query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Checks for multivalued fields, turns them into arrays, and combines all the values for the repeatable header. | def combine_multivalued_fields(uncombined_fields)
combined_fields = {}
uncombined_fields.each do |field|
normalized_header = normalize_header(field.header)
if multivalued?(normalized_header)
combined_fields[normalized_header] ||= Field.new(field.header, [])
combined_fields[normalized_header].value << field.value
else
combined_fields[normalized_header] ||= Field.new(field.header, field.value)
end
end
combined_fields.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiple_fields_to_one multfields, prefix=false\n vals = []\n multfields.each do |field, anotherval|\n if anotherval and not anotherval.empty? \n anotherval = anotherval.strip\n anotherval = field + \": #{anotherval}\" if prefix\n vals << anotherval\n end... | [
"0.6174231",
"0.58449346",
"0.5778309",
"0.56037545",
"0.5589498",
"0.5524742",
"0.55157167",
"0.5432429",
"0.540262",
"0.540262",
"0.54020363",
"0.5379739",
"0.53390354",
"0.53290915",
"0.5322947",
"0.531397",
"0.5293062",
"0.5260944",
"0.52455777",
"0.52386403",
"0.5224557"... | 0.69141644 | 0 |
quick check to see if this looks like a dotmation config file | def is_config?(data)
data.match(/dot|xdg/)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_config_filename\n \"path to a valid config file\"\n end",
"def check_config_format(config_path)\n $config = YAML::load(File.open(config_path))\n \n if !$config\n p \"Nothing in configuration. Exiting...\"\n exit 2\n elsif !$config['apps']\n p \"No applications in configuration. Exi... | [
"0.73369086",
"0.70864165",
"0.70606035",
"0.686761",
"0.68008894",
"0.67525357",
"0.6727321",
"0.66040415",
"0.6554731",
"0.6509361",
"0.648607",
"0.64283407",
"0.64094245",
"0.63725823",
"0.63665044",
"0.63643384",
"0.63350236",
"0.63327134",
"0.63140386",
"0.6308351",
"0.6... | 0.7345876 | 0 |
arg is the path to the config file (checks for existence first), a url or a github name. If given a file then it can give line number error messages. | def initialize(arg=nil)
set_from_config!(arg) if arg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highlight_config_error(file, line)\n config_file_lines = []\n\n # A file line is split into the line number (index) and the line content.\n # The line number is converted to string (to_s), right justified 3 characters with a colon, and its trimmed (chomp)\n\n IO.readlines(file).each_with_in... | [
"0.62650716",
"0.6073621",
"0.58032966",
"0.57874924",
"0.57857597",
"0.57857597",
"0.57857597",
"0.56303215",
"0.56060684",
"0.5559154",
"0.55367726",
"0.5463535",
"0.5462387",
"0.5460368",
"0.5424499",
"0.54067826",
"0.5389436",
"0.5387178",
"0.5384301",
"0.5381973",
"0.534... | 0.0 | -1 |
given a filename, a url, or a github name, will read the config file. returns self | def set_from_config!(arg)
@config_data =
if arg.include?("://")
open(arg) {|io| io.read }
elsif File.exist?(arg)
@config_filename = arg
IO.read(arg)
else
url = "https://raw.github.com/#{arg}/#{DEFAULT_CONFIG_GITHUB_REPO}/master/#{DEFAULT_CONFIG_GITHUB_PATH}"
begin
open(url) {|io| io.read }
rescue
raise RuntimeError, "assuming this is a github account name, but config file does not exist!: #{url}"
end
end
raise "config file doesn't look like config file" unless is_config?(@config_data)
(@data, @repos) = read_config_data(@config_data, @config_filename)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_config_file(file); end",
"def read_config_file; end",
"def initialize\n @config = config_from_file || empty_config\n end",
"def config_file\n @config_file\n end",
"def initialize(file_name, config = Crossref::Config)\n @file_name = file_name\n @config = config.load_config... | [
"0.67986375",
"0.66661227",
"0.64985013",
"0.6364298",
"0.63393503",
"0.6318858",
"0.6314006",
"0.628132",
"0.62802494",
"0.62562203",
"0.62440175",
"0.62334657",
"0.62129724",
"0.62113583",
"0.62111723",
"0.62046295",
"0.6188979",
"0.61832756",
"0.61553156",
"0.6140488",
"0.... | 0.7685288 | 0 |
returns data and repos. filename is helpful only for debugging. | def read_config_data(data, filename=nil)
ConfigReader.new.read(data, filename)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data\n @data ||= file? ?\n repos.file(fs_path, revision) :\n repos.dir(fs_path, revision)\n end",
"def data\n @repo_data\n end",
"def data\n data = @repo.working_read(@path) rescue nil\n data\n end",
"def list_files repos\n raise \"required ... | [
"0.714212",
"0.71261907",
"0.6785698",
"0.6780657",
"0.6704207",
"0.65609276",
"0.6550417",
"0.65123725",
"0.64992255",
"0.64853007",
"0.64511174",
"0.6438934",
"0.641075",
"0.6355222",
"0.62439364",
"0.6243057",
"0.6231202",
"0.62244225",
"0.6206093",
"0.6188503",
"0.6174837... | 0.0 | -1 |
Render a single file as if it were a diff with no changes & full context | def render_orphan(sequence, name, timestamp)
@names << name
left_header = "--- New file"
right_header = right_header_line(name, timestamp)
helper = HeaderHelper.new(left_header, right_header, @names.count - 1)
result = template("html_header.erb").evaluate(helper)
# create one opcode with the entire content
opcodes = [
[:equal, 0, sequence.length-1, 0, sequence.length-1]
]
helper = hunk_context(sequence, sequence, nil, opcodes, 0)
result << template("html_hunk.erb").evaluate(helper)
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_file!(f, target)\n done = 'keep'.white\n # unless newer?(target, f)\n tilt = Tilt::ERBTemplate.new(f)\n oh = File.open(target, 'wb')\n oh.write tilt.render(OpenStruct.new(@attrs.deep_merge(@config['attrs'])))\n oh.close\n\n # update template timestamp\n FileUtils.touch(f)\n do... | [
"0.6746669",
"0.6353739",
"0.6335399",
"0.63290465",
"0.6302568",
"0.61235553",
"0.6111975",
"0.61047834",
"0.6079808",
"0.6035596",
"0.59908634",
"0.5984947",
"0.5971413",
"0.5901739",
"0.5890334",
"0.58665586",
"0.584461",
"0.5812923",
"0.5806066",
"0.5793864",
"0.5791748",... | 0.0 | -1 |
override to add/change templates | def template_path(filename)
File.join(PatienceDiff::TEMPLATE_PATH, filename)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_template\n end",
"def add_template_pages; end",
"def templates; end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def template; end",
"def template(name); end",
"def templates_for(file); end",
"def... | [
"0.7978485",
"0.7597656",
"0.75656074",
"0.7231371",
"0.7231371",
"0.7231371",
"0.7231371",
"0.7231371",
"0.7231371",
"0.7231371",
"0.706379",
"0.69378155",
"0.6736379",
"0.66987044",
"0.6674104",
"0.6652837",
"0.6651881",
"0.6633436",
"0.6589501",
"0.6589501",
"0.65857697",
... | 0.0 | -1 |
Find the median of two sorted arrays | def find_median(arr1, arr2)
# determine index value of median element
median_index = ((arr1.length + arr2.length) / 2.0).round
stitched = []
# merge in order until length of the merged and sorted array is enough to
# calculate the median
while arr1.length > 0 and arr2.length > 0 and stitched.length < median_index
if arr1[0] <= arr2[0]
stitched.push(arr1.shift)
else
stitched.push(arr2.shift)
end
end
puts stitched
# if the stitched array has an even number of elements, then we need to use the last two
# otherwise just return the last element
if stitched.length.even?
return (stitched[-1] + stitched[-2]) / 2.0
else
return stitched[-1]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def median_sorted_arrays_dc(arr1, arr2)\n size = arr1.size\n return -1 if size <= 0\n return (arr1.first+arr2.first)/2 if size == 1\n return ([arr1.first, arr2.first].max + [arr1[1], arr2[1]].min)/2 if size == 2\n pos_med1 = arr1.size/2\n pos_med2 = arr2.size/2\n # If both are equal even though we form a ne... | [
"0.8358604",
"0.83355564",
"0.8266037",
"0.7651489",
"0.70722634",
"0.70464146",
"0.7044583",
"0.7026644",
"0.70022833",
"0.69793415",
"0.697342",
"0.6967107",
"0.69570243",
"0.6911792",
"0.6910163",
"0.69100744",
"0.6909307",
"0.6906097",
"0.69055784",
"0.69042623",
"0.69036... | 0.8347991 | 1 |
if it is not a mti_class do what you do else let the primary shard do the saving come back and cleanup | def create
return super unless mti_class?
shard_wrangler.cascade_save
ActiveRecord::IdentityMap.add(self) if ActiveRecord::IdentityMap.enabled?
@new_record = false
self.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sync\n # Reset the stash map to ensure that it's reset before the next\n # transaction is being started.\n @_stash_map = nil\n\n db_obj = {\n 'class_id' => @store.class_map.class_to_id(self.class.to_s),\n 'data' => _serialize\n }\n @store.db.put_object(db_obj, @_id)... | [
"0.5826379",
"0.5673144",
"0.5557971",
"0.55197066",
"0.5501623",
"0.54532266",
"0.54152966",
"0.53763133",
"0.53615886",
"0.53386056",
"0.53035116",
"0.52685183",
"0.52661794",
"0.5264755",
"0.5241011",
"0.52393705",
"0.52325785",
"0.5213133",
"0.5213133",
"0.5213133",
"0.52... | 0.6373751 | 0 |
if it is not a mti_class do what you do else let the primary shard do the destruction come back and cleanup | def destroy
return super unless mti_class?
shard_wrangler.destroy
if ActiveRecord::IdentityMap.enabled? and persisted?
ActiveRecord::IdentityMap.remove(self)
end
@destroyed = true
freeze
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n return super unless mti_class?\n shard_wrangler.class.cascade_delete_all(:id => id)\n if ActiveRecord::IdentityMap.enabled? and persisted?\n ActiveRecord::IdentityMap.remove(self)\n end\n @destroyed = true\n freeze\n end",
"def finalize()\n # below function... | [
"0.62744975",
"0.55911255",
"0.55807793",
"0.55019563",
"0.5481457",
"0.5481457",
"0.5481457",
"0.5481457",
"0.5479273",
"0.5475279",
"0.5421617",
"0.53866553",
"0.536539",
"0.5353782",
"0.5343694",
"0.5343694",
"0.53373057",
"0.5336828",
"0.5321232",
"0.53058505",
"0.5301606... | 0.6620269 | 0 |
if it is not a mti_class do what you do else let the primary shard do the deletion come back and cleanup | def delete
return super unless mti_class?
shard_wrangler.class.cascade_delete_all(:id => id)
if ActiveRecord::IdentityMap.enabled? and persisted?
ActiveRecord::IdentityMap.remove(self)
end
@destroyed = true
freeze
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n return super unless mti_class?\n shard_wrangler.destroy\n if ActiveRecord::IdentityMap.enabled? and persisted?\n ActiveRecord::IdentityMap.remove(self)\n end\n @destroyed = true\n freeze\n end",
"def delete_class o_class\n cl = classname(o_class)\n logg... | [
"0.6335179",
"0.5841632",
"0.5833209",
"0.57810926",
"0.5780316",
"0.5668683",
"0.5668683",
"0.56190246",
"0.56106365",
"0.5601296",
"0.5518485",
"0.5473844",
"0.5435063",
"0.5433932",
"0.539326",
"0.5380965",
"0.53754777",
"0.5354353",
"0.5353075",
"0.5353075",
"0.5317528",
... | 0.66031605 | 0 |
multi array ops on ruby arrays with same sizes | def multi_array_op(func, *args)
elem = args[0]
if elem.is_a?(Array)
elem.each_with_index.collect do |_item, index|
indexed_args = args.collect { |a| a = a.is_a?(Array) ? a : [a]; a[index] }
multi_array_op(func, *indexed_args)
end
else
func.call(*args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_array(array)\n array + array\nend",
"def double_array(array)\n array*2\nend",
"def mutliplied(array)\nend",
"def double_array(array)\n array.concat(array)\nend",
"def cross_array(*enumerables)\n # return to_a.product(*enumerables.map{|e| e.to_a})\n enumerables.unshift self\n result... | [
"0.68821985",
"0.66907203",
"0.6639874",
"0.6609849",
"0.6472788",
"0.64336085",
"0.6425901",
"0.6424392",
"0.6404394",
"0.6332263",
"0.63119227",
"0.62647986",
"0.6223592",
"0.6214414",
"0.62041587",
"0.62035066",
"0.6198502",
"0.619283",
"0.6170268",
"0.6161464",
"0.6144432... | 0.69382524 | 0 |
handle 3 tensor math operations | def call_3way_vector_op(v_a, v_b, v_c, child_context, &block)
return yield(v_a, v_b, v_c) unless v_a.is_a?(Array)
v_a.each_with_index.collect do |v1, index|
v2 = v_b[index]
v3 = v_c.is_a?(Array) ? v_c[index] : v_c
if v1.is_a?(Array)
call_3way_vector_op(v1, v2, v3, child_context, &block)
else
yield(v1, v2, v3)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transmogrifier(num1, num2, num3)\n\t(num1 * num2) ** num3\nend",
"def transmogrifier num1,num2,num3\n\t(num1 * num2) ** num3\nend",
"def transmogrifier (num1,num2,num3)\n (num1 * num2)**num3\nend",
"def transmogrifier(num1, num2, num3)\n transmogrified = ((num1*num2) * num3)\n return transmogrified ... | [
"0.6035634",
"0.5901361",
"0.58505476",
"0.58209014",
"0.5779332",
"0.57538015",
"0.5657838",
"0.5625845",
"0.5610086",
"0.55967724",
"0.5596765",
"0.54679465",
"0.5433536",
"0.54202074",
"0.5405133",
"0.5399429",
"0.538885",
"0.52724767",
"0.52546",
"0.5216338",
"0.51268774"... | 0.0 | -1 |
SF OpenData don't have rating for food trucks. We give random ratings for display purposes. | def rating
rand(40..140).to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_rating\n ratings = [\n ['Low Unsatisfactory', 2], \n ['High Unsatisfactory', 3], \n ['Low Satisfactory', 10], \n ['Mid Satisfactory', 15], \n ['High Satisfactory', 20], \n ['Low Advanced', 25], \n ['High Advanced', 25]\n ]\n wChooseUsingRand(@rand, ratings... | [
"0.7331151",
"0.6829501",
"0.6675677",
"0.661202",
"0.6558206",
"0.64459854",
"0.6426603",
"0.62336653",
"0.6217112",
"0.6152719",
"0.6148448",
"0.6116917",
"0.6105556",
"0.6097569",
"0.60747373",
"0.6062242",
"0.6044514",
"0.6039364",
"0.603809",
"0.60060555",
"0.5965579",
... | 0.7123666 | 1 |
Used for home page upload | def create
@receipt = current_user.receipts.build receipt_params
if @receipt.save
render json: {
receiptId: @receipt.id
}, status: 200
else
render json: {
error: @receipt.errors.full_messages.first,
}, status: 400
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adm_upload_selected\n if params[:upload].nil?\n flash.now[:error]='Es wäre schon gut, vor dem Upload eine Datei auszuwählen'\n else\n fpath=params[:upload].tempfile\n fbasename=File.basename(params[:upload].original_filename)\n # tempf=File.open(fpath,'r:BOM|UTF-8')\n ... | [
"0.75396794",
"0.7247704",
"0.7217689",
"0.7217689",
"0.7048944",
"0.7025128",
"0.6786027",
"0.6634935",
"0.66342694",
"0.65733033",
"0.6517045",
"0.65095687",
"0.64565",
"0.64150196",
"0.640897",
"0.6394262",
"0.63933957",
"0.63890725",
"0.63294303",
"0.6294235",
"0.62794113... | 0.0 | -1 |
Used for home page upload | def process_text
@receipt = current_user.receipts.find(params[:receipt_id])
if @receipt.present?
@receipt.process_text!
render json: { receiptUrl: receipt_url(@receipt)}, status: 200
else
render json: {
error: @receipt.errors.full_messages.first,
}, status: 400
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adm_upload_selected\n if params[:upload].nil?\n flash.now[:error]='Es wäre schon gut, vor dem Upload eine Datei auszuwählen'\n else\n fpath=params[:upload].tempfile\n fbasename=File.basename(params[:upload].original_filename)\n # tempf=File.open(fpath,'r:BOM|UTF-8')\n ... | [
"0.7539814",
"0.7244742",
"0.7215036",
"0.7215036",
"0.70458555",
"0.7022036",
"0.6785197",
"0.66328365",
"0.6632056",
"0.65708524",
"0.65152776",
"0.6508702",
"0.64537793",
"0.6414205",
"0.6407937",
"0.639302",
"0.63928306",
"0.6385388",
"0.63282716",
"0.6292313",
"0.6278396... | 0.0 | -1 |
unless you yield or call to the block: | def hello
"hello"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8364825",
"0.8074893",
"... | 0.0 | -1 |
Here we yield to the block on line 22 then execute the rest of the method | def say(words)
yield
puts words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7752462",
"0.7741243",
"... | 0.0 | -1 |
Hello the block executes (because it's the first line in the method implementation) World! then the rest of the method is evaluated => nil nil is returned at puts is the last expression evaluated and always returns nil | def say(words)
yield if block_given?
puts "> " + words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hello_world(&block)\n puts block.call\nend",
"def greeting(&block)\n puts 'good morning'\n text = block.call('hello')\n puts text\n puts 'good evening'\nend",
"def greeting(&block)\n puts 'good morning'\n text = block.call('hello')\n puts text\n puts 'good evening'\nend",
"def he... | [
"0.7029063",
"0.7000186",
"0.7000186",
"0.68835276",
"0.6721916",
"0.6712578",
"0.6712578",
"0.66419613",
"0.66212165",
"0.64980346",
"0.64818966",
"0.647526",
"0.6347402",
"0.6341181",
"0.633767",
"0.6320346",
"0.63184357",
"0.6309011",
"0.6307766",
"0.6306559",
"0.62841207"... | 0.63480604 | 12 |
Constantize full class name to allow methods to be sent to class | def modularized_class
"NameDrop::Resources::#{resource_class_name}".constantize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def underscorized_classname\n self.class.name.split(\"::\").last.\n gsub( /([A-Z]+)([A-Z][a-z])/, '\\1_\\2' ).\n gsub( /([a-z\\d])([A-Z])/, '\\1_\\2' ).downcase\n end",
"def safe_class_name()\n self.class.name.downcase.gsub(/[^\\d\\w]/, '_')\n end",
"def full_c... | [
"0.786215",
"0.77200544",
"0.754699",
"0.75467527",
"0.74926627",
"0.7381466",
"0.73253787",
"0.72885156",
"0.7274573",
"0.72708374",
"0.72708374",
"0.7241179",
"0.7179849",
"0.71694124",
"0.7093171",
"0.70799255",
"0.7062662",
"0.7044486",
"0.70441365",
"0.7040874",
"0.70400... | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
@post = Post.find(params[:id])
@commentable = @post
@comments = @commentable.comments
@comment = Comment.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
... | [
"0.77110183",
"0.73537844",
"0.73433185",
"0.73379177",
"0.73228735",
"0.7293139",
"0.7275997",
"0.7256934",
"0.7161576",
"0.7158913",
"0.71552676",
"0.71552676",
"0.7119547",
"0.7094749",
"0.7094749",
"0.7094749",
"0.70943594",
"0.7071599",
"0.70607626",
"0.70452625",
"0.703... | 0.0 | -1 |
GET /posts/new GET /posts/new.json | def new
if signed_in?
@post = Post.new
else
flash[:error] = "Please sign in to post"
redirect_to('/signin')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n \n @post = Post.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @post }\n end\n end",
"def new\n @post = Post.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\... | [
"0.8041974",
"0.80156785",
"0.79855186",
"0.7931169",
"0.79215",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"0.79208946",
"... | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = current_user.posts.create(params[:post])
if @post.save
flash[:success] = 'Post was successfully created.'
redirect_to @post
else
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @po... | [
"0.74463975",
"0.73221767",
"0.73072433",
"0.7123966",
"0.7015686",
"0.701327",
"0.69841874",
"0.6939327",
"0.69313824",
"0.69053805",
"0.68196476",
"0.6812792",
"0.6793222",
"0.6792862",
"0.6779654",
"0.6779654",
"0.67625546",
"0.67602354",
"0.67515427",
"0.6735786",
"0.6698... | 0.0 | -1 |
PUT /posts/1 PUT /posts/1.json | def update
@post = Post.find(params[:id])
if @post.update_attributes(params[:post])
flash[:success] = 'Post was successfully created.'
redirect_to @post
else
render action: "edit"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n respond_with post.update(params[:id], params[:post])\n end",
"def update\n title = params[:title]\n body ... | [
"0.730712",
"0.7121667",
"0.6814235",
"0.66412306",
"0.66166633",
"0.66057837",
"0.6581644",
"0.656272",
"0.6549959",
"0.65330195",
"0.651011",
"0.64858186",
"0.644467",
"0.6430717",
"0.6413994",
"0.6384365",
"0.6381423",
"0.63646674",
"0.6364095",
"0.6363726",
"0.6361106",
... | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post = Post.find(params[:id])
@post.destroy
redirect_to posts_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param... | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"... | 0.0 | -1 |
GET /book_editions/1 GET /book_editions/1.json | def show
@book_edition = BookEdition.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @book_edition }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_editions(params = {})\n get_json(get_editions_url(params))\n end",
"def show\n @ebook = Ebook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ebook }\n end\n end",
"def show\n @bookwork = Bookwork.find(params[:id])\n ... | [
"0.75861424",
"0.63522375",
"0.6336166",
"0.6311693",
"0.6262766",
"0.6220065",
"0.6185017",
"0.61807644",
"0.61670285",
"0.6116654",
"0.5896409",
"0.58800846",
"0.5848406",
"0.5824201",
"0.5811929",
"0.5804929",
"0.5795652",
"0.5782079",
"0.5782079",
"0.57789487",
"0.5771109... | 0.69758075 | 1 |
GET /book_editions/new GET /book_editions/new.json | def new
@book_edition = BookEdition.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @book_edition }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @ebook = Ebook.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ebook }\n end\n end",
"def new\n @book_step = BookStep.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_step }\n ... | [
"0.6673376",
"0.6649164",
"0.66380847",
"0.6552363",
"0.6552363",
"0.6551553",
"0.64930576",
"0.646029",
"0.6452665",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.64522296",
"0.6... | 0.72223675 | 0 |
POST /book_editions POST /book_editions.json | def create
@book_edition = BookEdition.new(params[:book_edition])
respond_to do |format|
if @book_edition.save
format.html { redirect_to @book_edition, notice: 'Book edition was successfully created.' }
format.json { render json: @book_edition, status: :created, location: @book_edition }
else
format.html { render action: "new" }
format.json { render json: @book_edition.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_editions(params = {})\n get_json(get_editions_url(params))\n end",
"def new\n @book_edition = BookEdition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_edition }\n end\n end",
"def index\n set_sort_params(params, params[:editio... | [
"0.6483485",
"0.5559471",
"0.5534786",
"0.5522819",
"0.5461252",
"0.54524195",
"0.5435738",
"0.5397763",
"0.5324665",
"0.5295557",
"0.52609503",
"0.5211759",
"0.5158263",
"0.5131353",
"0.5089978",
"0.5073321",
"0.50497204",
"0.5042247",
"0.5015296",
"0.49752697",
"0.49639487"... | 0.6236308 | 1 |
PUT /book_editions/1 PUT /book_editions/1.json | def update
@book_edition = BookEdition.find(params[:id])
respond_to do |format|
if @book_edition.update_attributes(params[:book_edition])
format.html { redirect_to @book_edition, notice: 'Book edition was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @book_edition.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @book_step = BookStep.find(params[:id])\n\n respond_to do |format|\n if @book_step.update_attributes(params[:book_step])\n format.html { redirect_to @book_step, notice: 'Book step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html ... | [
"0.6286758",
"0.6152691",
"0.61249655",
"0.6065369",
"0.6051807",
"0.5939199",
"0.5919881",
"0.5862974",
"0.5779976",
"0.5743298",
"0.5725421",
"0.5720114",
"0.5708054",
"0.5695846",
"0.5677846",
"0.56751186",
"0.56719136",
"0.56503654",
"0.56502616",
"0.5645794",
"0.5643389"... | 0.670074 | 0 |
DELETE /book_editions/1 DELETE /book_editions/1.json | def destroy
@book_edition = BookEdition.find(params[:id])
@book_edition.destroy
respond_to do |format|
format.html { redirect_to book_editions_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @book_step = BookStep.find(params[:id])\n @book_step.destroy\n\n respond_to do |format|\n format.html { redirect_to book_steps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ebooks.destroy :id\n respond_to do |format|\n format.html { redirec... | [
"0.7028683",
"0.69519824",
"0.67939264",
"0.6776585",
"0.67064196",
"0.66786176",
"0.6643948",
"0.6634539",
"0.6586968",
"0.65838796",
"0.64897543",
"0.6487982",
"0.64759845",
"0.6473655",
"0.64643717",
"0.6455547",
"0.64515024",
"0.64497",
"0.6442694",
"0.6442694",
"0.644269... | 0.75303924 | 0 |
We need this for atom_feed since an item doesn't have its correspoding show page | def item_url(item)
item.url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\n update_feed(@feed)\n\n @items = @feed.items.order('pub_date DESC').page params[:page]\n\n end",
"def feed_items\n feed_item\n end",
"def show\n @feed = Feed.find(params[:id]) rescue Feed.find_by_uri(params[:id])\n if @feed.is_duplicate? and @feed.duplicate\n redirect_to feed_... | [
"0.7065571",
"0.6741975",
"0.66020906",
"0.62356824",
"0.6219078",
"0.6200962",
"0.6180708",
"0.6100122",
"0.60709983",
"0.6049007",
"0.6026695",
"0.5978764",
"0.5975321",
"0.5971491",
"0.5958351",
"0.5957793",
"0.5940805",
"0.5933831",
"0.5932071",
"0.5916692",
"0.59159124",... | 0.55392957 | 66 |
GET /injurylocations GET /injurylocations.json | def index
@injurylocations = Injurylocation.all
@injurylocation = Injurylocation.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations\n get('locations')\n end",
"def index\n @investigationinjurylocations = Investigationinjurylocation.all\n end",
"def index\n locations = @project.locations.all\n render json: { locations: locations }\n end",
"def get_location\n as_json(get_results('/locations.json'))\n end",
... | [
"0.707683",
"0.70538217",
"0.69565535",
"0.6797584",
"0.6729313",
"0.6706152",
"0.65481186",
"0.64846283",
"0.6391387",
"0.63740015",
"0.63456833",
"0.6335893",
"0.62675375",
"0.6259015",
"0.6255757",
"0.62306124",
"0.62120104",
"0.62052584",
"0.61991715",
"0.61971456",
"0.61... | 0.6872393 | 3 |
GET /injurylocations/1 GET /injurylocations/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @injurylocations = Injurylocation.all\n @injurylocation = Injurylocation.new\n end",
"def index\n locations = @project.locations.all\n render json: { locations: locations }\n end",
"def index\n @investigationinjurylocations = Investigationinjurylocation.all\n end",
"def index\n ... | [
"0.7053685",
"0.68887514",
"0.68667996",
"0.65881336",
"0.65324515",
"0.6518005",
"0.6496938",
"0.64603835",
"0.6446168",
"0.63539594",
"0.6329275",
"0.6304276",
"0.63042605",
"0.62813634",
"0.6275883",
"0.6268665",
"0.626854",
"0.6254408",
"0.62329596",
"0.6219998",
"0.61730... | 0.0 | -1 |
POST /injurylocations POST /injurylocations.json | def create
@injurylocation = Injurylocation.new(injurylocation_params)
respond_to do |format|
if @injurylocation.save
format.html { redirect_to injurylocations_path, notice: 'Injurylocation was successfully created.' }
format.json { render :show, status: :created, location: @injurylocation }
else
format.html { render :new }
format.json { render json: @injurylocation.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @investigationinjurylocation = Investigationinjurylocation.new(investigationinjurylocation_params)\n\n respond_to do |format|\n if @investigationinjurylocation.save\n format.html { redirect_to @investigationinjurylocation.investigation, notice: 'Investigationinjurylocation was succes... | [
"0.70700353",
"0.6621055",
"0.6541455",
"0.64135724",
"0.63652897",
"0.6237003",
"0.60907704",
"0.6078286",
"0.60781884",
"0.60401905",
"0.60296065",
"0.60133",
"0.5990164",
"0.5979837",
"0.5975455",
"0.59443134",
"0.5914143",
"0.5912503",
"0.59022427",
"0.589973",
"0.5888254... | 0.7735785 | 0 |
PATCH/PUT /injurylocations/1 PATCH/PUT /injurylocations/1.json | def update
respond_to do |format|
if @injurylocation.update(injurylocation_params)
format.html { redirect_to @injurylocation, notice: 'Injurylocation was successfully updated.' }
format.json { render :show, status: :ok, location: @injurylocation }
else
format.html { render :edit }
format.json { render json: @injurylocation.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end",
"def update\r\n @location = Location.find(params[:id])\r\n \r\n respond_to do |format|\r\n if @location.update_attributes(params[:location])\r\n format.json { head :no_content }\r\n else\r\n ... | [
"0.6928675",
"0.6590127",
"0.6535516",
"0.63895977",
"0.636359",
"0.6359285",
"0.6354006",
"0.6349617",
"0.6347368",
"0.63206893",
"0.6289312",
"0.62445134",
"0.62128",
"0.62029785",
"0.6196315",
"0.6193008",
"0.6151019",
"0.615026",
"0.6142713",
"0.61333203",
"0.6132148",
... | 0.7007172 | 0 |
DELETE /injurylocations/1 DELETE /injurylocations/1.json | def destroy
@injurylocation.destroy
respond_to do |format|
format.html { redirect_to injurylocations_url, notice: 'Injurylocation was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Location.delete(params[\"id\"])\n end",
"def destroy\n @investigationinjurylocation.destroy\n respond_to do |format|\n format.html { redirect_to investigationinjurylocations_url, notice: 'Investigationinjurylocation was successfully destroyed.' }\n format.json { head... | [
"0.7169746",
"0.70201606",
"0.69014966",
"0.6846182",
"0.683516",
"0.6805017",
"0.6783422",
"0.6693135",
"0.6686494",
"0.6681633",
"0.66808337",
"0.6662069",
"0.66606796",
"0.6659907",
"0.66580576",
"0.66580576",
"0.665664",
"0.6656152",
"0.6656152",
"0.6656152",
"0.6656152",... | 0.7359374 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_injurylocation
@injurylocation = Injurylocation.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def injurylocation_params
params.require(:injurylocation).permit(:name, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
O(n) p my_min([ 0, 3, 5, 4, 5, 10, 1, 90 ]) p efficient_my_min([ 0, 3, 5, 4, 5, 10, 1, 90 ]) | def largest_contiguous_subsum(list)
new_arr = []
(0...list.length).each do |idx1| #O(n)
(0...list.length).each do |idx2| #O(n)
if idx2 >= idx1 #O(1)
new_arr << list[idx1..idx2].sum #O(1)
end
end
end
return new_arr.max #O(n)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_min_2(list)\r\n min = 0 # O(1)\r\n \r\n list.each do |ele| # O(n) \r\n if ele < min # O(1)\r\n min = ele # O(1)\r\n end\r\n end\r\n min ... | [
"0.8237659",
"0.8180464",
"0.81215715",
"0.81071955",
"0.8085318",
"0.8051608",
"0.8040617",
"0.8039413",
"0.803129",
"0.8018156",
"0.7984005",
"0.7980396",
"0.7976151",
"0.7956369",
"0.78611493",
"0.7860215",
"0.7848876",
"0.78371584",
"0.7833844",
"0.7820214",
"0.78129673",... | 0.0 | -1 |
=> 8 possible subsums [5] => 5 [5, 3] => 8 > we want this one [5, 3, 7] => 1 [3] => 3 [3, 7] => 4 [7] => 7 | def efficient_contiguous_subsum(list)
current_sum = list[0] #0
largest_sum = list[0] #5
# debugger
(1...list.length).each do |i|
if current_sum + list[i] > 0
current_sum += list[i]
largest_sum = current_sum if current_sum > largest_sum
else
current_sum = 0
end
end
largest_sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sub_sums(list)\n num = []\n list.length.times do |start|\n (start...list.length).each do |length|\n sub_array = list[start..(start + length)]\n num << sub_array.inject(:+)\n end\n end\n num.max\n end",
"def largest_continous_subsum\n largest = 0\n subsets = []\n\n i = 0\n... | [
"0.7468959",
"0.7172587",
"0.69921464",
"0.69749784",
"0.6932818",
"0.6928678",
"0.69280535",
"0.6919228",
"0.6911607",
"0.68701476",
"0.6828545",
"0.6805712",
"0.67969435",
"0.6783915",
"0.6778088",
"0.67545545",
"0.67083067",
"0.67000294",
"0.6678229",
"0.66722536",
"0.6669... | 0.6524383 | 42 |
GET /run_types GET /run_types.json | def index
@run_types = RunType.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @run_types = RunType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @run_types }\n end\n end",
"def show\n @run_type = RunType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { ren... | [
"0.7558277",
"0.67575896",
"0.66501176",
"0.66438615",
"0.6630948",
"0.63753474",
"0.62775445",
"0.6260427",
"0.6234029",
"0.6180226",
"0.61403346",
"0.60907465",
"0.6076732",
"0.6044926",
"0.6044163",
"0.60315347",
"0.59881127",
"0.59881127",
"0.59749556",
"0.59468913",
"0.5... | 0.74328816 | 1 |
GET /run_types/1 GET /run_types/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @run_types = RunType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @run_types }\n end\n end",
"def show\n @run_type = RunType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { ren... | [
"0.749174",
"0.73711944",
"0.72801197",
"0.7057678",
"0.6557763",
"0.6453602",
"0.6453602",
"0.6415689",
"0.6367274",
"0.6346261",
"0.6334664",
"0.6188315",
"0.6188315",
"0.6097806",
"0.60939306",
"0.6082426",
"0.6066972",
"0.6063172",
"0.60373616",
"0.60328287",
"0.6010431",... | 0.0 | -1 |
POST /run_types POST /run_types.json | def create
@run_type = RunType.new(run_type_params)
respond_to do |format|
if @run_type.save
format.html { redirect_to @run_type, notice: 'Run type was successfully created.' }
format.json { render :show, status: :created, location: @run_type }
else
format.html { render :new }
format.json { render json: @run_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @run_type = RunType.new(params[:run_type])\n\n respond_to do |format|\n if @run_type.save\n format.html { redirect_to @run_type, notice: 'Run type was successfully created.' }\n format.json { render json: @run_type, status: :created, location: @run_type }\n else\n ... | [
"0.6818408",
"0.679146",
"0.6748303",
"0.6630122",
"0.6617919",
"0.64316225",
"0.62767184",
"0.6260892",
"0.6205599",
"0.61164045",
"0.6111814",
"0.6111814",
"0.6069159",
"0.6016958",
"0.5966407",
"0.5964771",
"0.5902644",
"0.5824565",
"0.5824565",
"0.5823609",
"0.5823609",
... | 0.6901437 | 0 |
PATCH/PUT /run_types/1 PATCH/PUT /run_types/1.json | def update
respond_to do |format|
if @run_type.update(run_type_params)
format.html { redirect_to @run_type, notice: 'Run type was successfully updated.' }
format.json { render :show, status: :ok, location: @run_type }
else
format.html { render :edit }
format.json { render json: @run_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @run_type = RunType.find(params[:id])\n\n respond_to do |format|\n if @run_type.update_attributes(params[:run_type])\n format.html { redirect_to @run_type, notice: 'Run type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { rend... | [
"0.71815574",
"0.6975401",
"0.632426",
"0.628634",
"0.6165148",
"0.6105321",
"0.6105321",
"0.610498",
"0.61010486",
"0.608783",
"0.60799575",
"0.6071219",
"0.6069354",
"0.6068691",
"0.6068691",
"0.6068691",
"0.6068691",
"0.6068691",
"0.6068691",
"0.6068691",
"0.6068691",
"0... | 0.72308123 | 0 |
DELETE /run_types/1 DELETE /run_types/1.json | def destroy
@run_type.destroy
respond_to do |format|
format.html { redirect_to run_types_url, notice: 'Run type was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @run_type = RunType.find(params[:id])\n @run_type.destroy\n\n respond_to do |format|\n format.html { redirect_to run_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @run_type.remove_action_set_new_default\n\n respond_to do |format|\n if ... | [
"0.75388706",
"0.6970893",
"0.68634564",
"0.67474186",
"0.6655298",
"0.6654021",
"0.6549378",
"0.64984417",
"0.6465846",
"0.6456955",
"0.64284295",
"0.64201725",
"0.640605",
"0.6396923",
"0.6394494",
"0.6391869",
"0.6390206",
"0.6363904",
"0.63532853",
"0.6353162",
"0.6346058... | 0.74347365 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_run_type
@run_type = RunType.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def run_type_params
params.require(:run_type).permit(:type, :active)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Check if params of JSON is correct | def wrong_params?
if has_not_mandatory_params?
render json: { message: "Wrong data params" }, status: 400
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?\n unless @json.class == Hash\n return false\n end\n\n unless @json['method'].class == String\n return false\n end\n\n unless @json['params'].class == Array\n return false\n end\n\n return true\n end",
... | [
"0.77083033",
"0.7410057",
"0.7060128",
"0.6960697",
"0.69467294",
"0.6888149",
"0.6888149",
"0.68609464",
"0.68485796",
"0.6776756",
"0.674491",
"0.6727375",
"0.67187524",
"0.6716137",
"0.6676854",
"0.6668017",
"0.6665036",
"0.66641176",
"0.6650941",
"0.6650941",
"0.6650941"... | 0.7122817 | 2 |
Check if params DEVICE_CODE, DATA is present in JSON send | def has_not_mandatory_params?
!params[:email].present? || !params[:password].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_send_code_data(params)\n params[:game].is_a?(Game) && params[:code_string].is_a?(String) && params[:user].is_a?(User)\n end",
"def check_single_data(data:, message:)\n crit_msg(message) if data\n end",
"def wrong_params?\n if has_not_mandatory_params?\n render json: { message... | [
"0.6515538",
"0.5838034",
"0.5824579",
"0.57573754",
"0.5670267",
"0.5624435",
"0.5582012",
"0.5436488",
"0.54359585",
"0.5422075",
"0.54190546",
"0.5376578",
"0.5367298",
"0.5344924",
"0.5344924",
"0.5338389",
"0.5315112",
"0.53120005",
"0.53021",
"0.52555835",
"0.5252483",
... | 0.0 | -1 |
Make a request to the transaction search endpoint of the API | def transaction_search(transaction_type, location)
result = transaction_request(transaction_type, location)
Responses::Transaction.new(JSON.parse(result.body))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction_request(transaction_type, location)\n result = @client.connection.get (PATH +\n ERB::Util.url_encode(transaction_type) + '/search'), location\n Error.check_for_error(result)\n result\n end",
"def search_request(params)\n result = @client.connect... | [
"0.7584854",
"0.7413088",
"0.71697396",
"0.7103187",
"0.70791155",
"0.6963362",
"0.689927",
"0.686924",
"0.6684079",
"0.6673873",
"0.6670443",
"0.6656846",
"0.66339236",
"0.6610096",
"0.6567763",
"0.64440227",
"0.64122164",
"0.6392311",
"0.63895357",
"0.6381804",
"0.6381804",... | 0.75911456 | 0 |
Make a request to the transaction endpoint of the API The endpoint requires a format of /v3/transaction_search so the primary request parameter is concatenated. After getting the response back it's checked to see if there are any API errors and raises the relevant one if there is. | def transaction_request(transaction_type, location)
result = @client.connection.get (PATH +
ERB::Util.url_encode(transaction_type) + '/search'), location
Error.check_for_error(result)
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction_search(transaction_type, location)\n result = transaction_request(transaction_type, location)\n Responses::Transaction.new(JSON.parse(result.body))\n end",
"def search_with_http_info(space_id, query, opts = {})\n if @api_client.config.debugging\n @api_client.c... | [
"0.70431465",
"0.6969769",
"0.6944244",
"0.6600387",
"0.642537",
"0.64236534",
"0.64223266",
"0.64206314",
"0.64206314",
"0.64198583",
"0.63627535",
"0.6361853",
"0.63490045",
"0.63490045",
"0.6319004",
"0.62986666",
"0.6293366",
"0.6283354",
"0.6263393",
"0.6258303",
"0.6238... | 0.74454635 | 0 |
note: this extremely convoluted code is not how Ruby normally works, but Ruby's standard library's HTTP support is pretty horrible. most people use but we wanted to minimise dependencies here. | def post_request(device_id, epoch_time)
uri = URI.parse(BASE_URL)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = false
request = Net::HTTP::Post.new("/#{device_id}/#{epoch_time}")
response = http.request(request)
response.code == "200"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http; end",
"def net_http_res; end",
"def getHttp(fpUri,fpVerb=\"GET\",fpData=\"\")\n\t#@fpUserAgent = \"CMU/2.2 CFNetwork/672.0.8 Darwin/14.0.0\"\n\t@fpUserAgent = \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0\"\n\n\thttp = Net::HTTP.new(fpUri.host, fpUri.port)\n\n\t... | [
"0.7271585",
"0.70198554",
"0.6948352",
"0.67976016",
"0.6563417",
"0.6530013",
"0.6530013",
"0.65177315",
"0.6487354",
"0.64747363",
"0.64607257",
"0.6456502",
"0.6453718",
"0.64479053",
"0.6424643",
"0.64177495",
"0.6397112",
"0.63725424",
"0.63606185",
"0.63559896",
"0.634... | 0.0 | -1 |
Get the list of target branches | def get_target_branches
unless @target_branches
fetch_all
base = @config['branches']['production']
allowed_branches = @config['branches'].values
allowed_branches << @config['prefixes']['release'] if @config['prefixes']['release']
banned_branches = ['HEAD']
target_branches = `git branch -r origin/#{base} | grep -ie '\\(#{allowed_branches.join("\\|")}\\)' | grep -iv '\\(#{banned_branches.join("\\|")}\\)' | sed -e 's/origin\\///g'`
@target_branches = target_branches.split("\n").map{|a| a.gsub(/\s+/, "")}
end
@target_branches
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_targets\n []\n end",
"def branch_list\n raw_branches = `cd #{project_repo_path} && git branch -r`\n branches = raw_branches.split(/\\n/)\n return branches\n end",
"def ls_branches\n working_branches = get_branches\n if working_branches.empty?\n $stdout.puts \"No branches\"... | [
"0.81760216",
"0.77343994",
"0.7691612",
"0.7672455",
"0.7603706",
"0.7532292",
"0.7505481",
"0.7361787",
"0.7361787",
"0.7281029",
"0.7242032",
"0.71532995",
"0.71283394",
"0.7102128",
"0.70990485",
"0.7092226",
"0.709189",
"0.7063478",
"0.7028348",
"0.70251083",
"0.69988316... | 0.84020025 | 0 |
We only would like to push to a list of branches only | def valid_target? to
get_target_branches.include?(to)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pushToGitRemotes(branch = 'develop', force = 0)\n if force\n force = \"-f\"\n else\n force = \"\"\n end\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pushing #{branch} to remote: #{branch}\\\"\")\n sh(\"git push #{force} #{remote} #{bran... | [
"0.6731136",
"0.6482574",
"0.6482574",
"0.64637566",
"0.6429163",
"0.6423178",
"0.64213234",
"0.64163744",
"0.6391438",
"0.634921",
"0.63319963",
"0.63281703",
"0.63084906",
"0.6307754",
"0.62680304",
"0.6261009",
"0.6246311",
"0.62373775",
"0.6233716",
"0.6227596",
"0.621107... | 0.0 | -1 |
Boolean check on verbosity | def is_verbose?
options.include?("-v")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verbose?() @opts.verbose?; end",
"def verbose?\n options && options[:verbosity] && options[:verbosity] > 0\n end",
"def verbosity\n runopts(:verbosity) || 1\n end",
"def really_verbose\n case verbose\n when true, false, nil then\n false\n else\n ... | [
"0.75735337",
"0.73685026",
"0.73559695",
"0.7303877",
"0.7270917",
"0.7191519",
"0.71663505",
"0.7119162",
"0.71031684",
"0.7069796",
"0.7043617",
"0.7023738",
"0.7001978",
"0.6993639",
"0.69907564",
"0.69907564",
"0.6970506",
"0.696917",
"0.6913088",
"0.6856054",
"0.6810035... | 0.72941124 | 4 |
Rummager does not like really old dates in queries | def date_is_not_ancient?(date)
date > Date.new(1900)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def booking_with_furthest_checkin_date\n ActiveRecord::Base.connection.exec_query(custom_sql).collect &:values\nend",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def statement_to_date\n end",
"def reservation_search_received(limit, offset, first_year_date)\n extra_conditi... | [
"0.58639085",
"0.5593786",
"0.5593786",
"0.5593786",
"0.55794805",
"0.5538604",
"0.5500952",
"0.54879713",
"0.5473649",
"0.5465293",
"0.53997266",
"0.53786105",
"0.5376902",
"0.5359739",
"0.5351738",
"0.53102887",
"0.5259913",
"0.5237988",
"0.5213106",
"0.5201505",
"0.5199737... | 0.0 | -1 |
Write your code here. | def dictionary
dictionary = {
hello: "hi", to: "2", two: "2", too: "2", for: "4", four: "4", be: "b", you: "u", at: "@", and: "&"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def run\n \n end",
"def run\n \n end",
"def method\n\t\t# code code\n\tend",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"... | [
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.7117752",
"0.6527089",
"0.6527089",
"0.6524399",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.64633006",
"0.6418008",
"0.6343... | 0.0 | -1 |
def login=(value) write_attribute :login, (value ? value.downcase : nil) end | def email=(value)
write_attribute :email, (value ? value.downcase : nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login=(value)\n write_attribute :login, (value ? value.downcase : nil)\n end",
"def login=(value)\n write_attribute :login, (value ? value.downcase : nil)\n end",
"def login=(value)\n write_attribute :login, (value ? value.downcase : nil)\n end",
"def username=(value)\n write_attribute :us... | [
"0.9877592",
"0.9877592",
"0.9877592",
"0.7914654",
"0.77511036",
"0.7611718",
"0.7595162",
"0.75663465",
"0.7548009",
"0.75293976",
"0.75293976",
"0.7503506",
"0.7503506",
"0.74950147",
"0.74950147",
"0.74935037",
"0.74935037",
"0.74935037",
"0.74935037",
"0.74935037",
"0.74... | 0.67277485 | 53 |
Waits for the variable called +name+ to be modified. | def variable(name)
Tk.execute_only(:tkwait, :variable, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name\n# Input string\n# Return datatype: string\n# String interpolation and Ruby method sleep\n puts \"name your monster\"\n @name = gets.chomp.upcase\n puts \"The Gods are considering your request please wait 3 seconds\"\n sleep 3\n puts \"Congratulations: The Gods have granted your wish, they... | [
"0.6025988",
"0.5931591",
"0.59147143",
"0.5891724",
"0.57934916",
"0.57591355",
"0.575749",
"0.5754974",
"0.5754974",
"0.57400393",
"0.5721122",
"0.56909597",
"0.5629232",
"0.5629232",
"0.5595312",
"0.55924565",
"0.55825025",
"0.55825025",
"0.5580426",
"0.55797863",
"0.55713... | 0.6696047 | 0 |
Takes the +name+ of a window and waits for a change in its visibility state (as indicated by the arrival of a VisibilityNotify event). Typically used to wait for a newlycreated window to appear on the screen before taking some action. | def visibility(name)
Tk.execute_only(:tkwait, :visibility, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def window(name)\n Tk.execute_only(:tkwait, :window, name)\n end",
"def create_name_window\n @edit_window = Window_NameEdit.new(@actor, 10)\n @input_window = Window_NameInput.new(@edit_window)\n @input_window.set_handler(:ok, method(:on_input_ok))\n @edit_window.hide\n @input_window.hide\n... | [
"0.7509172",
"0.59860957",
"0.5871165",
"0.5866606",
"0.5835126",
"0.57493335",
"0.5722333",
"0.56358814",
"0.5586113",
"0.5583724",
"0.5578906",
"0.5553645",
"0.545271",
"0.5403329",
"0.5400555",
"0.5363628",
"0.5352441",
"0.5351471",
"0.53335834",
"0.5332441",
"0.5328992",
... | 0.73564255 | 1 |
This method takes the name of a window as argument and waits until the window is destroyed. It is typically used to wait for a user to finish interacting with a dialog box before using the result of that interaction. | def window(name)
Tk.execute_only(:tkwait, :window, name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_dialog(dialog_name)\n wait_start\n opera_desktop_action(\"Cancel\")\n wait_for_window_close(dialog_name)\n end",
"def close_dialog(dialog_name)\n wait_start\n opera_desktop_action(\"Cancel\")\n wait_for_window_close(dialog_name)\n end",
"def wait_for_popup window_i... | [
"0.6529077",
"0.6529077",
"0.63900715",
"0.63900715",
"0.6167899",
"0.61269265",
"0.6011314",
"0.59972215",
"0.59348774",
"0.5908893",
"0.5896044",
"0.5846541",
"0.5822378",
"0.5799336",
"0.578633",
"0.57769644",
"0.5776008",
"0.57602465",
"0.5691111",
"0.5643618",
"0.5623003... | 0.7175282 | 0 |
Complete the repeatedString function below. | def repeatedString(s, n)
s.count('a') * (n / s.size) + s[0, n % s.size].count('a')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeat string, number=2\n\trepeated = \"\"\n\tcur_index = 0\n\n\tnumber.times do\n\t\trepeated += string\n\n\t\tif cur_index != number - 1\n\t\t\trepeated += \" \"\n\t\tend\n\n\t\tcur_index += 1\n\tend\n\n\trepeated\nend",
"def repeatedString(s, n)\n length = s.length\n\n repeat_count = n / length\n\n rem... | [
"0.7409544",
"0.73620594",
"0.7344852",
"0.7297813",
"0.72317034",
"0.7213885",
"0.7204186",
"0.71674633",
"0.7156461",
"0.71371734",
"0.7105521",
"0.7101094",
"0.7099628",
"0.7099628",
"0.7096589",
"0.7067445",
"0.70617074",
"0.7046145",
"0.7039972",
"0.7015746",
"0.6985153"... | 0.7067652 | 15 |
2. Nothing will be printed to the screen because the block is never activated with a call method. 3. Exception handling handles any errors within our code and it solves the problem of not ending our program when an error is encounterd. 4. Modify the code from example 2 so that it will execute properly: | def execute(&block)
block.call
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_handler(*args)\r\n puts \"1. Doing this, then yielding to the block\"\r\n yield\r\n # The following will run only if there wasn't an error.\r\n # Otherwise, we move straight to +rescue+\r\n puts \"3b. The block has finished running without an error\"\r\nrescue StandardError => ex\r\n puts ex.messag... | [
"0.6910402",
"0.6618271",
"0.65081877",
"0.6495977",
"0.64518493",
"0.63797575",
"0.636988",
"0.63443613",
"0.62977684",
"0.62615407",
"0.62134993",
"0.61981916",
"0.6192385",
"0.6188206",
"0.6161353",
"0.6140907",
"0.61098814",
"0.6099411",
"0.6065924",
"0.6051868",
"0.60333... | 0.0 | -1 |
set the grue's current_room as far as possible from the player | def spawn(player_room)
# get all possible paths and create a hash indexed by size
paths_to_player = self.rooms.inject({}) do |hsh, room|
path = self.class.grue_path(room, player_room, self.edges)
hsh[path.size] = path
hsh
end
# get the longest of the shortest paths
# (this is as far away as we can get)
longest_path = paths_to_player[paths_to_player.keys.max]
# get the first element of the first edge
self.current_room = longest_path.first.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_current_room\n if cr.defeated\n $map.level_rooms.each do |r|\n if self.bounding_box_collision?(r)\n @cr = r\n end\n end\n $map.hallways.each do |h|\n if self.bounding_box_collision?(h)\n @cr = h\n end\n end\n end\n end",
"def setCur... | [
"0.75193226",
"0.67963445",
"0.64896613",
"0.64135283",
"0.638486",
"0.6344326",
"0.62918764",
"0.629002",
"0.62308913",
"0.6220066",
"0.61551213",
"0.61460614",
"0.61438286",
"0.61435413",
"0.61435413",
"0.61435413",
"0.61435413",
"0.61435413",
"0.61435413",
"0.61435413",
"0... | 0.5576684 | 88 |
grue_room : string player_room : string edges : array of arrays each element has the form [room1, room2, direction] | def grue_path(grue_room, player_room, edges)
shortest_path = []
edges_to_check = edges.select do |arr|
arr.first == grue_room
end
unchecked_edges = edges - edges_to_check
edges_to_check.each do |e|
path = [e]
if e[1] != player_room
next_node = (e - [grue_room]).first
remaining_path = grue_path(next_node, player_room, unchecked_edges)
if remaining_path.empty?
path.clear
else
path += remaining_path
end
else
path
end
if path_distance(path) < path_distance(shortest_path)
shortest_path = path
end
end
shortest_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spawn(player_room)\n # get all possible paths and create a hash indexed by size\n paths_to_player = self.rooms.inject({}) do |hsh, room|\n path = self.class.grue_path(room, player_room, self.edges)\n hsh[path.size] = path\n hsh\n end\n\n # get the longest of the shortes... | [
"0.62335527",
"0.609226",
"0.584873",
"0.5763222",
"0.57085866",
"0.5682897",
"0.55582434",
"0.54677194",
"0.544372",
"0.544372",
"0.53926706",
"0.53339165",
"0.5329858",
"0.52780896",
"0.52700406",
"0.52458787",
"0.52248937",
"0.52089703",
"0.5196735",
"0.51926434",
"0.51824... | 0.7357046 | 0 |
Generate a string representing the contents of a docx file. | def generate
Zip::File.open(@template_path) do |template_zip|
buffer = Zip::OutputStream.write_buffer do |out|
template_zip.each do |entry|
out.put_next_entry entry.name
if @replaceable_files[entry.name]
source = entry.get_input_stream.read.sub(/(<w:body>)(.*?)(<w:sectPr)/, "\\1#{@replaceable_files[entry.name]}\\3")
out.write(source)
else
out.write(template_zip.read(entry.name))
end
end
end
buffer.string
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_docx_contents_as_string(docx, collapse: false)\n Tempfile.create(\"court_report.zip\", \"tmp\") do |file|\n file << docx.force_encoding(\"UTF-8\")\n\n xml_document = Zip::File.open(file.path) do |docx_extracted|\n docx_extracted.find_entry(\"word/document.xml\").get_input_stream.read.fo... | [
"0.7650872",
"0.68179494",
"0.68123615",
"0.6739059",
"0.64994353",
"0.6498318",
"0.627216",
"0.6231102",
"0.61472917",
"0.6146519",
"0.61385334",
"0.6130964",
"0.6102305",
"0.61016965",
"0.6033875",
"0.60258317",
"0.5973944",
"0.5947558",
"0.5947025",
"0.5945146",
"0.5897873... | 0.0 | -1 |
Called when you want to add a gem to the opal load path so it can be required on the client side. | def opal_gem(gem_name)
Opal.use_gem(gem_name)
Opal.paths.uniq!
# require(gem_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_gem_paths; end",
"def add_hardcoded_gem(path)\n # make sure gem dir has a gemspec\n gemspec = File.join path, File.basename(path) + '.gemspec'\n return unless File.exists? gemspec\n # make sure gem dir has a lib dir\n libpath = File.join path, 'lib'\n return unless File.exis... | [
"0.73553574",
"0.71299034",
"0.704712",
"0.6884728",
"0.6685489",
"0.6639203",
"0.65313286",
"0.65016234",
"0.64808214",
"0.63119656",
"0.6248685",
"0.6235593",
"0.6219434",
"0.61811787",
"0.6128633",
"0.6127178",
"0.6085901",
"0.60708785",
"0.60696965",
"0.60397494",
"0.6024... | 0.66216385 | 6 |
Returns script tags that should be included | def javascript_tags(volt_app)
@opal_tag_generator ||= Opal::Server::Index.new(nil, volt_app.opal_files.server)
javascript_files = []
@assets.each do |type, path|
case type
when :folder
# for a folder, we search for all .js files and return a tag for them
javascript_files += Dir["#{path}/**/*.js"].sort.map { |folder| '/assets' + folder[path.size..-1] }
when :javascript_file
# javascript_file is a cdn path to a JS file
javascript_files << path
end
end
javascript_files = javascript_files.uniq
scripts = javascript_files.map {|url| "<script src=\"#{url}\"></script>" }
# Include volt itself. Unless we are running with MAPS=all, just include
# the main file without sourcemaps.
volt_path = 'volt/volt/app'
if ENV['MAPS'] == 'all'
scripts << @opal_tag_generator.javascript_include_tag(volt_path)
else
scripts << "<script src=\"/assets/#{volt_path}.js\"></script>"
scripts << "<script>#{Opal::Processor.load_asset_code(volt_app.sprockets, volt_path)}</script>"
end
scripts << @opal_tag_generator.javascript_include_tag('components/main')
scripts.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scripts\n script_tag(fancyviews.included_scripts.map do |name, js|\n \"\\n/* -- #{name} -- */\\n\" + js\n end.join)\n end",
"def render_js_includes\n return \"\".html_safe unless respond_to?(:javascript_includes) \n \n javascript_includes.uniq.collect do |args|\n javascript... | [
"0.77285165",
"0.6945368",
"0.6812882",
"0.6719892",
"0.6632145",
"0.66007644",
"0.6586229",
"0.65364593",
"0.6530072",
"0.65291584",
"0.6470059",
"0.6440482",
"0.6410502",
"0.63929796",
"0.6372538",
"0.6367777",
"0.6362191",
"0.63539284",
"0.6326827",
"0.6306213",
"0.626241"... | 0.6701303 | 4 |
Returns the link tags for the css | def css_tags
css.map do |url|
"<link href=\"#{url}\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />"
end.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stylesheet_link_tag(*sources)\n html = []\n sources.each do |stylesheet|\n if is_uri?(stylesheet)\n path = stylesheet\n else\n path = url(\"/css/#{stylesheet}.css\")\n end\n html << \"<link href=\\\"#{path}\\\" type=\\\"text/css\\\" rel=\\... | [
"0.6864819",
"0.6677279",
"0.66765517",
"0.66765517",
"0.66089404",
"0.6608529",
"0.65576434",
"0.6450691",
"0.6450691",
"0.64465535",
"0.64293253",
"0.6426241",
"0.6404482",
"0.63617927",
"0.6314443",
"0.6308768",
"0.6300712",
"0.6297919",
"0.62951744",
"0.6294637",
"0.62919... | 0.8004113 | 0 |
Returns an array of all css files that should be included. | def css
css_files = []
@assets.each do |type, path|
case type
when :folder
# Don't import any css/scss files that start with an underscore, so scss partials
# aren't imported by default:
# http://sass-lang.com/guide
css_files += Dir["#{path}/**/[^_]*.{css,scss}"].sort.map do |folder|
'/assets' + folder[path.size..-1].gsub(/[.]scss$/, '')
end
when :css_file
css_files << path
end
end
css_files.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stylesheets\n Dir[Dir.pwd + '/*.css'].map { |path| File.read(path) }\n end",
"def stylesheets\n Dir[Dir.pwd + '/*.css'].map { |path| File.read(path) }\n end",
"def all_stylesheet_paths\n all_paths = []\n all_paths += @stylesheets\n all_paths += @content_scripts.map { |cs| cs.styleshe... | [
"0.7286023",
"0.7286023",
"0.7279719",
"0.7190145",
"0.7125807",
"0.68153167",
"0.68043405",
"0.66962385",
"0.64743495",
"0.6439536",
"0.63381994",
"0.6333574",
"0.63240546",
"0.6251412",
"0.62375724",
"0.6231865",
"0.61180663",
"0.6083035",
"0.60699725",
"0.60644925",
"0.604... | 0.7496662 | 0 |
Returns the root path of the app. Similar to Rails.root but does not depend on Rails being defined. | def root
@root ||= Pathname.new("#{__dir__}/../../../..").cleanpath
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app_root\n if defined?(Rails)\n ::Rails.root\n else\n Dir.pwd\n end\n end",
"def root_path\n defined?(Rails) && Rails.root ||\n defined?(Sinatra::Application) && Pathname.new(Sinatra::Application.root) ||\n defined?(ROOT_DIR) && Pathname.new(ROOT_DIR)\n end",... | [
"0.86103046",
"0.8584908",
"0.8458264",
"0.82643515",
"0.82643515",
"0.8241175",
"0.8216867",
"0.81254",
"0.800226",
"0.7990894",
"0.7980168",
"0.793658",
"0.78503126",
"0.78305733",
"0.78168565",
"0.7776903",
"0.77692354",
"0.77244896",
"0.77091056",
"0.76808685",
"0.7663625... | 0.744482 | 33 |
Returns the path to the tmp directory. | def tmp_dir
@tmp_dir ||= root / 'tmp'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tmp_dir\n return Dir.tmpdir if path_of('tmp_dir').nil?\n return path_of('tmp_dir')\n end",
"def tmp_path\n File.join gem_root, 'tmp'\n end",
"def tmp_dir\n File.expand_path(self.relative_tmp_dir, @options[:root_dir])\n end",
"def get_tmp_dir\n return \"#{Dir.tmpdir}/FilesR... | [
"0.91156316",
"0.87035847",
"0.86786705",
"0.8584702",
"0.85378194",
"0.8458781",
"0.82125074",
"0.81841594",
"0.81374884",
"0.80592227",
"0.80571204",
"0.80511886",
"0.80427134",
"0.8013715",
"0.8009329",
"0.79961544",
"0.79811615",
"0.7972046",
"0.79370505",
"0.78426313",
"... | 0.85568225 | 4 |
Get the config folder path. | def config_root
@config_root ||= root / 'config'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cfg_dir\n File.join(@full_path, CONFIG_DIR)\n end",
"def conf_folder\n conf['conf_folder'] || '.'\n end",
"def get_config_directory()\n\t\t\tconfig_directory= File.join(@base_directory, \"config\")\n\t\t\treturn config_directory\n\t\tend",
"def getConfigPath\n if @conf[:config_name].... | [
"0.8326465",
"0.80605865",
"0.7996527",
"0.79837835",
"0.7954376",
"0.7934802",
"0.7907856",
"0.7813633",
"0.7610684",
"0.76068544",
"0.7586518",
"0.74842626",
"0.7460654",
"0.7445065",
"0.72790986",
"0.72439176",
"0.72393364",
"0.72353363",
"0.7234776",
"0.72232354",
"0.7202... | 0.68506384 | 33 |
Get the current application environment as defined by RAILS_ENV or RACK_ENV. | def env
return Rails.env if defined?(Rails) && defined?(Rails.env)
# https://github.com/rails/rails/blob/1ccc407e9dc95bda4d404c192bbb9ce2b8bb7424/railties/lib/rails.rb#L67
@env ||= ActiveSupport::StringInquirer.new(
ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || 'development'
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_environment\n ENV['RUBY_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'\n end",
"def environment\n if defined?(Rails) && Rails.respond_to?(:env)\n Rails.env.to_s\n else\n ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV'] || 'development'\n end\n end",
"def env\... | [
"0.8449787",
"0.8447072",
"0.8290873",
"0.81389576",
"0.8026043",
"0.79950917",
"0.7994942",
"0.7969055",
"0.7874867",
"0.78728384",
"0.78645766",
"0.7833095",
"0.7754501",
"0.7724591",
"0.7676637",
"0.76710474",
"0.76710474",
"0.7664936",
"0.7664936",
"0.7649764",
"0.7633289... | 0.8118427 | 4 |
Get the path to the default config files that will be loaded by the app | def config_files(config_root = self.config_root, env = self.env)
[
config_root / 'settings.yml',
config_root / 'settings' / 'default.yml',
config_root / 'settings' / "#{env}.yml",
*@custom_configs
].map(&:to_s).freeze
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_path\n Pathname.pwd.join(*base_config_path, self.class.config_folder)\n end",
"def app_config_path\n Pathname.new('.').join('config')\n end",
"def default_application_paths\n paths = []\n\n # Followed by the standard includes.\n paths.concat %w(\n config\... | [
"0.80343175",
"0.77136433",
"0.7629951",
"0.75546503",
"0.7554519",
"0.7472683",
"0.7356335",
"0.72973317",
"0.7244747",
"0.7216675",
"0.7198952",
"0.7179988",
"0.7170117",
"0.71229273",
"0.71229273",
"0.70983595",
"0.70267105",
"0.7008329",
"0.6996136",
"0.69776815",
"0.6966... | 0.7138303 | 13 |
are we in the development environment? | def development?
env == 'development'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dev_env?\n env == 'development'\n end",
"def development?\n self.environment == ENV_DEV\n end",
"def dev?\n Rails.env == 'development'\n end",
"def development?\n environment == 'development'\n end",
"def development? ; @app.options[:env] == :development ; end",
"def developme... | [
"0.8386098",
"0.8336098",
"0.8248356",
"0.82409084",
"0.8180134",
"0.81496793",
"0.80109537",
"0.7994709",
"0.78839225",
"0.78470504",
"0.7831569",
"0.7772603",
"0.7676056",
"0.76184464",
"0.75766873",
"0.7560572",
"0.75370014",
"0.75306714",
"0.74144775",
"0.73504907",
"0.73... | 0.83794415 | 1 |
are we in the test environment? | def test?
rspec? || env == 'test'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_env?\n @test_environment\n end",
"def test?\n self.environment == ENV_TEST\n end",
"def test?\n settings.environment == 'test'\n end",
"def test?\n @@mode == :test\n end",
"def test_env\n if ENVIRONMENT.is_a?(String) && ENVIRONMENT == \"test\"\n true\n else\n ... | [
"0.8128343",
"0.80245185",
"0.79179513",
"0.7496802",
"0.74355936",
"0.74281174",
"0.73509985",
"0.734666",
"0.7342551",
"0.72612697",
"0.72370946",
"0.72165114",
"0.71773195",
"0.71473",
"0.71248317",
"0.70725167",
"0.7047358",
"0.7045271",
"0.7002887",
"0.6983234",
"0.69466... | 0.7219837 | 11 |
Returns true if environment is development? or test? | def dev_or_test?
development? || test?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def development?\n env == 'development'\n end",
"def dev_env?\n env == 'development'\n end",
"def development?\n self.environment == ENV_DEV\n end",
"def development?\n environment == 'development'\n end",
"def development?\n environment == :development\nend",
"def test?\n s... | [
"0.86751854",
"0.86735874",
"0.86732763",
"0.8673128",
"0.84796625",
"0.8343251",
"0.8250853",
"0.8207119",
"0.8196234",
"0.8175681",
"0.8170555",
"0.8160151",
"0.8153777",
"0.8112107",
"0.80798095",
"0.8047786",
"0.804529",
"0.80203384",
"0.79971206",
"0.7926902",
"0.7921483... | 0.90946126 | 0 |
add custom configs before other things start | def setup(configs = nil)
return if @setup
@setup = true
@custom_configs = configs || []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_config\n # To be Extended\n end",
"def post_configure\n # noop\n end",
"def configure\n load_all_configs \n end",
"def configure; end",
"def before_configuration(&block); end",
"def preconfigure(&block)\n @preconfigure ||= block\n end",
"def startup_hook... | [
"0.7228922",
"0.67720205",
"0.67710435",
"0.67485243",
"0.6706806",
"0.6627635",
"0.6590881",
"0.65618175",
"0.6489989",
"0.6478255",
"0.6409258",
"0.63975376",
"0.63944656",
"0.63705426",
"0.63701934",
"0.6366857",
"0.6334453",
"0.628768",
"0.62800384",
"0.62677824",
"0.6261... | 0.7018678 | 1 |
indicates if the rfsb has been sent to the shipping machine, and then been recieved from the shipping machine back to the webserver. We know this if both sf and acf integrity_hashes are set on the object | def cycle_complete?
!self.sf_integrity_hash.nil? and !self.acf_integrity_hash.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_gen_a_new_rfsb?(sale)\n return true if sale.ready_for_shipment_batch_id.nil?\n false\n end",
"def refunded?\n !@refund_id.nil?\n end",
"def received?\r\n self['trans_status']=='99'\r\n end",
"def is_delivery_receipt_requested\n return @is_delivery_re... | [
"0.59853685",
"0.5933234",
"0.58303905",
"0.5734012",
"0.57134426",
"0.5640094",
"0.56085914",
"0.5581897",
"0.5573078",
"0.55507386",
"0.5548839",
"0.5520923",
"0.55179834",
"0.5509138",
"0.54957247",
"0.5487326",
"0.5446273",
"0.5442873",
"0.5432538",
"0.5427214",
"0.542566... | 0.56532896 | 5 |
( + 2) 3 | def get_fuel_for_mass(mass)
fuel_needed = (mass / 3) - 2
fuel_needed = fuel_needed + get_fuel_for_mass(fuel_needed) if fuel_needed >= MINIMUM_MASS_FOR_FUEL
fuel_needed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate\n (2 + 2) * 2\nend",
"def arthamatic_operation(number)\n\tnumber + 3\nend",
"def plus_three(num)\n num + 3\nend",
"def add_three(number)\n return number + 3\n number + 4\nend",
"def add_three(number)\n return number + 3\n number + 4\nend",
"def add_three(number)\n return number + 3... | [
"0.7626227",
"0.74221385",
"0.7077151",
"0.69432366",
"0.69432366",
"0.69432366",
"0.69432366",
"0.6815046",
"0.67873836",
"0.6780155",
"0.677549",
"0.6746993",
"0.6726859",
"0.6726859",
"0.6726859",
"0.6726859",
"0.67255557",
"0.669436",
"0.66880566",
"0.66735154",
"0.665405... | 0.0 | -1 |
Any action against the Functor is processesd by the function. | def method_missing(op, *args, &blk)
@function.call(op, *args, &blk)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fmap(*)\n raise NotImplementedError\n end",
"def functor_t\n raise NotImplementedError\n end",
"def process(action, *args); end",
"def apply( data, type, &block )\n @applyhash = self.applyhash\n if not @applyhash.key? type\n Kernel::raise(\"FloatFunctor::apply no regsit... | [
"0.57064384",
"0.567832",
"0.5631018",
"0.5564093",
"0.5480766",
"0.5422048",
"0.53626895",
"0.53556687",
"0.53132975",
"0.53109384",
"0.53052485",
"0.53052485",
"0.53052485",
"0.5275732",
"0.5275103",
"0.514948",
"0.51464474",
"0.51301265",
"0.51165277",
"0.510714",
"0.51071... | 0.0 | -1 |
Initializes a new Session object | def initialize(attributes = {})
@access_token = attributes['access_token']
@refresh_token = attributes['refresh_token']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(session); end",
"def init_session\n if session\n if session.updated_at < Time.now - ::Gricer.config.max_session_duration\n self.session = Session.create previous_session: session, ip_address: @ip_address, agent: agent, requested_locale: @request_locale\n ... | [
"0.82180506",
"0.79475015",
"0.78998554",
"0.78190297",
"0.78190297",
"0.78190297",
"0.77705884",
"0.7679515",
"0.7535753",
"0.7535098",
"0.7491678",
"0.74459237",
"0.74120414",
"0.7377829",
"0.73428303",
"0.7336974",
"0.73125815",
"0.7310738",
"0.7310738",
"0.7308767",
"0.72... | 0.0 | -1 |
Obtain hash with access_token and refresh_token | def hash
return {} unless access_token && refresh_token
return {
'access_token' => access_token,
'refresh_token' => refresh_token
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [grant_type, code, refresh_token, redirect_uri, client_id, client_secret].hash\n end",
"def build_token_hash\n { 'access_token' => access_token }\n end",
"def fetch_token_from_hash(refresh_token)\n @access_token_obj = OAuth2::AccessToken.from_hash(@auth_client,\n ... | [
"0.77518904",
"0.7053428",
"0.6891941",
"0.6822592",
"0.66937613",
"0.6689462",
"0.6669668",
"0.666153",
"0.66542876",
"0.6616804",
"0.6567058",
"0.65151054",
"0.6498517",
"0.6467488",
"0.64602053",
"0.6447396",
"0.6437423",
"0.64197814",
"0.638882",
"0.6365381",
"0.63502955"... | 0.747697 | 1 |
Create a new Unix Password Cracker. | def initialize(args = {})
@file = args[:file] if args[:file]
@dictionary = args[:dictionary] if args[:dictionary]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createNagiosPasswd\n `touch /usr/local/nagios/etc/htpasswd.users`\n `echo nagiosadmin:uPODiTjNs5eaY >> /usr/local/nagios/etc/htpasswd.users` \n end",
"def create(username, password)\n SecKeychainAddGenericPassword(nil, @service.length, @service, username.length, username, password.length, pas... | [
"0.66190594",
"0.6164644",
"0.6129946",
"0.6126131",
"0.6086274",
"0.59366596",
"0.58915704",
"0.57576907",
"0.5739757",
"0.5707239",
"0.56688786",
"0.56563675",
"0.5602771",
"0.5543264",
"0.55344844",
"0.5452343",
"0.544418",
"0.5443664",
"0.5443664",
"0.54362905",
"0.542917... | 0.0 | -1 |
Check if a given encrypted password matches a given plaintext word when the same crytographic operation is performed on it. | def check_password(encrypted_password, plaintext_password, strip = true)
plaintext_password.strip! if strip # sometimes passwords have trailing spaces
if plaintext_password.crypt(encrypted_password[0, 2]) == encrypted_password
true
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_pw pw\n (encrypt pw) == (self[:password])\n end",
"def matching_password?(pass)\n self.password_hash == encrypt_password(pass)\n end",
"def password_match?(login_password)\n\t\tencrypted_password == encrypt(login_password)\t\n\tend",
"def matches?(crypted, *tokens)\n encrypt(*tok... | [
"0.7631796",
"0.7580656",
"0.7446075",
"0.72147113",
"0.7204275",
"0.72013867",
"0.71478826",
"0.7133652",
"0.70869166",
"0.7079702",
"0.7067759",
"0.7041514",
"0.70401305",
"0.70184577",
"0.7016748",
"0.7013209",
"0.70012885",
"0.6973615",
"0.69602156",
"0.6937418",
"0.69373... | 0.7100315 | 8 |
GET /joineds GET /joineds.json | def index
@joineds = Joined.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n channel = Channel.find(params[:id])\n users = ChannelJoined.where(channel_id: params[:id])\n return json_response({\n users: users.map{|j| j.user}\n })\n end",
"def user_joined\n user = User.find_by!(id: params[:user_id])\n return json_response(... | [
"0.61768925",
"0.61329937",
"0.59698355",
"0.59334886",
"0.5906871",
"0.5827686",
"0.581064",
"0.5772694",
"0.57302773",
"0.57184124",
"0.5696679",
"0.569448",
"0.56850386",
"0.5662305",
"0.5612134",
"0.5599845",
"0.5598919",
"0.5598491",
"0.55726105",
"0.5572074",
"0.5567531... | 0.7064796 | 0 |
GET /joineds/1 GET /joineds/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @joineds = Joined.all\n end",
"def user_joined\n user = User.find_by!(id: params[:user_id])\n return json_response({\n \"joined\": ChannelJoined.exists?({\n channel_id: params[:id],\n user_id: params[:user_id]\n })\n })\n ... | [
"0.67032146",
"0.6174915",
"0.6073189",
"0.59284824",
"0.5924489",
"0.58915406",
"0.5827733",
"0.5800685",
"0.57807183",
"0.57568157",
"0.5742195",
"0.5738427",
"0.572748",
"0.57067174",
"0.5691861",
"0.55379844",
"0.5535582",
"0.5505199",
"0.5478197",
"0.5476489",
"0.5422311... | 0.0 | -1 |
POST /joineds POST /joineds.json | def create
@joined = Joined.new(joined_params)
respond_to do |format|
if @joined.save
format.html { redirect_to @joined, notice: 'Joined was successfully created.' }
format.json { render :show, status: :created, location: @joined }
else
format.html { render :new }
format.json { render json: @joined.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @joined_user = JoinedUser.new(joined_user_params)\n\n respond_to do |format|\n if @joined_user.save\n format.html { redirect_to @joined_user, notice: 'Joined user was successfully created.' }\n format.json { render :show, status: :created, location: @joined_user }\n else\... | [
"0.6444366",
"0.61074233",
"0.6028494",
"0.5714968",
"0.5658462",
"0.55792785",
"0.55047023",
"0.5489245",
"0.5450283",
"0.54474396",
"0.53643554",
"0.5343089",
"0.53148615",
"0.5305037",
"0.5304981",
"0.53048575",
"0.530181",
"0.52460873",
"0.52226734",
"0.52113134",
"0.5203... | 0.71221226 | 0 |
PATCH/PUT /joineds/1 PATCH/PUT /joineds/1.json | def update
respond_to do |format|
if @joined.update(joined_params)
format.html { redirect_to @joined, notice: 'Joined was successfully updated.' }
format.json { render :show, status: :ok, location: @joined }
else
format.html { render :edit }
format.json { render json: @joined.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_many\n if @users.update_all(user_params)\n render json: @users, status: :ok, location: users_url\n else\n render json: @users.errors, status: :unprocessable_entity\n end\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"... | [
"0.5877153",
"0.5859266",
"0.5837319",
"0.58131534",
"0.5788771",
"0.577431",
"0.57514715",
"0.5746399",
"0.5690212",
"0.5656355",
"0.56281143",
"0.5618896",
"0.56096923",
"0.5593497",
"0.557431",
"0.5567187",
"0.5562077",
"0.5548357",
"0.5514905",
"0.5498466",
"0.5492607",
... | 0.64423686 | 0 |
DELETE /joineds/1 DELETE /joineds/1.json | def destroy
@joined.destroy
respond_to do |format|
format.html { redirect_to joineds_url, notice: 'Joined was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @orphan.destroy\n respond_to do |format|\n format.html { redirect_to orphans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n relationship = Relationships.find(params[:id])\n relationship.destro... | [
"0.65177274",
"0.642456",
"0.636255",
"0.634181",
"0.63154453",
"0.6282337",
"0.627812",
"0.622095",
"0.6188782",
"0.61783826",
"0.6159404",
"0.6153933",
"0.61359674",
"0.6122363",
"0.6118371",
"0.61158764",
"0.6099251",
"0.60958564",
"0.6086497",
"0.6072789",
"0.60579747",
... | 0.7089706 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_joined
@joined = Joined.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def joined_params
params.require(:joined).permit(:order_id, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Sets up group relations and scopes in this model. No extra columns are required in the model table. | def has_groups(options={})
return if has_groups?
class_eval {
include GroupedModel::GroupedInstanceMethods
def self.has_groups?
true
end
def self.visible
ungrouped
end
}
has_many :permissions, :as => :permitted
accepts_nested_attributes_for :permissions
has_many :groups, :through => :permissions
Group.define_retrieval_methods(self.to_s)
named_scope :visible_to, lambda { |reader|
conditions = "pp.group_id IS NULL"
if reader && reader.is_grouped?
ids = reader.group_ids
conditions = ["#{conditions} OR pp.group_id IS NULL OR pp.group_id IN(#{ids.map{"?"}.join(',')})", *ids]
end
{
:joins => "LEFT OUTER JOIN permissions as pp on pp.permitted_id = #{self.table_name}.id AND pp.permitted_type = '#{self.to_s}'",
:group => column_names.map { |n| self.table_name + '.' + n }.join(','),
:conditions => conditions,
:readonly => false
}
}
named_scope :ungrouped, lambda {
{
:select => "#{self.table_name}.*, count(pp.id) as group_count",
:joins => "LEFT OUTER JOIN permissions as pp on pp.permitted_id = #{self.table_name}.id AND pp.permitted_type = '#{self.to_s}'",
:having => "group_count = 0",
:group => column_names.map { |n| self.table_name + '.' + n }.join(','), # postgres requires that we group by all selected (but not aggregated) columns
:readonly => false
}
} do
def count
length
end
end
named_scope :grouped, lambda {
{
:select => "#{self.table_name}.*, count(pp.id) as group_count",
:joins => "LEFT OUTER JOIN permissions as pp on pp.permitted_id = #{self.table_name}.id AND pp.permitted_type = '#{self.to_s}'",
:having => "group_count > 0",
:group => column_names.map { |n| self.table_name + '.' + n }.join(','),
:readonly => false
}
} do
def count
length
end
end
named_scope :belonging_to, lambda { |group|
{
:joins => "INNER JOIN permissions as pp on pp.permitted_id = #{self.table_name}.id AND pp.permitted_type = '#{self.to_s}'",
:group => column_names.map { |n| self.table_name + '.' + n }.join(','),
:conditions => ["pp.group_id = ?", group.id],
:readonly => false
}
}
named_scope :find_these, lambda { |ids|
ids = ['NULL'] unless ids && ids.any?
{ :conditions => ["#{self.table_name}.id IN (#{ids.map{"?"}.join(',')})", *ids] }
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups\n @groups = init_groups\n end",
"def initialize\n @columns = { }\n @primary_keys = []\n @to_avoid = []\n @default_values = { }\n @associations = \n {\n :belongs_to => { },\n :has_one => { },\n :has_n => { }\n }\n end",
... | [
"0.5691511",
"0.5637929",
"0.5628972",
"0.5460209",
"0.53210014",
"0.5306479",
"0.5296476",
"0.525185",
"0.52229434",
"0.51015556",
"0.5040195",
"0.50096405",
"0.49925354",
"0.4973446",
"0.49727598",
"0.4951639",
"0.49358112",
"0.49352038",
"0.49243206",
"0.48993593",
"0.4898... | 0.53705025 | 4 |
I worked on this challenge [by myself, with: ]. 1. Initial Solution | def pad!(array, min_size, value = nil) #destructive
# Your code here
if min_size > array.length
array << value
return array
else
return array
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution4(input)\n end",
"def problem_57\n ret,n,d = 0,1,1\n 1000.times do |i|\n n,d = (n+2*d),(n+d)\n ret += 1 if n.to_s.length > d.to_s.length\n end\n ret\nend",
"def isLucky(n)\r\nhalf1 = []\r\nhalf2 = []\r\nn_string = n.to_s\r\n\r\n\r\nfirsthalf = (n_string.length / 2) - 1\r\nsecondhalfstart... | [
"0.6214657",
"0.60906076",
"0.60019654",
"0.59951097",
"0.59756225",
"0.59489906",
"0.5918387",
"0.5905622",
"0.5898738",
"0.5892188",
"0.58871514",
"0.5863911",
"0.5858467",
"0.5841975",
"0.58291435",
"0.5826497",
"0.5801665",
"0.5792341",
"0.578724",
"0.57863325",
"0.577850... | 0.0 | -1 |
GET /sales_forecasts GET /sales_forecasts.json | def index
per_page = 50
@service_centers = ServiceCenter.all
@show_all = params[:show_all]
@sc = params[:sc]
@status = params[:status]
@segment = params[:segment]
@sales_forecasts = select_sales_forecasts_with_sorting
@paginated_sales_forecasts = paginate(@sales_forecasts, per_page)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @forecast_72s = Forecast72.all\n end",
"def forecast(forecast_path)\r\n response = Curl.get(forecast_path) do |curl|\r\n curl.headers['Accept'] = 'application/json'\r\n end\r\n JSON.parse(response.body_str)\r\n end",
"def forecast(query)\n get_json(... | [
"0.73036915",
"0.70815754",
"0.6934468",
"0.6887057",
"0.68293744",
"0.6797613",
"0.6792443",
"0.67614305",
"0.67052513",
"0.65584093",
"0.65034044",
"0.6501869",
"0.6458968",
"0.6439238",
"0.6426273",
"0.64123774",
"0.63653815",
"0.63632905",
"0.62917185",
"0.6263929",
"0.62... | 0.6081482 | 34 |
GET /sales_forecasts/1 GET /sales_forecasts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @forecast_72s = Forecast72.all\n end",
"def show\n @forecast = Forecast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forecast }\n end\n end",
"def forecast(forecast_path)\r\n response = Curl.get(forecast_path... | [
"0.72837394",
"0.7225123",
"0.7150389",
"0.69626546",
"0.69625044",
"0.68532974",
"0.68259215",
"0.68130034",
"0.66121113",
"0.6598987",
"0.65316457",
"0.65174276",
"0.6485646",
"0.6440357",
"0.6437726",
"0.64332515",
"0.64253724",
"0.6419338",
"0.6409399",
"0.6409399",
"0.64... | 0.0 | -1 |
POST /sales_forecasts POST /sales_forecasts.json | def create
@sales_forecast = SalesForecast.new(sales_forecast_params)
respond_to do |format|
if @sales_forecast.save
format.html { redirect_to @sales_forecast, notice: 'Sales forecast was successfully created.' }
format.json { render :show, status: :created, location: @sales_forecast }
else
format.html { render :new }
format.json { render json: @sales_forecast.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @forecast = Forecast.new(params[:forecast])\n\n respond_to do |format|\n if @forecast.save\n format.html { redirect_to @forecast, notice: 'Forecast was successfully created.' }\n format.json { render json: @forecast, status: :created, location: @forecast }\n else\n ... | [
"0.69442296",
"0.68253803",
"0.6629742",
"0.6359097",
"0.61735255",
"0.6083963",
"0.60762334",
"0.6058022",
"0.5992738",
"0.5916345",
"0.5916345",
"0.59101844",
"0.5834936",
"0.5818286",
"0.5809778",
"0.5800901",
"0.5776947",
"0.57012445",
"0.56845057",
"0.5681311",
"0.567284... | 0.7500896 | 0 |
PATCH/PUT /sales_forecasts/1 PATCH/PUT /sales_forecasts/1.json | def update
respond_to do |format|
if @sales_forecast.update(sales_forecast_params)
format.html { redirect_to @sales_forecast, notice: 'Sales forecast was successfully updated.' }
format.json { render :show, status: :ok, location: @sales_forecast }
else
format.html { render :edit }
format.json { render json: @sales_forecast.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @forecast = Forecast.find(params[:id])\n\n respond_to do |format|\n if @forecast.update_attributes(params[:forecast])\n format.html { redirect_to @forecast, notice: 'Forecast was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render acti... | [
"0.6864185",
"0.68214816",
"0.66747314",
"0.646551",
"0.6364731",
"0.6133831",
"0.6068756",
"0.6066065",
"0.59763414",
"0.59639233",
"0.590987",
"0.590987",
"0.58810806",
"0.58525234",
"0.5852201",
"0.583067",
"0.5807908",
"0.57937044",
"0.5747408",
"0.5747408",
"0.57401156",... | 0.73310417 | 0 |
DELETE /sales_forecasts/1 DELETE /sales_forecasts/1.json | def destroy
@sales_forecast.destroy
respond_to do |format|
format.html { redirect_to sales_forecasts_url, notice: 'Sales forecast was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @forecast = Forecast.find(params[:id])\n @forecast.destroy\n\n respond_to do |format|\n format.html { redirect_to forecasts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @forecast_72.destroy\n respond_to do |format|\n format.html { redirect_to forec... | [
"0.7497344",
"0.73701215",
"0.7358787",
"0.6998041",
"0.6994285",
"0.6930154",
"0.669101",
"0.6631623",
"0.66190374",
"0.66118467",
"0.6590123",
"0.65862006",
"0.65787464",
"0.657814",
"0.6571346",
"0.6561142",
"0.6542617",
"0.6515782",
"0.65096706",
"0.65055996",
"0.6499015"... | 0.7614303 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.