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 |
|---|---|---|---|---|---|---|
POST /service_users POST /service_users.json | def create
@service_user = ServiceUser.new(service_user_params)
if @service_user.save
render json: @service_user, status: :created, location: @service_user
else
render json: @service_user.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def create... | [
"0.69557995",
"0.69329315",
"0.68204945",
"0.66121256",
"0.6599712",
"0.65780985",
"0.65528244",
"0.6496241",
"0.64708954",
"0.6467669",
"0.64611936",
"0.64590675",
"0.6458734",
"0.64414996",
"0.64404505",
"0.63847053",
"0.6379412",
"0.63675886",
"0.6324089",
"0.632226",
"0.6... | 0.7580152 | 0 |
PATCH/PUT /service_users/1 PATCH/PUT /service_users/1.json | def update
if @service_user.update(service_user_params)
render json: @service_user, status: :ok, location: @service_user
else
render json: @service_user.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n render json: User.update(params[\"id\"], params[\"u... | [
"0.69742674",
"0.67773587",
"0.67094237",
"0.670239",
"0.670239",
"0.66780007",
"0.65648985",
"0.6509665",
"0.6477369",
"0.6437504",
"0.64248335",
"0.63967645",
"0.6326177",
"0.63003695",
"0.6294038",
"0.629348",
"0.62759894",
"0.62737566",
"0.6265825",
"0.626577",
"0.6263258... | 0.7038933 | 0 |
DELETE /service_users/1 DELETE /service_users/1.json | def destroy
@service_user.destroy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
... | [
"0.7489978",
"0.7185733",
"0.7168934",
"0.7121226",
"0.7101466",
"0.70768374",
"0.70529085",
"0.7050356",
"0.7033383",
"0.7012725",
"0.70116836",
"0.6996039",
"0.6969302",
"0.6953669",
"0.6939896",
"0.6936382",
"0.6932784",
"0.69278187",
"0.69278187",
"0.69192696",
"0.6915933... | 0.71482563 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_service_user
@service_user = ServiceUser.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 service_user_params
params.require(:service_user).permit(:service_id, :user_id, :position, :approved, :expiration_date, :active, :vehicle_id)
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.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
A caching oneofeachsort constructor. ==== Parameters kind Class name (string) of a scheduled resource. rid Id (string), selecting a resource instance. The two are combined and used as a unique tag in the DOM as id and class attributes as well as in server code. | def get_for( kind, rid )
tag = compose_tag( kind, rid )
# config[:rsrc_of_tag][ tag ] || self.new( kind, rid )
rsrc_of_tag[ tag ] || new( kind, rid )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(rid)\n @rid = rid\n @units = rid[1..-1].to_i\n @free = @units\n @waiting_list = []\n @@resources[rid] = self\n end",
"def sort(&block)\n self.class.new(super(&block), type: @type, api_client: @api_client)\n end",
"def sort_results(results)\n case @metadata[:sort]\n ... | [
"0.51968104",
"0.49895275",
"0.49558535",
"0.49337053",
"0.4865296",
"0.48290372",
"0.4804697",
"0.47877425",
"0.4701948",
"0.46995306",
"0.46876076",
"0.46830395",
"0.46826968",
"0.46826968",
"0.46826968",
"0.46826968",
"0.46826968",
"0.46826968",
"0.46802667",
"0.46802667",
... | 0.5407648 | 0 |
==== Returns String The class name of the scheduled resource. | def kind() @tag.sub( /_.*/, '' ) end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_name\n \"#{self.class.to_s.split(\"::\").last.downcase}s\"\n end",
"def resource_class_name\n @resource_class_name ||= resource_name.classify.constantize\n end",
"def resource_class\n (self.class.name.split('::').last || '').downcase\n end",
"def resource_as_constant_name... | [
"0.768872",
"0.7485516",
"0.7386417",
"0.73078805",
"0.71952116",
"0.7189275",
"0.7146249",
"0.71236235",
"0.711776",
"0.71126056",
"0.7102673",
"0.7033048",
"0.699981",
"0.699981",
"0.699981",
"0.69858253",
"0.6944261",
"0.69277024",
"0.6926903",
"0.6926715",
"0.69088984",
... | 0.0 | -1 |
==== Returns String The rid (abstract id) of the ScheduledResource. | def sub_id() @tag.sub( /.*_/, '' ) end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rid\n \"rId#{ndx + 1}\"\n end",
"def resource_id\n return \"%s:%s\" % [self.resource_type, self.id]\n end",
"def rrid\n \"#\" + rid\n end",
"def resource_id\n send self.class.resource_id\n end",
"def rid\n begin\n \"#{@metadata[:cluster]}:#{@metadata[:record]... | [
"0.7154267",
"0.70218146",
"0.6916988",
"0.6863483",
"0.6805653",
"0.66547024",
"0.6652975",
"0.6652975",
"0.6652975",
"0.66459346",
"0.66241854",
"0.6465694",
"0.6400273",
"0.63534725",
"0.62671375",
"0.6082888",
"0.6006119",
"0.59855133",
"0.59560764",
"0.59443474",
"0.5926... | 0.0 | -1 |
==== Returns String CSS classes automatically generated for the DOM row representing this SchedResource. | def css_classes_for_row(); "rsrcRow #{self.kind}row #{@tag}row #{self.kind}Row #{@tag}Row" end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def css_classes_for_row(); \"rsrcRow #{self.kind}row #{@tag}row\" end",
"def css_classes\n classes= [\"row\"]\n unless @element.content_by_name(:classi_css).essence.body.nil?\n classes << @element.content_by_name(:classi_css).essence.body\n end\n classes #todo estrapolare valori da opt... | [
"0.8176047",
"0.7195995",
"0.6565542",
"0.6363355",
"0.6196096",
"0.61606354",
"0.6089686",
"0.603053",
"0.60292846",
"0.6017251",
"0.5993414",
"0.5990317",
"0.5970405",
"0.5847365",
"0.5805924",
"0.58026206",
"0.57095754",
"0.5702482",
"0.56894624",
"0.5634108",
"0.56287485"... | 0.82030976 | 0 |
GET /form_templates GET /form_templates.json | def index
@form_templates = FormTemplate.where(:is_current => true)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @form_templates }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @form_templates = FormTemplate.all\n end",
"def form_templates\n FormTemplate.where(lecturer_id: @id)\n end",
"def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end",
"def templates\n response = get 'templates'\n response.ma... | [
"0.7324039",
"0.71069056",
"0.70216703",
"0.6924033",
"0.6899663",
"0.68102884",
"0.6769081",
"0.6629335",
"0.6546098",
"0.6534867",
"0.6531811",
"0.64924777",
"0.6423376",
"0.6407678",
"0.6398074",
"0.6396821",
"0.6366459",
"0.6353628",
"0.6345521",
"0.632177",
"0.630982",
... | 0.70837295 | 2 |
GET /form_templates/1 GET /form_templates/1.json | def show
@form_template = FormTemplate.find(params[:id])
# Preserve previous form templates' contents when they are edited
# So that the previously filled forms relying on them will not be broken
if !@form_template.ror_contents or
@form_template.ror_contents != raw_form_to_ror_form(@form_template.contents)
if not (@form_template.filled_forms.nil? or @form_template.filled_forms.empty?)
@form_template.update_attributes(:is_current => false)
@form_template = FormTemplate.new(@form_template.attributes)
@form_template[:created_at] = nil
@form_template[:updated_at] = nil
@form_template[:is_current] = true
end
@form_template.ror_contents = raw_form_to_ror_form(@form_template.contents)
@form_template.save
end
@filled_form = @form_template.filled_forms.build
respond_to do |format|
format.html # show.html.erb
format.json { render json: @form_template }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @form_templates = FormTemplate.all\n end",
"def index\n @form_templates = FormTemplate.where(:is_current => true)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @form_templates }\n end\n end",
"def form_json\n render template: 'util... | [
"0.7255488",
"0.7147867",
"0.68611133",
"0.684872",
"0.68084496",
"0.65847546",
"0.65817285",
"0.6574959",
"0.65309227",
"0.65224755",
"0.6520631",
"0.651479",
"0.6492878",
"0.6476686",
"0.6460299",
"0.6403384",
"0.63954026",
"0.6393296",
"0.6359617",
"0.6331609",
"0.63021845... | 0.63436276 | 19 |
def fibonacci(n) current_num = 1 index 0 current_num_next = 1 index 1 count = 1 loop do p current_num = current_num + current_num_next index 2 = index 0+index 1 = 2 p current_num_next = current_num_next + current_num index 3, current_num = current_num_next + current_num index 4 is 5, index 2 + index 3 current_num_next = current_num + current_num_next index 5 is 8, index 3 + index 4 = 3+5 current_num = current_num_next + current_num index 6 is 13 count += 2 break if count > n end current_num end 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 | def fibonacci(n)
current_num = 1
current_num_next = 1
sum = current_num + current_num_next
count = 2
loop do
current_num = current_num_next
current_num_next = sum
sum = current_num + current_num_next
# puts "sum is #{sum} and current value is #{current_num} and current next is #{current_num_next}"
count += 1
break if count > n - 2
end
sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibonacci(n)\n raise ArgumentError, \"n must be an integer greater than 0\" unless n && n >= 0\n current = 0\n one_before = 0\n two_before = 0\n i = 0\n while i <= n\n if i == 1\n current = 1\n else\n two_before = one_before\n one_before = current\n current = one_before + two_be... | [
"0.8915964",
"0.88393056",
"0.8791971",
"0.87730473",
"0.8765919",
"0.8696584",
"0.868194",
"0.8679762",
"0.86745274",
"0.86401296",
"0.8619857",
"0.86177707",
"0.8591837",
"0.85897076",
"0.8580005",
"0.85719764",
"0.8570753",
"0.85679847",
"0.85661715",
"0.8557604",
"0.85481... | 0.8424063 | 42 |
GET /guides GET /guides.xml | def index
@guides = Guide.all
#@guide = Guide.find(params[:guide]) rescue nil
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @guides }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @guide = Guide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @guide }\n end\n end",
"def index\n @guides = Guide.all\n end",
"def index\n @guides = Guide.all\n end",
"def index\n @guides = Guide.page(1)\n\n ... | [
"0.70598155",
"0.6992941",
"0.6992941",
"0.6924859",
"0.68683624",
"0.6856749",
"0.6697979",
"0.6521598",
"0.6516481",
"0.64622706",
"0.6341066",
"0.63265914",
"0.62710315",
"0.6122782",
"0.6122782",
"0.60242474",
"0.5974404",
"0.59562284",
"0.58663464",
"0.5766668",
"0.57666... | 0.73859346 | 0 |
GET /guides/1 GET /guides/1.xml | def show
@guide = Guide.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @guide }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @guides = Guide.all\n #@guide = Guide.find(params[:guide]) rescue nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @guides }\n end\n end",
"def index\n @guides = Guide.page(1)\n\n respond_to do |format|\n format.html # inde... | [
"0.7418233",
"0.69884825",
"0.6918407",
"0.6918407",
"0.6605223",
"0.6602563",
"0.6577677",
"0.6567486",
"0.6507739",
"0.6470245",
"0.6462822",
"0.6149771",
"0.61297476",
"0.61230266",
"0.61230266",
"0.6112914",
"0.6071439",
"0.60630757",
"0.6047497",
"0.5966256",
"0.5891714"... | 0.7161179 | 1 |
GET /guides/new GET /guides/new.xml | def new
@guide = Guide.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @guide }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @breadcrumb = 'create'\n @guide = Guide.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @guide }\n end\n end",
"def new\n @guide = Guide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.j... | [
"0.7520714",
"0.72318053",
"0.7169528",
"0.71011454",
"0.70143276",
"0.6949339",
"0.67203784",
"0.6715671",
"0.66570854",
"0.66430396",
"0.66342527",
"0.6622123",
"0.6617106",
"0.65912956",
"0.6591135",
"0.65655416",
"0.65655416",
"0.65655416",
"0.65655416",
"0.65655416",
"0.... | 0.7868487 | 0 |
POST /guides POST /guides.xml | def create
@guide = Guide.new(params[:guide])
@guide.secret_code = Guide.secret_code
respond_to do |format|
if @guide.save
flash[:notice] = 'Guide was successfully created.'
format.html { redirect_to(guides_path) }
format.xml { render :xml => @guide, :status => :created, :location => @guide }
else
format.html { render :action => "new" }
format.xml { render :xml => @guide.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @guide = Guide.new(guide_params)\n\n respond_to do |format|\n if @guide.save\n format.html { redirect_to @guide, notice: 'Guide was successfully created.' }\n format.json { render :show, status: :created, location: @guide }\n else\n format.html { render :new }\n ... | [
"0.6557796",
"0.6557796",
"0.6543405",
"0.63241917",
"0.62806326",
"0.6214812",
"0.61328715",
"0.6132308",
"0.6121283",
"0.6046019",
"0.6025866",
"0.60048467",
"0.5966775",
"0.5929379",
"0.5913038",
"0.5876413",
"0.5833023",
"0.582743",
"0.58205765",
"0.5807726",
"0.5807726",... | 0.6618626 | 0 |
PUT /guides/1 PUT /guides/1.xml | def update
@guide = Guide.find(params[:id])
respond_to do |format|
if @guide.update_attributes(params[:guide])
flash[:notice] = 'Guide was successfully updated.'
format.html { redirect_to(@guide) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @guide.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @guide = Guide.find(params[:id])\n\n respond_to do |format|\n if @guide.update_attributes(params[:guide])\n format.html { redirect_to @guide, notice: 'Guide was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.6701984",
"0.6701984",
"0.6701984",
"0.65662766",
"0.65662766",
"0.6279573",
"0.6208056",
"0.616738",
"0.616738",
"0.616738",
"0.59983474",
"0.5938671",
"0.59382033",
"0.5931679",
"0.58618623",
"0.5858754",
"0.5856399",
"0.58433574",
"0.58433574",
"0.58200014",
"0.58076984... | 0.6925337 | 0 |
DELETE /guides/1 DELETE /guides/1.xml | def destroy
@guide = Guide.find(params[:id])
@guide.destroy
respond_to do |format|
format.html { redirect_to(guides_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n @guide = Guide.find(params[:id])\n @guide.destroy\n respond_to do |format|\n format.html { redirect_to guides_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @guide = Guide.find(params[:id])\n @guide.destroy\n\n respond_to do |format|\n form... | [
"0.732782",
"0.7136434",
"0.7136434",
"0.6936058",
"0.68661547",
"0.6835519",
"0.6800889",
"0.66710484",
"0.6670409",
"0.66461945",
"0.66392195",
"0.6592145",
"0.6491167",
"0.64827716",
"0.64777905",
"0.64656806",
"0.646292",
"0.64600325",
"0.6432149",
"0.6429656",
"0.6372644... | 0.7685157 | 0 |
validates :description_category, :image, :service_fee, presence:true | def name
description_category
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n super\n errors.add(:name, \"can't be empty\") if name.blank?\n errors.add(:category_id, \"can't be empty\") if category_id.blank?\n errors.add(:price, \"can't be empty\") if price.blank?\n end",
"def validate!\n if identifier.to_s.empty?\n raise ValidationError.new(\"ident... | [
"0.65540177",
"0.64090073",
"0.6288335",
"0.6219141",
"0.62117827",
"0.6165551",
"0.61579746",
"0.61492026",
"0.61442524",
"0.6098558",
"0.60727084",
"0.60497963",
"0.60158134",
"0.6005152",
"0.60040003",
"0.5975477",
"0.5954448",
"0.5950787",
"0.5946185",
"0.5926829",
"0.591... | 0.0 | -1 |
numero di donazioni effettuate TORTONESI | def number_of_donations(campaign)
campaign.donations.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def posti_disponibili\n self.vehicle.posti - self.n_passeggeri\n end",
"def indice_masa_corporal\n\t\t(peso / (talla * talla) * 10000).round(1)\n\tend",
"def num_tankoubon; end",
"def duns_number; end",
"def num_nulos\n t = @filas*@columnas\n nn = 0\n \n @filas.times do |i|\n ... | [
"0.65203077",
"0.6343386",
"0.63206774",
"0.63063765",
"0.61632234",
"0.61566365",
"0.6133199",
"0.6116389",
"0.61131614",
"0.606355",
"0.60525197",
"0.60343015",
"0.59852093",
"0.59093153",
"0.589849",
"0.58674794",
"0.5808502",
"0.5800364",
"0.579633",
"0.57778865",
"0.5773... | 0.0 | -1 |
envelope_id is Docusign Envelope's id, not id of Envelope model | def initialize(envelope_id, user_id, loan_id)
@envelope_id = envelope_id
@user = User.find_by_id(user_id)
@loan = Loan.find_by_id(loan_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_envelope\n @envelope = Envelope.find(params[:id])\n end",
"def set_envelope\n @envelope = Envelope.find(params[:id])\n end",
"def envelope\n Hancock::Request.send_get_request(\"/envelopes/#{envelope_id}\")\n end",
"def create\n @envelope = Envelope.new(params[:envelope].mer... | [
"0.76314896",
"0.76314896",
"0.7184735",
"0.6776781",
"0.64655334",
"0.6435949",
"0.6395554",
"0.6277619",
"0.6240799",
"0.62350273",
"0.6221541",
"0.61814845",
"0.6115929",
"0.60948414",
"0.6094628",
"0.6092403",
"0.6077406",
"0.6011774",
"0.59982336",
"0.587575",
"0.5775823... | 0.0 | -1 |
Gets the user input, converts it to integer and checks if its within 18. If its not within that range, the method calls itself again. | def input_range
input = STDIN.getch
print input
sleep(0.17) #to see player input on console
if input.to_i>0 && input.to_i<9
$col = input.to_i-1
elsif input == "x"
print "\n\n\n"
exit
else
print "\n\n\tWrong input! Press key between 1 and 8.\n\n\tPlayer ", $x_or_o, " > "
input_range()
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def age_validator\n puts \"whats your characters age\" \n age = gets.strip.to_i \n until age > 16 #checks to see if age is a number \n begin \n if age >! 16\n end\n rescue #rescues if there is an error because its not an integer \n puts \"Input must be a valid number above 16, Try Again\"\... | [
"0.71028554",
"0.6831317",
"0.6798423",
"0.6696665",
"0.6660528",
"0.6623562",
"0.65640444",
"0.65100974",
"0.6383505",
"0.6362689",
"0.63162106",
"0.6312973",
"0.62666917",
"0.625564",
"0.62399954",
"0.620319",
"0.61906004",
"0.6157034",
"0.6141155",
"0.6115535",
"0.6108404"... | 0.0 | -1 |
Gets the input from player, decides which players turn it is and gets the updated game board from class "Move". In case there is no empty space in the chosen column the player can choose a different one. | def move_maker
GameBoard.print_game_board($game_board)
$move_counter+=1
$x_or_o = if $move_counter.even? then "o" else "x" end
print "\n --> Press key 1-8 to pick a column\n\n\tPlayer ", $x_or_o, " > "
input_range()
if Move.check_move == "column complete"
print "\n\n\tChoose different column!"
$move_counter-=1
sleep(1)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_move(column, player)\n placed = false\n return false unless (1..width).include?(column)\n\n grid.reverse_each do |row|\n if row[column - 1] == empty_cell && placed == false\n row[column - 1] = player\n placed = true\n end\n end\n placed\n end",
"def get_move_colu... | [
"0.7241283",
"0.71871006",
"0.71244305",
"0.7101226",
"0.6996138",
"0.69946074",
"0.692669",
"0.6914754",
"0.68970037",
"0.6886457",
"0.68770593",
"0.6841837",
"0.6835599",
"0.67981994",
"0.6764569",
"0.67413205",
"0.671001",
"0.6677614",
"0.6635272",
"0.6608262",
"0.6605565"... | 0.72193974 | 1 |
Generator Code. Remember this is just supedup Thor so methods are executed in order | def copy_files
copy_file 'initializer.rb', 'config/initializers/kono_utils.rb'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generators; end",
"def generators; end",
"def generate; end",
"def generate; end",
"def generate!\n generator.invoke_all\n end",
"def generate\n end",
"def generate_next\n @block.call(@so_far)\n end",
"def process\n self.generate\n end",
"def generate\n end",
"de... | [
"0.729359",
"0.729359",
"0.72033226",
"0.72033226",
"0.7152807",
"0.7085607",
"0.7074787",
"0.69549644",
"0.6915871",
"0.69113964",
"0.69113964",
"0.69032913",
"0.69032913",
"0.67924577",
"0.6611314",
"0.6611213",
"0.65883774",
"0.65796053",
"0.6540793",
"0.65272987",
"0.6527... | 0.0 | -1 |
Find token by representation of the token | def token_from_representation(repr)
token = Token.first(:token => repr)
if token.nil?
give_error(400, ERROR_USER_TOKEN_NOT_FOUND, "Token not found.").to_json
end
if !token.valid?
give_error(400, ERROR_USER_TOKEN_EXPIRED, "Token has expired.").to_json
end
return token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_by_token(name, token)\n token = find_token(:name => \"#{name}\", :token => token)\n token.object if token\n end",
"def find_by_token(name, hash)\n token = find_token(name: name.to_s, token: hash)\n return unless token\n token.tokenizable\n end",
"def find_t... | [
"0.7645852",
"0.75471294",
"0.73778474",
"0.7325185",
"0.709276",
"0.69753987",
"0.6929651",
"0.6843774",
"0.6813446",
"0.6757426",
"0.6743082",
"0.6701397",
"0.6475134",
"0.6425502",
"0.6350223",
"0.63098097",
"0.62975806",
"0.6294065",
"0.62726057",
"0.62498236",
"0.6223285... | 0.64062595 | 14 |
Returns the collection provided to the render call if present. | def collection
@options[:collection] if @options.key?(:collection)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_collection(collection = nil, options = nil)\n collection ||= @collection\n options ||= @collection_options || {}\n \n # to inherit to \"render_pure_collection\"\n @collection = collection\n @collection_options = options \n collection_template = options.delete(:collection_templ... | [
"0.6769171",
"0.674476",
"0.6706905",
"0.66703516",
"0.66332984",
"0.66332984",
"0.65951645",
"0.6593896",
"0.6576815",
"0.65488607",
"0.6536653",
"0.6511331",
"0.6510969",
"0.6461943",
"0.6426802",
"0.6376298",
"0.6344552",
"0.6261289",
"0.62583977",
"0.62370044",
"0.6225864... | 0.6595546 | 6 |
def new end def create end | def show
path = params[:path]
@page = Page.find(:path => path)
if @page
respond_to do |format|
format.html do
@page.layout_template && self.class.layout(@page.layout_template)
end
format.xml do
@pages = @page.children
render :action => "index"
end
end
else
error
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\r\n\r\n end",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def new \n end",
"def new \n end",
"def create\r\n end",
"def new\r\n end",
"def new\r\n end",
"def new\n\n end",
"def new\n\n end",
"def new\r\n \r\n end",
"def new\n... | [
"0.84706765",
"0.84688497",
"0.84688497",
"0.84688497",
"0.84688497",
"0.8412551",
"0.8412551",
"0.83974195",
"0.835175",
"0.835175",
"0.8349549",
"0.8349549",
"0.8337779",
"0.8316584",
"0.8316584",
"0.83123124",
"0.8308001",
"0.8308001",
"0.8293539",
"0.8293539",
"0.8293539"... | 0.0 | -1 |
GET /instituicao_responsavels GET /instituicao_responsavels.json | def index
@instituicao_responsavels = InstituicaoResponsavel.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sesions = Sesion.where(entidad_paraestatal_id: @entidad_paraestatal.id).all\n @suplente = Suplente.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sesions }\n end\n end",
"def index\n @instituicoes = Instituicao.all\n\n respond_t... | [
"0.64445686",
"0.6441958",
"0.6382819",
"0.6294997",
"0.62898296",
"0.6272282",
"0.61052346",
"0.6098689",
"0.60829616",
"0.6068272",
"0.6057521",
"0.60361946",
"0.6019912",
"0.60100704",
"0.59947616",
"0.59881955",
"0.5979414",
"0.59651655",
"0.5959119",
"0.5937477",
"0.5898... | 0.700344 | 0 |
GET /instituicao_responsavels/1 GET /instituicao_responsavels/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @instituicao_responsavels = InstituicaoResponsavel.all\n end",
"def index\n @instituicoes = Instituicao.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instituicoes }\n end\n end",
"def index\n @status_de_la_inscripcions = Statu... | [
"0.69806325",
"0.6805434",
"0.6589629",
"0.645523",
"0.6402247",
"0.6369921",
"0.63497525",
"0.63427854",
"0.63418436",
"0.6335533",
"0.63314253",
"0.63141507",
"0.62701905",
"0.6267739",
"0.6264664",
"0.6252689",
"0.62477833",
"0.62396085",
"0.62174124",
"0.62150836",
"0.621... | 0.0 | -1 |
POST /instituicao_responsavels POST /instituicao_responsavels.json | def create
@instituicao_responsavel = InstituicaoResponsavel.new(instituicao_responsavel_params)
respond_to do |format|
if @instituicao_responsavel.save
format.html { redirect_to @instituicao_responsavel, notice: 'Instituicao responsavel was successfully created.' }
format.json { render :show, status: :created, location: @instituicao_responsavel }
else
format.html { render :new }
format.json { render json: @instituicao_responsavel.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @responsavel = Responsavel.new(responsavel_params)\n\n if @responsavel.save\n render json: @responsavel, status: :created, location: @responsavel\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def socio_economico_submit\n\n # respond... | [
"0.59326315",
"0.5861852",
"0.58400804",
"0.5814467",
"0.5713281",
"0.56878877",
"0.5680321",
"0.5634274",
"0.5634042",
"0.5631347",
"0.5604365",
"0.55902904",
"0.55887616",
"0.55870575",
"0.5556952",
"0.55400854",
"0.5523738",
"0.551276",
"0.55069256",
"0.5501102",
"0.548741... | 0.6215593 | 0 |
PATCH/PUT /instituicao_responsavels/1 PATCH/PUT /instituicao_responsavels/1.json | def update
respond_to do |format|
if @instituicao_responsavel.update(instituicao_responsavel_params)
format.html { redirect_to @instituicao_responsavel, notice: 'Instituicao responsavel was successfully updated.' }
format.json { render :show, status: :ok, location: @instituicao_responsavel }
else
format.html { render :edit }
format.json { render json: @instituicao_responsavel.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.... | [
"0.679326",
"0.66887605",
"0.66880244",
"0.66590905",
"0.6619809",
"0.66090274",
"0.65979487",
"0.6551703",
"0.65102464",
"0.6492523",
"0.64729017",
"0.64688945",
"0.6468718",
"0.6456326",
"0.64464116",
"0.6439797",
"0.6439195",
"0.6427364",
"0.6415493",
"0.6387728",
"0.63756... | 0.69480276 | 0 |
DELETE /instituicao_responsavels/1 DELETE /instituicao_responsavels/1.json | def destroy
@instituicao_responsavel.destroy
respond_to do |format|
format.html { redirect_to instituicao_responsavels_url, notice: 'Instituicao responsavel was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solicitud.destroy\n respond_to do |format|\n format.html { redirec... | [
"0.73260534",
"0.72820103",
"0.7275473",
"0.72617584",
"0.72312665",
"0.719863",
"0.7193515",
"0.7177237",
"0.71733046",
"0.7170895",
"0.715135",
"0.71462196",
"0.71351576",
"0.71317315",
"0.71282184",
"0.7124477",
"0.71229243",
"0.71178937",
"0.71083856",
"0.71040034",
"0.71... | 0.75338024 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_instituicao_responsavel
@instituicao_responsavel = InstituicaoResponsavel.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.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def instituicao_responsavel_params
params.require(:instituicao_responsavel).permit(:instituicao_id, :nome, :inseridoPor, :dataDeInsercao, :atualizadoPor, :dataDeAtualizacao)
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 |
20 days possible states are :normal, :warn, :urgent | def todo_state
return :normal if !self.wip_total
return :urgent if self.wip_total > WIP_TOTAL_URGENT
return :warn if self.wip_total > WIP_TOTAL_WARN
return :normal if !self.lane
return :urgent if self.lane.urgent_limit and self.wip_current > self.lane.urgent_limit
return :warn if self.lane.warn_limit and self.wip_current > self.lane.warn_limit
return :normal
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_day ; true ; end",
"def set_day_if_discarded; end",
"def threshold_for_offline\n 8.days\n end",
"def left_to_state(left)\n if left <= DANGER_DAYS\n 'danger'\n elsif left <= WARNING_DAYS\n 'warning'\n else\n 'good'\n end\nend",
"def warning_state\n super\n end",
"def warni... | [
"0.58318627",
"0.5796542",
"0.5743867",
"0.5739495",
"0.5440411",
"0.5430141",
"0.5415253",
"0.5409522",
"0.5377407",
"0.53723675",
"0.5368352",
"0.5351271",
"0.5350276",
"0.53190815",
"0.52521896",
"0.5251513",
"0.52367383",
"0.5236585",
"0.52113044",
"0.5200838",
"0.5185219... | 0.5296324 | 14 |
wip counters needed to determine the current and the overall WIP wip_current for the current lane wip_total for all lanes | def update_time_counters
unless changed? and !changes["lane_id"].nil?
self.current_lane_entry = Time.now if self.new_record? && self.lane && self.lane.counts_wip
return
end
old_lane_id,new_lane_id = changes["lane_id"]
old_lane = Lane.new(old_lane_id) if old_lane_id
new_lane = Lane.new(new_lane_id)if new_lane_id
# add the time spent in the old_lane to the wip_total
if old_lane and current_lane_entry #and old_lane.counts_wip # not_needed?
self.wip_total ||= 0
self.wip_total += (Time.now - self.current_lane_entry)
self.current_lane_entry=nil
end
# start new counter for the new lane, if needed
if new_lane and new_lane.counts_wip
self.current_lane_entry=Time.now
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def todo_state\n return :normal if !self.wip_total\n return :urgent if self.wip_total > WIP_TOTAL_URGENT\n return :warn if self.wip_total > WIP_TOTAL_WARN\n\n return :normal if !self.lane\n return :urgent if self.lane.urgent_limit and self.wip_current > self.lane.urgent_limit\n return :warn if se... | [
"0.6004532",
"0.5483743",
"0.5440018",
"0.54042023",
"0.5348764",
"0.53287613",
"0.5327676",
"0.53036803",
"0.52771705",
"0.5273418",
"0.5257424",
"0.5248349",
"0.52202415",
"0.5163862",
"0.51202404",
"0.51176995",
"0.50591147",
"0.50305265",
"0.5018177",
"0.50074327",
"0.499... | 0.6598777 | 0 |
Set the value of a property | def []=(prop, value)
@prototype.set(prop, value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(property, value)\n self.send(\"#{property}=\".to_sym, value)\n end",
"def set_property(key, value)\n end",
"def set_Property(value)\n set_input(\"Property\", value)\n end",
"def intersys_set(property, value)\n intersys_property(property).set(value)\n end",
"def assign... | [
"0.82450175",
"0.8231292",
"0.80921656",
"0.80406284",
"0.7989122",
"0.7975242",
"0.78739625",
"0.78630817",
"0.77419573",
"0.77218795",
"0.7704562",
"0.7686469",
"0.7630605",
"0.7624287",
"0.7615933",
"0.7607973",
"0.74367213",
"0.7417343",
"0.7409318",
"0.74092907",
"0.7381... | 0.7312588 | 49 |
Data description for Dymo model M25 => [0] Unknown 3 => [1] Stability (2 when at 0, 3 when getting stable, 4 when stable, 5 when negative, 6 when too much weight) => [2] Mode (lbs = 11, kg = 2) => [3] Scale factor => [45] 16 bit weight | def initialize(raw_data)
raise Scale::Error, "Invalid data" unless raw_data.size == 6
self.raw_stability = raw_data[1]
self.raw_mode = raw_data[2]
self.raw_scale_factor = raw_data[3]
self.raw_weight = (raw_data[5] << 8 | (raw_data[4] & 0xFF)) * 1.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modeler_description\n return \"This measure will demonstrate how EMS functions can be used to demonstrate how information from a sizing run can be used to select HVAC equipment from nominal product sizes where unit total capacity is directly related to the unit supply airflow (1 ton = 1200 cfm, 1.5 ton = 16... | [
"0.6518598",
"0.6516782",
"0.64116484",
"0.6307434",
"0.6243534",
"0.62093925",
"0.62065464",
"0.61836827",
"0.614624",
"0.61438143",
"0.613039",
"0.61167514",
"0.6100191",
"0.605614",
"0.60561186",
"0.6036423",
"0.60015625",
"0.59511024",
"0.5920326",
"0.5914699",
"0.5890937... | 0.0 | -1 |
name isn't mandatory on signup, so fall back to email | def identifier
unless full_name.blank?
full_name
else
email.split('@').join(' from ')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_or_email\n self.name.blank? ? self.email : self.name\n end",
"def name_or_email\n if name.present?\n name\n else\n email\n end\n end",
"def name_or_email\n name.blank?? email : name\n end",
"def name\n username || email\n end",
"def name\n username || email\n en... | [
"0.76586074",
"0.75714576",
"0.7449726",
"0.7119772",
"0.71195257",
"0.7086814",
"0.7086814",
"0.70684296",
"0.69923794",
"0.6960828",
"0.6941891",
"0.6921003",
"0.6921003",
"0.6914869",
"0.68006814",
"0.6759951",
"0.6755081",
"0.6708651",
"0.6703954",
"0.6700805",
"0.6679638... | 0.0 | -1 |
Generate a list of PublicationIdentifiers. | def id_list(item, **opt)
id_split(item).map! { |v| id_obj(v, **opt) }.compact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_identifiers\n identifiers = publication_identifiers.map{|pi| pi.identifier_value}\n identifiers.push(self.isbn) unless !self.isbn\n identifiers.push(self.issn) unless !self.issn\n identifiers.push(self.eissn) unless !self.eissn\n identifiers.push(self.article_number) unless !self.article_num... | [
"0.70074755",
"0.5659676",
"0.5622354",
"0.5557195",
"0.5547024",
"0.54839015",
"0.54727125",
"0.5467094",
"0.541205",
"0.53949416",
"0.53366274",
"0.5295723",
"0.52737874",
"0.5268007",
"0.52506",
"0.52141464",
"0.5203304",
"0.5198751",
"0.5194605",
"0.5186757",
"0.5181994",... | 0.492727 | 54 |
Analyze a string into individual items. | def id_split(item)
case item
when Array then array = item.flat_map { |v| id_split(v) }
when String then array = item.split(/[ \t]*[,;\n]+[ \t]*/)
when PublicationIdentifier then array = Array.wrap(item)
else array = Array.wrap(item).map(&:to_s)
end
array.compact_blank!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(str)\n read_items(tokenize(str))\n end",
"def create_items(string)\r\n item_list = {}\r\n string.split(\" \").each { |item| item_list[item] = 1 }\r\n item_list\r\nend",
"def process(items) \n out = []\n \n if items.is_a?(Array)\n items.each do |item|\n o... | [
"0.6571353",
"0.61324406",
"0.6012022",
"0.6001111",
"0.57708174",
"0.5721283",
"0.5712482",
"0.5700286",
"0.55848926",
"0.55848926",
"0.55848926",
"0.55848926",
"0.55169004",
"0.55021626",
"0.5498174",
"0.5491798",
"0.54896516",
"0.5487206",
"0.54256153",
"0.5390878",
"0.538... | 0.0 | -1 |
Transform a type/ID pair. | def id_obj(type, id = nil, copy: false, **)
# noinspection RubyMismatchedReturnType
if type.is_a?(PublicationIdentifier)
Log.warn("#{__method__}: ignoring id #{id.inspect}") if id
copy ? type.dup : type
elsif id.is_a?(PublicationIdentifier)
Log.warn("#{__method__}: ignoring type #{type.inspect}") if type
copy ? id.dup : id
elsif type.is_a?(Array)
Log.warn("#{__method__}: ignoring id #{id.inspect}") if id
id = type.compact.join(':')
PublicationIdentifier.cast(id, invalid: true)
else
id = [type, id].compact.join(':')
PublicationIdentifier.cast(id, invalid: true)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_id_from_type(type); end",
"def convert_xid(type, id)\n map = {:gid => :group, :uid => :user}\n raise ArgumentError, \"Invalid id type #{type}\" unless map.include?(type)\n ret = Puppet::Util.send(type, id)\n if ret == nil\n raise Puppet::Error, \"Invalid #{map[type]}: #{id}\"\n end\... | [
"0.6249735",
"0.560366",
"0.5436727",
"0.53246623",
"0.52630454",
"0.5199958",
"0.5194698",
"0.5185302",
"0.5181757",
"0.51506406",
"0.51489824",
"0.5140712",
"0.5140712",
"0.5129856",
"0.5127464",
"0.51192814",
"0.5117716",
"0.5096962",
"0.5059687",
"0.505819",
"0.50546414",... | 0.5013483 | 24 |
Extract and print specified data. | def xml_to_string(xml)
return if xml.nil?
output = $data.each.map do |key, value|
"#{key.to_str}:#{xml.elements[value].text.to_f}"
end
output.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printData()\n puts @data\n end",
"def process_data(data)\n print_headline\n tmp = data.dup\n\n # TELNETコマンドを抽出しダンプする.\n tmp.gsub!(/#{IAC}(\n [#{DONT}#{DO}#{WONT}#{WILL}].|\n #{SB}.(#{IAC}#{IAC}|[^#{IAC}])*#{IAC}#{SE}|\n [#{NOP}-#{GA}#{0.chr}-#{2... | [
"0.6886395",
"0.6639123",
"0.64023614",
"0.6360974",
"0.6230373",
"0.61960685",
"0.6167886",
"0.6074729",
"0.6061806",
"0.6008538",
"0.59789824",
"0.59364724",
"0.5907427",
"0.5898483",
"0.5881963",
"0.58070964",
"0.5772384",
"0.57380396",
"0.573097",
"0.573097",
"0.5730963",... | 0.0 | -1 |
Wrte the last values to a file, ready for cacti to eat | def write_last_measurement(line, filename = '/tmp/currentcost')
File.open(filename, "w") do |file|
file.puts Time.now,(line)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end",
"def write_last_activity(activity)\n File.open(MAIN_DIR + \"prev_activity\", \"w\") do |file|\n file.... | [
"0.6356724",
"0.62938505",
"0.62356156",
"0.61873424",
"0.61844957",
"0.61325985",
"0.5942598",
"0.5942044",
"0.5942044",
"0.5873646",
"0.5858707",
"0.58343226",
"0.5833711",
"0.58302027",
"0.58269113",
"0.58243334",
"0.58200735",
"0.5815333",
"0.5812547",
"0.5812547",
"0.579... | 0.65162426 | 0 |
This destroy code works but I think it allows any loggedin user to delete another user, not just the admin. | def destroy
@user.destroy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n if @current_user.id = @user.id\n log_out (@current_user)\n end\n @user.destroy\n if @current_user.admin?\n redirect_to users_url\n else\n redirect_to root_url\n end\n end",
"def destroy\n user = User.find(params[:id])\n # if admin tries to delete himself\n ... | [
"0.8270667",
"0.8189494",
"0.8188857",
"0.8183297",
"0.8120714",
"0.811421",
"0.8106924",
"0.8075243",
"0.80613667",
"0.8032436",
"0.8028772",
"0.79900986",
"0.7974144",
"0.79613155",
"0.79613155",
"0.7960068",
"0.795053",
"0.7948487",
"0.7942245",
"0.7928578",
"0.7923336",
... | 0.0 | -1 |
Retrieves the aggregate data. | def get aggregate_alias = nil
if @aggregate_fields.count > 1 && aggregate_alias.nil?
raise ArgumentError, "Required param aggregate_alias for AggregateQuery with multiple aggregate fields"
end
aggregate_alias ||= @aggregate_fields.keys.first
@aggregate_fields[aggregate_alias]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data\n @data ||= aggregate\n end",
"def data\n @data ||= aggregate(:single)\n end",
"def aggregates\n self.class.instance_variable_get(:@aggregates) || {}\n end",
"def aggregates\n @aggregates\n end",
"def get_aggregate aggregate_query\n ensure_not_closed!\n... | [
"0.77936625",
"0.745657",
"0.6882014",
"0.6871705",
"0.6688629",
"0.6534879",
"0.6458202",
"0.64369506",
"0.6357086",
"0.62435645",
"0.62303084",
"0.6165014",
"0.61168534",
"0.6080659",
"0.6080659",
"0.6013445",
"0.59813946",
"0.59762245",
"0.59762245",
"0.5965558",
"0.596033... | 0.0 | -1 |
Show invalid properties with the reasons. Usually used together with valid? | def list_invalid_properties
invalid_properties = Array.new
if @timing.nil?
invalid_properties.push("invalid value for 'timing', timing cannot be nil.")
end
if !@amount.nil? && @amount < 0
invalid_properties.push("invalid value for 'amount', must be greater than or equal to 0.")
end
if !@quantity.nil? && @quantity < 1
invalid_properties.push("invalid value for 'quantity', must be greater than or equal to 1.")
end
return 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 @timing.nil?
timing_validator = EnumAttributeValidator.new('String', ["immediate", "renewal"])
return false unless timing_validator.valid?(@timing)
return false if !@amount.nil? && @amount < 0
return false if !@quantity.nil? && @quantity < 1
billing_validator = EnumAttributeValidator.new('String', ["prorated", "full", "zero_amount", "none"])
return false unless billing_validator.valid?(@billing)
compensation_method_validator = EnumAttributeValidator.new('String', ["full_refund", "prorated_refund", "full_credit", "prorated_credit", "none"])
return false unless compensation_method_validator.valid?(@compensation_method)
partial_period_handling_validator = EnumAttributeValidator.new('String', ["bill_full", "bill_prorated", "bill_zero_amount", "no_bill"])
return false unless partial_period_handling_validator.valid?(@partial_period_handling)
return 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.78989387",
"0.78989387",
"0.7097542",
"0.7077744",
"0.7031459",
"0.703038",
"0.69501424",
"0.6869871",
"0.68576187",
"0.68576187",
"0.68280154",
"0.68235457",
"0.682004",
"0.6814453",
"0.67930245",
"0.67521733",
"0.66832304",
"0.6675793",
"0.66681546",
"0.6629595",
"0.6617... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def timing=(timing)
validator = EnumAttributeValidator.new('String', ["immediate", "renewal"])
unless validator.valid?(timing)
fail ArgumentError, "invalid value for 'timing', must be one of #{validator.allowable_values}."
end
@timing = timing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.70875543",
"0.6483564",
"0.64317095",
"0.62286377",
"0.614331",
"0.5812138",
"0.5751908",
"0.57455283",
"0.5738135",
"0.57083595",
"0.57014704",
"0.5678817",
"0.56032133",
"0.55945593",
"0.55489385",
"0.553774",
"0.55357426",
"0.5529098",
"0.54367936",
"0.54300535",
"0.542... | 0.0 | -1 |
Custom attribute writer method with validation | def amount=(amount)
if !amount.nil? && amount < 0
fail ArgumentError, "invalid value for 'amount', must be greater than or equal to 0."
end
@amount = amount
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 quantity=(quantity)
if !quantity.nil? && quantity < 1
fail ArgumentError, "invalid value for 'quantity', must be greater than or equal to 1."
end
@quantity = quantity
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 checking allowed values (enum). | def billing=(billing)
validator = EnumAttributeValidator.new('String', ["prorated", "full", "zero_amount", "none"])
unless validator.valid?(billing)
fail ArgumentError, "invalid value for 'billing', must be one of #{validator.allowable_values}."
end
@billing = billing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def compensation_method=(compensation_method)
validator = EnumAttributeValidator.new('String', ["full_refund", "prorated_refund", "full_credit", "prorated_credit", "none"])
unless validator.valid?(compensation_method)
fail ArgumentError, "invalid value for 'compensation_method', must be one of #{validator.allowable_values}."
end
@compensation_method = compensation_method
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.70875543",
"0.6483564",
"0.64317095",
"0.62286377",
"0.614331",
"0.5812138",
"0.5751908",
"0.57455283",
"0.5738135",
"0.57083595",
"0.57014704",
"0.5678817",
"0.56032133",
"0.55945593",
"0.55489385",
"0.553774",
"0.55357426",
"0.5529098",
"0.54367936",
"0.54300535",
"0.542... | 0.0 | -1 |
Custom attribute writer method checking allowed values (enum). | def partial_period_handling=(partial_period_handling)
validator = EnumAttributeValidator.new('String', ["bill_full", "bill_prorated", "bill_zero_amount", "no_bill"])
unless validator.valid?(partial_period_handling)
fail ArgumentError, "invalid value for 'partial_period_handling', must be one of #{validator.allowable_values}."
end
@partial_period_handling = partial_period_handling
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_attribute_with_enum(attr, value)\n write_attribute_without_enum attr, converted_enum(attr, value)\n end",
"def attr_enum(name, enum, options={}, &block)\n raise ArgumentError, 'enum' unless enum && enum.respond_to?(:values)\n\n options = {\n :enum => enum,\n ... | [
"0.7088127",
"0.64820594",
"0.6429773",
"0.6227689",
"0.61418885",
"0.5809922",
"0.57507086",
"0.5743216",
"0.5736045",
"0.5708027",
"0.57014966",
"0.56777334",
"0.5601988",
"0.55947953",
"0.55464065",
"0.55371004",
"0.55344343",
"0.5528221",
"0.5434983",
"0.54312384",
"0.541... | 0.0 | -1 |
Checks equality by comparing each attribute. | def ==(o)
return true if self.equal?(o)
self.class == o.class &&
timing == o.timing &&
plan == o.plan &&
amount == o.amount &&
quantity == o.quantity &&
billing == o.billing &&
amount_incl_vat == o.amount_incl_vat &&
compensation_method == o.compensation_method &&
partial_period_handling == o.partial_period_handling &&
start_date == o.start_date &&
cancel_change == o.cancel_change &&
add_ons == o.add_ons &&
remove_add_ons == o.remove_add_ons
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
[timing, plan, amount, quantity, billing, amount_incl_vat, compensation_method, partial_period_handling, start_date, cancel_change, add_ons, remove_add_ons].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 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 = Reepay.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.84287274",
"0.8345594",
"0.8345594"
] | 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 |
Fetch a todoable list by ID for authenticated user | def find_list(id)
check_token
response = self.class.get("/lists/#{id}", headers: headers)
check_and_raise_errors(response)
Todoable::List.build_from_response(response.parsed_response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def todo_list\n TodoList.find_by(user_id: current_user['sub'])\n end",
"def get(id:)\n list = client.get_list(id: id)\n\n Todoable::List.new(list)\n end",
"def get_list(id)\n record \"/todos/list/#{id}\"\n end",
"def set_todo_list\n begin\n @todo_list = current_user.tod... | [
"0.77521765",
"0.7702502",
"0.75598496",
"0.7233524",
"0.7153296",
"0.70743227",
"0.6940351",
"0.68954396",
"0.6869285",
"0.68367934",
"0.67996114",
"0.674782",
"0.67412746",
"0.6738131",
"0.6675571",
"0.6670432",
"0.66499364",
"0.66397166",
"0.6631923",
"0.6569772",
"0.65582... | 0.70252156 | 6 |
Create a list with a name | def create_list(name:)
check_token
list = Todoable::List.new(name: name)
response = self.class.post(
'/lists', body: list.post_body, headers: headers
)
check_and_raise_errors(response)
attributes = response.parsed_response.merge!('items' => [])
Todoable::List.build_from_response(attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"lists\", data)\n end",
"def generate_list(name, count); end",
"def create_list(name)\n path = \"lists\"\n params = { list: { name: name }}\n list = request(path, params, :post)\n list_id = ... | [
"0.74762064",
"0.74018234",
"0.7340271",
"0.72752887",
"0.723564",
"0.7056499",
"0.70011747",
"0.6907137",
"0.6852303",
"0.67961806",
"0.6737306",
"0.6697882",
"0.66905147",
"0.66521937",
"0.66191185",
"0.66169417",
"0.65872747",
"0.6578596",
"0.65366775",
"0.6420805",
"0.639... | 0.667133 | 13 |
Update a list with a new name | def update_list(list_id:, name:)
check_token
list = Todoable::List.new(name: name)
response = self.class.patch(
"/lists/#{list_id}",
body: list.post_body,
headers: headers,
format: :text
)
check_and_raise_errors(response)
# This endpoint returns a plaintext body: "<new name> updated", so
# while I'd like to return a List with ListItems, that would require
# first looking up the list which isn't ideal. So we'll return true, ask
# todoable to fix this endpoint, and make developers keep track of the
# name change
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_list_name(id, new_name)\n sql = \"UPDATE lists SET name = $1 WHERE id = $2\"\n query(sql, new_name, id)\n end",
"def update_list(list_name, text)\n update_value(\"#{list_name}-list\", text)\n end",
"def rename_list(list_id, name)\n path = \"lists/#{list_id}\"\n params = { list: { na... | [
"0.81797",
"0.7860275",
"0.77589995",
"0.74683636",
"0.73006225",
"0.72081065",
"0.71912116",
"0.71633226",
"0.708184",
"0.6998175",
"0.696739",
"0.696739",
"0.69560194",
"0.6950948",
"0.6833445",
"0.68270445",
"0.6822277",
"0.67883027",
"0.67880416",
"0.67880416",
"0.6751274... | 0.71924657 | 6 |
Delete a list and its items for an authenticated user | def delete_list(id:)
check_token
response = self.class.delete("/lists/#{id}", headers: headers)
check_and_raise_errors(response)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end",
"def delete_list(params={})\n @obj.delete('delete', @auth.merge(params))\n end",
"def destroy\n authorize @list\n @list.destroy\n head :no_content\n end",
"def destroy\n @list = current_... | [
"0.8100903",
"0.79223645",
"0.767124",
"0.7668876",
"0.7663366",
"0.75563467",
"0.7552064",
"0.7412968",
"0.74017125",
"0.7314739",
"0.7314739",
"0.73095506",
"0.7244244",
"0.7240991",
"0.72336084",
"0.7213257",
"0.717839",
"0.71601725",
"0.7132194",
"0.7101568",
"0.7101266",... | 0.0 | -1 |
You can bid on an offer if you don't own it and it is open | def can_bid_on?(offer)
owns = (self == offer.user)
in_transaction = offer.responses.any? { |r| r.status != 'open' }
offer.is_parent_offer? && !owns && !in_transaction
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_receive_bids?\n is_parent_offer? && bids.empty?\n end",
"def bought?\n # paym\n end",
"def pending_offers_as_buyer\n self.offers_as_buyer.pending\n end",
"def accepted_bid\n accepted_response.present? ? accepted_response.bid : nil\n end",
"def bidding_open?\n return self.auction_... | [
"0.6836891",
"0.6794581",
"0.66933584",
"0.6650531",
"0.65907526",
"0.6590148",
"0.6570641",
"0.6562806",
"0.6562806",
"0.6552732",
"0.64454174",
"0.64386225",
"0.6432306",
"0.6432306",
"0.64285624",
"0.642609",
"0.64209837",
"0.6394601",
"0.6394601",
"0.6394601",
"0.6363933"... | 0.790385 | 0 |
Get the nearest node that contains the specified index. | def node_at(line, column)
tree_at(line, column).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_nearest_node(key) #:nodoc:\n x = anchor\n level = node_level(x)\n while level > 0\n level -= 1\n xnext = node_next(x, level)\n while node_compare(xnext, key) <= 0\n x = xnext\n xnext = node_next(x, level)\n end\n end\n x\n end",
"... | [
"0.71722895",
"0.7164428",
"0.70908165",
"0.69877434",
"0.6980247",
"0.69622743",
"0.69622743",
"0.69171876",
"0.68772894",
"0.6867266",
"0.68614256",
"0.68538165",
"0.68352306",
"0.67562836",
"0.6672253",
"0.6617807",
"0.659729",
"0.6583029",
"0.6477225",
"0.6408134",
"0.640... | 0.5900618 | 76 |
True if the specified location is inside a string. | def string_at?(line, column)
node = node_at(line, column)
# @todo raise InvalidOffset or InvalidRange or something?
return false if node.nil?
node.type == :str or node.type == :dstr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_substring?(string)\n !!@pointer.node_at(string)\n end",
"def contains?(string)\n node = @root\n string.each_char do |letter|\n return false unless node[letter]\n node = node[letter]\n end\n\n node[@end_symbol] ? true : false\n end",
"def custom_include?(str, substr)\n... | [
"0.67478484",
"0.65356946",
"0.64449733",
"0.64311224",
"0.63585126",
"0.6252691",
"0.62215734",
"0.62133944",
"0.61819476",
"0.61453235",
"0.6102149",
"0.6092413",
"0.6060883",
"0.60585344",
"0.6058458",
"0.603991",
"0.60247666",
"0.6010176",
"0.60053724",
"0.5997736",
"0.59... | 0.6569834 | 1 |
Get an array of nodes containing the specified index, starting with the nearest node and ending with the root. | def tree_at(line, column)
offset = Position.line_char_to_offset(@code, line, column)
stack = []
inner_tree_at @node, offset, stack
stack
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_at(index)\n if index >= self.size\n puts \"index out of range.\"\n else\n each_with_index do |node, i|\n return node if index == i \n end\n end\n end",
"def at(index)\n node = @head\n index.times do\n node = node.next_node\n return nil if node.nil?\n e... | [
"0.6042243",
"0.602964",
"0.60155445",
"0.5871705",
"0.58069557",
"0.5804123",
"0.56935906",
"0.56935674",
"0.56849885",
"0.56557804",
"0.5644573",
"0.56325054",
"0.5613536",
"0.56030506",
"0.5582477",
"0.55813146",
"0.5580539",
"0.55789447",
"0.5574872",
"0.55604285",
"0.555... | 0.0 | -1 |
Helper macros to use internally | def output_internal_helper_macros
putd "/* -- INTERNAL HELPER MACROS -- */"
define_return_sequence_helper
define_custom_fake_sequence_helper
define_reset_fake_macro
define_declare_arg_helper
define_declare_all_func_common_helper
define_declare_return_value_history
define_save_arg_helper
define_room_for_more_history
define_save_ret_history_helper
define_save_arg_history_helper
define_history_dropped_helper
define_value_function_variables_helper
define_custom_fake_seq_variables_helper
define_increment_call_count_helper
define_return_fake_result_helper
define_extern_c_helper
define_reset_fake_helper
putd "/* -- END INTERNAL HELPER MACROS -- */"
puts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def macro; end",
"def macro; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def macro; raise NotImplementedError; end",
"def define_helpers; end",
"def define; end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def formatPreproce... | [
"0.7449284",
"0.7449284",
"0.6381346",
"0.6381346",
"0.6381346",
"0.6027485",
"0.59765637",
"0.58085996",
"0.58085996",
"0.58085996",
"0.5782527",
"0.57596916",
"0.5733918",
"0.5702125",
"0.56943065",
"0.56943065",
"0.5671849",
"0.5612358",
"0.55247223",
"0.55237025",
"0.5497... | 0.6378281 | 5 |
multiline putd which adds a \ at the end of the generated macro | def putd_backslash str
putd(str + " \\")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def putc(*line)\n raise unless @state == :asm\n @outp.puts(formatDump(\" \" + line.join(''), lastComment))\n end",
"def join_define(text)\n text = text.split(\"\\n\\n\", 2).first || \"\"\n\n # Ruby 1.8 does not support negative lookbehind regex so let's\n # get the joined macro... | [
"0.6350613",
"0.6183881",
"0.5949563",
"0.5913823",
"0.5894897",
"0.5766995",
"0.5741963",
"0.5734899",
"0.5700001",
"0.56970716",
"0.5639991",
"0.5623113",
"0.5552626",
"0.55322295",
"0.55322295",
"0.55085677",
"0.5505156",
"0.55037475",
"0.54967415",
"0.547591",
"0.54742944... | 0.58864075 | 5 |
define macro_name(RETURN_TYPE, FUNCNAME, ARG0,...) | def output_macro_name(macro_name, arg_count, has_varargs, has_calling_conventions, return_type)
putd "#define " + macro_signature_for(macro_name, arg_count, has_varargs, has_calling_conventions, return_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def macro_signature_for(macro_name, arg_count, has_varargs, has_calling_conventions, return_type)\n parameter_list = \"#{macro_name}(\"\n if return_type != \"\"\n parameter_list += return_type\n parameter_list += \", \"\n end\n parameter_list += \"CALLING_CONVENTION, \" if (has_calling_conventions)\n pa... | [
"0.7344821",
"0.6278074",
"0.6278074",
"0.6174589",
"0.6174589",
"0.57493454",
"0.57493454",
"0.57493454",
"0.57493454",
"0.5740502",
"0.56576455",
"0.56576455",
"0.55900216",
"0.5581706",
"0.55465806",
"0.54793566",
"0.54793566",
"0.54793566",
"0.54793566",
"0.54793566",
"0.... | 0.6908462 | 1 |
macro_name(RETURN_TYPE, FUNCNAME, ARG0,...) \ | def macro_signature_for(macro_name, arg_count, has_varargs, has_calling_conventions, return_type)
parameter_list = "#{macro_name}("
if return_type != ""
parameter_list += return_type
parameter_list += ", "
end
parameter_list += "CALLING_CONVENTION, " if (has_calling_conventions)
parameter_list += "FUNCNAME"
arg_count.times { |i| parameter_list += ", ARG#{i}_TYPE" }
parameter_list += ", ..." if has_varargs
parameter_list += ") \\"
parameter_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_macro_name(macro_name, arg_count, has_varargs, has_calling_conventions, return_type)\n putd \"#define \" + macro_signature_for(macro_name, arg_count, has_varargs, has_calling_conventions, return_type)\nend",
"def macro; end",
"def macro; end",
"def macro\n # -> uncomment the next line to man... | [
"0.6904612",
"0.67198914",
"0.67198914",
"0.65299755",
"0.6259939",
"0.6259939",
"0.59508115",
"0.58626467",
"0.5840569",
"0.5732275",
"0.5701674",
"0.568185",
"0.56422156",
"0.5628717",
"0.56084174",
"0.5575177",
"0.5550959",
"0.5517609",
"0.5475656",
"0.5466418",
"0.5466418... | 0.7313522 | 0 |
example: ARG0_TYPE arg0, ARG1_TYPE arg1 | def arg_val_list(args_count)
return "void" if (args_count == 0)
arguments = []
args_count.times { |i| arguments << "ARG#{i}_TYPE arg#{i}" }
arguments.join(", ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type _args\n \"type _args;\" \n end",
"def args(*) end",
"def type=(_arg0); end",
"def type=(_arg0); end",
"def type=(_arg0); end",
"def type=(_arg0); end",
"def type=(_arg0); end",
"def type=(_arg0); end",
"def type=(_arg0); end",
"def type=(_arg0); end",
"def type=(_arg0); end",
... | [
"0.6980272",
"0.6963868",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.68407005",
"0.6825317",
"0.6805064",
"0.6760627",
"0.6760627",
"0.6760627",
"0.... | 0.65724605 | 24 |
RETURN_TYPE (custom_fake)(ARG0_TYPE arg0);\ OR RETURN_TYPE (CALLING_CONVENTION custom_fake)(ARG0_TYPE arg0);\ void (custom_fake)(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2);\ | def output_custom_function_signature(arg_count, has_varargs, has_calling_conventions, is_value_function)
return_type = is_value_function ? "RETURN_TYPE" : "void"
ap_list = has_varargs ? ", va_list ap" : ""
calling_conv = has_calling_conventions ? ", CALLING_CONVENTION" : ""
putd_backslash "CUSTOM_FFF_FUNCTION_TEMPLATE(#{return_type}#{calling_conv}, custom_fake, #{arg_type_list(arg_count)}#{ap_list});"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_me(some_code)\n some_code.call\nend",
"def call(*) end",
"def call(*) end",
"def what_am_i arg arg2\n \nend",
"def internal_deliver(mode, method_name, return_type, *args, &b) \n exp = expectations.find(method_name, mode, *args)\n# exp = expectations.find(method_name.underscore,... | [
"0.5956126",
"0.5877435",
"0.5877435",
"0.5621613",
"0.55576426",
"0.5556566",
"0.5543592",
"0.5543592",
"0.55231774",
"0.5517548",
"0.5503102",
"0.5486245",
"0.54757947",
"0.5459882",
"0.5450766",
"0.54363227",
"0.54363227",
"0.54363227",
"0.54363227",
"0.54363227",
"0.54363... | 0.5813386 | 3 |
example: RETURN_TYPE FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1) OR RETURN_TYPE CALLING_CONVENTION FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1) | def function_signature(arg_count, has_varargs, has_calling_conventions, is_value_function)
return_type = is_value_function ? "RETURN_TYPE" : "void"
varargs = has_varargs ? ", ..." : ""
calling_conventions = has_calling_conventions ?
"#{return_type} FFF_GCC_FUNCTION_ATTRIBUTES CALLING_CONVENTION FUNCNAME(#{arg_val_list(arg_count)}#{varargs})" :
"#{return_type} FFF_GCC_FUNCTION_ATTRIBUTES FUNCNAME(#{arg_val_list(arg_count)}#{varargs})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def single_returned_type(defn)\n returns = defn[3][1].rest.select do |child|\n child[0..2] == s(:call, nil, :returns)\n end\n if returns.count > 1\n raise 'Invalid stdlib class method definition: ' +\n \"#{@symbol_table.cclass}.#{defn[1]}\"\n elsif returns.count == 1\n ... | [
"0.57207525",
"0.5522323",
"0.5371888",
"0.5308808",
"0.53053224",
"0.5286602",
"0.52390224",
"0.51953083",
"0.51478446",
"0.50900024",
"0.507325",
"0.5060967",
"0.50418895",
"0.5026886",
"0.4963419",
"0.49342653",
"0.49314213",
"0.49300718",
"0.49287593",
"0.49287593",
"0.48... | 0.5996886 | 0 |
invoke move on entity unless blocked by map | def move(entity, direction)
entity.move(direction) if entity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_entity entity; end",
"def process_moving_entity(entity)\n unless @registry[entity.registry_id]\n puts \"#{entity} not in registry yet, no move to process\"\n yield\n return\n end\n\n before_x, before_y = entity.x, entity.y\n\n yield\n\n if moved = (entity.x != before_x || e... | [
"0.69359183",
"0.6908279",
"0.65862846",
"0.65085536",
"0.64431393",
"0.64431393",
"0.63592637",
"0.6269995",
"0.6250293",
"0.62378174",
"0.6220615",
"0.61999655",
"0.6195241",
"0.61748236",
"0.6166403",
"0.61662674",
"0.6129725",
"0.6120305",
"0.6120305",
"0.6104659",
"0.605... | 0.65239 | 3 |
kick core websocket gameplay loop | def react!
@started_at = Time.now
EM.next_tick do
EM.add_periodic_timer(TICK_INTERVAL) do
@last_tick ||= 0
# puts "==== tick! last one was #{Time.now - @last_tick} ago"
@last_tick = Time.now
# moves = @next_moves
removals = @scheduled_removals.dup
removals.each do |entity|
entity_group = @entities.detect { |es| es.include?(entity) }
if entity_group
sockets.values.each do |s|
data = {depth: @entities.index(entity_group), entity_id: entity.guid }
transmit 'removal', data, s
end
end
puts ">>>> DELETING ENTITY"
entity_group.delete(entity) if entity_group
@scheduled_removals.delete(entity)
# recompute all fovs? (seems like we could at least limit to heroes on this level, but should really be a question of asking the heroes if the object is visible)
# timing of this could also be problematic
heroes.each { |h| h.build_fov_map }
end
# step!
@heroes.each { |h| h.update }
@next_moves.each do |entity, direction|
if move(entity, direction)
# entity.recompute_fov if entity.is_a?(Hero)
# end
# end
# moves.each do |entity, _|
sockets.values.each do |s|
if entity.is_a?(Roguecraft::Hero)
message_data = entity.attributes.merge({
visible: entity.now_visible,
invisible: entity.now_invisible
})
puts "=== currently visible: #{entity.now_visible.inspect}"
transmit 'move', message_data, s
end
end
end
end
@next_moves = {}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play socket\n end",
"def run(opts)\n\n EventMachine.run {\n @players = []\n @game = Game.new\n @turn_schedule = nil\n\n web_app = opts[:app]\n\n dispatch = Rack::Builder.app do\n map '/' do\n run web_app\n end\n end\n\n Rack::Server.start({\n app: dispatch,\n ... | [
"0.6592833",
"0.63241875",
"0.62373143",
"0.6120532",
"0.6092128",
"0.604287",
"0.601848",
"0.60132366",
"0.6001739",
"0.5999792",
"0.5985935",
"0.59695977",
"0.5931094",
"0.59282905",
"0.5926197",
"0.59178203",
"0.5895238",
"0.5869406",
"0.5854603",
"0.5841808",
"0.5831969",... | 0.0 | -1 |
scan for a pattern in a snippet, for each pattern found, assign the last word from rand_words array, to names variable (capitalize only if caps = true) | def craft_names(rand_words, snippet, pattern, caps=false) # caps defaults to false
names = snippet.scan(pattern).map do
word = rand_words.pop()
caps ? word.capitalize : word
end
return names * 2 # return the names variable twice as an array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def craft_names(rand_words, snippet, pattern, caps = false)\n\tnames = snippet.scan(pattern).map do\n\t\tword = rand_words.pop()\n\t\tcaps ? word.capitalize : word\n\tend\n\t\n\treturn names * 2\t\nend",
"def craft_names(rand_words, snippet, pattern, caps=false)\nnames = snippet.scan(pattern).map do\n word = ra... | [
"0.82401747",
"0.8130118",
"0.79906577",
"0.65076303",
"0.6469055",
"0.6358023",
"0.6070672",
"0.6006945",
"0.5979286",
"0.59258187",
"0.58767855",
"0.5865621",
"0.58184326",
"0.5786329",
"0.57666796",
"0.57271266",
"0.56742775",
"0.56160384",
"0.55847496",
"0.55594605",
"0.5... | 0.8299373 | 0 |
Set types to each expressions | def check
set_superclasses!(@program.fclasses)
@program.fclasses.each{|k, v| check_fclass(v)}
type_expr!(@program.expr, {})
return @program.expr.type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expression_set(type, string)\n case type\n when :date\n date_expressions\n when :time\n time_expressions\n when :datetime\n # gives a speed-up for date string as datetime attributes\n if string.length < 11\n date_expressions + datetime_... | [
"0.68392897",
"0.6173443",
"0.58851725",
"0.5774013",
"0.5740963",
"0.57252145",
"0.57252145",
"0.57085407",
"0.5682831",
"0.55939233",
"0.5567317",
"0.55449843",
"0.55209345",
"0.551837",
"0.5511317",
"0.5499792",
"0.5475987",
"0.5475987",
"0.5475987",
"0.5475987",
"0.547598... | 0.0 | -1 |
Return true when t1 <: t2 | def subtype?(t1, t2)
return true if t1 == t2
fclass(t2) # Check existance of class t2
return fclass(t1).descendant_of?(t2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kind_of?(other)\n super || object.kind_of?(other)\n end",
"def <= (t)\n self == t || t.is_super_of?(self)\n end",
"def kind_of?(other)\n super || __getobj__.kind_of?(other)\n end",
"def assignable?(t, t2)\n if t.is_a?(Module)\n t = type(t)\n end\n t.is_a?(PAnyType) ?... | [
"0.6692199",
"0.6642902",
"0.6426827",
"0.64179045",
"0.63976806",
"0.6364597",
"0.6364343",
"0.6313674",
"0.62850547",
"0.61794823",
"0.6166119",
"0.61381817",
"0.61233985",
"0.607093",
"0.6046963",
"0.6023686",
"0.6023686",
"0.6023686",
"0.6005221",
"0.59775126",
"0.5976119... | 0.7655484 | 0 |
and b) the number of times it was repeated in that consecutive block. The output can be whatever format you choose (array with the letter in the first index and the count in the second, or perhaps a string with a letter and a number as a character). Example input: "rrSSrrrrPQr" would return "r4" or ["r", 4] Time: O(n) Space: O(1) | def most_repeated_letter(string)
letter = ""
count = 0
length = string.length
i = 0
current_count = 1
while i < length
if string[i] == string[i+1]
current_count += 1
else
if current_count > count
count = current_count
letter = string[i]
end
current_count = 1
end
i += 1
end
return "#{letter}#{count}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_repeats(string)\n \nidx1 = 0 #Made a counter for first loop\nidx2 = 0 #Made another counter for the second loop\nrepeat_count = 0 #Assigned a variable to tally the number of letters that had repeated in the string\ncurrent_repeat_count= []\nidx3 = 0\n while idx1 < string.length #The characters ... | [
"0.7440535",
"0.7399826",
"0.7308909",
"0.72962517",
"0.7215785",
"0.71923643",
"0.7158871",
"0.7152598",
"0.71241426",
"0.71065724",
"0.7075475",
"0.7053894",
"0.70304793",
"0.70052737",
"0.698804",
"0.6950817",
"0.694299",
"0.6937352",
"0.69308907",
"0.6916916",
"0.6892098"... | 0.65194833 | 51 |
Return the eval string. We get this as the parameter to the eval C call. A bit of checking is done to make sure everything is okay: we have to be in an EVAL type frame which has an iseq we have to have a prev frame which is a CFUNC the prev method name has to be 'eval' | def eval_string(frame)
return nil unless 'EVAL' == frame.type && frame.iseq
prev = frame.prev
return nil unless prev && 'CFUNC' == prev.type && 'eval' == prev.method
retval = prev.sp 3
retval = $1 if retval =~ /^\(eval "(.+)"\)/
retval
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_eval(string, ebinding=Mission.eval_binding)\n ebinding = ebinding.call if ebinding.is_a?(Proc)\n eval(string, ebinding)\n end",
"def eval(str)\n end",
"def eval(s, *rest)\n file, line = __find_caller__(caller())\n $__gen_code__[[file, line]] = {\n :binding => nil, \... | [
"0.6169209",
"0.6132331",
"0.59505296",
"0.593356",
"0.5745648",
"0.57366455",
"0.5699014",
"0.5663234",
"0.5615437",
"0.56154007",
"0.5581526",
"0.5554907",
"0.55529386",
"0.551529",
"0.5507912",
"0.5504082",
"0.5475119",
"0.5472345",
"0.5456916",
"0.54453486",
"0.54262865",... | 0.76864433 | 0 |
Return true if frame1 and frame2 are at the same place. We use this for example in detecting tail recursion. | def location_equal(frame1, frame2)
frame1 && frame2 && frame1.source_location == frame2.source_location &&
frame1.pc_offset == frame2.pc_offset &&
frame1.source_container == frame2.source_container
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location_equal(other_frame)\n # if self && other_frame \n # puts(self.vm_location.line, other_frame.vm_location.line, \n # self.vm_location.ip, other_frame.vm_location.ip, \n # self.vm_location.method.active_path, other_frame.vm_locaion.method.actionve_path)\n # end\n ... | [
"0.7118627",
"0.662954",
"0.6567314",
"0.6567314",
"0.6483421",
"0.6483421",
"0.6194595",
"0.6100733",
"0.6100733",
"0.6100733",
"0.604208",
"0.5976597",
"0.59662545",
"0.5863789",
"0.5811881",
"0.5798389",
"0.57770544",
"0.5776023",
"0.5766855",
"0.57663816",
"0.57617146",
... | 0.8015964 | 0 |
Print `count' frame entries | def print_stack_trace(frame, opts={})
opts = DEFAULT_STACK_TRACE_SETTINGS.merge(opts)
halfstack = (opts[:maxstack]+1) / 2
n = frame.stack_size
n = [n, opts[:count]].min if opts[:count]
if n > (halfstack * 2)
print_stack_trace_from_to(0, halfstack-1, frame, opts)
msg "... %d levels ..." % (n - halfstack*2)
last_frame = print_stack_trace_from_to(n - halfstack, n-1, frame, opts)
else
last_frame = print_stack_trace_from_to(0, n-1, frame, opts)
end
msg "(More stack frames follow...)" if last_frame.type != 'TOP'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_frame(count)\n\n clear_screen()\n\n if count == 0\n 12.times {puts \" \"}\n elsif count == 1\n 9.times {puts \" \"}\n puts \" _________ \"\n 2.times {puts \" \"}\n elsif count == 2\n 3.times {puts \" \"}\n puts \" | \"\n puts \" | \"\n pu... | [
"0.6398167",
"0.618714",
"0.61649483",
"0.6086265",
"0.6048901",
"0.60183513",
"0.59998345",
"0.59485203",
"0.5860821",
"0.5859112",
"0.5853356",
"0.5843102",
"0.5800844",
"0.57703024",
"0.57674855",
"0.5742932",
"0.5740459",
"0.57307523",
"0.57072306",
"0.56860375",
"0.56767... | 0.53811044 | 60 |
creates new session for user with authentication | def create
params.inspect
params[:user][:email] = params[:user][:email].downcase
params.inspect
user = User.find_by(email: params[:user][:email])
if user && user.authenticate(params[:user][:password])
session[:user_id] = user.id.to_s
redirect_to recipes_path
else
flash[:danger]= "Invalid login credentials."
redirect_to login_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_session\n login, password = get_login_and_password\n create_session_with authenticate_user(login, password, :trace => true)\n end",
"def new_user_session(user)\n session = new_session\n session.login!(user)\n return session\n end",
"def create_session\n req_params = params[:user]... | [
"0.82554793",
"0.80660903",
"0.79936004",
"0.7928978",
"0.7843265",
"0.77816784",
"0.7773531",
"0.7729638",
"0.77070653",
"0.76557976",
"0.76029485",
"0.75800085",
"0.7536167",
"0.7524035",
"0.7520292",
"0.75050956",
"0.7503108",
"0.7490362",
"0.74879897",
"0.7483386",
"0.747... | 0.0 | -1 |
logs user out of session/delete session | def destroy
session[:user_id]=nil
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_out\n \tsession.delete(:user_id)\n \t@current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n end",
"def log_out\n session.delete(:user_id)\n @current_user = nil\n\n end",
"def log_out \n session.clear\n @current_user = nil\n end",
"def log... | [
"0.8847182",
"0.881492",
"0.8783745",
"0.8782671",
"0.8770488",
"0.87580764",
"0.87580764",
"0.87580764",
"0.87580764",
"0.8757814",
"0.8754921",
"0.8754602",
"0.8751901",
"0.8751888",
"0.8751888",
"0.8751888",
"0.8751888",
"0.8751888",
"0.8751888",
"0.8751888",
"0.8751888",
... | 0.0 | -1 |
Connects to the Browserstack REST API and makes a PUT request to update the session with the matching +session_id+ to 'passed'. It returns a string which can be used as a message for output confirming the action. | def passed(session_id)
check_before_update(session_id, status: "passed")
"Browserstack session #{session_id} status set to \e[32mpassed\e[0m 😀"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @current_session = CurrentSession.find(params[:id])\n\n if @current_session.update(params[:current_session])\n head :no_content\n else\n render json: @current_session.errors, status: :unprocessable_entity\n end\n end",
"def update\n @session = @event.sessions.find(params[:i... | [
"0.6618149",
"0.64700043",
"0.6253981",
"0.6246038",
"0.62323993",
"0.62320304",
"0.62320304",
"0.6228393",
"0.62149775",
"0.6205324",
"0.6197566",
"0.6141522",
"0.6126286",
"0.6120822",
"0.6082385",
"0.6081707",
"0.6031955",
"0.6031955",
"0.6031955",
"0.6031955",
"0.6023681"... | 0.6255669 | 2 |
Connects to the Browserstack REST API and makes a PUT request to update the session with the matching +session_id+ to 'failed'. It returns a string which can be used as a message for output confirming the action. | def failed(session_id)
check_before_update(session_id, status: "failed")
"Browserstack session #{session_id} status set to \e[31mfailed\e[0m 😢"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @session_resource = SessionResource.find(params[:id])\n\n if @session_resource.update(session_resource_params)\n head :no_content\n else\n render json: @session_resource.errors, status: :unprocessable_entity\n end\n end",
"def update\n @current_session = CurrentSession.find... | [
"0.64133257",
"0.6306385",
"0.60378754",
"0.6013301",
"0.5861529",
"0.5861529",
"0.5860904",
"0.5860102",
"0.57726437",
"0.5761166",
"0.57418865",
"0.57270175",
"0.57232255",
"0.5702644",
"0.56772065",
"0.56475776",
"0.5637619",
"0.5624029",
"0.5623909",
"0.5598913",
"0.55530... | 0.7079413 | 0 |
:reek:DuplicateMethodCall rubocop:disable Style/StringLiterals, Metrics/LineLength, Rails/OutputSafety | def sp_msg(section, args = {})
args = args.merge(sp_name: sp_name)
args = args.merge(sp_create_link: sp_create_link)
return t("service_providers.#{sp_alert_name}.#{section}", args).html_safe if sp.friendly_name == "The FMCSA Drug & Alcohol Clearinghouse" && custom_alert?
return t("service_providers.#{sp_alert_name}.#{section}", args) if custom_alert?
t("service_providers.default.#{section}", args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def string()\n #This is a stub, used for indexing\n end",
"def as_you_like_it_quote; end",
"def private_method\n end",
"def string?; end",
"def to_s\n raise StandardError, \"#{self.class.name}#to_s accessed, must be redefined.\"\n end",
"def string() end",
"... | [
"0.63121074",
"0.5843608",
"0.5812137",
"0.5678669",
"0.5661342",
"0.5610322",
"0.5600049",
"0.5575512",
"0.5575512",
"0.5575512",
"0.5575512",
"0.5575512",
"0.5575512",
"0.5575512",
"0.5575512",
"0.5575512",
"0.5569264",
"0.5569264",
"0.5569264",
"0.5546131",
"0.55445075",
... | 0.0 | -1 |
rubocop:enable Style/StringLiterals, Metrics/LineLength, Rails/OutputSafety | def sp_logo
sp.logo || DEFAULT_LOGO
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string() end",
"def string?; end",
"def str; end",
"def str; end",
"def string()\n #This is a stub, used for indexing\n end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",
"def string; end",... | [
"0.63708454",
"0.6247293",
"0.61979115",
"0.61979115",
"0.6178588",
"0.6156243",
"0.6156243",
"0.6156243",
"0.6156243",
"0.6156243",
"0.6156243",
"0.6156243",
"0.6156243",
"0.6156243",
"0.6078768",
"0.60410863",
"0.60108125",
"0.59613734",
"0.59613734",
"0.5927105",
"0.592710... | 0.0 | -1 |
overriding to allow action on an on_hold task | def actions_available?(user)
actions_allowable?(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hold\n action('hold')\n end",
"def held(&block)\n @hold_callback = block\n end",
"def do_hold(last_check)\n if last_check.off?\n # If the status report says the Equipment is offline, try\n # resending the Task. If that doesn't work, fail and punt to the launcher.\n ... | [
"0.7364444",
"0.67987734",
"0.6677081",
"0.6055394",
"0.5993183",
"0.5986212",
"0.59062034",
"0.5881514",
"0.5874519",
"0.58523846",
"0.5814171",
"0.5761196",
"0.573183",
"0.573183",
"0.57186127",
"0.5683897",
"0.56623787",
"0.5642788",
"0.56292844",
"0.5625426",
"0.5608021",... | 0.0 | -1 |
ensures this task gets completed when child TimedHoldTask is completed after 30 days | def cascade_closure_from_child_task?(child_task)
return true if child_task&.type == TimedHoldTask.name
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def when_timer_ends\n IhpTasksFactory.new(parent).create_ihp_tasks!\n update!(status: :completed)\n end",
"def on_end_task\n mutex.synchronize do\n @completed_task_count += 1 #if success\n break unless running?\n end\n end",
"def ensure_finished\n ensure_exists!\n ... | [
"0.67195743",
"0.6183682",
"0.5961619",
"0.57686126",
"0.5704758",
"0.5607227",
"0.5600854",
"0.55446035",
"0.54580194",
"0.5446398",
"0.5433218",
"0.5348812",
"0.5287242",
"0.5234523",
"0.5199004",
"0.51821643",
"0.5163482",
"0.51630723",
"0.5146329",
"0.51411515",
"0.513406... | 0.68373746 | 0 |
before_create When an object is created, it doesn't have access to the parent to determine if the photo should be stored privately. After creation, that information is available. So, we rerun the path Proc. | def recalculate_path
self.photo.instance_variable_set('@path', self.class.photo_path(self.private))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_save\n\t\t\tself.name ||= ''\n\t\t\tself.filename ||= self.name.downcase.gsub(/[^a-z0-9]+/, '-')\n\t\t\tif self.parent.nil?\n\t\t\t\tself.path = ''\n\t\t\telsif self.parent.path.empty?\n\t\t\t\tself.path = filename\n\t\t\telse\n\t\t\t\tself.path = self.parent.path + '/' + self.filename\n\t\t\tend\n\t\te... | [
"0.65017766",
"0.6337799",
"0.60018194",
"0.5998204",
"0.59672207",
"0.5900859",
"0.58760893",
"0.5853009",
"0.58304757",
"0.5820224",
"0.5757632",
"0.56925106",
"0.56909657",
"0.565624",
"0.5602336",
"0.55588543",
"0.5539258",
"0.55024433",
"0.54894584",
"0.54750896",
"0.547... | 0.63130647 | 2 |
Write a method fibs which takes a number and returns that many members of the fibonacci sequence. Use iteration for this solution. | def fibs(num)
array = []
0.upto(num) do |i|
array << i if i.zero? || i == 1
array << array[i - 1] + array[i - 2] if i > 1
end
array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibs(n)\nend",
"def fibs(number)\n\n\tfibonacci=[1]\n\tcount=0\n\tnum1=1\n\tnum2=0\n\twhile fibonacci.size<number\n\t\tsum=num1+num2\n\t\tfibonacci.push(sum)\n\t\tnum2=num1\n\t\tnum1=sum\n\tend\n\n\treturn fibonacci\nend",
"def fibs (n) #Non-recursive\n\n\t# n = number of Fibonacci sequence members.\n\t# 0... | [
"0.8179819",
"0.81324905",
"0.8102675",
"0.79911506",
"0.79887795",
"0.79661435",
"0.79661435",
"0.79661435",
"0.79661435",
"0.79661435",
"0.7954532",
"0.79141074",
"0.7870756",
"0.78506565",
"0.78427285",
"0.7836909",
"0.7835531",
"0.7833199",
"0.7813367",
"0.77798784",
"0.7... | 0.782208 | 18 |
Now write another method fibs_rec which solves the same problem recursively. This can be done in just 3 lines | def fibs_rec(num)
# base cases 0 and 1
return [0] if num.zero?
return [0, 1] if num == 1
array = fibs_rec(num - 1)
array << array[-2] + array[-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibs_rec(num, fib = [0,1])\n if num == 1\n 0\n elsif num == fib.length\n fib\n else\n result = fib[fib.length - 2] + fib[fib.length - 1]\n fib.push(result)\n fibs_rec(num, fib)\n end\nend",
"def fibs_rec(n, result = [0, 1])\n if n > 1\n result << result[-2] + result[-1]\n fibs_rec(n... | [
"0.8324548",
"0.80892473",
"0.8088708",
"0.8064074",
"0.8042706",
"0.79955125",
"0.7937973",
"0.7918121",
"0.78814024",
"0.7879105",
"0.7877967",
"0.78698117",
"0.7847271",
"0.78340495",
"0.78315073",
"0.7810743",
"0.7729339",
"0.7728065",
"0.7709655",
"0.77081597",
"0.767099... | 0.77247757 | 18 |
GET /purchases GET /purchases.json | def index
default = 1
page = params.fetch(:page, default)
@purchases = Purchase.mine(current_user, page)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n end",
"def index\n @purchases = Purchase.find_all_by_user_id(current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @purchases }\n en... | [
"0.80066895",
"0.77672255",
"0.76304215",
"0.76304215",
"0.7425575",
"0.73844385",
"0.7343369",
"0.73353374",
"0.7317721",
"0.7251758",
"0.7217834",
"0.7217834",
"0.7217834",
"0.7134681",
"0.70766836",
"0.70638627",
"0.70366734",
"0.6953153",
"0.6953153",
"0.69219077",
"0.692... | 0.67761844 | 23 |
POST /purchases POST /purchases.json | def create
begin
purchase = Purchase.new(history_params)
purchase.package = @package
purchase.user = current_user
# Get the credit card details submitted by the form
token = stripe_token_params
# Create the charge on Stripe's servers - this will charge the user's card
Purchase.transaction do
promo = ParamsHelper.parse_promo_code_query(params)
total = @package.total
if promo
total = promo.discount_price(total)
purchase.promo_code = promo
purchase.discount = @package.total - total
end
begin
charge = Stripe::Charge.create(
:amount =>(total * 100).to_i(), # amount in cents
:currency => "cad",
:source => token[:id],
:description => "#{@package.quantity} bids purchased"
)
purchase.transaction_id = charge.id
purchase.total = total
if purchase.save
render json: purchase
else
# This should NEVER happen, if it does, it requires immediate investigation
logger.fatal "Trying to create purchase #{purchase.inspect} resulted in errors: #{purchase.errors.full_messages}"
errors = errors_to_hash(purchase)
render json: errors, status: :unprocessable_entity
end
rescue Stripe::CardError => e
logger.warn "Card declined for purchase #{purchase.inspect}"
warn_exception(e)
errors = [ "Your credit card was declined by Stripe, please contact support"]
render json: errors, status: :unprocessable_entity
end
end
rescue ActiveRecord::RecordNotFound
render json: {:promo_code => "Promotion code is invalid"}, status: :bad_request
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_purchase\n user.purchases.create!(\n amount_in_cents: purchase_amount,\n employee_id: purchase_params.dig(:employee_id),\n qty: purchase_params.dig(:qty).to_i,\n venue_id: purchase_params.dig(:venue_id),\n tap_id: purchase_params.dig(:tap_id),\n description: purchase_params.... | [
"0.7372497",
"0.7361999",
"0.71180695",
"0.6974874",
"0.6905323",
"0.6883787",
"0.688361",
"0.68291336",
"0.68291336",
"0.68291336",
"0.6828237",
"0.6822894",
"0.6724764",
"0.6648243",
"0.663833",
"0.6632912",
"0.6583054",
"0.65470576",
"0.6493291",
"0.6436755",
"0.643611",
... | 0.6361487 | 25 |
Never trust parameters from the scary internet, only allow the white list through. | def history_params
params.require(:history).permit(:brand, :last_4, :exp_month, :exp_year)
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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.