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 |
|---|---|---|---|---|---|---|
Returns an array [stacks, blocks] | def calc_stacks(n, stack_size=64)
[stacks = (n / stack_size).floor, n - (stacks * stack_size)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blocks\n @block_stacks.map { |candidates| candidates&.first }\n end",
"def get_blocks\n if (branches = @cur_state.branches[@tape.val])\n branches.map { |branch| branch.block } \n else\n [@cur_state.default]\n end\n end",
"def stack\n return (@stack&.stack || [])... | [
"0.79036254",
"0.68447727",
"0.6736061",
"0.6695343",
"0.6401598",
"0.6382057",
"0.6346067",
"0.62985915",
"0.62630713",
"0.6206717",
"0.61008775",
"0.6053213",
"0.6051162",
"0.5989511",
"0.5967226",
"0.595517",
"0.5944317",
"0.5935325",
"0.5935325",
"0.59115636",
"0.58667994... | 0.598758 | 14 |
Get proper pluralization pluralize 1, "stack" => "1 stack" pluralize 3, "stack" => "3 stacks" | def pluralize(n, str)
"#{n} #{str + (n == 1 ? "" : "s")}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pluralize_with_count( count=2 )\n count > 1 ? pluralize_without_count : singularize\n end",
"def pluralize\n self[-1] == 's' ? \"#{self}es\" : \"#{self}s\"\n end",
"def pluralize(count, singular, plural = nil)\n \"#{count} \" + if count == 1\n singular\n elsif plural\n ... | [
"0.7735955",
"0.7571325",
"0.75603735",
"0.74320835",
"0.74320835",
"0.7398042",
"0.738987",
"0.7385635",
"0.7377726",
"0.72870207",
"0.72658676",
"0.7218908",
"0.721805",
"0.7212929",
"0.7212703",
"0.7212703",
"0.7212703",
"0.7212163",
"0.71872634",
"0.7184885",
"0.71659935"... | 0.6957761 | 36 |
Create an intelligent output, i.e. don't print something like "0 blocks" | def get_output(stacks, blocks, put_shulkers=false)
s = ""
put_stacks, put_blocks = stacks.nonzero?, blocks.nonzero?
if put_shulkers
s += pluralize boxes = (stacks / 27).floor, "shulker"
# Strip the necessary # of stacks off the count.
stacks -= boxes * 27
put_stacks = stacks.nonzero?
s += ", " if put_stacks or put_blocks
end
if put_stacks
s += pluralize stacks, "stack"
s += ", " if put_blocks
end
s += pluralize blocks, "block" if put_blocks
s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_none(msg)\n tag = ' '\n print_formatted(tag,msg)\n end",
"def to_s; \"<Block #{length}>\"; end",
"def render\n\t\tprint \"cl1 cl2 cl3 cl4 cl5 cl6 cl7 cl8 cl9 c10\\n\"\n\t\t(0..9).each do |row|\n\t\t\t(0..9).each do |col|\n\t\t\t\tif @grid[row][col].is_flagged\n\t\t\t\t\tprint... | [
"0.633807",
"0.62709063",
"0.6128887",
"0.6080856",
"0.6064031",
"0.603488",
"0.60185343",
"0.60178137",
"0.6004134",
"0.59900373",
"0.598881",
"0.5984252",
"0.5984252",
"0.5968791",
"0.59390616",
"0.59125316",
"0.59097826",
"0.58964646",
"0.58925974",
"0.5889425",
"0.5884201... | 0.64846516 | 0 |
GET /polco_groups GET /polco_groups.xml | def index
#@polco_groups = PolcoGroup.all.paginate(:page => params[:page], :per_page => 20) # where(name: /#{params[:q]}/i)
@groups = Hash.new
@groups[:states] = PolcoGroup.states.all.paginate(:page => params[:page], :per_page => 20)
@groups[:districts] = PolcoGroup.districts.all.paginate(:page => params[:page], :per_page => 20)
@groups[:customs] = PolcoGroup.customs.all.paginate(:page => params[:page], :per_page => 20)
respond_to do |format|
format.html # index.haml
format.xml { render :xml => @polco_groups }
format.json { render :json => @polco_groups.map{|g| {:id => g.id, :name => g.name}} }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_use... | [
"0.6632415",
"0.6632415",
"0.6250863",
"0.62450117",
"0.6227549",
"0.6214434",
"0.62011504",
"0.62011504",
"0.6161222",
"0.6149713",
"0.61163837",
"0.6101761",
"0.6100348",
"0.60714644",
"0.60709774",
"0.6061873",
"0.60266846",
"0.60177326",
"0.60139126",
"0.598737",
"0.59611... | 0.6596778 | 2 |
for the autogroup work | def custom_groups
groups_list = prep_format(PolcoGroup.where(name: /#{params[:q]}/i, type: :custom))
respond_to do |format|
format.json {render :json => groups_list}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group; end",
"def find_work\n\n end",
"def do_work\n end",
"def i_groups; end",
"def work_pool; end",
"def current_group\n end",
"def process_issues rmp_id, force_new_task = false\n\n (1..$msp.Tasks.Count).each do |i|\n\n # check msp task\n next unless mst = $msp.Tasks(i)\n\n i... | [
"0.65304726",
"0.64990455",
"0.6234683",
"0.6223546",
"0.61844134",
"0.6022724",
"0.59699833",
"0.58951044",
"0.58951044",
"0.58951044",
"0.5811327",
"0.5729674",
"0.5729674",
"0.5729674",
"0.5701306",
"0.5695682",
"0.5644302",
"0.5638896",
"0.5637322",
"0.5628927",
"0.560115... | 0.0 | -1 |
GET /polco_groups/1 GET /polco_groups/1.xml | def show
@bills = @polco_group.get_bills
@members = @polco_group.members
@followers = @polco_group.followers
respond_to do |format|
format.html # show.haml
format.xml { render :xml => @polco_group }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_user, params) }\n format.xml { render :xml => Group.get_groups(params.merge({:show => 'all'})) }\n end\n end",
"def index\n respond_to do |format|\n format.html { @groups = Group.get_groups(current_use... | [
"0.6604452",
"0.6604452",
"0.6496511",
"0.63692397",
"0.63457036",
"0.63249075",
"0.63249075",
"0.6271248",
"0.60939056",
"0.6090448",
"0.6070155",
"0.60603446",
"0.60496134",
"0.602715",
"0.6008949",
"0.6006098",
"0.60058933",
"0.59982693",
"0.5993061",
"0.59766114",
"0.5976... | 0.62474316 | 8 |
GET /polco_groups/new GET /polco_groups/new.xml | def new
@polco_group = PolcoGroup.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @polco_group }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n Group.rebuild! if nil.|Group.find(:first).rgt\n\t @group = Group.new\n\t @groups = current_user.get_unique_group_branches.map {|g| g.get_self_and_children?}.flatten\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @group }\n end\n end",
"def n... | [
"0.7325297",
"0.718781",
"0.7174907",
"0.7173837",
"0.71379966",
"0.71379966",
"0.71379966",
"0.71379966",
"0.71379966",
"0.71379966",
"0.71379966",
"0.71379966",
"0.71379966",
"0.7100784",
"0.70862955",
"0.70862955",
"0.7070828",
"0.7053739",
"0.7034184",
"0.70267713",
"0.70... | 0.7936298 | 0 |
POST /polco_groups POST /polco_groups.xml | def create
# TODO -- might not be needed -- load or authorize
@polco_group = PolcoGroup.new(params[:polco_group])
@polco_group.title = "#{params[:polco_group][:name]}_custom"
respond_to do |format|
if @polco_group.save
format.html { redirect_to(@polco_group, :notice => 'PolcoGroup was successfully created.') }
format.xml { render :xml => @polco_group, :status => :created, :location => @polco_group }
else
format.html { render :action => "new" }
format.xml { render :xml => @polco_group.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @polco_group = PolcoGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @polco_group }\n end\n end",
"def create\n ip = request.location\n @user = current_user\n @group = @user.groups_as_owner.new(params[:group])\n params[:grou... | [
"0.59693825",
"0.59011346",
"0.5882576",
"0.5850695",
"0.5850695",
"0.5830923",
"0.5805485",
"0.56833404",
"0.5673835",
"0.5673296",
"0.5671528",
"0.5671528",
"0.56712943",
"0.56535393",
"0.5637584",
"0.56219417",
"0.56008923",
"0.5593232",
"0.55852175",
"0.55807257",
"0.5554... | 0.65015924 | 0 |
PUT /polco_groups/1 PUT /polco_groups/1.xml | def update
@polco_group = PolcoGroup.find(params[:id])
@polco_group.title = "#{params[:polco_group][:name]}_custom"
respond_to do |format|
if @polco_group.update_attributes(params[:group])
format.html { redirect_to(@polco_group, :notice => 'PolcoGroup was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @polco_group.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateGroup params = {}\n \n APICall(path: 'groups.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @grupo = Grupo.find(params[:id])\n\n respond_to do |format|\n if @grupo.update_attributes(params[:grupo])\n flash[:notice] = \"Los datos del Gru... | [
"0.60886693",
"0.5980185",
"0.5933728",
"0.58142257",
"0.58082825",
"0.5801515",
"0.5788851",
"0.5759366",
"0.5754389",
"0.5753049",
"0.5745206",
"0.572901",
"0.5718523",
"0.5705592",
"0.5703783",
"0.5703783",
"0.57024825",
"0.5700052",
"0.56993425",
"0.569925",
"0.569925",
... | 0.7052905 | 0 |
DELETE /polco_groups/1 DELETE /polco_groups/1.xml | def destroy
@polco_group = PolcoGroup.find(params[:id])
@polco_group.destroy
respond_to do |format|
format.html { redirect_to(polco_groups_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set3_04b_delete_group()\n group = \"test_group\"\n user = \"test_user\"\n \n @test_acl.create_principal(user)\n @test_acl.create_group(group, [\"ALL\"], [user])\n \n query = \"doc(\\\"#{@col_path}Principals.xml\\\")//node()[@id=\\\"#{user}\\\"]/membership/mgroup[@idref=\\\"#{group}\\\... | [
"0.693945",
"0.67653877",
"0.6716535",
"0.66650444",
"0.6605762",
"0.6524444",
"0.65234166",
"0.6463111",
"0.6456078",
"0.64131325",
"0.64057183",
"0.63950104",
"0.6377076",
"0.6376404",
"0.6372835",
"0.6372835",
"0.6366491",
"0.63500184",
"0.6348827",
"0.6348827",
"0.6348827... | 0.7511717 | 0 |
GET /applications GET /applications.json | def index
if current_user.is_admin
@applications = Application.all
puts @applications
elsif current_user.is_seeker
@applications = Application.where(jobseeker_id: Jobseeker.find_by(user_id: current_user.id).id)
elsif current_user.is_biz
@applications = Application.where(job_id: Job.where(bizowner_id: Bizowner.find_by(user_id: current_user.id).id))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def applications_list\n get \"applications\"\n end",
"def get_applications\n http_get_request(Scalarium.applications_url)\n end",
"def index\n @applications = Application.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @applications }\n... | [
"0.86093307",
"0.79462093",
"0.78742266",
"0.7813113",
"0.7733298",
"0.7699168",
"0.7673586",
"0.75540197",
"0.7525506",
"0.74982053",
"0.74982053",
"0.7469429",
"0.74091655",
"0.72886604",
"0.7258537",
"0.72536296",
"0.72512525",
"0.72512525",
"0.72512525",
"0.72512525",
"0.... | 0.6666625 | 46 |
POST /applications POST /applications.json | def create
@job_start_date = Job.find_by(id: params[:id]).job_start_date.to_date
@job_end_date = Job.find_by(id: params[:id]).job_end_date.to_date
@seeker_start_date = Jobseeker.find_by(user_id: current_user.id).start_date.to_date
@seeker_end_date = Jobseeker.find_by(user_id: current_user.id).end_date.to_date
if @job_start_date < @seeker_start_date
redirect_to root_path, notice: 'Unable to apply. Job starts before your available period'
return
elsif @job_end_date > @seeker_end_date
redirect_to root_path, notice: 'Unable to apply. Job ends after your availabilty period'
return
end
@application = Application.new(job_id: params[:id], jobseeker_id: Jobseeker.find_by(user_id: current_user.id).id, status: "Pending")
if @application.save
ApplicationNotificationMailer.notification_email(params[:id]).deliver
redirect_to @application, notice: 'You application has been sent. Good luck!'
else
redirect_to root_path, notice: 'You have already applied for this job'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @application = Application.new(application_params)\n\n if @application.save\n render json: @application, status: :created, location: api_application_path(@application)\n else\n render json: @application.errors.full_messages.join(', '), status: :unprocessable_entity\n end\n end",... | [
"0.75115496",
"0.7120853",
"0.7010377",
"0.69720936",
"0.6955418",
"0.6880274",
"0.68689686",
"0.68499",
"0.68345064",
"0.68260735",
"0.68003273",
"0.67571235",
"0.67512643",
"0.6713185",
"0.6713185",
"0.666663",
"0.6665081",
"0.66627544",
"0.66618484",
"0.6633409",
"0.661857... | 0.0 | -1 |
PATCH/PUT /applications/1 PATCH/PUT /applications/1.json | def update
respond_to do |format|
if @application.update(application_params)
format.html { redirect_to @application, notice: 'Application was successfully updated.' }
format.json { render :show, status: :ok, location: @application }
else
format.html { render :edit }
format.json { render json: @application.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_app data={}\n put '/app', data\n end",
"def update\n if @application.update(application_params)\n render json: @application, status: :ok, location: api_application_path(@application)\n else\n render json: @application.errors.full_messages.join(', '), status: :unprocessable_... | [
"0.7152944",
"0.7136675",
"0.7115411",
"0.70114315",
"0.7003497",
"0.6962699",
"0.69392174",
"0.6899615",
"0.6899615",
"0.6898765",
"0.68742436",
"0.6868403",
"0.68482035",
"0.68115634",
"0.68115634",
"0.68107307",
"0.68107307",
"0.68107307",
"0.680725",
"0.6806085",
"0.68037... | 0.6719687 | 27 |
DELETE /applications/1 DELETE /applications/1.json | def destroy
@application.destroy
respond_to do |format|
format.html { redirect_to applications_url, notice: 'Application was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client.app_destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to apps_url }\n format.json { head :no_content }\n end\n end",
"def delete_application(client, options)\n if !options[:application].nil?\n application = client.applications.get options[:appl... | [
"0.7910182",
"0.75623596",
"0.7552732",
"0.7552732",
"0.7552732",
"0.75480956",
"0.75480956",
"0.7524208",
"0.7524208",
"0.7420919",
"0.7420919",
"0.74039817",
"0.7369016",
"0.7369016",
"0.7369016",
"0.7363147",
"0.7355945",
"0.7339149",
"0.73071563",
"0.73071563",
"0.7307156... | 0.7065258 | 48 |
Use callbacks to share common setup or constraints between actions. | def set_application
@application = Application.find(params[:id])
@job = Job.find_by(id: @application.job_id)
@jobseeker = Jobseeker.find_by(id: @application.jobseeker_id)
@age = Date.today.year - @jobseeker.dob.year
@applicant = User.find_by(id: @jobseeker.user_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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Parses the commandline arguments and runs the executable. Calls `Kernelexit` at the end, so it never returns. | def parse!
begin
parse
rescue Exception => e
raise e if @options[:trace] || e.is_a?(SystemExit)
$stderr.print "#{e.class}: " unless e.class == RuntimeError
$stderr.puts "#{e.message}"
exit 1
end
exit 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n begin\n raise TooManyArgumentsError.new(@arguments) if @arguments.length > 1\n \n print_version if @options.version?\n scan if @options.scan?\n rename_given_file unless @arguments.empty?\n run_gui if @arguments.empty?\n \n raise Error\n re... | [
"0.6831748",
"0.6662406",
"0.64780813",
"0.6459409",
"0.64531523",
"0.64427316",
"0.643199",
"0.64210933",
"0.6416214",
"0.6375755",
"0.6360391",
"0.63353175",
"0.63198113",
"0.6318173",
"0.6300136",
"0.6292529",
"0.6291481",
"0.62793154",
"0.62793154",
"0.62793154",
"0.62793... | 0.0 | -1 |
Parses the commandline arguments and runs the executable. This does not handle exceptions or exit the program. | def parse
@opts = OptionParser.new(&method(:set_opts))
@opts.parse(@args)
@options
run_headless_web_browser
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n begin\n raise TooManyArgumentsError.new(@arguments) if @arguments.length > 1\n \n print_version if @options.version?\n scan if @options.scan?\n rename_given_file unless @arguments.empty?\n run_gui if @arguments.empty?\n \n raise Error\n re... | [
"0.7264311",
"0.722384",
"0.71330595",
"0.71011466",
"0.70697147",
"0.70550066",
"0.70316285",
"0.7018813",
"0.69785887",
"0.6973309",
"0.6973309",
"0.6973309",
"0.6973309",
"0.6973309",
"0.6973309",
"0.6967043",
"0.6966249",
"0.69627464",
"0.6923506",
"0.6919222",
"0.6886222... | 0.0 | -1 |
End parse Run headless web browser | def run_headless_web_browser
require File.dirname(__FILE__) + '/headlesswebbrowser'
headless_web_browser = Cssp::PhantomJS.new()
headless_web_browser.config_file_path = @options[:config_file_dir] + '/cssp_config.js'
headless_web_browser.build
headless_web_browser.prune
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Close\r\n\r\n # Close browser\r\n $browser.close\r\n $headless.destroy\r\n\r\nend",
"def parse\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse(@args)\n @options\n run_headless_web_browser\n end",
"def kill_browser\n Praline::kill_browser\n end",
"def... | [
"0.6271492",
"0.5946006",
"0.58983064",
"0.58686393",
"0.5823811",
"0.57689846",
"0.57689846",
"0.57405186",
"0.5734102",
"0.5734102",
"0.5734102",
"0.5726214",
"0.5686363",
"0.5660421",
"0.557751",
"0.5567707",
"0.554181",
"0.54720086",
"0.5450935",
"0.541767",
"0.5408571",
... | 0.5546061 | 16 |
picture: key in _config.yml | def pconfig
@pconfig ||= {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_defaults\n self.imagepath ||= Rails.application.config.missing_sign_image\n end",
"def image_name\n setting.data[\"image\"]\n end",
"def config_flickr\n FlickRaw.api_key = YAML.load_file(\"#{config_dir}/config.yml\")['flickr_api_key']\n end",
"def casein_config_logo\n \t'/images/logo... | [
"0.6165059",
"0.6162062",
"0.60885805",
"0.60800415",
"0.6076915",
"0.6041487",
"0.5919229",
"0.59163374",
"0.58619475",
"0.5836156",
"0.58352256",
"0.58337235",
"0.58309215",
"0.58229053",
"0.58182085",
"0.58166945",
"0.58166945",
"0.5763797",
"0.57625043",
"0.57117635",
"0.... | 0.0 | -1 |
Returns whatever params are originally passed in. | def stub_template_parsing
template_stub = Object.new
Liquid::Template.stubs(:parse).with do |params|
template_stub.stubs(:render).returns(params)
end.returns(template_stub)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params\n _params\n end",
"def params\n return @params || NO_PARAMS if frozen?\n @params ||= NO_PARAMS.dup\n end",
"def get_params()\n return self.params.keys\n end",
"def params\n return @params\n end",
"def params\n @@params\n end",
"def request_params( params = {} )... | [
"0.7510946",
"0.7494168",
"0.74740535",
"0.7417644",
"0.7351428",
"0.7296347",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"0.72948146",
"... | 0.0 | -1 |
What's the fullyqualified path of this boot JAR? Returns a FilePath object. (This is useful because the exact name of the boot JAR depends on the exact JVM you're running it with; this uses the Terracotta Java code to compute the name, ensuring that we don't duplicate the algorithm almost certainly incorrectly here.) | def path
# We cache this, since it can be fairly expensive to run the command to figure out
# what this should be.
if @path.nil?
outputproperty, errorproperty = @platform.next_output_properties
@ant.java(:classname => 'com.tc.object.tools.BootJarSignature',
:classpath => @module_set['dso-l1'].subtree('src').classpath(@build_results, :full, :runtime).to_s,
:jvm => @jvm.java,
:fork => true,
:failonerror => true,
:dir => @build_results.tools_home.to_s) do
@ant.redirector(:outputproperty => outputproperty, :alwayslog => true)
end
# Parse the output in case the JVM prints out additional messages, only the line
# that contains the actual boot jar name will be used.
# On MacOSX the JVM sometimes prints "HotSpot not at correct virtual address.
# Sharing disabled." for instance. Without parsing the output, the name of the
# bootjar file will be wrong.
rawout = @ant.get_ant_property(outputproperty)
out = rawout
rawout.each do |line|
if line =~ /^dso-boot-/
out = line
break
end
end
@path = FilePath.new(@directory, out)
end
@path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shared_boot_jar_directory\n FilePath.new(@build_dir, \"boot-jars\")\n end",
"def jar_path(p)\n path = p.sub(/^file:/, \"\").sub(/!.*/, \"\")\n path = path.sub(/^\\//, \"\") if win_platform? && path =~ /^\\/[A-Za-z]:/\n path\n end",
"def crypto_jar_internal_path(jar)\n libs = jar_... | [
"0.729299",
"0.67222077",
"0.6380369",
"0.631765",
"0.62999696",
"0.6279548",
"0.6253895",
"0.6236919",
"0.6099677",
"0.6094222",
"0.6052982",
"0.6022258",
"0.6018063",
"0.5983306",
"0.5939249",
"0.5936557",
"0.59211427",
"0.59173006",
"0.59156287",
"0.59054846",
"0.59049624"... | 0.68067217 | 1 |
Make sure there's a boot JAR at the given location. This will delete any existing file at the specified location! Be careful. This will only create this boot JAR once for a given instance of this object, so you don't have to worry about repeating work. | def ensure_created
unless @created
classpath = @module_set['dso-tests-jdk15'].subtree('src').classpath(@build_results, :full, :runtime)
puts("Creating boot JAR with: #{@jvm} and config file: #{@config_file}")
File.delete(path.to_s) if FileTest.exist?(path.to_s)
sysproperties = {
PropertyNames::TC_BASE_DIR => @static_resources.root_dir.to_s,
PropertyNames::MODULES_URL => @build_results.modules_home.to_url
}
begin
@ant.java(:classname => 'com.tc.object.tools.BootJarTool',
:classpath => classpath.to_s,
:jvm => @jvm.java,
:fork => true,
:failonerror => true,
:dir => @build_results.tools_home.to_s) do
sysproperties.each do |name, value|
@ant.sysproperty(:key => name.xml_escape(true),
:value => value.xml_escape(true))
end
@ant.arg(:value => '-o')
@ant.arg(:value => @directory.ensure_directory)
@ant.arg(:value => '-f')
@ant.arg(:value => @config_file)
@ant.arg(:value => '-q')
end
rescue
raise("Bootjar creation failed")
end
@created = true
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inject_jar(jar_path)\n jar_dir = tmp_app_path.join('Contents/Java')\n jar_dir.rmtree\n jar_dir.mkdir\n cp Pathname.new(jar_path), jar_dir\n end",
"def destroy(location)\n begin\n Pem::Logger.logit(\"Removing #{location}\")\n FileUtils.rm_rf(locati... | [
"0.6109842",
"0.6079872",
"0.6020823",
"0.6016218",
"0.5830876",
"0.5824421",
"0.5780001",
"0.5667129",
"0.5667129",
"0.5506725",
"0.54951495",
"0.5434579",
"0.5432811",
"0.5420999",
"0.5411961",
"0.53789455",
"0.5361506",
"0.5349101",
"0.53482455",
"0.5330091",
"0.5291847",
... | 0.6321847 | 0 |
Have we created this boot JAR yet? | def exist?
@created
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bootstrapped?\n raise \"Invalid Bootstrapper\"\n end",
"def bootstrapped?\n # @bootstrapped ||= !run('if [ -f /var/poolparty/bootstrapped ]; then echo \"YES\"; fi').match(/YES/).nil?\n @bootstrapped ||= !run('if [ -f /var/poolparty/bootstrapped ]; then echo \"YES\"; fi').chomp.empty... | [
"0.73813003",
"0.70551485",
"0.69826883",
"0.690088",
"0.67788357",
"0.6606966",
"0.6511709",
"0.6461377",
"0.643953",
"0.6413335",
"0.6403176",
"0.6297651",
"0.6274813",
"0.6262055",
"0.62575424",
"0.62564325",
"0.6130477",
"0.6082981",
"0.60324246",
"0.60216004",
"0.5978849... | 0.0 | -1 |
mode:Ruby; tabwidth:4; coding:USASCII; vi:set ft=ruby ts=4 fenc=USASCII : Example for wrapexec. Replace your script below. | def main
print "Hello world !! I am '#$0'\n"
return 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def usage\n puts \"Usage: akaza exec|wsrb|exec_wsrb FILE_NAME\"\nend",
"def script; end",
"def script; end",
"def result_of_executing_the_commands\n @commands = \":set ft=ruby\r\" + @commands\n RobotVim::Runner.new.run(:input_file => @input, :commands => @commands)\nend",
"def make_runnable(code)\n r... | [
"0.58934945",
"0.5837265",
"0.5837265",
"0.5559588",
"0.55195606",
"0.54865474",
"0.5468192",
"0.5315692",
"0.5306723",
"0.5285056",
"0.5285056",
"0.52834463",
"0.52663547",
"0.5258956",
"0.5257607",
"0.52551585",
"0.5242363",
"0.52340305",
"0.5219313",
"0.5161903",
"0.513712... | 0.0 | -1 |
build watchers for a set of mailboxes | def initialize(mailboxes)
self.watchers = []
mailboxes.each {|box| self.watchers << MailboxWatcher.new(box)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_watchers(obj)\n if user.allowed_to?(\"add_#{obj.class.name.underscore}_watchers\".to_sym, obj.project)\n addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase}\n unless addresses.empty?\n User.active.having_mail(addresses).each do |w|\n obj.add_wat... | [
"0.6625029",
"0.58762115",
"0.5699706",
"0.55986005",
"0.55883956",
"0.5588161",
"0.55659676",
"0.5532199",
"0.5530193",
"0.5530193",
"0.5525161",
"0.55043024",
"0.5487518",
"0.5396533",
"0.5370927",
"0.53650934",
"0.5359076",
"0.53409445",
"0.53271246",
"0.53244436",
"0.5273... | 0.74525857 | 0 |
start each of the watchers to running | def run
watchers.each(&:run)
self.running = true
sleep_while_running
ensure
quit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def watch\n start_watch\n end",
"def watch!\n start_watch true\n end",
"def start\n run_all if @options[:all_on_start]\n end",
"def start\n run_all if options[:all_on_start]\n end",
"def start\n run_all if options[:all_on_start]\n end",
"def start\n run_all if... | [
"0.70683455",
"0.704314",
"0.7041177",
"0.70304525",
"0.70304525",
"0.70304525",
"0.69761837",
"0.69615877",
"0.69147354",
"0.68628025",
"0.68527764",
"0.6799047",
"0.6755888",
"0.6701634",
"0.6568977",
"0.65603554",
"0.6539797",
"0.6517093",
"0.6442863",
"0.64336795",
"0.639... | 0.787525 | 0 |
quit each of the watchers when we're done running | def quit
watchers.each(&:quit)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quit\n @watch.quit # <-- should close all the files\n # and that should allow the sincedb_write to succeed if it could not before\n _sincedb_write\n end",
"def clear_watchers\n clear_all_watchers\n puts \"All watchers removed\"\n end",
"def run\n watchers.each(&:run)\n ... | [
"0.7150497",
"0.705695",
"0.6829095",
"0.6804164",
"0.6565564",
"0.6564466",
"0.65527344",
"0.6536513",
"0.6503505",
"0.6476618",
"0.64676833",
"0.6460868",
"0.64556795",
"0.64095783",
"0.6373465",
"0.63217527",
"0.6304432",
"0.6286655",
"0.62769616",
"0.62562984",
"0.6250181... | 0.88822365 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_country
@country = Country.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 country_params
params.fetch(:country, {})
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 |
Because this controller manages several different programs we need to ask ProgramFunction for the actual program name given the qc_inspection_type_code (url_param). | def program_name(qc_inspection_type_code)
ProgramFunction.generic_program_name( 'QC', qc_inspection_type_code )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def program_name\n Quickl.program_name\n end",
"def browse(program_name, program_specialization, requisite1, requisite2, opts={})\n \n defaults = {\n :nav_homepage => true,\n :browse_person => '%%_username%%', #user is the dynvar from users.csv\n :program_name_dyn_var => 'progra... | [
"0.588297",
"0.574445",
"0.5517274",
"0.5400045",
"0.53680587",
"0.53649807",
"0.53577924",
"0.52776587",
"0.52727246",
"0.5230957",
"0.515652",
"0.5150896",
"0.5134106",
"0.50242215",
"0.5013872",
"0.5002085",
"0.49926698",
"0.49716243",
"0.4969445",
"0.49632096",
"0.4943704... | 0.7682349 | 0 |
CURRENT SEARCH / INSPECTION Convenience action to quickly get back to the inspection the user was working on. | def current_qc_inspection
return if authorise_for_web(program_name(params[:id]),'edit')== false
qc_current_inspection = ActiveRecord::Base.connection.select_one("select * from qc_current_inspections
where user_id = #{session[:user_id].id}
and qc_inspection_type_code = '#{params[:id]}'")
if qc_current_inspection.nil? || qc_current_inspection.qc_inspection_id.nil?
redirect_to_index("'You have not yet captured an inspection for #{params[:id]}'", "''")
else
@qc_inspection = QcInspection.find(qc_current_inspection.qc_inspection_id)
params[:id_value] = @qc_inspection.qc_inspection_type.qc_inspection_type_code
params[:id] = @qc_inspection.id
edit_qc_inspection
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_qc_business_context_search\n return if authorise_for_web(program_name(params[:id]),'create')== false\n session[:qc_inspection_type_code] = params[:id]\n qc_current_inspection = ActiveRecord::Base.connection.select_one(\"select * from qc_current_inspections\n ... | [
"0.58005685",
"0.57101166",
"0.5669342",
"0.5625449",
"0.56117016",
"0.55610704",
"0.55534244",
"0.55344903",
"0.54867303",
"0.5368036",
"0.53369635",
"0.52909976",
"0.52007586",
"0.51814914",
"0.5140568",
"0.51107603",
"0.5102999",
"0.50937843",
"0.5089434",
"0.5072017",
"0.... | 0.59401613 | 0 |
Convenience action to quickly get back to the business context the user was working on. | def current_qc_business_context_search
return if authorise_for_web(program_name(params[:id]),'create')== false
session[:qc_inspection_type_code] = params[:id]
qc_current_inspection = ActiveRecord::Base.connection.select_one("select * from qc_current_inspections
where user_id = #{session[:user_id].id}
and qc_inspection_type_code = '#{params[:id]}'")
if qc_current_inspection.nil? || qc_current_inspection.qc_business_context_query.nil?
redirect_to_index("'You have not yet captured an inspection for #{params[:id]}'", "''")
else
dm_session[:search_engine_query_definition] = qc_current_inspection.qc_business_context_query
session[:columns_list] = YAML.load(qc_current_inspection.columns_list)
submit_business_context_search
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def back\n\n workitem_id = params[:id]\n\n Densha::Locks.unlock_workitem(session[:user], workitem_id) if workitem_id\n\n session[:workitem] = nil\n\n return_to_previous_page\n end",
"def pop_from_active_context\n return @active_context.pop_context\n end",
"def pop_context\n contex... | [
"0.59980243",
"0.5871513",
"0.5519757",
"0.53709215",
"0.53709215",
"0.53185546",
"0.5302653",
"0.5211627",
"0.52046216",
"0.5171685",
"0.5158422",
"0.51412994",
"0.51047707",
"0.50979245",
"0.5080028",
"0.5080028",
"0.5080028",
"0.50797933",
"0.5074271",
"0.5067887",
"0.5055... | 0.5161279 | 10 |
Convenience action to quickly get back to the list of tests of a certain type. | def current_qc_tests
return if authorise_for_web(program_name(params[:id]),'edit')== false
session[:qc_inspection_type_code] = params[:id]
qc_current_inspection = ActiveRecord::Base.connection.select_one("select * from qc_current_inspections
where user_id = #{session[:user_id].id}
and qc_inspection_type_code = '#{params[:id]}'")
if qc_current_inspection.nil? || qc_current_inspection.qc_business_context_query.nil?
redirect_to_index("'You have not yet listed tests for #{params[:id]}'", "''")
else
dm_session[:search_engine_query_definition] = qc_current_inspection.qc_tests_query
session[:columns_list] = YAML.load(qc_current_inspection.tests_columns_list)
submit_tests_search
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @type_tests = TypeTest.all\n end",
"def index\n @testtypes = Testtype.all\n end",
"def index\n @m_test_types = MTestType.all\n end",
"def list_tests(target,\n project,\n machine,\n pool,\n test_type = nil,\n ... | [
"0.65544206",
"0.6244059",
"0.5977399",
"0.58196515",
"0.55817896",
"0.55817896",
"0.55817896",
"0.55817896",
"0.55817896",
"0.55817896",
"0.55817896",
"0.55817896",
"0.553468",
"0.55223304",
"0.5468912",
"0.5380662",
"0.5369858",
"0.5356228",
"0.5355891",
"0.5321143",
"0.531... | 0.0 | -1 |
SEARCH FOR INSPECTIONS Find the business data on which an inspection will take place. If the parameter +with_inspection+ is true, the search will be run for existing inspections. | def search_business_context(with_inspections=false)
return if authorise_for_web(program_name(params[:id]),'create')== false
# Show a data miner...
inspection_type = QcInspectionType.find_by_qc_inspection_type_code(params[:id])
if inspection_type.nil?
raise "Unknown Inspection Type: '#{params[:id]}'. The inspection type is not setup correctly or the menu system is not correctly defined."
end
data_miner = inspection_type.qc_business_context_search
data_miner.sub!('.yml', '_active.yml') if with_inspections
session[:qc_inspection_type_code] = inspection_type.qc_inspection_type_code
dm_session[:parameter_fields_values] = nil
session[:qc_inspection_exists] = with_inspections
dm_session['se_layout'] = 'content'
@content_header_caption = "'search'"
dm_session[:redirect] = true
build_remote_search_engine_form(data_miner, 'submit_business_context_search')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_inspections\n search_business_context( true )\n end",
"def basic_search(data)\n fill_in_if_supplied('product_id', data['Product Id'])\n select_if_supplied('designer_id', data['Designer'])\n select_if_supplied('season_id', data['Season'])\n select_if_supplied('se... | [
"0.7095888",
"0.52420586",
"0.5145438",
"0.5135416",
"0.50376827",
"0.49311173",
"0.48040545",
"0.47550845",
"0.47352293",
"0.47213498",
"0.47195166",
"0.4718627",
"0.46804914",
"0.4652172",
"0.46153057",
"0.46124524",
"0.45771286",
"0.45693415",
"0.45435983",
"0.4537619",
"0... | 0.71185607 | 0 |
Existing (inprogress) inspections. Use search_business_context method to do the work. | def search_inspections
search_business_context( true )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_qc_business_context_search\n return if authorise_for_web(program_name(params[:id]),'create')== false\n session[:qc_inspection_type_code] = params[:id]\n qc_current_inspection = ActiveRecord::Base.connection.select_one(\"select * from qc_current_inspections\n ... | [
"0.5878665",
"0.57744426",
"0.5752357",
"0.55996585",
"0.5463367",
"0.5380196",
"0.53757155",
"0.5346502",
"0.52904576",
"0.52846503",
"0.52168226",
"0.5198116",
"0.51441634",
"0.5122801",
"0.5109033",
"0.50955945",
"0.5084032",
"0.50815564",
"0.50662553",
"0.5065539",
"0.505... | 0.7215116 | 0 |
Open a completed test for editing again. | def re_edit_qc_inspection_test
id = params[:id]
if id && @qc_inspection_test = QcInspectionTest.find(id)
@qc_inspection_type_code = @qc_inspection_test.qc_inspection.qc_inspection_type.qc_inspection_type_code
return if authorise_for_web(program_name(@qc_inspection_type_code),'edit')== false
@qc_inspection_test.set_status QcInspectionTest::STATUS_CREATED
edit_qc_inspection_test
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_fertility_tests\n touch \"* marked:'Fertility testing and workup'\"\n end",
"def test02_post_open_board_cancel_article_draft\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_boards_post_open_article_new)\n\t\t\n \t\tcreate_article_draft \"Article for Draft #{random}\"\n\t\tcancel... | [
"0.655958",
"0.6016864",
"0.6015502",
"0.6012939",
"0.600813",
"0.59931165",
"0.59917027",
"0.587614",
"0.57925636",
"0.57449096",
"0.57449096",
"0.57264245",
"0.57233125",
"0.57227916",
"0.5719982",
"0.56793207",
"0.5662548",
"0.5589693",
"0.55793744",
"0.55762565",
"0.55743... | 0.58232296 | 8 |
Edit a test but return to test list when done. | def edit_qc_inspection_test_from_test_list
edit_qc_inspection_test true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @test.update(test_params)\n render status: :ok, json: @test\n else\n self.send(:edit)\n end\n end",
"def update\n if @test.update(test_params)\n respond_to do |format|\n format.html { redirect_to admin_tests_path }\n format... | [
"0.6810869",
"0.6765429",
"0.6464224",
"0.6450342",
"0.639111",
"0.6354252",
"0.63444144",
"0.6330344",
"0.62117124",
"0.6163827",
"0.6111595",
"0.6097882",
"0.6097882",
"0.6097882",
"0.6097882",
"0.6097882",
"0.6097882",
"0.6097882",
"0.6088273",
"0.60850304",
"0.6070381",
... | 0.72623205 | 0 |
Add the selected cull measurement to the test and display it on the page. | def add_cull_measure
id = params[:id]
if id && @qc_inspection_test = QcInspectionTest.find(id)
@qc_inspection_type_code = @qc_inspection_test.qc_inspection.qc_inspection_type.qc_inspection_type_code
return if authorise_for_web(program_name(@qc_inspection_type_code),'edit')== false
@qc_measurement_type = QcMeasurementType.find(params[:cull_measure])
@qc_result = @qc_inspection_test.qc_results.first
begin
@qc_result.add_cull_measurement( @qc_measurement_type )
if !@qc_result.valid?
ajax_error_alert('Validation error', nil, @qc_result)
return
end
cull_measurements = @qc_result.cull_measurements( @qc_measurement_type )
col_headers = cull_measurements.shift
render :update do |page|
page.insert_html :bottom, 'cull_results', :partial => 'cull_result_measurement',
:object => cull_measurements[0],
:locals => {:max_cols => @qc_inspection_test.max_columns_for_measurements,
:col_headers => col_headers,
:measurement_rules => @qc_inspection_test.measurement_rules}
page << "$$('#cull_measure option[value=#{@qc_measurement_type.id}]').each(function(e) { e.remove(); })"
page << "if ($('cull_measure').options.length == 0) {$('cull_add_form').hide();}"
end
rescue StandardError => error
ajax_error_alert(nil, error, @qc_result)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMiniMeasurement\n#measurements\n\n\n @set= ChartItem.new(\"Total Inches\")\n\n for measurement in @measurement\n \n # id: integer, user_id: integer, chest: integer, belly_upper: integer, belly_lower: integer, hips: integer, thigh: integer, arm: integer, date: datetime, created_at: datetime, updated_... | [
"0.5209609",
"0.48895437",
"0.4873477",
"0.48674485",
"0.48023129",
"0.47934574",
"0.47310987",
"0.47115493",
"0.46786392",
"0.46770322",
"0.46750233",
"0.46645513",
"0.4633034",
"0.46070188",
"0.4604914",
"0.45972288",
"0.45910788",
"0.45899287",
"0.4585797",
"0.45814595",
"... | 0.6463163 | 0 |
Get the current inspection record for the loggedin user and inspection type. | def get_current_inspection_record( user_id, qc_inspection_type_code )
ActiveRecord::Base.connection.select_one("select * from qc_current_inspections
where user_id = #{user_id}
and qc_inspection_type_code = '#{qc_inspection_type_code}'")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_identification_type\n if user_signed_in?\n @identification_type = current_user.cvs.find_by(params[:identification_type])\n end\n end",
"def current_qc_inspection\n return if authorise_for_web(program_name(params[:id]),'edit')== false\n qc_current_inspection = ActiveRecord::Base... | [
"0.61430204",
"0.611974",
"0.6014599",
"0.59748006",
"0.5923573",
"0.5519745",
"0.5516016",
"0.54654187",
"0.5464543",
"0.5397729",
"0.53937167",
"0.5379367",
"0.536892",
"0.53654844",
"0.53334224",
"0.53231543",
"0.53115535",
"0.5309444",
"0.5309338",
"0.5299606",
"0.528398"... | 0.7372813 | 0 |
Record the inspection that the user is currently working on. | def log_current_inspection
qc_current_inspection = get_current_inspection_record( session[:user_id].id, @qc_inspection_type_code )
if qc_current_inspection.nil?
ActiveRecord::Base.connection.execute("INSERT INTO qc_current_inspections (user_id, qc_inspection_type_code, qc_inspection_id)
VALUES(#{session[:user_id].id}, '#{@qc_inspection_type_code}', #{@qc_inspection.id})")
else
ActiveRecord::Base.connection.execute(ActiveRecord::Base.extend_update_sql_with_request("UPDATE qc_current_inspections SET qc_inspection_id = #{@qc_inspection.id}
WHERE user_id = #{session[:user_id].id} AND qc_inspection_type_code = '#{@qc_inspection_type_code}' "))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_status_to_in_progress\n user = User.find_by(id: params[:user_id])\n user.send_issue_assigned_email\n issue = Issue.find_by(id: params[:id])\n expert = User.find_by(id: params[:expert_id])\n issue.update_attributes(status: \"inprogress\", expert_id: expert.id)\n flash[:success] = \"Issu... | [
"0.59739196",
"0.5926119",
"0.5672347",
"0.5403654",
"0.5386229",
"0.5385516",
"0.5375619",
"0.52748877",
"0.5274646",
"0.5266436",
"0.5265324",
"0.5259361",
"0.5247262",
"0.5234216",
"0.52232826",
"0.5187598",
"0.518542",
"0.5182635",
"0.51669246",
"0.5166531",
"0.51327795",... | 0.6290871 | 0 |
Record the lastused business context query for the inspection type / user so it can easily be rerun. | def log_current_cusiness_context_query
qc_current_inspection = get_current_inspection_record( session[:user_id].id, session[:qc_inspection_type_code] )
if qc_current_inspection.nil?
ActiveRecord::Base.connection.execute("INSERT INTO qc_current_inspections
(user_id, qc_inspection_type_code, qc_business_context_query, columns_list)
VALUES(#{session[:user_id].id}, '#{session[:qc_inspection_type_code]}',
'#{dm_session[:search_engine_query_definition].gsub(/'/, "''")}', '#{session[:columns_list].to_yaml}')")
else
ActiveRecord::Base.connection.execute(ActiveRecord::Base.extend_update_sql_with_request("UPDATE qc_current_inspections
SET qc_business_context_query = '#{dm_session[:search_engine_query_definition].gsub(/'/, "''")}',
columns_list = '#{session[:columns_list].to_yaml}'
WHERE user_id = #{session[:user_id].id} AND qc_inspection_type_code = '#{session[:qc_inspection_type_code]}' "))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_qc_business_context_search\n return if authorise_for_web(program_name(params[:id]),'create')== false\n session[:qc_inspection_type_code] = params[:id]\n qc_current_inspection = ActiveRecord::Base.connection.select_one(\"select * from qc_current_inspections\n ... | [
"0.5967394",
"0.5889454",
"0.5630853",
"0.54270166",
"0.52208525",
"0.5065545",
"0.50535",
"0.5041118",
"0.49943486",
"0.49584913",
"0.4955712",
"0.4947984",
"0.4837096",
"0.48126897",
"0.4806059",
"0.47935674",
"0.47928923",
"0.4765731",
"0.47293645",
"0.47159162",
"0.470605... | 0.7103345 | 0 |
Record the query for tests that the user is currently working on. | def log_current_test_query
qc_current_inspection = get_current_inspection_record( session[:user_id].id, session[:qc_inspection_type_code] )
if qc_current_inspection.nil?
ActiveRecord::Base.connection.execute("INSERT INTO qc_current_inspections
(user_id, qc_inspection_type_code, qc_tests_query, tests_columns_list)
VALUES(#{session[:user_id].id}, '#{session[:qc_inspection_type_code]}',
'#{dm_session[:search_engine_query_definition].gsub(/'/, "''")}', '#{session[:columns_list].to_yaml}')")
else
ActiveRecord::Base.connection.execute(ActiveRecord::Base.extend_update_sql_with_request("UPDATE qc_current_inspections
SET qc_tests_query = '#{dm_session[:search_engine_query_definition].gsub(/'/, "''")}',
tests_columns_list = '#{session[:columns_list].to_yaml}'
WHERE user_id = #{session[:user_id].id} AND qc_inspection_type_code = '#{session[:qc_inspection_type_code]}' "))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_current_cusiness_context_query\n qc_current_inspection = get_current_inspection_record( session[:user_id].id, session[:qc_inspection_type_code] )\n if qc_current_inspection.nil?\n ActiveRecord::Base.connection.execute(\"INSERT INTO qc_current_inspections\n (user_id, qc_inspection_type_code,... | [
"0.5865417",
"0.5696944",
"0.56217647",
"0.5570736",
"0.5496788",
"0.5438144",
"0.5421293",
"0.5321764",
"0.5286782",
"0.5275124",
"0.5240332",
"0.5221535",
"0.52208465",
"0.52083075",
"0.5200899",
"0.519102",
"0.5184194",
"0.51817226",
"0.5181273",
"0.5179332",
"0.5179332",
... | 0.6561817 | 0 |
GET /latestinfos GET /latestinfos.xml | def index
@latestinfos = Latestinfo.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @latestinfos }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @latestinfo = Latestinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @latestinfo }\n end\n end",
"def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xm... | [
"0.740909",
"0.6977425",
"0.65369564",
"0.6259685",
"0.6188745",
"0.60685813",
"0.6023717",
"0.6015103",
"0.59938014",
"0.59573454",
"0.595502",
"0.5954883",
"0.5933087",
"0.5933034",
"0.59259045",
"0.5895115",
"0.5884716",
"0.5884716",
"0.58728176",
"0.5868532",
"0.5865549",... | 0.7562117 | 0 |
GET /latestinfos/1 GET /latestinfos/1.xml | def show
@latestinfo = Latestinfo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @latestinfo }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @latestinfos = Latestinfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @latestinfos }\n end\n end",
"def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { rende... | [
"0.7547098",
"0.70854795",
"0.63476664",
"0.61837995",
"0.61541754",
"0.6123622",
"0.6123622",
"0.61221623",
"0.607991",
"0.60474885",
"0.6028598",
"0.6016018",
"0.6003816",
"0.5990813",
"0.5973135",
"0.5944778",
"0.59419405",
"0.59249496",
"0.59249496",
"0.5896276",
"0.58944... | 0.7528827 | 1 |
GET /latestinfos/new GET /latestinfos/new.xml | def new
@latestinfo = Latestinfo.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @latestinfo }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @info = Info.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @info }\n end\n end",
"def new\n @info = Info.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @info }\n end\n end",
... | [
"0.7275524",
"0.7275524",
"0.7175475",
"0.71342504",
"0.7016985",
"0.68744826",
"0.68568814",
"0.6805073",
"0.6784519",
"0.6765308",
"0.6765308",
"0.6730944",
"0.6730944",
"0.6730944",
"0.67272705",
"0.67253715",
"0.67230153",
"0.66530114",
"0.6647701",
"0.6642453",
"0.662889... | 0.80938065 | 0 |
POST /latestinfos POST /latestinfos.xml | def create
@latestinfo = Latestinfo.new(params[:latestinfo])
respond_to do |format|
if @latestinfo.save
flash[:notice] = 'Latestinfo was successfully created.'
format.html { redirect_to(@latestinfo) }
format.xml { render :xml => @latestinfo, :status => :created, :location => @latestinfo }
else
format.html { render :action => "new" }
format.xml { render :xml => @latestinfo.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @latestinfo = Latestinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @latestinfo }\n end\n end",
"def index\n @latestinfos = Latestinfo.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render... | [
"0.6772774",
"0.617886",
"0.57906073",
"0.57906073",
"0.5735705",
"0.5639365",
"0.56341606",
"0.55369216",
"0.54622775",
"0.54431456",
"0.53927386",
"0.53809893",
"0.5368499",
"0.53065395",
"0.53065085",
"0.5302676",
"0.52939165",
"0.5278253",
"0.5275522",
"0.5275522",
"0.526... | 0.69169295 | 0 |
PUT /latestinfos/1 PUT /latestinfos/1.xml | def update
@latestinfo = Latestinfo.find(params[:id])
respond_to do |format|
if @latestinfo.update_attributes(params[:latestinfo])
flash[:notice] = 'Latestinfo was successfully updated.'
format.html { redirect_to(@latestinfo) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @latestinfo.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def create\n @latestinfo = Latestinfo.new(params[:latestinfo])\n\n respond_to do |format|\n if @latestinfo.save\n flash[:notice] = 'Latestinfo was successfully c... | [
"0.6464016",
"0.6207809",
"0.61195457",
"0.6046499",
"0.6007649",
"0.5887896",
"0.5854325",
"0.5813116",
"0.580748",
"0.5807163",
"0.5666787",
"0.56336683",
"0.5627781",
"0.55768883",
"0.5574242",
"0.5559745",
"0.5559745",
"0.55391574",
"0.55262184",
"0.5523536",
"0.54991037"... | 0.69086146 | 0 |
DELETE /latestinfos/1 DELETE /latestinfos/1.xml | def destroy
@latestinfo = Latestinfo.find(params[:id])
@latestinfo.destroy
respond_to do |format|
format.html { redirect_to(latestinfos_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @info = Info.find(params[:id])\n @info.destroy\n\n respond_to do |format|\n format.html { redirect_to(infos_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @info... | [
"0.69785917",
"0.66624707",
"0.6528485",
"0.6459862",
"0.64228827",
"0.6422457",
"0.64184856",
"0.63670224",
"0.6334539",
"0.63317007",
"0.62889427",
"0.6273694",
"0.6249011",
"0.62483597",
"0.6210001",
"0.6203116",
"0.6172312",
"0.6148442",
"0.6147536",
"0.61439204",
"0.6143... | 0.7341333 | 0 |
Parses website domain without www | def get_host_without_www(url)
url = "http://#{url}" if URI.parse(url).scheme.nil?
host = URI.parse(url).host.downcase
host.start_with?('www.') ? host[4..-1] : host
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_domain url\n uri = URI.parse url\n host = uri.host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def get_url_domain\n uri = URI.parse(url)\n host = uri.host.downcase\n host.start_with?('www.') ? host[4..-1] : host\n end",
"def domain_name(url)\n #url.gsub(/http:... | [
"0.81021565",
"0.80014163",
"0.7758066",
"0.7671145",
"0.7600646",
"0.7586452",
"0.754547",
"0.75320435",
"0.7417374",
"0.7335665",
"0.7327372",
"0.718094",
"0.71241",
"0.70425934",
"0.69966865",
"0.69837767",
"0.69404125",
"0.69399065",
"0.69060874",
"0.6887073",
"0.68766916... | 0.75944036 | 5 |
takes an array of digits and sums all of the elements | def sum(nums)
return 0 if nums.empty?
nums[0] + sum_rec(nums[1..-1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_digits(array)\n return array.inject(:+) #explanation? combines all elements of array by applying binary operation, same as reduce\n # array.reduce do |product = 0, n| \n # product + n\n # end\n end",
"def digit_sum(array)\n array.map { |n| n >= 10 ? n / 10 + n % 10 : n }\n end",
"de... | [
"0.86284894",
"0.8384672",
"0.8155823",
"0.8001407",
"0.7968202",
"0.7769528",
"0.77677757",
"0.77426016",
"0.7701103",
"0.7696725",
"0.76922643",
"0.76600677",
"0.76273334",
"0.76125234",
"0.7558137",
"0.75278807",
"0.75194454",
"0.7512243",
"0.7499919",
"0.7499558",
"0.7466... | 0.0 | -1 |
returns the first n fibonacci numbers | def fibs(n)
return [0] if n == 1
return [0, 1] if n == 2
fibs = fibs(n - 1)
fibs << fibs[-2] + fibs[-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibonaci(n)\n\tfi= [1, 1]\n\t(n-1).times do\n\t\tfi << fi[1]+fi.shift\n\tend\n\treturn fi[0]\nend",
"def nth_fibonacci(n)\n result = [0,1]\n\n for i in 1..n-1\n result[i+1] = result[i] + result[i-1]\n end\n\n return result[n]\nend",
"def iterative_nth_fib(n)\n return 1 if n <= 2\n a = 1\n b = 1\n... | [
"0.87356544",
"0.8658518",
"0.84631395",
"0.84594154",
"0.8450539",
"0.8444242",
"0.8435001",
"0.8426963",
"0.8379996",
"0.83626705",
"0.836147",
"0.83586335",
"0.8357606",
"0.8354752",
"0.8321518",
"0.83181745",
"0.83109105",
"0.8309331",
"0.8303799",
"0.8295943",
"0.8295894... | 0.0 | -1 |
recursive binary search (boolean edition) | def bsearch(arr, item)
middle = arr.count / 2
return true if arr[middle] == item
return false if arr.count < 2
(item < arr[middle]) ? bsearch(arr[0...middle], item) : bsearch(arr[middle..-1], item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_bin_search(d, arr, first = 0, last=arr.size-1)\n middle = (first + last) / 2\n case arr[middle] <=> d\n when 0 # arr[middle] == d\n return true\n when -1 # arr[middle] < d\n first = first + 1\n return recursive_binary_search(arr, target, first, last)\n when 1 # arr[... | [
"0.73726475",
"0.7329054",
"0.73236984",
"0.72882795",
"0.7271904",
"0.7255239",
"0.7232599",
"0.71786046",
"0.714237",
"0.71394813",
"0.71384084",
"0.7132369",
"0.70760244",
"0.707322",
"0.7063654",
"0.7055301",
"0.70320654",
"0.70302",
"0.7029038",
"0.69994324",
"0.699734",... | 0.6632265 | 71 |
returns all subsets of an array | def subsets(array)
if array.empty?
return [[]]
end
el = array.shift[0]
old_subsets = subsets(array)
new_subsets = old_subsets.map { |old_subset| [el] + old_subset }
new_subsets + old_subsets
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsets(array)\n\nend",
"def subsets(array)\n\nend",
"def subsets(array)\n\nend",
"def subsets_of(array)\n 0.upto(array.length).flat_map { |n| array.combination(n).to_a }\n end",
"def subsets(array)\n if array.length <= 1\n return array\n end\n subset_array = []\n (0..arr... | [
"0.89047766",
"0.89047766",
"0.89047766",
"0.8867973",
"0.8580601",
"0.839653",
"0.8362648",
"0.83218443",
"0.823007",
"0.8221146",
"0.8198249",
"0.8193879",
"0.8164746",
"0.8150156",
"0.81158566",
"0.81113744",
"0.80861104",
"0.8072079",
"0.8049394",
"0.8048567",
"0.80346006... | 0.8340811 | 7 |
returns an array of the smallest number of coins that will total the amount | def make_change(amount, coins = [25, 10 ,5, 1])
biggest_fit_coin = coins.detect { |val| amount >= val }
if biggest_fit_coin == amount
[biggest_fit_coin]
else
[biggest_fit_coin] + make_change(amount - biggest_fit_coin)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_change_sum(coins, total)\n totals = Array.new(total + 1, 1000000000000)\n totals[0] = 0\n\n (1..total).each do |i|\n coins.each do |coin|\n if coin <= i && (totals[i-coin] + 1 < totals[i])\n totals[i] = totals[i-coin] + 1\n end\n end\n end\n\n totals[total]\nend",
"def minimum... | [
"0.7801314",
"0.7416584",
"0.7183905",
"0.70020497",
"0.6973914",
"0.69733477",
"0.69667035",
"0.6919655",
"0.6913986",
"0.6891893",
"0.68541056",
"0.68216276",
"0.6814197",
"0.6794056",
"0.67839384",
"0.6762581",
"0.6750556",
"0.674396",
"0.6710891",
"0.6690177",
"0.66723865... | 0.6583852 | 22 |
Suppose a hash represents a directory with subdirectories and so on. If a key is a directory, it points to a subhash. If a key is a file, it points to true. The function below returns an array of strings representing the file paths to each file in the hash. | def file_paths(file_tree, path_so_far = "")
paths = []
file_tree.keys.each do |key|
if file_tree[key] == true
extended_path = path_so_far + "#{key}"
paths << extended_path
else
extended_path = path_so_far + "#{key}/"
paths += file_paths(file_tree[key], extended_path)
end
end
paths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keys\n return full_path.to_s.split('.') if full_path\n return [key.to_s] unless path&.present?\n\n [path, key].compact.join('.').split('.')\n end",
"def get_vault_paths(keys = 'secret/')\n # We need to work with an array\n if keys.is_a?(String)\n keys = [keys]\n else\n raise Argume... | [
"0.6467754",
"0.6353136",
"0.6223243",
"0.6223243",
"0.60921377",
"0.60659885",
"0.60421485",
"0.5976336",
"0.59394246",
"0.5938303",
"0.59350574",
"0.58993495",
"0.58643603",
"0.5835709",
"0.58329815",
"0.58142596",
"0.5782391",
"0.5778076",
"0.5765533",
"0.5753983",
"0.5735... | 0.7308784 | 0 |
before_filter :fetch_user, only: [:show] | def index
render json: {
error: nil,
data: @current_user.api_hash
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n # authorize! :show, @user\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end",
"def show\n # Pundit authorization can be skipped because\... | [
"0.7663275",
"0.76391554",
"0.7596993",
"0.74469143",
"0.74305034",
"0.7416079",
"0.74087596",
"0.73918456",
"0.7379166",
"0.7372741",
"0.73509556",
"0.7337657",
"0.7314534",
"0.729787",
"0.72761947",
"0.72253287",
"0.7211065",
"0.7207608",
"0.7207608",
"0.7207033",
"0.720067... | 0.0 | -1 |
Creates a new header object. Accepts raw text or nothing. If given raw text will attempt to parse it and split it into the various fields, instantiating each field as it goes. If it finds a field that should be a structured field (such as content type), but it fails to parse it, it will simply make it an unstructured field and leave it alone. This will mean that the data is preserved but no automatic processing of that field will happen. If you find one of these cases, please make a patch and send it in, or at the least, send me the example so we can fix it. | def initialize(header_text = nil, charset = nil)
@charset = charset
self.raw_source = header_text
split_header if header_text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_header(raw)\n header = {}\n field = nil\n\n raw.each_line do |line|\n case line\n when /^([A-Za-z0-9!\\#$%&'*+\\-.^_`|~]+):\\s*(.*?)\\s*\\z/om\n field, value = $1, $2\n header[field] = value\n when /^\\s+(.*?)\\s*\\z/om\n value = $1\n ... | [
"0.7122219",
"0.5979536",
"0.5907158",
"0.58096755",
"0.57519037",
"0.569342",
"0.5690831",
"0.56503385",
"0.56431717",
"0.56266195",
"0.5585677",
"0.55615324",
"0.55594486",
"0.5546759",
"0.5535344",
"0.5493248",
"0.5490219",
"0.54751897",
"0.5468234",
"0.5450163",
"0.538760... | 0.6607831 | 1 |
The preserved raw source of the header as you passed it in, untouched for your Regexing glory. | def raw_source
@raw_source
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def original\n @original_header\n end",
"def parse_header_contents; end",
"def raw_headers; end",
"def header\n @raw.split(\"--\" + boundary)[0]\n end",
"def body\n @raw.split(header)[1]\n end",
"def header\n source_code.gsub /\\n^[^#].*/m, ''\n end",
"def sanitize_header(header, va... | [
"0.7179007",
"0.7106129",
"0.6977529",
"0.6897774",
"0.68092585",
"0.67463756",
"0.66546553",
"0.6648977",
"0.6598323",
"0.6574012",
"0.6519513",
"0.6510167",
"0.64424235",
"0.6424114",
"0.63725996",
"0.6344868",
"0.6344557",
"0.63307595",
"0.6322144",
"0.6309879",
"0.6275596... | 0.5784741 | 75 |
Returns an array of all the fields in the header in order that they were read in. | def fields
@fields ||= FieldList.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header_fields\n header.fields\n end",
"def headers\n fields.map(&:name).map(&:to_sym)\n end",
"def header_fields\n IO.binread(@path, HEADER_SIZE, 0).unpack(\"N5C1\")\n end",
"def getHeaderFieldNames\n\t\tend",
"def header_fields\n @csv.headers\n end",
"def fiel... | [
"0.764516",
"0.740656",
"0.7159083",
"0.7030511",
"0.6981399",
"0.6796104",
"0.67787886",
"0.66717446",
"0.65970594",
"0.6591688",
"0.6500536",
"0.64640874",
"0.64640874",
"0.6301887",
"0.6280385",
"0.6248019",
"0.62198037",
"0.6197492",
"0.61870223",
"0.6183988",
"0.6183541"... | 0.0 | -1 |
3.6. Field definitions It is important to note that the header fields are not guaranteed to be in a particular order. They may appear in any order, and they have been known to be reordered occasionally when transported over the Internet. However, for the purposes of this standard, header fields SHOULD NOT be reordered when a message is transported or transformed. More importantly, the trace header fields and resent header fields MUST NOT be reordered, and SHOULD be kept in blocks prepended to the message. See sections 3.6.6 and 3.6.7 for more information. Populates the fields container with Field objects in the order it receives them in. Acceps an array of field string values, for example: h = Header.new | def fields=(unfolded_fields)
@fields = Mail::FieldList.new
Kernel.warn "WARNING: More than #{self.class.maximum_amount} header fields; only using the first #{self.class.maximum_amount} and ignoring the rest" if unfolded_fields.length > self.class.maximum_amount
unfolded_fields[0..(self.class.maximum_amount-1)].each do |field|
if field = Field.parse(field, charset)
if limited_field?(field.name) && (selected = select_field_for(field.name)) && selected.any?
selected.first.update(field.name, field.value)
else
@fields << field
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fields\n @fields = headers.map.with_index do |header, index|\n Field.new(header, row_data[index])\n end\n end",
"def header_fields\n header.fields\n end",
"def headers\n fields.map(&:name).map(&:to_sym)\n end",
"def parse_header\n header.each do |field... | [
"0.6972926",
"0.6778327",
"0.63652045",
"0.6348624",
"0.6311162",
"0.6091288",
"0.60877717",
"0.60778505",
"0.5917039",
"0.5774508",
"0.5772151",
"0.5756259",
"0.57452345",
"0.5733866",
"0.57329214",
"0.5731396",
"0.57252806",
"0.571624",
"0.57137054",
"0.5713058",
"0.5710831... | 0.6145392 | 5 |
3.6. Field definitions The following table indicates limits on the number of times each field may occur in a message header as well as any special limitations on the use of those fields. An asterisk next to a value in the minimum or maximum column indicates that a special restriction appears in the Notes column. As per RFC, many fields can appear more than once, we will return a string of the value if there is only one header, or if there is more than one matching header, will return an array of values in order that they appear in the header ordered from top to bottom. Example: h = Header.new | def [](name)
name = dasherize(name)
name.downcase!
selected = select_field_for(name)
case
when selected.length > 1
selected.map { |f| f }
when !Utilities.blank?(selected)
selected.first
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header_fields\n header.fields\n end",
"def headers\n fields.map(&:name).map(&:to_sym)\n end",
"def getHeaderFieldNames\n\t\tend",
"def fields\n @fields = headers.map.with_index do |header, index|\n Field.new(header, row_data[index])\n end\n end",
"def hea... | [
"0.66339946",
"0.6013901",
"0.578894",
"0.5701452",
"0.56986225",
"0.568778",
"0.56282765",
"0.5618912",
"0.55824393",
"0.55448014",
"0.55355936",
"0.5534247",
"0.550896",
"0.5448223",
"0.5447678",
"0.5438937",
"0.54268557",
"0.5405288",
"0.5404703",
"0.54024756",
"0.5383236"... | 0.0 | -1 |
Sets the FIRST matching field in the header to passed value, or deletes the FIRST field matched from the header if passed nil Example: h = Header.new | def []=(name, value)
name = dasherize(name)
if name.include?(':')
raise ArgumentError, "Header names may not contain a colon: #{name.inspect}"
end
fn = name.downcase
selected = select_field_for(fn)
case
# User wants to delete the field
when !Utilities.blank?(selected) && value == nil
fields.delete_if { |f| selected.include?(f) }
# User wants to change the field
when !Utilities.blank?(selected) && limited_field?(fn)
selected.first.update(fn, value)
# User wants to create the field
else
# Need to insert in correct order for trace fields
self.fields << Field.new(name.to_s, value, charset)
end
if dasherize(fn) == "content-type"
# Update charset if specified in Content-Type
params = self[:content_type].parameters rescue nil
@charset = params[:charset] if params && params[:charset]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header(value = nil)\n value ? self.header = value : @header\n end",
"def parse_header\n header.each do |field, value|\n self.instance_variable_set(\"@#{field}\", value) if HEADER_FIELDS.include? field\n end\n end",
"def setFirst(first)\n @first = first\n end",
"def h... | [
"0.6505785",
"0.6139986",
"0.6100362",
"0.6046114",
"0.60236186",
"0.6007642",
"0.5944773",
"0.59438324",
"0.5937176",
"0.5933769",
"0.59020627",
"0.59020627",
"0.58999807",
"0.588291",
"0.5875876",
"0.58486",
"0.5813431",
"0.5800602",
"0.5762079",
"0.5714005",
"0.5654009",
... | 0.52428484 | 43 |
Returns true if the header has a MessageID defined (empty or not) | def has_message_id?
!fields.select { |f| f.responsible_for?('Message-ID') }.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_message_id?\n header.has_message_id?\n end",
"def has_outgoing_headers?\n !!(raw_headers =~ /^X\\-Postal\\-MsgID\\:/i)\n end",
"def has_outgoing_headers?\n !!(raw_headers =~ /^X\\-Postal\\-MsgID\\:/i)\n end",
"def header?(key)\n return true if @args[:headers].key?(k... | [
"0.89300835",
"0.7057632",
"0.7057632",
"0.6885972",
"0.67816186",
"0.67508394",
"0.6728832",
"0.67251354",
"0.6663678",
"0.66589653",
"0.6536141",
"0.64362377",
"0.64198345",
"0.64185977",
"0.64021087",
"0.63852394",
"0.6318951",
"0.6318951",
"0.6255903",
"0.62061983",
"0.61... | 0.7949452 | 1 |
Returns true if the header has a ContentID defined (empty or not) | def has_content_id?
!fields.select { |f| f.responsible_for?('Content-ID') }.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_message_id?\n header.has_message_id?\n end",
"def header?\n @properties.key?(:header) && !@properties[:header].empty?\n end",
"def has_header?\n @has_header\n end",
"def header?(key)\n\t\t\t@headers.select{|h| h[:id] == key}[0] rescue nil\n\t\tend",
"def header?(key)\n ... | [
"0.72349703",
"0.70114005",
"0.692935",
"0.690204",
"0.68856114",
"0.68556654",
"0.68556654",
"0.6801491",
"0.67694324",
"0.6692835",
"0.6554282",
"0.6554282",
"0.6509939",
"0.65007293",
"0.64706784",
"0.6436599",
"0.6436503",
"0.6432787",
"0.6430356",
"0.6417332",
"0.6401113... | 0.798544 | 0 |
Returns true if the header has a Date defined (empty or not) | def has_date?
!fields.select { |f| f.responsible_for?('Date') }.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_date?\n header.has_date?\n end",
"def headers?\n !self.data.strip.each.first.split(column_seperator).any? { |column| Date.parse(column) rescue false }\n end",
"def has_date?\n\t\t@date == ''\n\tend",
"def has_date?\n @date == ''\n end",
"def hasDate?\n if self.getDateStr == \"\" ... | [
"0.9115333",
"0.7826471",
"0.759845",
"0.758585",
"0.7293847",
"0.70789534",
"0.6871366",
"0.68597937",
"0.6810649",
"0.6731669",
"0.67083377",
"0.6652558",
"0.6617845",
"0.65892714",
"0.65813625",
"0.6562908",
"0.6516034",
"0.64911366",
"0.64911366",
"0.6489458",
"0.6457744"... | 0.7370901 | 4 |
Returns true if the header has a MIME version defined (empty or not) | def has_mime_version?
!fields.select { |f| f.responsible_for?('Mime-Version') }.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_mime_version?\n header.has_mime_version?\n end",
"def is_header?(); @type == GRT_HEADER; end",
"def mime_version\n (@mime_version ||= \"1.0\")\n end",
"def is_http_header? line\n line.split(':').length == 2\n end",
"def is_text_header?(header)\n not header.include?('/Subtype') an... | [
"0.9108818",
"0.70529276",
"0.6964974",
"0.6742308",
"0.67371166",
"0.6606519",
"0.6601112",
"0.65926987",
"0.65809846",
"0.6580691",
"0.6572181",
"0.65576136",
"0.65226924",
"0.6485858",
"0.6467491",
"0.64614755",
"0.64311296",
"0.6415586",
"0.6402825",
"0.63520205",
"0.6348... | 0.8264613 | 1 |
Splits an unfolded and line break cleaned header into individual field strings. | def split_header
self.fields = raw_source.split(HEADER_SPLIT)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initial_Headers_Split(initial_and_headers)\n\tif initial_and_headers.include?(\"\\r\\n\") # if body exist, a blank line must exist\n\t\tinitial,headers = initial_and_headers.split(\"\\r\\n\",2)\n\telse\n\t\tinitial,headers = initial_and_headers,''\n\tend\nend",
"def parse_header(raw)\n header = {}\n ... | [
"0.67276764",
"0.67138535",
"0.67064935",
"0.6349347",
"0.6313839",
"0.62987614",
"0.622084",
"0.62110406",
"0.6208317",
"0.61789197",
"0.6071018",
"0.59929943",
"0.5979156",
"0.59777385",
"0.59702027",
"0.5953611",
"0.5934405",
"0.5908522",
"0.5889994",
"0.58756375",
"0.5854... | 0.7546162 | 0 |
Enumerable support; yield each field in order to the block if there is one, or return an Enumerator for them if there isn't. | def each( &block )
return self.fields.each( &block ) if block
self.fields.each
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each( &blk ) #:yields: a Field or a Bitstruct\n @fields.each {|atom|\n if atom.is_a? Bitfield\n atom.fields.each {|f| yield f}\n else\n yield atom\n end\n }\n\n end",
"def each(&block)\n @fields.each(&block)\n end",
"de... | [
"0.70587695",
"0.7013422",
"0.6930019",
"0.687848",
"0.6869549",
"0.68246007",
"0.6721239",
"0.66432154",
"0.6612841",
"0.6609202",
"0.65901977",
"0.6584912",
"0.6556861",
"0.6550889",
"0.6543388",
"0.6543388",
"0.6515679",
"0.64985514",
"0.6489993",
"0.6396642",
"0.63918144"... | 0.75091094 | 0 |
Then provide an implementation: | def user(body)
User.find(body[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def implementation; end",
"def implementation; end",
"def provide\n raise NotImplementedError\n end",
"def implementation=(implementation); end",
"def call\n raise NotImplementedError\n end",
"def call\n raise NotImplementedError\n end",
"def call\n rais... | [
"0.8004915",
"0.8004915",
"0.7644503",
"0.6982072",
"0.6977004",
"0.6977004",
"0.6951976",
"0.68200195",
"0.6808356",
"0.6733499",
"0.6724624",
"0.67192864",
"0.6706957",
"0.67044455",
"0.67044455",
"0.660964",
"0.6590503",
"0.65820056",
"0.6568999",
"0.6563248",
"0.6553996",... | 0.0 | -1 |
private menas that the methods defined here are methods internal to the object. | def hungry?
#method names can endwith "?" usually, we only do this if the method returns true or false like this:
@stuffInBelly <= 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def methods() end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def private; end",
"def internal_methods; end",
"def accessibility; end",
"def internal; end",
"def private_method\n end",
"def private_method; end",
"def methods=(_arg0); end",
"def pu... | [
"0.7582183",
"0.74848807",
"0.74848807",
"0.74848807",
"0.74848807",
"0.72293866",
"0.71664006",
"0.7157473",
"0.7013877",
"0.68155503",
"0.6519713",
"0.65060616",
"0.6412229",
"0.6412229",
"0.63606894",
"0.63606894",
"0.63606894",
"0.63606894",
"0.63606894",
"0.63606894",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def service_params
params.require(:service).permit(:name, :description, :duration, :establishment_id, :teacher_id, :resource_id, :sub_category_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
rubocop: enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity | def multiply_els(arr)
arr.my_inject(:*)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def implementation; end",
"def implementation; end",
"def probers; end",
"def schubert; end",
"def strategy; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal()\n end",
"def operations; end",
"def operations; end",
"def s... | [
"0.75161785",
"0.6225229",
"0.6225229",
"0.62118864",
"0.6088498",
"0.6032464",
"0.6016659",
"0.6016659",
"0.6016659",
"0.6016659",
"0.6008422",
"0.589045",
"0.589045",
"0.58652633",
"0.5859985",
"0.5827736",
"0.5827736",
"0.5827736",
"0.57931453",
"0.57931453",
"0.5773953",
... | 0.0 | -1 |
Rysuje literke na scenie. | def draw
@img.draw(@x, @y, 2, 1.0, 1.0, @color)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suivre; end",
"def squeek\r\n\t\treturn \"eeeep\"\r\n\tend",
"def anstatauKodo(teksto)\n\n trovoj = teksto.scan(/&(.*?);/)\n if trovoj == nil or trovoj.size <= 0 then return teksto end\n\n for i in 0..trovoj.size do\n \n\ttrov = trovoj[i].to_s[2..-3]\n if @literoj[trov] != nil\n\t... | [
"0.6008694",
"0.58818597",
"0.57843864",
"0.5723996",
"0.55901295",
"0.55631036",
"0.552185",
"0.54891455",
"0.54761",
"0.5469009",
"0.5366697",
"0.5350044",
"0.5283717",
"0.5283717",
"0.52645147",
"0.52616906",
"0.5243375",
"0.52429914",
"0.5233237",
"0.52257836",
"0.5204991... | 0.0 | -1 |
Zmienia kolor literki na losowy. | def change_color
@color = Gosu::Color.rgb(rand * 255, rand * 255, rand * 255)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hsla_color; end",
"def crisis_color\n return text_color(17)\n end",
"def colorized?; end",
"def color\n\t\t \t\t\t\"El color de tu vaca es #{@color}\"\n\t\t \t\tend",
"def pikapika\n puts \"▕▔╲┊┊┊┊┊┊┊╱▔▏┊┊┊\".colorize(:yellow)\n puts \"┊╲╱╲┊┊┊┊┊╱╲╱┊┊┊┊\".colorize(:yellow)\n puts \"┊┊╲┈╲▂▂▂... | [
"0.66335374",
"0.63265437",
"0.6301206",
"0.62950873",
"0.62937826",
"0.627273",
"0.6229168",
"0.61431277",
"0.60787934",
"0.6074219",
"0.60729116",
"0.60721254",
"0.60055196",
"0.5992629",
"0.597288",
"0.5917997",
"0.5904019",
"0.5904019",
"0.5904019",
"0.5863588",
"0.585131... | 0.0 | -1 |
List all object ids in the repository, ordered by object type. Returns the path to the file containing the list of ids. Its name contains the timestamp when the command was issued. | def list_object_ids(output_path, after_timestamp = nil)
# Capture time in UTC, as snapshot of starting point for ids
# (back dated a minute to ensure no changes get lost between now and when the query executes)
start_time = (Time.now - 60).utc.iso8601.gsub!(/:/, '_')
# Start list file for IDs, in file named with starting point timestamp
filename = "id_list_#{start_time}.txt"
file_path = File.join(output_path, filename)
File.open(file_path, 'w') do |file|
BASE_QUERIES.each do |base_query|
record_paged_type_query(file, base_query, after_timestamp)
end
end
file_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_ids\n #FIXME\n base = @datapath\n Dir.glob(\"#{base}/[0-9][0-9]/[0-9][0-9]/[0-9][0-9]/[0-9][0-9]\").map do |dir|\n dir[base.length..-1].delete('/').to_i\n end\n end",
"def idlist(objects)\n safe_join(objects.collect {|o| o.id}, ',')\n end",
"def object_path(id)\n \"#{git_pat... | [
"0.64262617",
"0.60375994",
"0.6020777",
"0.59887123",
"0.5718663",
"0.5707122",
"0.56917477",
"0.5633536",
"0.5397954",
"0.5377332",
"0.5371289",
"0.5336751",
"0.53203577",
"0.5303246",
"0.5298228",
"0.5289205",
"0.5271126",
"0.52368826",
"0.52155846",
"0.52124774",
"0.52056... | 0.6902054 | 0 |
Trigger indexing of all objects listed in the provided file | def reindex(id_list_file, clean_index)
reindex_list(id_list_file, clean_index)
rescue ArgumentError => e
raise e
rescue StandardError => e
Rails.logger.error 'Execution interrupted by unexpected error'
Rails.logger.error [e.class.to_s, e.message, *e.backtrace].join($RS)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(file_rec)\n @index_driver.index(file_rec)\n end",
"def open_index_file\n end",
"def index_item_set(all_items, o={})\n puts \"Indexing #{all_items.size} items...\" ; cur_docs = 0\n #Searcher.load_features() if !$clf\n all_items.in_groups_of(FileCollector::FILES_IN_BATCH) do |batch|... | [
"0.67115146",
"0.66662186",
"0.6503352",
"0.640751",
"0.6361219",
"0.62574077",
"0.62543154",
"0.6208592",
"0.620452",
"0.6185532",
"0.6107002",
"0.61019784",
"0.6091456",
"0.60147846",
"0.5976097",
"0.5962538",
"0.59590197",
"0.5926683",
"0.5889196",
"0.5877432",
"0.5867403"... | 0.6050567 | 13 |
GET /my_studio/clients/1 GET /my_studio/clients/1.json | def show
@my_studio_client = MyStudio::Client.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @my_studio_client }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def index\n @clients = Client.all\n\n respond_to do |f... | [
"0.735819",
"0.7306338",
"0.7300522",
"0.7281493",
"0.7281493",
"0.7281493",
"0.7281493",
"0.7281493",
"0.7281493",
"0.7281493",
"0.7225086",
"0.72241795",
"0.7207474",
"0.71336424",
"0.7118993",
"0.70751715",
"0.7050957",
"0.70501",
"0.7034971",
"0.69702554",
"0.69097525",
... | 0.7652661 | 0 |
GET /my_studio/clients/new GET /my_studio/clients/new.json | def new
@my_studio_client = MyStudio::Client.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @my_studio_client }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end",
"def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n... | [
"0.7884393",
"0.7884393",
"0.7884393",
"0.7884393",
"0.74914384",
"0.74051243",
"0.74026966",
"0.739452",
"0.7381194",
"0.734045",
"0.72835845",
"0.7273845",
"0.7241994",
"0.7201605",
"0.71809745",
"0.71788216",
"0.71788216",
"0.71575797",
"0.7118455",
"0.7118455",
"0.7118455... | 0.77138335 | 4 |
POST /my_studio/clients POST /my_studio/clients.json | def create
@my_studio_client = MyStudio::Client.new(params[:my_studio_client])
respond_to do |format|
if @my_studio_client.save
format.html { redirect_to @my_studio_client, notice: 'Client was successfully created.' }
format.json { render json: @my_studio_client, status: :created, location: @my_studio_client }
else
format.html { render action: "new" }
format.json { render json: @my_studio_client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @studio_client = StudioClient.new(studio_client_params)\n\n respond_to do |format|\n if @studio_client.save\n format.html { redirect_to edit_admin_studio_client_path(@studio_client), notice: 'Studio client was successfully created.' }\n format.json { render :show, status: :cre... | [
"0.6985674",
"0.69118863",
"0.69086176",
"0.68978786",
"0.6862849",
"0.6831136",
"0.6831136",
"0.6831136",
"0.68026286",
"0.68024534",
"0.67850745",
"0.6782355",
"0.6761243",
"0.6761148",
"0.6761148",
"0.6761148",
"0.67517227",
"0.6743733",
"0.67414093",
"0.67366785",
"0.6718... | 0.7284644 | 0 |
PUT /my_studio/clients/1 PUT /my_studio/clients/1.json | def update
@my_studio_client = MyStudio::Client.find(params[:id])
respond_to do |format|
if @my_studio_client.update_attributes(params[:my_studio_client])
format.html { redirect_to @my_studio_client, notice: 'Client was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @my_studio_client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @client.update(client_params)\n render json: @client\n end",
"def update\n authorize! :update, Client\n load_client\n build_client\n save_client or render :edit\n end",
"def update\r\n params[:client][:version] = ENV[\"VERSION\"]\r\n params[:client][:username] = current_u... | [
"0.71831036",
"0.66596395",
"0.66572887",
"0.6628954",
"0.6609444",
"0.65954995",
"0.65943503",
"0.6584579",
"0.6567063",
"0.6567063",
"0.65631604",
"0.6557088",
"0.6557088",
"0.6535763",
"0.6525986",
"0.64829105",
"0.64765334",
"0.64691776",
"0.6464606",
"0.64388967",
"0.643... | 0.7078739 | 1 |
DELETE /my_studio/clients/1 DELETE /my_studio/clients/1.json | def destroy
@my_studio_client = MyStudio::Client.find(params[:id])
@my_studio_client.destroy
respond_to do |format|
format.html { redirect_to my_studio_clients_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @studio_client.destroy\n respond_to do |format|\n format.html { redirect_to studio_clients_url, notice: 'Studio client wa... | [
"0.73764867",
"0.7333829",
"0.73230195",
"0.73230195",
"0.73230195",
"0.73230195",
"0.73230195",
"0.73230195",
"0.73230195",
"0.73230195",
"0.73230195",
"0.7316281",
"0.7316281",
"0.73153675",
"0.7286203",
"0.726902",
"0.725696",
"0.72260314",
"0.72128206",
"0.72024894",
"0.7... | 0.78170395 | 0 |
arr The original array num The integer that will be placed at the beginning of the new array Examples prepend([1,2,3],4) => [4,1,2,3] Returns a new array with the integer as the first element | def prepend(arr, num)
output = []
output << num
return output + arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepend(arr, num)\n new_arr = arr.insert(0, num)\n return new_arr\nend",
"def prepend(arr, num)\n return arr.unshift(num)\nend",
"def prepend(arr,num)\n return [num] + arr\nend",
"def prepend(arr, num)\n return arr.insert(0, num)\nend",
"def prepend(array, num)\noutput = []\noutput << nu... | [
"0.81901723",
"0.7976083",
"0.79415953",
"0.7890589",
"0.7455889",
"0.7368295",
"0.68410224",
"0.6773811",
"0.6723409",
"0.67009735",
"0.663017",
"0.66265506",
"0.66227716",
"0.6613988",
"0.65757185",
"0.6573393",
"0.6550737",
"0.64812493",
"0.6470903",
"0.64467275",
"0.64369... | 0.7909119 | 3 |
Poorman's command line parsing Return [true, 1] if the parsing succeeds, or [false, pos] otherwise, where pos indicates the position in the command string that causes the failure | def parse_pipe_and_quote(cmd_str, &block)
cmds = []
# Splitted command and a certain piece of it
cmd, arg = [], ''
# Whether we're inside quotes
in_single_quote = false
in_double_quote = false
# Whether we're scanning escape sequence
escaped = false
# If the last non-space character is an active pipe
active_pipe = false
(0 ... cmd_str.length).each do |i|
case cmd_str[i]
when ' '
# Preserve spaces inside quotes
if in_single_quote || in_double_quote
arg += ' '
next
end
# Or we've splitted a new piece
if arg.length > 0
cmd.push(arg)
arg = ''
active_pipe = false
end
when '|'
# Complain if we have a pipe before
return [false, i] if active_pipe
# Preserve pipes inside quotes
if in_single_quote || in_double_quote
arg += cmd_str[i]
active_pipe = false
else
# Or we have a new piece before the pipe
cmd.push(arg) if arg.length > 0
# Yay!
if block_given?
yield cmd
else
cmds.push(cmd)
end
cmd = []
arg = ''
active_pipe = true
end
when "'"
# Treat the single quote as it is if it's escaped
# or we're inside double quotes
if escaped || in_double_quote
arg += cmd_str[i]
escaped = false if escaped
else
in_single_quote = !in_single_quote
end
active_pipe = false
when '"'
# Treat the double quote as it is if it's escaped
# or we're inside single quotes
if escaped || in_single_quote
arg += cmd_str[i]
escaped = false if escaped
else
in_double_quote = !in_double_quote
end
active_pipe = false
when '\\'
# Treat escape sequence as it is if we're inside single quotes
if escaped || in_single_quote
arg += '\\'
escaped = false if escaped
else
# Complain if there's nothing afterwards
return [false, i] if i + 1 >= cmd_str.length
# We are now ready for the escape sequence
escaped = true
end
active_pipe = false
else
# Turn \n, \t, \r to themselves
if escaped
arg += cmd_str[i] == 'n' ? "\n" :
cmd_str[i] == 't' ? "\t" :
cmd_str[i] == 'r' ? "\r" : cmd_str[i]
escaped = false
else
arg += cmd_str[i]
end
active_pipe = false
end
end
# Complain if we've exhausted the command string
# but ended up inside quotes
return [false, cmd_str.length] if in_single_quote ||
in_double_quote ||
active_pipe
# Collect the last splitted command
if arg.length > 0
cmd.push(arg)
if block_given?
yield cmd
else
cmds.push(cmd)
end
end
return cmds
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(args)\n true\n end",
"def commands_valid?\n # Loops through entire commands.txt, if there is a bad input, returns false with the index of the bad input and the entire input of that command.\n # Regex passes with only commands with F,B,L,R and positive whole numbers\n @commands.each... | [
"0.6680207",
"0.6667816",
"0.64562315",
"0.64255387",
"0.63459975",
"0.63353866",
"0.6332296",
"0.6284103",
"0.6246003",
"0.6208048",
"0.61975455",
"0.6157406",
"0.6129163",
"0.61200696",
"0.61163414",
"0.61068463",
"0.61012",
"0.608963",
"0.60886264",
"0.6086439",
"0.6076078... | 0.0 | -1 |
true if cookies are enabled, false otherwise. | def cookies_enabled
return true unless cookies["cookieTest"].blank?
cookies["cookieTest"] = Time.now
session[:return_to] = request.fullpath
if cookies["cookie_test"].blank?
return false
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cookies?\n cookies.length > 0\n end",
"def logged_in?\n\t\tcookies[:cookie_id] ? true : false\n\n\tend",
"def valid_cookie?\n cookie = @handshake.headers['Cookie']\n puts \"Cookie: #{cookie}\"\n return false unless cookie\n end",
"def cookie_valid?\n cookies[:clickfunne... | [
"0.76838183",
"0.7166335",
"0.714579",
"0.708127",
"0.70192784",
"0.69511825",
"0.6932264",
"0.6932264",
"0.6910483",
"0.6866767",
"0.6866767",
"0.68587136",
"0.67722076",
"0.67661065",
"0.6765488",
"0.67372143",
"0.6734038",
"0.67053664",
"0.6698484",
"0.66802573",
"0.665124... | 0.8233351 | 0 |
=begin :type x: Integer :rtype: Void =end | def push(x)
if @stack.length == 0 or x <= @min
@stack.push @min
@min = x
end
@stack.push x
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x\n 0\n end",
"def x(n)\n end",
"def x\n end",
"def x\n end",
"def x\n end",
"def return_value(x)\n\tif x > 1\n\t\treturn x\n\telse\n\tend\nend",
"def x; 1; end",
"def x; end",
"def x; end",
"def x; end",
"def x; end",
"def x; end",
"def cnt; xparam(6); end",
"def ge... | [
"0.6999597",
"0.6869975",
"0.6671123",
"0.66127646",
"0.66127646",
"0.6536892",
"0.6503381",
"0.64305717",
"0.64305717",
"0.64305717",
"0.64305717",
"0.64305717",
"0.64080566",
"0.6362651",
"0.62267184",
"0.6217009",
"0.61672753",
"0.61467487",
"0.61237484",
"0.61100554",
"0.... | 0.0 | -1 |
=begin :rtype: Void =end | def pop()
ret = @stack.pop()
if ret == @min
@min = @stack.pop()
end
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end; end",
"def end; end",
"def end; end",
"def void\n \"Void\"\n end",
"def incomplete\r\n\r\n end",
"def begin; end",
"def void()\n nil\n end",
"def complete?; end",
"def handle; end",
"def begin() end",
"def done; end",
"def suivre; end",
"def end() end",
... | [
"0.7076286",
"0.7076286",
"0.7076286",
"0.7042917",
"0.7006871",
"0.6946303",
"0.6753771",
"0.6736687",
"0.6684566",
"0.66822404",
"0.66349524",
"0.66205233",
"0.6619803",
"0.65918946",
"0.65669674",
"0.65669674",
"0.6561827",
"0.6561827",
"0.65405864",
"0.6527296",
"0.650094... | 0.0 | -1 |
=begin :rtype: Integer =end | def top()
@stack.last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range; end",
"def range; end",
"def range; end",
"def length\n @end - @start + 1\n end",
"def length\n @end - @start\n end",
"def start_num\n return @start_num\n end",
"def length\r\n return self.st... | [
"0.68839365",
"0.68839365",
"0.68839365",
"0.6832226",
"0.6770915",
"0.65820575",
"0.6458765",
"0.64062536",
"0.64062536",
"0.6389018",
"0.6268534",
"0.62334067",
"0.61995095",
"0.61995095",
"0.61995095",
"0.6191786",
"0.6191786",
"0.6191563",
"0.6190707",
"0.61641645",
"0.61... | 0.0 | -1 |
=begin :rtype: Integer =end | def get_min()
@min
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range; end",
"def range; end",
"def range; end",
"def length\n @end - @start + 1\n end",
"def length\n @end - @start\n end",
"def start_num\n return @start_num\n end",
"def length\r\n return self.st... | [
"0.68839365",
"0.68839365",
"0.68839365",
"0.6832226",
"0.6770915",
"0.65820575",
"0.6458765",
"0.64062536",
"0.64062536",
"0.6389018",
"0.6268534",
"0.62334067",
"0.61995095",
"0.61995095",
"0.61995095",
"0.6191786",
"0.6191786",
"0.6191563",
"0.6190707",
"0.61641645",
"0.61... | 0.0 | -1 |
define_index do indexes title, :sortable => true indexes author indexes editor indexes publisher.name, :as => :publisher, :sortable => true indexes author.name, :as => :author, :sortable => true indexes call1 indexes call2 indexes call3 indexes call4 attributes has publisher_id, created_at, updated_at, isbn end | def sortable_call
[self.call1, self.call2, self.call3, self.call4].map{|c| (c||"").gsub(/([0-9.]+)/, ' \1 ').split(" ").map{|s| s =~ /^[0-9.]+$/ ? s.to_f : s} }
[self.call1, (self.call2 =~ /^[0-9.]+$/ ? self.call2.to_f : self.call2) ] + "#{self.call3}#{self.call4}".gsub(/[^a-zA-Z.0-9]/,'').gsub(/([0-9.]+)/, ' \1 ').split(" ") # .map{|s| s =~ /^[0-9.]+$/ ? s.to_f : s}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_index\n end",
"def add_index_field(*) super end",
"def build_index(params)\n index = Algolia::Index.new(self.subdomain)\n\n params.each do |tablename, getters|\n klass = Object.const_get(tablename.to_s.classify)\n\n klass.all.each do |record|\n object_params = {\"tablena... | [
"0.68388724",
"0.6548044",
"0.64630425",
"0.6386257",
"0.6312421",
"0.6275402",
"0.6187312",
"0.6129667",
"0.6124606",
"0.6118035",
"0.60640305",
"0.6046897",
"0.5980893",
"0.59472406",
"0.5920126",
"0.591511",
"0.59096086",
"0.59034294",
"0.5903094",
"0.58993506",
"0.5894907... | 0.0 | -1 |
merge b into self if they are identical return true if done, false if not possible because books differ | def merge(b)
return false unless self.same_book?(b)
self.merge!(b)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge!(b)\n b.items.each do |i|\n self.items << i\n self.save!\n end\n AttributesForMerging.each do |k|\n if (self[k].nil? || self[k].empty?) && !(b[k].nil? || b[k].empty?)\n self[k]=b[k]\n end\n end\n self.save!\n b.destroy\n true\n end",
"def will_merge_chan... | [
"0.6887311",
"0.6057259",
"0.57850164",
"0.57249916",
"0.56876606",
"0.5640296",
"0.5621098",
"0.5610186",
"0.55885535",
"0.55845964",
"0.55777025",
"0.5527851",
"0.55133927",
"0.5472095",
"0.5464523",
"0.546012",
"0.545949",
"0.545255",
"0.5426013",
"0.5415535",
"0.54056543"... | 0.8531181 | 0 |
merge b into self even if they look different | def merge!(b)
b.items.each do |i|
self.items << i
self.save!
end
AttributesForMerging.each do |k|
if (self[k].nil? || self[k].empty?) && !(b[k].nil? || b[k].empty?)
self[k]=b[k]
end
end
self.save!
b.destroy
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def union(b)\n b.each do |bf|\n af = @cfile_by_name[bf.file]\n if af\n af.union bf\n else\n @cfile_by_name[bf.file] = bf\n end\n end\n self\n end",
"def union(b)\n @pages.update b.pages\n self\n end",
"def merge(b)\n return false unless self.same_book?(b)\n... | [
"0.70750886",
"0.7043613",
"0.6964805",
"0.67039114",
"0.6700077",
"0.66657674",
"0.6453251",
"0.6441163",
"0.63232726",
"0.62660897",
"0.6237583",
"0.6208841",
"0.6088389",
"0.60750747",
"0.6058318",
"0.60157704",
"0.599531",
"0.5992914",
"0.58998185",
"0.5883964",
"0.583789... | 0.74839884 | 0 |
GET /finance_items GET /finance_items.json | def index
@finance_items = FinanceItem.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = @deal.items\n\n respond_to do |format|\n format.html # index.html.erb\n ... | [
"0.69627506",
"0.68480736",
"0.66970426",
"0.66421974",
"0.6614795",
"0.65062666",
"0.65062666",
"0.65062666",
"0.65062666",
"0.6488863",
"0.6467391",
"0.6455168",
"0.64240485",
"0.63745",
"0.636653",
"0.634545",
"0.63429356",
"0.6332963",
"0.63220257",
"0.6310578",
"0.628795... | 0.7360347 | 0 |
GET /finance_items/1 GET /finance_items/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @finance_items = FinanceItem.all\n end",
"def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @api_v1_items = Item.all\n r... | [
"0.71434855",
"0.6999149",
"0.6852593",
"0.6710289",
"0.6608596",
"0.6508267",
"0.64741874",
"0.6473179",
"0.6432177",
"0.6424331",
"0.64037335",
"0.63769454",
"0.63769454",
"0.63769454",
"0.63769454",
"0.6365248",
"0.6348531",
"0.63376814",
"0.63280034",
"0.62592596",
"0.622... | 0.0 | -1 |
POST /finance_items POST /finance_items.json | def create
goal=Goal.find(params[:goal_id])
goal_text=goal.goal
@finance_item = @temp_item.finance_items.build(goal: goal)
respond_to do |format|
if @finance_item.save
if (goal_text=="Keep a Budget")
format.html { redirect_to new_temp_budget_plan_path, notice: 'Finance item was successfully created.' }
elsif (goal_text=="Set up a Protection")
format.html { redirect_to new_protection_plan_path, notice: 'Finance item was successfully created.' }
elsif (goal_text=="Emergency Fund")
format.html { redirect_to new_emergency_plan_path, notice: 'Finance item was successfully created.' }
elsif (goal_text=="Emergency Fund")
format.html { redirect_to new_emergency_plan_path, notice: 'Finance item was successfully created.' }
elsif (goal_text=="College Fund")
format.html { redirect_to new_college_plan_path, notice: 'Finance item was successfully created.' }
elsif (goal_text=="Plan for Retirement")
format.html { redirect_to new_retirement_plan_path, notice: 'Finance item was successfully created.' }
elsif (goal_text=="Investment")
format.html { redirect_to new_investment_plan_path, notice: 'Finance item was successfully created.' }
end
format.json { render action: 'show', status: :created, location: @finance_item }
else
format.html { render action: 'new' }
format.json { render json: @finance_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n # defined object to receive strict item_params including :description, :price, :stockQty ; else return 400\n @item = Item.new(item_params)\n \n if @item.save\n re... | [
"0.6814838",
"0.6689369",
"0.66512513",
"0.6623668",
"0.6533722",
"0.6532302",
"0.6465505",
"0.64310044",
"0.6361969",
"0.6326397",
"0.6294628",
"0.6280642",
"0.62482363",
"0.6224531",
"0.62207127",
"0.6220022",
"0.6196105",
"0.6194501",
"0.6180617",
"0.6169995",
"0.616083",
... | 0.0 | -1 |
PATCH/PUT /finance_items/1 PATCH/PUT /finance_items/1.json | def update
respond_to do |format|
if @finance_item.update(finance_item_params)
format.html { redirect_to @finance_item, notice: 'Finance item was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @finance_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n respond_to do |format|\n if @budget.update(budget_params)\n Item.where([\"budget_id = #{params[:id]}\"]).update_all(budget_id: nil)\n if !params[:budget][:items].nil?\n params[:budget]... | [
"0.67903686",
"0.67452943",
"0.674345",
"0.6732187",
"0.6548482",
"0.65046424",
"0.64801484",
"0.6463188",
"0.6414768",
"0.63969636",
"0.639078",
"0.6390224",
"0.6381282",
"0.63758993",
"0.6339884",
"0.63208246",
"0.6310882",
"0.6309246",
"0.62886137",
"0.6285171",
"0.6278372... | 0.7082645 | 0 |
DELETE /finance_items/1 DELETE /finance_items/1.json | def destroy
@finance_item.destroy
respond_to do |format|
format.html { redirect_to finance_items_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect... | [
"0.7175915",
"0.7119205",
"0.70943886",
"0.70806736",
"0.70174354",
"0.6984482",
"0.6970735",
"0.6927181",
"0.69234115",
"0.6909906",
"0.688377",
"0.6875334",
"0.6865821",
"0.68576586",
"0.68576586",
"0.68576586",
"0.68576586",
"0.68576586",
"0.68576586",
"0.68576586",
"0.685... | 0.7617663 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_finance_item
@finance_item = FinanceItem.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 finance_item_params
params.require(:finance_item).permit(:goal_id, :temp_item_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Default method, subclasses must override this | def run
super
# Get range, or host
### SECURITY!
to_scan = _get_entity_name
raise "INVALID INPUT: #{to_scan}" unless match_regex :ip_address, to_scan
### SECURITY!
opt_port = _get_option("port").to_i
raise "INVALID INPUT: #{opt_port}" unless match_regex :integer, opt_port
begin
# Create a tempfile to store result
temp_file = Tempfile.new("masscan")
# shell out to masscan and run the scan
masscan_string = "masscan -p #{opt_port} -oL #{temp_file.path} #{to_scan}"
_log "Running... #{masscan_string}"
_unsafe_system(masscan_string)
f = File.open(temp_file.path).each_line do |line|
# Skip comments
next if line =~ /^#.*/
# Get the discovered host (one per line) & create an ip address
line = line.delete("\n").strip.split(" ")[3] unless line.nil?
_create_entity("IpAddress", { "name" => line })
# Resolve, and iterate on each line
hostnames = resolve_names(line)
hostnames.each do |host|
next if host =~ /\.arpa$/
# Should we try to resolve first, and fall back on IP?
#_create_entity("DnsRecord", { "name" => host }) < this should be handled by enrichment...
if [80,443,8080,8081,8443].include?(opt_port)
ssl = true if [443,8443].include?(opt_port)
protocol = ssl ? "https://" : "http://" # construct uri
_create_entity("Uri", {"name" => "#{protocol}#{host}:#{opt_port}", "uri" => "#{protocol}#{host}:#{opt_port}" })
elsif opt_port == 21
uri = "ftp://#{host.ip}:#{opt_port}"
_create_entity("FtpServer", {
"name" => "#{host}:#{opt_port}",
"ip_address" => "#{host}",
"port" => opt_port,
"proto" => "tcp",
"uri" => uri })
end
end
### End Resolution
# Always create the network service
_create_entity("NetworkService", {
"name" => "#{line}:#{opt_port}/tcp",
"ip_address" => "#{line}",
"port" => opt_port,
"proto" => "tcp"
})
end
ensure
temp_file.close
temp_file.unlink
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overrides; end",
"def custom; end",
"def custom; end",
"def default; end",
"def default; end",
"def private; end",
"def special\n override\n end",
"def defaults\n super\n end",
"def implementation; end",
"def implementation; end",
"def default\n end",
"def defaults; end",
... | [
"0.7415348",
"0.73554313",
"0.73554313",
"0.6991004",
"0.6991004",
"0.69613177",
"0.69572926",
"0.6824949",
"0.6801543",
"0.6801543",
"0.67361915",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0... | 0.0 | -1 |
Subtracts any two integers that the user inputs. | def subtract(number_one, number_two)
number_one - number_two
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtraction\n\tputs \"which numbers would you like to subtract\"\n\tsub_number_1 = gets.chomp\n\tsub_number_2 = gets.chomp\n\tputs sub_number_1.to_f - sub_number_2.to_f\nend",
"def subtract\n @input1 = params[:input1]\n @input2 = params[:input2]\n @input1 = @input1.to_i\n @input2 = @input2.to_i\n... | [
"0.78235",
"0.7740966",
"0.7702333",
"0.7462998",
"0.7384113",
"0.7360426",
"0.73563015",
"0.7355439",
"0.7205422",
"0.7189571",
"0.7174598",
"0.7174598",
"0.7140615",
"0.7097119",
"0.7091647",
"0.70707744",
"0.7051348",
"0.6981722",
"0.697129",
"0.69348556",
"0.6920164",
"... | 0.7110011 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.