query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
GET /projects GET /projects.json
def index q_param = params[:q] page = params[:page] per_page = params[:per_page] || 100 @q = Account.ransack q_param @accounts = @q.result.page(page).per(per_page) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def listprojects\n get('listprojects.json')['projects']\n end", "def list\n get 'projects'\n end", "def projects\n request(method: 'getAllProjects')\n end", "def projects\n resource 'projects'\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n e...
[ "0.8574897", "0.8386689", "0.8355737", "0.8062607", "0.80368364", "0.8002139", "0.78593457", "0.7834634", "0.78324", "0.7799698", "0.77792805", "0.7748103", "0.77139485", "0.7700251", "0.7696023", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", ...
0.0
-1
GET /projects/1 GET /projects/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n get 'projects'\n end", "def listprojects\n get('listprojects.json')['projects']\n end", "def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def projects\n...
[ "0.7868971", "0.76979554", "0.7680216", "0.7611453", "0.75334454", "0.75258976", "0.74926496", "0.74926496", "0.74926496", "0.74926496", "0.74926496", "0.74926496", "0.74926496", "0.74924207", "0.7484109", "0.7479275", "0.7444873", "0.74294627", "0.74224764", "0.7414947", "0....
0.0
-1
POST /projects POST /projects.json
def create end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new...
[ "0.7338948", "0.73139244", "0.7308003", "0.7299582", "0.7227503", "0.7225945", "0.71982473", "0.71170384", "0.7104803", "0.7095263", "0.7070636", "0.70408624", "0.70358187", "0.7024969", "0.70191896", "0.7009597", "0.698481", "0.697517", "0.6963753", "0.6963096", "0.6948756",...
0.0
-1
PATCH/PUT /projects/1 PATCH/PUT /projects/1.json
def update end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def update\n authorize! :update, @project\n\n if @project.update(project_params)\n head :no_content\n else\...
[ "0.70004326", "0.69119745", "0.6911138", "0.6889052", "0.6888448", "0.6878091", "0.68675476", "0.6857582", "0.685334", "0.685334", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68...
0.0
-1
DELETE /projects/1 DELETE /projects/1.json
def destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pr...
[ "0.78951", "0.78593713", "0.7778056", "0.7771693", "0.77585995", "0.7730887", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77244985", "0.7718401", "0.7718401", "0.7718401", "0.7718401", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_project @project = Project.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def project_params params.require(:account).permit(:is_eligable, :is_registered) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
get this would normally have a form view to make a new url
def new @url = Url.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url\n end", "def to(url); end", "def edit\n session[:return_to] ||= request.referer\n @Urlmaster = Urlmaster.find(params[:id])\n end", "def new\n @page_title = 'New URL'\n @url = ShortenUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render jso...
[ "0.65918636", "0.6569572", "0.6503145", "0.6468078", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", "0.6433631", ...
0.6122127
44
post would accept form data from the new view
def create url = Url.create(params[:url]) redirect_to urls_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def POST; end", "def new\n respond_with(@post)\n end", "def new\n respond_with @post\n end", "def post\r\n end", "def form_view\n end", "def form\n end", "def post\n end", "def post; end", "def create \n #render plain: params[:post].inspect\n @post = Post.new(post_params) #...
[ "0.72150147", "0.70573664", "0.7024402", "0.6957369", "0.6776068", "0.6742947", "0.66835546", "0.66584283", "0.650927", "0.64824015", "0.64713037", "0.64713037", "0.64713037", "0.64713037", "0.64462554", "0.6421328", "0.63944113", "0.6359852", "0.63273907", "0.63062555", "0.6...
0.0
-1
Only allow a list of trusted parameters through.
def document_params params.require(:doc_file).permit(:data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
GET /relations GET /relations.json
def index if session[:user] != nil if (User.where(name: session[:user]).first).role != 0 me = User.where(name: session[:user]).first @relations = Relation.where('user1_id = ? OR user2_id = ?', me, me) else @relations = Relation.all end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_relations_referring_to_object(type, id)\n api_call_with_type(type, id, \"#{type}/#{id}/relations\")\n end", "def relations\n _relations\n end", "def relations\n _relations\n end", "def relations\n @relations ||= {}\n end", "def get_relation(args)\n\tapi...
[ "0.76649773", "0.73452705", "0.73452705", "0.7206631", "0.71788263", "0.71153605", "0.7097382", "0.7040563", "0.6891425", "0.6833073", "0.67859524", "0.67443615", "0.67295223", "0.6718496", "0.67149585", "0.6706494", "0.6630044", "0.6630044", "0.65891963", "0.6551609", "0.650...
0.0
-1
GET /relations/1 GET /relations/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_relations_referring_to_object(type, id)\n api_call_with_type(type, id, \"#{type}/#{id}/relations\")\n end", "def get_relation(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}/relations/#{args[:relation]}\"\n\tdo_the_get_call( url: api_url, user: @user )\nend", "def...
[ "0.7504887", "0.73537993", "0.720369", "0.7179545", "0.7179545", "0.6951257", "0.68535554", "0.6713202", "0.6704042", "0.6693183", "0.6654969", "0.6654969", "0.6635389", "0.65769684", "0.65248525", "0.6416955", "0.6393167", "0.6384109", "0.6350153", "0.6346643", "0.6325167", ...
0.0
-1
POST /relations POST /relations.json
def create @relation = Relation.new(relation_params) name1 = @relation.user1_id name2 = @relation.user2_id user1 = User.where(name: name1).first user2 = User.where(name: name2).first @relation = Relation.create(user1_id: user1.id, user2_id: user2.id, status: 0) respond_to do |format| if @relation.save format.html { redirect_to @relation, notice: 'Relation was successfully created.' } format.json { render :show, status: :created, location: @relation } else format.html { render :new } format.json { render json: @relation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_relation\n #add relation\n @word.word_roots.create(@word_root)\n respond_to do |format|\n format.js\n end\n end", "def relation_params\n params.require(:relation).permit(:user_id, :friend_id)\n end", "def create\n @relation = Relation.new(relation_params)\n\n respond_to ...
[ "0.6698783", "0.6452547", "0.6425456", "0.6410771", "0.6223413", "0.61852455", "0.61304104", "0.6125933", "0.61115205", "0.6019417", "0.6008763", "0.59798807", "0.5969094", "0.596323", "0.5960743", "0.589646", "0.58872426", "0.5861519", "0.57996064", "0.57966375", "0.57899326...
0.6018088
10
PATCH/PUT /relations/1 PATCH/PUT /relations/1.json
def update respond_to do |format| if @relation.update(relation_params) format.html { redirect_to @relation, notice: 'Relation was successfully updated.' } format.json { render :show, status: :ok, location: @relation } else format.html { render :edit } format.json { render json: @relation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n begin\n @resource = Relation.find params[:id]\n @resource.update_attributes!(params[:relation])\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def update\n relationship = Relationshi...
[ "0.6880368", "0.6605103", "0.65462255", "0.63583416", "0.6325468", "0.63048434", "0.616476", "0.6092026", "0.60556364", "0.60269153", "0.5955914", "0.59391123", "0.59208995", "0.5866268", "0.5860552", "0.5818152", "0.5790238", "0.5784563", "0.5773039", "0.5761265", "0.5721474...
0.63545454
4
DELETE /relations/1 DELETE /relations/1.json
def destroy if @relation.user1_id == @currentUser.id or @currentUser.role == 0 @relation.destroy respond_to do |format| format.html { redirect_to relations_url, notice: 'Relation was successfully destroyed.' } format.json { head :no_content } end else redirect_to relations_url, notice: 'You cant revoke anothers users queries' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @relation = Relation.find(params[:id])\n @relation.destroy\n\n respond_to do |format|\n format.html { redirect_to relations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @relation.destroy\n respond_to do |format|\n format.html { redirect_to ...
[ "0.76680166", "0.7349601", "0.71940434", "0.6980938", "0.6924732", "0.6881415", "0.67720175", "0.67577136", "0.667264", "0.6663593", "0.6651822", "0.66421074", "0.6634024", "0.6624969", "0.66126865", "0.66126865", "0.6562891", "0.65532494", "0.6552323", "0.6551405", "0.652803...
0.63310724
35
Use callbacks to share common setup or constraints between actions.
def set_relation @relation = Relation.find(params[:id]) @currentUser = User.where(name: session[:user]).first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def relation_params params.require(:relation).permit(:user1_id, :user2_id, :status) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Interview Problem Candidate given two intervals described each by two numbers on a number line, find the intersect and the section of each interval with no overlap let a range be [l, r] for [left, right]
def valid?(range) range[0] < range[1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersection_of(range_a, range_b)\n range_a, range_b = [range_a, range_b].sort_by(&:begin)\n return if range_a.end < range_b.begin\n heads_and_tails = [range_a.begin, range_b.begin, range_a.end, range_b.end].sort\n middle = heads_and_tails[1..-2]\n middle[0]..middle[1]\n end", "def rec_inters...
[ "0.7381147", "0.7220778", "0.71983415", "0.70048034", "0.6994546", "0.6978018", "0.6960054", "0.68424785", "0.68065727", "0.67823124", "0.67188334", "0.66775256", "0.66387403", "0.6632962", "0.6558203", "0.6479933", "0.64468604", "0.643191", "0.6414687", "0.6394847", "0.63589...
0.0
-1
Hill: find the minimum X such that given an array you can make it strictly ascending by adding or subtracting up to X to each element.
def hill(v) flat = [] v.each_with_index do |el, i| flat << el - i end value = 0 low = flat[0] high = flat[0] flat.each_with_index do |el| if el < low low = el elsif el > high high = el low = el end new_val = high - low value = new_val if new_val > value end (value + 1) / 2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def better_my_min(array)\n array.inject do |acc, ele|\n if acc <= ele\n acc\n else\n ele\n end\n end\n end", "def my_min_v2(array)\n minimum = array.first\n\n array[1..-1].each do |element|\n minimum = element if minimum > eleme...
[ "0.76129997", "0.74145097", "0.73758173", "0.7367551", "0.7359541", "0.7330479", "0.7317693", "0.7302399", "0.72603536", "0.72531956", "0.72435087", "0.7218045", "0.7207991", "0.71793324", "0.71555924", "0.71309173", "0.7127069", "0.7107026", "0.706305", "0.70531857", "0.7046...
0.0
-1
Challenge 5: Maximum Difference Given an array of integer elements, a subsequence of this array is a set of consecutive elements from the array (i.e: given the array v: [7, 8, 3, 5, 1], a subsequence of v is 8, 3, 5) Your task is to write a function that finds a left and a right subsequence of the array that satisfy the following conditions the two subsequences are unique (they don't have shared elements) the difference between the sum of the elements in the right subsequence and the sum of the elements in the left subsequence is maximum print the difference to the standard output (stdout) Note that your function will receive the following arguments: v which is the array of integers Data constraints the array has at least 2 and at most 1,000,000 numbers all the elements in the array are integer numbers in the following range: [1000, 1000] given an array and a starting index, return whether or not you can get to a zero by jumping forwards or backwards in the array by the numbers you land on
def can_win(array, index) positions_to_try = [index] visited = [] until positions_to_try.empty? pos = positions_to_try.shift value = array[pos] next if value.nil? || visited[pos] return true if value == 0 visited[pos] = true positions_to_try << pos + value positions_to_try << pos - value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def maximum_difference_2(v)\n\n integral_sum = [0]\n max = 0\n for index in (0..v.length-1) do\n integral_sum.push(integral_sum[index] + v[index])\n end\n\n for seq_len_left in (1..v.length-1) do\n for left_side in (0..(v.length-seq_len_left-1)) do\n sum_l = integral_sum[seq_len_left+left_side] - i...
[ "0.7730241", "0.76064557", "0.74778116", "0.74468887", "0.73017704", "0.6956514", "0.6944656", "0.6921782", "0.68170035", "0.67708206", "0.67589134", "0.6756629", "0.6733883", "0.6725273", "0.67202836", "0.67056674", "0.6687934", "0.6671229", "0.66570085", "0.6646567", "0.664...
0.0
-1
TODO: Given an array of integers, find the two subsequences that are disjoint and contiguous such that the difference of their sums is maximized.
def disjoint_attempt(arr) part = [0] maxPrev = [0] maxLeft = [] minPrev = [0] minLeft = [] max = 0 # main idea: subsequence sum is partial sum at end minus partial # sum at start. Max score is thus either # maxLeft[i] + maxPrev[i] - 2 * part[i] or # - minLeft[i] - minPrev[i] + 2 * part[i] # for some i # calculate partial sums up to each index in the array # calculate max of these seen so far at each index arr.each_with_index do |el, i| k = i + 1 part[k] = part[i] + el maxPrev[k] = [maxPrev[i], part[k]].max minPrev[k] = [minPrev[i], part[k]].min end maxLeft[arr.size] = part[arr.size] minLeft[arr.size] = part[arr.size] # calculate max partial sum remaining at each index # now that we have enough info, update max score arr.size.downto(1) do |i| k = i - 1 maxLeft[k] = [maxLeft[i], part[k]].max minLeft[k] = [minLeft[i], part[k]].min max = [max, maxLeft[i] + maxPrev[i] - 2 * part[i], 0 - minLeft[i] - minPrev[i] + 2 * part[i]].max end # loop doesn't catch this max = [max, maxLeft[0] + maxPrev[0] - 2 * part[0], 0 - minLeft[0] - minPrev[0] + 2 * part[0]].max return max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def largest_contiguous_subsum(arr)\n i = 0\n subs = []\n while i < arr.length\n j = i\n\n while j < arr.length\n subs << arr[i..j]\n\n j += 1\n end\n\n i += 1\n end\n\n\n return (subs.max {|a, b| a.sum <=> b.sum}).sum\n\nend", "def largest_contiguo...
[ "0.7588492", "0.7526391", "0.7478525", "0.7438863", "0.74315846", "0.7416461", "0.736408", "0.734911", "0.7346965", "0.730636", "0.7294165", "0.72899026", "0.7286098", "0.72835416", "0.72739893", "0.7273657", "0.7267079", "0.7222528", "0.7209317", "0.71969265", "0.7192207", ...
0.79555225
0
time: O(n^2), space: O(n)
def is_shuffle?(str1, str2, str3) return false unless str1.size + str2.size == str3.size seen = {} considering = [[0, 0]] str3.each_char do |chr| next_gen = [] considering.each do |pair| next if seen[pair] seen[pair] = true idx1, idx2 = pair next_gen << [idx1 + 1, idx2] if str1[idx1] == chr next_gen << [idx1, idx2 + 1] if str2[idx2] == chr end considering = next_gen end !considering.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\...
[ "0.71603787", "0.6699279", "0.66349244", "0.6444679", "0.6424871", "0.63408345", "0.6330529", "0.6330144", "0.6315709", "0.6283777", "0.6225761", "0.6224092", "0.62086004", "0.6178786", "0.6167653", "0.6160198", "0.6156636", "0.6155491", "0.61404717", "0.61083657", "0.6090492...
0.0
-1
time to parse some lisp input: string with newlines and tabs output: parens around function blocks iterate through characters in the string there are several states the parser can be in the token counting state, where line tokens are counted up and tabs are counted the tab counting state, where tabs are being read to determine the structure of the following line the ("[ state, where a stack is built up, newlines, tabs, and spaces are ignored, and only one token is being created the backslash state, where the following character is ignored
def parse_lisp(str) # TODO: handle the tab tree and resulting token structure depth_stack = [] # can have (, ", and [ current_token = nil state_stack = [] state = "token counting" tab_count = 0 str.each_char do |char| current_token << char if state == "tab counting" && char != "\t" # do stuff with tabs and structure tab_count = 0 end if char == "\\" state = "backslash" else case state when "token counting" when "tab counting" when "within paren, quote, or bracket" case char when ")" depth_stack.pop if depth_stack[-1] == '(' when "]" depth_stack.pop if depth_stack[-1] == '[' when '"' depth_stack.pop if depth_stack[-1] == '"' else if "([".include?(char) depth_stack << char else end end when "backslash" state = state_stack.pop end end end puts pre_parse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse str\n self.ss = scanner_class.new str\n self.lineno = 1\n self.start_of_current_line_pos = 0\n self.state ||= nil\n\n do_parse\n end", "def parse str\n self.ss = scanner_class.new str\n self.lineno = 1\n self.start_of_current_line_pos = 0\n self.state ||= nil\n\n ...
[ "0.62273145", "0.62273145", "0.61859584", "0.60420746", "0.5964846", "0.5865738", "0.5865738", "0.5865738", "0.5865738", "0.58180296", "0.5816488", "0.57989705", "0.57957935", "0.5783337", "0.5772337", "0.5763411", "0.5749674", "0.57179713", "0.57089925", "0.57087326", "0.570...
0.6894451
0
garante que sera usando um 'Range' ou 'Array' para meses e anos na importacao. Se vier um unico valor sera criado um range com apenas ele.
def validate_range(value) classname = value.class.to_s case classname when "Range" then value when "Array" then value else return (value..value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def m_range\r\n end", "def to_range\n Range.new(self.start, self.end)\n end", "def range\n unless value.is_a? Range\n errors.add(:value, :range)\n end\n end", "def range; end", "def range; end", "def range; end", "def range\n @range ||= set_range\n end", "def range(arr)\n\nen...
[ "0.6830491", "0.6825375", "0.67711097", "0.67022", "0.67022", "0.67022", "0.6673403", "0.66349554", "0.66348237", "0.6590816", "0.6523634", "0.65096164", "0.642427", "0.6422655", "0.63773715", "0.63382196", "0.6328013", "0.6308158", "0.6302805", "0.6293935", "0.6293847", "0...
0.6750199
3
Common base command for Local/Push/Pull
def rsync_command utility(:rsync).dup << archive_option << mirror_option << exclude_option << " #{Array(additional_rsync_options).join(" ")}".rstrip end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(cmd); end", "def pull; end", "def remotes_action(command, id, host, action, remote_dir, std_in=nil)\n super(command,id,host,ACTION[action],remote_dir,std_in)\n end", "def push\n hg 'push'\n end", "def push(arg='')\n `git push #{arg} 2>&1`\n end", "def sync\n pull && pu...
[ "0.68151647", "0.622344", "0.6195468", "0.6187363", "0.6181452", "0.6162007", "0.61189204", "0.60621804", "0.60489327", "0.59954864", "0.5980596", "0.59374505", "0.5903741", "0.5845923", "0.58328164", "0.58097005", "0.5806688", "0.57864654", "0.5780313", "0.57355386", "0.5712...
0.0
-1
Each path is expanded, since these refer to local paths and are being shellquoted. This will also remove any trailing `/` from each path, as we don't want rsync's "trailing / on source directories" behavior. This method is used by RSync::Local and RSync::Push.
def paths_to_push directories.map { |dir| "'#{File.expand_path(dir)}'" }.join(" ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def relativize_paths(paths)\n return paths unless relativize_paths?\n paths.map do |path|\n path.gsub(%r{^#{@directory}/}, '')\n end\n end", "def cleanup_paths(*paths)\n #.gsub(%r{#{@locations[:root]}/#{@locations[:root]}}, @locations[:root])\n paths.join('/').gsub(/[\\/]{2,}/,'/')...
[ "0.6812318", "0.6662711", "0.64938563", "0.64875567", "0.6461957", "0.64167035", "0.6322109", "0.6319573", "0.62081707", "0.6161062", "0.61464655", "0.6045176", "0.6031419", "0.5928399", "0.5923", "0.59223986", "0.5892843", "0.5880533", "0.58543104", "0.5844329", "0.58434963"...
0.5694741
27
Return the number of positive amino acids (R and K) in an AA sequence.
def num_pos @num_neg ||= @seq.count("RK") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def acidic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n ACIDIC_AMINO_ACIDS.each do |acidic|\n if comp[acidic]\n count += comp[acidic]\n end\n end\n return count\n end", "def basic_count(amino_acid_sequence)\n count = 0\n...
[ "0.7483294", "0.74113756", "0.71197534", "0.6365894", "0.62830573", "0.6223864", "0.6124915", "0.5964618", "0.5955391", "0.59027463", "0.59025335", "0.585989", "0.5812948", "0.57828134", "0.57761735", "0.5698144", "0.5671942", "0.5661504", "0.56376785", "0.5630795", "0.560748...
0.599255
7
Return the number of residues in an AA sequence.
def amino_acid_number @seq.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def acidic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n ACIDIC_AMINO_ACIDS.each do |acidic|\n if comp[acidic]\n count += comp[acidic]\n end\n end\n return count\n end", "def basic_count(amino_acid_sequence)\n count = 0\n...
[ "0.73948544", "0.7297782", "0.69801915", "0.6814103", "0.5902533", "0.5879276", "0.57900685", "0.5719953", "0.5716063", "0.5603393", "0.5584541", "0.55838674", "0.5531532", "0.5525034", "0.55025285", "0.55020696", "0.5500859", "0.5495017", "0.54446185", "0.543454", "0.5386478...
0.65121734
4
Return the number of atoms in a sequence. If type is given, return the number of specific atoms in a sequence.
def total_atoms(type=nil) if !type.nil? type = type.to_sym if /^(?:C|H|O|N|S){1}$/ !~ type.to_s raise ArgumentError, "type must be C/H/O/N/S/nil(all)" end end num_atom = {:C => 0, :H => 0, :O => 0, :N => 0, :S => 0} each_aa do |aa| ATOM[aa].each do |t, num| num_atom[t] += num end end num_atom[:H] = num_atom[:H] - 2 * (amino_acid_number - 1) num_atom[:O] = num_atom[:O] - (amino_acid_number - 1) if type.nil? num_atom.values.inject(0){|prod, num| prod += num } else num_atom[type] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quantity(type=NonEmpty)\n grep(type).inject(0){ |sum, spot| sum + spot.item.count }\n end", "def countAtoms(seq)\n\t\t\t\to = 0\n\t\t\t\tn = 0\n\t\t\t\tc = 0\n\t\t\t\th = 0\n\t\t\t\ts = 0\n\t\t\t\tp = 0\n\t\t\t\tse = 0\n\t\t\t\tseq.each_char do |aa|\n\t\t\t\t\to = o + MS::Feature::AA::ATOM_COUNTS[aa]...
[ "0.63567305", "0.63145524", "0.61980516", "0.60390794", "0.59796715", "0.5946256", "0.5850562", "0.5831301", "0.58186245", "0.5765675", "0.5749233", "0.56758785", "0.56386787", "0.56018287", "0.5587829", "0.55661076", "0.5442579", "0.5369471", "0.53659385", "0.53339356", "0.5...
0.68754864
0
Return the number of carbons.
def num_carbon @num_carbon ||= total_atoms :C end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def car_count\n self.cars.length\n end", "def show_cars_count\n puts \"cars count: #{cars.size}\"\n end", "def show_cars_count\n puts \"cars count: #{self.cars.size}\"\n end", "def num_bombs\n count = 0\n (0...9).each do |ro|\n (0...9).each do |co|\n if @gr...
[ "0.7277891", "0.71840256", "0.71306664", "0.7058281", "0.65940386", "0.65794706", "0.6518702", "0.64791226", "0.6458497", "0.6451858", "0.6451858", "0.64388806", "0.64099425", "0.64028925", "0.6386796", "0.6382967", "0.63799137", "0.63799137", "0.6376489", "0.6376489", "0.637...
0.5889996
80
Return the number of nitrogens.
def num_nitro @num_nitro ||= total_atoms :N end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_concept_genres(login=nil)\n count_by_frbr(login, :has_as_its_genre, :how_many_concepts?) \n end", "def number_of_concept_genres(login=nil)\n count_by_frbr(login, :has_as_its_genre, :how_many_concepts?) \n end", "def count\n count = 0\n\n each do |node|\n ...
[ "0.68646866", "0.68646866", "0.6578251", "0.6530618", "0.64941645", "0.6474515", "0.6474515", "0.64725417", "0.6360934", "0.63361204", "0.63211834", "0.63211834", "0.63051116", "0.62940323", "0.6272964", "0.62563336", "0.6251159", "0.6243836", "0.6237959", "0.62242717", "0.62...
0.7361511
0
Return the number of oxygens.
def num_oxygen @num_oxygen ||= total_atoms :O end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size\n @gens.size\n end", "def size\n @gens.size\n end", "def lots_count\t\t\n lots.count\n end", "def length\n @gens.length\n end", "def length\n @gens.length\n end", "def nb_opinions() opinion_ids.size end", "def count\n @ole.Count\n end", "def c...
[ "0.6822128", "0.6822128", "0.6805353", "0.6792886", "0.6792886", "0.671845", "0.66310984", "0.66310984", "0.66310984", "0.66310984", "0.66310984", "0.66310984", "0.66310984", "0.66310984", "0.6570404", "0.6523384", "0.65066195", "0.6486188", "0.6468808", "0.6466652", "0.64594...
0.6822373
0
Return the number of sulphurs.
def num_sulphur @num_sulphur ||= total_atoms :S end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_susus_global\n susus = Susu.all.count\n end", "def how_many\n return @@total_samurais\n end", "def spicy_count\n self.spicies.size\n end", "def dinosaurii_count\n @@count += 1\n end", "def num_shelf\n\t\tputs \"Library has #{@shelves.length} shelves\"\n\tend", "def...
[ "0.6834224", "0.6822347", "0.679203", "0.6628784", "0.6579925", "0.6576353", "0.65345216", "0.6468602", "0.6458979", "0.6440525", "0.63977396", "0.6358515", "0.63417405", "0.63160545", "0.6304613", "0.6304613", "0.6304613", "0.6280699", "0.6275606", "0.62723404", "0.6271254",...
0.81454146
0
Calculate molecular weight of an AA sequence. _Protein Mw is calculated by the addition of average isotopic masses of amino acids in the protein and the average isotopic mass of one water molecule._
def molecular_weight @mw ||= begin mass = WATER_MASS each_aa do |aa| mass += AVERAGE_MASS[aa.to_sym] end (mass * 10).floor().to_f / 10 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def molecular_weight\n Bio::AminoAcid.weight(self)\n end", "def weight\n @mass * @hopper.size\n end", "def calculateWeight word\n letters = word.split\n weight = 0\n hash_alphabet = generateHashWithLetterAndWeight()\n letters.each do |letter|\n (/[[:upper:]]/.match(letter)) ? weight...
[ "0.7229752", "0.60174626", "0.59964734", "0.5925158", "0.5860306", "0.57346463", "0.5703239", "0.5697059", "0.56761897", "0.5663131", "0.5591569", "0.55661243", "0.5384147", "0.53690857", "0.5359473", "0.5354546", "0.53224325", "0.53134286", "0.52998465", "0.5292222", "0.5282...
0.71202606
1
Claculate theoretical pI for an AA sequence with bisect algorithm. pK value by Bjelqist, et al. is used to calculate pI.
def theoretical_pI charges = [] residue_count().each do |residue| charges << charge_proc(residue[:positive], residue[:pK], residue[:num]) end round(solve_pI(charges), 2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def p(i, j, k)\n n = neighbours(i, k)\n if n.include?(j) then\n this_move_value = 0.0\n other_possible_moves_summed_value = 0.0\n @state.transaction do\n this_move_value = @state[:trails][[i, j]]\n other_possible_moves_summed_value = n.in...
[ "0.5462763", "0.5442878", "0.5347153", "0.5302049", "0.5289266", "0.51673424", "0.51580364", "0.514113", "0.5125691", "0.5110864", "0.51021624", "0.5093386", "0.50421435", "0.49688026", "0.4938162", "0.49120304", "0.4909912", "0.4881527", "0.48788646", "0.48482218", "0.484738...
0.5590275
0
Return estimated half_life of an AA sequence. _The halflife is a prediction of the time it takes for half of the amount of protein in a cell to disappear after its synthesis in the cell. ProtParam relies on the "Nend rule", which relates the halflife of a protein to the identity of its Nterminal residue; the prediction is given for 3 model organisms (human, yeast and E.coli)._
def half_life(species=nil) n_end = @seq[0].chr.to_sym if species HALFLIFE[species][n_end] else { :ecoli => HALFLIFE[:ecoli][n_end], :mammalian => HALFLIFE[:mammalian][n_end], :yeast => HALFLIFE[:yeast][n_end] } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_expected_dominant_offspring(xAA_AA, xAA_Aa, xAA_aa, xAa_Aa, xAa_aa, xaa_aa, offspring_each = 2)\r\n xAA_AA_prob = offspring_each.to_f * xAA_AA * 1 \r\n xAA_Aa_prob = offspring_each.to_f * xAA_Aa * 1 \r\n xAA_aa_prob = offspring_each.to_f * xAA_aa * 1 \r\n xAa_Aa_prob = offspring_each.to_f...
[ "0.5435176", "0.5106106", "0.51055604", "0.5099969", "0.5079222", "0.49448442", "0.49448442", "0.49408907", "0.49173385", "0.49081874", "0.48839054", "0.4853226", "0.4842884", "0.48420635", "0.48389047", "0.48318678", "0.4829914", "0.4829279", "0.48252252", "0.48178998", "0.4...
0.6273526
0
Calculate instability index of an AA sequence. _The instability index provides an estimate of the stability of your protein in a test tube. Statistical analysis of 12 unstable and 32 stable proteins has revealed [7] that there are certain dipeptides, the occurence of which is significantly different in the unstable proteins compared with those in the stable ones. The authors of this method have assigned a weight value of instability to each of the 400 different dipeptides (DIWV)._
def instability_index @instability_index ||= begin instability_sum = 0.0 i = 0 while @seq[i+1] != nil aa, next_aa = [@seq[i].chr.to_sym, @seq[i+1].chr.to_sym] if DIWV.key?(aa) && DIWV[aa].key?(next_aa) instability_sum += DIWV[aa][next_aa] end i += 1 end round((10.0/amino_acid_number.to_f) * instability_sum, 2) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aliphatic_index\n aa_map = aa_comp_map\n @aliphatic_index ||= round(aa_map[:A] +\n 2.9 * aa_map[:V] +\n (3.9 * (aa_map[:I] + aa_map[:L])), 2)\n end", "def ig_ind\n\t\taibc(@datos[0]).each_with_index.map{ |ind, i| (ind/aib...
[ "0.64629894", "0.61294776", "0.5818332", "0.5763177", "0.56234854", "0.5593739", "0.5575883", "0.5564423", "0.5524716", "0.53492093", "0.5343286", "0.5320034", "0.52854216", "0.5278959", "0.5276254", "0.5217866", "0.52151525", "0.5093001", "0.508744", "0.50860256", "0.5084812...
0.8551031
0
Return wheter the sequence is stable or not as String (stable/unstable). _Protein whose instability index is smaller than 40 is predicted as stable, a value above 40 predicts that the protein may be unstable._
def stability (instability_index <= 40) ? "stable" : "unstable" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stable?\n (instability_index <= 40) ? true : false\n end", "def complete?\n return nil unless ivsat_table\n line = ivsat_table.split(\"\\n\").find{|l| l.include? 'INFO: Sequence completeness:' }\n line && !line.include?('partial')\n end", "def assess_insurance()\n\t\tvalues = self.comb_va...
[ "0.59346", "0.55109864", "0.5359347", "0.5294463", "0.5180834", "0.51680654", "0.5112167", "0.51115215", "0.51037943", "0.50916517", "0.50392485", "0.4972031", "0.49627674", "0.49081233", "0.4901036", "0.48808068", "0.4855916", "0.4855916", "0.4855916", "0.48397312", "0.48253...
0.6345953
0
Return true if the sequence is stable.
def stable? (instability_index <= 40) ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stable\n self[:draft] == false && self[:prerelease] == false\n end", "def sequential\n return true if hand_to_val.last - hand_to_val.first == 4\n return false \n end", "def consistent?\n return @grammar.consistent?\n end", "def empty_sequence?\n false\n end", ...
[ "0.6626637", "0.6512906", "0.6167755", "0.6158894", "0.61111784", "0.6092307", "0.60544586", "0.60181403", "0.60051495", "0.60025716", "0.59646", "0.59554505", "0.58984464", "0.5885162", "0.5823181", "0.58019644", "0.5774902", "0.5761803", "0.57541203", "0.57541203", "0.57134...
0.6803989
0
Calculate aliphatic index of an AA sequence. _The aliphatic index of a protein is defined as the relative volume occupied by aliphatic side chains (alanine, valine, isoleucine, and leucine). It may be regarded as a positive factor for the increase of thermostability of globular proteins._
def aliphatic_index aa_map = aa_comp_map @aliphatic_index ||= round(aa_map[:A] + 2.9 * aa_map[:V] + (3.9 * (aa_map[:I] + aa_map[:L])), 2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def instability_index\n @instability_index ||=\n begin\n instability_sum = 0.0\n i = 0\n while @seq[i+1] != nil\n aa, next_aa = [@seq[i].chr.to_sym, @seq[i+1].chr.to_sym]\n if DIWV.key?(aa) && DIWV[aa].key?(next_aa)\n instability_sum += DIWV...
[ "0.6621182", "0.6333505", "0.6068041", "0.6020737", "0.59023076", "0.58319247", "0.56881386", "0.5607501", "0.55861014", "0.5583739", "0.5526599", "0.55243194", "0.5512173", "0.5501506", "0.5465918", "0.5452043", "0.5447528", "0.5445903", "0.5329291", "0.53167236", "0.5311475...
0.77311355
0
Calculate GRAVY score of an AA sequence. _The GRAVY(Grand Average of Hydropathy) value for a peptide or protein is calculated as the sum of hydropathy values [9] of all the amino acids, divided by the number of residues in the sequence._
def gravy @gravy ||= begin hydropathy_sum = 0.0 each_aa do |aa| hydropathy_sum += HYDROPATHY[aa] end round(hydropathy_sum / @seq.length.to_f, 3) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_gpa\n tot_grade_points/tot_graded_attmp rescue 0.0/0.0\n end", "def get_gpa\n total = registrations.where('grade is not null').inject(0){|sum, c| sum + c.grade}\n if total != 0\n # binding.pry\n final_gpa = total.to_f / (self.registrations.where('grade is not null').count).to_f\n ...
[ "0.60018265", "0.5839094", "0.5787341", "0.565506", "0.55642915", "0.55627733", "0.5533933", "0.55288666", "0.55063254", "0.54518044", "0.54405046", "0.54323685", "0.5411593", "0.5410152", "0.53939104", "0.5326942", "0.5324399", "0.53011346", "0.5292673", "0.526699", "0.52649...
0.7091364
0
Calculate the percentage composition of an AA sequence as a Hash object. It return percentage of a given amino acid if aa_code is not nil.
def aa_comp(aa_code=nil) if aa_code.nil? aa_map = {} IUPAC_CODE.keys.each do |k| aa_map[k] = 0.0 end aa_map.update(aa_comp_map){|k,_,v| round(v, 1) } else round(aa_comp_map[aa_code], 1) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overall_aroma_percentage\n overall_aroma = self.aroma_bundles.inject(0) do |memo, bundle|\n memo += bundle.percent if bundle.percent.is_a?(Integer) || bundle.percent.is_a?(BigDecimal)\n memo\n end\n\n return overall_aroma\n end", "def calculate_percentage_completion\n result = {}\n ...
[ "0.57860136", "0.5707039", "0.5654985", "0.5577412", "0.55692405", "0.5556035", "0.5485852", "0.5466409", "0.5452387", "0.54397494", "0.53883076", "0.5377612", "0.5369018", "0.53582907", "0.5344103", "0.5330651", "0.5329907", "0.5329273", "0.5324464", "0.5321181", "0.53096193...
0.68882215
0
Return proc calculating charge of a residue.
def charge_proc positive, pK, num if positive lambda {|ph| num.to_f / (1.0 + 10.0 ** (ph - pK)) } else lambda {|ph| (-1.0 * num.to_f) / (1.0 + 10.0 ** (pK - ph)) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def charge\n subtotal * 0\n end", "def charge\n ((sprintf(\"%.1f\", (\n $ioreg_return.split(' = ')[15].strip.split(\"\\n\")[0].to_f / $ioreg_return.split(' = ')[9].strip.split(\"\\n\")[0].to_f )\n )).to_f*100).to_i\n end", "def theoretical_pI\n charges = []\n residue_count().ea...
[ "0.6225294", "0.5906098", "0.5820925", "0.5817745", "0.57494015", "0.5707212", "0.5559077", "0.54159015", "0.5376804", "0.53589404", "0.53589404", "0.53448075", "0.53445965", "0.52909523", "0.5265159", "0.524935", "0.5217298", "0.5191494", "0.5138116", "0.5102817", "0.5086883...
0.65045726
0
Transform AA sequence into residue count
def residue_count counted = [] # N-terminal n_term = @seq[0].chr if PK[:nterm].key? n_term.to_sym counted << { :num => 1, :residue => n_term.to_sym, :pK => PK[:nterm][n_term.to_sym], :positive => positive?(n_term) } elsif PK[:normal].key? n_term.to_sym counted << { :num => 1, :residue => n_term.to_sym, :pK => PK[:normal][n_term.to_sym], :positive => positive?(n_term) } end # Internal tmp_internal = {} @seq[1,(@seq.length-2)].each_byte do |x| aa = x.chr.to_sym if PK[:internal].key? aa if tmp_internal.key? aa tmp_internal[aa][:num] += 1 else tmp_internal[aa] = { :num => 1, :residue => aa, :pK => PK[:internal][aa], :positive => positive?(aa.to_s) } end end end tmp_internal.each do |aa, val| counted << val end # C-terminal c_term = @seq[-1].chr if PK[:cterm].key? c_term.to_sym counted << { :num => 1, :residue => c_term.to_sym, :pK => PK[:cterm][c_term.to_sym], :positive => positive?(c_term) } end counted end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def acidic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n ACIDIC_AMINO_ACIDS.each do |acidic|\n if comp[acidic]\n count += comp[acidic]\n end\n end\n return count\n end", "def basic_count(amino_acid_sequence)\n count = 0\n...
[ "0.7141778", "0.70089996", "0.68835706", "0.6433953", "0.5985886", "0.5922526", "0.5756015", "0.57402045", "0.56796736", "0.5613895", "0.5606639", "0.5547495", "0.55425197", "0.5510146", "0.54603595", "0.54540306", "0.5436752", "0.5427353", "0.5423404", "0.54028624", "0.53948...
0.7270198
0
Solving pI value with bisect algorithm.
def solve_pI charges state = { :ph => 0.0, :charges => charges, :pI => nil, :ph_prev => 0.0, :ph_next => 14.0, :net_charge => 0.0 } error = false # epsilon means precision [pI = pH +_ E] epsilon = 0.001 loop do # Reset net charge state[:net_charge] = 0.0 # Calculate net charge state[:charges].each do |charge_proc| state[:net_charge] += charge_proc.call state[:ph] end # Something is wrong - pH is higher than 14 if state[:ph] >= 14.0 error = true break end # Making decision temp_ph = 0.0 if state[:net_charge] <= 0.0 temp_ph = state[:ph] state[:ph] = state[:ph] - ((state[:ph] - state[:ph_prev]) / 2.0) state[:ph_next] = temp_ph else temp_ph = state[:ph] state[:ph] = state[:ph] + ((state[:ph_next] - state[:ph]) / 2.0) state[:ph_prev] = temp_ph end if (state[:ph] - state[:ph_prev] < epsilon) && (state[:ph_next] - state[:ph] < epsilon) state[:pI] = state[:ph] break end end if !state[:pI].nil? && !error state[:pI] else raise "Failed to Calc pI: pH is higher than 14" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def p_value(p, a, b, rmin = 0, rmax = 1)\n fail 'a <= 0' if a <= 0\n fail 'b <= 0' if b <= 0\n fail 'rmin == rmax' if rmin == rmax\n fail 'p <= 0' if p <= 0\n fail 'p > 1' if p > 1\n\n precision = 8.88e-016\n max_iterations = 256\n\n ga = 0\n ...
[ "0.614283", "0.5933399", "0.56879985", "0.56388", "0.5591578", "0.5515401", "0.545671", "0.5451235", "0.5417222", "0.53818583", "0.53731453", "0.5349993", "0.5303633", "0.52670103", "0.5259487", "0.5258435", "0.52548975", "0.524092", "0.52062017", "0.51943946", "0.5193879", ...
0.61282843
1
file. As a deterrent against cheating, when the game loads a save file it performs a simple check against the file's modification time. If it differs from the timestamp recorded inside the file, the game refuses to load the save file. The save_game method is responsible for recording the timestamp:
def save_game(file) score = 1000 open(file, "w") do |f| f.puts(score) f.puts(Time.new.to_i) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_game\n\t\t# If current game was previously saved, delete the old version of current game...\n\t\tif @running_saved_game != nil\n\t\t\tover_write_data\n\t\tend\n\t\t# And add new version of current game to saved data\n\t\tFile.open(@path, 'a+') do |f|\n\t\t\t\tf.puts \"#{@word.join},#{@guess},#{@wrong_lett...
[ "0.73074615", "0.72911596", "0.69355166", "0.68088514", "0.67271143", "0.66961", "0.6551119", "0.65485656", "0.65349394", "0.6527913", "0.6441509", "0.64391744", "0.6438206", "0.63551563", "0.6337121", "0.6307436", "0.6300116", "0.6267606", "0.62563145", "0.622857", "0.619127...
0.6833198
3
The load_game method is responsible for comparing the timestamp within the file to the time the filesystem has associated with the file. Write the load_game(file) method.
def load_game(file) raise "I suspect you of cheating." if File.mtime(file) != Time.at(File.readlines(file).last.to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_gamedata\n @time_stamp = Time.at(0)\n @file_exist = FileTest.exist?(@filename)\n if @file_exist\n file = File.open(@filename, \"r\")\n @time_stamp = file.mtime\n begin\n @characters = Marshal.load(file)\n @frame_count = Marshal.load(file)\n @last_bgm ...
[ "0.77167517", "0.727479", "0.72611916", "0.7061204", "0.6986792", "0.69377977", "0.685706", "0.6831958", "0.6797869", "0.67838186", "0.664105", "0.6372434", "0.63679725", "0.6291665", "0.6234307", "0.6166935", "0.6145533", "0.6017127", "0.60056835", "0.59807503", "0.5978757",...
0.80305064
0
Oauth specfic login method
def auth request.env['omniauth.auth'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oauth\n login_at(auth_params[:provider])\n end", "def oauth\n login_at(auth_params[:provider])\n end", "def oauth_authentication; end", "def http_auth_login\n # FIXME: Implement\n end", "def oauth_login oauth\n method = ::AuthMethod.by_provider_data oauth.provider_data\...
[ "0.8281184", "0.8281184", "0.81554186", "0.77170265", "0.7650618", "0.7426348", "0.7329483", "0.72815555", "0.72606593", "0.715163", "0.71176964", "0.7108532", "0.7086213", "0.7080806", "0.7065281", "0.7065281", "0.70414764", "0.70107776", "0.70107776", "0.70107776", "0.70107...
0.0
-1
Extra credit: write a function to calculate some other formula
def calculate_area_of_trapezoid(h,b1,b2) puts "Calculating the area of a trapezoid with height #{h}, top #{b1}, bottom #{b2}" multiply(divide(h, 2), add(b1, b2)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def formula() @ob.get_formula end", "def inverse_formula (a, b)\n return 2 * (a + 5 * b)\nend", "def calculation\n end", "def calc_t1(price, tip, tax)\n tax_amount = price * tax\n tip_amount = price * tip\n price + tip_amount + tax_amount\nend", "def calculated; end", "def calc_equation(x, y)\n r...
[ "0.71227455", "0.6990211", "0.6879419", "0.68395585", "0.6785403", "0.6698989", "0.66834563", "0.66183764", "0.65040666", "0.64839524", "0.64831805", "0.6469795", "0.64187896", "0.64091796", "0.6404391", "0.6380907", "0.63642734", "0.6345924", "0.6339137", "0.63385624", "0.63...
0.0
-1
initializer that will parse the configuration file that was passed in and makes it available via the instance variables
def initialize(configuration_file_location) @rules_location = "" file = File.new( configuration_file_location ) doc = REXML::Document.new file @rules_location = doc.elements["snortRulesAnalysisEngineConfiguration/rulesLocation"].text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @config = config_from_file || empty_config\n end", "def initialize\n\n # Set some defaults\n self.auth_location = 'usa'\n self.use_service_net = 'false'\n self.retention_days = 7\n\n config_file = find_config_file\n raise \"Unable to find configuration file\...
[ "0.8030183", "0.7928831", "0.7583291", "0.75449616", "0.74726194", "0.7442349", "0.74075323", "0.7381535", "0.73444533", "0.7335179", "0.7221417", "0.71948636", "0.7142813", "0.71253437", "0.7106711", "0.70752573", "0.7075207", "0.70208704", "0.7018089", "0.7011479", "0.70073...
0.674817
52
find note and parent picture, destroy then redirect back to artwork
def destroy @note = Note.find(params[:id]) @picture = @note.picture @artwork = @picture.artwork @note.destroy redirect_to @artwork end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n #need a redirect here\n redirect_back(fallback_location: root_path)\n #if artwork is no longer present fallback to the root\n end", "def destroy\n if @note\n @parent = @note.get_parent if @note\n @note.destroy\...
[ "0.73953956", "0.71886754", "0.66464704", "0.64856774", "0.6481065", "0.6458882", "0.6432985", "0.6409424", "0.6349936", "0.6347975", "0.6316039", "0.63066953", "0.62736166", "0.6269202", "0.6267368", "0.6244086", "0.6211219", "0.62053996", "0.6203089", "0.619996", "0.6199286...
0.75453204
0
defined strong params for notes
def note_params params.require(:note).permit(:content, :noteImgData, :noteImg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def note_params\n\t\tparams.require(:note).permit(:text, :author_id, :student_id)\n\tend", "def note_params\n\t\tparams.require(:note).permit(:text, :author_id, :student_id)\n\tend", "def notes_params\n params.require(:note).permit(:title, :author, :body)\n end", "def note_params\n params.require(:n...
[ "0.8095777", "0.8095777", "0.8080339", "0.8072689", "0.80465996", "0.8020872", "0.79912484", "0.7966443", "0.7966443", "0.79652786", "0.7953361", "0.7946721", "0.7938833", "0.7935312", "0.7931431", "0.7913021", "0.79067695", "0.79060334", "0.790305", "0.7878012", "0.7878012",...
0.7565081
54
For a recurrent network, this resets hidden states back to zero
def reset if config.isRecurrent @nn.resetRecurrentStates else puts "Warning not a recurrent network. This does nothing" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_state\n @hidden.data = @hidden.data.fill(0) if @hidden.data\n end", "def reset\n clear\n CONNECTION_TYPES.map { |ct| connections.send(ct) }.each do |conn_group|\n conn_group.each_value { |conn| conn.weight = rand * 0.2 - 0.1 }\n end\n\n @bias = rand * 0.2 - 0.1\n ...
[ "0.793131", "0.65126204", "0.6357723", "0.6288698", "0.62217224", "0.61153", "0.59013903", "0.5882676", "0.58755016", "0.5801405", "0.5768204", "0.575981", "0.5719362", "0.5677884", "0.56665677", "0.563799", "0.56377774", "0.5635372", "0.5632821", "0.5627946", "0.5625814", ...
0.7516543
1
TODO:fix logic, private id shadow business id
def seller seller_id = Product.find(params[:product_id]).owner_id begin if PrivateProfile.find_by_id(seller_id) redirect_to url_for(:controller => :private_profiles, :action => :show, :id => seller_id) return end end begin if BusinessProfile.find_by_id(seller_id) redirect_to url_for(:controller => :business_profiles, :action => :show, :id => seller_id) return end end render_404 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id_number; end", "def external_id; end", "def id() end", "def object_id() end", "def local_id; end", "def id_public\n id\n end", "def real_id\n @id\n end", "def real_id\n @id\n end", "def __id__() end", "def generate_id \n end", "def id; end", "def id; end", "def id; en...
[ "0.6937187", "0.6920891", "0.6897053", "0.68818897", "0.6853511", "0.6838446", "0.67880136", "0.67880136", "0.678048", "0.6696062", "0.66667944", "0.66667944", "0.66667944", "0.66667944", "0.66667944", "0.66667944", "0.66667944", "0.66667944", "0.66667944", "0.66667944", "0.6...
0.0
-1
Copies workflows to another scope.
def copy workflows = Workflow.accessible_by(@context).where(id: params[:item_ids]) new_workflows = workflows.map { |wf| copy_service.copy(wf, params[:scope]).first } # TODO: change old UI to handle json-response! respond_to do |format| format.html do redirect_to pathify(workflows.first), success: "The workflow has been published successfully!" end format.json { render json: new_workflows, root: "workflows", adapter: :json } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy\n workflows = Workflow.accessible_by(@context).where(id: params[:item_ids])\n\n new_workflows = workflows.map { |wf| copy_service.copy(wf, params[:scope]).first }\n\n # TODO: change old UI to handle json-response!\n respond_to do |format|\n format.html do\n redirect_to ...
[ "0.6871361", "0.57982564", "0.5650359", "0.5604749", "0.5523248", "0.55140465", "0.5383086", "0.5368381", "0.53668875", "0.5338356", "0.52970976", "0.5240788", "0.52288944", "0.5172689", "0.51283437", "0.51116115", "0.50960404", "0.50477606", "0.5039503", "0.50284374", "0.501...
0.6953001
0
noREST Methods confirm_payment_user_payment_reward_receivers POST /users/:user_id/payment/reward_receivers/:shipping_order_id/confirm_payment
def confirm_payment if @shipping_order.transacted redirect_to(:back) else if @shipping_order.update( status: 'Started' ) confirm_shipping_payment else flash[:error] = t('errors.messages.not_saved') redirect_to(:back) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_shipping_fee\n\t\t@reward = Reward.find(@reward_receiver.reward_id)\n\t\t#Select shipping amount based on different situiations\n\t\tif @reward.shippings.where(country: @reward_receiver.shipping_address.country).first\n\t\t\t@amount = @reward.shippings.where(country: @reward_receiver.shipping_address.c...
[ "0.64884776", "0.60414433", "0.59830576", "0.5975201", "0.59442484", "0.59240156", "0.58681536", "0.580634", "0.57849306", "0.576695", "0.573333", "0.56884193", "0.5626151", "0.5610683", "0.56017447", "0.55956084", "0.5595445", "0.5594523", "0.55937845", "0.55859315", "0.5584...
0.54854983
32
This is the actual action that ships the reward ship_reward_now_user_payment_reward_receivers POST
def ship_reward_now @reward_receiver = RewardReceiver.find(params[:reward_receiver_id]) @reward_receiver.update(reward_receiver_params) if @reward_receiver.update( status: "shipped" ) #Send email #Send notification #Add xp @user.add_score("ship_reward") end redirect_to show_user_studio_rewards_path(@reward_receiver.reward.user_id,@reward_receiver.reward_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_reward_action_params\n params.fetch(:user_reward_action, {})\n end", "def set_user_reward_action\n @user_reward_action = UserRewardAction.find(params[:id])\n end", "def rewardpurchase\n @reward = Reward.find(params[:id]).clone\n @rewardpurchase = @reward.rewardpurchases.create(pa...
[ "0.62571675", "0.6154065", "0.6122438", "0.6039495", "0.6003704", "0.59771526", "0.5963008", "0.5954132", "0.5932498", "0.59322613", "0.59250814", "0.5878585", "0.5833457", "0.5800626", "0.57559234", "0.57546043", "0.5743966", "0.572459", "0.5718811", "0.56481206", "0.5639043...
0.7573464
0
reward_receiver_router_user_payment_reward_receivers GET /users/:user_id/payment/reward_receivers/:reward_receiver_id/:reward_receiver_router/reward_receiver_router def reward_receiver_router case params[:reward_receiver_router] when 'request_shipping_fee' redirect_to request_shipping_fee_user_payment_reward_receivers_path(params[:user_id], params[:reward_receiver_id]) end end request_shipping_fee_user_payment_reward_receivers GET /users/:user_id/payment/reward_receivers/:reward_receiver_id/request_shipping_fee
def request_shipping_fee @reward = Reward.find(@reward_receiver.reward_id) #Select shipping amount based on different situiations if @reward.shippings.where(country: @reward_receiver.shipping_address.country).first @amount = @reward.shippings.where(country: @reward_receiver.shipping_address.country).first.amount else if @reward.shipping_anywhere @amount = @reward.shipping_anywhere.amount end end if @shipping_order = ShippingOrder.find_by_reward_receiver_id(@reward_receiver.id) else @shipping_order = ShippingOrder.create( user_id: @reward_receiver.user_id, amount: @amount, currency: @reward.currency, status: 'Sent', country: @reward_receiver.shipping_address.country, city: @reward_receiver.shipping_address.city, line1: @reward_receiver.shipping_address.line1, postal_code: @reward_receiver.shipping_address.postal_code, state: @reward_receiver.shipping_address.state, name: @reward_receiver.shipping_address.name, reward_id: @reward_receiver.reward_id, reward_receiver_id: @reward_receiver.id, due: 30.days.from_now ) end @reward_receiver.update( status: 'shipping_fee_request_sent' ) #Send order email Payment::ShippingOrdersMailer.send_confirmation(shipping_order_id: @shipping_order.id).deliver_now #Send order notification Notification.create( user_id: @reward_receiver.user_id, trackable_id: @shipping_order.id, trackable_type: "ShippingOrder", notification_type: "send_shipping_order_confirmation" ) redirect_to(:back) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_route_target server_type, msg, route_param, &block\n if @router_type\n router = case @router_type\n when :roundrobin\n method :rr_route\n when :weight_roundrobin\n method :wrr_route\n when :least_a...
[ "0.58377457", "0.5802118", "0.564564", "0.55723697", "0.54849094", "0.5454066", "0.54359776", "0.5412983", "0.53737605", "0.53597045", "0.5349736", "0.53322536", "0.532743", "0.53150374", "0.530132", "0.5287566", "0.52838707", "0.5251775", "0.52385974", "0.52003413", "0.51650...
0.5240686
18
Search the TISS REST API for the query
def search begin @theses = Thesis.search(params[:query]) if params[:query] rescue Searchable::SearchError => msg flash.now[:error] = msg rescue Searchable::NoSearchResults => msg flash.now[:notice] = msg end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Search query\n \n APICall(path: \"search.json?query=#{query}\",method: 'GET')\n \n end", "def scsearch(squery)\n\thttp = Net::HTTP.new(\"shell-storm.org\", 80)\n\treq = Net::HTTP::Get.new(\"/api/?s=#{squery.downcase}\", {'User-Agent' => 'Shell-Storm Ruby API - Search'})\n\tres = htt...
[ "0.7764589", "0.72229016", "0.71741825", "0.7070183", "0.7052473", "0.69716257", "0.69406587", "0.6938641", "0.6921789", "0.6898469", "0.684355", "0.68409854", "0.6797582", "0.6792282", "0.6767056", "0.6765203", "0.6751859", "0.6746635", "0.66900384", "0.6680971", "0.6678334"...
0.644545
43
Show the given thesis with the given tiss_id
def show @thesis = Thesis.load params[:id] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_thesis\n @thesis = Thesis.find(params[:id])\n end", "def display_resource(thesis)\n \"Thesis: #{thesis.title}\"\n end", "def show\n @issuance = Issuance.where(id: params[:id]).first\n end", "def show\n @tuiter = Tuiter.find(params[:id])\n end", "def index\n @theses = Thesis.a...
[ "0.69233584", "0.66976506", "0.63381547", "0.6287084", "0.6270265", "0.62337285", "0.6196108", "0.6163608", "0.6042122", "0.6031026", "0.60042626", "0.59876084", "0.5986726", "0.59836763", "0.5972753", "0.5943741", "0.59387267", "0.59319234", "0.59302306", "0.59246606", "0.58...
0.72106856
0
|1||2||3| |4||5||6| |7||8||9| [0][0] [0][1] [0][2] [1][0] [1][1] [1][2] [2][0] [2][1] [2][2]
def cpu_defend if check_position_1 return elsif check_position_2 elsif check_position_3 elsif check_position_4 elsif check_position_6 elsif check_position_7 elsif check_position_8 elsif check_position_9 return else cpu_place_move end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input4\n [\n [1, 0, 0, 0, 1],\n [0, 0, 0, 1, 3],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 8]\n ]\nend", "def input1\n [\n [1, 0, 0, 0, 1],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 4],\n [0, 0, 0, 1, 3]\n ]\nend", "def make_diamond(arr, rows)\n start = 1\n 1.upto(rows) do |iteration|\n ar...
[ "0.6503528", "0.6357327", "0.6091897", "0.6091593", "0.607279", "0.6065504", "0.60297275", "0.59254587", "0.59208584", "0.58373344", "0.58352804", "0.58193326", "0.57934755", "0.579264", "0.5735498", "0.56862223", "0.5674831", "0.5674831", "0.56702644", "0.56648517", "0.56574...
0.0
-1
Show invalid properties with the reasons. Usually used together with valid?
def list_invalid_properties invalid_properties = Array.new if !@display_name.nil? && @display_name.to_s.length > 255 invalid_properties.push('invalid value for "display_name", the character length must be smaller than or equal to 255.') end if !@description.nil? && @description.to_s.length > 1024 invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 1024.') end if @tcp_closed.nil? invalid_properties.push('invalid value for "tcp_closed", tcp_closed cannot be nil.') end if @tcp_closed > 4320000 invalid_properties.push('invalid value for "tcp_closed", must be smaller than or equal to 4320000.') end if @tcp_closed < 10 invalid_properties.push('invalid value for "tcp_closed", must be greater than or equal to 10.') end if @tcp_opening.nil? invalid_properties.push('invalid value for "tcp_opening", tcp_opening cannot be nil.') end if @tcp_opening > 4320000 invalid_properties.push('invalid value for "tcp_opening", must be smaller than or equal to 4320000.') end if @tcp_opening < 10 invalid_properties.push('invalid value for "tcp_opening", must be greater than or equal to 10.') end if @udp_single.nil? invalid_properties.push('invalid value for "udp_single", udp_single cannot be nil.') end if @udp_single > 4320000 invalid_properties.push('invalid value for "udp_single", must be smaller than or equal to 4320000.') end if @udp_single < 10 invalid_properties.push('invalid value for "udp_single", must be greater than or equal to 10.') end if @tcp_finwait.nil? invalid_properties.push('invalid value for "tcp_finwait", tcp_finwait cannot be nil.') end if @tcp_finwait > 4320000 invalid_properties.push('invalid value for "tcp_finwait", must be smaller than or equal to 4320000.') end if @tcp_finwait < 10 invalid_properties.push('invalid value for "tcp_finwait", must be greater than or equal to 10.') end if @tcp_first_packet.nil? invalid_properties.push('invalid value for "tcp_first_packet", tcp_first_packet cannot be nil.') end if @tcp_first_packet > 4320000 invalid_properties.push('invalid value for "tcp_first_packet", must be smaller than or equal to 4320000.') end if @tcp_first_packet < 10 invalid_properties.push('invalid value for "tcp_first_packet", must be greater than or equal to 10.') end if @tcp_closing.nil? invalid_properties.push('invalid value for "tcp_closing", tcp_closing cannot be nil.') end if @tcp_closing > 4320000 invalid_properties.push('invalid value for "tcp_closing", must be smaller than or equal to 4320000.') end if @tcp_closing < 10 invalid_properties.push('invalid value for "tcp_closing", must be greater than or equal to 10.') end if @tcp_established.nil? invalid_properties.push('invalid value for "tcp_established", tcp_established cannot be nil.') end if @tcp_established > 4320000 invalid_properties.push('invalid value for "tcp_established", must be smaller than or equal to 4320000.') end if @tcp_established < 120 invalid_properties.push('invalid value for "tcp_established", must be greater than or equal to 120.') end if @udp_multiple.nil? invalid_properties.push('invalid value for "udp_multiple", udp_multiple cannot be nil.') end if @udp_multiple > 4320000 invalid_properties.push('invalid value for "udp_multiple", must be smaller than or equal to 4320000.') end if @udp_multiple < 10 invalid_properties.push('invalid value for "udp_multiple", must be greater than or equal to 10.') end if @icmp_error_reply.nil? invalid_properties.push('invalid value for "icmp_error_reply", icmp_error_reply cannot be nil.') end if @icmp_error_reply > 4320000 invalid_properties.push('invalid value for "icmp_error_reply", must be smaller than or equal to 4320000.') end if @icmp_error_reply < 10 invalid_properties.push('invalid value for "icmp_error_reply", must be greater than or equal to 10.') end if @udp_first_packet.nil? invalid_properties.push('invalid value for "udp_first_packet", udp_first_packet cannot be nil.') end if @udp_first_packet > 4320000 invalid_properties.push('invalid value for "udp_first_packet", must be smaller than or equal to 4320000.') end if @udp_first_packet < 10 invalid_properties.push('invalid value for "udp_first_packet", must be greater than or equal to 10.') end if @icmp_first_packet.nil? invalid_properties.push('invalid value for "icmp_first_packet", icmp_first_packet cannot be nil.') end if @icmp_first_packet > 4320000 invalid_properties.push('invalid value for "icmp_first_packet", must be smaller than or equal to 4320000.') end if @icmp_first_packet < 10 invalid_properties.push('invalid value for "icmp_first_packet", must be greater than or equal to 10.') end invalid_properties end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_invalid_properties\n invalid_properties = super\n if @class_id.nil?\n invalid_properties.push('invalid value for \"class_id\", class_id cannot be nil.')\n end\n\n if @object_type.nil?\n invalid_properties.push('invalid value for \"object_type\", object_type cannot be nil....
[ "0.76497203", "0.76497203", "0.76497203", "0.76497203", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7637422", "0.7356452", "0.7334807", "0.72685325", "0.7238964", "0.7231359", "0.72258264", "0.7208294", "0.71760833", "0.717024...
0.0
-1
Check to see if the all the properties in the model are valid
def valid? return false if !@display_name.nil? && @display_name.to_s.length > 255 return false if !@description.nil? && @description.to_s.length > 1024 return false if @tcp_closed.nil? return false if @tcp_closed > 4320000 return false if @tcp_closed < 10 return false if @tcp_opening.nil? return false if @tcp_opening > 4320000 return false if @tcp_opening < 10 return false if @udp_single.nil? return false if @udp_single > 4320000 return false if @udp_single < 10 return false if @tcp_finwait.nil? return false if @tcp_finwait > 4320000 return false if @tcp_finwait < 10 return false if @tcp_first_packet.nil? return false if @tcp_first_packet > 4320000 return false if @tcp_first_packet < 10 return false if @tcp_closing.nil? return false if @tcp_closing > 4320000 return false if @tcp_closing < 10 return false if @tcp_established.nil? return false if @tcp_established > 4320000 return false if @tcp_established < 120 return false if @udp_multiple.nil? return false if @udp_multiple > 4320000 return false if @udp_multiple < 10 return false if @icmp_error_reply.nil? return false if @icmp_error_reply > 4320000 return false if @icmp_error_reply < 10 return false if @udp_first_packet.nil? return false if @udp_first_packet > 4320000 return false if @udp_first_packet < 10 return false if @icmp_first_packet.nil? return false if @icmp_first_packet > 4320000 return false if @icmp_first_packet < 10 true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_properties\n true\n end", "def validate_properties\n true\n end", "def validate\n super\n\n check_optional_property :collection, String\n check_optional_property :create, String\n check_optional_property :delete, String\n check_optional_property :...
[ "0.78992486", "0.78992486", "0.70971805", "0.70782334", "0.7032205", "0.7031276", "0.69510347", "0.6869891", "0.6858077", "0.6858077", "0.68287027", "0.6823878", "0.6820306", "0.68144894", "0.6794656", "0.6752167", "0.66843414", "0.6676546", "0.6667755", "0.66296124", "0.6618...
0.0
-1
Custom attribute writer method with validation
def display_name=(display_name) if !display_name.nil? && display_name.to_s.length > 255 fail ArgumentError, 'invalid value for "display_name", the character length must be smaller than or equal to 255.' end @display_name = display_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def description=(description) if !description.nil? && description.to_s.length > 1024 fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 1024.' end @description = description end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def tcp_closed=(tcp_closed) if tcp_closed.nil? fail ArgumentError, 'tcp_closed cannot be nil' end if tcp_closed > 4320000 fail ArgumentError, 'invalid value for "tcp_closed", must be smaller than or equal to 4320000.' end if tcp_closed < 10 fail ArgumentError, 'invalid value for "tcp_closed", must be greater than or equal to 10.' end @tcp_closed = tcp_closed end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def tcp_opening=(tcp_opening) if tcp_opening.nil? fail ArgumentError, 'tcp_opening cannot be nil' end if tcp_opening > 4320000 fail ArgumentError, 'invalid value for "tcp_opening", must be smaller than or equal to 4320000.' end if tcp_opening < 10 fail ArgumentError, 'invalid value for "tcp_opening", must be greater than or equal to 10.' end @tcp_opening = tcp_opening end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def udp_single=(udp_single) if udp_single.nil? fail ArgumentError, 'udp_single cannot be nil' end if udp_single > 4320000 fail ArgumentError, 'invalid value for "udp_single", must be smaller than or equal to 4320000.' end if udp_single < 10 fail ArgumentError, 'invalid value for "udp_single", must be greater than or equal to 10.' end @udp_single = udp_single end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def tcp_finwait=(tcp_finwait) if tcp_finwait.nil? fail ArgumentError, 'tcp_finwait cannot be nil' end if tcp_finwait > 4320000 fail ArgumentError, 'invalid value for "tcp_finwait", must be smaller than or equal to 4320000.' end if tcp_finwait < 10 fail ArgumentError, 'invalid value for "tcp_finwait", must be greater than or equal to 10.' end @tcp_finwait = tcp_finwait end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def tcp_first_packet=(tcp_first_packet) if tcp_first_packet.nil? fail ArgumentError, 'tcp_first_packet cannot be nil' end if tcp_first_packet > 4320000 fail ArgumentError, 'invalid value for "tcp_first_packet", must be smaller than or equal to 4320000.' end if tcp_first_packet < 10 fail ArgumentError, 'invalid value for "tcp_first_packet", must be greater than or equal to 10.' end @tcp_first_packet = tcp_first_packet end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def tcp_closing=(tcp_closing) if tcp_closing.nil? fail ArgumentError, 'tcp_closing cannot be nil' end if tcp_closing > 4320000 fail ArgumentError, 'invalid value for "tcp_closing", must be smaller than or equal to 4320000.' end if tcp_closing < 10 fail ArgumentError, 'invalid value for "tcp_closing", must be greater than or equal to 10.' end @tcp_closing = tcp_closing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def tcp_established=(tcp_established) if tcp_established.nil? fail ArgumentError, 'tcp_established cannot be nil' end if tcp_established > 4320000 fail ArgumentError, 'invalid value for "tcp_established", must be smaller than or equal to 4320000.' end if tcp_established < 120 fail ArgumentError, 'invalid value for "tcp_established", must be greater than or equal to 120.' end @tcp_established = tcp_established end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def udp_multiple=(udp_multiple) if udp_multiple.nil? fail ArgumentError, 'udp_multiple cannot be nil' end if udp_multiple > 4320000 fail ArgumentError, 'invalid value for "udp_multiple", must be smaller than or equal to 4320000.' end if udp_multiple < 10 fail ArgumentError, 'invalid value for "udp_multiple", must be greater than or equal to 10.' end @udp_multiple = udp_multiple end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def icmp_error_reply=(icmp_error_reply) if icmp_error_reply.nil? fail ArgumentError, 'icmp_error_reply cannot be nil' end if icmp_error_reply > 4320000 fail ArgumentError, 'invalid value for "icmp_error_reply", must be smaller than or equal to 4320000.' end if icmp_error_reply < 10 fail ArgumentError, 'invalid value for "icmp_error_reply", must be greater than or equal to 10.' end @icmp_error_reply = icmp_error_reply end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def udp_first_packet=(udp_first_packet) if udp_first_packet.nil? fail ArgumentError, 'udp_first_packet cannot be nil' end if udp_first_packet > 4320000 fail ArgumentError, 'invalid value for "udp_first_packet", must be smaller than or equal to 4320000.' end if udp_first_packet < 10 fail ArgumentError, 'invalid value for "udp_first_packet", must be greater than or equal to 10.' end @udp_first_packet = udp_first_packet end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Custom attribute writer method with validation
def icmp_first_packet=(icmp_first_packet) if icmp_first_packet.nil? fail ArgumentError, 'icmp_first_packet cannot be nil' end if icmp_first_packet > 4320000 fail ArgumentError, 'invalid value for "icmp_first_packet", must be smaller than or equal to 4320000.' end if icmp_first_packet < 10 fail ArgumentError, 'invalid value for "icmp_first_packet", must be greater than or equal to 10.' end @icmp_first_packet = icmp_first_packet end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_writer_tag(text); end", "def allowed_attributes=(_arg0); end", "def allowed_attributes=(_arg0); end", "def writer(*args)\n attr_writer(*args)\n args\n end", "def define_write_method(attr_name)\n evaluate_attribute_method attr_name, \"def #{attr_name}=(new_value);write_attribute('#{at...
[ "0.6472992", "0.6315012", "0.6315012", "0.62821025", "0.6279224", "0.6211609", "0.61891466", "0.6182247", "0.60683644", "0.6032628", "0.5995443", "0.5988785", "0.5959885", "0.5938289", "0.5931089", "0.58951056", "0.5859927", "0.5851703", "0.58493423", "0.58465594", "0.5832836...
0.0
-1
Checks equality by comparing each attribute.
def ==(o) return true if self.equal?(o) self.class == o.class && _self == o._self && _links == o._links && _schema == o._schema && _revision == o._revision && _system_owned == o._system_owned && display_name == o.display_name && description == o.description && tags == o.tags && _create_user == o._create_user && _protection == o._protection && _create_time == o._create_time && _last_modified_time == o._last_modified_time && _last_modified_user == o._last_modified_user && id == o.id && resource_type == o.resource_type && path == o.path && parent_path == o.parent_path && unique_id == o.unique_id && relative_path == o.relative_path && children == o.children && overridden == o.overridden && marked_for_delete == o.marked_for_delete && tcp_closed == o.tcp_closed && tcp_opening == o.tcp_opening && udp_single == o.udp_single && tcp_finwait == o.tcp_finwait && tcp_first_packet == o.tcp_first_packet && tcp_closing == o.tcp_closing && tcp_established == o.tcp_established && udp_multiple == o.udp_multiple && icmp_error_reply == o.icmp_error_reply && udp_first_packet == o.udp_first_packet && icmp_first_packet == o.icmp_first_packet end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n attributes == other.attributes\n end", "def ==(other) # :nodoc:\n @attrs == other.attrs\n end", "def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en...
[ "0.7291717", "0.7188103", "0.70395297", "0.7007927", "0.68874705", "0.6861532", "0.6707156", "0.6660597", "0.66147524", "0.658478", "0.6584619", "0.6580019", "0.65543133", "0.6543933", "0.65068495", "0.6479513", "0.6456241", "0.6415999", "0.6412208", "0.6412208", "0.6412208",...
0.0
-1
Calculates hash code according to all attributes.
def hash [_self, _links, _schema, _revision, _system_owned, display_name, description, tags, _create_user, _protection, _create_time, _last_modified_time, _last_modified_user, id, resource_type, path, parent_path, unique_id, relative_path, children, overridden, marked_for_delete, tcp_closed, tcp_opening, udp_single, tcp_finwait, tcp_first_packet, tcp_closing, tcp_established, udp_multiple, icmp_error_reply, udp_first_packet, icmp_first_packet].hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ...
[ "0.7118691", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.68960655", "0.67847186", "0.6707762", "0.670052", "0.6688737", "0.66705376", "0.6489735", "0.6462376", "0.6462376", "0.64444333", "0.6413127", "0.6395483", "0.638...
0.0
-1
Builds the object from hash
def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(hash)\n obj = new\n hash.each_pair do |k,v|\n obj[k] = v if variables[k]\n end\n return obj\n end", "def build_from_hash(attributes)\n\n end", "def build_from_hash(hash)\n instance = self.new\n\n # Add the instance attributes dynamically ...
[ "0.8011074", "0.7470833", "0.7457607", "0.7256629", "0.72455454", "0.70060325", "0.6973257", "0.6955014", "0.69459796", "0.69398683", "0.69363195", "0.6917627", "0.6872358", "0.6796184", "0.6783521", "0.67575246", "0.67575246", "0.67560464", "0.67514306", "0.67136854", "0.666...
0.0
-1
Deserializes the data based on type
def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :BOOLEAN if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model temp_model = NSXTPolicy.const_get(type).new temp_model.build_from_hash(value) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deserialize(type, value)\n case type.to_sym\n when :DateTime\n DateTime.parse(value)\n when :Date\n Date.parse(value)\n when :String\n value.to_s\n when :Integer\n value.to_i\n when :Float\n value.to_f\n when :BOOLEAN\n if value.to_s...
[ "0.7330926", "0.7274019", "0.72504056", "0.7245751", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", "0.72291344", ...
0.0
-1
Returns the string representation of the object
def to_s to_hash.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @object.to_s\n end", "def to_s\n object.to_s\n end", "def serialize(object)\n object.to_s\n end", "def to_s\n self.inspect\n end", "def to_s\n @string || @object.to_s('F')\n end", "def to_s\n @string || @object.to_s('F')\n end", "de...
[ "0.901024", "0.89506465", "0.84703195", "0.83409667", "0.8337169", "0.8337169", "0.8332247", "0.82546586", "0.8145818", "0.8144667", "0.81357557", "0.812714", "0.8093436", "0.8086725", "0.8073356", "0.8039774", "0.80308646", "0.80064154", "0.80064154", "0.80064154", "0.800641...
0.0
-1
to_body is an alias to to_hash (backward compatibility)
def to_body to_hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_body\r\n to_hash\r\n end", "def to_body\n to_hash\nend", "def to_body\n to_hash\nend" ]
[ "0.84283537", "0.8347048", "0.8347048" ]
0.0
-1
Returns the object in the form of hash
def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n object\n end", "def hash\r\n return to_s.hash\r\n end", "def hash\n to_a.hash\n end", "def hash\n [_hash, name, owner].hash\n end", "def hash\n return to_s.hash\n end", "def hash\n @hash\n end", "def hash\n @hash.hash\n end", "def hash\n ...
[ "0.8270299", "0.78767854", "0.78726953", "0.7802364", "0.7789188", "0.77806795", "0.7775915", "0.7767511", "0.7760525", "0.7760525", "0.77559966", "0.7731286", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916", "0.7713916",...
0.0
-1
Outputs nonarray value in the form of hash For object, use to_hash. Otherwise, just return the value
def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n [value].hash\n end", "def hash\n [value].hash\n end", "def hash\n\t\tvalue.hash\n\tend", "def hash\n value.hash\n end", "def hash\n @value.hash\n end", "def hash\r\n return to_s.hash\r\n end", "def to_hash\n @value\n end", "def to_hash\n @va...
[ "0.6719518", "0.6719518", "0.666832", "0.66565555", "0.6586841", "0.6452931", "0.6414911", "0.6414911", "0.6382046", "0.6346188", "0.6302933", "0.62237245", "0.6151989", "0.6101756", "0.60795677", "0.60795677", "0.60717124", "0.6035991", "0.6021168", "0.5936472", "0.5903488",...
0.0
-1
vim: ts=2 sts=2 sw=2 expandtab
def hex(s) s.nil? ? 'nil' : "[#{s.bytesize}]:#{s.bytes.map{|b|'%02X' % b}.join '.'}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def with_repl_like_sigint; end", "def terpene; end", "def autofinish; end", "def my955; end", "def source_line=(_); end", "def start_re=(_); end", "def expanded; end", "def code_point=(_); end", "def lines_of_code; end", "def lines_of_code; end", "def leading=(_); end", "def tt; end", "def ...
[ "0.6003154", "0.5932986", "0.5823631", "0.57155794", "0.56689525", "0.5657982", "0.56509584", "0.5605258", "0.5604854", "0.5604854", "0.5564482", "0.55569184", "0.5554731", "0.55493504", "0.55493504", "0.5541388", "0.55095273", "0.5505661", "0.5505661", "0.54965097", "0.54531...
0.0
-1
True if we've sent or received a GOAWAY frame.
def shutdown? @shutdown_lock.synchronize { @shutting_down } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def framed?\n return @peer.framed?\n end", "def sent?\n status.sent? || status.received? || status.read?\n end", "def received?\r\n self['trans_status']=='99'\r\n end", "def response_received?\n !! @status\n end", "def response_received?\n !! @status\n end", ...
[ "0.6952977", "0.6361301", "0.63327146", "0.6249398", "0.6249398", "0.62153685", "0.6182273", "0.61802363", "0.61600554", "0.61289746", "0.61289746", "0.6128398", "0.61024445", "0.609877", "0.60802794", "0.60538113", "0.60538113", "0.6029418", "0.5988028", "0.59795785", "0.597...
0.0
-1
Set the callback to be invoked when a stream is cancelled.
def on_cancel &b @cancel_proc = b self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel()\n @callback = nil\n @cancelled = true\n end", "def cancel!\n @callback = nil\n end", "def cancel!\n # The simplest way to keep track of cancelled status is to nullify the\n # callback. This should also be optimal for garbage collection.\n @callback...
[ "0.78955865", "0.76355064", "0.76210225", "0.7489106", "0.67421764", "0.66237724", "0.6587204", "0.6572214", "0.6509801", "0.6430958", "0.63600487", "0.6304011", "0.62445414", "0.6043354", "0.60068184", "0.58935237", "0.5841838", "0.58389264", "0.5814512", "0.5808875", "0.580...
0.7140782
4
wrap a TCPSocket e.g.: require 'socket' server = TCPServer.new 4567 http_client.wrap server.accept
def wrap s raise "already wrapped a socket!" if @socket @socket = s if defined? OpenSSL::SSL::SSLSocket and s.is_a? OpenSSL::SSL::SSLSocket @descr = s.io.remote_address.inspect_sockaddr else @descr = s.remote_address.inspect_sockaddr end @sil = FrameSerialiser.new {|b| cyan "@sil: _write #{hex b}" _write s, b rescue nil } @dsil = FrameDeserialiser.new do |f| begin brown "dsil: received #{frm f}" @hook << f rescue ConnectionError => e @logger.info "connection error [#{e.code}:#{e}] in client #{@descr} {1}" die e.code end end handle_prefaces s send_frame Settings.frame_from(initial_settings), true loop do bytes = begin s.readpartial(4*1024*1024) rescue EOFError nil rescue IOError, Errno::ECONNRESET raise unless s.closed? end if bytes.nil? or bytes.empty? @logger.info "client disconnected from #{@descr}" break end red "read #{hex bytes}" @dsil << bytes Thread.pass end rescue ConnectionError => e @logger.info "connection error [#{e.code}:#{e}] in client #{@descr} {2}" die e.code ensure _close_socket end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept\n while true\n s = @socket.accept\n break if (@acl ? @acl.allow_socket?(s) : true)\n s.close\n end\n if @config[:tcp_original_host].to_s.size == 0\n uri = \"druby://#{s.addr[3]}:#{@config[:tcp_port]}\"\n else\n uri = @uri\n end\n self.clas...
[ "0.6688478", "0.666855", "0.65875596", "0.63295555", "0.6329368", "0.63021624", "0.62836003", "0.62812495", "0.62465173", "0.62204075", "0.620938", "0.61625844", "0.6144681", "0.61268616", "0.6115253", "0.61095124", "0.6090156", "0.6076619", "0.60708207", "0.60624117", "0.603...
0.6297075
6
Shut down the connection.
def shut_down @shutdown_lock.synchronize { return if @shutting_down @shutting_down = true } die NO_ERROR end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shutdown\n @conn.shutdown\n end", "def shutdown_connection\n teardown_timers\n @conn.shutdown if @conn.respond_to? :shutdown\n @conn.terminate if @conn.respond_to? :terminate\n @conn = nil\n end", "def shutdown\n connection.write(\"shutdown...
[ "0.8183246", "0.79578334", "0.7912625", "0.73885876", "0.7354836", "0.72706264", "0.7257099", "0.71811414", "0.71494514", "0.71494514", "0.7058152", "0.7056894", "0.7054947", "0.70393366", "0.70356286", "0.7025426", "0.701538", "0.70030946", "0.6991097", "0.6976469", "0.69725...
0.7005302
17
send a PING message
def ping message=nil if message message = (message.to_s.b + (0.chr * 8)).slice(0, 8) else now = Time.now message = [now.to_i, now.usec].pack('NN') end @pings << message g = Frame.new FrameTypes::PING, 0, 0, message send_frame g end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ping!\n send_message [IGNORE, 4, \"ping\"].pack(\"cNA4\")\n end", "def ping\n send_command(\"ping\")\n end", "def ping(request)\n if request.message =~ /PING$/i\n request.answer 'PONG'\n end\n end", "def ping\n return_code, response = send_command(\"ping...
[ "0.7946903", "0.76782644", "0.72139764", "0.719248", "0.7182499", "0.71192193", "0.7106439", "0.7095092", "0.70772904", "0.7071936", "0.7038733", "0.7031764", "0.70281", "0.7020114", "0.70171416", "0.69965017", "0.69899064", "0.6945946", "0.6937511", "0.6937511", "0.68778104"...
0.723646
2
returns truthy if the given frame carries HTTP semantics (so has to be sent in order)
def semantic_frame? f f.type == FrameTypes::DATA || f.type == FrameTypes::HEADERS || f.type == FrameTypes::CONTINUATION || f.type == FrameTypes::GZIPPED_DATA end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def head?\r\nHTTP_METHOD_LOOKUP[request_method] == :head\r\nend", "def http_header?(name)\n name.start_with?(\"HTTP\") && !HTTP_NON_HEADERS.include?(name)\n end", "def treat_as_standard_html_request?\n !request.format.json? and !request.format.print? and !request.format.video?\n end", "def treat_...
[ "0.6558549", "0.62860686", "0.6256679", "0.6256679", "0.61295325", "0.61175334", "0.61175334", "0.6113873", "0.60840786", "0.60704446", "0.6067758", "0.60201645", "0.6002649", "0.5972792", "0.58855915", "0.5847994", "0.5845215", "0.5839393", "0.5836589", "0.5833479", "0.58316...
0.7241635
0
Are we configured to accept GZIPPED_DATA frames from this peer? Takes into account peer's apparent ability to correctly send gzip.
def accept_gzip? return if @ext__veto_gzip @ext__recv_gzip end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def send_gzip?\n return if !@ext__peer_gzip\n @ext__send_gzip\n end", "def no_accept_gzi...
[ "0.766792", "0.74445325", "0.6850856", "0.65573454", "0.63458", "0.60623276", "0.60623276", "0.60442317", "0.5980888", "0.59735066", "0.595472", "0.59233373", "0.5898725", "0.5839625", "0.58131963", "0.57851064", "0.57664853", "0.5682518", "0.56816906", "0.56658715", "0.56405...
0.7738065
0
tell the peer we'll accept GZIPPED_DATA frames
def accept_gzip! return if @ext__veto_gzip if !@ext__recv_gzip send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1}) @ext__recv_gzip = true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end", "def no_accept_gzip!\n return if @ext__veto_gzip\n if @ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0})\n @ext__recv_gzip = false\n end\n end", "def snapshots...
[ "0.6632567", "0.63472205", "0.59732676", "0.5944581", "0.59191394", "0.58648014", "0.57127595", "0.56354225", "0.561135", "0.55936605", "0.55447555", "0.54818", "0.54678214", "0.5440597", "0.54247224", "0.54160464", "0.5398543", "0.53897715", "0.5374744", "0.535133", "0.53371...
0.7478205
0
tell the peer we don't accept GZIPPED_DATA frames
def no_accept_gzip! return if @ext__veto_gzip if @ext__recv_gzip send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0}) @ext__recv_gzip = false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def no_send_gzip!\n if @ext__send_gzip\n @ext__send_gzip = false\n end\n end", "d...
[ "0.6865061", "0.63741463", "0.62295026", "0.610589", "0.610589", "0.5976867", "0.58996403", "0.5692219", "0.5689522", "0.56092215", "0.5589415", "0.55344594", "0.55241996", "0.5496961", "0.5429668", "0.54194087", "0.5402771", "0.5391948", "0.53852093", "0.5376257", "0.5374902...
0.74682546
0
Are we configured to send GZIPPED_DATA frames to this peer? Takes into account peer's settings for receiving them.
def send_gzip? return if !@ext__peer_gzip @ext__send_gzip end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end", "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def no_accept_gz...
[ "0.6787585", "0.67495316", "0.6270493", "0.6021219", "0.5889975", "0.5840739", "0.5817615", "0.5672995", "0.56668615", "0.56657493", "0.56657493", "0.56309086", "0.56244725", "0.55641174", "0.54602253", "0.5459606", "0.5457673", "0.53546077", "0.53490037", "0.53181916", "0.53...
0.7271987
0
application lets us send GZIPPED_DATA frames to this peer
def send_gzip! if !@ext__send_gzip @ext__send_gzip = true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def send_data_with_http_tunnel(data)\n #msg_data = Base64::encode64(data)\n #@socket_srv.print \"...
[ "0.67159706", "0.60468405", "0.5960542", "0.58490294", "0.5817642", "0.58146393", "0.57843447", "0.578295", "0.57530475", "0.5714235", "0.5696031", "0.56844765", "0.56827", "0.5673934", "0.5617282", "0.5607205", "0.5592035", "0.55890477", "0.55718523", "0.55499536", "0.554069...
0.61859727
1
application won't let us send GZIPPED_DATA frames to this peer
def no_send_gzip! if @ext__send_gzip @ext__send_gzip = false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end", "def no_accept_gzip!\n return if @ext__veto_gzip\n if @ext__recv_gzip\n send_frame Sett...
[ "0.6992377", "0.6936296", "0.6386955", "0.63543797", "0.6304036", "0.6174788", "0.6093384", "0.59526116", "0.59526116", "0.5895546", "0.5701681", "0.5689615", "0.56669146", "0.5662106", "0.5639858", "0.56113803", "0.56113803", "0.56057626", "0.5575226", "0.55733573", "0.55730...
0.63301873
4
Initial settings sent during preface
def initial_settings #{Settings::INITIAL_WINDOW_SIZE => 0x7fffffff, Settings::ACCEPT_GZIPPED_DATA => 1} #{Settings::INITIAL_WINDOW_SIZE => 0x7fffffff} {Settings::INITIAL_WINDOW_SIZE => 0x20000, Settings::MAX_FRAME_SIZE => @dsil.max_frame_size, Settings::ACCEPT_GZIPPED_DATA => 1} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_init\n end", "def setting; end", "def post_init\n end", "def at_init\n\n\t\tend", "def post_init\n\tend", "def settings=(_arg0); end", "def settings=(_arg0); end", "def init_settings\n merge_in_user_settings(copy_hash(DEFAULT_SETTINGS))\n end", "def settings; end", "def setting...
[ "0.6982722", "0.6800582", "0.67651033", "0.67079645", "0.6676908", "0.66686296", "0.66686296", "0.6510814", "0.65026325", "0.65026325", "0.6487079", "0.64243084", "0.6414315", "0.63874924", "0.635785", "0.6322867", "0.62695163", "0.62582636", "0.6255312", "0.6242282", "0.6193...
0.58367896
79
Shut down the connection.
def die code if !@send_lock.synchronize{@first_frame_out} g = Frame.new FrameTypes::GOAWAY, 0x00, 0, [@last_stream,code].pack('NN') send_frame g end _close_socket end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shutdown\n @conn.shutdown\n end", "def shutdown_connection\n teardown_timers\n @conn.shutdown if @conn.respond_to? :shutdown\n @conn.terminate if @conn.respond_to? :terminate\n @conn = nil\n end", "def shutdown\n connection.write(\"shutdown...
[ "0.8183246", "0.79578334", "0.7912625", "0.73885876", "0.7354836", "0.72706264", "0.7257099", "0.71811414", "0.71494514", "0.71494514", "0.7058152", "0.7056894", "0.7054947", "0.70393366", "0.70356286", "0.7025426", "0.701538", "0.7005302", "0.70030946", "0.6991097", "0.69764...
0.0
-1
close the socket we've wrapped
def _close_socket raise "no wrapped socket" unless @socket return if @socket.closed? @socket.shutdown rescue nil @socket.read_nonblock(4*1024*1024) rescue nil # flush any in-flight crud @socket.close rescue nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close\n @socket.close unless closed?\n end", "def close\n @socket.close if @socket\n end", "def close\n @socket.close\n end", "def close\n @socket.close\n end", "def close\n @socket.close if @socket\n @socket = nil\n end", "def close\n if @socke...
[ "0.8546623", "0.8422953", "0.84210277", "0.84210277", "0.83778405", "0.8376597", "0.8376597", "0.8351885", "0.8327489", "0.82896495", "0.82811064", "0.8217123", "0.81748974", "0.8173299", "0.8098206", "0.8014346", "0.79676753", "0.79237014", "0.7873896", "0.78597885", "0.7819...
0.8207528
12