query stringlengths 7 6.41k | document stringlengths 12 28.8k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 5 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
GET /photo_blogs GET /photo_blogs.json | def index
@photo_blogs = PhotoBlog.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @blogs = Blog.all\n\n render json: @blogs\n end",
"def index\n @blogs = Blog.all\n render json: @blogs\n end",
"def index\n @blogs = Blog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @blogs }\n end\n end",
"... | [
"0.7004081",
"0.69967824",
"0.6950476",
"0.6950476",
"0.6928955",
"0.6927045",
"0.6830014",
"0.6630224",
"0.6618953",
"0.6575687",
"0.6527057",
"0.6502092",
"0.64803094",
"0.6423872",
"0.641496",
"0.6410947",
"0.6359144",
"0.6345776",
"0.6310204",
"0.6280976",
"0.6280976",
... | 0.7580038 | 0 |
POST /photo_blogs POST /photo_blogs.json | def create
@photo_blog = PhotoBlog.new(photo_blog_params)
respond_to do |format|
if @photo_blog.save
format.html { redirect_to @photo_blog, notice: 'Photo blog was successfully created.' }
format.json { render action: 'show', status: :created, location: @photo_blog }
else
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @blog = Blog.new(blog_params)\n if @blog.save\n render json: @blog\n else\n render json: @blog.errors, status: :unprocessable_entity\n end\n end",
"def create\n blog = Blog.create(blog_params)\n\n if blog.save\n render json: blog, status: :created\n else\n r... | [
"0.66996586",
"0.65993214",
"0.65681255",
"0.6519417",
"0.6508927",
"0.6409146",
"0.6374629",
"0.635892",
"0.635282",
"0.63303524",
"0.632453",
"0.6312963",
"0.63025403",
"0.63020766",
"0.62943023",
"0.62797016",
"0.626506",
"0.6258422",
"0.6256232",
"0.6254656",
"0.62518924"... | 0.72765553 | 0 |
PATCH/PUT /photo_blogs/1 PATCH/PUT /photo_blogs/1.json | def update
respond_to do |format|
if @photo_blog.update(photo_blog_params)
format.html { redirect_to @photo_blog, notice: 'Photo blog was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @photo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n# @blog = Blog.find(params[:id])\n\n respond_to do |format|\n if @blog.update_attributes(params[:blog])\n format.html { redirect_to @blog, :notice => 'Blogs was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n... | [
"0.6482389",
"0.64401674",
"0.6429861",
"0.63413423",
"0.6327639",
"0.628811",
"0.62321866",
"0.6213813",
"0.61867833",
"0.61360097",
"0.61297935",
"0.61219364",
"0.6113652",
"0.6113145",
"0.61069196",
"0.61069196",
"0.6102901",
"0.6099186",
"0.60888284",
"0.6087478",
"0.6080... | 0.67973256 | 0 |
DELETE /photo_blogs/1 DELETE /photo_blogs/1.json | def destroy
@photo_blog.destroy
respond_to do |format|
format.html { redirect_to photo_blogs_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @myblog = Myblog.find(params[:id])\n @myblog.destroy\n\n respond_to do |format|\n format.html { redirect_to myblogs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @myblog = Myblog.find(params[:id])\n @myblog.destroy\n\n respond_to do |format|\n... | [
"0.7247025",
"0.7247025",
"0.71861714",
"0.70648754",
"0.7056167",
"0.7006981",
"0.69854367",
"0.69854367",
"0.6969176",
"0.6952985",
"0.6936024",
"0.69179326",
"0.6904932",
"0.6883215",
"0.68783176",
"0.68712384",
"0.6856189",
"0.68453664",
"0.68450713",
"0.68450713",
"0.684... | 0.77564365 | 0 |
GET /hscores GET /hscores.json | def index
@hscores = Hscore.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hourly_scores\n players = Player.all.order(:id)\n\n response_json = []\n\n players.each do |p|\n response_json.push({name: p.name, scores: p.get_hourly_scores})\n end\n\n render json: response_json\n end",
"def set_hscore\n @hscore = Hscore.find(params[:id])\n end",
"def index\... | [
"0.6644244",
"0.6520435",
"0.65198445",
"0.6167107",
"0.60353595",
"0.60153925",
"0.5986882",
"0.5963002",
"0.58825165",
"0.5854779",
"0.58544576",
"0.58269113",
"0.5818326",
"0.57936764",
"0.57473403",
"0.57316464",
"0.5714733",
"0.571192",
"0.5676559",
"0.56714946",
"0.5608... | 0.74886256 | 0 |
POST /hscores POST /hscores.json | def create
@hscore = Hscore.new(hscore_params)
respond_to do |format|
if @hscore.save
format.html { redirect_to @hscore, notice: 'Hscore was successfully created.' }
format.json { render action: 'show', status: :created, location: @hscore }
else
format.html { render action: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hscore_params\n params.require(:hscore).permit(:game, :score)\n end",
"def index\n @hscores = Hscore.all\n end",
"def create\n @high_score = HighScore.new(params[:high_score])\n\n respond_to do |format|\n if @high_score.save\n format.html { redirect_to @high_score, notice: 'Hi... | [
"0.64834553",
"0.615781",
"0.60518086",
"0.5989966",
"0.5961152",
"0.58835936",
"0.5882441",
"0.58031523",
"0.57800454",
"0.57534724",
"0.5728988",
"0.5612007",
"0.5606037",
"0.5589958",
"0.55512714",
"0.5547557",
"0.5525967",
"0.5525967",
"0.55222803",
"0.5519713",
"0.551971... | 0.70890814 | 0 |
PATCH/PUT /hscores/1 PATCH/PUT /hscores/1.json | def update
respond_to do |format|
if @hscore.update(hscore_params)
format.html { redirect_to @hscore, notice: 'Hscore was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @hscore.errors, status... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors,... | [
"0.5979002",
"0.596129",
"0.5944912",
"0.5943981",
"0.59211075",
"0.58778024",
"0.58696777",
"0.58582014",
"0.5823395",
"0.5801154",
"0.5759528",
"0.5704369",
"0.5692596",
"0.56765836",
"0.566905",
"0.56561923",
"0.56553316",
"0.5651828",
"0.5648165",
"0.5643571",
"0.5643571"... | 0.6906075 | 0 |
DELETE /hscores/1 DELETE /hscores/1.json | def destroy
@hscore.destroy
respond_to do |format|
format.html { redirect_to hscores_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @common_core = CommonCore.find(params[:id])\n @common_core.destroy\n\n respond_to do |format|\n format.html { redirect_to common_cores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @core = Core.find(params[:id])\n @core.destroy\n\n respond_to ... | [
"0.7045936",
"0.695999",
"0.65987045",
"0.65636444",
"0.65375",
"0.65214264",
"0.64567727",
"0.64567727",
"0.6423964",
"0.63983536",
"0.63706446",
"0.635787",
"0.63542265",
"0.6350534",
"0.6346498",
"0.6319486",
"0.6263135",
"0.6262736",
"0.6217275",
"0.6214553",
"0.62104744"... | 0.7668215 | 0 |
used to finalize a transaction for pages like join where we need a response before adding the uer, this does the rest of the purchase items. | def finalize_transaction(type='purchase')
self.save
self.user.make_paid! if (!user.nil? && user.persisted?)
self.transactions.create(action:type, amount: self.price_in_cents, response: self.purchase_response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finalize!\n update_attribute(:completed_at, Time.now)\n update_attribute(:payment_method_name, self.payment_method.name) unless self.payment_method_name\n self.out_of_stock_items = InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n adjustme... | [
"0.6480077",
"0.63544375",
"0.6291055",
"0.6281441",
"0.62500733",
"0.6094156",
"0.60428417",
"0.6018372",
"0.6011861",
"0.5879966",
"0.58615977",
"0.5802055",
"0.579744",
"0.5784571",
"0.5773792",
"0.57138956",
"0.5695641",
"0.5640582",
"0.56251097",
"0.55843127",
"0.5565109... | 0.6784187 | 0 |
Create a new CloudFunctionsService client object. | def initialize
# These require statements are intentionally placed here to initialize
# the gRPC module only when it's required.
# See https://github.com/googleapis/toolkit/issues/446
require "gapic/grpc"
require "google/cloud/functions/v1/functions_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n # These require statements are intentionally placed here to initialize\n # the gRPC module only when it's required.\n # See https://github.com/googleapis/toolkit/issues/446\n require \"gapic/grpc\"\n require \"google/cloud/functions/... | [
"0.62967694",
"0.59990144",
"0.591988",
"0.58444834",
"0.5707263",
"0.5669007",
"0.5649269",
"0.5644812",
"0.5633988",
"0.56114894",
"0.5600812",
"0.55979335",
"0.55531394",
"0.55496395",
"0.55480677",
"0.5540359",
"0.54974294",
"0.54863304",
"0.54598874",
"0.5413678",
"0.540... | 0.63331246 | 0 |
an input of MMDD throws an error on Date object, replaces a hyphen with a backslash, checks the input is valid. Asks the user if their birthday is in the form "February 9". | def check_birthday(input)
if input.include?('-')
input = input.gsub('-', '/')
elsif
input.length > 5 || input.length < 3
return false
elsif input.length == 4
if input[0].to_i > 1 || input[1].to_i > 2
puts "That date is not valid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_birthday_valid\n if((Date.parse(birthday.to_s) rescue ArgumentError) == ArgumentError)\n errors.add(:birthday, 'must be a valid day')\n end\n end",
"def valid_birthdate(input)\n if input.length == 8 && input.match(/^[0-9]+[0-9]$/)\n return true\n else\n return false\n end\n... | [
"0.754712",
"0.7474742",
"0.7285704",
"0.7226091",
"0.6998842",
"0.6847877",
"0.669696",
"0.6613486",
"0.65513563",
"0.6536648",
"0.6513443",
"0.6491905",
"0.6476975",
"0.64543766",
"0.6437407",
"0.641835",
"0.6383511",
"0.6352529",
"0.6326764",
"0.6313372",
"0.63126653",
"... | 0.84726614 | 0 |
takes the user inputted DOB, serches through the dates in all Zodiac instances using the Date object, returns the zodiac instance. Exception made for Capricorn because beginning of year /end of year | def user_input_to_zodiac(input)
zodiac_sign = ''
dates = []
Zodiac.all_dates.each do |date_array|
if Date.parse(input).between?(Date.parse(date_array[0]), Date.parse(date_array[1]))
dates = date_array
end
end
Zodiac.all.each do |zodiac|
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def easter\n y = year\n a = y % 19\n b = y / 100\n c = y % 100\n d = b / 4\n e = b % 4\n f = (b + 8) / 25\n g = (b - f + 1) / 3;\n h = (19 * a + b - d - g + 15) % 30\n i = c / 4\n k = c % 4\n l = (32 + 2 * e + 2 * i - h - k) % 7\n m = (a + 11 * h + 2... | [
"0.55422235",
"0.55289507",
"0.5480344",
"0.54557383",
"0.54465735",
"0.5444313",
"0.54097897",
"0.54050547",
"0.535896",
"0.5357941",
"0.5326785",
"0.5312461",
"0.531226",
"0.53034425",
"0.5287844",
"0.52869797",
"0.5276292",
"0.5274059",
"0.52500796",
"0.5249878",
"0.523863... | 0.6912065 | 0 |
gives options of what characteristics of zodiac you would like to see, and displays it, asks for user selection. Selected from array_of methods and the selected method is applied to the zodiac instance. | def zodiac_info(zodiac)
array_of_methods = Zodiac.get_attributes.map{|attribute| attribute.to_s}
puts options1.blue.bold
user_input = gets.strip.to_i
method = array_of_methods[user_input]
if !user_input.between?(1, 7)
puts "\n Please select a valid number:".blue.bold
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_select_7(input, zodiac, array_of_methods)\n puts options2.blue.bold\n user_input = gets.strip.to_i\n method = array_of_methods[user_input]\n if user_input.between?(1, 6)\n apply_method(method, zodiac)\n elsif !user_input.between?(8, 12) \n puts \"\\... | [
"0.70446634",
"0.6322315",
"0.62013507",
"0.60969025",
"0.581111",
"0.5746926",
"0.5745498",
"0.5725249",
"0.5649993",
"0.56426084",
"0.56297237",
"0.5621878",
"0.5591245",
"0.5588795",
"0.5529153",
"0.5507504",
"0.5462576",
"0.54036784",
"0.5403326",
"0.5398434",
"0.5383177"... | 0.70538366 | 0 |
what now gives the "what would you like to do now" menu, gives list of zodiac signs, takes user input and returns what the user requested to see | def what_now(zodiac)
puts menu.blue.bold
user_input = gets.strip
if user_input == "2"
zodiac_info(@zodiac)
elsif user_input == "1"
puts "Which sign would you like to see?".blue.bold
Zodiac.all_names.each_with_index {|name, index| puts "#{index + 1}. #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def menu\n input = nil\n while input != \"exit\"\n puts \"Enter the number of the day you'd like more info on, type list to see the days again or type exit:\"\n input = gets.strip.downcase\n #input can only be from 1-9 because there's only 9 scraper methods currently.\n if input.to_i > 0 ... | [
"0.6473902",
"0.6368265",
"0.62865824",
"0.6277873",
"0.6250453",
"0.62278014",
"0.6218133",
"0.6154248",
"0.6141246",
"0.5987605",
"0.59851235",
"0.59729004",
"0.5965114",
"0.5962895",
"0.5939292",
"0.5924161",
"0.5914272",
"0.5909971",
"0.590805",
"0.589932",
"0.58921367",
... | 0.81883514 | 0 |
Get Stats for API Key | def stats(api_key = nil)
if api_key && (!api_key.is_a? String)
error = InvalidOptions.new(['API key(String)'], ['API key(String)'])
raise error
end
# Disable cache for API key status calls
get_request('/stats/', {:key => api_key}, true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_event_stats ( event_key )\n get_api_resource \"#{@@api_base_url}event/#{event_key}/stats\"\n end",
"def stats\n Client.current.get(\"#{resource_url}/stats\")\n end",
"def stats\n request :get, \"_stats\"\n end",
"def stats\n request :get, \"_stats\"\n end",
"def stats\n ... | [
"0.72303176",
"0.6560693",
"0.64489794",
"0.64489794",
"0.6382123",
"0.6305464",
"0.6267919",
"0.623436",
"0.623436",
"0.62278694",
"0.61584026",
"0.61420125",
"0.61420125",
"0.6095298",
"0.6071633",
"0.60699576",
"0.6017825",
"0.60038584",
"0.6000961",
"0.59681326",
"0.59677... | 0.76713306 | 0 |
"ticket owner" if show_generic? OR support_identity name, with volunteer designation if support response | def byline
return "ticket owner" if self.show_generic?
parens = self.support_response? ? " (volunteer)" : ""
self.support_identity.name + parens
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def byline\n parens = self.support_response? ? \" (volunteer)\" : \"\"\n self.support_identity.name + parens\n end",
"def name_of_person_of_ticket\n self.viewer.name\n \n end",
"def show_generic?\n return true unless self.support_identity_id # guest comment on own ticket\n return ... | [
"0.6984381",
"0.6259364",
"0.61022925",
"0.6102195",
"0.6003713",
"0.58860576",
"0.5867978",
"0.58437383",
"0.5745492",
"0.57075495",
"0.5699975",
"0.5695704",
"0.5671438",
"0.56387097",
"0.56133187",
"0.5587194",
"0.5514647",
"0.55051076",
"0.54998446",
"0.54949844",
"0.5476... | 0.8015623 | 0 |
tries to detect the prompt sends a "\n", waits for a X seconds, and uses the last line as prompt this won't work reliable if the prompt changes during the session | def detect_prompt(seconds: 3)
write_n
process(seconds)
self.default_prompt = read[/\n?^.*\z/]
raise Error::PromptDetection, "couldn't detect a prompt" unless default_prompt.present?
default_prompt
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_prompt\n while !@prompted do\n sleep(0.2)\n end\n end",
"def wait_for_line(prompt = \">> \")\n move_cursor Qt::TextCursor::End\n\n change_cursor { |c|\n c.move_position Qt::TextCursor::End\n c.merge_char_format ANSIToQt::Styles[:clear]\n ANSIToQt.in... | [
"0.6937154",
"0.69335955",
"0.6911136",
"0.6788542",
"0.6598622",
"0.6512135",
"0.6500591",
"0.6442484",
"0.6306797",
"0.62801397",
"0.6235388",
"0.6235388",
"0.6234678",
"0.6233517",
"0.6225389",
"0.62230885",
"0.6221272",
"0.6205207",
"0.6204697",
"0.62016964",
"0.6186609",... | 0.756352 | 0 |
continues to process the ssh connection till stdout matches the given prompt. might raise a timeout error if a soft/hard timeout is given be carefull when using the hard_timeout, this is using the dangerous Timeout.timeout this gets really slow on large outputs, since the prompt will be searched in the whole output. Us... | def read_till(prompt: current_prompt, timeout: read_till_timeout, hard_timeout: read_till_hard_timeout, hard_timeout_factor: read_till_hard_timeout_factor, **_opts)
raise Error::UndefinedMatch, 'no prompt given or default_prompt defined' unless prompt
hard_timeout = (read_till_hard_timeout_factor * time... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_and_watch_prompt(cmd, regex_to_watch)\n run cmd, :pty => true do |ch, stream, data|\n watch_prompt(ch, stream, data, regex_to_watch)\n end\nend",
"def waitfor(options) # :yield: recvdata\n time_out = @options[\"Timeout\"]\n waittime = @options[\"Waittime\"]\n fail_eof = @options[\"Fai... | [
"0.6348343",
"0.62326515",
"0.6219522",
"0.6093374",
"0.6067206",
"0.5937947",
"0.592257",
"0.5884649",
"0.58766603",
"0.567938",
"0.5654632",
"0.56338924",
"0.5544115",
"0.547453",
"0.5464534",
"0.5418788",
"0.54138243",
"0.53790164",
"0.53568083",
"0.5310116",
"0.53055036",... | 0.6469281 | 0 |
removes the prompt from the given output prompt should contain a named match 'prompt' /(?.something.)\z/ for backwards compatibility it also tries to replace the first match of the prompt /(something)\z/ it removes the whole match if no matches are given /something\z/ | def rm_prompt!(output, prompt: current_prompt, **opts)
if rm_prompt?(**opts)
if output[prompt]
case prompt
when String then output[prompt] = ''
when Regexp
if prompt.names.include?("prompt")
output[prompt, "prompt"] = ''
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prompt(file,action,msg)\n if not $config[\"settings\"][\"prompt_prune_duplicates\"]\n print msg\n answer = STDIN.gets.chomp\n if answer =~ /^y$/i\n FileUtils.rm(file,$options) if action == \"delete\"\n end\n elsif $config[\"settings\"][\"auto_prune_duplicates\"]\n @script = File.basename ... | [
"0.6184303",
"0.6144429",
"0.6100525",
"0.53525347",
"0.53042233",
"0.52660286",
"0.5251695",
"0.52231055",
"0.5208874",
"0.51375866",
"0.5137527",
"0.51360846",
"0.51317763",
"0.51215357",
"0.50959253",
"0.50732815",
"0.5056977",
"0.50071394",
"0.5005703",
"0.4988389",
"0.49... | 0.75665003 | 0 |
the same as cmd but it will only run the command if the option run_impact is set to true. this can be used for commands which you might not want to run in development|testing mode but in production cli.impact("reboot") => "skip: reboot" cli.run_impact = true cli.impact("reboot") => "system is going to reboot NOW" | def impact(command, **opts)
run_impact? ? cmd(command, **opts) : "skip: #{command.inspect}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_inline(cmd, redact: nil)\n put_command(cmd, redact: redact)\n\n # `system`, by design (?!), hides stderr when the command fails.\n if ENV[\"PROJECTRB_USE_SYSTEM\"] == \"true\"\n if not system(*cmd)\n exit $?.exitstatus\n end\n else\n pid = spawn(*cmd)\n Process.wait p... | [
"0.57997423",
"0.5782336",
"0.57335275",
"0.57202005",
"0.5650346",
"0.56110156",
"0.5540975",
"0.55314285",
"0.5527315",
"0.5470313",
"0.5454288",
"0.543684",
"0.5423271",
"0.5423271",
"0.5423271",
"0.5423271",
"0.54190296",
"0.5393973",
"0.5385602",
"0.53215814",
"0.5310002... | 0.7492061 | 0 |
same as cmds but for impact instead of cmd | def impacts(*commands, **opts)
commands.flatten.map { |command| [command, impact(command, **opts)] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd; end",
"def commands; end",
"def run_cmd(cmd)\n\tend",
"def subcommands(cmd); end",
"def subcommands(cmd); end",
"def cmd(*args) self.class.cmd(*args) end",
"def camCommand _obj, _args\n \"_obj camCommand _args;\" \n end",
"def exec_commands(cmds)\n exec_tape(cmds)\n exec_ou... | [
"0.65165347",
"0.62815654",
"0.621928",
"0.62057954",
"0.62057954",
"0.62021023",
"0.6140648",
"0.61079097",
"0.61006874",
"0.6098658",
"0.60913604",
"0.60835695",
"0.60835695",
"0.60835695",
"0.60835695",
"0.60835695",
"0.60835695",
"0.5996593",
"0.597487",
"0.596001",
"0.59... | 0.6643866 | 0 |
if sleep_procs are set, they will be called instead of Kernel.sleep great for async .sleep_procs["async"] = proc do |duration| async_reactor.sleep(duration) end cli.sleep(1) | def sleep(duration)
if sleep_procs.any?
sleep_procs.each { |_name, a_proc| instance_exec(duration, &a_proc) }
else
Kernel.sleep(duration)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_sleep; end",
"def sleepy_run; end",
"def sleep _args\n \"sleep _args;\" \n end",
"def sleep\n #sleeps\n puts \"*sleeps*\"\n end",
"def sleep_if_set\n sleep_sec = config[:sleep].to_i\n if sleep_sec > 0\n info(\"Sleep #{config[:sleep]} seconds...\")\n sl... | [
"0.67476964",
"0.6364916",
"0.6361981",
"0.611147",
"0.6072088",
"0.60428846",
"0.6040456",
"0.60190433",
"0.5986239",
"0.5950244",
"0.5813983",
"0.5771954",
"0.57261693",
"0.57235503",
"0.5716282",
"0.56997246",
"0.5685285",
"0.5670589",
"0.56565523",
"0.56565523",
"0.563975... | 0.67547023 | 0 |
when new data is beeing received, likely more data will arrive this improves the performance by a large factor but on a lot of data, this leads to a stack level too deep therefore it is limited to max on_stdout_processing the bigger on_stdout_processing, the closer we get to a stack level too deep | def optimise_stdout_processing
self.process_count += 1
process unless process_count > on_stdout_processing
ensure
self.process_count -= 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_processing(i)\n # pop_op returns a future which is fulfilled with a message from buffer\n # when a message is valuable.\n @buffer.pop_op.then_on(:fast) do |data|\n # then we process the message on :fast pool since this has no blocking\n log DEBUG, \"data-processor #{i} got #{data}\"\n @data_pr... | [
"0.600923",
"0.58822167",
"0.57085586",
"0.5521616",
"0.5476486",
"0.5445889",
"0.5445889",
"0.53955346",
"0.53920174",
"0.53810394",
"0.5350995",
"0.5348786",
"0.5296996",
"0.52739716",
"0.5267878",
"0.52406675",
"0.52325284",
"0.52312255",
"0.52312255",
"0.5220152",
"0.5204... | 0.6954515 | 0 |
Collects the associated samples or child containers into a 2D Array sparse matrix | def container_matrix
cm = Array.new(container_type.y_dimension, Array.new(container_type.x_dimension, nil))
children.each do |c|
cm[c.container_y][c.container_x] = container_x
end
samples.each do |s|
cm[s.container_y][container_x] = s
end
return c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sparse_matrix\n Hash.new do |hash, pairer|\n hash[pairer] = Hash.new { |hash, pairee| hash[pairee] = 0 }\n end\n end",
"def data_matrix_all(coll, data_matrix)\n pas = coll.part_associations\n part_ids = pas.collect(&:part_id)\n das = DataAssociation.where(parent_class: 'Item', pa... | [
"0.585969",
"0.58557796",
"0.58059335",
"0.5677151",
"0.5572702",
"0.5448905",
"0.5366578",
"0.5329966",
"0.5329966",
"0.5311216",
"0.52804834",
"0.52363175",
"0.5184442",
"0.51733845",
"0.51703644",
"0.5141371",
"0.5129726",
"0.5118281",
"0.50990635",
"0.5085892",
"0.5074357... | 0.673954 | 0 |
Returns true if hooks given for class methods of the class +klass+ exist | def is_class_hooked?(klass)
CLASS_METHOD_HOOKS.has_key?(klass) and not CLASS_METHOD_HOOKS[klass].empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def are_instances_hooked?(klass)\n INSTANCE_METHOD_HOOKS.has_key?(klass)\n end",
"def hook_class!(klass, hooked_methods, hooks)\n\n hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol\n\n validate_hooks(hooks) # Validate hooks\n validate_is_class(klass) # Valida... | [
"0.7310219",
"0.6766386",
"0.670261",
"0.66748494",
"0.66624814",
"0.65113264",
"0.6432014",
"0.64221185",
"0.64022857",
"0.63327694",
"0.6293792",
"0.6256441",
"0.625226",
"0.623128",
"0.6209186",
"0.62012374",
"0.6196263",
"0.6193089",
"0.6185792",
"0.6181005",
"0.61724365"... | 0.82099456 | 0 |
Returns a hash containing all hooked methods for class +klass+ as keys, or an empty hash if don't exist | def hooked_class_methods_for(klass)
CLASS_METHOD_HOOKS[klass] || {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hooked_instance_methods_for(klass)\n INSTANCE_METHOD_HOOKS[klass] || {}\n end",
"def get_methods(klasses)\n m = {}\n klasses.each do |klass|\n m[klass.to_s] = klass.methods(false)\n end\n m\n end",
"def emit_classes_dictionary\n methods = emit_methods_arrays\n ... | [
"0.7490754",
"0.66107464",
"0.6567655",
"0.65028787",
"0.6499651",
"0.64365774",
"0.6317256",
"0.63127184",
"0.63127184",
"0.6238336",
"0.6189954",
"0.6187819",
"0.6105555",
"0.6052201",
"0.60224915",
"0.6014861",
"0.5985889",
"0.59695494",
"0.5944092",
"0.5867654",
"0.582649... | 0.81323946 | 0 |
Adds +hooks+ hooks to the given +klass+ class methods +hooked_methods+ This parameter can be either a symbol or an array of symbols. Possible thrown exceptions: NotAClassException:: When the specified parameter +klass+ is not a class UndefinedMethodException:: When one of the symbols in +hooked_methods+ param is effect... | def hook_class!(klass, hooked_methods, hooks)
hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol
validate_hooks(hooks) # Validate hooks
validate_is_class(klass) # Validate class
hooked_methods.each do |hooked_method| # Validate methods defined
validate_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hook_instances!(klass, hooked_methods, hooks)\n hooked_methods = [hooked_methods] if hooked_methods.is_a? Symbol\n\n #=== Validations ===\n validate_hooks(hooks)\n validate_is_class(klass)\n hooked_methods.each { |hooked_method| validate_has_method_defined(klass, hooked_metho... | [
"0.8007669",
"0.7233891",
"0.71619916",
"0.6880774",
"0.6536785",
"0.6399694",
"0.6250899",
"0.61551845",
"0.6019106",
"0.60059637",
"0.5988926",
"0.58145136",
"0.5720778",
"0.56676495",
"0.5655872",
"0.5636116",
"0.56304747",
"0.55945593",
"0.557735",
"0.55268836",
"0.550018... | 0.8553353 | 0 |
Removes hook class methods as well as returns the hooked methods to their original definition | def unhook_class!(klass, methods = :all, hooks = :all)
methods = (methods == :all) ? CLASS_METHOD_HOOKS[klass].keys : (methods.is_a?(Symbol) ? [methods] : methods)
raise ArgumentError("Valid arguments: :before, :after or :all") unless [:before, :after, :all].include?(hooks)
# Validate all metho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unhook_instances!(klass, methods = :all, hooks = :all)\n methods = (methods == :all) ? INSTANCE_METHOD_HOOKS[klass].keys : (methods.is_a?(Symbol) ? [methods] : methods)\n raise ArgumentError(\"Valid arguments: :before, :after or :all\") unless [:before, :after, :all].include?(hooks)\n\n # ... | [
"0.7499635",
"0.74109846",
"0.71193486",
"0.6880894",
"0.6878117",
"0.6875764",
"0.6863165",
"0.6844279",
"0.67862993",
"0.6746658",
"0.668756",
"0.66794676",
"0.6628391",
"0.6606302",
"0.6592446",
"0.6579968",
"0.65181196",
"0.65081495",
"0.64793026",
"0.6470714",
"0.6462220... | 0.79705024 | 0 |
GET /prefs GET /prefs.json | def index
@prefs = Pref.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_prefs(user_id:)\n path = '/users/{userId}/prefs'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n ... | [
"0.7251142",
"0.6761902",
"0.66948515",
"0.6616954",
"0.64420813",
"0.6434389",
"0.63979083",
"0.63979083",
"0.63600385",
"0.6347418",
"0.6346615",
"0.6317264",
"0.62982005",
"0.6275839",
"0.62658846",
"0.6192738",
"0.6157607",
"0.6157607",
"0.6125356",
"0.6078854",
"0.597834... | 0.69928795 | 1 |
Methods Update the reviews average and the reviews count given a new score | def update_reviews_average(score)
self.reviews_average = calculate_reviews_average(score)
self.reviews_count += 1
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_reviews_average(score)\n (self.reviews_average * self.reviews_count + score) / (self.reviews_count + 1)\n end",
"def update_score\n sum = 0.0\n total = 0.0\n ratings.each do |rating|\n vp = User.find(rating.user_id).voting_power \n sum = sum + rating.score * vp\n tot... | [
"0.8080404",
"0.78725606",
"0.76636446",
"0.76574475",
"0.76060873",
"0.75917244",
"0.7576124",
"0.7564977",
"0.7546094",
"0.7535571",
"0.753012",
"0.7488696",
"0.7437442",
"0.7401332",
"0.73624873",
"0.73564315",
"0.7261185",
"0.7253401",
"0.7240178",
"0.72221446",
"0.720850... | 0.89768314 | 0 |
Calculate the new reviews average based on the current average and the new score | def calculate_reviews_average(score)
(self.reviews_average * self.reviews_count + score) / (self.reviews_count + 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recalculate_average()\n\n #find total of all review ratings by iterating through them\n total = 0\n self.reviews.each do |review|\n total = total + review.rating\n end\n\n newAvg = total / self.reviews.size\n\n self.update_attribute(:avg_rating, newAvg)\n ... | [
"0.836803",
"0.82633",
"0.8074812",
"0.80517966",
"0.8017102",
"0.80057484",
"0.79732347",
"0.7941563",
"0.7886829",
"0.78383374",
"0.7792528",
"0.77142584",
"0.7680951",
"0.7650779",
"0.7645334",
"0.76302254",
"0.7591105",
"0.75836635",
"0.75704855",
"0.75548035",
"0.7540675... | 0.84132844 | 0 |
This challenge took me 2 hours. Pseudocode input: an integer output: true or false Steps: 1. Create a variable and set it equal to 0. This will be used to represent the current number in the sequence. 1. Create a loop that cycles through the Fibonacci sequence when the supplied argument is greater than the current numb... | def is_fibonacci?(num)
sequence = [0, 1]
while num > sequence.last
x, y = sequence.pop(2)
sequence.push(x, y, x + y)
end
if num == sequence.last
true
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_fibonacci?(num)\n\tfZero = 0\n\tfOne = 1\n\tfSum = 0\n\twhile fSum <= num\n\t\tfSum = fOne + fZero\n\t\tfZero = fOne\n\t\tfOne = fSum\n\n\t\tif fSum == num\n\t\t\treturn true\n\t\telsif fSum > num\n\t\t\treturn false\n\t\tend\n\tend\n\nend",
"def is_fibonacci?(num)\n fibonacci = [0,1]\n next_num = 0\n ... | [
"0.8761208",
"0.86387265",
"0.8635486",
"0.8610119",
"0.85859984",
"0.8570896",
"0.85536635",
"0.8547745",
"0.84999704",
"0.8483046",
"0.8476261",
"0.8460773",
"0.8422832",
"0.84222174",
"0.8416708",
"0.8416351",
"0.83955884",
"0.8393101",
"0.8391404",
"0.83835125",
"0.836108... | 0.86423767 | 1 |
GET /apply_activities GET /apply_activities.json | def index
@apply_activities = ApplyActivity.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activities\n get_call(\"1/activities.json\")\n end",
"def activities(params = {})\n scope 'default'\n get('activities/', params)\n end",
"def activities(options={})\n response = connection.get do |req|\n req.url \"activities\", options\n end\n return_error_or_body... | [
"0.7623579",
"0.71435964",
"0.71391284",
"0.68960124",
"0.6859198",
"0.6827893",
"0.679709",
"0.67801493",
"0.67765176",
"0.6692471",
"0.6619812",
"0.6616502",
"0.6613421",
"0.6613421",
"0.65980774",
"0.65792245",
"0.65652674",
"0.6493737",
"0.6493263",
"0.6486136",
"0.647295... | 0.7277546 | 1 |
POST /apply_activities POST /apply_activities.json | def create
@apply_activity = ApplyActivity.new(apply_activity_params)
respond_to do |format|
if @apply_activity.save
format.html { redirect_to @apply_activity, notice: 'Apply activity was successfully created.' }
format.json { render :show, status: :created, location: @apply_activity }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_activity_params\n params.require(:apply_activity).permit(:open_id, :activity_id)\n end",
"def create\n data = reload(get_series('activities'), str(Date.strptime(params[:activity].values.join(\"-\"))))\n saved = false\n get_series('activities').each do |s|\n puts \"Updating series=... | [
"0.6652301",
"0.6551743",
"0.64245963",
"0.63597345",
"0.6297626",
"0.62622863",
"0.6258047",
"0.62342465",
"0.61807245",
"0.61654073",
"0.61579144",
"0.61483",
"0.6129478",
"0.61262494",
"0.61139774",
"0.61034274",
"0.61017317",
"0.61000836",
"0.6100039",
"0.6094671",
"0.609... | 0.70064515 | 0 |
PATCH/PUT /apply_activities/1 PATCH/PUT /apply_activities/1.json | def update
respond_to do |format|
if @apply_activity.update(apply_activity_params)
format.html { redirect_to @apply_activity, notice: 'Apply activity was successfully updated.' }
format.json { render :show, status: :ok, location: @apply_activity }
else
format.html { render :edit ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n @activity.status = Activity::SETTED if @activity.setting?\n if @activity.update(activity_params)\n format.html { redirect_to activities_url, notice: 'Activity was successfully updated.' }\n format.json { head :no_content }\n else\n format... | [
"0.6758553",
"0.6723398",
"0.6709441",
"0.66073865",
"0.6598649",
"0.6595237",
"0.65950817",
"0.65923995",
"0.6586487",
"0.65739834",
"0.6572812",
"0.65611845",
"0.6555289",
"0.6555289",
"0.6555289",
"0.6555289",
"0.6555289",
"0.655434",
"0.6547699",
"0.65343827",
"0.6532168"... | 0.742696 | 0 |
DELETE /apply_activities/1 DELETE /apply_activities/1.json | def destroy
@apply_activity.destroy
respond_to do |format|
format.html { redirect_to apply_activities_url, notice: 'Apply activity was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @my_activity = MyActivity.find(params[:id])\n @my_activity.destroy\n\n respond_to do |format|\n format.html { redirect_to my_activities_url }\n format.json { head :no_content }\n end\n end",
"def destroy \n @activity = current_user.user_activities.find(params[:id])\n ... | [
"0.7042031",
"0.70284617",
"0.70284617",
"0.70235425",
"0.70235425",
"0.70235425",
"0.70235425",
"0.70235425",
"0.7011134",
"0.700443",
"0.695807",
"0.69339615",
"0.6912101",
"0.6912101",
"0.675458",
"0.6746851",
"0.673374",
"0.6731689",
"0.6708743",
"0.67060494",
"0.6702397"... | 0.7467354 | 0 |
Configure A Few Parallels Settings | def try_parallels
parallels = Parallels.new(config, settings)
parallels.configure
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_initial_parameters\n p x_range = [-4, 0, 4]\n p y_range = [-4, -2, 0]\n p machines = %w[6 6 7 7 7 6 6 7 7]\n\n sleep_sec = 3\n [x_range, y_range, sleep_sec, machines]\nend",
"def configure_parallels_vm(options)\n check_parallels_is_installed(options)\n if options['vmnet'].to_s.match(/hostonly/)\n ... | [
"0.611005",
"0.607093",
"0.5922022",
"0.57869995",
"0.57623225",
"0.5758209",
"0.57515323",
"0.57503396",
"0.5682845",
"0.5682845",
"0.56137145",
"0.56122005",
"0.55994016",
"0.55922496",
"0.55922496",
"0.55922496",
"0.55922496",
"0.55922496",
"0.5587337",
"0.55778944",
"0.55... | 0.74008757 | 0 |
Configure all of the configured databases | def try_databases
db = Database.new(application_root, config, settings)
db.configure
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure\n configure_databases_yml\n configure_propel_ini\n end",
"def setup!\n ActiveRecord::Base.configurations[configuration_name] = db_config\n ActiveRecord::Base.establish_connection(configuration_name).connection\n self\n end",
"def setup_databases\n postgres_user = app... | [
"0.7232488",
"0.69919014",
"0.678876",
"0.67558074",
"0.6636984",
"0.6589398",
"0.65731543",
"0.63984936",
"0.63840586",
"0.63770354",
"0.6366992",
"0.6291771",
"0.62661064",
"0.6266088",
"0.62646997",
"0.62534314",
"0.6203",
"0.6203",
"0.61420065",
"0.6135387",
"0.6090649",
... | 0.7529875 | 0 |
Go through child entities and spots, deleting the same blueprints if they exist | def ensure_unique_in_chain
self.entity.spots.each { |s| remove_duplicate_blueprint(s) }
self.entity.apply_to_children do |entity|
remove_duplicate_blueprint(entity)
entity.spots.each { |s| remove_duplicate_blueprint(s) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_children()\n # self.children.each do |c|\n # class_const = Service.class_map[c.service_id]\n # raise NoClassError.new(\"Pas de classe rattachée au service=#{c.service_id}\") if class_const.nil?\n # child = class_const[c.id]\n # child.destroy()\n # end\n end",
"def destroy\n... | [
"0.6301589",
"0.6062386",
"0.5990024",
"0.5971461",
"0.591564",
"0.5907713",
"0.5889784",
"0.58711445",
"0.58597344",
"0.58585227",
"0.578757",
"0.5728686",
"0.5693474",
"0.5650827",
"0.5627955",
"0.56237704",
"0.5621806",
"0.56187683",
"0.5611437",
"0.5587804",
"0.55795264",... | 0.708383 | 0 |
test_ro Test the 'disabled' flag | def test_disabled
base = RoBaseIf.new( 'lab1', '' )
assert_equal false, base.disabled
base.disabled = true
assert_equal true, base.disabled
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disabled?; end",
"def disabled?; end",
"def disabled?\n false\n end",
"def error_on_disabled?\n false\n end",
"def disabled; end",
"def test_disabled?\n ENV['NO_TEST'] == '1'\nend",
"def test_disabled?\n ENV['NO_TEST'] == '1'\nend",
"def disabled?\n !enabled?\n end",
"def ... | [
"0.7445075",
"0.7445075",
"0.739893",
"0.73192656",
"0.72880954",
"0.7190743",
"0.7190743",
"0.69780815",
"0.69612837",
"0.6959625",
"0.6959059",
"0.69134533",
"0.69013625",
"0.68979985",
"0.68934953",
"0.6887908",
"0.68865454",
"0.6874429",
"0.6843469",
"0.68206584",
"0.6806... | 0.8295871 | 0 |
GET /patrimonios/1 GET /patrimonios/1.xml | def show
@patrimonio = Patrimonio.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @patrimonio }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @patrimonio = Patrimonio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patrimonio }\n end\n end",
"def api_xml(path,method=:get,options={})\n xml_message(amee,\"/data\"+path,method,options)\n end",
"def xml(id)\n http.get(\"... | [
"0.61679983",
"0.6130975",
"0.60858256",
"0.6076567",
"0.60178024",
"0.5982235",
"0.5966017",
"0.5943246",
"0.5933648",
"0.58350027",
"0.5830929",
"0.5817254",
"0.5817131",
"0.57999825",
"0.57711923",
"0.5760946",
"0.575977",
"0.57565844",
"0.575618",
"0.57509965",
"0.5748988... | 0.687344 | 0 |
GET /patrimonios/new GET /patrimonios/new.xml | def new
@patrimonio = Patrimonio.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @patrimonio }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @patron = Patron.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @patron }\n end\n end",
"def new\n @precio = Precio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @precio }\n e... | [
"0.719956",
"0.6919194",
"0.68861026",
"0.6868864",
"0.682951",
"0.6798009",
"0.67816186",
"0.67125344",
"0.6708941",
"0.6708081",
"0.6708081",
"0.66984516",
"0.66859096",
"0.6676304",
"0.66678464",
"0.66638845",
"0.6653871",
"0.6650784",
"0.66504085",
"0.6644368",
"0.6640242... | 0.75492597 | 0 |
POST /patrimonios POST /patrimonios.xml | def create
@patrimonio = Patrimonio.new(params[:patrimonio])
respond_to do |format|
if @patrimonio.save
flash[:notice] = 'Patrimonio criado com sucesso.'
format.html { redirect_to(@patrimonio) }
format.xml { render :xml => @patrimonio, :status => :created, :location => @patrimoni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post(method, params = {})\n url = make_url method, params\n query = url.query\n url.query = nil\n\n req = Net::HTTP::Post.new url.path\n req.body = query\n ... | [
"0.6040027",
"0.5696885",
"0.5691127",
"0.56835115",
"0.5658179",
"0.5553776",
"0.5543783",
"0.5529424",
"0.55279475",
"0.5518438",
"0.54892373",
"0.5437468",
"0.5433367",
"0.54155135",
"0.53999364",
"0.5384351",
"0.53770024",
"0.5372938",
"0.5371675",
"0.5338473",
"0.5337057... | 0.6376043 | 0 |
PUT /patrimonios/1 PUT /patrimonios/1.xml | def update
@patrimonio = Patrimonio.find(params[:id])
respond_to do |format|
if @patrimonio.update_attributes(params[:patrimonio])
flash[:notice] = 'Patrimonio salvo com sucesso.'
format.html { redirect_to(@patrimonio) }
format.xml { head :ok }
else
format.html { re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start... | [
"0.64397186",
"0.6141356",
"0.60038555",
"0.5865258",
"0.5773722",
"0.5761053",
"0.57281476",
"0.5719075",
"0.5711562",
"0.57087135",
"0.5681896",
"0.5669889",
"0.5664304",
"0.5648227",
"0.5596489",
"0.55868787",
"0.5561905",
"0.5541459",
"0.55391675",
"0.5536457",
"0.5532692... | 0.6336989 | 1 |
DELETE /patrimonios/1 DELETE /patrimonios/1.xml | def destroy
@patrimonio = Patrimonio.find(params[:id])
@patrimonio.destroy
respond_to do |format|
format.html { redirect_to(patrimonios_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete()\n response = send_post_request(@xml_api_del... | [
"0.68901026",
"0.6760502",
"0.6615776",
"0.65528667",
"0.6527533",
"0.65016496",
"0.6455595",
"0.6440513",
"0.6426724",
"0.64062226",
"0.63617533",
"0.63516384",
"0.63456017",
"0.63258624",
"0.6324476",
"0.63190466",
"0.63190466",
"0.6317349",
"0.63100743",
"0.6298882",
"0.62... | 0.67861617 | 1 |
PARAMETERS: JSON object from STDIN with the following fields: target: a required string parameter. noop: an optional boolean metaparameter, will set params['_noop']. Read parameters, set defaults, and validate values. | def read_parameters
params = read_stdin
return_error("Parameter 'target' contains illegal characters") unless safe_string?(params['target'])
params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(target, starting_parameters = nil)\n @target = target\n @parameters = starting_parameters || {}\n end",
"def parse_input(params, resource); end",
"def parse_parameters; end",
"def target_params\n params.fetch(:target, {}).permit(:radius, :title, :latitude, :longitude, :topic_id)\n e... | [
"0.6515819",
"0.6001433",
"0.5732027",
"0.5716715",
"0.5668867",
"0.56391525",
"0.55718523",
"0.55372065",
"0.55236083",
"0.5514184",
"0.5507976",
"0.5477726",
"0.54387724",
"0.54286057",
"0.5418427",
"0.54073876",
"0.539102",
"0.53696674",
"0.5363767",
"0.535197",
"0.5336894... | 0.6815387 | 0 |
Read parameters as JSON from STDIN. | def read_stdin
params = {}
begin
Timeout.timeout(3) do
params = JSON.parse(STDIN.read)
end
rescue Timeout::Error
return_error('Cannot read parameters as JSON from STDIN')
end
params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input \n @input ||= JSON.parse(File.read(ARGV[0]));\nend",
"def input_as_json\n return @json_input if @json_input\n require 'json'\n raw = @env['rack.input'].read if @env['rack.input']\n begin\n return @json_input = JSON.parse(raw)\n rescue JSON::ParserError\n end if raw... | [
"0.7220243",
"0.6828171",
"0.67843854",
"0.6737622",
"0.6243689",
"0.60870147",
"0.5995166",
"0.59016126",
"0.5852161",
"0.584042",
"0.57797694",
"0.5772471",
"0.57476646",
"0.57369345",
"0.57349086",
"0.56939733",
"0.5688928",
"0.5582566",
"0.54372364",
"0.5386467",
"0.53706... | 0.7975332 | 0 |
Returns the hotkey (i.e. shortcut key) associated to the shortcut, in the form of a 2byte number of which the first byte identifies the modifiers (Ctrl, Alt, Shift) and the second is the ASCII code of the character key. | def hotkey
@link.HotKey
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key ch\n ch.getbyte(0)\n end",
"def get_char\n c = @window.getchar\n case c\n when 13,10\n return \"ENTER\"\n when 32\n return \"SPACE\"\n when 127\n return \"BACKSPACE\"\n when 27\n return \"ESCAPE\"\n end\n keycode_tos c\n# if c > 32 && c < 127\n #return c.chr\n #end\n ... | [
"0.6206607",
"0.6085046",
"0.60055214",
"0.59673446",
"0.58247715",
"0.5747055",
"0.569865",
"0.5697806",
"0.5695054",
"0.5664587",
"0.5650183",
"0.5606303",
"0.54731965",
"0.5469083",
"0.54470944",
"0.5430459",
"0.5409042",
"0.5404641",
"0.53982955",
"0.5397447",
"0.5369536"... | 0.6530931 | 0 |
Sets the hotkey for the shortcut. | def hotkey=(key)
@link.HotKey = key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_hot_key\n @hot_key = HotKey.find(params[:id])\n end",
"def keyboard_block_shortcuts=(value)\n @keyboard_block_shortcuts = value\n end",
"def addHotkey(key, modifiers, &block)\n Env.addHotkey key, modifiers, Env::RHotkeyListener.new(block)\n end",
"def addHotkey(k... | [
"0.68683696",
"0.6457046",
"0.6402735",
"0.6402735",
"0.6367657",
"0.62866354",
"0.5972243",
"0.5931904",
"0.5844145",
"0.5717958",
"0.570596",
"0.5570506",
"0.5570142",
"0.55101395",
"0.5498032",
"0.53873223",
"0.53817916",
"0.5361607",
"0.53386676",
"0.5334646",
"0.53043234... | 0.82111794 | 0 |
Returns the type of window style used by a shortcut. The possible return values are 'normal', 'maximized', or 'minimized'. | def window_style
case @link.WindowStyle
when SHOWNORMAL
'normal'
when SHOWMAXIMIZED
'maximized'
when SHOWMINNOACTIVE
'minimized'
else
'unknown' # Should never reach here
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def window_style=(style)\n valid = [SHOWNORMAL, SHOWMAXIMIZED, SHOWMINNOACTIVE]\n valid.concat(['normal', 'maximized', 'minimized'])\n\n unless valid.include?(style)\n raise ArgumentError, 'invalid style'\n end\n\n if style.is_a?(String)\n case style.downcase\n when ... | [
"0.6836268",
"0.5861454",
"0.58607477",
"0.57881606",
"0.5483765",
"0.5389272",
"0.53725743",
"0.53240347",
"0.5250995",
"0.52179015",
"0.5199417",
"0.5186616",
"0.5186616",
"0.51794076",
"0.51068294",
"0.5105344",
"0.5075509",
"0.50635815",
"0.5029475",
"0.501661",
"0.497903... | 0.7848982 | 0 |
Sets the window style to a shortcut. The +style+ can be one of the following three constants or equivalent string values: SHOWNORMAL or 'normal' SHOWMAXIMIZED or 'maximized' SHOWMINNOACTIVE or 'minimized' Please see the documentation for those constants for further details. | def window_style=(style)
valid = [SHOWNORMAL, SHOWMAXIMIZED, SHOWMINNOACTIVE]
valid.concat(['normal', 'maximized', 'minimized'])
unless valid.include?(style)
raise ArgumentError, 'invalid style'
end
if style.is_a?(String)
case style.downcase
when 'normal'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Button_SetStyle(hwndCtl, style,fRedraw)\n SendMessage(hwndCtl, BM_SETSTYLE, style, MAKELPARAM(fRedraw ? true : false), 0)\n end",
"def window_style\n case @link.WindowStyle\n when SHOWNORMAL\n 'normal'\n when SHOWMAXIMIZED\n 'maximized'\n when SHOWMINNO... | [
"0.6544995",
"0.645348",
"0.6320167",
"0.5691432",
"0.55500525",
"0.5432534",
"0.5404338",
"0.5392901",
"0.5179251",
"0.51585126",
"0.51313406",
"0.5079207",
"0.5076832",
"0.5061102",
"0.5020049",
"0.5016483",
"0.50126797",
"0.49763054",
"0.4959005",
"0.4865714",
"0.4865119",... | 0.8232504 | 0 |
Saves (creates) the link object in the current directory. | def save
@link.Save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n CONNECTION.execute(\"UPDATE links SET link = '#{self.link}', relative_assignment = '#{self.relative_assignment}' WHERE id = #{self.id};\")\n end",
"def save_to(path); end",
"def save_posted_link( )\n\t\n\tdata_file = \"posted_link.dat\"\n\tfp = File.open(data_file,\"a\")\n\t$link_posted.keys.eac... | [
"0.66439503",
"0.646054",
"0.6373026",
"0.6313694",
"0.6222929",
"0.6077122",
"0.60623544",
"0.6050221",
"0.60325223",
"0.60275304",
"0.60275304",
"0.60104513",
"0.6002287",
"0.5969502",
"0.5954671",
"0.59256285",
"0.5903352",
"0.5903311",
"0.5869719",
"0.5866856",
"0.5855324... | 0.78685623 | 0 |
lectures that do not belong to courses the tag is associated to but are associated to the given tag | def extra_lectures
Lecture.where.not(course: courses).select { |l| in?(l.tags) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def missing_lectures\n Lecture.where(course: courses).reject { |l| in?(l.tags) }\n end",
"def _tagging\n t_tagging[:tag_id].in(self.tags) unless self.tags.length == 0\n end",
"def tags\n @tags ||= tag_class.in_challenge(collection).group(:id)\n end",
"def related_tag_categories\n @related_tag_... | [
"0.74250275",
"0.5731028",
"0.55907583",
"0.5558424",
"0.5476277",
"0.5435328",
"0.5390963",
"0.5354954",
"0.5278159",
"0.5253585",
"0.5211509",
"0.51780736",
"0.51477075",
"0.5054706",
"0.5029915",
"0.5020445",
"0.4988788",
"0.4988788",
"0.49858418",
"0.49824753",
"0.4968426... | 0.757229 | 0 |
lectures that belong to courses the tag is associated to but are not associated to the given tag | def missing_lectures
Lecture.where(course: courses).reject { |l| in?(l.tags) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extra_lectures\n Lecture.where.not(course: courses).select { |l| in?(l.tags) }\n end",
"def lectures\n Lecture.where(id: Lecture.all.select { |l| in_lecture?(l) }.map(&:id))\n end",
"def section_courses\n all_sections = sections.to_a.concat(sections_as_student).uniq\n\n # In the future we may... | [
"0.7941053",
"0.5695997",
"0.567604",
"0.5660183",
"0.54580337",
"0.5433149",
"0.53762007",
"0.5367397",
"0.53604794",
"0.53427213",
"0.53374904",
"0.53228486",
"0.52977777",
"0.52931577",
"0.52662814",
"0.51565164",
"0.51537377",
"0.5151254",
"0.5132106",
"0.5100165",
"0.508... | 0.79823446 | 0 |
returns the vertex title color of the tag in the neighbourhood graph of the given marked tag | def color(marked_tag, highlight_related_tags: true)
return '#f00' if self == marked_tag
return '#ff8c00' if highlight_related_tags && in?(marked_tag.related_tags)
'#000'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cytoscape_vertex(marked_tag, highlight_related_tags: true)\n { id: id.to_s,\n label: title,\n color: color(marked_tag,\n highlight_related_tags: highlight_related_tags),\n background: background(marked_tag,\n highlight_related_tags: highlight_rela... | [
"0.6700625",
"0.6159392",
"0.57467216",
"0.55165124",
"0.54445755",
"0.54418516",
"0.54367113",
"0.53907275",
"0.53706807",
"0.53599674",
"0.5290897",
"0.5288064",
"0.524879",
"0.5235292",
"0.5230079",
"0.52218497",
"0.52102023",
"0.51943994",
"0.5164834",
"0.5162659",
"0.516... | 0.6314463 | 1 |
returns the cytoscape hash describing the tag's vertex in the neighbourhood graph of the marked tag | def cytoscape_vertex(marked_tag, highlight_related_tags: true)
{ id: id.to_s,
label: title,
color: color(marked_tag,
highlight_related_tags: highlight_related_tags),
background: background(marked_tag,
highlight_related_tags: highlight_related_tags) }... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n @node.sort.push(@edge).hash\n end",
"def hash\n node_id.hash\n end",
"def hash # Hack for Ruby 1.8.6\n @node.id.hash ^ self.class.hash\n end",
"def node_hash(node_id)\n \n end",
"def cytoscape_edge(related_tag)\n { id: \"#{id}-#{related_tag.id}\",\n source... | [
"0.68881595",
"0.684809",
"0.6666004",
"0.6622215",
"0.6546963",
"0.6173934",
"0.6111437",
"0.6034532",
"0.6026594",
"0.5987839",
"0.59796715",
"0.59264547",
"0.5909009",
"0.5864447",
"0.58586997",
"0.5840533",
"0.58227235",
"0.58204365",
"0.5815073",
"0.5812405",
"0.5793465"... | 0.71082187 | 0 |
returns the cytoscape hash describing the edge between the tag and the related tag | def cytoscape_edge(related_tag)
{ id: "#{id}-#{related_tag.id}",
source: id,
target: related_tag.id }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n @node.sort.push(@edge).hash\n end",
"def edge_key(edge)\n edge.key.to_s\n end",
"def cytoscape_vertex(marked_tag, highlight_related_tags: true)\n { id: id.to_s,\n label: title,\n color: color(marked_tag,\n highlight_related_tags: highlight_related_tags)... | [
"0.6894628",
"0.6539697",
"0.63683414",
"0.61620283",
"0.6158486",
"0.61534643",
"0.6120209",
"0.6120209",
"0.6029144",
"0.6020845",
"0.60055536",
"0.5937331",
"0.5889614",
"0.5829168",
"0.5775773",
"0.5678599",
"0.56696695",
"0.5597362",
"0.5577416",
"0.55538476",
"0.5543253... | 0.8034387 | 0 |
GET /travel_destinations GET /travel_destinations.json | def index
@travel_destinations = TravelDestination.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_destinations(opts = {})\n data, _status_code, _headers = get_destinations_with_http_info(opts)\n data\n end",
"def index\n @destinations = current_user.destinations\n end",
"def get_flight_destinations\n @flights = Flight.all.map(&:destination)\n end",
"def get_destinations_with_... | [
"0.6998979",
"0.6987532",
"0.69231254",
"0.6798966",
"0.6780669",
"0.6736186",
"0.67296225",
"0.6698047",
"0.66024",
"0.64577705",
"0.6336516",
"0.6262463",
"0.6194923",
"0.61677325",
"0.61645454",
"0.6054115",
"0.60448444",
"0.60320103",
"0.602223",
"0.6019681",
"0.6003904",... | 0.7561514 | 0 |
DELETE /travel_destinations/1 DELETE /travel_destinations/1.json | def destroy
@travel_destination.destroy
respond_to do |format|
format.html { redirect_to travel_destinations_url, notice: 'Travel destination was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @travel.destroy\n respond_to do |format|\n format.html { redirect_to travels_url, notice: 'Travel was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @travel.destroy\n respond_to do |format|\n format.html { redirect_to travel... | [
"0.6945485",
"0.6943871",
"0.68896717",
"0.68896717",
"0.68896717",
"0.6857132",
"0.68315566",
"0.6801644",
"0.68014747",
"0.6781782",
"0.6781782",
"0.6779274",
"0.6741531",
"0.6741531",
"0.6741531",
"0.67177975",
"0.66940784",
"0.6691178",
"0.6691178",
"0.6688248",
"0.668824... | 0.7305253 | 0 |
3 different coordinate systems for lookups | def coordinate_systems
[:row_col, :col_row, :box]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_by_coords(x, y)\n diameter = Cfg.galaxy_zone_diameter\n lookup(\n (x.to_f / diameter).floor,\n (y.to_f / diameter).floor\n )\n end",
"def meshcode2_coordinate(gps_info)\n grid_square_code = gps_info.to_s\n \n # calc from 1st grid square code\n lat = grid_square_code... | [
"0.6748104",
"0.6361164",
"0.6330459",
"0.6115558",
"0.60482275",
"0.6029212",
"0.59481555",
"0.59242755",
"0.5896718",
"0.58744013",
"0.56835973",
"0.56560355",
"0.56256205",
"0.56162846",
"0.55879575",
"0.55703455",
"0.5568753",
"0.5561615",
"0.5547192",
"0.55437475",
"0.55... | 0.6614686 | 1 |
Calculate the index at (x,y) in the relevant coordinate_system 0: (row, column) 1: (column, row) 2: (box number, element number. left>right, top>down) | def index_for(x, y, coordinate_system=:row_col)
case coordinate_system
when :row_col
x * 9 + y
when :col_row
y * 9 + x
when :box
[0,3,6,27,30,33,54,57,60][x] + [0,1,2,9,10,11,18,19,20][y]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def idx(x, y)\n tx = x % @width\n ty = y % @height\n idx = tx + ty * @width\n end",
"def index_of x, y\n\t\tindex = (y* @width) + x\n\t\treturn index\n\tend",
"def point_to_index(x,y)\n return (x*(bpp >> 3))+(y*((bpp >> 3)*(width)))\n end",
"def axis_index(index, coordinate_system)\n cas... | [
"0.76329213",
"0.7245963",
"0.72131217",
"0.7179345",
"0.7142602",
"0.7097473",
"0.7043124",
"0.6986117",
"0.6935946",
"0.69311833",
"0.69311833",
"0.6914777",
"0.68623555",
"0.6789896",
"0.6765102",
"0.6725684",
"0.670736",
"0.6671636",
"0.6493925",
"0.64916337",
"0.64796495... | 0.8306979 | 0 |
All allowed numbers for that position given the other numbers along it's axes. Returned as a bitmask (number) eg 214 | def allowed(index)
bits = 511
coordinate_systems.each do |c|
axis_index = first_axis_index(index)
bits &= axis_missing(axis_index, c)
end
bits
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_numbers\n allowed = @board.map { |n| n.nil? ? 511 : 0 }\n coordinate_systems.each do |c|\n (0..8).each do |x|\n bits = axis_missing(x, c)\n (0..8).each { |y| allowed[index_for(x, y, c)] &= bits }\n end\n end\n allowed\n end",
"def to_i\n bitmask\n end",
... | [
"0.8198245",
"0.6387139",
"0.6286462",
"0.6276572",
"0.6068154",
"0.59959465",
"0.5924163",
"0.59200716",
"0.5869281",
"0.5860783",
"0.58427554",
"0.5842105",
"0.5805906",
"0.57742846",
"0.5756669",
"0.5755815",
"0.57323915",
"0.5729575",
"0.57121104",
"0.56609505",
"0.559647... | 0.7289039 | 1 |
Takes a board and returns in bitmask format: allowed: A list of all directly allowed numbers for each position eg [123, 231, 231 ...] 81 of them in linear order. | def allowed_numbers
allowed = @board.map { |n| n.nil? ? 511 : 0 }
coordinate_systems.each do |c|
(0..8).each do |x|
bits = axis_missing(x, c)
(0..8).each { |y| allowed[index_for(x, y, c)] &= bits }
end
end
allowed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def bit_board(color)\n @board.map { |row|\n row.map { |cell| ROAD[color].include?(cell.last) ? 1 : 0 }\n }\n end",
"def allowed_moves(from_cell, chessboard)\n map_chess_move_array(from_cell, allowed_cells(from_cell,... | [
"0.64420503",
"0.64173424",
"0.63034344",
"0.6103172",
"0.60082316",
"0.583086",
"0.5749764",
"0.5726503",
"0.56823975",
"0.5634278",
"0.559613",
"0.559457",
"0.5565813",
"0.5531373",
"0.5530637",
"0.55115354",
"0.54936343",
"0.54936343",
"0.54745525",
"0.5469444",
"0.5467644... | 0.77479553 | 0 |
what is first coordinate of position in this axis | def first_axis_index(index, coordinate_system=:row_col)
case coordinate_system
when :row_col
(index / 9)
when :col_row
index % 9
when :box
(index / 27) * 3 + (index / 3) % 3
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x\n @point[0]\n end",
"def x\n position.x if position\n end",
"def x\n position.x if position\n end",
"def x\n @position.x\n end",
"def min_x\n @pos.x\n end",
"def x_offset; end",
"def coord(axis_)\n ainfo_ = @structure.axis(axis_)\n ain... | [
"0.69691247",
"0.68517864",
"0.68517864",
"0.6839735",
"0.6685985",
"0.6577273",
"0.65761954",
"0.6535521",
"0.6524613",
"0.6504888",
"0.6494624",
"0.643005",
"0.6411759",
"0.64075446",
"0.6363134",
"0.6349611",
"0.6349611",
"0.63473356",
"0.62924415",
"0.6261241",
"0.6254015... | 0.6912746 | 1 |
lookup an axis based on it's 09 index and coordinate system. | def axis_index(index, coordinate_system)
case coordinate_system
when :row_col
index
when :col_row
9 + index
when :box
18 + index
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_axis_index(index, coordinate_system=:row_col)\n case coordinate_system\n when :row_col\n (index / 9)\n when :col_row\n index % 9\n when :box\n (index / 27) * 3 + (index / 3) % 3\n end\n end",
"def axis(axis_)\n case axis_\n when ::Integer\n @indexes[axis_... | [
"0.65393114",
"0.62480056",
"0.5916999",
"0.585222",
"0.5729227",
"0.56434435",
"0.5544455",
"0.55375427",
"0.54612803",
"0.53110427",
"0.5270095",
"0.5246193",
"0.52433544",
"0.52061063",
"0.51710176",
"0.5162305",
"0.51472306",
"0.5052501",
"0.5039097",
"0.5025738",
"0.4995... | 0.70901006 | 0 |
Return the list of numbers that a bitmask represents eg bits_to_numbers(511) > [0, 1, ... 8] | def bits_to_numbers(bits)
(0..8).select { |n| (bits & (1 << n)) != 0 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitmask(int)\n return int.to_s(2).reverse.split('')\n end",
"def to_i\n bitmask\n end",
"def to_i\n bitmask\n end",
"def number_to_set_bit_positions_array(number)\n assert_non_negative(number)\n array = []\n position = 0\n while number > 0\n array << positio... | [
"0.72207516",
"0.6757856",
"0.66567385",
"0.65442234",
"0.6321977",
"0.6275532",
"0.62221396",
"0.62138224",
"0.62138224",
"0.6204103",
"0.6188916",
"0.6188916",
"0.6188916",
"0.6188916",
"0.6188916",
"0.618546",
"0.61775863",
"0.61247975",
"0.6119135",
"0.61090577",
"0.60789... | 0.7576217 | 0 |
takes a stack of tuples [(guesses, guesses_index, board)] returns [stack, solution] Uses DFS keeps appending guesses to the stack. If there are If we have gone through all guesses, ignore this board state Otherwise put the next guess on the stack Otherwise, try the current guess, deduce it (return if won), and append e... | def solve_next
while stack.length > 0
guesses, guesses_index, board = stack.pop
# skip if all possible guesses at this level are done
next if guesses_index >= guesses.size
stack << [guesses, guesses_index + 1, board]
board = board.duplicate
guess = guesses[guesses_index]
bo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_guess(partially_solved_board)\n return nil if partially_solved_board == nil\n\n until solved?(partially_solved_board)\n partially_solved_board.each_with_index do |row, row_idx|\n row.each_with_index do |square, col_idx|\n if square.is_a?(Array)\n square = solve_suite(row, square, ro... | [
"0.66609436",
"0.6138048",
"0.6133926",
"0.6076103",
"0.59931016",
"0.58564955",
"0.5851412",
"0.57578063",
"0.57563424",
"0.56887573",
"0.5649418",
"0.5605335",
"0.55762",
"0.55684805",
"0.55537325",
"0.5545839",
"0.5532785",
"0.5490438",
"0.54767007",
"0.5453743",
"0.543967... | 0.79778975 | 0 |
Returns the difficulty rating of a puzzle or 1 if it is not valid. Takes an option 'board' parameter which is the puzzle's solution. If you pass in a solution, it checks that our solver gives that solution. It also makes sure that there are no alternative solutions by solving from the remaining state. | def check_puzzle(puzzle, board=Nil)
solver = PuzzleSolver.new(puzzle)
answer = solver.solve
stack = solver.stack
if answer.nil?
return -1
end
if !board.nil? && !board_matches(board, answer)
return -1
end
difficulty = stack.length
state, second = PuzzleSolver.new(board, s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve(board)\n position = board.first_empty_position\n return board unless position\n board.options(position).each do |option|\n solution = solve(Board.new(\n board.digits[0...position] + option + board.digits[position + 1..-1]\n ))\n return solution if solution\n end\n nil\nend",
"def sco... | [
"0.62393725",
"0.5892497",
"0.5831322",
"0.5831322",
"0.5751628",
"0.5608168",
"0.56042075",
"0.55831677",
"0.55492944",
"0.55079067",
"0.55047566",
"0.54949397",
"0.547414",
"0.53949285",
"0.5384676",
"0.53768754",
"0.5374985",
"0.5353545",
"0.528325",
"0.52598715",
"0.52524... | 0.7057254 | 0 |
Tests equivalence of 2 boards. | def board_matches(b1, b2)
b1.board == b2.board
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_board(board1, board2)\n b1 = board1.grids.flatten\n b2 = board2.grids.flatten\n b1.each_with_index do |grid1, i|\n return false unless compare_grid(b1[i], b2[i])\n end\n return true\n end",
"def isSameBoardState(b)\n ret = true\n if @myPlaced[Controller::Player::WHITE] != b... | [
"0.751151",
"0.705034",
"0.65127814",
"0.65088445",
"0.6508265",
"0.65011454",
"0.6432559",
"0.64280874",
"0.63365865",
"0.6327004",
"0.62946486",
"0.6291534",
"0.6288776",
"0.62712514",
"0.6268631",
"0.6258236",
"0.619973",
"0.6188045",
"0.61769164",
"0.61750144",
"0.6158047... | 0.79263324 | 0 |
GET /recommends/new GET /recommends/new.json | def new
@recommend = Recommend.new
respond_to do |format|
format.html
format.json { render json: @recommend }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @recommendation = Recommendation.new\n @rr = RecommendationRequest.find(params[:request])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recommendation }\n end\n end",
"def new\n @collection = current_user.collections.find(params[:collect... | [
"0.72288465",
"0.7178074",
"0.7162343",
"0.70580214",
"0.67819023",
"0.6752147",
"0.6752147",
"0.6752147",
"0.6654328",
"0.6654328",
"0.6643846",
"0.6643678",
"0.65939736",
"0.6557213",
"0.6537322",
"0.64817065",
"0.6475126",
"0.6475126",
"0.6475126",
"0.6475126",
"0.6475126"... | 0.73276 | 0 |
Net_payments method combines the two hashes returned from you_owe and you_are_owed to determine the net amount owed/you owe for each user returns a hash of user: amount where amount is the net between any amount you owe or are owed to a user | def net_payments(current_user_id)
payments = {"you_are_owed" => {}, "you_owe" => {}}
# {"Matt"=>15.0, "Sam"=>10.0, "Drew"=>10.0, "Tristan"=>22.22} you_are_owed
# {"Matt"=>11.11, "Kyle"=>25.22, "Dega"=>30.22, "Drew"=>30.22} you_owe
you_owe_hash = you_owe(current_user_id)
you_are_owed_hash = you_are_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def you_are_owed(current_user_id)\n\n you_are_owed_list = {}\n\n bills = Bill.joins(:bill_splits).joins(:bill_author).where('author_id = ?', current_user_id).where('recipient_paid = false').where('paid = false').includes(:bill_recipients)\n bills.uniq.each do |bill|\n bill.bill_splits.each do |split|... | [
"0.6122293",
"0.6098528",
"0.60367364",
"0.595311",
"0.59407336",
"0.5939967",
"0.58202773",
"0.57085145",
"0.5623687",
"0.55967647",
"0.55547124",
"0.5510094",
"0.5464091",
"0.5431486",
"0.54189974",
"0.53521425",
"0.5350606",
"0.5313558",
"0.53124243",
"0.5306378",
"0.53038... | 0.8280896 | 0 |
You_owe method creates a hash of user: amount where user are all of the users that the current_user owes by total bill amount | def you_owe(current_user_id)
you_owe_list = {}
billsplits = Billsplit.joins(:bill).includes(:bill_author).where('recipient_id = ?', current_user_id).where('recipient_paid = false').where('paid = false')
billsplits.each do |bill|
if you_owe_list.has_key? bill.bill_author.username
temp_amount ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def you_are_owed(current_user_id)\n\n you_are_owed_list = {}\n\n bills = Bill.joins(:bill_splits).joins(:bill_author).where('author_id = ?', current_user_id).where('recipient_paid = false').where('paid = false').includes(:bill_recipients)\n bills.uniq.each do |bill|\n bill.bill_splits.each do |split|... | [
"0.7801793",
"0.7194259",
"0.71429604",
"0.62640923",
"0.61592513",
"0.614256",
"0.6138234",
"0.6110369",
"0.60087657",
"0.59414715",
"0.5824088",
"0.5796594",
"0.57565343",
"0.57528925",
"0.57371557",
"0.5732662",
"0.5727519",
"0.57181215",
"0.5715774",
"0.5694797",
"0.56618... | 0.79057044 | 0 |
You_are_owed method creates a hash of user: amount where user are all of the users that owes the current_user by total bill amount | def you_are_owed(current_user_id)
you_are_owed_list = {}
bills = Bill.joins(:bill_splits).joins(:bill_author).where('author_id = ?', current_user_id).where('recipient_paid = false').where('paid = false').includes(:bill_recipients)
bills.uniq.each do |bill|
bill.bill_splits.each do |split|
us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def you_owe(current_user_id)\n\n you_owe_list = {}\n billsplits = Billsplit.joins(:bill).includes(:bill_author).where('recipient_id = ?', current_user_id).where('recipient_paid = false').where('paid = false')\n\n billsplits.each do |bill|\n if you_owe_list.has_key? bill.bill_author.username\n ... | [
"0.7772489",
"0.73372257",
"0.6771234",
"0.6172366",
"0.6147367",
"0.6082846",
"0.6045769",
"0.60340446",
"0.5735372",
"0.5719394",
"0.5666735",
"0.56626457",
"0.5656839",
"0.55504096",
"0.5480814",
"0.54708946",
"0.5462598",
"0.5462066",
"0.54516745",
"0.54422385",
"0.540432... | 0.8131363 | 0 |
Settle_up method finds all billsplits between settle_from user and settle_to user then the method creates a 2D array where the inner arrays have length 3 inner array indices correspond to the following: 0: billsplit_id OR "new" which corresponds to an overpayment 1: recipient_paid 2: amount (will be 0 if paid is true) ... | def settle_up(settle_from, settle_to, amount)
# You are looking for all of the billsplits where the recipient id is payer (settle_from) because those are the ones you want to now fulfill
billsplits = Billsplit.joins(:bill).where('author_id = ?', settle_to).where('recipient_id = ?', settle_from).where('recipien... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_paid_splits(array)\n # [[5, true, 0], [8, true, 0], [\"new\", false, 27.78]] =>\n # [[5, true, 0]] => [ [5, true, 0], []]\n # [[5, true, 0], [8, true, 0]]\n # [[5, true, 0], [8, true, 0], [8, true, 0], [\"new\", false, 27.78]]\n # [[\"new\", false, 27.78]] => [ [], [\"new\", false, 27.78]]... | [
"0.54562885",
"0.53862923",
"0.5260035",
"0.5165662",
"0.5018942",
"0.49864957",
"0.4933092",
"0.48937154",
"0.48702782",
"0.48688123",
"0.4823531",
"0.48022318",
"0.48006642",
"0.47575372",
"0.47567225",
"0.47443378",
"0.4730163",
"0.4688956",
"0.46662208",
"0.4642333",
"0.4... | 0.8007914 | 0 |
Bill_paid method updates paid column for Bills. Returns an array of bill_ids that need the paid column to be true | def bill_paid
bill_ids_to_update = []
bills = Bill.includes(:bill_splits)
bill_paid = true
bills.each do |bill|
bill.bill_splits.each do |split|
bill_paid = bill_paid && split.recipient_paid
end
if bill_paid
bill_ids_to_update.push(bill.id)
end
# Reset bi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_paid\n self.check_paid\n # Use update_columns to skip more callbacks\n self.update_columns(paid: self.paid, paid_amount: self.paid_amount)\n end",
"def pay_all_bills\n #self.appointments.update_all(cost: 0)\n self.appointments.each {|a| a.paid}\n end",
"def paid\n whe... | [
"0.7409774",
"0.68678594",
"0.65715265",
"0.646388",
"0.63750476",
"0.62968165",
"0.62943715",
"0.6290311",
"0.6233184",
"0.6190122",
"0.6125305",
"0.61103106",
"0.6049344",
"0.60218066",
"0.59781927",
"0.5852067",
"0.5821356",
"0.57875586",
"0.5787282",
"0.57695967",
"0.5754... | 0.8305236 | 0 |
GET /weapons_types GET /weapons_types.json | def index
@weapons_types = WeaponsType.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @weapons_types }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @weapon_types = WeaponType.all\n\n render json: @weapon_types\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def show\n @weapons_type = WeaponsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n for... | [
"0.7486661",
"0.74548006",
"0.7124811",
"0.7049519",
"0.6995989",
"0.6799722",
"0.6650578",
"0.6503781",
"0.6421163",
"0.6407155",
"0.63738",
"0.6307829",
"0.62753487",
"0.62725496",
"0.6215563",
"0.6215563",
"0.6183276",
"0.6146297",
"0.61342764",
"0.6104675",
"0.60772616",
... | 0.75776684 | 0 |
GET /weapons_types/1 GET /weapons_types/1.json | def show
@weapons_type = WeaponsType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @weapons_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @weapons_types = WeaponsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @weapons_types }\n end\n end",
"def index\n @weapon_types = WeaponType.all\n\n render json: @weapon_types\n end",
"def show\n render json: @weapon_ty... | [
"0.7557915",
"0.7405561",
"0.7080682",
"0.70338",
"0.69112134",
"0.68377185",
"0.6741181",
"0.6676032",
"0.6454673",
"0.63902384",
"0.63826436",
"0.6379832",
"0.6259993",
"0.62562376",
"0.625556",
"0.62017184",
"0.62002784",
"0.6190151",
"0.6190151",
"0.6183187",
"0.6182029",... | 0.7550434 | 1 |
GET /weapons_types/new GET /weapons_types/new.json | def new
@weapons_type = WeaponsType.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @weapons_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @weapons_type = WeaponsType.new(params[:weapons_type])\n\n respond_to do |format|\n if @weapons_type.save\n format.html { redirect_to @weapons_type, notice: 'Weapons type was successfully created.' }\n format.json { render json: @weapons_type, status: :created, location: @weap... | [
"0.75566703",
"0.75373244",
"0.73591566",
"0.734712",
"0.72618836",
"0.71914554",
"0.70875496",
"0.69874066",
"0.6983242",
"0.6930042",
"0.6927358",
"0.6829888",
"0.6821294",
"0.6820877",
"0.68136513",
"0.68008685",
"0.67839795",
"0.67837167",
"0.67797685",
"0.67797685",
"0.6... | 0.80788666 | 0 |
POST /weapons_types POST /weapons_types.json | def create
@weapons_type = WeaponsType.new(params[:weapons_type])
respond_to do |format|
if @weapons_type.save
format.html { redirect_to @weapons_type, notice: 'Weapons type was successfully created.' }
format.json { render json: @weapons_type, status: :created, location: @weapons_type }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @weapon_type = WeaponType.new(weapon_type_params)\n\n if @weapon_type.save\n render json: @weapon_type, status: :created, location: @weapon_type\n else\n render json: @weapon_type.errors, status: :unprocessable_entity\n end\n end",
"def pet_types\r\n BnetApi::make_reque... | [
"0.7276281",
"0.69176286",
"0.6911527",
"0.6389748",
"0.63685334",
"0.6285244",
"0.62796485",
"0.6279584",
"0.62784123",
"0.6232793",
"0.6164081",
"0.61100787",
"0.60883605",
"0.60665196",
"0.60628724",
"0.6040901",
"0.60207003",
"0.59732497",
"0.5959624",
"0.5932341",
"0.591... | 0.7200826 | 1 |
PUT /weapons_types/1 PUT /weapons_types/1.json | def update
@weapons_type = WeaponsType.find(params[:id])
respond_to do |format|
if @weapons_type.update_attributes(params[:weapons_type])
format.html { redirect_to @weapons_type, notice: 'Weapons type was successfully updated.' }
format.json { head :no_content }
else
format.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @weapon_type = WeaponType.find(params[:id])\n\n if @weapon_type.update(weapon_type_params)\n head :no_content\n else\n render json: @weapon_type.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @weapon_type.update(weapon_typ... | [
"0.7585868",
"0.7114269",
"0.66530687",
"0.6627351",
"0.659099",
"0.65111375",
"0.6418152",
"0.63813496",
"0.6357267",
"0.63099563",
"0.6242855",
"0.6224125",
"0.6211643",
"0.61986476",
"0.61804897",
"0.61613476",
"0.6154875",
"0.6130961",
"0.6117892",
"0.6113518",
"0.6101469... | 0.7363982 | 1 |
DELETE /weapons_types/1 DELETE /weapons_types/1.json | def destroy
@weapons_type = WeaponsType.find(params[:id])
@weapons_type.destroy
respond_to do |format|
format.html { redirect_to weapons_types_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @weapon_type.destroy\n\n head :no_content\n end",
"def destroy\n @weapon_type.destroy\n respond_to do |format|\n format.html { redirect_to weapon_types_url, notice: 'Weapon type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy... | [
"0.76043475",
"0.75813264",
"0.72321564",
"0.71466225",
"0.70623624",
"0.70547736",
"0.69824576",
"0.69741744",
"0.69730735",
"0.69668037",
"0.6965528",
"0.696513",
"0.6947532",
"0.6927966",
"0.69256437",
"0.69148743",
"0.6873474",
"0.687082",
"0.6867073",
"0.6865521",
"0.686... | 0.79296285 | 0 |
checks that the associated os_type exists | def os_must_exist
return if self.os_type_id.nil?
errors.add(:os_type_id, "must be an existing OS.") if OsType.find(self.os_type_id).nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def os_type\n\n if @ostype\n return @ostype\n end\n\n res = :invalid\n\n Rouster.os_files.each_pair do |os, f|\n [ f ].flatten.each do |candidate|\n if self.is_file?(candidate)\n next if candidate.eql?('/etc/os-release') and ! self.is_in_file?(candidate, os.to_s, 'i') # CentOS... | [
"0.7222285",
"0.64640266",
"0.6281192",
"0.627834",
"0.62270457",
"0.62235576",
"0.6137453",
"0.61294043",
"0.6084894",
"0.6028942",
"0.601877",
"0.60146403",
"0.60098135",
"0.59796184",
"0.5970616",
"0.59580773",
"0.59495705",
"0.5938054",
"0.5934302",
"0.59327483",
"0.59317... | 0.7997785 | 0 |
Return the number of votes on this voteable | def votes_count
votes.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_votes\n num_of_votes = self.votes.count\n return num_of_votes\n end",
"def vote_count\n self.votes.count\n end",
"def number_of_votes\n self.votes.size\n end",
"def vote_count\n count = Vote.find_all_by_question_id(self.id)\n if count\n return count.count\n else\n ... | [
"0.84357005",
"0.84072703",
"0.83347434",
"0.8237336",
"0.7823559",
"0.78175306",
"0.7731851",
"0.7731851",
"0.77144605",
"0.76944643",
"0.76320475",
"0.7589796",
"0.75711167",
"0.7550084",
"0.7549603",
"0.7548463",
"0.75344795",
"0.7456246",
"0.7456246",
"0.7451813",
"0.7347... | 0.8690773 | 0 |
Return all the voters who voted for this voteable | def voters_who_voted
votes.map(&:voter).uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_votes\n\t\t@voters.each{ |voter| @votes << voter.vote(@candidates) }\n\tend",
"def up_voters\n self.votes.where({value: 1}).collect {|vote| vote.user}\n end",
"def user_voters\n votes = self.votes.order(created_at: :desc)\n user_ids = []\n\n votes.each do |vote|\n user_ids << vote.use... | [
"0.7423311",
"0.69325995",
"0.6846831",
"0.68361366",
"0.67914975",
"0.67729783",
"0.6746141",
"0.6636471",
"0.66146284",
"0.6549418",
"0.65116787",
"0.648335",
"0.6480435",
"0.6451229",
"0.64176255",
"0.6367252",
"0.6318452",
"0.62862545",
"0.61899936",
"0.6188358",
"0.61858... | 0.8103476 | 0 |
Check if a specific voter has voted for this voteable | def voted_by?(voter)
0 < Vote.where(
:voteable_id => self.id,
:voteable_type => self.class.name,
:voter_id => voter.id
).count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_voted_on?(votable)\n # Ineffecient. Change to a better way.\n return votes.pluck(:votable_id).include?(votable.id)\n end",
"def voted_by?(voter)\n up_voted?(voter) || down_voted?(voter)\n end",
"def voted_by?(voter, voting_field = \"votes\")\n !!vote_value(voter, voting_field)\n ... | [
"0.8149587",
"0.80774724",
"0.8069274",
"0.80152345",
"0.80152345",
"0.80047864",
"0.7758587",
"0.77403176",
"0.7675872",
"0.76680887",
"0.76665676",
"0.7666435",
"0.76427567",
"0.7601",
"0.7553447",
"0.7463912",
"0.7444187",
"0.73933583",
"0.73769844",
"0.7330313",
"0.732564... | 0.84780616 | 0 |
show get '/rats/:id' do model | def show
# model
@rat = Rat.find(params[:id])
# response
render :show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @rater = Rater.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rater }\n end\n end",
"def show\n @rute = Rute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :x... | [
"0.721783",
"0.7046521",
"0.6984163",
"0.6982823",
"0.6976052",
"0.6897438",
"0.68908167",
"0.68592066",
"0.68560356",
"0.68503845",
"0.6821857",
"0.6821705",
"0.6815531",
"0.68143135",
"0.6809052",
"0.6773245",
"0.67425364",
"0.67425364",
"0.6733471",
"0.6727122",
"0.6727122... | 0.7768577 | 0 |
The array of SingleResolvers used for sending query messages attr_accessor :single_resolvers :nodoc: | def single_resolvers=(s) # :nodoc:
@configured = true
# @single_res_mutex.synchronize {
@single_resolvers = s
# }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolvers\n @resolvers\n end",
"def add_resolver(single)\r\n @single_resolvers.push(single)\r\n end",
"def resolver\n unless resolvers.empty?\n resolvers.first\n else\n nil\n end\n end",
"def resolve!\n @domains.map(&:resolve!)\n end",
"def re... | [
"0.63107437",
"0.5979599",
"0.5840501",
"0.55672854",
"0.55127263",
"0.548972",
"0.53587997",
"0.5176324",
"0.5153619",
"0.51303405",
"0.5108384",
"0.50863916",
"0.4995421",
"0.49658796",
"0.49617684",
"0.49337977",
"0.48926795",
"0.48536864",
"0.4814126",
"0.47980782",
"0.47... | 0.6460948 | 0 |
Like send_message, but does not raise an error when an error occurs. Instead, it returns it. | def send_message!(message)
response = nil; error = nil
begin
response = send_message(message)
rescue => e
error = e
end
[response, error]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send\n response = @message.send\n @message = new_message\n unless response.success?\n raise ServiceError, response.raw\n end\n return response\n end",
"def send(message)\n message\n end",
"def send_message(message); end",
"def send_message(message); end",
"def send_message(msg)... | [
"0.70161676",
"0.66363436",
"0.6448628",
"0.6448628",
"0.62567985",
"0.59689724",
"0.59233475",
"0.5833965",
"0.5816381",
"0.57728565",
"0.5766792",
"0.5721519",
"0.56442195",
"0.56442195",
"0.5625103",
"0.5619633",
"0.55625385",
"0.55524117",
"0.55342263",
"0.55190635",
"0.5... | 0.6820123 | 1 |
Asynchronously send a Message to the server. The send can be done using just Dnsruby. Support for EventMachine has been deprecated. == Dnsruby pure Ruby event loop : A client_queue is supplied by the client, along with an optional client_query_id to identify the response. The client_query_id is generated, if not suppli... | def send_async(msg, client_queue, client_query_id = nil)
unless @configured
add_config_nameservers
end
# @single_res_mutex.synchronize {
unless @resolver_ruby # @TODO@ Synchronize this?
@resolver_ruby = ResolverRuby.new(self)
end
# }
client_query_id ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_async(*args) # msg, client_queue, client_query_id, use_tcp=@use_tcp)\r\n # @TODO@ Need to select a good Header ID here - see forgery-resilience RFC draft for details\r\n msg = args[0]\r\n client_query_id = nil\r\n client_queue = nil\r\n use_tcp = @use_tcp\r\n if (msg.kind_of?... | [
"0.72161597",
"0.6102812",
"0.5757734",
"0.57091624",
"0.56496376",
"0.5577633",
"0.5528267",
"0.55091053",
"0.54810506",
"0.5428034",
"0.5388661",
"0.53567225",
"0.5200698",
"0.5186172",
"0.5170064",
"0.51572275",
"0.51224566",
"0.51191866",
"0.5114643",
"0.5112234",
"0.5108... | 0.70486856 | 1 |
The source port to send queries from Returns either a single Integer or an Array e.g. '0', or '[60001, 60002, 60007]' Defaults to 0 random port | def src_port
@src_port.length == 1 ? @src_port[0] : @src_port
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_port\n rand(55534) + 10_000\n end",
"def random_port\n rand(55534) + 10_000\n end",
"def random_port\n rand(55534) + 10_000\n end",
"def random_port\n rand(1024..49151)\n end",
"def actual_port; end",
"def actual_port; end",
"def next_src_port\n 1024 + rand(65535 -... | [
"0.62862605",
"0.62862605",
"0.62862605",
"0.6268434",
"0.620305",
"0.620305",
"0.6188896",
"0.6160377",
"0.6126333",
"0.60621446",
"0.5971077",
"0.5908372",
"0.59024155",
"0.58736444",
"0.58599603",
"0.5786744",
"0.5781727",
"0.574432",
"0.5722217",
"0.57154876",
"0.5715255"... | 0.71638846 | 0 |
Sets the TSIG to sign outgoing messages with. Pass in either a Dnsruby::RR::TSIG, or a key_name and key (or just a key) Pass in nil to stop tsig signing. res.tsig=(tsig_rr) res.tsig=(key_name, key) defaults to hmacmd5 res.tsig=(key_name, key, alg) e.g. alg = 'hmacsha1' res.tsig=nil Stop the resolver from signing | def tsig=(t)
@tsig = t
update
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tsig=(*args)\r\n @tsig = SingleResolver.get_tsig(args)\r\n end",
"def tsig=(t)\r\n @tsig=t\r\n update\r\n end",
"def sign(req, ts)\n md5_salt = \"ifxy8jvzf1q0f9uz\"\n body = \"#{CGI.escape(req)}#{ts}#{md5_salt}\"\n # md5.update body.upcase\n sign = Digest::MD5.hexdigest body\n sig... | [
"0.63777214",
"0.6115751",
"0.5130486",
"0.50808513",
"0.50693154",
"0.5048358",
"0.50108564",
"0.49537766",
"0.49536407",
"0.48968494",
"0.4877239",
"0.4861175",
"0.48518595",
"0.48225078",
"0.47695115",
"0.46951512",
"0.46797922",
"0.4677271",
"0.46584728",
"0.46568546",
"0... | 0.63255584 | 1 |
MUST BE CALLED IN A SYNCHRONIZED BLOCK! Sends the result to the client's queue, and removes the queue observer from the select thread | def send_result(client_queue, client_query_id, select_queue, msg, error) # :nodoc: all
stop_querying(client_query_id) # @TODO@ !
# We might still get some callbacks, which we should ignore
st = SelectThread.instance
st.remove_observer(select_queue, self)
# @mutex.synchronize{
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_result_and_close(client_queue, client_query_id, select_queue, msg, error) #:nodoc: all\r\n # We might still get some callbacks, which we should ignore\r\n st = SelectThread.instance\r\n st.remove_observer(select_queue, self)\r\n # @mutex.synchronize{\r\n # Remove the query fr... | [
"0.73035514",
"0.6562838",
"0.620212",
"0.5930962",
"0.5833973",
"0.5806786",
"0.5770664",
"0.5751762",
"0.572997",
"0.5720404",
"0.5710901",
"0.5709971",
"0.5702749",
"0.5681804",
"0.56701916",
"0.5656899",
"0.5625658",
"0.56179214",
"0.5611495",
"0.5567959",
"0.55649376",
... | 0.75176424 | 0 |
This method is called twice a second from the select loop, in the select thread. It should arguably be called from another worker thread... (which also handles the queue) Each tick, we check if any timeouts have occurred. If so, we take the appropriate action : Return a timeout to the client, or send a new query | def tick # :nodoc: all
# Handle the tick
# Do we have any retries due to be sent yet?
# @mutex.synchronize{
@parent.single_res_mutex.synchronize {
time_now = Time.now
@timeouts.keys.each do |client_query_id|
msg, client_queue, select_queue, outstanding = @query_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tick #:nodoc: all\r\n # Handle the tick\r\n # Do we have any retries due to be sent yet?\r\n @mutex.synchronize{\r\n time_now = Time.now\r\n @timeouts.keys.each do |client_query_id|\r\n msg, client_queue, select_queue, outstanding = @query_list[client_query_id]\r\n ... | [
"0.7386343",
"0.6484172",
"0.6419707",
"0.6390079",
"0.62722945",
"0.62630105",
"0.61301535",
"0.6095594",
"0.6083947",
"0.6046161",
"0.5999628",
"0.5980871",
"0.58703953",
"0.5858698",
"0.58533907",
"0.5846369",
"0.584631",
"0.5833777",
"0.5794867",
"0.57428974",
"0.57369715... | 0.7433682 | 0 |
Compute the context to pass to htmlpipeline based on the given options | def pipeline_context(options)
{
:asset_root => "https://a248.e.akamai.net/assets.github.com/images/icons/",
:base_url => "https://github.com/",
:gfm => options[:comment_mode],
:disabled_tasks => !options[:comment_mode]
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(context, options); end",
"def render_template(context, options); end",
"def view_context\n options[:view_context]\n end",
"def determine_template(options); end",
"def html_options; @html_opts end",
"def build_context\n site = stub_jekyll_site\n site.liquid_renderer.file(\"\").par... | [
"0.66335297",
"0.64246696",
"0.64105046",
"0.61946166",
"0.6153456",
"0.60860276",
"0.60352063",
"0.5972369",
"0.5920968",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753",
"0.5875753... | 0.6916406 | 0 |
Compute the filters to use in the htmlpipeline based on the given options | def pipeline_filters(options)
filters = [
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::SanitizationFilter,
HTML::Pipeline::ImageMaxWidthFilter,
HTML::Pipeline::HttpsFilter,
HTML::Pipeline::EmojiFilter,
GithubMarkdownPreview::Pipeline::TaskListFilter
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_pipeline\n @filter_pipeline ||= HTML::Pipeline.new([TypogrubyFilter])\n end",
"def liquid_filters\n [\n StylesheetFilter,\n JavascriptFilter,\n AssignToFilter,\n LinkToFilter,\n GoogleAnalyticsFilter,\n GoogleWebmasterToolsFilter,\n GoogleJavascrip... | [
"0.7205011",
"0.693711",
"0.67044365",
"0.67044365",
"0.654563",
"0.6517949",
"0.6425086",
"0.640834",
"0.63339275",
"0.6321674",
"0.626295",
"0.6215505",
"0.6209103",
"0.61859655",
"0.61204827",
"0.61202574",
"0.61156905",
"0.6080281",
"0.6068146",
"0.60445887",
"0.6041467",... | 0.8049746 | 0 |
Update the preview file | def update
unless File.exist?(@source_file)
raise FileNotFoundError.new("Source file deleted")
end
markdown_render = @preview_pipeline.call(IO.read(@source_file), @pipeline_context, {})[:output].to_s
preview_html = wrap_preview(markdown_render)
File.open(@preview_file, 'w') do |f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n end",
"def preview\n end",
"def update\n @upload_preview = UploadPreview.find(params[:id])\n\n respond_to do |format|\n if @upload_preview.update_attributes(params[:upload_preview])\n format.html { redirect_to(@upload_preview, :notice => 'Upload preview was successfully update... | [
"0.70834315",
"0.70834315",
"0.6808312",
"0.6761738",
"0.6719533",
"0.66168374",
"0.661459",
"0.661459",
"0.65717447",
"0.6533753",
"0.64291286",
"0.634634",
"0.634634",
"0.63302034",
"0.6324805",
"0.6314412",
"0.6266992",
"0.62500346",
"0.6219718",
"0.6197564",
"0.61892426",... | 0.78473943 | 0 |
Register a callback to be fired when the preview is updated Multiple calls to this will register multiple callbacks | def on_update(&update_callback)
@update_callbacks << update_callback
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_update_callback &cb\n\t\t\t@update_callbacks << cb\n\t\t\tcb\n\t\tend",
"def on_update=(callback)\n @update_callback = callback\n end",
"def after_update_callback\n puts('----------after_updateをコール----------')\n end",
"def callback\n end",
"def register_update_handle_callback(&blk)\n ... | [
"0.65909946",
"0.6419817",
"0.61350065",
"0.6110187",
"0.6102253",
"0.60801685",
"0.6016127",
"0.60073346",
"0.59658086",
"0.5919196",
"0.58123004",
"0.57754624",
"0.57754624",
"0.5757943",
"0.57541937",
"0.57541937",
"0.5723598",
"0.5671103",
"0.5671103",
"0.5637252",
"0.563... | 0.68373394 | 0 |
Watch source file for changes, updating preview on change Nonblocking version of watch! | def watch
start_watch
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watch!\n start_watch true\n end",
"def watch_src\n Dispatch::Queue.concurrent.async do\n raise \"$project_src_dir undefined.\" if ! $project_src_dirs\n\n dirs = $project_src_dirs.map { |dir| dir.stringByExpandingTildeInPath }\n options = FSEvent::CLI.parse(dirs.dup << '--file-events... | [
"0.7250246",
"0.7138005",
"0.70792747",
"0.67944354",
"0.67288184",
"0.669319",
"0.669319",
"0.6652054",
"0.66162",
"0.6604042",
"0.6604042",
"0.6592163",
"0.65217745",
"0.65217745",
"0.6507584",
"0.6493642",
"0.64625376",
"0.6425739",
"0.63516927",
"0.6339636",
"0.6308519",
... | 0.73883456 | 0 |
Watch source file for changes, updating preview on change Blocking version of watch | def watch!
start_watch true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watch\n start_watch\n end",
"def watch\n\nend",
"def watch_src\n Dispatch::Queue.concurrent.async do\n raise \"$project_src_dir undefined.\" if ! $project_src_dirs\n\n dirs = $project_src_dirs.map { |dir| dir.stringByExpandingTildeInPath }\n options = FSEvent::CLI.parse(dirs.dup <... | [
"0.7272507",
"0.7067961",
"0.69017553",
"0.68236727",
"0.67888117",
"0.6657434",
"0.6657434",
"0.6643811",
"0.6643811",
"0.6580039",
"0.6575383",
"0.6506219",
"0.65018344",
"0.65018344",
"0.64535517",
"0.6420128",
"0.6377666",
"0.63722014",
"0.63468695",
"0.63320476",
"0.6325... | 0.7145439 | 1 |
Delete the preview file from disk | def delete
if File.exist?(@preview_file)
File.delete(@preview_file)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n file&.delete\n end",
"def del\n File.delete(@file)\n end",
"def delete\n @file = nil\n # file.delete\n end",
"def destroy_file\n File.delete full_file_path\n rescue\n end",
"def delete\n ::File.unlink(@path)\n end",
"def de... | [
"0.7761365",
"0.76965845",
"0.7685517",
"0.7643839",
"0.7476809",
"0.74297583",
"0.73658544",
"0.7316429",
"0.7302307",
"0.7256241",
"0.7218007",
"0.7218007",
"0.71218824",
"0.71177584",
"0.7111943",
"0.71009785",
"0.7041792",
"0.7018793",
"0.7011464",
"0.70022506",
"0.699538... | 0.8764679 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.