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 |
|---|---|---|---|---|---|---|
add a comment in the final conf | def add_comment comment
"\n###### #{comment} ######\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_comment(comment)\n \"\\n+++++++++++++++++++++++++++++++++++++++++ #{comment} ++++++++++++++++++++++++++++++++++++++++++++++\\n\"\n end",
"def add_comment(comment); end",
"def comment(comment = nil)\n set_option(:comment, comment)\n end",
"def add_comment(comment)\n @comment += commen... | [
"0.70812535",
"0.6986145",
"0.69501334",
"0.6820148",
"0.6820134",
"0.67648804",
"0.67058355",
"0.6676917",
"0.6637153",
"0.6581897",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",
"0.6569327",... | 0.73425174 | 0 |
Get birthdays within `from_year` and `to_year` | def birthdays(from_year:, to_year:)
rows = []
config_hash.characters.each do |chara|
(from_year..to_year).each do |year|
date = Date.parse("#{year}/#{chara.birthday}")
rows << CalendarRow.new(date: date, chara: chara)
rescue ArgumentError => e
# NOTE: うるう年以外で2/29をparseしようとする... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dates_of_birth\n raise(ArgumentError, \"Need category to calculate dates of birth\") unless category\n\n Date.new(date.year - category.ages.end, 1, 1)..Date.new(date.year - category.ages.begin, 12, 31)\n end",
"def dates_of_birth\n raise(ArgumentError, 'Need category to calculate dates of birth') u... | [
"0.70308924",
"0.70156837",
"0.69484365",
"0.67663723",
"0.66908175",
"0.66463363",
"0.6646331",
"0.65502983",
"0.6544361",
"0.6491688",
"0.6234534",
"0.60682946",
"0.60669696",
"0.6052091",
"0.6034089",
"0.60161823",
"0.59962225",
"0.5995604",
"0.5983265",
"0.59674954",
"0.5... | 0.74616283 | 0 |
def initialize(environment); super end | def build
configuration = environment[:configuration]
sdk = environment[:sdk]
build_dir = File.join environment[:build_dir], "#{configuration}-#{sdk}"
puts "Building #{environment[:full_name]} configuration:#{configuration}"
arch = sdk == "iphonesimulator" ? " -arch i386" : ""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_environment\n end",
"def initialize_environment\n end",
"def initialize env\n @env = env\n super()\n end",
"def initialize env\n @env = env\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()... | [
"0.8649255",
"0.8649255",
"0.84974676",
"0.84974676",
"0.78229564",
"0.78229564",
"0.78229564",
"0.78229564",
"0.78229564",
"0.78229564",
"0.78229564",
"0.768986",
"0.768986",
"0.768986",
"0.76883876",
"0.76883876",
"0.76883876",
"0.76883876",
"0.76883876",
"0.76883876",
"0.7... | 0.0 | -1 |
SNIP=featured_products DO NOT REMOVE THE ABOVE COMMENT. It is used to remove the above feature Displays a list of Features for editing. Template: admin/features/list.rhtml | def list
@current_area = 'features'
@current_menu = 'products'
sort_order ||= get_sort_order("s-code", "products.product_code")
sort_order ||= get_sort_order("s-name", "products.product_name")
# heh - doesn't work well when products are featured in multiple categories/static pages
# sort_order ||= get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def features_field\n product_descriptions.where(content_name: \"features\").first_or_initialize\n end",
"def edit\r\n\t\t@current_area = 'features'\r\n\t\t@current_menu = 'products'\r\n\r\n\t\tif params[:id]\r\n\t\t\tbegin\r\n\t\t\t\t@feature = Feature.find(params[:id], :include => [ :product ])\r\n\t\t\tres... | [
"0.63820654",
"0.61074525",
"0.6083806",
"0.5996376",
"0.5996376",
"0.5996376",
"0.58092225",
"0.579473",
"0.57811475",
"0.5777084",
"0.5752902",
"0.56704324",
"0.5649426",
"0.5618833",
"0.55375856",
"0.55375856",
"0.55312866",
"0.5527378",
"0.55173004",
"0.5484574",
"0.54391... | 0.6061674 | 3 |
Allows a new feature to be created Template: admin/features/new.rhtml | def new
@current_area = 'features'
@current_menu = 'products'
@feature_categories = Array.new
@feature_static_pages = Array.new
if params[:save]
params[:feature][:until] = ffs_parse_date(params[:feature][:until])
@feature = Feature.new(params[:feature])
if @feature.save
if params[:cate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @feature = Feature.new(params[:feature])\n\n respond_to do |format|\n if @feature.save\n format.html { redirect_to admin_features_path, notice: 'Feature was successfully created.' }\n format.json { render json: @feature, status: :created, location: @feature }\n else\n ... | [
"0.7333201",
"0.72081953",
"0.70486647",
"0.70166314",
"0.70160174",
"0.6558835",
"0.6558835",
"0.649084",
"0.64324254",
"0.64271414",
"0.6426938",
"0.6402174",
"0.6392468",
"0.63842565",
"0.63828063",
"0.63689125",
"0.63524127",
"0.6340282",
"0.6330231",
"0.63254577",
"0.631... | 0.65076745 | 7 |
Displays a Feature for editing. Also handles updating the Feature. Template: admin/features/edit.rhtml | def edit
@current_area = 'features'
@current_menu = 'products'
if params[:id]
begin
@feature = Feature.find(params[:id], :include => [ :product ])
rescue ActiveRecord::RecordNotFound
redirect_to(:action => list) and return false
end
if params[:save]
params[:feature][:until] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @feature = Feature.find(params[:id])\n\n respond_to do |format|\n if @feature.update_attributes(params[:feature])\n format.html { redirect_to admin_features_path, notice: 'Feature was successfully updated.' }\n format.json { head :no_content }\n else\n format.html ... | [
"0.75166374",
"0.71844214",
"0.71730614",
"0.7031767",
"0.6972122",
"0.69048953",
"0.6761792",
"0.67617446",
"0.674746",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"0.67414325",
"... | 0.67566156 | 8 |
baseurl = ' page = mechanize.get(baseurl) | def isArticle?(url)
# possible parameters:
# page contains a date
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crawlPage pageURL\n agent = Mechanize.new\n page = agent.get pageURL\n return page\nend",
"def mechanize; end",
"def load_page\n @page ||= @mechanize.get(url)\n end",
"def load_page\n @mechanize_instance.get(@url)\n end",
"def crawler_page\n open(crawler_url)\n end",
"def initialize(ur... | [
"0.7314171",
"0.70829076",
"0.68739355",
"0.6858708",
"0.6805618",
"0.6641158",
"0.66359466",
"0.66359466",
"0.66068006",
"0.65601695",
"0.6433597",
"0.6408721",
"0.63877803",
"0.63317525",
"0.6299594",
"0.6277796",
"0.62484103",
"0.6238353",
"0.62013596",
"0.61985457",
"0.61... | 0.0 | -1 |
That is, each substring must consist of the same sequence of characters forwards as it does backwards. The return value should be arranged in the same sequence as the substrings appear in the string. Duplicate palindromes should be included multiple times. You may (and should) use the substrings method you wrote in the... | def substrings_at_start(str)
index = 0
length = 1
arry = []
while length <= str.size
arry << str[index, length]
length += 1
end
arry
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def palindrome_substrings(string)\n\nend",
"def palindrome_substrings(str)\r\n result = []\r\n substrings_arr = substrings(str)\r\n substrings_arr.each do |substring|\r\n result << substring if is_palindrome?(substring)\r\n end\r\n result\r\nend",
"def palindrome_substrings(str)\n result = []\n subst... | [
"0.8673504",
"0.8502994",
"0.84503126",
"0.8445603",
"0.84140354",
"0.8370329",
"0.8301203",
"0.8295006",
"0.82491946",
"0.81418085",
"0.81154245",
"0.80517626",
"0.79718804",
"0.7966499",
"0.7950344",
"0.79397637",
"0.7888543",
"0.7861423",
"0.78516364",
"0.78212094",
"0.779... | 0.0 | -1 |
Finds a resource if it exists in the collection. | def lookup_resource(type, name, run_context)
begin
run_context.resource_collection.find("#{ type }[#{ name }]")
rescue ArgumentError => e
puts "You provided invalid arugments to resource_collection.find: #{ e }"
rescue RuntimeError => e
puts "The resources you searched for were... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists?(id, options = {})\r\n id && !find_single(id, options).nil?\r\n rescue ActiveResource::ResourceNotFound\r\n false\r\n end",
"def exists?(id, options = {})\n id && !find_single(id, options).nil?\n rescue ActiveResource::ResourceNotFound\n false\n end",
... | [
"0.7309345",
"0.7209196",
"0.6965031",
"0.67626476",
"0.6755875",
"0.67396927",
"0.67196536",
"0.67022014",
"0.66608685",
"0.6651408",
"0.66250885",
"0.6618103",
"0.66017723",
"0.65745354",
"0.6536711",
"0.6516162",
"0.65107733",
"0.6466972",
"0.6455015",
"0.6432868",
"0.6432... | 0.6318022 | 27 |
Entry point for initiating an exploit. This module wrappers the exploit method and determines whether or not the selected target supports brute force. If it does, it does some special things and wraps the brute forcing logic. | def exploit
# Is the selected target a brute force target?
if (target.bruteforce?)
# The step direction is automatically calculated
direction = {}
bf = target.bruteforce
# Get the start and stop address hashes
start = bf.start_addresses ? bf.start_addresses.dup : {}
stop =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exploit\r\n # Find a valid CGI target\r\n target_uri = find_target_cgi\r\n return unless target_uri\r\n\r\n # Create wrappers for each potential architecture\r\n cycle_possible_payloads do |wrapped_payload|\r\n\r\n # Trigger the vulnerability and run the payload\r\n trigger_payload(tar... | [
"0.6635119",
"0.60340077",
"0.6024154",
"0.5917341",
"0.57573676",
"0.56081825",
"0.56049156",
"0.5540623",
"0.55313736",
"0.5530628",
"0.5488216",
"0.5444746",
"0.53957474",
"0.52903825",
"0.5269177",
"0.52278113",
"0.5195604",
"0.51766914",
"0.51766914",
"0.51550823",
"0.50... | 0.750577 | 0 |
This routine is called once per brute force iteration. The addresses parameter is a hash of addresses that are incremented each iteration and are derived from the target's bruteforce information or the module's datastore in case they are being overriden. | def brute_exploit(addrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run!\n cnt = addresses.size\n\n addresses.each_slice(1) do |addies|\n before = nil\n get_txrefs_batched(addies).each do |tr|\n addy = tr['address']\n txrefs = [tr['txrefs']]\n\n # Insert global address meta-data\n db.query(get_address_query(tr))\n\n... | [
"0.58797675",
"0.55286926",
"0.5402101",
"0.53459543",
"0.52742547",
"0.51928157",
"0.5117065",
"0.5046773",
"0.5046244",
"0.50434804",
"0.5026177",
"0.5019531",
"0.50171757",
"0.50025344",
"0.49933386",
"0.4984701",
"0.49643236",
"0.49578765",
"0.49357355",
"0.49078798",
"0.... | 0.65612036 | 0 |
Call if the target is not a brute force target. | def single_exploit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bruteforce?\n return (bruteforce != nil)\n end",
"def is_target? \n return false\n end",
"def can_attack?( target )\n not @finished and targets.include?( target )\n end",
"def bad_target\n raise Exception.new(\"Can only attack a robot.\")\n end",
"def check(target)\n odie(\"For... | [
"0.7076978",
"0.6786918",
"0.647909",
"0.6278812",
"0.6125386",
"0.60495293",
"0.6033681",
"0.6022081",
"0.5944483",
"0.5941571",
"0.59080064",
"0.58802605",
"0.5846281",
"0.5844295",
"0.5844295",
"0.57790947",
"0.5764103",
"0.5723738",
"0.5682872",
"0.55706733",
"0.556572",
... | 0.0 | -1 |
Waits for the provide delay. | def brute_wait(delay)
sleep(delay)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_launching\n sleep @delay\n end",
"def delay\n sleep(2)\n end",
"def watch_delay\n @conn.watch(Web.keys[:delay]) do\n yield if block_given?\n end\n end",
"def delay(seconds)\n sleep(seconds)\n end",
"def delay(seconds); end",
"def de... | [
"0.7344138",
"0.71141547",
"0.70652175",
"0.7021996",
"0.7006501",
"0.7006501",
"0.6997505",
"0.6915153",
"0.6912405",
"0.6904837",
"0.69000167",
"0.689777",
"0.68685234",
"0.68073916",
"0.6797555",
"0.6783033",
"0.6759106",
"0.6753906",
"0.6748425",
"0.6673782",
"0.6613115",... | 0.76538527 | 0 |
Imports information into the supplied hash from the datastore. This is a way of allowing the user to override values for a specific brute force target by name without them actually being conveyed in the options list. This is a bit of a change from 2.x, but 2.x didn't have pertarget brute force addresses, which I think ... | def import_from_datastore(hash, prefix = '')
hash.each_key { |k|
if (self.datastore[prefix + k])
hash[k] = self.datastore[prefix + k]
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(hash)\n @opts = hash\n end",
"def import_hash(hash)\n clean_char_encoding!(hash)\n\n ref = {}\n {\"@referent\" => \"rft\", \"@referrer\" => \"rfr\", \"@referringEntity\" => \"rfe\",\n \"@requestor\" => \"req\"}.each do |ent, abbr|\n next unless hash[\"#{abbr}_val_... | [
"0.61150146",
"0.5790135",
"0.57540053",
"0.57487935",
"0.55743694",
"0.54813975",
"0.5424842",
"0.5389336",
"0.5243928",
"0.5240102",
"0.5232147",
"0.5170038",
"0.51696223",
"0.5158265",
"0.51553386",
"0.5154887",
"0.51288605",
"0.5121568",
"0.50949264",
"0.50949264",
"0.506... | 0.57972926 | 1 |
n 3 + m end puts cube() puts cube(3) puts cube(3, 3) | def qualifier(zone, *countries)
puts "The winners of #{zone} qualifiers are:\n"
countries.each do |country|
puts "- #{country}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cube (n)\ncube_result = n**3\nreturn cube_result\nend",
"def cube(num)\n return num * num * num\nend",
"def cube(num) #specify, pass it num \n num * num * num \n 5 \nend",
"def cube(number)\n return number * number * number\nend",
"def cube(number)\n return number * number * number\nend",... | [
"0.84284997",
"0.83453673",
"0.8339368",
"0.832038",
"0.832038",
"0.827851",
"0.827851",
"0.8273367",
"0.82233334",
"0.8213388",
"0.8168474",
"0.8168474",
"0.8162725",
"0.811986",
"0.8087771",
"0.80754584",
"0.8064619",
"0.8021902",
"0.7879359",
"0.7859141",
"0.77673805",
"... | 0.0 | -1 |
compares file checksums for a set of directory paths | def watch( paths )
chksum_errors = {}
paths.map!{ |path| Dir["#{path}/**/*"] }.flatten! if $r
dirs = paths.select{ |path| File.directory? path }
dirs.each do |dir|
cd dir do
begin
chksum_manifest = load
chksum_manifest = check chksum_manifest
dump chksum_manif... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_paths(src_path, dst_path)\n match = true\n # assume linux\n md5sum = \"md5sum\"\n md5sum = \"md5\" if node.platform == \"freebsd\"\n\n lib_files = `ls #{src_path}/`.split(/\\n/)\n lib_files.each do |file|\n src = `#{md5sum} #{src_path}/#{file}`.split(/\\s+/)\n dst = `#{md5sum} #{d... | [
"0.68051404",
"0.6733173",
"0.65549767",
"0.6410948",
"0.62383807",
"0.6167939",
"0.6167822",
"0.6162172",
"0.6071311",
"0.6060409",
"0.59917593",
"0.59010077",
"0.5869253",
"0.5855578",
"0.58423465",
"0.5791854",
"0.5727085",
"0.57167745",
"0.5712124",
"0.56942505",
"0.56865... | 0.64100486 | 4 |
Attempts to load checksum manifest YAML file, otherwise returns an empty hash. | def load
YAML.load_file MANIFEST rescue {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load\n @checksum ||= ::File.exists?(checksum_file) ? ::File.read(checksum_file) : ''\n Chef::Log.debug(\"Loaded checksum for SMF #{self.name}: #{@checksum}\")\nend",
"def read_manifest()\n if not File.exists?(MANIFEST)\n return {}\n end\n\n f = File.new(MANIFEST, \"r\")\n f.rewind()\n yml = ... | [
"0.6978622",
"0.62130827",
"0.60595584",
"0.6032698",
"0.60058445",
"0.585851",
"0.5832155",
"0.5793039",
"0.56793606",
"0.567392",
"0.56575745",
"0.564769",
"0.5632648",
"0.56153864",
"0.56152153",
"0.5598906",
"0.5557974",
"0.5551193",
"0.5516729",
"0.5509866",
"0.55079615"... | 0.61543274 | 2 |
Write YAML file containing checksum manifest | def dump( chksum_manifest )
File.open(MANIFEST,'w') { |f| YAML.dump chksum_manifest, f }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(filename, hash)\n File.open(filename, \"a\") do |f|\n f.write(yaml(hash))\n end\nend",
"def create_chksum_manifest\n chksum_manifest = {}\n files = Dir['*'].select{ |f| File.file? f }\n files.each do |file|\n chksum_manifest[file] = Digest::MD5.file(file).hexdigest\n end\n chks... | [
"0.6538927",
"0.6535628",
"0.6449397",
"0.6372029",
"0.6131754",
"0.5987868",
"0.59824663",
"0.59765023",
"0.5831428",
"0.5819895",
"0.5816778",
"0.5780003",
"0.57682854",
"0.5751531",
"0.5706426",
"0.5701545",
"0.56864846",
"0.56401634",
"0.56232905",
"0.5591834",
"0.5587537... | 0.770175 | 0 |
Create a checksum manifest of files in current directory | def create_chksum_manifest
chksum_manifest = {}
files = Dir['*'].select{ |f| File.file? f }
files.each do |file|
chksum_manifest[file] = Digest::MD5.file(file).hexdigest
end
chksum_manifest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_checksums\n # puts \"Ins: #{@basename}\"\n md5 = Digest::MD5.file(@fullname).to_s\n sha1 = Digest::SHA1.file(@fullname).to_s\n sha256 = Digest::SHA2.new(256).file(@fullname).to_s\n @pkgdb.query(\"insert into checksums values ( datetime('now'), '#{@basename}', '#{@suit... | [
"0.69820946",
"0.6784016",
"0.62605023",
"0.6207925",
"0.61522347",
"0.61317825",
"0.61240834",
"0.606561",
"0.60537064",
"0.59999835",
"0.5982133",
"0.597507",
"0.59272116",
"0.59263164",
"0.5914449",
"0.590957",
"0.58954686",
"0.5861402",
"0.5770545",
"0.5727331",
"0.572614... | 0.8324981 | 0 |
Check old manifest against the current state. | def check( chksum_manifest )
new_chksum_manifest = create_chksum_manifest
changed = []
chksum_manifest.each do |file,chksum|
changed << file if chksum != new_chksum_manifest[file]
end
if changed.empty?
chksum_manifest = new_chksum_manifest
else
raise ChecksumError, changed
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_current_if_current\n manifest.reload\n if current = manifest.current\n current.stored_manifest.copy(Manifesto.bucket, \"#{manifest.name}-current.json\", s3_headers) unless current.version > self.version\n elsif current = directory.files.get(\"#{manifest.name}-current.json\")\n current... | [
"0.6286332",
"0.6284107",
"0.6231148",
"0.61004406",
"0.6036433",
"0.5999586",
"0.59167457",
"0.5906116",
"0.5827238",
"0.57990426",
"0.57943565",
"0.5762446",
"0.57463187",
"0.5733623",
"0.56520337",
"0.56146973",
"0.55967313",
"0.55887777",
"0.55749106",
"0.55539775",
"0.54... | 0.62065136 | 3 |
OS X and Arch ship an ancient version of `tic` which does not support reading from standard IO, so we have to use temp files. Fortunately, Ruby's tempfile class makes this relatively painless. c.f. | def write_terminfo terminfo
tempfile = Tempfile.new 'terminfo'
begin
tempfile.write terminfo
ensure
tempfile.close
shell "tic -x #{tempfile.path}"
tempfile.unlink
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tmpio\n fp = begin\n TmpIO.open(\"#{Dir::tmpdir}/#{rand}\",\n File::RDWR|File::CREAT|File::EXCL, 0600)\n rescue Errno::EEXIST\n retry\n end\n File.unlink(fp.path)\n fp.binmode\n fp.sync = true\n fp\n end",
"def tempfi... | [
"0.6655493",
"0.63529766",
"0.63529766",
"0.6162415",
"0.61319363",
"0.6083337",
"0.6050067",
"0.6046999",
"0.6026971",
"0.5940522",
"0.5839918",
"0.5826656",
"0.5825305",
"0.5820184",
"0.5817699",
"0.57584375",
"0.57489175",
"0.5720667",
"0.5720667",
"0.5720667",
"0.5689821"... | 0.56778574 | 22 |
I worked on this challenge by myself, but my pair was on standby if I needed help (Tim Beck) because he's a good dude. Your Solution Below | def welcome(address)
if address.include? "CA"
return "Welcome to California"
else
return "You should move to California"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(s, p, q)\n # write your code in Ruby 2.2\n g = s.length + 1\n a = (s.length + 1)**3\n c = (s.length + 1)**2\n tmp = []\n res = []\n tmp.push 0\n o = 0\n s.split('').each do |i|\n o += if i == 'T'\n 1\n elsif i == 'G'\n g\n elsif i == 'C'\n c\n ... | [
"0.62595195",
"0.6231386",
"0.61789614",
"0.612626",
"0.605326",
"0.60449195",
"0.5958255",
"0.5955736",
"0.5945782",
"0.5931656",
"0.5931125",
"0.5868965",
"0.5862806",
"0.58457625",
"0.5822398",
"0.5821755",
"0.5805436",
"0.5803848",
"0.5791756",
"0.5774919",
"0.57713944",
... | 0.0 | -1 |
GET /places/:place_id/issues GET /places/:place_id/issues.json GET /issues GET /issues.json | def index
if params[:place_id] and params[:place_id].to_i>0 then
place_id = params[:place_id]
# first make sure the place is in our db locally
if not Place.exists?(:id => place_id)
logger.info("Adding new place %d" % place_id)
place_info = SeeClickFix.place(place_id)
new_pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:place_id] and params[:place_id].to_i>0 then\n place_id = params[:place_id]\n # first make sure the place is in our db locally\n if not Place.exists?(:id => place_id)\n logger.info(\"Adding new place %d\" % place_id)\n place_info = SeeClickFix.place(place_id)\n... | [
"0.7932809",
"0.6499258",
"0.63391316",
"0.6301066",
"0.617356",
"0.617356",
"0.617356",
"0.617356",
"0.617356",
"0.6153249",
"0.61098933",
"0.60822237",
"0.60700864",
"0.60672706",
"0.60024875",
"0.59814423",
"0.5966597",
"0.5925629",
"0.5900989",
"0.5887542",
"0.5877726",
... | 0.7484061 | 1 |
GET /issues/1 GET /issues/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gather_issues\n url = \"#{URL}/projects/foreman/issues.json?status_id=1&limit=100&release_id=#{@current_release_id}\"\n puts url\n uri = URI(URI.escape(url))\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend",
"def issue(project, id)\n get(\"/projects/#{url_encode project}/issues/#{id}\")... | [
"0.7721504",
"0.74035424",
"0.7397191",
"0.7381908",
"0.7281266",
"0.7261736",
"0.71961874",
"0.71948856",
"0.7193348",
"0.7191528",
"0.7177091",
"0.7177091",
"0.7177091",
"0.7177091",
"0.7177091",
"0.71535766",
"0.71528447",
"0.707041",
"0.70652086",
"0.7061967",
"0.7052516"... | 0.0 | -1 |
POST /issues POST /issues.json | def create
@issue = Issue.new(issue_params)
respond_to do |format|
if @issue.save
format.html { redirect_to @issue, notice: 'Issue was successfully created.' }
format.json { render :show, status: :created, location: @issue }
else
format.html { render :new }
format.js... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @issue = Issue.new(issue_params)\n\n respond_to do |format|\n if @issue.save\n format.html { redirect_to issues_url, notice: 'Issue was successfully created.' }\n format.json { render json: @issue }\n else\n format.html { redirect_to issues_url, notice: 'There was ... | [
"0.7199947",
"0.7071001",
"0.70693976",
"0.7026722",
"0.69781667",
"0.68653685",
"0.6785479",
"0.6740587",
"0.6726511",
"0.66771275",
"0.65047675",
"0.64861673",
"0.6484347",
"0.64759445",
"0.64703494",
"0.6463607",
"0.64526457",
"0.64397407",
"0.64287966",
"0.63603735",
"0.6... | 0.6982282 | 7 |
PATCH/PUT /issues/1 PATCH/PUT /issues/1.json | def update
respond_to do |format|
if @issue.update(issue_params)
format.html { redirect_to @issue, notice: 'Issue was successfully updated.' }
format.json { render :show, status: :ok, location: @issue }
else
format.html { render :edit }
format.json { render json: @issue.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @issue = Issue.find(params[:id])\n\n respond_to do |format|\n if @issue.update_attributes(params[:issue])\n format.html { redirect_to @issue, notice: 'Issue was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.6900769",
"0.6900471",
"0.6823495",
"0.6821491",
"0.67413807",
"0.6737853",
"0.66919345",
"0.6649898",
"0.6648978",
"0.65227854",
"0.650085",
"0.6498031",
"0.6481125",
"0.6477697",
"0.64270854",
"0.6398599",
"0.6384687",
"0.6358786",
"0.63515913",
"0.6350626",
"0.63403386"... | 0.670992 | 10 |
DELETE /issues/1 DELETE /issues/1.json | def destroy
@issue.destroy
respond_to do |format|
format.html { redirect_to issues_url, notice: 'Issue was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @issue = Issue.find(params[:id])\n @issue.destroy\n\n respond_to do |format|\n format.html { redirect_to issues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @issue = Issue.find(params[:id])\n @issue.destroy\n\n respond_to do |format|\n f... | [
"0.77372533",
"0.77372533",
"0.77372533",
"0.77372533",
"0.7725531",
"0.77085704",
"0.7654118",
"0.7585393",
"0.7575043",
"0.7548656",
"0.7493511",
"0.7480316",
"0.7480316",
"0.744561",
"0.73996127",
"0.73723876",
"0.7363262",
"0.72894686",
"0.7279824",
"0.72566104",
"0.72566... | 0.74467105 | 19 |
Use callbacks to share common setup or constraints between actions. | def set_issue
@issue = Issue.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 issue_params
params.require(:issue).permit(:place_id, :summary, :status, :description, :address, :scf_image_url, :lat, :lng,
:geofence_radius, :custom_image, :question, :answer1, :answer2, :answer3, :answer4, :answer5, :answer6 )
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 |
Write a method that returns a boolean indicating whether an array is in sorted order. Use the equality operator (==), which returns a boolean indicating whether its operands are equal, e.g., 2 == 2 => true, ["cat", "dog"] == ["dog", "cat"] => false | def in_order?(arr)
# your code goes here
arr == arr.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_order?(arr)\n arr == arr.sort\nend",
"def in_order?(arr)\n arr == arr.sort\nend",
"def in_order?(arr)\r\n # your code goes here\r\n\r\n arr == arr.sort\r\nend",
"def in_order?(arr)\n arr.sort == arr\nend",
"def in_order?(arr)\n arr.sort == arr\nend",
"def in_order?(arr)\n # your code goes h... | [
"0.8278019",
"0.8278019",
"0.82624376",
"0.8242917",
"0.8242917",
"0.8138189",
"0.81127244",
"0.80830884",
"0.79470384",
"0.76986504",
"0.76309896",
"0.7615475",
"0.7610949",
"0.76106477",
"0.76094496",
"0.75458807",
"0.75007784",
"0.749095",
"0.74887514",
"0.7487287",
"0.747... | 0.8127836 | 6 |
MEDIUM Write a method that returns the range of its argument (an array of integers). | def range(arr)
# your code goes here
arr = arr.sort
arr.last - arr.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range(arr)\n\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def range(arr)\n arr.max - arr.min\nend",
"def range(arr)\narr.max - arr.min\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def range(arr)\n # your code goes here\n arr.max - arr.min\nend",
"def range(... | [
"0.85641015",
"0.7994433",
"0.7994433",
"0.7929499",
"0.7862422",
"0.7862422",
"0.78434277",
"0.7720966",
"0.76946574",
"0.76530474",
"0.76052505",
"0.76052505",
"0.76052505",
"0.739257",
"0.7355825",
"0.7286302",
"0.71909106",
"0.71848303",
"0.71245915",
"0.7110883",
"0.7100... | 0.0 | -1 |
HARD Write a method that returns an array of the digits of a nonnegative integer in descending order and as strings, e.g., descending_digits(4291) => ["9", "4", "2", "1"] | def descending_digits(num)
# your code goes here
num.digits.sort{ |x,y| y <=> x}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def descending_digits(int)\n int.to_s.split('').sort.reverse\nend",
"def descending_digits(int)\n int.to_s.split('').sort.reverse\nend",
"def descending_digits(int)\n int.to_s.split(\"\").sort.reverse\nend",
"def descending_digits(int)\n int.to_s.split(\"\").sort.reverse\nend",
"def descending_digits(... | [
"0.78802073",
"0.78802073",
"0.7847883",
"0.7845561",
"0.7819051",
"0.77857995",
"0.7743486",
"0.7732352",
"0.7724538",
"0.77162206",
"0.7654352",
"0.7654352",
"0.76204973",
"0.7620032",
"0.7618526",
"0.76146895",
"0.76077634",
"0.75840294",
"0.75256497",
"0.75120634",
"0.736... | 0.71430135 | 25 |
Write a method that converts an array of ten integers into a phone number in the format "(123) 4567890". | def to_phone_number(arr)
# your code goes here
str = arr.join
"(#{str[0,3]}) #{str[3,3].to_s}-#{str[6,4]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_phone_number(arr)\n string = \"(\" + arr[0..2].join + \") \" + arr[3..5].join + \"-\" + arr[6..9].join\nend",
"def to_phone_number(arr)\n \"(#{arr[0..2].join}) #{arr[3..5].join}-#{arr[6..10].join}\"\nend",
"def to_phone_number(arr)\n \"(#{arr[0..2].join}) #{arr[3..5].join}-#{arr[6..-1].join}\"\nend",... | [
"0.8380048",
"0.83732325",
"0.8310481",
"0.8202933",
"0.8074936",
"0.80697894",
"0.7932485",
"0.7922528",
"0.7917879",
"0.79073983",
"0.7906991",
"0.7831325",
"0.7815431",
"0.78126574",
"0.7812163",
"0.76961356",
"0.7654568",
"0.7640946",
"0.7634562",
"0.74945366",
"0.7428888... | 0.8033459 | 6 |
Write a method that returns the range of a string of commaseparated integers, e.g., str_range("4,1,8") => 7 | def str_range(str)
# your code goes here
arr = str.split(",").map(&:to_i).sort
arr.last - arr.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str_range(str)\n split = str.split(\",\")\n minimum = split.min.to_i\n maximum = split.max.to_i\n range = maximum - minimum\n return range\nend",
"def str_range(str)\n to_i = lambda { |num| num.to_i }\n nums = str.split(',').map(&to_i)\n nums.max - nums.min\nend",
"def str_range(str)\n max = str.d... | [
"0.8339904",
"0.80975974",
"0.7930805",
"0.7750638",
"0.7676766",
"0.76231354",
"0.75595415",
"0.7294791",
"0.71876955",
"0.7035714",
"0.6970872",
"0.6935765",
"0.6829714",
"0.67585313",
"0.67382294",
"0.6713016",
"0.65676767",
"0.65258855",
"0.63555205",
"0.6328613",
"0.6180... | 0.74387467 | 7 |
GET /equipe_persos GET /equipe_persos.json | def index
@equipe_persos = EquipePerso.all
@joueurs = Joueur.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end",
"def set_equipe_perso\n @equipe_perso = EquipePerso.find(params[:id])\n end",
"def index\n logement = Logement... | [
"0.69818556",
"0.67983043",
"0.67644644",
"0.6700641",
"0.66894144",
"0.6655512",
"0.66419536",
"0.661162",
"0.65872854",
"0.6567852",
"0.6540351",
"0.65249205",
"0.6513927",
"0.6507898",
"0.6490357",
"0.6488757",
"0.64458853",
"0.6444611",
"0.64270777",
"0.6420753",
"0.64077... | 0.6579046 | 9 |
GET /equipe_persos/1 GET /equipe_persos/1.json | def show
@equipe_persos = EquipePerso.all
@joueurs = Joueur.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end",
"def show\n @peso = Peso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n for... | [
"0.68741417",
"0.6855273",
"0.68036735",
"0.672647",
"0.6672648",
"0.660734",
"0.66072214",
"0.65971136",
"0.6595065",
"0.6578494",
"0.65727913",
"0.65598077",
"0.65551966",
"0.6548458",
"0.65430623",
"0.65355635",
"0.65217924",
"0.6501138",
"0.64998",
"0.6497097",
"0.6494524... | 0.6193366 | 70 |
POST /equipe_persos POST /equipe_persos.json | def create
@equipe_perso = EquipePerso.new(equipe_perso_params)
@joueur = Joueur.find(22)
@joueur.estAchete = true
@joueur.save
@joueur = Joueur.find(27)
@joueur.estAchete = true
@joueur.save
@joueur = Joueur.find(28)
@joueur.estAchete = true
@joueur.save
@joueur = Joueur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @equipe = Equipe.new(equipe_params)\n\n respond_to do |format|\n if @equipe.save\n format.html { redirect_to @equipe, notice: 'Equipe foi Adicionada.' }\n format.json { render :show, status: :created, location: @equipe }\n else\n format.html { render :new }\n ... | [
"0.6687939",
"0.65657604",
"0.64190894",
"0.6356523",
"0.6348385",
"0.6338529",
"0.6330935",
"0.6326884",
"0.6316556",
"0.63025296",
"0.6301388",
"0.62725705",
"0.62601596",
"0.6257714",
"0.6240678",
"0.62093127",
"0.6208388",
"0.62063867",
"0.6179837",
"0.6172373",
"0.614471... | 0.6254358 | 14 |
PATCH/PUT /equipe_persos/1 PATCH/PUT /equipe_persos/1.json | def update
respond_to do |format|
if @equipe_perso.update(equipe_perso_params)
format.html { redirect_to @equipe_perso }
flash[:success] = "Ton équipe a bien été modifié !"
format.json { render :show, status: :ok, location: @equipe_perso }
else
format.html { render :edit ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @equipe.update(equipe_params)\n format.html { redirect_to @equipe, notice: 'Equipe foi Atualizada.' }\n format.json { render :show, status: :ok, location: @equipe }\n else\n format.html { render :edit }\n format.json { render json: @... | [
"0.65994364",
"0.65773886",
"0.6507584",
"0.65012485",
"0.64872485",
"0.64180017",
"0.6396292",
"0.6357498",
"0.6356757",
"0.63563406",
"0.63534874",
"0.6334",
"0.6329614",
"0.6306592",
"0.6301805",
"0.6300021",
"0.6291045",
"0.6278591",
"0.62673837",
"0.6266289",
"0.6261932"... | 0.69130826 | 0 |
DELETE /equipe_persos/1 DELETE /equipe_persos/1.json | def destroy
@equipe_perso.destroy
respond_to do |format|
format.html { redirect_to equipe_persos_url, success: "Ton équipe a bien été supprimé !" }
format.json { head :no_content }
@joueurs = Joueur.all
@joueurs.each do |joueur|
if joueur.estAchete?
joueur.estAchete = f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @equipe.destroy\n respond_to do |format|\n format.html { redirect_to equipes_url, notice: 'Equipe foi Removida.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_ur... | [
"0.73905855",
"0.737344",
"0.7284074",
"0.72622234",
"0.7247025",
"0.7242442",
"0.7217747",
"0.7190887",
"0.7183669",
"0.71836346",
"0.7178354",
"0.7156677",
"0.71566683",
"0.7151167",
"0.7145401",
"0.71443766",
"0.712915",
"0.7127936",
"0.7122987",
"0.7120508",
"0.71095014",... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_equipe_perso
@equipe_perso = EquipePerso.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 equipe_perso_params
params.require(:equipe_perso).permit(:nameteam, :nametrainer, :pays, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /task2s GET /task2s.json | def index
@task2s = Task2.all
@task2 = Task2.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @task2 = Task2.new(task2_params)\n\n respond_to do |format|\n if @task2.save\n format.html { redirect_to @task2, notice: 'Task2 was successfully created.' }\n format.json { render :show, status: :created, location: @task2 }\n else\n @task2s = Task2.all\n for... | [
"0.65693766",
"0.6387797",
"0.6251542",
"0.62264144",
"0.5861415",
"0.5707581",
"0.5636897",
"0.5626722",
"0.5615739",
"0.56044537",
"0.5573035",
"0.55699116",
"0.5558142",
"0.55452067",
"0.54862845",
"0.54848707",
"0.54821956",
"0.5481842",
"0.5466904",
"0.54586214",
"0.5442... | 0.6985075 | 0 |
GET /task2s/1 GET /task2s/1.json | def show
# @task2 Task2.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @task2s = Task2.all\n @task2 = Task2.new\n end",
"def set_task2\n @task2 = Task2.find(params[:id])\n end",
"def create\n @task2 = Task2.new(task2_params)\n\n respond_to do |format|\n if @task2.save\n format.html { redirect_to @task2, notice: 'Task2 was successfully ... | [
"0.717153",
"0.70287234",
"0.67833686",
"0.5955961",
"0.5913423",
"0.5861824",
"0.5811103",
"0.5809511",
"0.58080614",
"0.5770652",
"0.5770207",
"0.57690674",
"0.57455355",
"0.57316464",
"0.5715915",
"0.57140815",
"0.570938",
"0.5702336",
"0.5678701",
"0.56754327",
"0.5651478... | 0.70335215 | 1 |
POST /task2s POST /task2s.json | def create
@task2 = Task2.new(task2_params)
respond_to do |format|
if @task2.save
format.html { redirect_to @task2, notice: 'Task2 was successfully created.' }
format.json { render :show, status: :created, location: @task2 }
else
@task2s = Task2.all
format.html { ren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @task2s = Task2.all\n @task2 = Task2.new\n end",
"def task2_params\n params.require(:task2).permit(:title, :body)\n end",
"def set_task2\n @task2 = Task2.find(params[:id])\n end",
"def create\n @task = Task.new(task_params)\n @task.save\n render json: full_task(@ta... | [
"0.6316669",
"0.62859356",
"0.61148685",
"0.59261817",
"0.5892305",
"0.5813187",
"0.57652724",
"0.57543737",
"0.56850547",
"0.5685054",
"0.5667197",
"0.56372315",
"0.56208974",
"0.55870134",
"0.5585089",
"0.55714726",
"0.55441314",
"0.55392426",
"0.55332166",
"0.5524789",
"0.... | 0.7401985 | 0 |
PATCH/PUT /task2s/1 PATCH/PUT /task2s/1.json | def update
respond_to do |format|
if @task2.update(task2_params)
format.html { redirect_to @task2, notice: 'Task2 was successfully updated.' }
format.json { render :show, status: :ok, location: @task2 }
else
format.html { render :edit }
format.json { render json: @task2.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_user_task\n task = Task.find(params[:id])\n \n if task.update(task_params)\n render json: {task: task, status: 201} \n else\n render json: {errors: task.errors.full_message , status: 422}\n end\n end",
"def edit_user_task\n task = Task.find(params[:id])\n \n if task.up... | [
"0.672604",
"0.672604",
"0.665476",
"0.6551163",
"0.65299475",
"0.64497",
"0.64380294",
"0.63800746",
"0.63688654",
"0.6366282",
"0.63223153",
"0.63082075",
"0.63062066",
"0.63062066",
"0.63062066",
"0.6294729",
"0.62907743",
"0.62907743",
"0.62907743",
"0.62907743",
"0.62907... | 0.7211705 | 0 |
DELETE /task2s/1 DELETE /task2s/1.json | def destroy
@task2.destroy
respond_to do |format|
format.html { redirect_to task2s_path, notice: 'Task2 was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @task = Node.find(params[:id])\n @task.destroy\n respond_to do |format|\n format.html { redirect_to tasks_path}\n format.json { head :no_content }\n end\n \n end",
"def delete_task\n @task = Task.find_by(id: params[:id])\n @task.destroy\n render :json => @task.as_... | [
"0.67409855",
"0.6731892",
"0.67225844",
"0.6713397",
"0.6712176",
"0.669347",
"0.6692473",
"0.6692473",
"0.6692473",
"0.6692473",
"0.6692473",
"0.6692473",
"0.6676272",
"0.6676272",
"0.6676272",
"0.6676272",
"0.6676272",
"0.6676272",
"0.6676272",
"0.6676272",
"0.6676272",
... | 0.7498793 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_task2
@task2 = Task2.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def task2_params
params.require(:task2).permit(:title, :body)
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 |
take the moves generated from check | def checkmate?(from_1, piece_1)
all_possible_moves = []
board.game_board.each_with_index do |row, x|
row.each_with_index do |_col, y|
piece = board.game_board[x][y]
from = x, y
next unless piece != ' ' && piece.color == current_player.color
@final << final_mate?(from_1, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_moves\n @delta.each do |step|\n (1..7).each do |i|\n new_pos = [@pos[0] + step[0] * i, @pos[1] + step[1] * i]\n if valid_coord?(new_pos)\n @move_list << new_pos\n break if @board[new_pos]\n else\n break\n end\n end\n end\n end",
... | [
"0.7274656",
"0.7234107",
"0.72145605",
"0.7201619",
"0.710318",
"0.7075682",
"0.6988021",
"0.6897698",
"0.68920976",
"0.6885474",
"0.6866371",
"0.6863708",
"0.6856482",
"0.682154",
"0.6799014",
"0.67948264",
"0.6780819",
"0.6774004",
"0.67625517",
"0.67540616",
"0.6751582",
... | 0.0 | -1 |
uses checkmate helper methods to see if there are any valid moves out of check. if not, it is mate. | def final_mate?(from1, piece1, all_possible_moves)
!block_check?(piece1, from1, all_possible_moves) && !can_take_piece?(all_possible_moves, from1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_checkmate?\n @current_selection = @current_king_location\n calculate_moves(\"King\", @current_king_location)\n move_out_of_check = @possible_moves.all? do |move|\n \t board_pre_move = @board.clone\n \t @board[move] = @board[@current_king_location]\n \t ... | [
"0.7628538",
"0.7575839",
"0.75058246",
"0.7398346",
"0.7397677",
"0.7384672",
"0.73236835",
"0.73059",
"0.7289253",
"0.7280161",
"0.7171149",
"0.7152065",
"0.7135167",
"0.70474446",
"0.70162433",
"0.69971186",
"0.6985113",
"0.6946919",
"0.69233364",
"0.6907097",
"0.6903756",... | 0.6712624 | 32 |
ensures that subsequent move does not put king in check | def puts_king_in_check?(from, to)
if check?
legal_king_moves(from, to)
error.bad_check_move(current_player)
board.make_move(to, from)
board.respawn_pieces
play_game
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def under_check\r\n # Define permitted moves for the king, when under check.\r\n end",
"def move_piece(move)\n curr_piece = @board[move[0]]\n if curr_piece.non_check_moves.include?(move[1])\n #if en passant, remove captured piece\n if curr_piece.class == Pawn\n #puts curr_piece.can_en_... | [
"0.76580364",
"0.74701685",
"0.7418936",
"0.7418936",
"0.7347307",
"0.72370493",
"0.7214584",
"0.7213907",
"0.71263117",
"0.70959073",
"0.7083384",
"0.7020467",
"0.7008313",
"0.6970631",
"0.69578993",
"0.69542205",
"0.6938757",
"0.69160813",
"0.6913879",
"0.6908562",
"0.68926... | 0.0 | -1 |
Initializes this environment to be an empty list of configurations. | def initialize
@configurations = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n\t\t@configurations = Array.new\n\tend",
"def empty_config\n nil\n end",
"def class_init\n @environments_by_name = {}\n @environments = []\n end",
"def reset\n @config = empty_config\n end",
"def configurations\n @configurations ||= []\n end",
... | [
"0.75029004",
"0.6841958",
"0.64101875",
"0.63748634",
"0.63730645",
"0.61532867",
"0.6124448",
"0.60800934",
"0.60712224",
"0.60548073",
"0.59636456",
"0.5942657",
"0.5942657",
"0.5904648",
"0.5875182",
"0.5852081",
"0.58493686",
"0.583797",
"0.5833667",
"0.58110106",
"0.578... | 0.69802666 | 1 |
Defines a new configuration with the given name. | def configuration(name, &block)
config = Configuration.new
config.instance_eval(&block)
@configurations[name] = config
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name=(value); configuration.name = value; end",
"def add_config(name, config)\n\t\tend",
"def add_configuration(name, config)\n config.validate_config!\n @configurations ||= {}\n config.send(:cache_headers!)\n config.freeze\n @configurations[name] = config\n e... | [
"0.7561275",
"0.71907556",
"0.7123847",
"0.6934123",
"0.6753044",
"0.67456216",
"0.66752577",
"0.6624582",
"0.66219455",
"0.66205597",
"0.6606587",
"0.65477693",
"0.6501622",
"0.6491291",
"0.64686143",
"0.644862",
"0.643231",
"0.6396999",
"0.6322091",
"0.6299909",
"0.62872344... | 0.7147029 | 2 |
Initializes the configuration to have no env vars and no aliases. | def initialize
@environment_variables = {}
@aliases = {}
@commands = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_configuration\n\t\t# Set defaults\n\t\t@setup = { \"create\" => false, \"environment\" => false, \"test\" => true, \"destroy\" => false }\n\t\t@config = false\n\tend",
"def initialize(*args)\n initialize_config unless instance_variable_defined?(:@config)\n super\n end",
"def init_default_confi... | [
"0.75330585",
"0.7198437",
"0.7058883",
"0.70506626",
"0.6929967",
"0.6873013",
"0.67502254",
"0.6648526",
"0.66315097",
"0.6553906",
"0.6471492",
"0.6449204",
"0.64232594",
"0.6398959",
"0.6389454",
"0.6344435",
"0.63380283",
"0.63178045",
"0.6316513",
"0.63143724",
"0.62999... | 0.62300473 | 24 |
Defines a new environment variable. | def env(key, value)
@environment_variables[key] = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setenv(n, v)\n debug \"Adding env: #{n}=#{v}\"\n debug \"prev value: #{@rye_getenv[n]}\"\n @rye_getenv[n] = v\n (@rye_current_environment_variables ||= {})[n] = v\n self\n end",
"def set_variable (varname, value)\n\n env, var = lookup_environment(varname)\n env[var] = va... | [
"0.7122205",
"0.6981709",
"0.68485844",
"0.68399364",
"0.66148645",
"0.66085404",
"0.66038525",
"0.653138",
"0.6363545",
"0.63244253",
"0.63236475",
"0.62381566",
"0.62245506",
"0.6202135",
"0.62007415",
"0.62007415",
"0.61940384",
"0.61864084",
"0.6114607",
"0.61085325",
"0.... | 0.71915793 | 0 |
Defines a new command alias. | def alias_cmd(key, value)
@aliases[key] = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commandalias(command, a)\r\n\t$gamemode.commandalias(command, a)\r\nend",
"def commandalias(command, a)\r\n\t\t\t@commands[a] = @commands[command]\r\n\t\tend",
"def alias(a)\n Registry.alias_command(self, a)\n end",
"def aliases(s)\n command.aliases(s)\n end",
"def alias(cmd_name)\n lo... | [
"0.80529046",
"0.80152446",
"0.7870202",
"0.7255616",
"0.7203679",
"0.70196986",
"0.68974423",
"0.68897074",
"0.6857754",
"0.6769448",
"0.6645706",
"0.6633599",
"0.6576131",
"0.65706986",
"0.6563461",
"0.65506715",
"0.6550447",
"0.65502465",
"0.6526573",
"0.6455053",
"0.64042... | 0.7519183 | 3 |
Schedules a string to be echoed. | def echo(string)
@commands << "echo #{string}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text(string)\n @reactor.schedule { @driver.text(string.to_s) }\n end",
"def sleep_until(str)\n @queue << \"sleep #{str}\"\n end",
"def schedule_tweet(text, datetime)\n scheduler = Rufus::Scheduler.new\n\n job = scheduler.schedule datetime do\n puts \"beep\"\n send_... | [
"0.6625457",
"0.65267503",
"0.6070761",
"0.60540485",
"0.5878649",
"0.57552475",
"0.57084566",
"0.57084566",
"0.57031745",
"0.56967556",
"0.5679019",
"0.5669229",
"0.56247616",
"0.55838656",
"0.5582952",
"0.55500823",
"0.5509522",
"0.5509522",
"0.55000764",
"0.5472689",
"0.54... | 0.5929443 | 4 |
Schedules a command to be run. | def cmd(string)
@commands << string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle(command)\n super do\n add_schedule(command)\n end\n end",
"def schedule\n run_callbacks :schedule do\n perform_async\n end\n end",
"def run(command)\n @commands_to_run << command\n end",
"def schedule\n run_callbacks :schedule do... | [
"0.68564034",
"0.655802",
"0.6360038",
"0.613144",
"0.60298604",
"0.59808177",
"0.5939087",
"0.5939087",
"0.58782256",
"0.5854143",
"0.5844542",
"0.57673514",
"0.5761334",
"0.5761334",
"0.5761334",
"0.5761334",
"0.5720307",
"0.5678679",
"0.5672279",
"0.56702596",
"0.5646124",... | 0.0 | -1 |
Evals a block only if the current operating system matches the named operating system. names can be one of :linux, :macos, or :windows | def os(*names, &block)
if OS.linux? and names.include? :linux
instance_eval &block
elsif OS.mac? and names.include? :macos
instance_eval &block
elsif OS.windows? and names.include? :windows
instance_eval &block
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_os name\n os_kernel = `uname -a`\n os_kernel.downcase.include?(name)\nend",
"def for_platform(platform_name)\n if ENV[\"FASTLANE_PLATFORM_NAME\"] == platform_name.to_s\n yield\n end\n end",
"def only_on(*architectures)\n architectures = architectures.map do |name|\n if na... | [
"0.6574821",
"0.6049616",
"0.5908852",
"0.5826702",
"0.5816691",
"0.57200027",
"0.5715691",
"0.5714363",
"0.56780607",
"0.56764495",
"0.5547789",
"0.554456",
"0.55402416",
"0.5538376",
"0.5526001",
"0.551954",
"0.55178815",
"0.5506034",
"0.5487224",
"0.5483189",
"0.5479943",
... | 0.70705074 | 0 |
extend Concerns::Findable::ClassMethods include Concerns::Findable::InstanceMethods | def initialize(name)
@name=name
#save
@songs =[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(object, parent = @base)\n raise NotImplementedError, \"Subclasses must implement public method find\"\n end",
"def find\n fail NotImplementedError\n end",
"def find\n raise \"Method not implemented\"\n end",
"def find_by()\n\n end",
"def find; end",
"def finder_met... | [
"0.71190184",
"0.707146",
"0.7021296",
"0.6949463",
"0.68052393",
"0.6803246",
"0.6629471",
"0.6557268",
"0.6476053",
"0.64702266",
"0.64536285",
"0.6329331",
"0.63023025",
"0.62696755",
"0.6250894",
"0.62203145",
"0.6194261",
"0.6185263",
"0.6184601",
"0.6178711",
"0.6178103... | 0.0 | -1 |
Initialize a new Matcher object with the languages_range parameter representing the user's preferred languages and their respective quality values. | def initialize(**languages_range)
@excluded_langtags = ::Set[]
langtags = []
languages_range.select do |langtag, quality|
if quality.zero?
@excluded_langtags << langtag unless wildcard?(langtag)
else
level = (quality * 1_000).to_i
langtags[level] = langta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(query, languages)\n @query = query\n @languages = languages\n end",
"def build_matcher(options, whitelist_option, blacklist_option); end",
"def initialize(args)\n super\n @languages = {\"af\" => \"Afrikaans\", \"sq\" => \"Albanian\",\n \"ar\"=>\"Arabic\",\"be\"=>\"Belarusian\",\"... | [
"0.573642",
"0.53608185",
"0.52865344",
"0.5274363",
"0.51768136",
"0.51425993",
"0.5126894",
"0.51205033",
"0.51152474",
"0.50866246",
"0.50866246",
"0.4979181",
"0.4945497",
"0.49084282",
"0.488632",
"0.48721302",
"0.485768",
"0.48513958",
"0.48260352",
"0.48194137",
"0.477... | 0.723555 | 0 |
Matches the user's preferred languages against the available languages of your application. It prioritizes higher quality values and returns the most suitable match. | def call(*available_langtags)
available_langtags = drop_unacceptable(*available_langtags)
preferred_langtags.each do |preferred_tag|
if wildcard?(preferred_tag)
langtag = any_other_langtag(*available_langtags)
return langtag unless langtag.nil?
else
available_l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preferred_language_from(locales)\n (accepted_languages & locales).first\n end",
"def compute_effective_locale\n # Priority order:\n # 1.query parameter 'lang'\n # 2.cookie 'lang'\n # 3.browser setting\n requested_lang = params[:lang] || cookies[:lang]\n if self.offered_l... | [
"0.6934695",
"0.6765851",
"0.6688984",
"0.668288",
"0.66536397",
"0.66503996",
"0.64854544",
"0.6468775",
"0.6384589",
"0.63182765",
"0.63124484",
"0.6308719",
"0.6258222",
"0.6250123",
"0.62281066",
"0.61827683",
"0.6171559",
"0.6170722",
"0.61684537",
"0.6131338",
"0.611887... | 0.65824705 | 6 |
setup and loading functions | def get_canvas_focus
find(:css, '#umpleCanvas').click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load!; end",
"def load; end",
"def load; end",
"def load; end",
"def loader; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
... | [
"0.70141846",
"0.7000655",
"0.7000655",
"0.7000655",
"0.6968174",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
"0.6879576",
... | 0.0 | -1 |
Initializes a new CountryDefiner with a Hash containing shared CountryTimezone instances, keyed by an alias. | def initialize(shared_timezones)
@shared_timezones = shared_timezones
@timezones = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timezone(reference, identifier, latitude_numerator, latitude_denominator,\n longitude_numerator, longitude_denominator, description = nil)\n # Dedupe non-frozen literals from format 1 on all Ruby versions and\n # format 2 on Ruby < 2.3 (without frozen_string_literal support).\n... | [
"0.65155303",
"0.582379",
"0.5721146",
"0.5622603",
"0.55646557",
"0.54442245",
"0.52533597",
"0.5154458",
"0.5145428",
"0.51088345",
"0.51052994",
"0.50992846",
"0.50951016",
"0.5070895",
"0.50454545",
"0.50221807",
"0.5021097",
"0.5016803",
"0.49971762",
"0.4975123",
"0.497... | 0.53816634 | 6 |
Defines a timezone of a country either using a given identifier, latitude, longitude and description, or as a reference to a predefined shared timezone. The latitude and longitude are given as the numerator and denominator of a Rational. | def timezone(identifier_or_reference, latitude_numerator = nil,
latitude_denominator = nil, longitude_numerator = nil,
longitude_denominator = nil, description = nil)
if latitude_numerator
unless latitude_denominator && longitude_numerator && longitude_denominator
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timezone(reference, identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = T.unsafe(nil)); end",
"def timezone(reference, identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = T.unsafe(nil)); en... | [
"0.8015183",
"0.8015183",
"0.78062475",
"0.7679681",
"0.6866767",
"0.6866767",
"0.6866767",
"0.62243867",
"0.62186974",
"0.62153685",
"0.62153685",
"0.62153685",
"0.62153685",
"0.6148057",
"0.5998396",
"0.5998396",
"0.59896874",
"0.59896874",
"0.59896874",
"0.59896874",
"0.59... | 0.80145055 | 2 |
we load parser tests from a data file. ensure the file is structured in the correct way | def test_parser_valid_data
assert Yay::PARSER_TESTS.kind_of? Hash
Yay::PARSER_TESTS.each_pair { |input, expected|
assert input.kind_of? String
assert expected.kind_of? Array
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_test(tc)\n data = Hash.new\n File.open(tc, \"r\") do |infile|\n while (line = infile.gets)\n #test = /^.*\\/(.*\\.rb)/.match(tc)[1]\n test = /^.*\\/([A-Za-z0-9_-]*[T|t]est.*)/.match(tc)[1]\n data['execute_class'] = /^([A-Za-z0-9_-]*[T|t]es... | [
"0.6990681",
"0.6842473",
"0.6717189",
"0.6540258",
"0.6410906",
"0.6410906",
"0.6390492",
"0.6320891",
"0.62788236",
"0.6264095",
"0.6259046",
"0.61996025",
"0.6153481",
"0.6152546",
"0.6140943",
"0.61400884",
"0.61070824",
"0.60987246",
"0.60973454",
"0.6094058",
"0.603374"... | 0.6181675 | 12 |
run the lexer tests we loaded from the data file | def test_parser_run
Yay::PARSER_TESTS.each_pair { |input, expected|
parser = Yay::Parser.new
assert_equal expected, parser.parse(input), "For |#{input}|"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_program_a_has_correct_tokens\n @program_d.scan\n\n token_a = @program_d.tokens[0]\n token_b = @program_d.tokens[9]\n token_c = @program_d.tokens[10]\n token_d = @program_d.tokens[7]\n\n assert(token_a.type == :keyword, \"Expected :keyword at token 1\")\n assert(token_b.type == :number... | [
"0.6035371",
"0.60212356",
"0.5978892",
"0.5910247",
"0.5893974",
"0.583835",
"0.582868",
"0.5810676",
"0.5755712",
"0.5735606",
"0.57285106",
"0.57217795",
"0.57013834",
"0.569267",
"0.5649397",
"0.56404126",
"0.5623439",
"0.561856",
"0.5583744",
"0.557987",
"0.5579442",
"... | 0.57399994 | 9 |
create a new user and attempt sacing to db | def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
flash[:success] = "Welcome to Alpha Blog #{@user.username}"
redirect_to user_path(@user)
else
render 'new'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_user\n # first insert into user_secrets and use it's id in users table\n @user_secret = UserSecret.using_client_shard(client: @client).create!(login_salt: @login_salt_hash[:ciphertext_blob])\n\n password_e = User.using_client_shard(client: @client).get_encrypted_password(@password, @login... | [
"0.7746812",
"0.7712207",
"0.7708197",
"0.76976264",
"0.7585193",
"0.75761384",
"0.7561375",
"0.7534137",
"0.75081533",
"0.74844235",
"0.74702364",
"0.74645054",
"0.7442108",
"0.74376047",
"0.74239284",
"0.73906004",
"0.7385262",
"0.7383761",
"0.7359796",
"0.73583215",
"0.735... | 0.0 | -1 |
gets correct user using id parameter | def edit
require_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(id)\n @users[id]\n end",
"def get_user(users, id)\n user = users.select { |f| f[:id] == id }\n user.first\n end",
"def get_user_byid(id)\n # accept an id input parameter\n # use the User Model class to get the User associated with the `id` primary key\n # return the U... | [
"0.79455173",
"0.77175224",
"0.7713563",
"0.76962805",
"0.76552975",
"0.7649579",
"0.76190305",
"0.7600258",
"0.75919414",
"0.7586028",
"0.7579358",
"0.7553344",
"0.7525518",
"0.7518023",
"0.75111204",
"0.7496851",
"0.748225",
"0.7439714",
"0.74290985",
"0.7419004",
"0.741894... | 0.0 | -1 |
Used by edit action | def update
if @user.update(user_params)
flash[:success] = 'Account Updated'
redirect_to articles_path
else
render 'edit'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; e... | [
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"0.8403647",
"... | 0.0 | -1 |
Token valids for 4hours | def password_token_valid?
(updated_at + 4.hours) > Time.now.utc
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verification_token_valid?\n (self.verification_sent_at + 4.hours) > Time.now.utc\n end",
"def validate_token\n if self.transaction_token_created_at + 720.minutes > Time.now\n true\n else\n false\n end\n end",
"def token_validation\n if (!jwt_string.blank? && !(token.all? &:blank?... | [
"0.7320989",
"0.71379095",
"0.6878706",
"0.6839305",
"0.67913973",
"0.6763247",
"0.6733926",
"0.66980404",
"0.6687844",
"0.6488671",
"0.64213467",
"0.63297445",
"0.62762976",
"0.6251046",
"0.6133217",
"0.608702",
"0.60488105",
"0.59805405",
"0.59580535",
"0.5926393",
"0.59164... | 0.74236745 | 0 |
GET /tmps/1 GET /tmps/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_results\n case_id = params[:case_id]\n lab_external_id = params[:lab_id]\n consumer_id = get_consumer_id()\n lab = Lab.find_by(lab_external_id: lab_external_id, api_consumer_id: consumer_id)\n lab_id = lab.id.to_s\n tmp_file = File.join('Data/tmp/', lab_id, case_id + '.json')\n data = ... | [
"0.5919916",
"0.5790385",
"0.575375",
"0.5748227",
"0.5748227",
"0.57234687",
"0.56969523",
"0.56762975",
"0.5646738",
"0.55459386",
"0.55202496",
"0.5467141",
"0.5457296",
"0.5455727",
"0.5451637",
"0.54371244",
"0.53792876",
"0.5363716",
"0.53490543",
"0.5337781",
"0.531362... | 0.0 | -1 |
POST /tmps POST /tmps.json | def create
ret = false
begin
@tmp = set_tmp_data(:tmp, tmp_params)
ret = true
rescue => e
@tmp = get_tmp_data(:tmp)
@tmp.errors[:base] << "#{e.message}"
end
if ret
redirect_to tmp_steps_path
else
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n files = params[:files]\n\n files.each do |file|\n\n filename = file.original_filename\n\n # Rack uploads have `#tempfiles` and test uploads are Tempfile objects. More\n # investigation required.\n file = file.tempfile if file.respond_to?(:tempfile)\n\n UploadStore.creat... | [
"0.61608267",
"0.5780841",
"0.5711868",
"0.5533112",
"0.5396367",
"0.5384921",
"0.5346923",
"0.53458184",
"0.53438604",
"0.5303671",
"0.5293188",
"0.52861655",
"0.52771384",
"0.526519",
"0.52525705",
"0.5247393",
"0.5214781",
"0.5214781",
"0.52146626",
"0.5213793",
"0.5212685... | 0.54893255 | 4 |
PATCH/PUT /tmps/1 PATCH/PUT /tmps/1.json | def update
respond_to do |format|
@tmp = get_tmp_data(:tmp)
if set_tmp_data(:tmp, @tmp.data.merge(tmp_params))
format.html { redirect_to tmp_url, notice: 'User was successfully updated.' }
format.json { render :show, status: :ok, location: @user }
else
format.html { render ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes... | [
"0.62648606",
"0.6030491",
"0.5954387",
"0.5933187",
"0.59167755",
"0.5907735",
"0.58864236",
"0.58204174",
"0.5768199",
"0.57266027",
"0.56823915",
"0.5677198",
"0.5670844",
"0.5619772",
"0.56166935",
"0.5583489",
"0.55823946",
"0.55182344",
"0.5516121",
"0.55098456",
"0.550... | 0.5957188 | 2 |
Never trust parameters from the scary internet, only allow the white list through. | def tmp_params
params.require(:temporary_data).permit(:email, :password, :password_confirmation, :name, :twitter_username, :github_username, :website, :date_of_birth, :bio)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
helper methods go here! | def shift_elements(index)
while index < @length - 1
@cache[index] = @cache[index+1]
index += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def probers; end",
"def suivre; end",
"def weber; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def who_we_are\r\n end",
"def custom; end",
"def custom; end",
"def helpers; end",
"def helpers; end",
"def help... | [
"0.7287261",
"0.66014576",
"0.6562698",
"0.6280189",
"0.6234601",
"0.62198305",
"0.62198305",
"0.62198305",
"0.62198305",
"0.61928034",
"0.61432976",
"0.61432976",
"0.6137897",
"0.6137897",
"0.6137897",
"0.6112013",
"0.6112013",
"0.6097403",
"0.60813224",
"0.6008863",
"0.5990... | 0.0 | -1 |
The url is defined as the file's path with a leading slash. | def url
::File.join "/", path.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_url\n end",
"def url(options = {})\n file.path\n end",
"def path\n file.url\n end",
"def url_file_path\n return @url_file_path if @url_file_path\n url_parts = url.match /\\A[^:]+:\\/*[^\\/]+\\/(?<path_portion>.*)/\n url_parts = url.match /\\A\\/?(?<path_portion>.*... | [
"0.7938164",
"0.790021",
"0.78615147",
"0.7735383",
"0.75137097",
"0.75134087",
"0.749697",
"0.74387103",
"0.73466617",
"0.7324577",
"0.7309748",
"0.730688",
"0.7277144",
"0.7232647",
"0.7232647",
"0.7212703",
"0.7196718",
"0.7124926",
"0.7050403",
"0.7007574",
"0.6971733",
... | 0.8250454 | 0 |
arr = [0, 1, 5, 7] p bad_two_sum?(arr, 6) => should be true p bad_two_sum?(arr, 10) => should be false O(n log n) | def okay_two_sum?(array, target_sum)
sorted = array.sort #O(logn) (But isn't worst case here O(n^2)?)
i, j = 0, array.length - 1
while i < j #O(n)
case (array[i] + array[j]) <=> target_sum
when 0
return true
when -1
i += 1
when 1
j -= 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad_two_sum?(arr, target_sum) #O(n^2)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend",
"def bad_two_sum?(arr, target_sum)\n arr.length.times do |i|\n (arr.length - i - 1).times do |j|\n ... | [
"0.89130175",
"0.883197",
"0.88295484",
"0.881894",
"0.8803002",
"0.8788895",
"0.87006116",
"0.86985224",
"0.8690846",
"0.8642515",
"0.86356",
"0.862982",
"0.8601465",
"0.8531461",
"0.8523433",
"0.84908587",
"0.8426225",
"0.8351002",
"0.8329801",
"0.83189875",
"0.8295949",
... | 0.8173198 | 42 |
p okay_two_sum?(arr, 6) => should be true p okay_two_sum?(arr, 10) => should be false O(n) | def two_sum?(array, target_sum)
checked = {}
array.each_with_index do |ele, i|
return true if checked[target_sum - ele]
checked[ele] = i
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend",
"def bad_two_sum?(arr, target_sum) #O(n^2)\n (0...arr.length).each do |i|... | [
"0.8811891",
"0.8805038",
"0.8719995",
"0.8707814",
"0.8659688",
"0.8647976",
"0.858263",
"0.85574377",
"0.85486066",
"0.8513212",
"0.8478114",
"0.84764826",
"0.8472579",
"0.84674",
"0.84607",
"0.84529805",
"0.8419596",
"0.8418882",
"0.84093654",
"0.8381354",
"0.83721757",
... | 0.0 | -1 |
O(n) linear time O(n) linear space This can be easily adapted to also return the indices of the two numbers: | def two_sum_indices(arr, target_sum)
complements = {}
arr.each_with_index do |el, i|
complement, j = complements[target_sum - el] # these will both be nil if the complement doesn't exist
return [i, j] if complement
complements[el] = [el, i]
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_sum(nums, target)\n hsh = Hash.new\n nums.each_with_index do |n, i|\n hsh[n] = i+1\n end\n \n nums.each_with_index do |val, ind|\n second = target - val\n if hsh.include?(second) && nums.index(second) != ind\n return [ind+1, nums.index(second)+1]\n end\n end\nend",
"def two_sum(num... | [
"0.75109637",
"0.74781215",
"0.7475096",
"0.7425264",
"0.738871",
"0.73416317",
"0.7294862",
"0.7281225",
"0.7272917",
"0.7260437",
"0.72409856",
"0.71851856",
"0.71849954",
"0.71739817",
"0.7153491",
"0.7144469",
"0.7138454",
"0.7095283",
"0.708936",
"0.7088065",
"0.70727515... | 0.74097836 | 4 |
DELETE /jukeboxs/1 DELETE /jukeboxs/1.json | def destroy
@jukebox_song = JukeboxSong.find(params[:id])
jukebox_id = @jukebox_song.jukebox_id
@jukebox_song.destroy
@songs = JukeboxSong.songs_for_jukebox(jukebox_id)
respond_to do |format|
format.html {render :partial => "jukeboxes/playlist2", :locals => {:songs => @songs}}
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @box = Box.find(params[:id])\n @box.destroy\n\n respond_to do |format|\n format.html { redirect_to boxes_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @ruby.destroy\n respond_to do |format|\n ... | [
"0.69702613",
"0.6730877",
"0.6715159",
"0.6700156",
"0.6688042",
"0.6662826",
"0.66116196",
"0.6593941",
"0.6577695",
"0.65634304",
"0.655273",
"0.6522567",
"0.64860886",
"0.6482297",
"0.6479559",
"0.64697266",
"0.64600146",
"0.6456703",
"0.6450388",
"0.6447006",
"0.6439323"... | 0.6256627 | 78 |
Input provide 0 if the robot is over a black panel or 1 if the robot is over a white panel. First, it will output a value indicating the color to paint the panel the robot is over: 0 means to paint the panel black, and 1 means to paint the panel white. Second, it will output a value indicating the direction the robot s... | def init_white_panel!
grid.cells[grid.pos] = 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def colour move\n\tif move == \"X\"\n\t\treturn \"#{colourize(\"X\", \"human\")}\"\n\telsif move == \"O\"\n\t\treturn \"#{colourize(\"O\", \"cpu\")}\"\n\telse\n\t\treturn move\n\tend\nend",
"def forward_dir\n if @color == :black\n 1\n else\n -1\n end\n end",
"def f... | [
"0.5849568",
"0.56735647",
"0.5671868",
"0.5611724",
"0.55704254",
"0.555072",
"0.5490379",
"0.54449236",
"0.54280114",
"0.53744304",
"0.5353621",
"0.53488773",
"0.5344963",
"0.53416955",
"0.53292865",
"0.53105485",
"0.5288173",
"0.528681",
"0.5271583",
"0.5257442",
"0.524733... | 0.0 | -1 |
the json hash for this ClassGradeDTO | def to_jaxb_json_hash
_h = {}
_h['className'] = className.to_jaxb_json_hash unless className.nil?
_h['grade'] = grade.to_jaxb_json_hash unless grade.nil?
return _h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @_hash_\n end",
"def to_json\n\t\t\tself.instance_variable_hash\n\t\tend",
"def to_json\n return self.to_hash.to_json\n end",
"def serialize\n self.t... | [
"0.67425984",
"0.66754216",
"0.66754216",
"0.66649306",
"0.6650347",
"0.6625657",
"0.66184664",
"0.6612944",
"0.65661883",
"0.6490752",
"0.6478752",
"0.6429663",
"0.6429663",
"0.6429663",
"0.64233434",
"0.6409795",
"0.64042336",
"0.64042336",
"0.6402717",
"0.63963705",
"0.639... | 0.66079545 | 8 |
the json (string form) for this ClassGradeDTO | def to_json
to_jaxb_json_hash.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tojson\n\t\tend",
"def class_json\n clazz = @offering.clazz\n section = clazz.section && clazz.section.length > 0 ? clazz.section : nil\n section = section ? \" (#{section})\" : \"\"\n {\n name: clazz.name + section,\n students: @students\n .sort_by { |s| \"#{s.last_n... | [
"0.69526815",
"0.69253457",
"0.6787228",
"0.6764926",
"0.6764926",
"0.6741381",
"0.670019",
"0.66402113",
"0.6622636",
"0.6607142",
"0.65911794",
"0.65690917",
"0.65690917",
"0.65541965",
"0.6531444",
"0.652027",
"0.65041226",
"0.64871407",
"0.64815557",
"0.64741254",
"0.6472... | 0.0 | -1 |
initializes this ClassGradeDTO with a json hash | def init_jaxb_json_hash(_o)
if !_o['className'].nil?
_oa = _o['className']
if(_oa.is_a? Hash)
@className = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']
@className = String.from_json(_oa) unless _oa['@class']
elsif (_oa.is_a? Array)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize json_hash\n @json = json_hash\n super\n end",
"def initialize(hash_that_represents_json)\n\t\t@data = hash_that_represents_json\n\tend",
"def init_jaxb_json_hash(_o)\n if !_o['students'].nil?\n _oa = _o['students']\n if(_oa.is_a? Hash)\n @stud... | [
"0.66499406",
"0.6441068",
"0.63282746",
"0.607976",
"0.5953447",
"0.59171885",
"0.5908194",
"0.5905287",
"0.5881757",
"0.58616203",
"0.5813599",
"0.58068866",
"0.57944375",
"0.5777784",
"0.5776453",
"0.5753877",
"0.5733913",
"0.5712489",
"0.57007647",
"0.56951565",
"0.566576... | 0.67223966 | 0 |
the json hash for this StudentDTO | def to_jaxb_json_hash
_h = {}
_h['firstName'] = firstName.to_jaxb_json_hash unless firstName.nil?
_h['lastName'] = lastName.to_jaxb_json_hash unless lastName.nil?
_h['email'] = email.to_jaxb_json_hash unless email.nil?
_h['gpa'] = gpa.to_jaxb_json_hash unless gpa.nil?
if !grades.nil?... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fat_student_hash(student)\n HashWithIndifferentAccess.new(student.as_json({\n except: [\n :primary_phone,\n :primary_email,\n :student_address\n ]\n }).merge({\n has_photo: student.has_photo,\n discipline_incidents_count: student.most_recent_school_year_discipline... | [
"0.7239547",
"0.7114033",
"0.6980375",
"0.67623997",
"0.6705546",
"0.6705546",
"0.6705546",
"0.670346",
"0.670296",
"0.6657621",
"0.6604145",
"0.6596115",
"0.6549756",
"0.6549756",
"0.6508695",
"0.6490469",
"0.64386815",
"0.63953114",
"0.6337333",
"0.63266313",
"0.63158363",
... | 0.0 | -1 |
the json (string form) for this StudentDTO | def to_json
to_jaxb_json_hash.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_serialize\n end",
"def tojson\n\t\tend",
"def json\n {\"creation_date\" => @creation_date}\n end",
"def to_json\n JSON.dump ({\n :name => @name,\n :age => @age,\n :gender => @gender\n })\n end",
"def as_json\n\t\t{\n\t\t\t:id => self.id,... | [
"0.68692875",
"0.68264693",
"0.6768491",
"0.6728449",
"0.6670979",
"0.6665776",
"0.66024774",
"0.6595771",
"0.6586447",
"0.6559015",
"0.6551181",
"0.6551181",
"0.654527",
"0.65274405",
"0.6522712",
"0.6522712",
"0.6522685",
"0.65113544",
"0.6505498",
"0.64972425",
"0.6473548"... | 0.0 | -1 |
initializes this StudentDTO with a json hash | def init_jaxb_json_hash(_o)
if !_o['firstName'].nil?
_oa = _o['firstName']
if(_oa.is_a? Hash)
@firstName = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']
@firstName = String.from_json(_oa) unless _oa['@class']
elsif (_oa.is_a? Array)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_jaxb_json_hash(_o)\n if !_o['students'].nil?\n _oa = _o['students']\n if(_oa.is_a? Hash)\n @students = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']\n @students = Abogner::OtusChallenge::Rest::Student::Dto::StudentDTO.from_json(_oa) unl... | [
"0.6993958",
"0.6795601",
"0.6605711",
"0.6565968",
"0.65620553",
"0.6535042",
"0.64048386",
"0.6404366",
"0.63499457",
"0.62985927",
"0.6236501",
"0.6140192",
"0.6114163",
"0.6080529",
"0.6024885",
"0.5990569",
"0.598876",
"0.59752965",
"0.5916596",
"0.59150356",
"0.5907141"... | 0.0 | -1 |
the json hash for this StudentListDTO | def to_jaxb_json_hash
_h = {}
if !students.nil?
_ha = Array.new
students.each { | _item | _ha.push _item.to_jaxb_json_hash }
_h['students'] = _ha
end
return _h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n @list\n end",
"def fat_student_hash(student)\n HashWithIndifferentAccess.new(student.as_json({\n except: [\n :primary_phone,\n :primary_email,\n :student_address\n ]\n }).merge({\n has_photo: student.has_photo,\n discipline_incidents_count: stu... | [
"0.6671721",
"0.66370606",
"0.65258217",
"0.65003085",
"0.6499006",
"0.6397841",
"0.6397841",
"0.6397841",
"0.63477266",
"0.63051444",
"0.6285648",
"0.62835014",
"0.62770414",
"0.62770414",
"0.6269445",
"0.62457293",
"0.6235827",
"0.6217091",
"0.62057924",
"0.6135965",
"0.606... | 0.668528 | 0 |
the json (string form) for this StudentListDTO | def to_json
to_jaxb_json_hash.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tojson\n\t\tend",
"def json_serialize\n end",
"def json\n {\"creation_date\" => @creation_date}\n end",
"def serialize\n JSON.generate(to_h)\n end",
"def to_json\n\n end",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def as_j... | [
"0.6838153",
"0.6824372",
"0.6665747",
"0.65456903",
"0.6519363",
"0.64518964",
"0.64518964",
"0.6439105",
"0.6439105",
"0.6412598",
"0.6410241",
"0.63510334",
"0.63415784",
"0.63330084",
"0.6295943",
"0.62731445",
"0.6270637",
"0.62475675",
"0.62404484",
"0.62105",
"0.620748... | 0.0 | -1 |
initializes this StudentListDTO with a json hash | def init_jaxb_json_hash(_o)
if !_o['students'].nil?
_oa = _o['students']
if(_oa.is_a? Hash)
@students = EnunciateHelpers::LAMB_CLASS_AWARE.call(_oa) if _oa['@class']
@students = Abogner::OtusChallenge::Rest::Student::Dto::StudentDTO.from_json(_oa) unless _oa['@... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize json_hash\n @json = json_hash\n super\n end",
"def initialize(student_hash)\n student_hash.each {|key,value| self.send((\"#{key}=\"),value)}\n @@all << self\n end",
"def initialize(student_hash)\n # @name = student_hash[:name]\n # @location = student_hash[:locatio... | [
"0.64867854",
"0.6436487",
"0.6404627",
"0.6374436",
"0.6347818",
"0.6168598",
"0.6113657",
"0.60842663",
"0.60408777",
"0.59895635",
"0.5980497",
"0.59700793",
"0.58297294",
"0.5827018",
"0.58005553",
"0.57807225",
"0.5701502",
"0.56863827",
"0.5674254",
"0.5665866",
"0.5662... | 0.68433845 | 0 |
Reads the subject into the object. Returns nil if resource does not validate, given its position | def resolve(resource, position: :subject)
case position
when :subject
RDF::Literal(as_literal(resource.first).to_s, language: resource.last.to_s.to_sym)
when :object
return nil unless resource.literal? || resource.variable?
resource
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subject\n @subject = Subject.find_by_id(params[:id])\n return if check_nil_object(@subject)\n end",
"def validate_subject\n if @subject.nil?\n puts \"No subject, skipping\"\n raise StandardError, \"No subject\"\n else\n @title.strip\n end\n end",
"def subject\n subjec... | [
"0.58130735",
"0.5776922",
"0.57728875",
"0.54074574",
"0.53619057",
"0.53556657",
"0.5235215",
"0.51998866",
"0.51889426",
"0.51186645",
"0.51042885",
"0.5081105",
"0.5074272",
"0.50203353",
"0.50120384",
"0.49949032",
"0.49898398",
"0.49831372",
"0.4953675",
"0.49355358",
"... | 0.53039795 | 6 |
GET /groups GET /groups.xml | def index
@groups = SuperSimpleCms::Group.find(:all, :order=>:position)
respond_to do |format|
format.html { render :template => 'admin/groups/index' }
format.xml { render :xml => @groups }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_use... | [
"0.7711083",
"0.7711083",
"0.7465078",
"0.7379438",
"0.7379438",
"0.7292179",
"0.7227291",
"0.7186587",
"0.71560854",
"0.7112754",
"0.6978677",
"0.6882048",
"0.6879026",
"0.6879026",
"0.6853823",
"0.6840086",
"0.6836807",
"0.68203634",
"0.6809281",
"0.6798404",
"0.67801327",
... | 0.68955135 | 11 |
GET /groups/1 GET /groups/1.xml | def show
@group = SuperSimpleCms::Group.find(params[:id])
respond_to do |format|
format.html { render :template=>'admin/groups/show' }
format.js { render :template=>'admin/groups/show', :layout=>false}
format.xml { render :xml => @group }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_use... | [
"0.745734",
"0.745734",
"0.7347871",
"0.727876",
"0.727876",
"0.7197428",
"0.7168664",
"0.7168664",
"0.7099385",
"0.70444334",
"0.7025216",
"0.70193565",
"0.70193565",
"0.70193565",
"0.70193565",
"0.70193565",
"0.69452775",
"0.6943903",
"0.69397503",
"0.69138265",
"0.68579435... | 0.63618225 | 63 |
GET /groups/new GET /groups/new.xml | def new
@group = SuperSimpleCms::Group.new
respond_to do |format|
format.html {render :template=>'admin/groups/new'}
format.js {render :template=>'admin/groups/new', :layout=>false}
format.xml { render :xml => @group }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @group = Group.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def new\n @group = Group.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end... | [
"0.7770431",
"0.7769207",
"0.7769207",
"0.7769207",
"0.7769207",
"0.7769207",
"0.7769207",
"0.7769207",
"0.7769207",
"0.7769207",
"0.7675987",
"0.76748323",
"0.7673685",
"0.7650189",
"0.7648868",
"0.7648868",
"0.764517",
"0.7507692",
"0.7494768",
"0.7486554",
"0.7481777",
"... | 0.7257294 | 28 |
POST /groups POST /groups.xml | def create
@group = SuperSimpleCms::Group.new(params[:group])
respond_to do |format|
if @group.save
flash[:notice] = 'Group was successfully created.'
format.html { redirect_to super_simple_group_path(@group) }
format.js { redirect_to formatted_super_simple_group_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(groups)\n groups_params = groups.inject({}) do |params, (k, v)|\n params[\"groups[#{k}]\"] = 1\n params\n end\n\n response = RouteNGN.put self.class.base_url, {:id => self.id}.merge!(groups_params)\n response.success?\n end",
"def create\n #logger.info \"Post parameters... | [
"0.660965",
"0.6602641",
"0.6588023",
"0.6588023",
"0.6567241",
"0.6546185",
"0.6518592",
"0.63975435",
"0.6392506",
"0.6383147",
"0.63828105",
"0.6363887",
"0.6356866",
"0.6355277",
"0.6355277",
"0.6355277",
"0.6323264",
"0.6296784",
"0.6214893",
"0.61911434",
"0.6170261",
... | 0.5786038 | 94 |
PUT /groups/1 PUT /groups/1.xml | def update
@group = SuperSimpleCms::Group.find(params[:id])
respond_to do |format|
if @group.update_attributes(params[:group])
flash[:notice] = 'Group was successfully updated.'
format.html { redirect_to super_simple_group_path(@group) }
format.js { redirect_to forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n logger.info \"Put parameters: #{params.to_json}\"\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def update\n \n @group = Group.find(... | [
"0.6685341",
"0.66725194",
"0.66642857",
"0.66642857",
"0.664555",
"0.6640031",
"0.6640031",
"0.6640031",
"0.6640031",
"0.6640031",
"0.6640031",
"0.6574576",
"0.65679026",
"0.6565279",
"0.6562684",
"0.654085",
"0.6539202",
"0.6516348",
"0.65080595",
"0.6467505",
"0.6426014",
... | 0.630189 | 27 |
DELETE /groups/1 DELETE /groups/1.xml | def destroy
@group = SuperSimpleCms::Group.find(params[:id])
respond_to do |format|
if SuperSimpleCms::Group.find(:all).length > 1
@group.destroy
format.html { redirect_to(super_simple_groups_url) }
format.js { head :ok }
format.xml { head :ok }
else
forma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.find(params[:id])\n @group.destroy\n\n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n Group.destroy(params[:id])\n\n respond_to do ... | [
"0.75225985",
"0.7469291",
"0.74164146",
"0.74164146",
"0.74083424",
"0.7387716",
"0.7384185",
"0.7384185",
"0.7384185",
"0.7384185",
"0.7384185",
"0.7384185",
"0.7384185",
"0.7384185",
"0.7371072",
"0.72700936",
"0.72526824",
"0.7237537",
"0.71858174",
"0.7167465",
"0.716576... | 0.6697366 | 90 |
Override strong_params for `build` account. | def account_params_for_build
super + [{ account_number_parts: NufsAccount.account_number_field_names }]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_params_for_build\n self.class.common_permitted_account_params + [:account_number]\n end",
"def account_params\n params.require(:account).permit!\n end",
"def account_params\n params.require(:account).permit!\n end",
"def account_params_for_update\n self.class.common_permitted_a... | [
"0.7387636",
"0.6815538",
"0.68102676",
"0.6657144",
"0.6623749",
"0.65301764",
"0.65020645",
"0.6481556",
"0.6329845",
"0.62561417",
"0.62506235",
"0.6245612",
"0.6244902",
"0.62369764",
"0.6236657",
"0.623008",
"0.6218363",
"0.6217502",
"0.619934",
"0.6198704",
"0.6198231",... | 0.63507026 | 8 |
Hooks into superclass's `build` method. | def after_build
load_account_components
account.set_expires_at
# This is kind of a weird message to be adding here (the message is about)
# not finding the fund, dept, activity, etc, but leaving here to preserve
# existing behavior
account.errors.add(:base, :missing_expires_at) unless account.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(**)\n raise NotImplementedError\n end",
"def build\r\n raise \"Not implemented\"\r\n end",
"def build; end",
"def build\n end",
"def build\r\n end",
"def build\r\n end",
"def build(*args)\n raise \"Method 'build' not implemented for #{self.class.name}\"\n end",
... | [
"0.7709913",
"0.7407432",
"0.72963333",
"0.72804874",
"0.72319645",
"0.72319645",
"0.7207465",
"0.71956",
"0.7163267",
"0.70825946",
"0.68906856",
"0.68360066",
"0.6768686",
"0.669469",
"0.6627663",
"0.66187775",
"0.66069263",
"0.652246",
"0.6495069",
"0.6495069",
"0.6462549"... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.