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 |
|---|---|---|---|---|---|---|
Display the type of mission in underscore | def mission_type
type.underscore
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def missionName \n \"missionName\" \n end",
"def mission_type(mission)\n case mission[\"type\"]\n when /\\A(neighbor|our|empty)_provinces\\z/, /\\A(threat|rival|neighbor|elector)_countries\\z/, /\\A(rivals|threats)_rivals\\z/\n \"FROM\"\n when \"country\"\n \"ROOT\"\n else\n ra... | [
"0.6996433",
"0.66281265",
"0.65444034",
"0.6429527",
"0.63833696",
"0.63833696",
"0.63160163",
"0.6303995",
"0.61983776",
"0.61460847",
"0.60916114",
"0.6066946",
"0.6057695",
"0.60184413",
"0.59847516",
"0.59784216",
"0.5946182",
"0.5910264",
"0.5890486",
"0.5886798",
"0.58... | 0.83988845 | 0 |
FIXME: fix kung_figure to do such things simpler | def get_options
{
:cssOptimize => cssOptimize,
:optimize=> optimize,
:cssImportIgnore=>cssImportIgnore,
:internStrings=>internStrings
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def figures\n return 3\n end",
"def t\n @figure_maker\n end",
"def figures\n return 2\n end",
"def figures\n return 2\n end",
"def graphicsmagick?; end",
"def begin_figure\n # do nothing\n end",
"def plot; end",
"def draw_cutters cutters\r\n cutters.each do |cutter|\r\n... | [
"0.60742885",
"0.5986729",
"0.59218186",
"0.59218186",
"0.57832354",
"0.57090575",
"0.5623377",
"0.54233783",
"0.5373971",
"0.52976704",
"0.52889675",
"0.5279703",
"0.5256407",
"0.5228467",
"0.5214086",
"0.51820874",
"0.5175107",
"0.51747406",
"0.51643425",
"0.51489747",
"0.5... | 0.0 | -1 |
input: ['cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams', 'scream'] => output: [["cars", "racs", "scar"], ["four"], ["for"], ["potatoes"], ["creams", "scream"]] HINT: you can quickly tell if two words are anagrams by sorting their letters, keeping in mind that upper vs lowercase doesn't matter | def combine_anagrams(words)
#
hash = {}
words.each{ |word|
key = word.downcase.split(//).sort
hash[key] = (hash[key] || []) + [word]
}
ans = []
hash.map{ |k, v|
ans += v
}
ans
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_anagrams(words)\n Array anagrams = []\n words.each {|x|\n flag = false\n anagrams.collect {|y|\n if x.downcase.chars.to_a.sort == y[0].downcase.chars.to_a.sort then\n y << x\n flag = true\n break\n end\n }\n ... | [
"0.85689706",
"0.8428664",
"0.83914363",
"0.8368178",
"0.83209956",
"0.83119404",
"0.82922345",
"0.8241497",
"0.8228095",
"0.8214223",
"0.81857216",
"0.8181703",
"0.8172637",
"0.81265473",
"0.8123622",
"0.8105459",
"0.8096058",
"0.80754554",
"0.80746084",
"0.8053887",
"0.8050... | 0.78263485 | 58 |
GET /application_exprs/1 GET /application_exprs/1.xml | def show
@application_expr = ApplicationExpr.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @application_expr }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @application_expr = ApplicationExpr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @application_expr }\n end\n end",
"def show\n @expression = Expression.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb... | [
"0.6212146",
"0.58112854",
"0.57605636",
"0.5658207",
"0.5626504",
"0.5594703",
"0.55931896",
"0.557089",
"0.5567381",
"0.5549139",
"0.5511722",
"0.5496485",
"0.5477095",
"0.5475403",
"0.5474893",
"0.5474893",
"0.54572475",
"0.54470253",
"0.54412025",
"0.5433114",
"0.5387162"... | 0.7172296 | 0 |
GET /application_exprs/new GET /application_exprs/new.xml | def new
@application_expr = ApplicationExpr.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @application_expr }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @expression = Expression.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @expression }\n end\n end",
"def create\n @application_expr = ApplicationExpr.new(params[:application_expr])\n\n respond_to do |format|\n if @application_ex... | [
"0.69537896",
"0.6953562",
"0.6342212",
"0.6301874",
"0.6299016",
"0.6299016",
"0.6299016",
"0.6282477",
"0.6228813",
"0.6206638",
"0.61975974",
"0.6186536",
"0.6172394",
"0.6153501",
"0.6144902",
"0.6141877",
"0.6126337",
"0.61124116",
"0.60947293",
"0.60932904",
"0.60787207... | 0.7979148 | 0 |
POST /application_exprs POST /application_exprs.xml | def create
@application_expr = ApplicationExpr.new(params[:application_expr])
respond_to do |format|
if @application_expr.save
flash[:notice] = 'ApplicationExpr was successfully created.'
format.html { redirect_to(@application_expr) }
format.xml { render :xml => @application_expr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend",
"def apply(application, params={})\n response = @http.post(\"/application/submit\", application.to_xml)\n check_status(respons... | [
"0.618973",
"0.57820064",
"0.56368273",
"0.5594044",
"0.5057584",
"0.50313276",
"0.4996282",
"0.4994205",
"0.4969017",
"0.49554572",
"0.49298713",
"0.48968256",
"0.48859292",
"0.48858577",
"0.48662728",
"0.48294616",
"0.48294616",
"0.48185182",
"0.48115885",
"0.4809601",
"0.4... | 0.6499778 | 0 |
PUT /application_exprs/1 PUT /application_exprs/1.xml | def update
@application_expr = ApplicationExpr.find(params[:id])
respond_to do |format|
if @application_expr.update_attributes(params[:application_expr])
flash[:notice] = 'ApplicationExpr was successfully updated.'
format.html { redirect_to(@application_expr) }
format.xml { head ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @expression = Expression.find(params[:id])\n\n respond_to do |format|\n if @expression.update_attributes(params[:expression])\n flash[:notice] = 'Ex... | [
"0.58364266",
"0.5764041",
"0.56704104",
"0.5602936",
"0.55575883",
"0.55405",
"0.54435164",
"0.5435964",
"0.5399579",
"0.53859997",
"0.5272515",
"0.5214948",
"0.5200879",
"0.5186635",
"0.5176999",
"0.51766104",
"0.5174854",
"0.51597977",
"0.5135416",
"0.5121543",
"0.5116119"... | 0.6881809 | 0 |
DELETE /application_exprs/1 DELETE /application_exprs/1.xml | def destroy
@application_expr = ApplicationExpr.find(params[:id])
@application_expr.destroy
respond_to do |format|
format.html { redirect_to(application_exprs_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @expression = Expression.find(params[:id])\n @expression.destroy\n\n respond_to do |format|\n format.html { redirect_to(expressions_url) }\n format.xml { head :ok }\n end\n end",
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_var... | [
"0.6418078",
"0.6393035",
"0.6202869",
"0.60661215",
"0.59538627",
"0.5920408",
"0.5917653",
"0.5908683",
"0.5827746",
"0.5752535",
"0.5751531",
"0.5751531",
"0.57501054",
"0.57226974",
"0.5722205",
"0.5714112",
"0.57062334",
"0.5704628",
"0.56942916",
"0.56942916",
"0.567807... | 0.72303134 | 0 |
The task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters. | def english(str)
result = []
arr = str.split(' ')
result << arr.uniq.group_by { |v| arr.count(v) }.max.last.join
result << arr.max_by{ |x| x.length }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_frequent_word(string)\n hash = {}\n splitstring = string.split(\" \")\n splitstring.each {|element| element.downcase!}\n p splitstring\n splitstring.each{|element| if hash[element].nil?\n hash[element]=1\n else\n ... | [
"0.7678489",
"0.76606804",
"0.7562951",
"0.7533843",
"0.75292933",
"0.7515354",
"0.75024694",
"0.74421465",
"0.742471",
"0.73213094",
"0.73160744",
"0.7305145",
"0.7297804",
"0.7297208",
"0.7269722",
"0.7255456",
"0.72520155",
"0.7231393",
"0.7214727",
"0.718554",
"0.71626407... | 0.7073627 | 27 |
before_filter :email_address_uniqueness_validation, :only => ['subscribe'] | def index
#@page = Page.find_by_slug('home') || Page.first(:conditions => {:root => true})
#render '/pages/show'
if cookies[:first_time_visit]
redirect_to courses_path
return
else
cookies[:first_time_visit] = {:value => Time.now.to_s, :expires => 1.year.from_now }
redirect_to '/l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # look for subscriber with this email already\n @skip_flash = true\n found = Subscriber.find_by_address(params[:subscriber][:address])\n if found\n flash[:error] = \"The email address \\\"#{params[:subscriber][:address]}\\\" has already been subscribed.\"\n else\n @subscriber ... | [
"0.6482214",
"0.6468008",
"0.62503564",
"0.62232757",
"0.61885995",
"0.61863583",
"0.6154143",
"0.6089589",
"0.60695904",
"0.6045279",
"0.6026677",
"0.6021687",
"0.601631",
"0.60051423",
"0.59591615",
"0.593449",
"0.58890253",
"0.58890253",
"0.5870756",
"0.58532536",
"0.58446... | 0.0 | -1 |
Test reading old ways. | def test_history_visible
# check that a visible way is returned properly
get :history, :params => { :id => create(:way, :with_history).id }
assert_response :success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def closed_read?()\n #This is a stub, used for indexing\n end",
"def old?\n\t\t@mutex.synchronize {\n\t\t\t@old\n\t\t}\n\tend",
"def closed_read?() end",
"def available_for_read?; end",
"def test_read_guard\n song_file = File.expand_path('../song.txt', __FILE__)\n [\"IO.read '#{song_file}'\... | [
"0.60646045",
"0.5958724",
"0.58637446",
"0.5786682",
"0.57635415",
"0.5675468",
"0.5665371",
"0.5661999",
"0.56118923",
"0.55417174",
"0.55417174",
"0.55417174",
"0.55213195",
"0.54940706",
"0.5481014",
"0.54712427",
"0.5458712",
"0.5447552",
"0.54431313",
"0.54431313",
"0.5... | 0.0 | -1 |
check that we can retrieve versions of a way | def test_version
way = create(:way, :with_history)
used_way = create(:way, :with_history)
create(:relation_member, :member => used_way)
way_with_versions = create(:way, :with_history, :version => 4)
create(:way_tag, :way => way)
create(:way_tag, :way => used_way)
create(:way_tag, :way => wa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_version\n check_current_version(current_ways(:visible_way).id)\n check_current_version(current_ways(:used_way).id)\n check_current_version(current_ways(:way_with_versions).id)\n end",
"def test_history_equals_versions\n check_history_equals_versions(current_ways(:visible_way).id)\n check... | [
"0.7502715",
"0.6754164",
"0.66459674",
"0.6616179",
"0.642531",
"0.63920003",
"0.6328418",
"0.6207519",
"0.60832155",
"0.60034543",
"0.59868217",
"0.5982202",
"0.59800667",
"0.5960881",
"0.5911098",
"0.5849901",
"0.58334",
"0.58049107",
"0.5795501",
"0.57936954",
"0.57749254... | 0.6053235 | 9 |
check that returned history is the same as getting all versions of a way from the api. | def test_history_equals_versions
way = create(:way, :with_history)
used_way = create(:way, :with_history)
create(:relation_member, :member => used_way)
way_with_versions = create(:way, :with_history, :version => 4)
check_history_equals_versions(way.id)
check_history_equals_versions(used_way.id)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_history_equals_versions\n check_history_equals_versions(current_ways(:visible_way).id)\n check_history_equals_versions(current_ways(:used_way).id)\n check_history_equals_versions(current_ways(:way_with_versions).id)\n end",
"def check_history_equals_versions(way_id)\n get :history, :id => w... | [
"0.77507603",
"0.74381626",
"0.74089503",
"0.65260136",
"0.64890844",
"0.6480415",
"0.63770485",
"0.63307524",
"0.6293751",
"0.62274396",
"0.622207",
"0.62169945",
"0.6143395",
"0.6071247",
"0.6045029",
"0.6036728",
"0.5994562",
"0.59872663",
"0.59363395",
"0.59363395",
"0.59... | 0.704809 | 3 |
test the redaction of an old version of a way, while not being authorised. | def test_redact_way_unauthorised
way = create(:way, :with_history, :version => 4)
way_v3 = way.old_ways.find_by(:version => 3)
do_redact_way(way_v3, create(:redaction))
assert_response :unauthorized, "should need to be authenticated to redact."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_version_redacted\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n get :version, :params => { :id => way_v1.way_id, :version => way_v1.version }\n assert_response :forbidden, \"Redacted way shouldn't be... | [
"0.77962375",
"0.7673122",
"0.7561234",
"0.74805117",
"0.746397",
"0.7299842",
"0.71363133",
"0.70303833",
"0.69272786",
"0.61240536",
"0.6041161",
"0.60003287",
"0.5898755",
"0.56868094",
"0.5676678",
"0.5631221",
"0.5573468",
"0.55632997",
"0.5546791",
"0.55428016",
"0.5528... | 0.7979149 | 0 |
test the redaction of an old version of a way, while being authorised as a normal user. | def test_redact_way_normal_user
basic_authorization create(:user).email, "test"
way = create(:way, :with_history, :version => 4)
way_v3 = way.old_ways.find_by(:version => 3)
do_redact_way(way_v3, create(:redaction))
assert_response :forbidden, "should need to be moderator to redact."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to be authenticated to redact.\"\n end",
"def test_version_redacted\n way... | [
"0.8033165",
"0.79121006",
"0.7872581",
"0.76405567",
"0.76303625",
"0.74932915",
"0.7240351",
"0.71002066",
"0.69710773",
"0.6090892",
"0.59209573",
"0.5875313",
"0.58239555",
"0.5822186",
"0.5721914",
"0.5654402",
"0.55734164",
"0.55734164",
"0.5566649",
"0.5524464",
"0.549... | 0.79667634 | 1 |
test that, even as moderator, the current version of a way can't be redacted. | def test_redact_way_current_version
basic_authorization create(:moderator_user).email, "test"
way = create(:way, :with_history, :version => 4)
way_latest = way.old_ways.last
do_redact_way(way_latest, create(:redaction))
assert_response :bad_request, "shouldn't be OK to redact current version as mod... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unredact_way_moderator\n moderator_user = create(:moderator_user)\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n basic_authorization moderator_user.email, \"test\"\n\n post :redact, :params => { :... | [
"0.7170043",
"0.7166648",
"0.715914",
"0.70923173",
"0.69068766",
"0.6894393",
"0.68494433",
"0.672256",
"0.61311316",
"0.61120224",
"0.6085789",
"0.6023511",
"0.59643275",
"0.59565",
"0.5952385",
"0.5943402",
"0.5890697",
"0.58667916",
"0.58640856",
"0.5818492",
"0.5810378",... | 0.7332776 | 0 |
test that redacted ways aren't visible, regardless of authorisation except as moderator... | def test_version_redacted
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
get :version, :params => { :id => way_v1.way_id, :version => way_v1.version }
assert_response :forbidden, "Redacted way shouldn't be visible via... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unredact_way_normal_user\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n basic_authorization create(:user).email, \"test\"\n\n post :redact, :params => { :id => way_v1.way_id, :version => way_v1.versi... | [
"0.7230943",
"0.71947366",
"0.7095296",
"0.6971271",
"0.683786",
"0.6592876",
"0.6552571",
"0.64715135",
"0.646752",
"0.6426068",
"0.6420835",
"0.6343499",
"0.63382816",
"0.6303942",
"0.6290644",
"0.6267942",
"0.6256663",
"0.6232863",
"0.6178737",
"0.6171115",
"0.6153828",
... | 0.6564654 | 6 |
test that redacted ways aren't visible in the history | def test_history_redacted
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
get :history, :params => { :id => way_v1.way_id }
assert_response :success, "Redaction shouldn't have stopped history working."
assert_selec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_false_when_history_prevents_en_passant\n # TODO\n end",
"def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to ... | [
"0.70671666",
"0.6803142",
"0.66778195",
"0.6624665",
"0.64899224",
"0.6455371",
"0.6369667",
"0.6310871",
"0.6264107",
"0.61866343",
"0.61604375",
"0.58604",
"0.5789878",
"0.5776005",
"0.5765333",
"0.5686443",
"0.56617415",
"0.5611779",
"0.56089574",
"0.55509484",
"0.5527895... | 0.7449184 | 0 |
test the redaction of an old version of a way, while being authorised as a moderator. | def test_redact_way_moderator
way = create(:way, :with_history, :version => 4)
way_v3 = way.old_ways.find_by(:version => 3)
basic_authorization create(:moderator_user).email, "test"
do_redact_way(way_v3, create(:redaction))
assert_response :success, "should be OK to redact old version as moderator.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_redact_way_current_version\n basic_authorization create(:moderator_user).email, \"test\"\n way = create(:way, :with_history, :version => 4)\n way_latest = way.old_ways.last\n\n do_redact_way(way_latest, create(:redaction))\n assert_response :bad_request, \"shouldn't be OK to redact current ... | [
"0.8189737",
"0.7883215",
"0.75987875",
"0.75292474",
"0.7483012",
"0.74509907",
"0.7316512",
"0.6995696",
"0.65755713",
"0.5634904",
"0.56195086",
"0.560643",
"0.5525665",
"0.5466188",
"0.54428273",
"0.5431477",
"0.5404308",
"0.53670233",
"0.53545755",
"0.5338001",
"0.533275... | 0.75553226 | 3 |
testing that if the moderator drops auth, he can't see the redacted stuff any more. | def test_redact_way_is_redacted
way = create(:way, :with_history, :version => 4)
way_v3 = way.old_ways.find_by(:version => 3)
basic_authorization create(:moderator_user).email, "test"
do_redact_way(way_v3, create(:redaction))
assert_response :success, "should be OK to redact old version as moderato... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unredact_way_normal_user\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n basic_authorization create(:user).email, \"test\"\n\n post :redact, :params => { :id => way_v1.way_id, :version => way_v1.versi... | [
"0.6567787",
"0.6538547",
"0.6495184",
"0.63925064",
"0.6387277",
"0.6280796",
"0.62231785",
"0.61792094",
"0.6141864",
"0.6132131",
"0.61283755",
"0.6120559",
"0.6105496",
"0.60881823",
"0.60825634",
"0.6046493",
"0.6024004",
"0.60220844",
"0.59964186",
"0.5981748",
"0.59768... | 0.5864814 | 28 |
test the unredaction of an old version of a way, while not being authorised. | def test_unredact_way_unauthorised
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }
assert_response :unauthorized, "should need to be authent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to be authenticated to redact.\"\n end",
"def test_version_redacted\n way... | [
"0.7574344",
"0.7242024",
"0.7221315",
"0.68751556",
"0.6810728",
"0.67724496",
"0.6668766",
"0.626724",
"0.6178674",
"0.6006852",
"0.5880644",
"0.573227",
"0.56894827",
"0.5637376",
"0.5617718",
"0.559375",
"0.5590608",
"0.5565837",
"0.5550879",
"0.55262226",
"0.55170643",
... | 0.7430961 | 1 |
test the unredaction of an old version of a way, while being authorised as a normal user. | def test_unredact_way_normal_user
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
basic_authorization create(:user).email, "test"
post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }
asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_redact_way_unauthorised\n way = create(:way, :with_history, :version => 4)\n way_v3 = way.old_ways.find_by(:version => 3)\n\n do_redact_way(way_v3, create(:redaction))\n assert_response :unauthorized, \"should need to be authenticated to redact.\"\n end",
"def test_unredact_way_unauthorised... | [
"0.76950175",
"0.75404155",
"0.73959833",
"0.7300002",
"0.70885175",
"0.6929247",
"0.67946625",
"0.6374641",
"0.6276902",
"0.5726859",
"0.57020193",
"0.570056",
"0.5676805",
"0.56325155",
"0.560316",
"0.55980456",
"0.5558411",
"0.5524559",
"0.5503341",
"0.54999477",
"0.549945... | 0.75988746 | 1 |
test the unredaction of an old version of a way, while being authorised as a moderator. | def test_unredact_way_moderator
moderator_user = create(:moderator_user)
way = create(:way, :with_history, :version => 2)
way_v1 = way.old_ways.find_by(:version => 1)
way_v1.redact!(create(:redaction))
basic_authorization moderator_user.email, "test"
post :redact, :params => { :id => way_v1.wa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unredact_way_normal_user\n way = create(:way, :with_history, :version => 2)\n way_v1 = way.old_ways.find_by(:version => 1)\n way_v1.redact!(create(:redaction))\n\n basic_authorization create(:user).email, \"test\"\n\n post :redact, :params => { :id => way_v1.way_id, :version => way_v1.versi... | [
"0.7618157",
"0.7412753",
"0.7305275",
"0.7281943",
"0.7246833",
"0.6894155",
"0.68637514",
"0.67888206",
"0.60273665",
"0.59882015",
"0.5745012",
"0.5741967",
"0.56612974",
"0.56606907",
"0.5614848",
"0.55598617",
"0.5526578",
"0.55122226",
"0.5483684",
"0.54188484",
"0.5404... | 0.72975904 | 3 |
check that the current version of a way is equivalent to the version which we're getting from the versions call. | def check_current_version(way_id)
# get the current version
current_way = with_controller(WayController.new) do
get :read, :params => { :id => way_id }
assert_response :success, "can't get current way #{way_id}"
Way.from_xml(@response.body)
end
assert_not_nil current_way, "getting way ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_current_version(way_id)\n # get the current version\n current_way = with_controller(WayController.new) do\n get :read, :id => way_id\n assert_response :success, \"can't get current way #{way_id}\"\n Way.from_xml(@response.body)\n end\n assert_not_nil current_way, \"getting way ... | [
"0.72277457",
"0.72135246",
"0.6823471",
"0.62561774",
"0.6225652",
"0.62078786",
"0.62071085",
"0.60220426",
"0.60084313",
"0.60077524",
"0.59982747",
"0.5911423",
"0.59083784",
"0.58934605",
"0.58671486",
"0.5866001",
"0.581952",
"0.58079165",
"0.5795183",
"0.57509845",
"0.... | 0.719219 | 2 |
look at all the versions of the way in the history and get each version from the versions call. check that they're the same. | def check_history_equals_versions(way_id)
get :history, :params => { :id => way_id }
assert_response :success, "can't get way #{way_id} from API"
history_doc = XML::Parser.string(@response.body).parse
assert_not_nil history_doc, "parsing way #{way_id} history failed"
history_doc.find("//osm/way").e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history\n \treturn self.study_versions.to_a.sort_by{|x| x.version}\n end",
"def versions\n link = data.xpath(\"at:link[@rel = 'version-history']/@href\", NS::COMBINED)\n if link = link.first\n Collection.new(repository, link) # Problem: does not in fact use self\n else\n # The ... | [
"0.70815676",
"0.6985401",
"0.6951835",
"0.6780071",
"0.66356957",
"0.6613331",
"0.6608946",
"0.65634996",
"0.6503454",
"0.64857525",
"0.6477453",
"0.64685947",
"0.645282",
"0.6439572",
"0.64378804",
"0.6434911",
"0.6393516",
"0.63793486",
"0.63674164",
"0.6339389",
"0.632478... | 0.66241306 | 5 |
10001st prime Problem 7 By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? Code now optimized to run everything as a method, thus enabling user to find ANY given prime. Code also runs even faster, since the size of the Sieve of Erotost... | def is_prime(number)
if number == 1
return true
end
2.upto(number) do |x|
if (number % x == 0) && (number != x)
return false
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def p7\n\tprimes = [2]\n\t(1...10001).each do\n\t\tprime = next_prime(primes[-1])\n\t\tprimes << prime\n\tend\n\tprimes[-1]\nend",
"def eratosthenes_sieve(nth_prime)\n top = nth_prime * 10\n # this is really kludgy, you might have to increase 10 if you want\n # nth primes above 10k. It seems to work fine for ... | [
"0.77551794",
"0.76860666",
"0.7441039",
"0.74373513",
"0.73510545",
"0.734153",
"0.73055816",
"0.73027664",
"0.7267048",
"0.7246523",
"0.7224967",
"0.7218241",
"0.7200904",
"0.71863127",
"0.71674234",
"0.71585315",
"0.7153672",
"0.71391594",
"0.71310544",
"0.71199286",
"0.71... | 0.0 | -1 |
:doc: This helper returns exclusively if the request's user_aget is from a mobile device or not. | def is_mobile_request?
request.user_agent.to_s.downcase =~ Regexp.union(MOBILE_USER_AGENTS)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_mobile_request?\n request.user_agent.to_s.downcase =~ /#{MOBILE_USER_AGENTS}/\n end",
"def mobile?\n user_agent = request.user_agent.to_s.downcase rescue \"false\"\n return false if user_agent =~ /ipad/\n user_agent =~ Regexp.new(MOBILE_USER_AGENTS)\n end",
"def is_mobile_request?\... | [
"0.85906446",
"0.8399449",
"0.83955896",
"0.83855724",
"0.8174182",
"0.8090654",
"0.807504",
"0.807504",
"0.80613375",
"0.80576295",
"0.80371076",
"0.7977709",
"0.7902158",
"0.7898408",
"0.78981227",
"0.7892139",
"0.78838027",
"0.7881076",
"0.7851318",
"0.78497237",
"0.784870... | 0.8467372 | 1 |
:doc: This helper returns exclusively if the current format is mobile or not | def is_mobile_view?
true if (request.format.to_s == "mobile") or (params[:format] == "mobile")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mobile?\n os_parser.mobile?\n end",
"def mobile?\n return params[:format] == 'm'\n end",
"def mobile?\n return params[:format] == 'm'\n end",
"def mobile?\n true\n end",
"def mobile?\n true\n end",
"def in_mobile_view?\n request.format.to_sym == :mobile\n ... | [
"0.84858036",
"0.8435477",
"0.8435477",
"0.8136407",
"0.8136407",
"0.8131321",
"0.80936515",
"0.80935323",
"0.80683255",
"0.8063783",
"0.8035807",
"0.7930164",
"0.77713203",
"0.77621174",
"0.77520144",
"0.7725198",
"0.7679012",
"0.76204145",
"0.7608734",
"0.7605392",
"0.75541... | 0.79661715 | 12 |
Returns true if this request should be treated as a mobile request | def respond_as_mobile?
processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or allow_mobile_response? or (params[:format] == 'mobile'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_as_mobile?\n processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or is_mobile_request? or (params[:format] == 'mobile'))\n end",
"def is_mobile_request?\n request.user_agent.to_s.downcase =~ /#{MOBILE_USER_AGENTS}/\n end",
"def respond_a... | [
"0.8691467",
"0.85484105",
"0.84981",
"0.84452987",
"0.8419529",
"0.8350595",
"0.81718194",
"0.81713957",
"0.81711364",
"0.80911183",
"0.79733",
"0.7950714",
"0.7901085",
"0.7901085",
"0.78943604",
"0.7803651",
"0.7797475",
"0.77766275",
"0.77699924",
"0.77660537",
"0.7744304... | 0.859012 | 1 |
Returns true if the visitor has de force_mobile session | def force_mobile_by_session?
session[:mobylette_override] == :force_mobile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_mobile_by_session?\n session[:mobylette_override] == :force_mobile\n end",
"def mobile_device?\n if session[:mobile_param]\n session[:mobile_param] == \"1\"\n else\n if request.user_agent =~ /Mobile|webOS/\n session[:mobile_param] = \"1\"\n return true\n else\... | [
"0.83993447",
"0.80589527",
"0.79922444",
"0.7868589",
"0.7836865",
"0.7699944",
"0.76925975",
"0.7581405",
"0.7581405",
"0.7458913",
"0.74291664",
"0.7413509",
"0.7413509",
"0.73837656",
"0.73585594",
"0.73351395",
"0.7332812",
"0.73270017",
"0.7228249",
"0.72135955",
"0.719... | 0.8384117 | 2 |
Returns true when ?skip_mobile=true is not passed to the request | def skip_mobile_param_not_present?
params[:skip_mobile] != 'true'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_processing_because_param?\n return true if params[:skip_mobile] == 'true'\n false\n end",
"def respond_as_mobile?\n processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? or is_mobile_request? or (params[:format] == 'mobile'))\n end",
"def re... | [
"0.78112537",
"0.72036564",
"0.7166107",
"0.7084016",
"0.7082869",
"0.6788907",
"0.6771608",
"0.65249294",
"0.6514596",
"0.64029366",
"0.6363628",
"0.6328041",
"0.63076854",
"0.63076335",
"0.62974703",
"0.62104464",
"0.6176819",
"0.6176819",
"0.61438173",
"0.61398405",
"0.612... | 0.8281517 | 1 |
Returns true only if treating XHR requests (when skip_xhr_requests are set to false) or or when this is a non xhr request | def processing_xhr_requests?
not self.mobylette_options[:skip_xhr_requests] && request.xhr?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_xhr?\n !!request.xhr?\n end",
"def xhr_request_check\n request.xhr?\n end",
"def xhr?\n @env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i\n end",
"def xhr?\n @env[\"HTTP_X_REQUESTED_WITH\"] == \"XMLHttpRequest\"\n end",
"def stop_processing_because_xhr?\n if reques... | [
"0.84824455",
"0.8399075",
"0.8242247",
"0.8108369",
"0.80987185",
"0.7900502",
"0.782177",
"0.77931273",
"0.76222175",
"0.7591954",
"0.7287755",
"0.7169659",
"0.706895",
"0.7001487",
"0.686565",
"0.67977786",
"0.6758073",
"0.6752449",
"0.672324",
"0.66952264",
"0.6661545",
... | 0.8948431 | 1 |
:doc: Changes the request.form to :mobile, when the request is from a mobile device | def handle_mobile
return if session[:mobylette_override] == :ignore_mobile
if respond_as_mobile?
original_format = request.format.to_sym
request.format = :mobile
if self.mobylette_options[:fall_back] != false
request.formats << Mime::Type.new(self.mobylett... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_for_mobile\r\n session[:mobile_param] = params[:mobile] if params[:mobile]\r\n request.format = :mobile if mobile_device?\r\n end",
"def prepare_for_mobile\n session[:mobile_param] = params[:mobile] if params[:mobile]\n request.format = :mobile if mobile_device?\n end",
"def handle_mo... | [
"0.7266896",
"0.71761376",
"0.7132818",
"0.6868552",
"0.6797921",
"0.6785643",
"0.67850524",
"0.67850524",
"0.67677087",
"0.675466",
"0.6730091",
"0.66244674",
"0.65978",
"0.6552875",
"0.65513754",
"0.65217346",
"0.65207666",
"0.65165514",
"0.64799494",
"0.6370009",
"0.635938... | 0.6922197 | 4 |
GET /locations/1 GET /locations/1.json | def show
@locations_tree = @location.descendants.arrange(order: [:position, :name, :id])
@items = @location.items.includes(:stock_item).preload(:item_summary).order("stock_items.name")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations\n get('locations')\n end",
"def get_location\n as_json(get_results('/locations.json'))\n end",
"def index\n locations = Location.all\n render json: locations\n end",
"def index\n locations = @project.locations.all\n render json: { locations: locations }\n end",
"def show... | [
"0.77431786",
"0.7690497",
"0.7402892",
"0.7278375",
"0.72128636",
"0.7179753",
"0.71755373",
"0.7158328",
"0.71116275",
"0.70961183",
"0.70597774",
"0.7054361",
"0.7042809",
"0.7010643",
"0.6969208",
"0.6925418",
"0.69004",
"0.68884706",
"0.6884856",
"0.6876957",
"0.68584985... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_location
@location = Location.find(params[:id])
add_location_breadcrumb @location
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 location_params
params.require(:location).permit(:parent_id, :name, :position, :description)
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 |
Initialize and load data from kred api | def initialize(api_key)
raise ArgumentError, 'api_key is required' if api_key == nil || api_key.empty?
@api_key = api_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch\n response = RestClient.get \"http://pokeapi.co/#{resource_uri}\"\n update(resource_data: JSON.parse(response))\n end",
"def initialize\n load_data\n end",
"def initialize()\n\t\t@url = \"http://lcboapi.com/products\"\n\t\t@id = 0\n\t\t@term = \"\"\n\t\t@result = []\n\t\t@single = {}\n\ten... | [
"0.61837924",
"0.61215246",
"0.6060106",
"0.6026838",
"0.59978366",
"0.59892356",
"0.5978046",
"0.59699637",
"0.59690154",
"0.5960186",
"0.5951112",
"0.5943352",
"0.5940132",
"0.59089696",
"0.5901004",
"0.58525556",
"0.58300996",
"0.5828898",
"0.5812949",
"0.58011705",
"0.579... | 0.0 | -1 |
Get core from peerindex api | def score(username)
begin
@data = self.class.get("?twitter_screen_name=#{username}&api_key=#{@api_key}", verify: false)
result = @data ? JSON.parse(@data.body) : nil
result['peerindex'] if result
rescue Timeout::Error
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getblockchaininfo\n @api.request 'getblockchaininfo'\n end",
"def coreApiEP\n\t\tCORE_API_URL_83\n\tend",
"def solr_core_api(host_name,port,params,path=\"/solr/admin/cores\")\n path = \"#{path}?\".concat(params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\" }.join('&'))+\"&wt=json\"\n Chef::... | [
"0.62151563",
"0.60970014",
"0.5781671",
"0.55916613",
"0.55378264",
"0.53990144",
"0.5398869",
"0.5364266",
"0.5305242",
"0.5253647",
"0.5212809",
"0.5206844",
"0.51732826",
"0.51646364",
"0.5163923",
"0.51086354",
"0.50987184",
"0.50937337",
"0.5079469",
"0.50743276",
"0.50... | 0.0 | -1 |
rails r "tp User.first.wkbk_info" | def wkbk_info
{
"ID" => id,
"名前" => name,
"メールアドレス" => email,
"プロバイダ" => auth_infos.collect(&:provider).join(" "),
"Twitterアカウント" => twitter_key,
"最終ログイン日時" => current_sign_in_at&.to_s(:distance),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wkt\n self.read_attribute(:wkt)\n end",
"def user_name\n Recipe.select('users.name as user_name').joins(:user).where(:users => {:id => object.user_id})[0]['user_name']\n end",
"def users\n self.triples.map(&:first)\n end",
"def show\n @pw_user = PwUser.find(params[:id])\n\n respond_to d... | [
"0.5424187",
"0.536509",
"0.5334917",
"0.5258821",
"0.5258675",
"0.5250401",
"0.5224145",
"0.5183217",
"0.5171401",
"0.5168484",
"0.51590383",
"0.5153929",
"0.51017904",
"0.50842375",
"0.50687855",
"0.50575024",
"0.5045281",
"0.5023248",
"0.5023248",
"0.50017625",
"0.5000593"... | 0.5190597 | 7 |
Greater or equal value is on the right side | def insert(coordinates, value)
raise ArgumentError unless coordinates.is_a? Array
raise DimensionError if coordinates.length != dimension
@size += 1
node = Node.new coordinates, value, nil
if @root
insert_node @root, node, 0
else
@root = node
end
value
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def >=(p0) end",
"def >=(p0) end",
"def >=(p0) end",
"def <=(value)\n self < value or self == value\n end",
"def <=>(an0ther)\n get_val() <=> an0ther.get_val()\nend",
"def <=(p0) end",
"def bust?; value > 21; end",
"def do_greater_than(s); s[:direction] = 'right'; end",
"def below(x)\n re... | [
"0.6986781",
"0.6986781",
"0.6986781",
"0.68097734",
"0.66047585",
"0.6591056",
"0.6523926",
"0.6481155",
"0.6480416",
"0.64511424",
"0.64292634",
"0.6394749",
"0.6393403",
"0.63765204",
"0.6362728",
"0.6359239",
"0.63373744",
"0.6333859",
"0.6327139",
"0.6320261",
"0.6289304... | 0.0 | -1 |
Wrapper to create project with self.create_project_workflow_payload | def create_ingestion_workflow(params={})
payload=create_ingestion_workflow_payload(params)
create_workflow(payload)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_project(project)\n handle_action_exceptions(__method__) do\n cmd_line = [\"createproject '#{project}'\"]\n cmd_line << 'json' if @json\n\n handle_return(@toolshck_ether.cmd(cmd_line.join(' ')))\n end\n end",
"def create_project(optional={})\n\t\targs = self.class.new_params\n\t\t... | [
"0.7573791",
"0.74043506",
"0.73460686",
"0.7155662",
"0.71044177",
"0.7097131",
"0.69878757",
"0.6931392",
"0.69305605",
"0.69117254",
"0.6890852",
"0.68823403",
"0.6860759",
"0.6852324",
"0.6816502",
"0.67809606",
"0.67635924",
"0.6763581",
"0.675964",
"0.670003",
"0.669146... | 0.0 | -1 |
Builds the payload to create an ingestion workflow | def create_ingestion_workflow_payload(params={})
params[:uuid] ||= Config::Constants::ASSET_UUID
params[:path] ||= Config::Constants::ASSET_PATH
params[:title] ||= Config::Constants::ASSET_TITLE
params[:url] ||= Config::Constants::ASSET_URL + params[:uuid] + '/'
{
'definitionId': Config::... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_ingestion_workflow(params={})\n payload=create_ingestion_workflow_payload(params)\n create_workflow(payload)\n end",
"def create_payload\n payload = {}\n study = self.study\n # retrieve available objects pertaining to submission (submission, configuration, all workflows contained in su... | [
"0.7568646",
"0.6528402",
"0.61029536",
"0.60506654",
"0.5947633",
"0.58688915",
"0.58506745",
"0.5802693",
"0.5794872",
"0.5761983",
"0.57548255",
"0.567958",
"0.5675826",
"0.566689",
"0.56631845",
"0.5610897",
"0.55982727",
"0.55807453",
"0.5553352",
"0.55442464",
"0.554054... | 0.81712925 | 0 |
Validates the size of an uploaded picture. | def picture_size
if picture.size > 5.megabytes
errors.add(:picture, "should be less than 5MB")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def picture_size\n if picture.size > 5.megabytes\n errors.add(:picture, \"should be less than 5MB\")\n end\n end",
"def picture_size\n if picture.size > 5.megabytes\n errors.add(:picture, \"should be less than 5MB\")\n end\n end",
"def picture_size\n errors.add(:pictu... | [
"0.8246438",
"0.8246069",
"0.8203719",
"0.8203224",
"0.8199266",
"0.8188133",
"0.8187386",
"0.8179088",
"0.81592035",
"0.81588674",
"0.8158672",
"0.8143774",
"0.81267804",
"0.8125886",
"0.81034553",
"0.8086152",
"0.80746686",
"0.80457693",
"0.80301785",
"0.8022583",
"0.801906... | 0.81494313 | 18 |
Never trust parameters from the scary internet, only allow the white list through. | def proposal_params
params.require(:proposal).permit(:proposal_status_id, :not_approved_comment )
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 |
Count all alive Neighbours | def count_neighbours(row_index, col_index)
neighbours = 0
neighbours += life_in_cell(row_index - 1, col_index - 1)
neighbours += life_in_cell(row_index, col_index - 1)
neighbours += life_in_cell(row_index + 1, col_index - 1)
neighbours += life_in_cell(row_index - 1, col_index)
neighbours += life... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_neighbors\r\n @neighbors.count\r\n end",
"def live_neighbor_count(coords, cells=@cells)\n num_alive_neighbors = 0\n minmax = coords.map { |dim_coord| [dim_coord-1, dim_coord+1] }\n all_coords_in(minmax).each do |neighbor_coord|\n if coords != neighbor_coord && cells.include?(neighbor_co... | [
"0.79600376",
"0.7819636",
"0.77452314",
"0.77452314",
"0.7740812",
"0.7606822",
"0.7379666",
"0.7257162",
"0.725308",
"0.72245455",
"0.7045979",
"0.7033364",
"0.7016752",
"0.699349",
"0.6961627",
"0.69478685",
"0.6938074",
"0.6855168",
"0.6843047",
"0.6794041",
"0.6763732",
... | 0.7106585 | 10 |
Is there life at these coordinates? | def life_in_cell row_index, col_index
row_index = 0 if row_index == @size
col_index = 0 if col_index == @size
row_index = @size-1 if row_index == -1
col_index = @size-1 if col_index == -1
return @universe[row_index][col_index] || 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_come_to_life?(x, y)\n dead?(x,y) && neighbours(x,y) == 3\n end",
"def is_alive?\n @life_points <= 0\n end",
"def alive?(x, y)\n @cells.include?([x, y])\n end",
"def in_world?\n return false if lat < -90 || lat > 90\n return false if lon < -180 || lon > 180\n true\n end",
"d... | [
"0.7429481",
"0.7006593",
"0.693983",
"0.6720659",
"0.6714332",
"0.6671349",
"0.6666159",
"0.6638993",
"0.6584772",
"0.6563628",
"0.6522597",
"0.6504837",
"0.6458286",
"0.6440312",
"0.6419211",
"0.64186275",
"0.63905483",
"0.6379281",
"0.637282",
"0.6370257",
"0.63640577",
... | 0.0 | -1 |
A method we're giving you. This "flattens" Arrays of Arrays so: [[1,2], [3,4,5], [6]] => [1,2,3,4,5,6]. | def flatten_a_o_a(aoa)
result = []
i = 0
while i < aoa.length do
k = 0
while k < aoa[i].length do
result << aoa[i][k]
k += 1
end
i += 1
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten(array)\n new_array = []\n array.each do |x|\n if x.class == Array\n x.each {|y| new_array.push(y)}\n else\n new_array.push(x)\n end\n end\n new_array\nend",
"def flatten_array(array, result = [])\n array.each do |element|\n if element.is_a? Array\n flatten_array(elemen... | [
"0.78228056",
"0.76921076",
"0.768592",
"0.76206446",
"0.76188546",
"0.7610833",
"0.76067674",
"0.75865823",
"0.7549727",
"0.7549727",
"0.7531783",
"0.7514375",
"0.7505751",
"0.7502754",
"0.75009745",
"0.7488195",
"0.7488195",
"0.7488195",
"0.7488195",
"0.7488195",
"0.7488195... | 0.0 | -1 |
Your code after this point | def movies_with_director_key(name, movies_collection)
results_arr = [] # Delcare and initalize empty hash
movies_collection.length.times do |movie| # Traverse through movie collection
# Push the hash returned from the movie_with_director_name onto the empty array results_arr
results_arr << movie_with_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probers; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def post_process; end",
"def run() end",
"def private; end",
"def refutal()\n end",
"def finished; end",
"def finish()... | [
"0.6601133",
"0.6556763",
"0.6556763",
"0.6556763",
"0.6556763",
"0.6556763",
"0.6556763",
"0.6556763",
"0.6556763",
"0.6556763",
"0.65511525",
"0.6542253",
"0.65339035",
"0.6486297",
"0.63979787",
"0.6376763",
"0.6359356",
"0.632939",
"0.6325425",
"0.62865126",
"0.62865126",... | 0.0 | -1 |
End of Your Code Region Don't edit the following code! Make the methods above work with this method call code. You'll have to "seesaw" to get this to work! | def studios_totals(nds)
a_o_a_movies_with_director_names = movies_with_directors_set(nds)
movies_with_director_names = flatten_a_o_a(a_o_a_movies_with_director_names)
return gross_per_studio(movies_with_director_names)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def probers; end",
"def weber; end",
"def refutal()\n end",
"def zuruecksetzen()\n end",
"def who_we_are\r\n end",
"def suivre; end",
"def spouse; end",
"def calls; end",
"def calls; end",
"def rossini; end",
"def villian; end",
"def call\n\n\... | [
"0.6748544",
"0.66703254",
"0.6554182",
"0.6523715",
"0.6432566",
"0.63518554",
"0.6319761",
"0.6302851",
"0.6242884",
"0.6239233",
"0.6239233",
"0.62077737",
"0.6162149",
"0.6153764",
"0.6153764",
"0.61218953",
"0.61218953",
"0.61218953",
"0.61218953",
"0.61218953",
"0.61218... | 0.0 | -1 |
Options can include any writable attributes. They will be set as the class is instantiated. | def initialize(options = {})
options.each_pair do |k,v|
# TODO: don't allow setting of others?
instance_variable_set("@#{k.to_s}",v)
end
@uuid = UUID.new.generate.gsub('-','').upcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @options = {}\n @options[:extra] = true\n end",
"def set_attributes(options)\n @options.keys.each do |opt_name|\n instance_variable_set(\"@#{opt_name}\", options[opt_name])\n end\n end",
"def options\n @options ||= self.class.options\n end",
"def opti... | [
"0.73232776",
"0.71920717",
"0.7166838",
"0.70897835",
"0.70790213",
"0.7077543",
"0.70390826",
"0.70390826",
"0.70390826",
"0.6976001",
"0.69658965",
"0.6964563",
"0.6934791",
"0.69329524",
"0.6929539",
"0.69240236",
"0.6916705",
"0.69016355",
"0.688274",
"0.6881121",
"0.686... | 0.0 | -1 |
DELETE t FROM ( SELECT ticket_types.id FROM ticket_types GROUP BY type_uuid HAVING COUNT() > 1 ) t2 JOIN ticket_types t on t.id = t2.id; | def down
execute <<-SQL
ALTER TABLE ticket_types
DROP INDEX ticket_types_type_uuid;
SQL
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_all_with_joins\n ReferenceCode.joins(:reference_type).where(:reference_type_id => 1).delete_all\n end",
"def purge_type!(type)\n\n @redis.keys_to_a(\"#{type}/*\").each { |k| (@redis.del(k) rescue nil) }\n end",
"def deleteExtraUnits(allIds)\n dbUnits = Set.new(Unit.map { |unit| uni... | [
"0.6032297",
"0.559607",
"0.5522675",
"0.5466836",
"0.5440678",
"0.5433744",
"0.53851897",
"0.5361336",
"0.53550035",
"0.5338337",
"0.5287749",
"0.5279245",
"0.5252037",
"0.52198833",
"0.52122796",
"0.5177736",
"0.5168564",
"0.5150796",
"0.51455164",
"0.5143752",
"0.51280296"... | 0.5842581 | 1 |
GET /links/1 GET /links/1.json | def show
@link = Link.find(params[:id])
if @link['id']==2
require 'rubygems'
require 'nokogiri'
require 'open-uri'
url=@link['name']
puts url
doc = Nokogiri::HTML(open(url))
@title = doc.at_css("title").text
@imguLink = doc.at_css('.article-body')
@imgLink = @imguLink.to_s
@imgLink = @imgLink.gsub(/<\/?[^>]+>/,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n render json: @links\n end",
"def index\n links = all_links\n render json: { success: true, links: links }\n end",
"def index\n @links = Link.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @links }\n end\n end",
"def sho... | [
"0.7350112",
"0.7120274",
"0.7025738",
"0.6990482",
"0.69635993",
"0.6938119",
"0.6838034",
"0.6833723",
"0.6815706",
"0.68135786",
"0.6781963",
"0.6781963",
"0.6624377",
"0.65752435",
"0.6487915",
"0.6386929",
"0.6386929",
"0.6386929",
"0.6386929",
"0.6386929",
"0.6386929",
... | 0.0 | -1 |
GET /links/new GET /links/new.json | def new
@link = Link.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @link }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @link = Link.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @link }\n end\n end",
"def new\n @useful_link = UsefulLink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @useful_link }... | [
"0.7807135",
"0.7548326",
"0.7494255",
"0.7478307",
"0.73248",
"0.71945024",
"0.714992",
"0.7140056",
"0.7139754",
"0.7139754",
"0.70566434",
"0.7049113",
"0.70003074",
"0.6975316",
"0.6975316",
"0.6975316",
"0.6975316",
"0.6954977",
"0.69119275",
"0.68942344",
"0.68712157",
... | 0.7882237 | 4 |
POST /links POST /links.json | def create
@link = Link.new(params[:link])
puts @link
respond_to do |format|
if @link.save
format.html { redirect_to @link, notice: 'Link was successfully created.' }
format.json { render json: @link, status: :created, location: @link }
else
format.html { render action:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n if @link.save\n render json: @link, status: :created, location: @link\n else\n render json: @link.errors, status: :unprocessable_entity\n end\n end",
"def test_should_create_link_via_API_JSON\r\n get \"/logout\"\r\n post \"/links.json\", :api_key => 'testapikey',\r\n ... | [
"0.7279239",
"0.7042173",
"0.6892667",
"0.6849184",
"0.67824477",
"0.6708206",
"0.66861737",
"0.66628766",
"0.66427463",
"0.66249496",
"0.65540344",
"0.6506658",
"0.64941686",
"0.6478123",
"0.6459337",
"0.64366543",
"0.64365256",
"0.6423571",
"0.64210635",
"0.6417331",
"0.639... | 0.67146206 | 5 |
PUT /links/1 PUT /links/1.json | def update
@link = Link.find(params[:id])
respond_to do |format|
if @link.update_attributes(params[:link])
format.html { redirect_to @link, notice: 'Link was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n update_and_respond(@link, link_params)\n end",
"def update\n @link = Link.find(params[:id])\n\n respond_to do |format|\n if @link.update_attributes(params[:link])\n format.html { redirect_to @link, :notice => 'Ссылка была успешно обновлена' }\n format.json { head :ok }\n... | [
"0.66980344",
"0.65328366",
"0.6506885",
"0.6465254",
"0.6460195",
"0.64541274",
"0.641197",
"0.6301279",
"0.62843585",
"0.6200359",
"0.61855596",
"0.61855596",
"0.61855596",
"0.61855596",
"0.61855596",
"0.61615235",
"0.6144457",
"0.61441606",
"0.6131856",
"0.6123039",
"0.611... | 0.64490974 | 7 |
DELETE /links/1 DELETE /links/1.json | def destroy
@link = Link.find(params[:id])
@link.destroy
respond_to do |format|
format.html { redirect_to links_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @link = Link.find(params[:id])\n @link.destroy\n\n respond_to do |format|\n format.html { redirect_to links_url }\n format.... | [
"0.75310004",
"0.74690264",
"0.73705393",
"0.73705393",
"0.73637277",
"0.7292658",
"0.7263792",
"0.7260787",
"0.72489226",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.72376317",
"0.723125",
"0.72103757",
"0.72103304",
"... | 0.74529105 | 3 |
Returns 'completed', 'completed with errors', 'in progress', 'queued' depending on status of the child import jobs. In progress if there are any jobs in progress. Queued if all the jobs are queued. Completed if all the jobs have been completed successfully. Completed with errors if at least one job failed. | def status
return nil if digital_object_imports.empty?
if digital_object_imports.all?(&:successful?)
COMPLETED
elsif imports_finished_with_failures?
COMPLETED_WITH_ERRORS
elsif digital_object_imports.all?(&:queued?)
QUEUED
else
IN_PROGRESS
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n job = delayed_job\n return 'queued' if job_queued?(job)\n return 'working' if job_working?(job)\n return 'completed' if job_completed?(job)\n return 'failed' if job_failed?(job)\n return 'unknown'\n end",
"def status\n if not(exist?)\n r... | [
"0.66033566",
"0.6260458",
"0.6191626",
"0.6173958",
"0.6118471",
"0.61020654",
"0.6071415",
"0.59899426",
"0.5917287",
"0.5877907",
"0.58378726",
"0.5837508",
"0.58296466",
"0.58293897",
"0.57696366",
"0.5768261",
"0.56507653",
"0.56507653",
"0.5634312",
"0.5589584",
"0.5561... | 0.6818543 | 0 |
Generate CSV for Bulk Import. | def csv
data = digital_object_imports.map(&:import_data)
Bulwark::StructuredCSV.generate(data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_csv\n\n fields = @resource[:class].typus_fields_for(:csv).collect { |i| i.first }\n\n require 'csv'\n if CSV.const_defined?(:Reader)\n # Old CSV version so we enable faster CSV.\n begin\n require 'fastercsv'\n rescue Exception => error\n raise erro... | [
"0.80076194",
"0.79788655",
"0.7178874",
"0.71344167",
"0.71344167",
"0.7061281",
"0.7054698",
"0.69472677",
"0.6895591",
"0.68628603",
"0.68392074",
"0.6761945",
"0.6725891",
"0.67157346",
"0.6710152",
"0.67034763",
"0.6621237",
"0.6615348",
"0.6606829",
"0.6584007",
"0.6580... | 0.71193063 | 5 |
Determine if the related DO Imports are all complete (_not_ in progress or queued) and has at least one failed | def imports_finished_with_failures?
digital_object_imports.where(status: DigitalObjectImport::FAILED).exists? &&
digital_object_imports.where(
status: [DigitalObjectImport::QUEUED, DigitalObjectImport::IN_PROGRESS]
).blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_complete\n return if errors.any? || building_data_frozen?\n\n check_contract_details_completed\n check_contract_period_completed\n check_service_and_buildings_present\n check_service_and_buildings_completed\n end",
"def complete?\n logger = Logger.new(STDOUT)\n\n err... | [
"0.7075292",
"0.67715055",
"0.67675453",
"0.66872686",
"0.66639274",
"0.65155566",
"0.6493192",
"0.6449565",
"0.6433253",
"0.6429974",
"0.6424724",
"0.6413714",
"0.6413714",
"0.63945425",
"0.6369455",
"0.6364834",
"0.6338503",
"0.6293209",
"0.62895435",
"0.6259809",
"0.625857... | 0.7831202 | 0 |
Create password via BCrypt; set the password_hash attribute unless the password is nil or empty => If you want to set the password_hash to nil, then you have to do this: user.update_attribute(:password_hash, nil) | def password=(new_password)
self.password_hash = BCrypt::Password.create(new_password) if !new_password.nil? && new_password != ''
@password = new_password
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crypt_password\n self.crypted_pass = BCrypt::Password.create(password) if password\n end",
"def hash_password # We'll call this method in the seed file; from https://gist.github.com/mdang/7b6097cc13b07db82c78\n if password.present?\n self.password_digest = BCrypt::Password.create(password)\n e... | [
"0.81774795",
"0.81148916",
"0.8096053",
"0.80819327",
"0.7974811",
"0.79744023",
"0.7945191",
"0.79156643",
"0.7898762",
"0.7898762",
"0.78887236",
"0.7853413",
"0.7844759",
"0.78366053",
"0.78261477",
"0.7799952",
"0.7797557",
"0.7788379",
"0.778606",
"0.7782177",
"0.777950... | 0.7746464 | 23 |
This method will error out if there is an attempt to set the password_hash to an invalid hash format (i.e. 'simplepassword') | def password_hash=(password_hash)
super(BCrypt::Password.new(password_hash))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_hashpass\n\t\tres = DB.exec(\"SELECT hashpass FROM people WHERE id=1\")\n\t\told_hashpass = res[0]['hashpass']\n\t\tassert old_hashpass.size > 20\n\t\tDB.exec_params(\"SELECT set_hashpass($1, $2)\", [1, 'bl00p€r'])\n\t\tres = DB.exec(\"SELECT hashpass FROM people WHERE id=1\")\n\t\trefute_equal old_ha... | [
"0.675226",
"0.65084165",
"0.6481979",
"0.6437747",
"0.63686585",
"0.631325",
"0.63083345",
"0.62777853",
"0.624781",
"0.62409806",
"0.62132645",
"0.62073994",
"0.62069225",
"0.62024546",
"0.619556",
"0.619109",
"0.6182826",
"0.6182826",
"0.61704254",
"0.6155106",
"0.6152712"... | 0.6332933 | 5 |
If self.password has been explicitly set on this object, then return it; Otherwise generate a new BCrypt::Password object and return it; | def password
@password
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password\n begin\n password = ::BCrypt::Password.new(self.encrypted_password)\n rescue\n password = nil\n end\n password\n end",
"def password\n @password ||= BCrypt::Password.new(password_hash)\n end",
"def password\n @password ||= BCrypt::Password.new(password_hash)\n end",... | [
"0.81130356",
"0.8096676",
"0.8096676",
"0.8096676",
"0.8096676",
"0.8096676",
"0.8084303",
"0.80780137",
"0.8057656",
"0.80536044",
"0.8034573",
"0.79708534",
"0.79078305",
"0.7891677",
"0.7886937",
"0.7886937",
"0.7886937",
"0.7886937",
"0.7886937",
"0.7886937",
"0.7886937"... | 0.0 | -1 |
Authenticate the user against a password and an account; TODO: WORK THIS OUT > auth_params must contain 2 keys: (1) :account => account_object (2) :password => password_string | def authenticate(password)
# Call BCrypt::Password's "==" method to check the authenticity of the password
if BCrypt::Password.new(self.password_hash) == password
return true
else
self.errors.add(:authentication, "Incorrect E-Mail/Password combination.")
self.password = ''
self.pass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate!\n if params[:user]\n user = User.find_by(email: params[:user][:user_name])\n if user and user.local? and user.valid_password?(params[:user][:password])\n success!(user)\n else\n fail\n end\n elsif auth\n user = User.... | [
"0.77690583",
"0.7596181",
"0.7594978",
"0.7368058",
"0.71771735",
"0.7104185",
"0.7070093",
"0.705569",
"0.7012682",
"0.7009855",
"0.69620883",
"0.6940548",
"0.68853885",
"0.67722577",
"0.6761764",
"0.6753473",
"0.6750596",
"0.674631",
"0.6726811",
"0.6726511",
"0.67237014",... | 0.0 | -1 |
Only used for dev stats (which need rewriting anyway) | def sprint_day(date)
return -1 unless start_date && end_date
return -1 if date < start_date
return (duration + 1) if date > end_date
counter_date = start_date
day = 1
while (counter_date < date)
if counter_date.wday == 0 || counter_date.wday == 6
counter_date += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stats; end",
"def stats; end",
"def stats\n end",
"def stats\n end",
"def stat() end",
"def fasthttp_statistics\n super\n end",
"def stats\n ## TODO:\n end",
"def stats\n \n end",
"def quick_stats\n\tend",
"def stat\n end",
"def statistics; end",
"def profiler; end",
... | [
"0.6264556",
"0.6264556",
"0.6097688",
"0.6097688",
"0.60867864",
"0.6026343",
"0.60211456",
"0.6000456",
"0.59512293",
"0.5855323",
"0.5819618",
"0.5811949",
"0.5811949",
"0.57906634",
"0.57811457",
"0.5778177",
"0.57629204",
"0.5756892",
"0.56964034",
"0.5667348",
"0.564309... | 0.0 | -1 |
PATCH/PUT /subjects/1 PATCH/PUT /subjects/1.json | def update
set_field
# byebug
if @field.update(fields_params)
render :json => {}
else
render :json => @subject.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n if @subject.update_attributes(params[:subject])\n\n format.html { redirect_to subjects_url, :notice => 'Subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ... | [
"0.7399212",
"0.7341869",
"0.72854865",
"0.712811",
"0.7044038",
"0.70004374",
"0.70004374",
"0.6995105",
"0.6978002",
"0.68667805",
"0.68179256",
"0.6792362",
"0.67713135",
"0.675009",
"0.6706549",
"0.66950065",
"0.6676277",
"0.66413474",
"0.66335547",
"0.6620601",
"0.661519... | 0.0 | -1 |
DELETE /subjects/1 DELETE /subjects/1.json | def destroy
set_field
if @field.destroy
render :json => {}
else
render :json => @subject.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |format|\n format.html { redirect_to subjects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |fo... | [
"0.79004234",
"0.79000086",
"0.7851459",
"0.7812474",
"0.7791248",
"0.77289444",
"0.76450217",
"0.7632434",
"0.75925595",
"0.75750107",
"0.756666",
"0.7557011",
"0.75504565",
"0.7544504",
"0.75413173",
"0.75402933",
"0.75402933",
"0.75240225",
"0.7490376",
"0.7464556",
"0.741... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_field
@field = Field.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 fields_params
#params.require(:subject).permit(:name, :professor_id, :department_id, :descricao)
params.require(:field).permit(:id, :name, :description)
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 |
============================================== Builds XML from Ruby Hashes/Arrays/Primitives ============================================== | def buildXmlFromObject(obj, parent_tag=nil)
xml = ""
has_parent = !parent_tag.nil?
# Arrays are formatted with the parent tag
# wrapping each of the array elements for some
# reason
if obj.is_a? Array
obj.each do |e|
xml += has_parent ? "<#{parent_tag}>" : ""
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml_from_array(builder, tags_and_values)\n tags_and_values.each do |tag, value|\n tag = javaize_key(tag)\n if value.is_a?(Array)\n builder.tag!(tag) { xml_from_array(builder, value) }\n else\n builder.tag!(tag, value)\n end\n end\n en... | [
"0.70313007",
"0.67979175",
"0.67050827",
"0.6647795",
"0.66041136",
"0.62638754",
"0.6253414",
"0.62204415",
"0.6197823",
"0.6144185",
"0.61304724",
"0.61304724",
"0.61304724",
"0.61304724",
"0.61304724",
"0.61304724",
"0.6108888",
"0.6088756",
"0.6081685",
"0.60478944",
"0.... | 0.6162857 | 9 |
Board initialize sets the cells of the board to a 9 element array of " " | def initialize()
reset!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\r\n @board = Array.new(9, \" \") \r\n end",
"def initialize\n\t\t\t@empty_cell = '_'\n\t\t\t@board = Array.new(3) {Array.new(3,@empty_cell)}\n\t\tend",
"def initialize_board\n board = Array.new(8) {Array.new(8)}\n populate_board(board)\n end",
"def initialize\n # The board is an... | [
"0.8506915",
"0.8391565",
"0.83736026",
"0.83564514",
"0.8331813",
"0.82292217",
"0.81333196",
"0.80333745",
"0.80333745",
"0.80243886",
"0.8011637",
"0.7970938",
"0.7914111",
"0.7914111",
"0.7914111",
"0.78339034",
"0.7827635",
"0.7824958",
"0.7803323",
"0.7784678",
"0.77693... | 0.0 | -1 |
Board reset! sets the cells of the board to a 9 element array of " " Board reset! can reset the state of the cells in the board | def reset!
@cells = Array.new(9, " ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset\n\t\tfor i in (0...9)\n\t\t\t@board[i] = nil\n\t\tend\n\tend",
"def reset\n\t\t@board = Array.new(3) {Array.new(3,\" \")}\n\tend",
"def reset_board\n @board = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n end",
"def reset!\n @cells = Array.new(9,\" \")\n end",
"def reset!\n @cells = Array.new(9,... | [
"0.8498634",
"0.84887654",
"0.84582704",
"0.81553495",
"0.81292695",
"0.8109868",
"0.806421",
"0.80462456",
"0.80432814",
"0.80032307",
"0.7961869",
"0.7925318",
"0.7925318",
"0.7925318",
"0.7925318",
"0.790904",
"0.7896877",
"0.7837673",
"0.77594924",
"0.77557284",
"0.767918... | 0.81078935 | 9 |
Board display prints the board | def display
puts " #{cells[0]} | #{cells[1]} | #{cells[2]} "
puts "-----------"
puts " #{cells[3]} | #{cells[4]} | #{cells[5]} "
puts "-----------"
puts " #{cells[6]} | #{cells[7]} | #{cells[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[... | [
"0.8979077",
"0.8924058",
"0.8891884",
"0.8867705",
"0.8844775",
"0.8819063",
"0.8819063",
"0.88177997",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.8813849",
"0.88047874",
"0.8798972",
... | 0.0 | -1 |
Board position takes in user input and returns the value of the board cell | def position(input)
cells[input.to_i-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position(input)\n player_position = input.to_i - 1\n @cells[player_position]\n end",
"def position(user_input)\n cells[user_input.to_i - 1]\n end",
"def position(user_input)\n return self.cells[user_input.to_i - 1]\n end",
"def position(player_input)\n cells[move_to_index(player_input)]... | [
"0.7758957",
"0.77266717",
"0.76810455",
"0.76185644",
"0.7611537",
"0.74969465",
"0.74790263",
"0.74124175",
"0.73989123",
"0.7366972",
"0.7351685",
"0.7291052",
"0.7281247",
"0.72724324",
"0.7249452",
"0.7195443",
"0.7129773",
"0.7122614",
"0.71056104",
"0.69893664",
"0.688... | 0.72046167 | 16 |
Board full? returns true for a full board Board full? returns false for an inprogress game | def full?
cells.all? {|value| value == "X" || value == "O"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def board_full?\n @board.flatten.all?\n @turn == 9 \n end",
"def full? #if theres no winning combos and the board is full? check to see\n @board.all?{|square| square!= \" \" }\n end",
"def board_full?\r\n @game_board.count(\"\") == 0\r\n end",
"def board_f... | [
"0.89323634",
"0.88798845",
"0.8842033",
"0.8719939",
"0.8670259",
"0.8670259",
"0.85427344",
"0.85082436",
"0.8492002",
"0.8487846",
"0.8473191",
"0.8461895",
"0.8457952",
"0.8457718",
"0.8441328",
"0.8434499",
"0.8416259",
"0.8412511",
"0.83883727",
"0.8378517",
"0.83582735... | 0.0 | -1 |
Board turn_count returns the amount of turns based on cell value | def turn_count
cells.count {|value| value == "X" || value == "O"}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_count\n turns = 0\n @board.each do |spot|\n if spot==\"X\" || spot==\"O\"\n turns += 1\n end\n end\n return turns\n end",
"def turn_count\n @board.count{|token| token == \"X\" || token == \"O\"}\n end",
"def turn_count()\n turns = 0\n \n @board.each do |p... | [
"0.84457123",
"0.84399146",
"0.83866733",
"0.8375129",
"0.8356444",
"0.8338881",
"0.83385247",
"0.83181703",
"0.83113945",
"0.8302289",
"0.82886076",
"0.8282003",
"0.8281581",
"0.8274414",
"0.8267338",
"0.8267212",
"0.8265706",
"0.8256636",
"0.82533824",
"0.8248288",
"0.82387... | 0.8311618 | 8 |
Board taken? returns true if the position is X or O Board taken? returns false if the position is empty or blank | def taken?(input)
!(position(input) == " " || position(input) == "")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def taken?(position)\n #board position -1 because of test using range 1-9 (user input numbers)\n self.cells[position.to_i-1] == \"X\" || \n self.cells[position.to_i-1] == \"O\"\n end",
"def position_taken?(board, position)\n if !board.empty? && board[position] && (board[position].include?(\"X\") || bo... | [
"0.8322731",
"0.8158422",
"0.81437314",
"0.8143035",
"0.8122052",
"0.8115441",
"0.8106005",
"0.8106005",
"0.8105039",
"0.80985767",
"0.8097687",
"0.80909646",
"0.8080206",
"0.8076679",
"0.8071088",
"0.8066616",
"0.8061258",
"0.80479807",
"0.80317",
"0.80199414",
"0.8015029",
... | 0.0 | -1 |
Board valid_move? returns true for user input between 19 that is not taken | def valid_move?(input)
input.to_i.between?(1,9) && !taken?(input)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?(number_entered, board)\n number_entered.between?(0, 8) && !(position_taken?(board, number_entered))\nend",
"def valid_move?(board,user_input)\n taken = position_taken?(board,user_input)\n valid_input = user_input.between?(0,8)\n valid_move = nil\n if(taken)\n valid_move = false\n else\n ... | [
"0.8624379",
"0.85842675",
"0.85835123",
"0.8501089",
"0.84936106",
"0.8473911",
"0.8453768",
"0.84478474",
"0.84464973",
"0.84447634",
"0.84425664",
"0.8423691",
"0.8414251",
"0.8401258",
"0.83882517",
"0.8383236",
"0.8377714",
"0.8376216",
"0.83572495",
"0.83572125",
"0.835... | 0.0 | -1 |
Board update updates the cells in the board with the player token according to the input | def update(input, player)
cells[input.to_i-1] = player.token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(input, player)\n input = input.to_i\n\t\tif valid_move?(input) # Check for a valid move\n\t\t\t cells[input-1] = player.token # Update the cell of the board with the player's token\n\t\tend\n\tend",
"def update(input, player)\n #When you update the appropriate index in the cells, you will set it... | [
"0.8180263",
"0.8076462",
"0.8074455",
"0.8033903",
"0.80094224",
"0.80094224",
"0.80019367",
"0.774654",
"0.7576534",
"0.7558736",
"0.7497593",
"0.74933434",
"0.723658",
"0.71181726",
"0.7055529",
"0.684341",
"0.6830434",
"0.67661774",
"0.67568403",
"0.6691073",
"0.66818935"... | 0.79631644 | 8 |
use find_by_id so no exception is thrown | def new
@revenue = Revenue.new
flash.now[:error] = "No tag found for #{params[:tag_id]}" unless @tag
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(id); end",
"def find(id); end",
"def find(id)\n raise NotImplementedError\n end",
"def find_by_id!(id)\n new(one.find_by_id(id) || raise(RecordNotFound, \"A #{name} record for #{id} does not exist.\"))\n end",
"def find_by_id(id)\n find(id)\n end",
"def find!(id)\... | [
"0.81599784",
"0.81599784",
"0.7821103",
"0.7811412",
"0.7752365",
"0.77393824",
"0.7680048",
"0.7664901",
"0.76376766",
"0.7582731",
"0.75339824",
"0.74899733",
"0.74804735",
"0.7423472",
"0.7387234",
"0.7367722",
"0.733853",
"0.7334839",
"0.7301492",
"0.72927904",
"0.726842... | 0.0 | -1 |
FUY: handles only JSON format for now | def body_params(request)
body = request.body.read
return {} if body.empty?
JSON
.parse(body)
.each_with_object({}) { |(key, value), res| res[key] = filtered_value(key, value) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readable_json(json)\n\t\t JSON.parse(json) rescue nil\n\t\tend",
"def json?\n true\n end",
"def jsonify(input); end",
"def format\n :json\n end",
"def apply_json_trait(value); end",
"def _convertJSON() \n js=\"\"\n \tbegin\n gem \"json\"\n\t\t js = JSON.parse(self.respo... | [
"0.7169035",
"0.71631444",
"0.71371186",
"0.70766866",
"0.6988194",
"0.6964091",
"0.69236124",
"0.6869459",
"0.6807512",
"0.6758075",
"0.6758075",
"0.6745395",
"0.67303973",
"0.67183214",
"0.66877055",
"0.66877055",
"0.66877055",
"0.66877055",
"0.66869414",
"0.6657245",
"0.66... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.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 |
Test if crew is not missing methods | def test( crew )
[ 'board', 'step', 'event', 'identifier' ].each do | method |
if not crew.respond_to?( method )
raise "Crew should respond to #{method}"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_exist\n $tracer.trace(format_method(__method__))\n @name_links.should_exist && @remove_buttons.should_exist\n end",
"def check_only_methods\n end",
"def test_airline_seat_has_instance_method_window?\n assert AirlineSeat.instance_methods.include?(:window?)\n end",
"def test_classes_... | [
"0.6577907",
"0.65716636",
"0.6567987",
"0.6422317",
"0.6405241",
"0.63617504",
"0.63617504",
"0.63617504",
"0.6322846",
"0.6237228",
"0.6123319",
"0.61135805",
"0.6109576",
"0.60815775",
"0.6073277",
"0.6027039",
"0.59967864",
"0.59967864",
"0.59651804",
"0.5951756",
"0.5924... | 0.7388072 | 0 |
Spawn the player on a node | def spawn( node, data = {} )
ship = build( data )
ship.command_center.travel( node )
ship.command_center.join
Space::Universe.timestamped 0, "Spawned #{ ship.identifier } on #{ ship.interface.position }"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spawn_player player; end",
"def spawn_mob entity; end",
"def spawned; end",
"def spawned; end",
"def start(player)\n precondition do\n raise \"Player not provided.\" if player.nil?\n end\n @game.sync\n @game.start player\n end",
"def create_player()\n box_vertices = polygon_ve... | [
"0.80225325",
"0.6608343",
"0.6246014",
"0.6246014",
"0.61197144",
"0.6114682",
"0.6078777",
"0.6029255",
"0.59943515",
"0.5991894",
"0.59844965",
"0.589936",
"0.5876692",
"0.58227533",
"0.5782751",
"0.57413745",
"0.57176244",
"0.55405927",
"0.55403125",
"0.55244905",
"0.5481... | 0.69541144 | 1 |
GET /tlcp_rueba_lists GET /tlcp_rueba_lists.json | def index
@tlcp_rueba_lists = TlcpRuebaList.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end",
"def get_lists\n response = rest(\"get\", \"lists\")\n\n return response[\"lists\"]\n end",
"def set_tlcp_rueba_list\n @tlcp_rueba_list = TlcpRuebaList.find(params[:id])\n end",
"def get_list(user, list)\n get(\"/#{us... | [
"0.686169",
"0.67294407",
"0.6683718",
"0.66096973",
"0.653841",
"0.6456861",
"0.6420835",
"0.6355611",
"0.63543",
"0.63290113",
"0.6317827",
"0.6280868",
"0.62666154",
"0.62227684",
"0.62215453",
"0.62173057",
"0.62003255",
"0.6174034",
"0.61389416",
"0.6138158",
"0.6134297"... | 0.7557752 | 0 |
GET /tlcp_rueba_lists/1 GET /tlcp_rueba_lists/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tlcp_rueba_lists = TlcpRuebaList.all\n end",
"def get_list(list_id)\n rest(\"get\", \"lists/#{list_id}\")\n end",
"def get_list(user, list)\n get(\"/#{user}/lists/#{list}.json\")\n end",
"def set_tlcp_rueba_list\n @tlcp_rueba_list = TlcpRuebaList.find(params[:id])\n end",... | [
"0.730006",
"0.7060004",
"0.66587037",
"0.6618601",
"0.63416845",
"0.633865",
"0.6320328",
"0.6284409",
"0.6281026",
"0.62772363",
"0.6253696",
"0.6239189",
"0.6230634",
"0.6215059",
"0.6210359",
"0.61787504",
"0.61574125",
"0.61172086",
"0.6110288",
"0.60981226",
"0.6095872"... | 0.0 | -1 |
POST /tlcp_rueba_lists POST /tlcp_rueba_lists.json | def create
@tlcp_rueba_list = TlcpRuebaList.new(tlcp_rueba_list_params)
respond_to do |format|
if @tlcp_rueba_list.save
format.html { redirect_to @tlcp_rueba_list, notice: 'Tlcp rueba list was successfully created.' }
format.json { render :show, status: :created, location: @tlcp_rueba_lis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tlcp_rueba_list_params\n params.require(:tlcp_rueba_list).permit(:title, :description)\n end",
"def create_list(params={})\n @obj.post('create-list', @auth.merge(params))\n end",
"def create_list(name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"post\", \"li... | [
"0.6978885",
"0.67790073",
"0.66844654",
"0.66375035",
"0.64931107",
"0.63854986",
"0.63854283",
"0.63525414",
"0.6127815",
"0.61086327",
"0.6090495",
"0.60744333",
"0.6058899",
"0.6058467",
"0.6019998",
"0.59965205",
"0.5968682",
"0.5964276",
"0.5951643",
"0.5939965",
"0.592... | 0.73264366 | 0 |
PATCH/PUT /tlcp_rueba_lists/1 PATCH/PUT /tlcp_rueba_lists/1.json | def update
respond_to do |format|
if @tlcp_rueba_list.update(tlcp_rueba_list_params)
format.html { redirect_to @tlcp_rueba_list, notice: 'Tlcp rueba list was successfully updated.' }
format.json { render :show, status: :ok, location: @tlcp_rueba_list }
else
format.html { render :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_list(list_id, name)\n data = {\n list: {\n name: name\n }\n }\n rest(\"patch\", \"lists/#{list_id}\", data)\n end",
"def update_list(id, list)\n record \"/todos/update_list/#{id}\", :list => list\n end",
"def update\n respond_to do |format|\n if @todoit_list.up... | [
"0.68319947",
"0.6590226",
"0.6436584",
"0.6430839",
"0.6430839",
"0.6424735",
"0.64165443",
"0.64116263",
"0.64035255",
"0.64026666",
"0.6401348",
"0.63894564",
"0.63894564",
"0.63841105",
"0.63762504",
"0.6373691",
"0.6348047",
"0.6345621",
"0.63441175",
"0.634021",
"0.6331... | 0.71063465 | 0 |
DELETE /tlcp_rueba_lists/1 DELETE /tlcp_rueba_lists/1.json | def destroy
@tlcp_rueba_list.destroy
respond_to do |format|
format.html { redirect_to tlcp_rueba_lists_url, notice: 'Tlcp rueba list was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_list(list_id)\n rest(\"delete\", \"lists/#{list_id}\")\n\n return true\n end",
"def delete_list(user, list)\n delete(\"/#{user}/lists/#{list}.json\")\n end",
"def destroy\n @list.destroy\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { h... | [
"0.724316",
"0.7132911",
"0.71089476",
"0.71089476",
"0.71089476",
"0.70500195",
"0.70388085",
"0.70320123",
"0.70320123",
"0.70320123",
"0.69993496",
"0.6991014",
"0.6972951",
"0.69641805",
"0.69554055",
"0.692615",
"0.6916199",
"0.69117105",
"0.6898801",
"0.6893538",
"0.689... | 0.7438396 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_tlcp_rueba_list
@tlcp_rueba_list = TlcpRuebaList.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 tlcp_rueba_list_params
params.require(:tlcp_rueba_list).permit(:title, :description)
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 /corps GET /corps.json | def index
@corps = Corp.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @corges = Corge.all\n end",
"def index\n @copons = Copon.all\n end",
"def index\n @popcorns = Popcorn.all\n end",
"def index\n @corridas = Corrida.all\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def index\n @cps = Cp.all\... | [
"0.6263956",
"0.5834942",
"0.58079624",
"0.58032",
"0.576666",
"0.5690641",
"0.56730187",
"0.56513697",
"0.5528497",
"0.55201536",
"0.5510321",
"0.5472428",
"0.54684246",
"0.54522026",
"0.54453355",
"0.5436924",
"0.54369015",
"0.54288995",
"0.5424727",
"0.54214495",
"0.540392... | 0.66932553 | 1 |
GET /corps/1 GET /corps/1.json | def show
members = @corp.members_income
if params[:q]
if params[:q][:ts_lteq]
date_to = params[:q][:ts_lteq]
if date_to =~ /^\d{4}-\d{2}-\d{2}$/
params[:q][:ts_lteq]=Time.parse(date_to).strftime("%Y-%m-%d 23:59:59")
end
end
if params[:q][:s]=="amount ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @corps = Corp.all\n end",
"def index\n @corps = Corp.all\n end",
"def index\n @corges = Corge.all\n end",
"def set_corpu\n @corpu = Corpu.find(params[:id])\n end",
"def show\n @circulation = Circulation.find(params[:id])\n\n respond_to do |format|\n format.html # ... | [
"0.6537758",
"0.6537758",
"0.6211128",
"0.5856104",
"0.5821062",
"0.58143884",
"0.5800207",
"0.5743693",
"0.5714927",
"0.56905675",
"0.56778306",
"0.56736755",
"0.5650279",
"0.5639502",
"0.5614502",
"0.56134313",
"0.56128067",
"0.56124675",
"0.5610981",
"0.5610778",
"0.560419... | 0.0 | -1 |
POST /corps POST /corps.json | def create
@corp = Corp.new(corp_params)
respond_to do |format|
if @corp.save
format.html { redirect_to @corp, notice: 'Corp was successfully created.' }
format.json { render action: 'show', status: :created, location: @corp }
else
format.html { render action: 'new' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @corpu = Corpu.new(corpu_params)\n respond_to do |format|\n if @corpu.save\n format.json { head :no_content }\n format.js\n else\n format.json { render json: @corpu.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ... | [
"0.61420125",
"0.5903179",
"0.5584617",
"0.5559048",
"0.5544588",
"0.5443427",
"0.54015064",
"0.5396335",
"0.5374695",
"0.5357605",
"0.5355798",
"0.53437245",
"0.5333569",
"0.5329659",
"0.5319357",
"0.53118473",
"0.5277994",
"0.52441555",
"0.52071774",
"0.51894706",
"0.517467... | 0.50754106 | 43 |
PATCH/PUT /corps/1 PATCH/PUT /corps/1.json | def update
respond_to do |format|
if @corp.update(corp_params)
format.html { redirect_to @corp, notice: 'Corp was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @corp.errors, status: :unproce... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @corpu.update(corpu_params)\n format.json { head :no_content }\n format.js\n else\n format.json { render json: @corpu.errors.full_message... | [
"0.6366213",
"0.6249702",
"0.6162892",
"0.6097376",
"0.6085265",
"0.6084564",
"0.60695153",
"0.6023439",
"0.59824556",
"0.59824556",
"0.59468406",
"0.59447885",
"0.59155864",
"0.58933204",
"0.5884843",
"0.585303",
"0.58506316",
"0.58461344",
"0.58433396",
"0.5832676",
"0.5827... | 0.55287766 | 77 |
DELETE /corps/1 DELETE /corps/1.json | def destroy
@corp.destroy
respond_to do |format|
format.html { redirect_to corps_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n ... | [
"0.71577334",
"0.6618937",
"0.6523853",
"0.652249",
"0.65168405",
"0.6514556",
"0.6510145",
"0.650041",
"0.65003556",
"0.6497556",
"0.64871114",
"0.6458781",
"0.6433229",
"0.64139646",
"0.64117616",
"0.64070874",
"0.6396723",
"0.63945866",
"0.639348",
"0.63920444",
"0.6388995... | 0.68015623 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_corp
@corp = Corp.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 corp_params
params[:corp]
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.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
Periodically called each second to fire request retries | def tick
@requests.each do |id,req|
req.tick
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retry_service(e) # e == rescued error\n\t\t\tif self.tries <= 10\n\t\t\t\tself.tries += 1\n\t\t\t\t# puts \"Connection issues... retrying in 3 seconds\"\n\t\t\t\tsleep(3)\n\t\t\t\tself.call_service\n\t\t\telse\n\t\t\t\tputs \"Backtrace: #{e.backtrace}\"\n\t\t\t\tputs \"BIG TIME ERROR getting: #{self.url}\"\n\t... | [
"0.7098024",
"0.7036834",
"0.68663734",
"0.68221873",
"0.68221873",
"0.6792861",
"0.6782418",
"0.67184925",
"0.66831785",
"0.66344833",
"0.6612246",
"0.66041076",
"0.6584169",
"0.65821904",
"0.65803677",
"0.65765285",
"0.6455307",
"0.64314413",
"0.6428968",
"0.64253926",
"0.6... | 0.0 | -1 |
Decodes the packet, looks for the request and passes the response over to the requester | def receive_data(data)
msg = nil
begin
msg = Resolv::DNS::Message.decode data
rescue
else
req = @requests[msg.id]
if req
@requests.delete(msg.id)
req.receive_answer(msg)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reply\n bytes_read = receive_packet 1400\n is_compressed = false\n\n if @buffer.long == 0xFFFFFFFE\n split_packets = []\n begin\n # Parsing of split packet headers\n request_id = @buffer.long\n is_compressed = ((request_id & 0x80000000) != 0)\n packet_count = @buf... | [
"0.6492733",
"0.64741653",
"0.6456098",
"0.63800925",
"0.6340381",
"0.6336303",
"0.6323422",
"0.6249403",
"0.6132614",
"0.60774076",
"0.6050564",
"0.5990672",
"0.59807056",
"0.5928351",
"0.5852148",
"0.5809262",
"0.5795507",
"0.57782316",
"0.57714385",
"0.56774753",
"0.567279... | 0.5496706 | 35 |
======================================== input: 2 strings: first one is to be converted. 2nd one are minor words separated by " ". the second string is optional. output: converted first string as string. rules: convert string1 to title case, except if the word is in the exception list (2nd string) if 1st word: capitali... | def title_case title, minors=""
sentence = title.downcase.split()
minor_words = minors.downcase.split()
sentence.map.with_index do |word,i|
minor_words.include?(word) && i!= 0 ? word : word.capitalize
end.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title_case(title, minor_words = true)\n title_words = title.downcase.split\n \n return title_words.map! {|word| word.capitalize!}.join(' ') if minor_words == true\n \n minor_words_split = minor_words.downcase.split \n \n title_words.map!.with_index do |word,index|\n if index == 0 or !minor_words_spl... | [
"0.6995915",
"0.6911233",
"0.68568623",
"0.6802257",
"0.67974293",
"0.6786206",
"0.6726932",
"0.6669281",
"0.66220975",
"0.65620047",
"0.65187216",
"0.63410723",
"0.633022",
"0.6321893",
"0.63206434",
"0.63068175",
"0.6302253",
"0.62699825",
"0.6257874",
"0.6252811",
"0.62452... | 0.6741558 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.