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 |
|---|---|---|---|---|---|---|
About scenario execution Because some condition holds... | def because(msg="Unknown cause", &block)
raise ArgumentError, "WSpec because/therefore expects a block" unless block
__stack.push(msg)
yield(browser)
__stack.pop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def condition; end",
"def run_cond; end",
"def win_condition\nend",
"def hit_condition()\n #This is a stub, used for indexing\n end",
"def result_of_checking; end",
"def cond; end",
"def cond; end",
"def cond; end",
"def check\n \n end",
"def check\n ... | [
"0.7026186",
"0.6742123",
"0.6522219",
"0.6463206",
"0.6375171",
"0.6368828",
"0.6368828",
"0.6368828",
"0.6218896",
"0.6218896",
"0.6186503",
"0.6186503",
"0.61676884",
"0.60708827",
"0.59520215",
"0.5943198",
"0.59377944",
"0.5933726",
"0.5931793",
"0.59282166",
"0.5926182"... | 0.0 | -1 |
About reaching pages Asserts that a page can be reached, leading to a Net::HTTPSuccess result | def i_reach(which_page)
result = go(which_page)
assert Net::HTTPSuccess===result, __last_because + " (cannot actually reach #{which_page}: #{result})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_page(base, page, severity=:E, expectedStatus=\"200\", log=true)\n path = base + page\n response = getHTTP(path)\n code = response.code || '?'\n if code != expectedStatus\n test(severity, \"Fetched #{path} - HTTP status: #{code} expected: #{expectedStatus}\") unless severity == nil\n return nil... | [
"0.72206855",
"0.674044",
"0.6577114",
"0.6558375",
"0.6494465",
"0.644917",
"0.6429458",
"0.6426055",
"0.6384194",
"0.63343143",
"0.6331706",
"0.6258108",
"0.624846",
"0.6190442",
"0.61850494",
"0.61820865",
"0.61788094",
"0.6175449",
"0.61469823",
"0.6137762",
"0.61120224",... | 0.69959426 | 1 |
Asserts that a page could be reached (requesting headers leads to a Net::HTTPSucess result) | def i_could_reach(which_page)
return if which_page.nil? or '#'==which_page
case which_page
when Tag
i_could_reach(which_page[:href])
when Array
which_page.each{|link| i_could_reach(link)}
when String
result = browser.headers_fetch(which_page)
assert Net::HTTPSuccess===result, __last_because + " (could not reach #{which_page}: #{result})"
else
raise ArgumentError, "Unable to use #{which_page} for i_could_reach"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_page(base, page, severity=:E, expectedStatus=\"200\", log=true)\n path = base + page\n response = getHTTP(path)\n code = response.code || '?'\n if code != expectedStatus\n test(severity, \"Fetched #{path} - HTTP status: #{code} expected: #{expectedStatus}\") unless severity == nil\n return nil... | [
"0.7060058",
"0.6837437",
"0.6837437",
"0.67828757",
"0.6603641",
"0.6550996",
"0.6550749",
"0.6484186",
"0.64726526",
"0.64720774",
"0.64279705",
"0.6350959",
"0.62982",
"0.62548584",
"0.62311",
"0.61963177",
"0.618093",
"0.61547214",
"0.61358213",
"0.6118504",
"0.6114479",
... | 0.60112536 | 29 |
Asserts that a page cannot be reached, leading to a Net::HTTPNotFound or a Net::HTTPForbidden (403) result | def i_dont_reach(which_page)
result = go(which_page)
assert (Net::HTTPNotFound===result or Net::HTTPForbidden===result), __last_because + " (can reach #{which_page}: #{result})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_may_not_reach(which_page)\n result = go(which_page)\n assert (Net::HTTPForbidden===result or Net::HTTPBadRequest===result), __last_because + \" (may actually reach #{which_page}: #{result})\"\n end",
"def check_url(path, url)\n res = http_client.get(url, follow_redirect: true)\n return... | [
"0.7737149",
"0.72584164",
"0.7084957",
"0.707849",
"0.69714546",
"0.69306064",
"0.6772716",
"0.672265",
"0.67165005",
"0.66754",
"0.66626287",
"0.6621195",
"0.6571661",
"0.65649056",
"0.6533863",
"0.65250134",
"0.650281",
"0.64729524",
"0.642314",
"0.64007586",
"0.6384376",
... | 0.7498706 | 1 |
Asserts that a page may not be reached, leading to a Net::HTTPForbidden (403) result. | def i_may_not_reach(which_page)
result = go(which_page)
assert (Net::HTTPForbidden===result or Net::HTTPBadRequest===result), __last_because + " (may actually reach #{which_page}: #{result})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i_dont_reach(which_page)\n result = go(which_page)\n assert (Net::HTTPNotFound===result or Net::HTTPForbidden===result), __last_because + \" (can reach #{which_page}: #{result})\"\n end",
"def bots_not_allowed\n render_403('page') if visitor_is_bot?\n end",
"def assert_forbidden\n ... | [
"0.77923113",
"0.7196156",
"0.7086012",
"0.7011919",
"0.6874228",
"0.6870177",
"0.6847909",
"0.6718713",
"0.6517071",
"0.6511993",
"0.6406746",
"0.6373354",
"0.63517374",
"0.6351584",
"0.6351584",
"0.6340072",
"0.6335313",
"0.6332222",
"0.63061833",
"0.62902474",
"0.62892973"... | 0.8168092 | 0 |
About seeing something on the page Asserts that something can be seen on the current page | def i_see(what)
assert i_see?(what), __last_because + " (don't see #{what})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertHomepage #Assertions for the corresponding page within the corresponding page object class\n expect(page.title).to include(\"TodoMVC\")\n end",
"def test_p1_00010_aboutpage\n @aboutpage.goto_about_page\n \tassert @browser.body.present?\n assert @aboutpage.about_widget.present?\n @abouturl... | [
"0.70692956",
"0.70179796",
"0.68485636",
"0.67491496",
"0.67491496",
"0.67294014",
"0.6668216",
"0.6662455",
"0.66601545",
"0.66525555",
"0.66165525",
"0.6615059",
"0.6590222",
"0.6590222",
"0.65801567",
"0.6571386",
"0.65680563",
"0.65601003",
"0.6541923",
"0.6514346",
"0.6... | 0.0 | -1 |
Asserts that something is not present on the current page | def i_dont_see(what)
assert !i_see?(what), __last_because + " (actually see #{what})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_capybara_can_ensure_something_is_not_found\n on_visiting_browserkoans_test_page do\n assert_equal __(false), page.has_selector?('#not-there')\n assert_nothing_raised do\n expect(page).to_not have_selector(__('#not-there'))\n end\n end\n end",
"def expect_page_to_not_have_con... | [
"0.7536978",
"0.7220779",
"0.7149996",
"0.7097892",
"0.6965843",
"0.6961422",
"0.68913674",
"0.6890181",
"0.6872802",
"0.6813863",
"0.6764166",
"0.6719421",
"0.66887593",
"0.66631734",
"0.6614167",
"0.65759957",
"0.6571946",
"0.6553961",
"0.6543067",
"0.6528654",
"0.6490951",... | 0.5843209 | 78 |
Asserts that I see a particular tag (see HTMLAnalysis.tag) | def i_see_tag(name, opts = nil)
assert has_tag?(name, opts), __last_because + " (don't see tag <#{name} #{opts.inspect})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_has_tag\n ogg = dummy()\n\n assert ogg.has_tag?(\"GENRE\")\n assert !ogg.has_tag?(\"UNKNOWN\")\n end",
"def test_navbar\n get 'index'\n tag={:tag=>'li'}\n assert_tag :ancestor=>tag,\n :tag => 'a', :content=>'Feed'\n \n assert_tag :ancestor=>tag,\n ... | [
"0.67250544",
"0.6717588",
"0.67012674",
"0.66086125",
"0.66059035",
"0.65624624",
"0.64394224",
"0.6423503",
"0.63943315",
"0.63641894",
"0.6362613",
"0.6299818",
"0.6298143",
"0.62975556",
"0.6252634",
"0.60787",
"0.6077071",
"0.6077071",
"0.60445255",
"0.60224754",
"0.6017... | 0.5893549 | 22 |
Asserts that I see a particular link (see HTMLAnalysis.link) | def i_see_link(opts = nil)
assert has_link?(opts), __last_because + " (dont see link <a #{opts.inspect})"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_link_is_visible(text, is_target_link=nil, link=nil)\n if !is_target_link.nil?\n find_link(text, visible: true)[:target].should == \"_blank\"\n elsif !link.nil?\n expect(page).to have_link(text, visible: true, href: Helpers::ContentHelper.str_to_regexp(link), minimum: 1)\n el... | [
"0.72316915",
"0.7087352",
"0.7048184",
"0.6803872",
"0.67697275",
"0.6733283",
"0.663515",
"0.65928894",
"0.65332997",
"0.6459212",
"0.64545757",
"0.64526594",
"0.6428117",
"0.6423113",
"0.6341839",
"0.6329584",
"0.6320291",
"0.63007975",
"0.62639904",
"0.6233173",
"0.623021... | 0.6579738 | 8 |
About linkbased navigation Following a link | def i_follow(link)
link = case link
when String
link
when Tag
link[:href]
when ::Waw::ActionController::Action
link.href
else
raise ArgumentError, "Unable to apply i_follow to #{link.inspect}"
end
i_reach(link)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_page; link 'next' end",
"def click_through_link\n\t\treturn '/items/' + self.items.first.slug if !self.items.first.blank?\n\t\treturn '/blog/' + self.blogs.first.slug if !self.blogs.first.blank?\n\t\treturn \"#\"\n\tend",
"def links; end",
"def links; end",
"def click(link); end",
"def show\n ... | [
"0.6808108",
"0.67411846",
"0.66839784",
"0.66839784",
"0.66414374",
"0.6522173",
"0.64972407",
"0.64508826",
"0.64416075",
"0.6394263",
"0.6378187",
"0.63633364",
"0.62921023",
"0.62797123",
"0.6242351",
"0.6242351",
"0.62389725",
"0.62112355",
"0.6185782",
"0.6185486",
"0.6... | 0.61314225 | 28 |
About forms and action Submits some form with optional arguments | def i_submit(form, args = {})
assert_not_nil form, __last_because + "(form has not been found)"
raise ArgumentError, "i_submit requires a Tag instance, #{form.inspect} received" unless Tag===form
i_invoke(form[:action], args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit; end",
"def submit\n end",
"def fb_request_form_submit(options={})\n\t\t\t tag(\"fb:request-form-submit\",stringify_vals(options))\n\t\t\tend",
"def submit(form, button = T.unsafe(nil), headers = T.unsafe(nil)); end",
"def submit_form\n @page = @form.submit\n end",
"def submit!\n\tend",... | [
"0.69529366",
"0.68987024",
"0.682489",
"0.6816341",
"0.67750204",
"0.67656577",
"0.67510206",
"0.6746226",
"0.67338943",
"0.66551137",
"0.66525877",
"0.661776",
"0.6581385",
"0.6581385",
"0.6581385",
"0.6581385",
"0.65773493",
"0.6560446",
"0.6560446",
"0.6549808",
"0.653866... | 0.64751977 | 26 |
Directly invoke an action or service server side, bypassing form lookup and so on. | def i_invoke(action, args = {})
result = case action
when String
browser.invoke_service(action, args)
when ::Waw::ActionController::Action
browser.invoke_action(action, args)
else
raise ArgumentError, "Unable to apply i_invoke on #{action.inspect}, unable to catch the associated action"
end
assert Net::HTTPSuccess===result, __last_because + " (invoking #{action.inspect} led to: #{result})"
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_action(name)\n check_authenticity_token unless req.request_method == 'GET'\n self.send(name)\n self.render(name.to_s) unless already_built_response?\n end",
"def invoke_direct(method_name, *args)\r\n prepare_request('api', 'api', method_name, *args)\r\n @controller.process(... | [
"0.6927848",
"0.6789505",
"0.65752107",
"0.65752107",
"0.6574149",
"0.6508829",
"0.6466567",
"0.64300656",
"0.64256185",
"0.6394846",
"0.63693225",
"0.63602453",
"0.6345985",
"0.63020897",
"0.6289195",
"0.6289195",
"0.62844884",
"0.62803626",
"0.62679785",
"0.62516385",
"0.62... | 0.646318 | 7 |
GET /classifieds/1 GET /classifieds/1.json | def show
@classified = Classified.find(params[:id])
@message = @classified.messages.build # In this case ..its same as Message.new ....because while building an empty message , since this message is not nested in some routes like users/12/messages ....so when u do form_for @message ....it doesnt matter much...the only advantage of building through association a new record (not creating mind u ...building) is that when u do form_for @message ...it auto.. gets the route path of the message
respond_to do |format|
format.html # show.html.erb
format.json { render json: @classified }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @classifieds = Classified.all\n end",
"def new\n @classified = Classified.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @classified }\n end\n end",
"def create\n @classified = Classified.new(classified_params)\n respond_to do ... | [
"0.7305298",
"0.6786777",
"0.6599307",
"0.64442146",
"0.6397545",
"0.6397545",
"0.62669694",
"0.61965847",
"0.6155539",
"0.6142037",
"0.6072862",
"0.60491306",
"0.6011878",
"0.59770024",
"0.5957758",
"0.588961",
"0.5861056",
"0.5833146",
"0.5773363",
"0.57686156",
"0.57515895... | 0.0 | -1 |
GET /classifieds/new GET /classifieds/new.json | def new
@classified = Classified.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @classified }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @classified = Classified.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @classified }\n end\n end",
"def create\n @classified = Classified.new(classified_params)\n respond_to do |format|\n if @classified.save\n format.htm... | [
"0.7290924",
"0.7123625",
"0.69955546",
"0.679667",
"0.675727",
"0.6642035",
"0.66077185",
"0.6570642",
"0.6570221",
"0.6568146",
"0.6467695",
"0.64505446",
"0.6449248",
"0.6428555",
"0.64233875",
"0.63973665",
"0.6378445",
"0.63398683",
"0.6321351",
"0.6318048",
"0.63082737"... | 0.8099734 | 0 |
POST /classifieds POST /classifieds.json | def create
if signed_in?
@classified = current_user.classifieds.build(params[:classified])
else
if user_present?(params[:email]) # checks whether user is already present ...and if present assigns it to @user
redirect_to signin_path, notice: 'This account is already in use.Please sign in to use it'
return
else
create_impulse_signup params[:email]
end
@classified = @user.classifieds.build(params[:classified])
end
respond_to do |format|
if @classified.save
if signed_in?
format.html { redirect_to @classified, notice: 'Classified was successfully created.' }
else
format.html { redirect_to @classified, notice: 'Classified was successfully created..Please confirm your email account by clicking on the link we sent you' }
end
format.json { render json: @classified, status: :created, location: @classified }
else
format.html { render action: 'new' }
format.json { render json: @classified.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @classified = Classified.new(classified_params)\n respond_to do |format|\n if @classified.save\n format.html { redirect_to @classified, notice: 'Classified was successfully created.' }\n format.json { render :show, status: :created, location: @classified }\n else\n ... | [
"0.7535576",
"0.7053226",
"0.6705475",
"0.656762",
"0.65147984",
"0.6427479",
"0.62266773",
"0.62266773",
"0.61918867",
"0.60876113",
"0.59600914",
"0.5907236",
"0.5885389",
"0.5870816",
"0.5870816",
"0.58438134",
"0.57648623",
"0.56751895",
"0.56650513",
"0.5615167",
"0.5599... | 0.6072999 | 10 |
PUT /classifieds/1 PUT /classifieds/1.json | def update
@classified = @user.classifieds.find(params[:id])
respond_to do |format|
if @classified.update_attributes(params[:classified])
format.html { redirect_to @classified, notice: 'Classified was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @classified.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @classified.update(classified_params)\n format.html { redirect_to @classified, notice: 'Classified was successfully updated.' }\n format.json { render :show, status: :ok, location: @classified }\n else\n format.html { render :edit }\n ... | [
"0.6790866",
"0.6790866",
"0.6443071",
"0.6443071",
"0.6332666",
"0.60775906",
"0.6046845",
"0.5942756",
"0.5915898",
"0.58568054",
"0.58161974",
"0.57492745",
"0.57295406",
"0.5697634",
"0.56951195",
"0.5639165",
"0.5630543",
"0.56200415",
"0.56196827",
"0.55982274",
"0.5589... | 0.7026347 | 0 |
DELETE /classifieds/1 DELETE /classifieds/1.json | def destroy
@classified = @user.classifieds.find(params[:id])
@classified.destroy
respond_to do |format|
format.html { redirect_to classifieds_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @classified.destroy\n respond_to do |format|\n format.html { redirect_to classifieds_url, notice: 'Classified was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @classified.destroy\n respond_to do |format|\n format.html { re... | [
"0.735492",
"0.735492",
"0.73449916",
"0.7194511",
"0.70238125",
"0.6886442",
"0.68384784",
"0.67592686",
"0.67164856",
"0.66575056",
"0.66549844",
"0.66458607",
"0.6619374",
"0.66177684",
"0.6577693",
"0.6549269",
"0.6535986",
"0.65257215",
"0.65209186",
"0.6513518",
"0.6512... | 0.7414375 | 0 |
The rule used to determine if a model has a problem | def rule(model)
return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
model_steps = model.steps || []
return false unless model_steps.last
when_keywords.include?(model_steps.last.keyword)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rule(model)\n return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)\n\n @linted_step_count = model.steps.nil? ? 0 : model.steps.count\n @linted_step_threshold = @step_threshold || 10\n\n @linted_step_count > @linted_step_threshold\n end",
"def ... | [
"0.66836125",
"0.66733706",
"0.6342038",
"0.6323115",
"0.6299487",
"0.6210634",
"0.6119436",
"0.6092455",
"0.6087931",
"0.6087931",
"0.6087931",
"0.60011846",
"0.59728104",
"0.5846034",
"0.58372587",
"0.5814538",
"0.5768985",
"0.5768985",
"0.5768985",
"0.5768985",
"0.5768985"... | 0.5973222 | 12 |
The message used to describe the problem that has been found | def message
"Test has 'When' as the final step."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_msg\n name\n end",
"def message\n msg = \"Format error found in %s tuple: %s\" % [@identifier, @invalid_data.inspect]\n return msg\n end",
"def message\n message = \"Some of the request parameters are invalid:\" \n @messages.each { |param, identifiers| m... | [
"0.72686905",
"0.7262926",
"0.7171339",
"0.71390676",
"0.71348447",
"0.7084101",
"0.70767105",
"0.707142",
"0.7028446",
"0.7025792",
"0.7013351",
"0.7012839",
"0.6992545",
"0.69484556",
"0.69111955",
"0.6865585",
"0.68640834",
"0.6856111",
"0.685106",
"0.68445855",
"0.6822585... | 0.0 | -1 |
NOTE: (cmhobbs) all_groups and unique_groups are used because the UserGroup object was repurposed and now requires UserGroups for a given User to be unique. This needs rearch. FIXME (cmhobbs) wrap all_groups and unique_groups in tests. | def all_groups
groups + [organization]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_groups\n return @user_groups if @user_groups\n\n @user_groups = default_user_groups\n @user_groups |= current_user.groups if current_user and current_user.respond_to? :groups\n @user_groups |= ['registered'] if !current_user.new_record? && current_user.is_osu\n @user_groups\n end",
"def ... | [
"0.7268439",
"0.7154243",
"0.7076522",
"0.66934717",
"0.66569066",
"0.66560596",
"0.65319574",
"0.6493767",
"0.64746463",
"0.6398485",
"0.63856745",
"0.6358953",
"0.63484156",
"0.62237376",
"0.62062955",
"0.61791676",
"0.6172178",
"0.6156638",
"0.6155247",
"0.61112285",
"0.61... | 0.5829316 | 42 |
FIXME: (cmhobbs) this is pretty heavy handed. User shouldn't know this much about related objects. Public: Aggregate all users in associated groups Examples User.first.related_groups_users => [ , ] Returns an Array representing the related User objects. | def related_groups_users
[].tap do |related_users|
all_groups.each do |group|
related_users << group.all_users.reject { |group_user| group_user == self }
end
end.flatten.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users\n users = []\n members.each do |member|\n if member.is_a? User\n users << member\n elsif member.is_a? UserGroup\n users + member.users\n else\n raise UserGroupException, \"While retrieving users from a user group (#{self}), found a member that was not a User or U... | [
"0.6788714",
"0.66747075",
"0.64734405",
"0.63823956",
"0.60214233",
"0.5985585",
"0.5972596",
"0.59077686",
"0.58903253",
"0.5865416",
"0.5822525",
"0.57893354",
"0.5760975",
"0.5745023",
"0.5733774",
"0.57257736",
"0.57074296",
"0.5695067",
"0.56680304",
"0.5631721",
"0.563... | 0.78119546 | 0 |
NOTE: (cmhobbs+tyrendenison) verify usage of this set of methods | def non_profit_admin?
managed_organization.try(:type) == 'NonProfit'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def jack_handey; end",
"def mitch_hedberg; end",
"def weber; end",
"def berlioz; end",
"def celebr... | [
"0.7557106",
"0.7089973",
"0.6906544",
"0.6891817",
"0.6891817",
"0.6877616",
"0.6877616",
"0.6877616",
"0.6877616",
"0.6834909",
"0.6621984",
"0.6570836",
"0.6562285",
"0.6541487",
"0.6535754",
"0.6535754",
"0.65221846",
"0.65221846",
"0.65221846",
"0.65221846",
"0.6507424",... | 0.0 | -1 |
NOTE: (cmhobbs) we don't check to see if a BadgeType is awardable. this may prove troublesome in the future. FIXME (cmhobbs) we're passing badge_type_id around quite a bit... this may require a separate class at some point. | def award_badge(badge_type_id)
if badges.where(badge_type_id: badge_type_id).exists?
false
else
badge = badges.create(badge_type_id: badge_type_id, year: Time.now.year)
Notifier.delay.new_badge_email(self, badge)
# NOTE: (cmhobbs) spam all the users! \o/
# BadgeWorker.perform_async(badge.id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def award_badge(participant_id, badge_name)\n badge_id = Badge.get_id_from_name(badge_name: badge_name)\n AwardedBadge.where(participant_id: participant_id, badge_id: badge_id, approval_status: 0).first_or_create\n end",
"def has_badge?(badge)\n case badge\n when Badge\n badges.find_by_id(badge... | [
"0.6292739",
"0.61310035",
"0.6009031",
"0.5941763",
"0.5928707",
"0.59059054",
"0.583447",
"0.5803822",
"0.5802567",
"0.5726422",
"0.5684858",
"0.5675342",
"0.5619803",
"0.5567785",
"0.55570734",
"0.5527625",
"0.5522571",
"0.5483815",
"0.5443195",
"0.5434529",
"0.54320854",
... | 0.70889163 | 0 |
Parse out the main components of the BLAST output file in preparation for result display | def hits_prev
# see PsiBlastJob for comment
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse\n # TODO: Try to convert lsynth parts, maybe flag parts that are troublesome for manual editing,\n # look up to see if I've stored a conversion from ldraw ID to Bricklink ID,\n # convert Ldraw color IDs to BL color IDs, etc.\n parts = {}\n temp_parts = []\n\n @lines.each_with_index do |... | [
"0.59766674",
"0.593385",
"0.593385",
"0.5905647",
"0.57631016",
"0.55680686",
"0.55493873",
"0.55393714",
"0.553312",
"0.55093956",
"0.5483597",
"0.5483597",
"0.5423291",
"0.5418414",
"0.539924",
"0.53982705",
"0.5389963",
"0.5373868",
"0.5362725",
"0.5362725",
"0.5362725",
... | 0.0 | -1 |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | def instance_config project_id:, instance_config_id:
# [START spanner_get_instance_config]
# project_id = "Your Google Cloud project ID"
# instance_config_id = "Spanner instance config ID"
require "google/cloud/spanner"
require "google/cloud/spanner/admin/instance"
instance_admin_client = Google::Cloud::Spanner::Admin::Instance.instance_admin
instance_config_path = instance_admin_client.instance_config_path \
project: project_id, instance_config: instance_config_id
config = instance_admin_client.get_instance_config name: instance_config_path
puts "Available leader options for instance config #{config.name} : #{config.leader_options}"
# [END spanner_get_instance_config]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def implementation; end",
"def implementation; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; en... | [
"0.66184175",
"0.5639416",
"0.5639416",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
"0.5544618",
... | 0.0 | -1 |
Configure the connection instance in a generic manner. Each client can modify the connection in a specific way, when the application requires special handling. Just overwrite the +configure+ method, and call +super(con)+. Here is a full example: def configure(con) super(con) con.request :url_encoded con.response :logger con.adapter Faraday.default_adapter end | def configure(con)
con.use :instrumentation
# The definition order is execution order
con.request :ph_data_sanitization
con.request :ph_default_headers
con.request :json
con.request :multipart
con.request :url_encoded
# The definition order is reverse to the execution order
con.response :ph_recursive_open_struct
con.response :ph_data_sanitization
con.response :dates
con.response :json, content_type: /\bjson$/
con.response :follow_redirects
con.adapter Faraday.default_adapter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_connection\n end",
"def configure_connection\n end",
"def configure(conf)\n super\n end",
"def configure(settings = {})\n abstract_method\n end",
"def configure(&block)\n @config = Logger::Config.new\n\n yield @config\n\n ensure_required_options_... | [
"0.69118875",
"0.6892308",
"0.6635147",
"0.6527062",
"0.64633083",
"0.6451594",
"0.6320453",
"0.62772256",
"0.6216108",
"0.6192429",
"0.6178731",
"0.61609817",
"0.6159202",
"0.61010367",
"0.6091954",
"0.6083834",
"0.60795146",
"0.6059017",
"0.60533184",
"0.60489523",
"0.60481... | 0.7414548 | 0 |
rubocop:enable Metrics/MethodLength Create a new Faraday connection on the first shot, and pass the cached connection object on subsequent calls. | def connection
@connection ||= Faraday.new(url: PriceHubble.configuration.base_url,
&method(:configure))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection\n @connection ||= begin\n conn = Faraday.new(url: url)\n conn.build do |b|\n conn_build.call(b)\n end if conn_build\n conn\n end\n end",
... | [
"0.76702726",
"0.7626552",
"0.74242043",
"0.7394347",
"0.7366933",
"0.73524314",
"0.7320439",
"0.72897077",
"0.7238186",
"0.7194645",
"0.7194645",
"0.7187595",
"0.71869045",
"0.7181838",
"0.7167381",
"0.7161359",
"0.71354043",
"0.71345055",
"0.71345055",
"0.71345055",
"0.7134... | 0.6771172 | 53 |
GET /paperitems GET /paperitems.json | def index
if current_user.has_role? :admin
@paperitems = Paperitem.all
else
@paper = Paper.find(session[:paper_id])
@paperitems = Paperitem.where(paper_id: @paper.id).order(:serial)
## 如果已经有了测验会话,则继续测验
if session[:papertest_id]
@papertest = Papertest.find(session[:papertest_id])
## 如果没有测验会话
else
### 并且不是出卷人,则新建测验会话开始测验。
if @paper.user_id != current_user.id
unless Master.find_by(id: current_user.id)
@papertest = Papertest.create{|pt|
pt.user_id = current_user.id
pt.paper_id = @paper.id
pt.end_at = Time.now + @paper.duration * 60
}
session[:papertest_id] = @papertest.id
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @paper_items = PaperItem.all\n end",
"def index\n @papers = Paper.all\n\n render json: @papers\n end",
"def show\n render json: @paper\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn... | [
"0.7294244",
"0.64252704",
"0.6221957",
"0.61366534",
"0.6053562",
"0.60098606",
"0.5966599",
"0.59658164",
"0.59639955",
"0.5945867",
"0.5938329",
"0.59294647",
"0.5924382",
"0.59029573",
"0.590159",
"0.58515126",
"0.58447504",
"0.58360595",
"0.5824796",
"0.5821241",
"0.5767... | 0.0 | -1 |
GET /paperitems/1 GET /paperitems/1.json | def show
if current_user.has_role? :admin
else
session[:paperitem_id] = @paperitem.id
@paper = @paperitem.paper
@papertest_ids = @paper.papertests.map{|p|p.id}
@evaluations = Evaluation.where(practice_id: @paperitem.practice_id, papertest: @papertest_ids).order(id: :desc)
# 下面生成“上一题”和“下一题”
all_paperitem_ids = Paperitem.where(paper_id: @paper.id).order(:serial).pluck(:id)
index = all_paperitem_ids.find_index(@paperitem.id)
if index - 1 < 0
@previous_paperitem = nil
else
previous_paperitem = all_paperitem_ids[index - 1]
@previous_paperitem = Paperitem.find(previous_paperitem)
end
if index + 1 == all_paperitem_ids.length
@next_paperitem = nil
else
next_paperitem = all_paperitem_ids[index + 1]
@next_paperitem = Paperitem.find(next_paperitem)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @paper_items = PaperItem.all\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"... | [
"0.6998211",
"0.6408055",
"0.6305317",
"0.62869877",
"0.62258196",
"0.6203707",
"0.62015474",
"0.6183967",
"0.6177961",
"0.6114213",
"0.60679924",
"0.60595286",
"0.60313183",
"0.5989586",
"0.59498775",
"0.5948773",
"0.59012043",
"0.5889972",
"0.5872183",
"0.58697534",
"0.5844... | 0.0 | -1 |
POST /paperitems POST /paperitems.json | def create
@paperitem = Paperitem.new(paperitem_params)
unless @paperitem.practice_id
@paperitem.practice_id = 0
@paperitem.user_id = current_user.id
@paperitem.paper_id = session[:paper_id]
@paperitem.score = 0
end
respond_to do |format|
if @paperitem.save
format.html { redirect_to @paperitem, notice: 'Paperitem was successfully created.' }
format.json { render :show, status: :created, location: @paperitem }
else
format.html { render :new }
format.json { render json: @paperitem.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @paper = current_paper\n question = Question.find(params[:question_id])\n @paper_item = @paper.paper_items.build(:question=> question)\n\n respond_to do |format|\n if @paper_item.save\n format.html { redirect_to @paper_item, notice: 'Paper item was successfully created.' }\n ... | [
"0.71196145",
"0.6931301",
"0.6668755",
"0.63936496",
"0.6215943",
"0.61679894",
"0.6131102",
"0.60715365",
"0.60362417",
"0.6014292",
"0.6008369",
"0.60058945",
"0.5849308",
"0.57866037",
"0.5779479",
"0.5765568",
"0.57343155",
"0.5728311",
"0.5719931",
"0.57191",
"0.5716803... | 0.6359009 | 4 |
PATCH/PUT /paperitems/1 PATCH/PUT /paperitems/1.json | def update
respond_to do |format|
if @paperitem.update(paperitem_params)
format.html { redirect_to @paperitem, notice: 'Paperitem was successfully updated.' }
format.json { render :show, status: :ok, location: @paperitem }
else
format.html { render :edit }
format.json { render json: @paperitem.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @paper_item.update(paper_item_params)\n format.html { redirect_to @paper_item, notice: 'Paper item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render ... | [
"0.7298528",
"0.68244535",
"0.65368",
"0.65147763",
"0.6473924",
"0.6460453",
"0.6457427",
"0.6450522",
"0.6409075",
"0.639189",
"0.63773245",
"0.63773245",
"0.63341373",
"0.63212675",
"0.6317687",
"0.63074917",
"0.63025326",
"0.63017166",
"0.630061",
"0.62975484",
"0.6291182... | 0.7192861 | 1 |
DELETE /paperitems/1 DELETE /paperitems/1.json | def destroy
@paperitem.destroy
respond_to do |format|
format.html { redirect_to paperitems_url, notice: 'Paperitem was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @paper_item.destroy\n respond_to do |format|\n format.html { redirect_to paper_items_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete_item\n item_id = params[\"item_id\"]\n\n item = Text... | [
"0.7619962",
"0.7118266",
"0.70054746",
"0.6773249",
"0.67275685",
"0.6701529",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
"0.6701408",
... | 0.73722816 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_paperitem
@paperitem = Paperitem.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 paperitem_params
params.require(:paperitem).permit(:user_id, :paper_id, :practice_id, :score, :serial, :memo, :deleted_at)
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 |
The Clever Algorithms Project: (c) Copyright 2010 Jason Brownlee. Some Rights Reserved. This work is licensed under a Creative Commons AttributionNoncommercialShare Alike 2.5 Australia License. | def onemax(bitstring)
sum = 0
bitstring.each_char {|x| sum+=1 if x=='1'}
return sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alg; end",
"def ca; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def cops; end",
"def cops; end",
"def cops; end",
"def villian; end",
"def king_richard_iii; end",
"def celebrity; end",
"def celebrity; end",
... | [
"0.6706549",
"0.6273459",
"0.6248101",
"0.6248101",
"0.6248101",
"0.6248101",
"0.6248101",
"0.61685634",
"0.61685634",
"0.61685634",
"0.60687137",
"0.59263885",
"0.59144986",
"0.59144986",
"0.58673203",
"0.5854937",
"0.5835647",
"0.5833234",
"0.5790324",
"0.57768756",
"0.5776... | 0.0 | -1 |
VIEW HELPERS. Return a link with the "http(s)://( prefix stripped away. | def website_link
return unless website?
@website_link ||= website.split("//")[1].sub(/^www\./, "")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link() url; end",
"def link() url; end",
"def linkify(str)\n\t\t\tstr.gsub( %r{http://[^\"\\s]+} ) do |url|\n\t\t\t\tshort = url.gsub(%r{^.*#{Regexp.quote(request.host_with_port)}}, '')\n \t\t\"<a href='#{url}'>#{short}</a>\"\n\t\t\tend\n\tend",
"def link\n @link ||= uri.to_... | [
"0.7125662",
"0.7125662",
"0.7105084",
"0.67459285",
"0.6732336",
"0.67315036",
"0.66884965",
"0.66864663",
"0.66809696",
"0.6633163",
"0.6610444",
"0.6589095",
"0.6582854",
"0.65626395",
"0.65278137",
"0.6499147",
"0.6497",
"0.6475981",
"0.6436557",
"0.6427511",
"0.6400324",... | 0.61279213 | 55 |
arguments: symbol name of the field, FieldDefs parent object | def initialize(field_name, defs) #:nodoc:
@field_name = field_name
@for_model = defs.for_model
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field(name); end",
"def get_field(field_name)\n\t\tend",
"def process_field(field_name)\n if ['id', 'name', 'first_name', 'node_id'].include?(field_name)\n \"#{table}.#{field_name}\"\n else\n super # raises\n end\n end",
"def start_field=(_arg0); end",
"def add_field(field)\n\t\tend... | [
"0.74475235",
"0.69970655",
"0.6650262",
"0.66497535",
"0.65533406",
"0.6435762",
"0.6430852",
"0.63948786",
"0.63327855",
"0.63005465",
"0.6269922",
"0.62695867",
"0.6257703",
"0.62473214",
"0.6217794",
"0.61956716",
"0.61803186",
"0.61787516",
"0.6172737",
"0.6166402",
"0.6... | 0.6184642 | 16 |
used for applying labels to fields, you can then find all fields with a given lable by using FieldDefs.all_attributes_labeled | def label(label_name)
@labels ||= []
@labels << label_name.to_sym
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_attributes_labeled(label_name)\n to_return = {}\n @fields.each do |key, field|\n if field.has_label?(label_name.to_sym)\n to_return[key] = field.human_name\n end\n end\n to_return\n end",
"def all_fields_labeled(label_name)\n @fields.values.reject do |field|\n !field... | [
"0.7770568",
"0.72955835",
"0.72811604",
"0.7176707",
"0.7165646",
"0.711778",
"0.67014897",
"0.6700405",
"0.6683422",
"0.6683422",
"0.6683422",
"0.6683422",
"0.6683422",
"0.6683422",
"0.6658331",
"0.65247697",
"0.64326954",
"0.6423094",
"0.63937145",
"0.6371045",
"0.63656807... | 0.0 | -1 |
returns true/false based on if this field has the label asked for | def has_label?(label_name)
(@labels || []).include?(label_name.to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_label?\n\t\tnot @label.nil?\n\tend",
"def label?(label)\n self.labels.keys.include?(label)\n end",
"def label?\n not elements.select { |e| e.respond_to?(:label) }.empty?\n end",
"def has_extended_label?\n extended_label != nil\n end",
"def label_present?\n ... | [
"0.81016797",
"0.74153674",
"0.73295045",
"0.73185045",
"0.7298243",
"0.7247018",
"0.7202353",
"0.712427",
"0.710574",
"0.7104708",
"0.6979164",
"0.6834891",
"0.6829568",
"0.6795901",
"0.669731",
"0.6688157",
"0.66489685",
"0.66413325",
"0.6592044",
"0.6587566",
"0.65769184",... | 0.70511675 | 10 |
give me a block that describes how to display a potential value for the named field. If you call me without a block, I will return either the last block you sent me, or the default display_proc. Block should take 1 arg (being the value to format) and return the value, formatted. default proc just runs to_s on the value. | def display_proc(&block)
#defined by default_for_proc_type in initialize!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format!\n if block\n captured_value\n else\n to_s\n end\n end",
"def format(value = nil, &block)\n __define__(:format, value, block)\n end",
"def format_submission_field(field, value, &block)\n FormSubmissionFieldDisplay.new(self, field, value, &block)\n end",
... | [
"0.67699414",
"0.6548284",
"0.64155734",
"0.6355904",
"0.6308477",
"0.6200092",
"0.61819214",
"0.60970324",
"0.6069356",
"0.5991577",
"0.5970047",
"0.59550935",
"0.59262466",
"0.5898025",
"0.57645",
"0.5736172",
"0.5714861",
"0.5695842",
"0.56460404",
"0.56246173",
"0.5588536... | 0.7153447 | 0 |
give me a block that describes how to retrieve the value for the named field from a given entity If you call me wthout a block, I will return either the last block you send me, or the default reader_proc Block should take 1 arg (being the entity) and return the value retrieved default proc just assumes there is a method with the same name as field_name on the entity | def reader_proc(&block)
#defined by default_for_proc_type in initialize!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field name\n f = fields.find { |fld| fld.name == name.to_s }\n return nil if f.nil?\n yield f if block_given?\n f\n end",
"def get_field(field_name)\n\t\tend",
"def fetch_field(expected_key = nil, &block)\n find_field(expected_key, &block) ||\n ... | [
"0.6744902",
"0.6416119",
"0.63977563",
"0.63334256",
"0.6263338",
"0.62179524",
"0.61222124",
"0.6100709",
"0.6063372",
"0.60627455",
"0.60350156",
"0.60061616",
"0.60034776",
"0.58803684",
"0.58663774",
"0.5847971",
"0.5846034",
"0.57646984",
"0.57646984",
"0.569866",
"0.56... | 0.5887053 | 13 |
give me a block that describes how to set the value for the named field for the given entity If you call me without a block, I will reeturn either the last block you sent me, or the default writer_proc Block should take 2 args (1st the entity, 2nd the value to be written) default proc assumes there is an = method with the same name as field_name on the entity | def writer_proc(&block)
#defined by default_for_proc_type in initialize!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_field_value(name, value)\n\t\tend",
"def create_field_setter(name, meth, field)\n generated_methods.module_eval do\n define_method(\"#{ meth }=\") do |value|\n instance_variable_set \"@#{ name }\", value\n end\n end\n end",
"def field(field_name, value)\n... | [
"0.65005964",
"0.6222336",
"0.6204971",
"0.6196575",
"0.6182443",
"0.5976424",
"0.5937335",
"0.5925649",
"0.58924073",
"0.58897233",
"0.5884147",
"0.58749115",
"0.58186764",
"0.58148813",
"0.57631576",
"0.57437974",
"0.5734103",
"0.572136",
"0.5708385",
"0.5689501",
"0.568912... | 0.54637975 | 31 |
give me an arg and I will set a string for how the name of this field should be seen to end users call me with no args and I will give you the human_name you gave me | def human_name(*args)
#defined by default_for_arg_type in initialize!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def human_name=(_arg0); end",
"def human_name=(_arg0); end",
"def human_from_name; end",
"def human_to_name; end",
"def display_name(opts)\n opts = check_params(opts,[:field_names])\n super(opts)\n end",
"def name(arg = nil)\n if !arg.nil?\n validate(\n { name: arg },\n ... | [
"0.8093905",
"0.8093905",
"0.70941055",
"0.69186366",
"0.69056475",
"0.6833314",
"0.6819889",
"0.678319",
"0.6781301",
"0.6745799",
"0.6736689",
"0.6712051",
"0.6689699",
"0.6689699",
"0.6689699",
"0.6657979",
"0.6657979",
"0.6657979",
"0.6618683",
"0.65638477",
"0.65638477",... | 0.776178 | 2 |
Convenience method for chaining FieldDefs::Field.display_proc and FieldDefs::Field.reader_proc as intended i.e. instead of: field = field_defs.field_called(:name) field.display_proc.call(field.reader_proc.call(user)) you can do: field_defs.display_for(user, :name) | def display_for(object, field_name)
fdef = field_called(field_name)
fdef.display_proc.call(fdef.reader_proc.call(object))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_and_show_as(arg = nil, &proc) # :yields: field_def or nil\n edit_as(arg, &proc)\n show_as(arg, &proc)\n end",
"def display_proc(&block)\n #defined by default_for_proc_type in initialize!\n end",
"def show_as(*args, &proc) # :yields: field_def or nil\n @view_control.show_as(*args, &pr... | [
"0.67662483",
"0.6171107",
"0.6156245",
"0.6135175",
"0.5839443",
"0.5765052",
"0.57484514",
"0.5679762",
"0.5616974",
"0.5616675",
"0.5557382",
"0.55462784",
"0.55382544",
"0.5517704",
"0.5498199",
"0.54641896",
"0.54518807",
"0.5446169",
"0.5443193",
"0.5429538",
"0.5385006... | 0.77835965 | 0 |
Get a hash of all fields of the form: field name => human name | def all_attributes
@@all_attributes ||=
begin
to_return = {}
@fields.each do |key, field|
to_return[key] = field.human_name
end
to_return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields\n iterator = @form_fields.keySet.iterator\n map = {}\n while iterator.hasNext\n key = iterator.next.toString\n map[key.to_sym] = field(key)\n end\n map\n end",
"def form_fields\n values = super\n result = {}\n mappings.values.e... | [
"0.8123569",
"0.7356526",
"0.7281278",
"0.72111523",
"0.71293825",
"0.70986676",
"0.70986676",
"0.70924854",
"0.7040434",
"0.69130963",
"0.68933916",
"0.6892606",
"0.6873787",
"0.6872257",
"0.686649",
"0.6861421",
"0.6856828",
"0.6853996",
"0.6800241",
"0.6798241",
"0.6768439... | 0.6219597 | 67 |
Get a hash of all fields of the form: field name => human name Include only those fields that have the given label | def all_attributes_labeled(label_name)
to_return = {}
@fields.each do |key, field|
if field.has_label?(label_name.to_sym)
to_return[key] = field.human_name
end
end
to_return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_names\n label_fields.to_h\n end",
"def all_fields_labeled(label_name)\n @fields.values.reject do |field|\n !field.has_label?(label_name.to_sym)\n end\n end",
"def fields\n iterator = @form_fields.keySet.iterator\n map = {}\n while iterator.hasNext\n key = iterato... | [
"0.7511716",
"0.7379545",
"0.7066162",
"0.6679022",
"0.66658986",
"0.6416762",
"0.63890654",
"0.62618876",
"0.62233377",
"0.61832553",
"0.61760795",
"0.6132272",
"0.606464",
"0.6047817",
"0.6040522",
"0.60270554",
"0.5990106",
"0.5962807",
"0.5946538",
"0.5916742",
"0.5914366... | 0.7639816 | 0 |
Get an array of all fields thate have the given label | def all_fields_labeled(label_name)
@fields.values.reject do |field|
!field.has_label?(label_name.to_sym)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_names\n label_fields.to_h\n end",
"def labels\n fields[\"labels\"]\n end",
"def label_fields\n @label_fields ||= LabelFields.new do |lf|\n labels.each { |label| lf.add(label) }\n end\n end",
"def all_attributes_labeled(label_name)\n to_return = {}\n @fields.each do |ke... | [
"0.75214005",
"0.7258704",
"0.6793908",
"0.67801625",
"0.6606448",
"0.6520151",
"0.63650584",
"0.6353497",
"0.6348224",
"0.6230569",
"0.5949403",
"0.58672667",
"0.58672667",
"0.58545065",
"0.58101046",
"0.5802713",
"0.57898027",
"0.5760543",
"0.57258147",
"0.5722296",
"0.5719... | 0.7786056 | 0 |
Get an array of all fields defined on this FieldDefs | def all_fields
@fields.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields\n return @fields if defined?(@fields)\n\n @fields = array_of_items_for(Fields, :fields)\n end",
"def fields\n @fields ||= []\n end",
"def all_fields\n fields.values\n end",
"def fields\n @fields ||= []\n end",
"def all_fields\n found_fields = Array.n... | [
"0.789651",
"0.7806454",
"0.77410626",
"0.7733278",
"0.76102364",
"0.74666685",
"0.74292547",
"0.7425123",
"0.7404021",
"0.7376528",
"0.7363096",
"0.7313151",
"0.7303127",
"0.72987014",
"0.727751",
"0.7196521",
"0.7173657",
"0.7173657",
"0.71626455",
"0.71626455",
"0.7089634"... | 0.7534352 | 5 |
find a field by it's name | def field_called(field_name)
return nil if field_name.to_s.empty?
# return nil if field_name.to_s.empty?
@fields[field_name.to_sym]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_by_name(name = nil)\n @fields.find { |h| h[:name].to_snym == name.to_snym }\n end",
"def get_field_by_name(name)\n name = name.to_sym\n fields.values.find {|field| field.name == name}\n end",
"def field_by_name(name)\n @fields.detect{|f|f.name==name}\n end",
"def fiel... | [
"0.8724193",
"0.8718288",
"0.85044116",
"0.85040236",
"0.8058694",
"0.80316186",
"0.80316186",
"0.80280936",
"0.7966784",
"0.7962705",
"0.7798971",
"0.7612169",
"0.7519848",
"0.74554265",
"0.7349322",
"0.7343995",
"0.73297334",
"0.7327927",
"0.7315643",
"0.7264195",
"0.726013... | 0.64886045 | 64 |
Get an array of fields based on the given array of field names | def fields_called(field_names)
field_names.collect{ |name| field_called(name) || (raise ArgumentError, "field called #{name} not found") }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields(*fields)\n result = []\n keys.sort.each do |name|\n result << self[name].pick(*fields)\n end\n result\n end",
"def fields_by_name(name)\n @fields.select{|f|f.name==name}\n end",
"def fields(*args)\n return @fields if args.empty?\n @fields = arg... | [
"0.74406946",
"0.67190284",
"0.6709556",
"0.66769433",
"0.66562265",
"0.65829986",
"0.64617735",
"0.626644",
"0.6203308",
"0.61324567",
"0.6127118",
"0.611645",
"0.61118937",
"0.6102141",
"0.60826594",
"0.60580987",
"0.602145",
"0.5988478",
"0.5935649",
"0.5935228",
"0.592766... | 0.5813433 | 24 |
Puts the file into cache with the URI. | def put(src, uri)
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache(uri, obj)\n filename=cacheFileName(uri)\n print(\"Creating #{filename}\\n\")\n File.open(filename, 'w') {|f| f.write(obj) }\nend",
"def put(src, uri)\n # prepare cache path\n path = prepare_cache_path\n\n # move the file from the working directory to cache\n FileU... | [
"0.73098624",
"0.72068524",
"0.7068385",
"0.68803614",
"0.67575413",
"0.6749286",
"0.66958",
"0.65673214",
"0.65020853",
"0.6475204",
"0.6446909",
"0.6437824",
"0.63880116",
"0.6351356",
"0.6343938",
"0.6270706",
"0.6266897",
"0.625671",
"0.6226085",
"0.6215723",
"0.6190821",... | 0.60632104 | 26 |
Gets cached data path from the uri resource. | def get(uri)
# check cached or not
unless @table.has_key?(uri)
# prepare cache path
path = prepare_cache_path
# link the resource file to cache path
Resource[uri].link_to(path)
@table[uri.to_s] = path
end
return @table[uri.to_s]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path\n data.path\n end",
"def path\n data.path\n end",
"def fetch_path(path=\"\")\n read_data(@uri + path)\n end",
"def cache_filename_for_uri( path )\n uid = Digest::MD5.hexdigest( \"#{@uid}:#{path}\" )\n # NOTE: this path needs to exist with r/w permissions for webserv... | [
"0.6887563",
"0.6887563",
"0.6859787",
"0.6830755",
"0.6811168",
"0.6765802",
"0.66990376",
"0.6682875",
"0.6589293",
"0.6566418",
"0.6566418",
"0.6566418",
"0.64847183",
"0.64646184",
"0.6450746",
"0.64396197",
"0.6437117",
"0.64262676",
"0.64156437",
"0.6374739",
"0.6324969... | 0.68610585 | 2 |
Puts the data to uri resource and caches it in local. | def put(src, uri)
# prepare cache path
path = prepare_cache_path
# move the file from the working directory to cache
FileUtils.mv(src, path)
# make a symbolic link from original location to the cache
FileUtils.symlink(path, src)
# copy from cache to the resource file
@table[uri.to_s] = path
Resource[uri].link_from(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update (uri, data)\n return nil unless @enabled\n\n cache_name = translate_uri(uri)\n mkdir # FIXME include cache_name to build all necessary directories \n\n File.open(File.join(@directory, cache_name), 'w') do |f|\n f << data\n end\n end",
"def cache(uri, obj)\n filename... | [
"0.73367345",
"0.6583097",
"0.6364916",
"0.6362433",
"0.6337253",
"0.6242172",
"0.62378186",
"0.62011737",
"0.6126663",
"0.6065884",
"0.6065884",
"0.6065884",
"0.6065884",
"0.59127784",
"0.59109694",
"0.59077907",
"0.5884891",
"0.5883963",
"0.5842657",
"0.5835551",
"0.5835551... | 0.6736703 | 1 |
Makes new cache path. | def prepare_cache_path
cache = Tempfile.new("", Global.file_cache_directory)
path = cache.path
cache.close(true)
return path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_cache_dir\n ::FileUtils.mkdir_p(@cache_dir) unless ::File.directory?(@cache_dir)\n end",
"def populate_cache_path(container)\n cache_path.run_action(:create)\n\n r = Chef::Resource::File.new(::File.join(new_resource.cache_path, 'cid'), run_context)\n r.content(container.id)\... | [
"0.69791275",
"0.6952284",
"0.67630917",
"0.67209595",
"0.67001855",
"0.66851884",
"0.66851884",
"0.6662241",
"0.6647477",
"0.6638841",
"0.6602987",
"0.6594684",
"0.6590354",
"0.6540276",
"0.6479168",
"0.64747745",
"0.64726007",
"0.64538646",
"0.6434149",
"0.6384997",
"0.6354... | 0.63383937 | 21 |
If two numbers in the argument array have the same number of digits, return the first one in the array. MY SOLUTION | def find_longest(arr)
arr.max_by { |x| x.to_s.length }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_to_single_method(multiplied_integer_array)\n single_digit_array = []\n multiplied_integer_array.each do |value|\n if value > 9\n value = value - 9\n single_digit_array << value\n else\n value = value\n single_digit_array << value\n end\n end\n return single_digit_array\n... | [
"0.6912624",
"0.68084055",
"0.6710376",
"0.660626",
"0.6387354",
"0.63461185",
"0.63276875",
"0.6226721",
"0.62236136",
"0.6220724",
"0.6220524",
"0.62170947",
"0.6210346",
"0.62044764",
"0.61951774",
"0.61946523",
"0.618273",
"0.61289483",
"0.608719",
"0.6074364",
"0.6069914... | 0.0 | -1 |
DELETE /event DELETE /event.xml | def destroy
self.resource = destroy_resource
respond_to do |format|
format.html do
flash[:notice] = "#{resource_name.humanize} was successfully destroyed."
redirect_to enclosing_resource_url if enclosing_resource
end
format.js
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_event(event)\n @connection.send(Addressable::URI.parse(events_url + \"/#{event.id}\"), :delete)\n end",
"def delete_event(event)\n notifications = \"sendNotifications=#{event.send_notifications?}\"\n send_events_request(\"/#{event.id}?#{notifications}\", :delete)\n end",
"def de... | [
"0.772324",
"0.7523603",
"0.7488018",
"0.73347944",
"0.73237276",
"0.73237276",
"0.73204166",
"0.731671",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0.72896975",
"0... | 0.0 | -1 |
common cache : load_notetags_bubs_dismantle | def load_notetags_bubs_dismantle
@dismantle_items = []
@dismantle_gold_fee = Bubs::Dismantle::DEFAULT_DISMANTLE_FEE
@dismantle_reagents = {}
@dismantle_counter = 0
dismantle_tag = false
self.note.split(/[\r\n]+/).each { |line|
case line
when /<dismantle>/i
dismantle_tag = true
when /<\/dismantle>/i
dismantle_tag = false
when /(\w+):\s*(\d+)\s*[,:]?\s*(\d+\.?\d*)?/i
next unless dismantle_tag
new_obj = DismantleObj.new
case $1.upcase
when "I", "ITEM"
new_obj.item = $data_items[$2.to_i]
new_obj.chance = $3.to_f unless $3.nil?
@dismantle_items.push( new_obj )
when "W", "WEAPON", "WEP"
new_obj.item = $data_weapons[$2.to_i]
new_obj.chance = $3.to_f unless $3.nil?
@dismantle_items.push( new_obj )
when "A", "ARMOR", "ARMOUR", "ARM"
new_obj.item = $data_armors[$2.to_i]
new_obj.chance = $3.to_f unless $3.nil?
@dismantle_items.push( new_obj )
when "F", "FEE"
@dismantle_gold_fee = $2.to_i
end # case
end # case
} # self.note.split
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_notetags_bubs_tocrafting\n @recipe_list = []\n @ingredient_list = []\n @tocrafting_tools = []\n @tocrafting_actors = []\n @tocrafting_skills = []\n @tocrafting_gold_fee = self.price\n @tocrafting_bookcover = \"\"\n @tocrafting_se = []\n @tocrafting_category = :none\n @tocraft... | [
"0.6404823",
"0.6006554",
"0.58851457",
"0.56934065",
"0.5693365",
"0.56367594",
"0.5615738",
"0.5562807",
"0.5562807",
"0.55256224",
"0.55125296",
"0.5498459",
"0.54863095",
"0.5467426",
"0.5456634",
"0.5355182",
"0.5286759",
"0.52649176",
"0.52649176",
"0.52496904",
"0.5218... | 0.69911176 | 0 |
new method : dismantlable? | def dismantlable?
return false unless self.is_a?(RPG::Item) || self.is_a?(RPG::EquipItem)
return true unless @dismantle_items.empty?
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def original; end",
"def extended(*) end",
"def custom; end",
"def custom; end",
"def original_method; end",
"def overload; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def method; end",
"def method; end",
"def method; end",
"def... | [
"0.7215089",
"0.71076375",
"0.690512",
"0.6877685",
"0.6877685",
"0.6736623",
"0.6650486",
"0.6626182",
"0.6626182",
"0.6626182",
"0.6626182",
"0.6622015",
"0.6622015",
"0.6622015",
"0.6622015",
"0.6622015",
"0.6622015",
"0.6622015",
"0.6622015",
"0.6622015",
"0.6622015",
"... | 0.0 | -1 |
new method : set_dismantle_mask_flags | def set_dismantle_mask_flags(flag = true)
return unless self.is_a?(RPG::Item) || self.is_a?(RPG::EquipItem)
@dismantle_items.each do |obj| obj.mask = flag end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_dismantle_mask(key, id)\n case key\n when :item\n $data_items[id].set_dismantle_mask_flags(true)\n when :armor\n $data_armors[id].set_dismantle_mask_flags(true)\n when :weapon\n $data_weapons[id].set_dismantle_mask_flags(true)\n end\n end",
"def set_mask(opts)\n opt... | [
"0.7003532",
"0.6814202",
"0.66662574",
"0.6605281",
"0.6500882",
"0.64192605",
"0.64068455",
"0.6384925",
"0.6317895",
"0.6238115",
"0.6238115",
"0.62272185",
"0.62259436",
"0.6225939",
"0.6206085",
"0.6175929",
"0.6127259",
"0.6078628",
"0.6033596",
"0.59747803",
"0.5968044... | 0.8143703 | 0 |
current_item_enabled? Get Activation State of Selection Item | def current_item_enabled?
enable?(@data[index])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_item_enabled?\n true\n end",
"def current_item_enabled?\r\n current_data ? current_data[:enabled] : false\r\n end",
"def current_item_enabled?\n current_data ? current_data[:enabled] : false\n end",
"def current_item_enabled?\n return true\n end",
"def current_item_enabled?() ta... | [
"0.74860334",
"0.7435893",
"0.7426056",
"0.7353028",
"0.7345886",
"0.71996814",
"0.71095306",
"0.69557726",
"0.6944723",
"0.6813259",
"0.676741",
"0.6703807",
"0.6647579",
"0.6625739",
"0.660995",
"0.6595868",
"0.6475963",
"0.6472574",
"0.6424648",
"0.63654745",
"0.63617396",... | 0.69458383 | 12 |
enable? Display in Enabled State? | def enable?(item)
return false if item.nil?
return false if $game_party.gold < item.dismantle_gold_fee
return item.dismantlable?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enabled; end",
"def enabled; end",
"def enabled; end",
"def enabled; end",
"def enabled\n\t\ttrue\n\tend",
"def enable=(value); self.is_enable = value end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def en... | [
"0.7351811",
"0.7351811",
"0.7351811",
"0.7351811",
"0.7288546",
"0.7189319",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71865124",
"0.7181389",
"0.7181389",
"0.7163995",
"0.7088384",
"0.69797695",
"0.6968339",
"0.6928011",
"0.68663... | 0.0 | -1 |
include? Include in Item List? | def include?(item)
case @category
when :item
item.is_a?(RPG::Item) && !item.key_item? && item.dismantlable?
when :weapon
item.is_a?(RPG::Weapon) && item.dismantlable?
when :armor
item.is_a?(RPG::Armor) && item.dismantlable?
when :key_item
item.is_a?(RPG::Item) && item.key_item? && item.dismantlable?
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include item\n\tend",
"def include?(item)\n end",
"def include?(item)\n return true\n end",
"def includes item\n msg = \"#{self} did not include #{item}\"\n check_if self.include?(item), msg\n end",
"def include?(item)\n self.__contains__(item).rubify\n end",
"def includes\n end",
... | [
"0.8237255",
"0.7737315",
"0.76933944",
"0.7598491",
"0.70257956",
"0.7013284",
"0.7013284",
"0.69817686",
"0.69424975",
"0.6874573",
"0.6754231",
"0.675245",
"0.6732813",
"0.66679555",
"0.66679555",
"0.6592755",
"0.6574391",
"0.6525474",
"0.6447482",
"0.64163613",
"0.6403947... | 0.0 | -1 |
enable? Display in Enabled State? | def enable?(item)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enabled; end",
"def enabled; end",
"def enabled; end",
"def enabled; end",
"def enabled\n\t\ttrue\n\tend",
"def enable=(value); self.is_enable = value end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def enabled_state\n super\n end",
"def en... | [
"0.7351811",
"0.7351811",
"0.7351811",
"0.7351811",
"0.7288546",
"0.7189319",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71890163",
"0.71865124",
"0.7181389",
"0.7181389",
"0.7163995",
"0.7088384",
"0.69797695",
"0.6968339",
"0.6928011",
"0.68663... | 0.0 | -1 |
status_window= Set Status Window | def status_window=(status_window)
@status_window = status_window
call_update_help
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_window\r\n super\r\n # Make status window\r\n @status_window = Window_Status.new(@actor)\r\n end",
"def status_window aconfig={}, &block\n sw = StatusWindow.new aconfig\n sw.win.name = \"WINDOW::status_window\"\n return sw unless block_given?\n begin\n yield sw\n ensure\n sw.destroy... | [
"0.75381744",
"0.7533768",
"0.7349331",
"0.7293328",
"0.7165387",
"0.70072675",
"0.68058324",
"0.67529106",
"0.67412716",
"0.6699734",
"0.66870475",
"0.66507846",
"0.6604116",
"0.65468305",
"0.65257317",
"0.6495793",
"0.6488882",
"0.64444166",
"0.6436358",
"0.64126533",
"0.64... | 0.8316029 | 0 |
update_help Update Help Text | def update_help
@help_window.set_item(item) if @help_window
@status_window.item = item if @status_window
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_help\n case current_symbol\n when :name\n text = Vocab.registration_help_name\n when :avatar\n text = Vocab.registration_help_avatar\n when :register\n text = Vocab.registration_help_submit\n when :title\n text = Vocab.registration_help_title\n else\n text = ''... | [
"0.792534",
"0.77582747",
"0.7638981",
"0.75335985",
"0.74417496",
"0.7366081",
"0.7205921",
"0.7136657",
"0.7136157",
"0.71318996",
"0.7095824",
"0.7073853",
"0.6964069",
"0.6928521",
"0.69220406",
"0.69138676",
"0.69111353",
"0.6906115",
"0.6896226",
"0.6880755",
"0.6855143... | 0.6556861 | 41 |
new method : remove_dismantle_mask | def remove_dismantle_mask(key, id)
case key
when :item
$data_items[id].set_dismantle_mask_flags(true)
when :armor
$data_armors[id].set_dismantle_mask_flags(true)
when :weapon
$data_weapons[id].set_dismantle_mask_flags(true)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unset_mask\n @masking_key = nil\n end",
"def unset_mask\n @masking_key = nil\n end",
"def remove_all_dismantle_masks\n groups = [$data_items, $data_armors, $data_weapons]\n for group in groups\n for obj in group\n next if obj.nil?\n obj.set_dismantle_mask_fl... | [
"0.72729516",
"0.72729516",
"0.6729544",
"0.6561492",
"0.65048856",
"0.6470863",
"0.63681674",
"0.6323612",
"0.6202933",
"0.6117511",
"0.6115914",
"0.610217",
"0.60555184",
"0.5968678",
"0.58524173",
"0.5797469",
"0.5691447",
"0.5676621",
"0.5667922",
"0.5658228",
"0.56496507... | 0.73759496 | 0 |
new method : remove_all_dismantle_masks | def remove_all_dismantle_masks
groups = [$data_items, $data_armors, $data_weapons]
for group in groups
for obj in group
next if obj.nil?
obj.set_dismantle_mask_flags(true)
end # for
end # for
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unset_mask\n @masking_key = nil\n end",
"def unset_mask\n @masking_key = nil\n end",
"def remove_dismantle_mask(key, id)\n case key\n when :item\n $data_items[id].set_dismantle_mask_flags(true)\n when :armor\n $data_armors[id].set_dismantle_mask_flags(true)\n w... | [
"0.6793357",
"0.6793357",
"0.6572579",
"0.6498804",
"0.6329656",
"0.6117755",
"0.60109484",
"0.600906",
"0.5995232",
"0.59944004",
"0.5984359",
"0.5957172",
"0.5935121",
"0.5907152",
"0.5898249",
"0.5873984",
"0.58672345",
"0.57989764",
"0.5792419",
"0.5790591",
"0.5766319",
... | 0.81315804 | 0 |
def new method : get_dismantle_count | def get_dismantle_count(key, id)
case key
when :item
$data_items[id].dismantle_counter
when :armor
$data_armors[id].dismantle_counter
when :weapon
$data_weapons[id].dismantle_counter
end # case
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n end",
"def count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n en... | [
"0.7293059",
"0.7293059",
"0.7293059",
"0.7204344",
"0.7204344",
"0.70775926",
"0.70653343",
"0.70653343",
"0.70653343",
"0.7001986",
"0.698729",
"0.6959307",
"0.6959307",
"0.6935823",
"0.69139975",
"0.6845829",
"0.6845829",
"0.6845829",
"0.6833355",
"0.6786442",
"0.6763345",... | 0.74452114 | 0 |
def new method : get_all_dismantle_count | def get_all_dismantle_count
count = 0
groups = [$data_items, $data_armors, $data_weapons]
for group in groups
for obj in group
next if obj.nil?
count += obj.dismantle_counter
end # for
end # for
return count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count\n end",
"def count\n end",
"def counts\r\n @counts\r\n end",
"def count\n return @@all\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",... | [
"0.72181416",
"0.72181416",
"0.71026546",
"0.7082664",
"0.7011825",
"0.7011825",
"0.7011825",
"0.70047706",
"0.70047706",
"0.70047706",
"0.7000065",
"0.6999205",
"0.6957815",
"0.6957815",
"0.6934482",
"0.6910248",
"0.6892735",
"0.6853122",
"0.68384576",
"0.68384576",
"0.68384... | 0.7478532 | 0 |
depends_on 'cmake' => :build | def install
ENV.deparallelize
ENV['OCAMLFIND_DESTDIR'] = "#{lib}/ocaml/site-lib/"
(lib + "ocaml/site-lib/").mkpath
system "make"
system "make install"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def package_depends_on\n depends_on\n end",
"def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n# system \"make package\"\n# end\nend",
"def ... | [
"0.69059354",
"0.675044",
"0.6558107",
"0.64560115",
"0.6422537",
"0.6393465",
"0.62657166",
"0.6190308",
"0.6190308",
"0.6135606",
"0.60239774",
"0.60239774",
"0.60239774",
"0.602081",
"0.59494925",
"0.59151554",
"0.5829265",
"0.58019245",
"0.5750149",
"0.57219386",
"0.56962... | 0.0 | -1 |
GET /accession_location_entries/1 GET /accession_location_entries/1.json | def show
@accession_location_entry = AccessionLocationEntry.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @accession_location_entry }
end
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 new\n @accession_location_entry = AccessionLocationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accession_location_entry }... | [
"0.65202993",
"0.64902353",
"0.64635515",
"0.6282157",
"0.6237028",
"0.6159012",
"0.61464167",
"0.6120498",
"0.6094246",
"0.6031871",
"0.60231113",
"0.6014338",
"0.5984254",
"0.59740543",
"0.5971812",
"0.59533226",
"0.5952472",
"0.5937841",
"0.59320223",
"0.59299326",
"0.5925... | 0.7180944 | 0 |
GET /accession_location_entries/new GET /accession_location_entries/new.json | def new
@accession_location_entry = AccessionLocationEntry.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @accession_location_entry }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @accession_location_entry = AccessionLocationEntry.new(params[:accession_location_entry])\n\n respond_to do |format|\n if @accession_location_entry.save\n format.html { redirect_to @accession_location_entry, notice: 'Accession location entry was successfully created.' }\n form... | [
"0.7206542",
"0.7106107",
"0.71039516",
"0.7068216",
"0.7063189",
"0.6962698",
"0.6962698",
"0.6962698",
"0.6962698",
"0.6962698",
"0.69202393",
"0.6903823",
"0.69018424",
"0.6899007",
"0.6899007",
"0.68906575",
"0.68439025",
"0.6823207",
"0.678212",
"0.67619354",
"0.6758749"... | 0.78341454 | 0 |
POST /accession_location_entries POST /accession_location_entries.json | def create
@accession_location_entry = AccessionLocationEntry.new(params[:accession_location_entry])
respond_to do |format|
if @accession_location_entry.save
format.html { redirect_to @accession_location_entry, notice: 'Accession location entry was successfully created.' }
format.json { render json: @accession_location_entry, status: :created, location: @accession_location_entry }
else
format.html { render action: "new" }
format.json { render json: @accession_location_entry.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postLocation( location_id, type, country, language, name, formal_name, resolution, population, description, timezone, latitude, longitude, parent_town, parent_county, parent_province, parent_region, parent_neighbourhood, parent_district, postalcode, searchable_id, searchable_ids)\n params = Hash.new\n pa... | [
"0.6242699",
"0.5955907",
"0.58618236",
"0.57917845",
"0.5767019",
"0.5755245",
"0.5726805",
"0.5684456",
"0.56395006",
"0.5524876",
"0.54961795",
"0.54804873",
"0.54216635",
"0.54098195",
"0.53835875",
"0.53774047",
"0.53772527",
"0.53649586",
"0.53627306",
"0.53198624",
"0.... | 0.6858917 | 0 |
PUT /accession_location_entries/1 PUT /accession_location_entries/1.json | def update
@accession_location_entry = AccessionLocationEntry.find(params[:id])
respond_to do |format|
if @accession_location_entry.update_attributes(params[:accession_location_entry])
format.html { redirect_to @accession_location_entry, notice: 'Accession location entry was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @accession_location_entry.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end",
"def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end",
"def create\n @accession_location_entry = AccessionLocationEntry.new(params[:accessi... | [
"0.64269066",
"0.64180183",
"0.6282211",
"0.6180619",
"0.60750437",
"0.60668075",
"0.601699",
"0.6009725",
"0.59824437",
"0.5979467",
"0.59150267",
"0.5914181",
"0.5907044",
"0.58921933",
"0.58792233",
"0.5851517",
"0.5848158",
"0.5799227",
"0.57919824",
"0.57903355",
"0.5788... | 0.70068336 | 0 |
DELETE /accession_location_entries/1 DELETE /accession_location_entries/1.json | def destroy
@accession_location_entry = AccessionLocationEntry.find(params[:id])
@accession_location_entry.destroy
respond_to do |format|
format.html { redirect_to accession_location_entries_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Location.delete(params[\"id\"])\n end",
"def destroy\n @record = Location.find(params[:id])\n @record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @location = Location.find(params[:id])\r\n @location.destr... | [
"0.69462156",
"0.68298554",
"0.6684562",
"0.6682947",
"0.6636414",
"0.66307396",
"0.66076356",
"0.6575782",
"0.655458",
"0.65400356",
"0.65395075",
"0.6538113",
"0.65314806",
"0.6516871",
"0.6516409",
"0.65123856",
"0.6507473",
"0.6503454",
"0.65003955",
"0.6485329",
"0.64798... | 0.7760664 | 0 |
Specify an attribute for the Immutable Object. This enables the object to be instantiated with the attribute, as well as creates an attribute reader for it. | def attribute(name)
@attribute_names << name
attr_reader(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr(attribute, name: attribute.to_s.camelize(:lower), nullable: nil, description: nil, deprecation_reason: nil, &block)\n name = name.to_sym unless name.is_a?(Symbol)\n\n # Get the description from the column, if it's not provided. Doesn't work in Rails 4 :(\n unless description\n ... | [
"0.6707965",
"0.6687016",
"0.6643935",
"0.66366524",
"0.6611993",
"0.6593258",
"0.6507238",
"0.64900976",
"0.6482233",
"0.64706546",
"0.64467925",
"0.6446142",
"0.64392996",
"0.6423832",
"0.63996214",
"0.6319561",
"0.6319216",
"0.6319179",
"0.6315432",
"0.627164",
"0.6270606"... | 0.63355976 | 15 |
DELETE /statements/1 DELETE /statements/1.json | def destroy
@statement.destroy
respond_to do |format|
format.html { redirect_to admin_statements_url, notice: 'Statement was successfully destroyed.' }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @statement = Statement.find(params[:id])\n @statement.destroy\n\n respond_to do |format|\n format.html { redirect_to statements_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @statement.destroy\n respond_to do |format|\n format.html { redirec... | [
"0.74896455",
"0.71904516",
"0.7111607",
"0.6917781",
"0.6737038",
"0.66258734",
"0.6539619",
"0.6518448",
"0.6485976",
"0.6457105",
"0.6446704",
"0.6444823",
"0.64389604",
"0.6409114",
"0.6389034",
"0.6373529",
"0.6337345",
"0.63357604",
"0.6325747",
"0.63200015",
"0.6314593... | 0.65855336 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_statement
@statement = Statement.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def statement_params
params.require(:statement).permit(:email, :name, :soname, :father_name, :position, :place, :test_id, :notified, :paid, :certificate, {search: [:paid,
:email, :fio, :ticket_id,{date: [:start, :end]}]})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
updates details of given ticket on CCCinema database | def update # EXTENSION
sql = "UPDATE tickets SET customer_id = $1, film_id = $2, screening_id = $3 WHERE id = $4"
values = [@customer_id, @film_id, @screening_id, @id]
SqlRunner.run(sql, values)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @ticket.update(ticket_params)\n\n end",
"def update\n logger.info { \"PARAMS: #{params.inspect}\" }\n project_id, id = params[:id].split('-')\n ticket = Lighthouse::Ticket.find(id, :params => {:project_id => project_id})\n \n # insanely hacky. can't nest json, so don't want to do... | [
"0.7801914",
"0.74517876",
"0.7255612",
"0.7127886",
"0.70913583",
"0.69678116",
"0.69181865",
"0.69103605",
"0.68866813",
"0.6841769",
"0.68368363",
"0.68330294",
"0.6822439",
"0.68152404",
"0.68152404",
"0.68152404",
"0.68152404",
"0.68152404",
"0.6801375",
"0.6801108",
"0.... | 0.0 | -1 |
deletes a given ticket from CCCinema database | def delete() # EXTENSION
sql = "DELETE FROM films WHERE id = $1"
values = [@id]
SqlRunner.run(sql, values)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete()\n sql = \"DELETE FROM tickets WHERE id=#{@id};\"\n SqlRunner.run(sql)\n end",
"def delete\n sql = \"DELETE FROM tickets WHERE id = $1\"\n values = [id]\n SqlRunner.run(sql, values)\n end",
"def destroy\n @ticket.destroy\n end",
"def delete_ticket\n @ticket = Ticket.find(p... | [
"0.8144336",
"0.77924424",
"0.77821",
"0.7665984",
"0.75117606",
"0.7400323",
"0.73921573",
"0.7350771",
"0.72729844",
"0.7236232",
"0.7213921",
"0.72084",
"0.70836437",
"0.70750093",
"0.7021717",
"0.7021717",
"0.7021717",
"0.7021717",
"0.7021717",
"0.7021717",
"0.7016013",
... | 0.0 | -1 |
return the film this ticket is for | def film()
sql = "SELECT * FROM films WHERE id = $1"
values = [@film_id]
pg_result = SqlRunner.run(sql, values)
film_hash = pg_result[0]
film = Film.new(film_hash)
return film
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def film()\n sql = \"SELECT * FROM films WHERE id = $1\"\n values = [@film_id]\n film = SqlRunner.run(sql, values).first\n return Film.new(film)\n end",
"def film\n sql ='SELECT films.*\n FROM films\n WHERE f_id = $1'\n values = [@fk_film_id]\n film = SqlRunner.run(sql,values).first\n... | [
"0.7123806",
"0.672053",
"0.66696143",
"0.6593509",
"0.65752465",
"0.65594864",
"0.653462",
"0.64463824",
"0.64386255",
"0.64127856",
"0.6391474",
"0.63549435",
"0.63549435",
"0.63549435",
"0.63549435",
"0.63549435",
"0.6325068",
"0.63173324",
"0.62750566",
"0.6272012",
"0.62... | 0.61261255 | 25 |
return the screening a ticket is for | def screening()
sql = "SELECT * FROM screenings WHERE id = $1"
values = [@screening_id]
pg_result = SqlRunner.run(sql, values)
screening_hash = pg_result[0]
screening = Screening.new(screening_hash)
return screening
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def screen\n if $game_temp.in_battle\n return $game_troop.screen\n else\n return $game_map.screen\n end\n end",
"def screening?\n self.tip == \"screening\"\n end",
"def most_popular_screening_film\n most_popular = nil\n unsold_tickets = 2 #max capacity of the cinema\n screening... | [
"0.6145317",
"0.6100488",
"0.60194844",
"0.5942157",
"0.5908259",
"0.58549714",
"0.5834012",
"0.579468",
"0.5758781",
"0.5714734",
"0.5695654",
"0.5628547",
"0.55884475",
"0.55547065",
"0.5541342",
"0.5538755",
"0.55246496",
"0.5488587",
"0.5460648",
"0.54376644",
"0.5408142"... | 0.48398176 | 98 |
return the customer who bought this ticket | def customer()
sql = "SELECT * FROM customers WHERE id = $1"
values = [@customer_id]
pg_result = SqlRunner.run(sql, values)
customer_hash = pg_result[0]
customer = Customer.new(customer_hash)
return customer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer\n self.user\n end",
"def current_customer(unit)\n customers.at(unit).first\n end",
"def customer_info(customer)\n return customer\n end",
"def current_customer\n Customer.find_by({ id: session[:customer_id] })\n end",
"def current_user\n current_customer\n end",
"def cust... | [
"0.70813394",
"0.69925123",
"0.69325",
"0.68071675",
"0.67841923",
"0.6756783",
"0.6708404",
"0.6697619",
"0.6656346",
"0.6649654",
"0.6615263",
"0.6587293",
"0.65314305",
"0.64587766",
"0.6446382",
"0.6412533",
"0.63775736",
"0.6358827",
"0.635578",
"0.6352925",
"0.63286334"... | 0.0 | -1 |
Require attribute to be set. Return attribute value. | def require_attr(name)
send(name).tap do |_|
raise AttributeError, "Attribute must be set: #{name}" if _.nil?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_attr(name)\n send(name).tap do |_|\n raise \"Attribute must be set: #{name}\" if _.nil?\n end\n end",
"def is_attribute?; end",
"def get_attribute(name); end",
"def get_attribute(name); end",
"def required(required)\n state_depth_must_be(States::ATTRIBUTE)\n ... | [
"0.7701382",
"0.6624033",
"0.6465094",
"0.6465094",
"0.64115876",
"0.64109665",
"0.6395014",
"0.6395014",
"0.63879555",
"0.6332254",
"0.62541634",
"0.62414527",
"0.62332577",
"0.6221746",
"0.6193909",
"0.6183849",
"0.6143699",
"0.6128453",
"0.6095054",
"0.6095054",
"0.6095054... | 0.7460677 | 1 |
A bigram is a pair of consecutive words. Given a string, return the longest bigram in that string. Include the space between the words. Assume there will be no punctuation. In the case of a tie, return the earlier bigram. | def longest_bigram(str)
bigram_hash = Hash.new
bigram_str = str.split(" ")
bigram_str.each_with_index do |word, i|
if i == bigram_str.length - 1
next
else
bigram_hash[word + " " + bigram_str[i + 1]] = (word + " " + bigram_str[i + 1]).length
end
end
temp_str = ""
temp_str_length = 0
bigram_hash.keys.each do |compound|
if compound.length > temp_str_length
temp_str = compound
temp_str_length = compound.length
end
end
p temp_str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_frequent_bigram(str)\n bigrams_hash = biagram_hash(str)\n bigrams_hash.key(bigrams_hash.values.max)\nend",
"def most_frequent_bigram(str)\n sub_str_arr = []\n bigram_count = Hash.new(0)\n str.each_char.with_index do |char,idx|\n if idx+1 != nil && str[idx..idx+1].length ==2\n ... | [
"0.7207688",
"0.7051371",
"0.7041303",
"0.702443",
"0.70081127",
"0.70071846",
"0.698274",
"0.6979883",
"0.69363034",
"0.6920343",
"0.68968546",
"0.68956643",
"0.68891966",
"0.6885634",
"0.6866206",
"0.6860503",
"0.68334246",
"0.68278694",
"0.6824303",
"0.68168306",
"0.681510... | 0.78004354 | 0 |
Retrieve one API Secret. | def get(secret_id)
request('/accounts/' + account_id + '/secrets/' + secret_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_secret(params)\n return @api_secret\n end",
"def secret\n client.get(\"/user/secret\").fetch(\"result\")\n end",
"def secretkey(apikey)\n get 'secretkey', {apikey: apikey} { |x| x['secretkey'] }\n end",
"def get_secret(secret_name, secret_version = nil)\n url = @vault_url... | [
"0.7861695",
"0.7570085",
"0.7257975",
"0.71788913",
"0.715328",
"0.70748",
"0.7073112",
"0.7039963",
"0.7020124",
"0.70143735",
"0.69242084",
"0.6916224",
"0.6916224",
"0.6913969",
"0.68782926",
"0.6830732",
"0.68221384",
"0.68221384",
"0.68221384",
"0.68221384",
"0.67820835... | 0.7575617 | 1 |
Revoke an API Secret. | def revoke(secret_id)
request('/accounts/' + account_id + '/secrets/' + secret_id, type: Delete)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke\n post('/api/revoke')\n end",
"def revoke(user_id)\n require_user\n\n user = User.find(user_id)\n user.secrets.each do |secret|\n secret.destroy\n end\n\n user.destroy\n end",
"def decrypt_api_secret\n @api_secret_d = @client_api_detail.decrypted_api_s... | [
"0.70278716",
"0.68591785",
"0.6726838",
"0.67246026",
"0.6722175",
"0.66734755",
"0.65290856",
"0.64716893",
"0.64186555",
"0.6398145",
"0.63798296",
"0.63777775",
"0.6376802",
"0.63757986",
"0.6338414",
"0.62342596",
"0.6228308",
"0.61449856",
"0.6137439",
"0.61210626",
"0.... | 0.7718061 | 0 |
All the behavior we want the class CookBook to do C: add all the recipes | def add_recipe(recipe)
@recipes << recipe
write_csv
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(name)\n @cookbook.add_recipe(name)\n end",
"def add_to_cookbook(recipe)\n @cookbook.push(recipe)\n end",
"def setup\n recipes.each { |rcp| rcp.setup }\n end",
"def cook(&block)\n the_recipes = [\n self.class.standard_recipes,\n ... | [
"0.6945913",
"0.69398206",
"0.6747966",
"0.6656515",
"0.65884864",
"0.6547027",
"0.6501342",
"0.64209527",
"0.63748807",
"0.6364102",
"0.6342077",
"0.6332726",
"0.6275663",
"0.6269464",
"0.61720175",
"0.6170489",
"0.6167769",
"0.61657983",
"0.6108907",
"0.6077471",
"0.6077307... | 0.5603127 | 64 |
R: display all recipes in the cook book | def load_csv
# read each line frmo csv and append to recipes collection
CSV.foreach(@csv_file) do |row|
# puts "#{row[0]} | #{row[1]}"
@recipes << Recipe.new(name: row[0], description: row[1], cooking_time: row[2], difficulty: row[3], tested: row[4])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n recipes = @cookbook.all\n # byebug\n @view.display_recipes(recipes)\n end",
"def list\n display_recipes\n end",
"def all\n # returns all recipes\n @recipes\n end",
"def all\n @recipes\n end",
"def all\n @recipes\n end",
"def all\n @recipes\n end",
"def genera... | [
"0.82058334",
"0.79469186",
"0.7315663",
"0.70847344",
"0.70847344",
"0.70847344",
"0.69080645",
"0.68886364",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.6872699",
"0.687269... | 0.0 | -1 |
D: delete the recipe in the CookBook | def remove_recipe(index)
@recipes.delete_at(index)
write_csv
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n recipe_index = @view.index_delete\n @cookbook.remove_recipe(recipe_index)\n @view.listing\n end",
"def delete_saved_recipes\n File.open(\"recipes.txt\", 'w') {|f| f.puts \"\"}\n end",
"def destroy\n @recipe.destroy\n head :no_content\n end",
"def destroy\n... | [
"0.7287634",
"0.70133305",
"0.69676733",
"0.68609166",
"0.67825526",
"0.6682779",
"0.66753685",
"0.66503346",
"0.6618757",
"0.66020876",
"0.6551775",
"0.6527186",
"0.65077984",
"0.6386763",
"0.6385767",
"0.6330814",
"0.6326098",
"0.63168997",
"0.6284455",
"0.627665",
"0.62532... | 0.6007957 | 38 |
U: update a recipe from the cookbook | def write_csv
# header = "name, description"
CSV.open(@csv_file, 'wb') do |csv|
# csv << header
@recipes.each do |row|
csv << [row.name, row.description, row.cooking_time, row.difficulty, row.tested]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_appd_cookbook\n @ssh.exec! \"cd #{APPD_COOKBOOK_PATH}; git pull origin master\", sudo: true\n chef_exec \"berks install --path #{@cookbook_path.first} --berksfile #{APPD_COOKBOOK_PATH}/Berksfile\"\n end",
"def update(recipe)\n return false unless recipe.valid?\n\n @service... | [
"0.6896645",
"0.67673415",
"0.6638705",
"0.6559748",
"0.64904517",
"0.6387237",
"0.6283333",
"0.62814236",
"0.6240274",
"0.6208242",
"0.61692876",
"0.6150001",
"0.6108496",
"0.604654",
"0.60287184",
"0.6014465",
"0.60095936",
"0.6005512",
"0.59941614",
"0.5976714",
"0.5948155... | 0.0 | -1 |
Binds the given variables to the corresponding placeholders in the SQL text. See Databaseexecute for a description of the valid placeholder syntaxes. Example: stmt = db.prepare( "select from table where a=? and b=?" ) stmt.bind_params( 15, "hello" ) See also execute, bind_param, Statementbind_param, and Statementbind_params. | def bind_params( *bind_vars )
index = 1
bind_vars.flatten.each do |var|
if Hash === var
var.each { |key, val| bind_param key, val }
else
bind_param index, var
index += 1
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind_params( *bind_vars )\n @statement.bind_params( *bind_vars )\n end",
"def bind_named_parameters( params )\n check_parameter_count!( params.size )\n params.each_pair do | param, value |\n position = param_position_of( param )\n if position > 0 then\n bind_parameter... | [
"0.7914118",
"0.70524013",
"0.6406802",
"0.6324408",
"0.62096703",
"0.62084997",
"0.60961884",
"0.60810673",
"0.6011438",
"0.59015197",
"0.5875792",
"0.58161384",
"0.57922715",
"0.57697296",
"0.574275",
"0.56216246",
"0.5585722",
"0.543515",
"0.5432835",
"0.5409647",
"0.53952... | 0.67408913 | 2 |
Execute the statement. This creates a new ResultSet object for the statement's virtual machine. If a block was given, the new ResultSet will be yielded to it; otherwise, the ResultSet will be returned. Any parameters will be bound to the statement using bind_params. Example: stmt = db.prepare( "select from table" ) stmt.execute do |result| ... end See also bind_params, execute!. | def execute( *bind_vars )
reset! if active? || done?
bind_params(*bind_vars) unless bind_vars.empty?
@results = ResultSet.new(@connection, self)
step if 0 == column_count
yield @results if block_given?
@results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(stmt, bindvars={})\n sanity_check(stmt)\n\n if @convert_types\n bindvars = DBI::Utils::ConvParam.conv_param(driver_name, bindvars)\n end\n\n sth = StatementHandle.new(@handle.execute(stmt, bindvars), true, true, @convert_types, true)\n # FIXME trace sth.trace(@trace_mode... | [
"0.78412986",
"0.7522994",
"0.7345846",
"0.6927035",
"0.6924953",
"0.6923811",
"0.6919758",
"0.66868365",
"0.6662286",
"0.66231287",
"0.6573493",
"0.6498426",
"0.6485987",
"0.64362",
"0.6425445",
"0.6412007",
"0.63899696",
"0.63838255",
"0.6362206",
"0.6327105",
"0.6318795",
... | 0.7812787 | 1 |
Execute the statement. If no block was given, this returns an array of rows returned by executing the statement. Otherwise, each row will be yielded to the block. Any parameters will be bound to the statement using bind_params. Example: stmt = db.prepare( "select from table" ) stmt.execute! do |row| ... end See also bind_params, execute. | def execute!( *bind_vars, &block )
execute(*bind_vars)
block_given? ? each(&block) : to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute( *params )\n bind( *params )\n begin\n # save the error state at the beginning of the execution. We only want to\n # reraise the error if it was raised during this execution.\n s_before = $!\n if block_given? then\n while row = next_row\n yield... | [
"0.77273667",
"0.7425375",
"0.7233965",
"0.7043422",
"0.6793586",
"0.6675891",
"0.6615595",
"0.66002375",
"0.65986073",
"0.65450394",
"0.64950895",
"0.6493661",
"0.6486962",
"0.6459792",
"0.64573944",
"0.64573944",
"0.6450475",
"0.6346525",
"0.6297712",
"0.6286969",
"0.627680... | 0.7001811 | 4 |
Returns true if the statement is currently active, meaning it has an open result set. | def active?
@rows && !@rows.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active?\n return false unless @connection.open?\n # return true if @connection.transaction_started\n select(\"SELECT 1 FROM RDB$DATABASE\")\n true\n rescue\n false\n end",
"def active?\n return false unless @connection\n raw_connection_do 'SELECT 1'\... | [
"0.7841427",
"0.7833315",
"0.77466875",
"0.71090865",
"0.7083131",
"0.6994848",
"0.68817127",
"0.674244",
"0.6712915",
"0.66582954",
"0.66221863",
"0.6622152",
"0.6619347",
"0.66106075",
"0.65719855",
"0.65653354",
"0.65440273",
"0.6524113",
"0.6522171",
"0.65104294",
"0.6497... | 0.674425 | 7 |
Return an array of the column names for this statement. Note that this may execute the statement in order to obtain the metadata; this makes it a (potentially) expensive operation. | def columns
must_be_open!
return @columns.map(&:first)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_names\n columns.map(&:name)\n end",
"def column_names\n @column_names ||= columns.collect(&:name)\n end",
"def columns(sql)\n return self.dbh.execute(sql).column_names\n end",
"def column_names\n @columns.keys\n end",
"def column_names\n @entity_colum... | [
"0.7842423",
"0.7661916",
"0.76400715",
"0.7555133",
"0.7448656",
"0.73712766",
"0.72986823",
"0.7296484",
"0.7291443",
"0.7285645",
"0.7264878",
"0.72425413",
"0.7175319",
"0.7128576",
"0.7075359",
"0.7057506",
"0.70546097",
"0.70503426",
"0.70461655",
"0.699372",
"0.6977553... | 0.6480896 | 42 |
Return an array of the data types for each column in this statement. Note that this may execute the statement in order to obtain the metadata; this makes it a (potentially) expensive operation. | def types
must_be_open!
@columns.map(&:last)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_types\n @column_types ||= @columns.values\n end",
"def types\n @stmt.types\n end",
"def types\n @stmt.types\n end",
"def col_types\n result = {}\n columns.each do |c|\n result[c.header] = c.type\n end\n result\n end",
"def get_data_types(table_na... | [
"0.7469181",
"0.71150976",
"0.7005474",
"0.68865716",
"0.67476064",
"0.65647674",
"0.63629097",
"0.6311052",
"0.62604487",
"0.6249",
"0.62456113",
"0.6181214",
"0.6137428",
"0.6130923",
"0.6054862",
"0.6053559",
"0.6029096",
"0.6018177",
"0.5953607",
"0.59502286",
"0.59054476... | 0.68075883 | 4 |
Performs a sanity check to ensure that the statement is not closed. If it is, an exception is raised. | def must_be_open! # :nodoc:
if closed?
raise Thredis::Exception, "cannot use a closed statement"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_statement(stmt)\n raise InterfaceError, \"Statement is empty, or contains nothing but whitespace\" if stmt !~ /\\S/\n end",
"def integrity_check\n execute( \"PRAGMA integrity_check\" ) do |row|\n raise Exceptions::DatabaseException, row[0] if row[0] != \"ok\"\n end\n end",
... | [
"0.6775886",
"0.614622",
"0.6121186",
"0.6121186",
"0.60484594",
"0.59901685",
"0.59743994",
"0.5653497",
"0.56164974",
"0.56164974",
"0.54735667",
"0.5429225",
"0.5390244",
"0.5353985",
"0.52740806",
"0.52547145",
"0.5230944",
"0.52300596",
"0.5227438",
"0.5227438",
"0.52123... | 0.6764198 | 1 |
ZZZ def convert_type(rows, columns) rows.each do |row| for i in 0...row.size row[i] = Integer(row[i]) if columns[i].last == 'int' end end rows end | def query_thredis(prepare_only)
if prepare_only
@rows = @connection.redis.sqlprepare(@sql)
else
@rows = @connection.redis.sql(@sql, *@params)
@prepare_only = false
end
if @rows.is_a? Integer
@rows, @columns, @connection.changes = [], [], @rows
else
@columns = @rows.shift
## @rows = convert_type(@rows, @columns)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = ... | [
"0.7683182",
"0.7397243",
"0.7195339",
"0.7081908",
"0.68820935",
"0.6714796",
"0.6674798",
"0.65500486",
"0.6462369",
"0.63822156",
"0.63781893",
"0.6216193",
"0.6197715",
"0.6109297",
"0.60963625",
"0.6086278",
"0.6058896",
"0.6053657",
"0.5999433",
"0.59915835",
"0.5989856... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.