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 |
|---|---|---|---|---|---|---|
test initialization of OriginalSourceCodeTest'model. | def test_ut_diff_result_02
original_source_code = OriginalSourceCode.new(
:original_file_id => 10,
:line_number => 349898,
:error_line => 4564,
:line_content => "123456"
)
assert_equal(10,original_source_code.original_file_id)
assert_equal(349898,original_source_code.line_number)
assert_equal(4564,original_source_code.error_line)
assert_equal("123456",original_source_code.line_content)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_original_source_code_01\n original_source_code = OriginalSourceCode.new(:original_file_id => 1,\n :line_number => 2,\n :line_content => \"y1\",\n :error_lin... | [
"0.6654709",
"0.65798503",
"0.64541215",
"0.6097681",
"0.60935074",
"0.6088076",
"0.6052738",
"0.60485315",
"0.5981326",
"0.5981326",
"0.5964102",
"0.593474",
"0.58965594",
"0.5889463",
"0.586842",
"0.58099186",
"0.5796693",
"0.5782361",
"0.5782361",
"0.5782361",
"0.5782361",... | 0.62550867 | 3 |
GET /components or /components.json | def index
if params[:model]
@components = Component.filtermodel(params[:model])
elsif params[:serial_number]
@components = Component.filterserial(params[:serial_number])
elsif params[:rgb]
@components = Component.where(:rgb.to_s => params[:rgb].to_s) unless params[:rgb].blank?
elsif params[:type]
@components = Component.filtertype(params[:type])
elsif params[:brand_id]
@components = Component.where(:brand_id => params[:brand_id]) unless params[:brand_id].blank?
else
@components = Component.all
end
@types = ["Motherboard", "CPU", "GPU", "RAM", "SSD", "HDD", "PSU", "Cabinet", "Monitor", "Keyboard", "Mouse", "Mousepad", "Headset"]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @component = service.components.find_by(slug: params[:id])\n\n render json: @component\n end",
"def index\n respond_with(components)\n end",
"def show\n @component = CustomComponent.find(params[:id])\n render json: @component\n end",
"def index\n @components = CustomComponent.... | [
"0.71747875",
"0.6927493",
"0.6743073",
"0.6665426",
"0.64892614",
"0.63499594",
"0.6302068",
"0.6293612",
"0.61323285",
"0.6020784",
"0.60112333",
"0.5947259",
"0.5934678",
"0.5919645",
"0.59106606",
"0.58839697",
"0.58804095",
"0.5860231",
"0.58440787",
"0.5810696",
"0.5806... | 0.0 | -1 |
GET /components/1 or /components/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @component = service.components.find_by(slug: params[:id])\n\n render json: @component\n end",
"def show\n @component = CustomComponent.find(params[:id])\n render json: @component\n end",
"def index\n respond_with(components)\n end",
"def index\n @components = CustomComponent.... | [
"0.74488866",
"0.6933603",
"0.66943616",
"0.6623955",
"0.65852815",
"0.64780265",
"0.6385005",
"0.6161339",
"0.61601275",
"0.61301696",
"0.6104537",
"0.60741526",
"0.60249203",
"0.5866941",
"0.58461773",
"0.5841321",
"0.58016646",
"0.5797771",
"0.57730633",
"0.57729113",
"0.5... | 0.0 | -1 |
POST /components or /components.json | def create
@component = Component.new(component_params)
respond_to do |format|
if @component.save
format.html { redirect_to @component, notice: "Component was successfully created." }
format.json { render :show, status: :created, location: @component }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @component.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @component = service.components.new(component_params)\n\n if @component.save\n render json: @component, status: :created, location: @component\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def create\n flash[:notice] = 'The component ... | [
"0.7546477",
"0.66862917",
"0.6500564",
"0.6288414",
"0.6229747",
"0.6143371",
"0.6063302",
"0.6036099",
"0.60085887",
"0.59940445",
"0.598912",
"0.5938024",
"0.5937408",
"0.5909762",
"0.5889818",
"0.5868632",
"0.5840807",
"0.5839643",
"0.5777752",
"0.5724854",
"0.57138485",
... | 0.6787954 | 1 |
PATCH/PUT /components/1 or /components/1.json | def update
respond_to do |format|
if @component.update_attributes(component_params)
format.html { redirect_to @component, notice: "Component was successfully updated." }
format.json { render :show, status: :ok, location: @component }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @component.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @component = service.components.find_by!(slug: params[:id])\n\n if @component.update(component_params)\n head :no_content\n else\n render json: @component.errors, status: :unprocessable_entity\n end\n end",
"def update\n flash[:notice] = 'The component was successfully upda... | [
"0.72437364",
"0.6452081",
"0.64208704",
"0.64208704",
"0.64128953",
"0.6381774",
"0.62361735",
"0.6213064",
"0.62038606",
"0.62038606",
"0.6178921",
"0.6157307",
"0.61453146",
"0.6131692",
"0.60130215",
"0.6004166",
"0.5989117",
"0.5945427",
"0.5940296",
"0.59374315",
"0.593... | 0.6679688 | 1 |
DELETE /components/1 or /components/1.json | def destroy
@component.destroy
respond_to do |format|
format.html { redirect_to components_url, notice: "Component was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @componente = Componente.find(params[:id])\n @componente.destroy\n\n respond_to do |format|\n format.html { redirect_to componentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @component.destroy\n respond_to do |format|\n format.html { red... | [
"0.7216769",
"0.7206919",
"0.7137377",
"0.7056512",
"0.7048621",
"0.6821791",
"0.68137157",
"0.6795859",
"0.6761204",
"0.67086035",
"0.66795343",
"0.6660593",
"0.6653648",
"0.66115165",
"0.65908563",
"0.6589922",
"0.653329",
"0.6528732",
"0.652714",
"0.65241337",
"0.6505982",... | 0.7203496 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_component
@component = Component.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def component_params
params.require(:component).permit(:model, :category, :serial_number, :rgb, :brand_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.6949516",
"0.68133247",
"0.6803944",
"0.6795208",
"0.6745487",
"0.67407674",
"0.65270406",
"0.6520888",
"0.6491314",
"0.6430685",
"0.6430685",
"0.6430685",
"0.6398393",
"0.6355302",
"0.63544565",
"0.6347063",
"0.6343035",
"0.63376737",
"0.6326283",
"0.6326283",
"0.6326283"... | 0.0 | -1 |
Renders a template named `name` located in the templates folder. | def render(name, object = nil)
binding = get_binding
if object.respond_to?(:get_binding)
binding = object.get_binding
end
content = File.read(File.join(TEMPLATE_PATH, name))
ERB.new(content).result(binding)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template(name,locals={})\n Tilt.new(Dir.glob(\"#{settings.service.templates_dir}/#{name}.*\").first)\n .render(self,locals)\n end",
"def template(name)\n ERB.new(File.read(File.join(File.dirname(__FILE__), \"views\", \"#{name}.erb\")))\n end",
"def template(name)\n E... | [
"0.8127833",
"0.7862208",
"0.78393674",
"0.7495167",
"0.74709857",
"0.7444906",
"0.74424815",
"0.7369953",
"0.7356984",
"0.72394866",
"0.7221205",
"0.72126186",
"0.70645887",
"0.70539564",
"0.70341736",
"0.702832",
"0.70088816",
"0.69900763",
"0.6983047",
"0.69444996",
"0.692... | 0.71112615 | 12 |
Return the ERB binding. | def get_binding
binding
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thru_erb aBinding = Kernel.binding\n ERB.new(self).result(aBinding)\n end",
"def render_with_binding(binding)\n ERB.new(read, nil, '<>').result(binding)\n end",
"def _erb(templ, _binding)\n return ERB.new(templ, nil, \"<>\").result(_binding)\n end",
"def erb(vars = {})\n ERBRes... | [
"0.7632277",
"0.7319603",
"0.7198902",
"0.6844309",
"0.6844309",
"0.683822",
"0.683822",
"0.67694205",
"0.67636687",
"0.6715121",
"0.6711174",
"0.6711174",
"0.67098355",
"0.67098355",
"0.6702703",
"0.6702703",
"0.6702703",
"0.6702703",
"0.6654567",
"0.66515994",
"0.6649766",
... | 0.66836536 | 25 |
Detects files affected during example execution based on line coverage. Transforms absolute paths to relative. Exclude paths outside of repository and in excluded prefixes | def detect(before, after)
file_names = after.keys
covered_files = file_names.reject { |file_name| same_coverage?(before, after, file_name) }
filter(covered_files)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uncovered_relevant_lines\n lineno = 0\n File.open(@filename, \"rb\").each_line do |line|\n if @coverage[lineno] == Bashcov::Line::IGNORED && revelant?(line)\n yield lineno\n end\n lineno += 1\n end\n end",
"def coverage_exceeding_source_warn; end",
"def run_c... | [
"0.62677276",
"0.57785356",
"0.5775404",
"0.5737828",
"0.5725156",
"0.5719086",
"0.56872344",
"0.5646256",
"0.5633359",
"0.5585594",
"0.5580334",
"0.5540335",
"0.55374",
"0.5489791",
"0.54888386",
"0.54700166",
"0.54642165",
"0.5463755",
"0.5461154",
"0.5457786",
"0.5448176",... | 0.512841 | 47 |
Placeholder for ack received. You must override hsdq_request in your HsdqXxx class | def hsdq_ack(message, context); placeholder; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :delivery_tag => @header_obj.properties[:delivery_tag] })\n end\n end",
"def ack(msg_info)\n end",
"def hsdq_send_ack(message)\n hsdq_send(message.merge(type: :ack))\n end",
"def req_ack(clk_e,req,ack,port)\n ... | [
"0.7028409",
"0.658635",
"0.65078974",
"0.63730556",
"0.63401514",
"0.63015056",
"0.6200988",
"0.6188497",
"0.61433804",
"0.61350363",
"0.6123512",
"0.60782903",
"0.6040169",
"0.5986932",
"0.59699655",
"0.59630936",
"0.59562784",
"0.59536606",
"0.5950276",
"0.592767",
"0.5919... | 0.7449846 | 0 |
Placeholder for callback received. You must override hsdq_request in your HsdqXxx class | def hsdq_callback(message, context); placeholder; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callback\n def_deferr = ::EventMachine::DefaultDeferrable.new\n proc_callback = Proc.new { |response| ::OnesnooperServer::Log.debug(\n \"[#{self.class.name}] Handled as: #{response}\"\n ) }\n\n def_deferr.callback &proc_callback\n def_deferr.errback &proc_callback\n\n def_deferr\n end",... | [
"0.6535027",
"0.64699954",
"0.6435503",
"0.6331204",
"0.6268352",
"0.62193644",
"0.6136512",
"0.5965365",
"0.59640306",
"0.59458804",
"0.591139",
"0.5845023",
"0.58422947",
"0.5837795",
"0.5830636",
"0.582171",
"0.5798763",
"0.5781419",
"0.5761212",
"0.5753158",
"0.5753158",
... | 0.7942339 | 0 |
Placeholder for feedback received. You must override hsdq_request in your HsdqXxx class | def hsdq_feedback(message, context); placeholder; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hsdq_callback(message, context); placeholder; end",
"def hsdq_send_feedback(message)\n hsdq_send(message.merge(type: :feedback))\n end",
"def hsdq_ack(message, context); placeholder; end",
"def hsdq_error(message, context); placeholder; end",
"def hsdq_send_request(message)\n hsdq_... | [
"0.67383987",
"0.6363598",
"0.6160989",
"0.59689695",
"0.595466",
"0.5917709",
"0.5901353",
"0.58158934",
"0.5809793",
"0.57807577",
"0.57217646",
"0.5672317",
"0.56591624",
"0.56588054",
"0.565498",
"0.56109685",
"0.55991304",
"0.5583421",
"0.5541239",
"0.549523",
"0.5431828... | 0.8023943 | 0 |
Placeholder for error received. You must override hsdq_request in your HsdqXxx class | def hsdq_error(message, context); placeholder; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error\n @error_response\n end",
"def connection_error(error, req, text = T.unsafe(nil)); end",
"def request_error( err_str )\n case err_str\n when \"MAINTENANCE COMPANY NOT SPECIFIED\"\n return \"יש לבחור חברת אחזקה\";\n else\n return translate( \"QUERY_E... | [
"0.6218071",
"0.62142265",
"0.61370933",
"0.61193824",
"0.6116165",
"0.6082611",
"0.60430026",
"0.6030907",
"0.60243493",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.60064536",
"0.59876335",
"0.59619504",
"0.5928889",
"0.59055",
"0.5... | 0.8026948 | 0 |
Send the ACk and start the processing for the message just received. The processing will be either executed synchronously or a new thread will be started based on the configuration. | def hsdq_ignit(raw_spark, options)
spark = h_spark raw_spark
send_ack spark
if valid_spark? spark, options
if hsdq_opts[:threaded]
# :nocov:
hsdq_start_thread -> { sparkle spark, options }
# :nocov:
else
sparkle spark, options
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\r\n\t\t\tswdebug 'Started new thread for message processing.'\r\n\t\t\t# Start a new child Thread\r\n\t\t\t@thread = Thread.new {\r\n\t\t\t\tloop do\r\n\t\t\t\t\titems = process\r\n\t\t\t\t\tif items == 0\r\n\t\t\t\t\t\tsleep(0.1)\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tswdebug \"Processing #{items} items\"\r\n... | [
"0.61254233",
"0.5846753",
"0.5843763",
"0.5705409",
"0.56589127",
"0.5556909",
"0.55074763",
"0.55064166",
"0.5461887",
"0.5443115",
"0.53966194",
"0.5388551",
"0.5388348",
"0.53880715",
"0.535887",
"0.5354482",
"0.53453535",
"0.5305684",
"0.5298877",
"0.5277103",
"0.5276255... | 0.0 | -1 |
blpop return an array [list_name, data] | def get_spark(raw_spark)
raw_spark.kind_of?(Array) ? raw_spark.last : raw_spark
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_list_data\n\t\tlist_data = Array.new\n\t\tlist = get_list\n\t\tlist.each do |item|\n\t\t\tvoc = Voc.find(item)\n\t\t\tvoc.wylie = Functions.disparse_a(voc.wylie)\t\n\t\t\tlist_data.push( voc )\n\t\tend\n\t\treturn list_data\n\tend",
"def pop()\n @data.pop\n end",
"def pop \r\n @data.pop... | [
"0.6211502",
"0.6063916",
"0.60359174",
"0.58774966",
"0.5837753",
"0.58364785",
"0.5821982",
"0.58210546",
"0.57783246",
"0.5774944",
"0.5766763",
"0.5739442",
"0.57384866",
"0.57384866",
"0.57384866",
"0.57384866",
"0.57384866",
"0.5711455",
"0.5711455",
"0.5690897",
"0.563... | 0.0 | -1 |
return the spark (ephemeral part of the message) from the message list | def h_spark(raw_spark)
JSON.parse get_spark(raw_spark), {symbolize_names: true}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_spark(message)\n keys = [:sender, :uid, :spark_uid, :tstamp, :context, :previous_sender, :type, :topic, :task ]\n spark = keys.inject({}) { |memo, param| memo.merge(param => message[param]) }\n spark\n end",
"def get_spark(raw_spark)\n raw_spark.kind_of?(Array) ? raw_spark.last :... | [
"0.64653647",
"0.6004747",
"0.53561693",
"0.5301743",
"0.5076641",
"0.50756043",
"0.49699196",
"0.49670097",
"0.4813249",
"0.4757134",
"0.4751784",
"0.47315294",
"0.47273046",
"0.471648",
"0.47117364",
"0.46999922",
"0.46761626",
"0.46488327",
"0.46466285",
"0.46375796",
"0.4... | 0.5122599 | 4 |
Entry point for the task to process, this is what is executed in the threads when a message is pulled. Pull the burst (line with the request or response) from the the hash Pull the context related to a response if it exist Set values for the next hop context in case of a request. Call one of the 5 methods (request, ack, callback, feedback, error) in your hsdqXxx class (or the placeholder) based on the message type | def sparkle(spark, options)
puts spark.inspect
burst, ctx_burst = get_burst spark, options
context ctx_burst
case spark[:type].to_sym
when :ack
hsdq_ack burst, context
when :callback
hsdq_callback burst, context
when :feedback
hsdq_feedback burst, context
when :error
hsdq_error burst, context
when :request
set_context spark
hsdq_request burst, context
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_thread_step\n case (obj = read_from_wire)\n when Block\n handle_block obj\n when Message\n handle_message obj\n else\n raise \"don't know what to do with #{obj.inspect}\"\n end\n\n ## to enable immediate response, if there are no rate limits,\n ## we'll send the blocks... | [
"0.59011865",
"0.587079",
"0.58684707",
"0.58466643",
"0.583267",
"0.58268005",
"0.58240277",
"0.57761085",
"0.5758437",
"0.5729472",
"0.5704195",
"0.5645847",
"0.5567061",
"0.55201375",
"0.5518222",
"0.5499532",
"0.549418",
"0.54630053",
"0.54579365",
"0.544479",
"0.54348004... | 0.0 | -1 |
Save for future use context data into the thread_store | def set_context(spark)
# store in thread_store for later use
sent_to spark[:sender]
previous_sender spark[:sender]
context_params({ reply_to: spark[:previous_sender], spark_uid: spark[:spark_uid]})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store\n Thread.current\n end",
"def save_context(context)\n session[:context] = context\n end",
"def save_context(context)\n message_context_session[:context] = context\n end",
"def context\n Thread.current[NAME] ||= Hash.new\n end",
"def context\n ... | [
"0.7367369",
"0.65594435",
"0.6550074",
"0.6405408",
"0.5983536",
"0.5953486",
"0.591049",
"0.5887386",
"0.5846141",
"0.58443063",
"0.58374345",
"0.58030486",
"0.5778585",
"0.5688269",
"0.56869334",
"0.56869334",
"0.5669636",
"0.5669636",
"0.56667805",
"0.5641456",
"0.5631540... | 0.5379825 | 40 |
Manage pulling: the burst (persistent action) associated with the spark from the matching Redis hash if needed the context data | def get_burst(spark, _options={})
# get the context parameters
context_h = spark[:context]
burst_p = -> { cx_data.hget hsdq_key(spark), burst_key(spark) }
if response?(spark) && context_h
# save previous_sender in thread_store for later reply
sent_to context_h[:previous_sender]
# set the proc for multi redis to pull the initial request
burst_context_p = -> { cx_data.hget hsdq_key(spark), "request_#{context_h[:spark_uid]}" }
# exec the redis multi
burst_j, burst_context_j = pull_burst(burst_p, burst_context_p)
else
burst_j, burst_context_j = pull_burst_only burst_p
end
burst = burst_j ? (JSON.parse burst_j, {symbolize_names: true}) : {}
burst_context = burst_context_j ? (JSON.parse burst_context_j, {symbolize_names: true}) : {}
[burst, burst_context]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(params)\n Resque.logger.info \"Requestable.fetch received #{params.inspect}\"\n past = Time.now\n total = api_count(params)\n remain_requests = (total/250.to_f).ceil\n Resque.logger.info \"pages to request total: #{remain_requests}\"\n batch_num = (remain_requests / BATCH_SIZE.to_f).cei... | [
"0.56816435",
"0.5641253",
"0.5445054",
"0.53529847",
"0.5347884",
"0.5346648",
"0.52747536",
"0.52167577",
"0.5178319",
"0.51277167",
"0.50772816",
"0.496733",
"0.4929243",
"0.49261323",
"0.49189678",
"0.49168858",
"0.4915393",
"0.49079368",
"0.48955694",
"0.4876947",
"0.486... | 0.5368666 | 3 |
Execute a multi transaction to get the burst and the context from Redis in a single call | def pull_burst(burst_p, burst_context_p)
cx_data.multi do
burst_p.call
burst_context_p.call
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enqueue\n redis.multi do\n enqueue_non_atomically\n end\n end",
"def transaction(&block); end",
"def runMbxTransaction(hpk, op = '')\n limit = Rails.configuration.x.relay.mailbox_retry\n count, complete, res = 0, false, nil\n while count < limit and not complete\n rds.watch(\"mbx_... | [
"0.6150511",
"0.60140514",
"0.6000278",
"0.59217525",
"0.58475876",
"0.57977444",
"0.57458943",
"0.5729778",
"0.57279706",
"0.57279706",
"0.57230306",
"0.57178307",
"0.5714453",
"0.57112795",
"0.5677369",
"0.5656723",
"0.56521195",
"0.56381905",
"0.5634469",
"0.56168234",
"0.... | 0.0 | -1 |
If there is no context this method is used instead of pull_burst | def pull_burst_only(burst_p)
[burst_p.call, nil]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull_burst(burst_p, burst_context_p)\n cx_data.multi do\n burst_p.call\n burst_context_p.call\n end\n end",
"def get_burst(spark, _options={})\n # get the context parameters\n context_h = spark[:context]\n\n burst_p = -> { cx_data.hget hsdq_key(spark), burst_key(spar... | [
"0.6811905",
"0.557157",
"0.51338893",
"0.47984928",
"0.46801764",
"0.4668408",
"0.46215606",
"0.46159634",
"0.4613274",
"0.46123788",
"0.46123788",
"0.45138147",
"0.44802356",
"0.4468857",
"0.44554564",
"0.4449934",
"0.44464165",
"0.4433477",
"0.44118798",
"0.43884322",
"0.4... | 0.62543994 | 1 |
Spark validation, call valid_type?. If invalid: an error is sent back to the sender false is returned to the processing to stop the action. | def valid_spark?(spark, options)
begin
raise ArgumentError.new("Illegal type #{spark[:type]}") unless valid_type? spark[:type]
'request' == spark[:type] ? check_whitelist(spark, options) : true
rescue => e
reject_spark spark, e
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n self.send(\"validate_#{type}\".to_sym)\n end",
"def validate!\n # pass\n end",
"def validated?; end",
"def validate_type(type, context:); end",
"def valid?(_) true end",
"def valid?(_) true end",
"def validate\n end",
"def validate!(t)\n # None.\n ... | [
"0.6746783",
"0.6337037",
"0.62817955",
"0.62786585",
"0.6133059",
"0.6133059",
"0.6084968",
"0.6062485",
"0.60308945",
"0.60270345",
"0.60270345",
"0.59943277",
"0.59943277",
"0.59943277",
"0.59571874",
"0.5942148",
"0.5942148",
"0.5942148",
"0.5942148",
"0.594166",
"0.59253... | 0.62345374 | 4 |
Call whitelisted? to verify the the topic and task are legit. | def check_whitelist(spark, options)
begin
whitelisted?(spark, options) ? true : (raise ArgumentError.new("Illegal argument in topic or task"))
rescue => e
reject_spark spark, e
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def whitelisted?(spark, options)\n valid_topic?(spark, options) && valid_task?(spark, options)\n end",
"def whitelisted?(request)\n false\n end",
"def can_be_blacklisted?\n !self.blacklisted?\n end",
"def task_available\n return unless task\n\n validate_task_has_no_pending\n vali... | [
"0.65914893",
"0.6058476",
"0.60472053",
"0.6020961",
"0.5945337",
"0.58393544",
"0.5823831",
"0.57127124",
"0.5674508",
"0.56393725",
"0.56154907",
"0.56102693",
"0.5594485",
"0.5544983",
"0.5516038",
"0.55117995",
"0.5505832",
"0.54988116",
"0.5498231",
"0.5495662",
"0.5485... | 0.6660271 | 0 |
validate the topic and the task | def whitelisted?(spark, options)
valid_topic?(spark, options) && valid_task?(spark, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_create(topic)\n true\n end",
"def validate_topic\n errors.add(:topic_id, 'Topic not presence') if Topic.find_by_id( self[:topic_id] ) == nil\n end",
"def validate_topic_input(forum, subject, message)\n raise Impostor::TopicError.new(\"forum not set\") unless forum\n raise Impostor::T... | [
"0.7291646",
"0.72716177",
"0.67401636",
"0.64412546",
"0.64292365",
"0.63417315",
"0.62256604",
"0.61765784",
"0.61765784",
"0.60115564",
"0.59328145",
"0.5918468",
"0.58776146",
"0.58436525",
"0.58224374",
"0.58051574",
"0.5758825",
"0.5730315",
"0.57258123",
"0.57218087",
... | 0.0 | -1 |
Send the ack back to the sender in case of a request | def send_ack(spark)
return unless ['request', :request].include? spark[:type]
ack_msg = spark.merge sent_to: spark[:sender], sender: channel
hsdq_send_ack ack_msg
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_ack\n sock.put('+')\n vprint_status('Sending ack...')\n end",
"def ack\n unless acked?\n @acked = true\n @connection.future(:ack, delivery_info.delivery_tag).value\n end\n end",
"def ack\n @mq.callback do\n @mq.send Protocol::Basic::Ack.new({ :de... | [
"0.79083085",
"0.7592287",
"0.7546514",
"0.75286406",
"0.73193854",
"0.71973634",
"0.7018864",
"0.6948857",
"0.6925333",
"0.689984",
"0.68785095",
"0.6801428",
"0.6800155",
"0.67787606",
"0.6675017",
"0.6660697",
"0.66142124",
"0.6610668",
"0.65270597",
"0.6474745",
"0.639441... | 0.65629834 | 18 |
Hash of the internal authorized message types | def hsdq_authorized_types
[:request, :ack, :feedback, :callback, :error]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [domain, message, stack, type].hash\n end",
"def hash\r\n\t\treturn @name.hash() + @type.hash()\r\n\tend",
"def message_types\n @message_types ||= {}\n end",
"def hash\n @type.hash\n end",
"def hash\n [type, page_access_token, app_id, app_secret, account_sid,... | [
"0.66591483",
"0.6562162",
"0.6497484",
"0.63952833",
"0.62717116",
"0.6239237",
"0.6233638",
"0.62060845",
"0.6127952",
"0.608272",
"0.608272",
"0.6050678",
"0.59844804",
"0.59699756",
"0.5959553",
"0.59431374",
"0.59243554",
"0.5869893",
"0.5847079",
"0.5821665",
"0.5814615... | 0.0 | -1 |
Cached value of the tasks authorized to be processed | def hsdq_authorized_tasks(*tasks)
if tasks.any?
@hsdq_authorized_tasks = [tasks].flatten
else
@hsdq_authorized_tasks ||= [hsdq_opts[:tasks]].flatten
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active_permitted_tasks\n ( self.restricted? ) ? self.tasks.active : Task.active\n end",
"def all_permitted_tasks\n ( self.restricted? ) ? self.tasks.scoped : Task.scoped\n end",
"def update_task_completion_status_cache!(tasks = nil)\n self.task_completion_status_cache ||= {}\n tasks ||= offer... | [
"0.66707957",
"0.63352734",
"0.625641",
"0.61616063",
"0.60851854",
"0.60552716",
"0.60341424",
"0.589842",
"0.589842",
"0.5854229",
"0.585054",
"0.5847502",
"0.58469665",
"0.58457255",
"0.5844895",
"0.5820754",
"0.5817586",
"0.5772821",
"0.5747787",
"0.5742558",
"0.57385063"... | 0.56039107 | 32 |
Cached value of the topics authorized to be processed | def hsdq_authorized_topics(*topics)
if topics.any?
@hsdq_authorized_topics = [topics].flatten
else
@hsdq_authorized_topics ||= [hsdq_opts[:topics]].flatten
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_topic\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end",
"def index\n @published_topics = current_user.topics.published\n @unpublished_topics = current_user.topics.unpublished\n end",
"def topics_with_cache\n if new_record... | [
"0.6574096",
"0.6515707",
"0.6410573",
"0.63099027",
"0.62513775",
"0.61848086",
"0.6099768",
"0.58392316",
"0.5755114",
"0.5746827",
"0.5746827",
"0.5649583",
"0.557454",
"0.5556482",
"0.5526483",
"0.551546",
"0.55131006",
"0.55011934",
"0.54585177",
"0.5427703",
"0.5410237"... | 0.57883227 | 8 |
test the task against the list of authorised tasks | def valid_task?(spark, _options)
return true if spark[:task].nil? || hsdq_authorized_tasks.empty?
hsdq_authorized_tasks.include?(spark[:task].to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permission_for_task?( task )\n tasklist.present? && tasklist.split(',').map{ |v| Integer(v) }.include?( task )\n end",
"def tasks_are_active_and_permitted\n self.tasks.all.each do | task |\n errors.add( :base, \"Task '#{ task.augmented_title }' is no longer active and cannot be included\" ) unles... | [
"0.73010886",
"0.69179",
"0.6898325",
"0.67475116",
"0.66654694",
"0.6574193",
"0.6573384",
"0.6528925",
"0.6467978",
"0.6461469",
"0.64126956",
"0.636431",
"0.6359416",
"0.6341048",
"0.6274866",
"0.6228298",
"0.62179524",
"0.616861",
"0.61562407",
"0.61488205",
"0.6135555",
... | 0.5986161 | 27 |
updating the locationerror and itemerror after deleting records from the upload screen | def update_errormaintenance
case self.upload_filename
when 'Location.csv'
location_error = Locationerror.destroy_all(uploadfile_id: self.id)
when 'Item.csv'
item_error = Itemerror.destroy_all(uploadfile_id: self.id)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reprocess\n ids = params[:id]\n errorExists = false\n ids.each do |id|\n itemerror = Itemerror.find(id.to_i)\n error = is_row_valid itemerror \n if error.blank?\n \n itemHash = {:client_id => itemerror.attribute1, \n :item_nu... | [
"0.63751537",
"0.58743423",
"0.5806554",
"0.57207894",
"0.569172",
"0.5683614",
"0.5657516",
"0.5617872",
"0.5604993",
"0.55403167",
"0.55263066",
"0.5513364",
"0.5510752",
"0.55032307",
"0.5493465",
"0.54803884",
"0.5459021",
"0.54234034",
"0.54214585",
"0.54098827",
"0.5398... | 0.72084194 | 0 |
Update the status of the uploaded file | def update_status
case
#If the file is in processing dont change the status
when (self.attribute1 == "Processing" or self.attribute1 == "Uploaded")
self.attribute1 = self.attribute1
#When the file has all processed record
when (self.no_of_processed_records !=0 and self.no_of_error_records == 0)
self.attribute1 = "Processed"
#When the file has only error records no processed record
when (self.no_of_processed_records ==0 and self.no_of_error_records !=0)
self.attribute1 = "Error"
#When there are processed records and error records both in the file
when (self.no_of_processed_records!=0 and self.no_of_error_records !=0)
self.attribute1 = "Processed with Error"
#When all the records are processed and no error and no deleted records
when (self.no_of_records == self.no_of_processed_records and self.no_of_error_records == 0 and self.no_of_deleted_records == 0)
self.attribute1 = "Processed Successfully"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_status(status)\n @status = status\n @last_status_change = Time.now\n update_statusfile\n end",
"def update(uploaded_file)\n _set(uploaded_file)\n end",
"def run_upload!\n \tself.status = 'En Proceso'\n \tsave\n end",
"def update_file(params)\n self.processed = false... | [
"0.7392309",
"0.7360412",
"0.7196221",
"0.711043",
"0.69734913",
"0.6907724",
"0.6903304",
"0.6836086",
"0.67979157",
"0.677148",
"0.6767429",
"0.67000014",
"0.6678934",
"0.6672454",
"0.6672454",
"0.66581047",
"0.66365635",
"0.65847164",
"0.65715075",
"0.6557642",
"0.6553165"... | 0.6479603 | 28 |
refactor to put in the reader and initialize method | def title
if @title == nil
"Movie not found!"
else
@title
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initializing_reader(key); end",
"def initialize(reader)\n @reader = reader\n end",
"def reader=(_arg0); end",
"def reader; end",
"def initialize(structured_reader,&block)\n @reader = structured_reader\n instance_eval( &block ) if block\n end",
"def initialize\n super()\n ... | [
"0.7154368",
"0.70898867",
"0.70443493",
"0.6979475",
"0.65022844",
"0.64680356",
"0.6453356",
"0.64045167",
"0.6398014",
"0.63712186",
"0.6330945",
"0.6329816",
"0.63130033",
"0.6281689",
"0.6254085",
"0.6230478",
"0.6194092",
"0.6176675",
"0.61694026",
"0.6157127",
"0.61571... | 0.0 | -1 |
This concern requires the following methods to be implemented: current_user, target_branch, repository, commit_message Before calling `run_actions`, you should ensure the repository exists, by calling `repository.create_if_not_exists`. | def run_actions(actions, skip_system_notes: false)
raise NoActions if actions.empty?
sha = repository.multi_action(current_user,
branch_name: target_branch,
message: commit_message,
actions: actions.map(&:gitaly_action))
::DesignManagement::Version
.create_for_designs(actions, sha, current_user)
.tap { |version| post_process(version, skip_system_notes) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push\n ensure_git_and_cucumber_available\n ensure_repository\n\n puts \"Not implemented yet... pull request for push please!\"\n end",
"def create_managed_repository\n OpenProject::Revisions::Git::GitoliteWrapper.update(:add_repository, self)\n rescue => e\n Rails.logger.error(\"Error while ... | [
"0.63340926",
"0.6236264",
"0.6153249",
"0.6011007",
"0.59975284",
"0.5940933",
"0.5936595",
"0.5833702",
"0.5833702",
"0.5833702",
"0.5833702",
"0.57903993",
"0.5786597",
"0.5775998",
"0.575702",
"0.5753893",
"0.5709424",
"0.5704756",
"0.5695411",
"0.5693894",
"0.56690115",
... | 0.0 | -1 |
Setting.plugin_redmine_html_macro['htmlmacro_url'] ? Setting.plugin_redmine_html_macro['htmlmacro_url'] : Setting.plugin_redmine_html_macro['markdownit_url'] ? Setting.plugin_redmine_html_macro['markdownit_url'] : | def view_layouts_base_body_bottom(context={})
html = ""
html << stylesheet_link_tag('htmlmacro.css', :plugin => 'redmine_html_macro')
html << javascript_include_tag('markdown-it.min.js', :plugin => 'redmine_html_macro')
# html << stylesheet_link_tag('/redmine/plugin_assets/redmine_html_macro/stylesheets/htmlmacro.css')
# html << javascript_include_tag('/redmine/plugin_assets/redmine_html_macro/javascripts/markdown-it.min.js')
html << stylesheet_link_tag(Setting.plugin_redmine_html_macro['css_url'])
html << javascript_include_tag(Setting.plugin_redmine_html_macro['js_url'])
# html
# html << javascript_tag("mermaid.initialize({startOnLoad:true});var mermaidInitialized = 1;")
return html
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markdown_extra?\n true\n end",
"def getDefaultConfig\n return \"\n{\n \\# Directory where MediaWiki is installed\n :MediawikiDir => '#{@MediawikiDir}'\n}\n\"\n end",
"def main_url\n homepage || linkedin || twitter_url || github_url || nil\n end",
"def use_markdown=(value)\n ... | [
"0.57778347",
"0.56799877",
"0.54663444",
"0.5212251",
"0.5204728",
"0.5204728",
"0.5201314",
"0.5139513",
"0.5133032",
"0.5120223",
"0.5117432",
"0.510278",
"0.5102328",
"0.5087032",
"0.5087032",
"0.5087032",
"0.5082156",
"0.5059761",
"0.50050765",
"0.5004875",
"0.50010616",... | 0.47161523 | 65 |
broke it down like this so that can access and compare the attributes | def control
{ :masterid => '1234FAKE',
:ca_co_status => 'control',
:biomom => 1,
:biodad => nil,
:date => nil,
:mother_full_name => 'Jill Johnson',
:mother_maiden_name => 'Jackson',
:father_full_name => 'Jack Johnson',
:child_full_name => 'Michael Johnson',
:child_dobm => 1,
:child_dobd => 6,
:child_doby => 2009,
:child_gender => 'M',
:birthplace_country => 'United States',
:birthplace_state => 'CA',
:birthplace_city => 'Oakland',
:mother_hispanicity => 2,
:mother_hispanicity_mex => 2,
:mother_race => 1,
:mother_race_other => nil,
:father_hispanicity => 2,
:father_hispanicity_mex => 2,
:father_race => 1,
:father_race_other => nil }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_reader(*args)\n super\n comparison_attrs.concat(args)\n end",
"def attr; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
"def attributes; end",
... | [
"0.648961",
"0.64631283",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.64562124",
"0.6366363",
"0.6329011",
"0.6291048",
"0.6253686",
"0.6253686",
"0.6253686",
"0.6253686",
"0.62... | 0.0 | -1 |
shouldn't be called test_... as makes it a test method! | def csv_test_file_name
"live_birth_data_update_test_file.csv"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testing\n # ...\n end",
"def test_method\n end",
"def tests; end",
"def tests; end",
"def self_test; end",
"def self_test; end",
"def test \n end",
"def test\n\n end",
"def test_case; end",
"def test\n end",
"def test\n end",
"def test\n end",
"def __dummy_test... | [
"0.7896266",
"0.77121276",
"0.7646567",
"0.7646567",
"0.754109",
"0.754109",
"0.7492185",
"0.7461208",
"0.74444",
"0.74434185",
"0.74434185",
"0.74434185",
"0.7419577",
"0.72673863",
"0.72673863",
"0.7238924",
"0.722074",
"0.71210295",
"0.7105422",
"0.7105422",
"0.70630527",
... | 0.0 | -1 |
def logger= Wrap SizedQueuepush with a timer metric. | def push(*args)
@metric_queue_write.time do
super(*args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_time_updates\n @log.debug(\"Pushing timelogs.\")\n @ob.static(:Timelog, :push_time_updates, {:oata => self})\n end",
"def queue_time\n NotImplementedError\n end",
"def send_timer_message(topic, tag, body, timer, key = '')\n @producer.send_timer_message(topic, tag, body, timer.t... | [
"0.60173494",
"0.5971506",
"0.5854686",
"0.58236337",
"0.5822852",
"0.5727988",
"0.57177424",
"0.56765884",
"0.56610304",
"0.56102896",
"0.5589174",
"0.55890787",
"0.5575735",
"0.5575735",
"0.5575735",
"0.5575735",
"0.55646974",
"0.5550715",
"0.5498783",
"0.5464265",
"0.54569... | 0.73045415 | 0 |
GET /ingredients GET /ingredients.json | def index
@ingredients = Ingredient.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def ingredient_data\n respond_to do |format|\n format.json { ren... | [
"0.82749915",
"0.7904606",
"0.738146",
"0.7342815",
"0.73110056",
"0.7248971",
"0.71387273",
"0.71288425",
"0.7097881",
"0.7073",
"0.70626014",
"0.7022474",
"0.69816965",
"0.6942283",
"0.69415855",
"0.6918985",
"0.68556786",
"0.68556786",
"0.68036395",
"0.6783335",
"0.6777634... | 0.6984497 | 13 |
GET /ingredients/1 GET /ingredients/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_ingredients\n rid = params[:id]\n items = Aws.get_ingredients_from_db(rid)\n render :json => items\n end",
"def ingredients_by_recipe\n recipe = Recipe.find(params[:id])\n render json: recipe.ingredients\n end",
"def show\n params.require(%i[id])\n render json: Ingredient.find_b... | [
"0.79940003",
"0.788936",
"0.7566463",
"0.7531003",
"0.74188334",
"0.73733646",
"0.7350761",
"0.7282355",
"0.7211195",
"0.71441513",
"0.7120503",
"0.7106303",
"0.70800036",
"0.7016235",
"0.6978926",
"0.6972189",
"0.6941257",
"0.6941257",
"0.6913198",
"0.6897089",
"0.68653595"... | 0.0 | -1 |
POST /ingredients POST /ingredients.json | def create
@ingredient = Ingredient.new(ingredient_params)
@ingredient.recipe = Recipe.find(ingredient_params[:recipe])
@ingredient.recipe.ingredients << @ingredient
save_relations
respond_to do |format|
if @ingredient.save
format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully added.' }
format.json { render :show, status: :created, location: @ingredient }
else
format.html { render :new }
format.json { render json: @ingredient.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n ingredient = Ingredient.create(ingredient_params)\n render json: ingredient\n end",
"def add_ingredients\n rid = params['id']\n name = params['name']\n quant = params['quantity']\n meas = params['measurement']\n\n ingredients = {\n 'name' => name,\n 'quantit... | [
"0.7749055",
"0.7590346",
"0.7465898",
"0.74050695",
"0.73933405",
"0.7167695",
"0.716602",
"0.71002847",
"0.7087613",
"0.70036024",
"0.6972241",
"0.69679314",
"0.6920982",
"0.6916151",
"0.68945533",
"0.68943995",
"0.6876029",
"0.68722105",
"0.6858264",
"0.6791807",
"0.678736... | 0.7286979 | 5 |
PATCH/PUT /ingredients/1 PATCH/PUT /ingredients/1.json | def update
respond_to do |format|
save_relations
if @ingredient.update(ingredient_params)
format.html { redirect_to @ingredient.recipe, notice: 'Ingredient was successfully updated.' }
format.json { render :show, status: :ok, location: @ingredient }
else
format.html { render :edit }
format.json { render json: @ingredient.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end",
"def update\n respond_to do |format|\n if @recipe.update(recipe_params)\n params[:recipe][:ingredients].each do |ingredient_id|\n next if ingredient_id.to_i == 0\n ingredient = In... | [
"0.7534066",
"0.7481154",
"0.7282842",
"0.7218124",
"0.716812",
"0.7153985",
"0.7069031",
"0.70139724",
"0.6955492",
"0.69382715",
"0.6930377",
"0.6907371",
"0.68695575",
"0.68323964",
"0.68057036",
"0.6788979",
"0.6773863",
"0.67670363",
"0.675039",
"0.6748699",
"0.6729589",... | 0.7144632 | 6 |
DELETE /ingredients/1 DELETE /ingredients/1.json | def destroy
recipe = @ingredient.recipe
@ingredient.destroy
respond_to do |format|
if recipe.save
format.html { redirect_to recipe, notice: 'Ingredient was successfully removed.' }
format.json { head :no_content }
else
format.html { redirect_to recipe, notice: 'An error occured while removing the ingredient.' }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n rid = params['id']\n if Aws.delete_recipe(rid) && Aws.delete_all_ing... | [
"0.77841467",
"0.7688536",
"0.7622828",
"0.75866234",
"0.7467383",
"0.7467383",
"0.74408317",
"0.7433734",
"0.73942",
"0.7372651",
"0.7334119",
"0.7302972",
"0.73027277",
"0.72947854",
"0.7273495",
"0.7253994",
"0.72406185",
"0.72399557",
"0.7224781",
"0.7174499",
"0.714602",... | 0.7305878 | 11 |
Use callbacks to share common setup or constraints between actions. | def set_ingredient
@ingredient = Ingredient.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 ingredient_params
params.require(:ingredient).permit(:weight, :recipe, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Removes html and generate a summary | def summarize(html, max = nil)
return '' if is_blank?(html)
unclean = Nokogiri::HTML::DocumentFragment.parse(html.dup)
summarize_fragment(unclean, max).to_html
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summary\n if key? 'summary'\n self['summary'].to_s.thru_erb.to_html\n else\n case html.gsub(%r{<(h\\d).*?>.*?</\\1>}m, '') # omit headings from summary\n\n # the first HTML block-level element\n when %r{\\A\\s*<(\\w+).*?>.*?</\\1>}m\n $&\n\n # the first par... | [
"0.7422649",
"0.7302963",
"0.7220527",
"0.716317",
"0.71277595",
"0.71272093",
"0.70591176",
"0.68869823",
"0.6794872",
"0.6727793",
"0.6624929",
"0.64273643",
"0.64220995",
"0.6385799",
"0.63471955",
"0.6271075",
"0.6197062",
"0.6189212",
"0.6189212",
"0.61786336",
"0.614703... | 0.66016406 | 11 |
Truncates text at a word boundry Parameters: text The text to truncate wordcount The number of words | def snippet(text, max)
result = ''
count = 0
# TODO figure out support for pre that contains code blocks..
return [result, count] if is_blank?(text)
text.split.each do |word|
return [result.strip!, count] if count >= max
result << "#{word} "
count += 1
end
[result.strip!, count]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncate\n @text.truncate_words(@word_num, omission: \"#{@cut_off}\")\n end",
"def truncate( text, num_words = 6, truncate_string = \"...\" )\n if text.nil? then return end\n arr = text.split( ' ' )\n arr.length > num_words ? arr[ 0...num_words ].join( ' ' ) + truncate_string : text\nend",
"def trunc... | [
"0.8006132",
"0.7943916",
"0.7894737",
"0.78400475",
"0.7774668",
"0.74910235",
"0.7342186",
"0.72614336",
"0.71379024",
"0.71034974",
"0.70580155",
"0.70544076",
"0.69960004",
"0.69745386",
"0.6945516",
"0.68938476",
"0.68938476",
"0.68938476",
"0.6878777",
"0.680703",
"0.67... | 0.0 | -1 |
TODO: pass ident of block/whatever | def initialize(ident, parent=nil)
@ident = ident
@symtab = {} # key: name, value: symbol
self.parent = parent
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7733458",
"0.7533599",
"... | 0.0 | -1 |
=begin rdoc Child scopes. This is used mainly for symbol table generation. =end | def children
@children ||= []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scopes; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope() binding end",
"def scopes\n read_inheritable_attribute(:scopes) || write_in... | [
"0.7538822",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.72437936",
"0.688924",
"0.6764597",
"0.65053344",
"0.64787346",
"0.6474301",
"0.6416756",
"0.6416343",
"0.6396639",
"0.6370502",
"0.63... | 0.0 | -1 |
=begin rdoc Set Parent of this scope. Note that this populates Scopechildren of parent Scope. =end | def parent=(scp)
@parent = scp
scp.children << self if scp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scope\n @scope ||= Scope.new(parent)\n end",
"def parent\n unless @parent\n @parent = search(:base => dn.parent, :scope => :base, :limit => true)\n @parent.instance_variable_get(:@children)[rdn] = self\n end\n @parent\n end",
"def parent\n _parent\n end",
"... | [
"0.74865836",
"0.7467809",
"0.73911303",
"0.7337593",
"0.73222315",
"0.7299989",
"0.7296345",
"0.7296345",
"0.7296345",
"0.7296345",
"0.72732824",
"0.724922",
"0.7213648",
"0.7161236",
"0.71584684",
"0.7135253",
"0.7116828",
"0.71003914",
"0.7060164",
"0.7060164",
"0.7053903"... | 0.0 | -1 |
=begin rdoc Return level of nesting for this Scope. Note that this is recursive calling Parentnesting. =end | def nesting
@parent ? @parent.nesting + 1 : 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level\n case\n when root? then 0\n when depth_column_could_be_used? then depth\n when parent_association_loaded? then parent.level + 1\n # @todo move it adapters\n else ancestors.size\n end\n end",
"def level\n return 0 if root?\n\n @parent.level + 1\... | [
"0.75401276",
"0.75121593",
"0.74023145",
"0.7244222",
"0.72277987",
"0.7158171",
"0.7113225",
"0.7089794",
"0.70424134",
"0.6976919",
"0.6938359",
"0.69357014",
"0.6877372",
"0.6877372",
"0.6855419",
"0.6836558",
"0.6804442",
"0.6766529",
"0.67595685",
"0.6721652",
"0.671457... | 0.77564746 | 0 |
=begin rdoc Return list of symbols defined in this scope. If recurse is true, all child scopes are included as well. =end | def symbols(names_only=false, recurse=false)
symtab = recurse ? @children.map { |c| c.symbols(names_only, true)
}.flatten : []
names_only ? @symtab.keys.concat(symtab) : @symtab.values.concat(symtab)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbols() @symbols end",
"def symbols\n @symbol_set.symbols\n end",
"def namespaces(recurse=false)\n symbols(false, recurse).map { |s| s.namespace }.sort.uniq\n end",
"def get_symbols\n\t\treturn @symbols\n\tend",
"def scopes\n @scope.scopes\n end",
"def find_scopes\n beg... | [
"0.59482014",
"0.5947744",
"0.58883786",
"0.5883107",
"0.58507305",
"0.5771868",
"0.5759235",
"0.56927687",
"0.5626161",
"0.5608084",
"0.5599274",
"0.5589726",
"0.55891174",
"0.5549639",
"0.5541664",
"0.5518219",
"0.5476042",
"0.54557234",
"0.54118705",
"0.5394323",
"0.537701... | 0.68184316 | 0 |
=begin rdoc Return a list of all namespaces defined in this scope. If recurse is true, all child scopes are included as well. =end | def namespaces(recurse=false)
symbols(false, recurse).map { |s| s.namespace }.sort.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespaces\n root ? root.collect_namespaces : {}\n end",
"def namespaces(name = nil)\n find_children_of_type(\"Namespace\", name)\n end",
"def get_namespaces\n @paths.keys\n end",
"def namespaces\n root ? root.namespaces : {}\n end",
"def namespaces_list(trac... | [
"0.6608163",
"0.63307005",
"0.6328688",
"0.6302396",
"0.62484294",
"0.60767066",
"0.6074819",
"0.6070898",
"0.60553",
"0.59742683",
"0.5966621",
"0.596532",
"0.58927965",
"0.5837362",
"0.58171564",
"0.57937944",
"0.5710635",
"0.5691525",
"0.56797403",
"0.5676827",
"0.5676827"... | 0.77889705 | 0 |
=begin rdoc Return number of symbols defined in this scope. =end | def num_symbols
@symtab.keys.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size() @symbols.size end",
"def count\n @symbols.count\n end",
"def num_sym_assumptions()\n count = 0\n for hop in @hops\n count += 1 if hop.type == :sym or hop.type == \"sym\"\n end\n count\n end",
"def symbol_ref\n @symbols += 1\n end",
"def total_documented... | [
"0.80281717",
"0.7972307",
"0.66729957",
"0.6554171",
"0.65375775",
"0.64984596",
"0.64677846",
"0.6394975",
"0.6370103",
"0.6336157",
"0.6294522",
"0.6276931",
"0.61802554",
"0.6163487",
"0.6130694",
"0.6120605",
"0.6105579",
"0.60652995",
"0.60208327",
"0.60191417",
"0.5999... | 0.8217561 | 0 |
=begin rdoc Define a symbol for function 'name' at location 'value' in scope. =end | def define_func(name, value, namespace=nil)
define(CodeSymbol.new name, value, namespace)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def []=(name, value)\n @symbols[to_name(name)] = value\n value.name = name if Function === value\n value\n end",
"def symfun name\n Symbolic.check_name name\n fs = SymbolicFunction.new(name)\n meta_def name do\n fs\n end\n fs\n end",
"def define_func... | [
"0.6376007",
"0.6342895",
"0.61895347",
"0.6139959",
"0.607645",
"0.59908056",
"0.59749603",
"0.59721446",
"0.5943563",
"0.59186906",
"0.5851679",
"0.582243",
"0.5819515",
"0.5779738",
"0.5768328",
"0.57683176",
"0.57570684",
"0.57507247",
"0.57507247",
"0.5733522",
"0.572135... | 0.7363207 | 0 |
=begin rdoc Define a symbol for variable 'name' at location 'value' in scope. =end | def define_var(name, value, namespace=nil)
define(DataSymbol.new name, value, namespace)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def []=( name, value )\n\t\t\t@locals[ name.to_sym ] = value\n\t\tend",
"def name=(value); end",
"def []=(name, value)\n ::Kernel.raise TypeError, \"name #{name} must convert to_sym\" unless name and name.respond_to?(:to_sym)\n @locals[name.to_sym] = value\n end",
"def []=(name, value)\n ... | [
"0.7030192",
"0.69080853",
"0.6905061",
"0.67526674",
"0.6659901",
"0.66179127",
"0.6560321",
"0.65255743",
"0.64517105",
"0.64145845",
"0.6384664",
"0.63763916",
"0.6369937",
"0.62819105",
"0.62392205",
"0.6197893",
"0.61888456",
"0.6162282",
"0.6152252",
"0.6137273",
"0.613... | 0.68786436 | 3 |
=begin rdoc Define a symbol for constant 'name' with value 'value' in scope. =end | def define_const(name, value, namespace=nil)
define(ConstSymbol.new name, value, namespace)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constant(name, value)\n define_method name.to_sym do\n value\n end\n end",
"def const name, value\n Symbolic.check_name name\n const = ConstExpr.new(name, value)\n meta_def name do\n const\n end\n const\n end",
"def const_def(name, value)\n ... | [
"0.794613",
"0.7674613",
"0.7243851",
"0.714517",
"0.7026722",
"0.6406562",
"0.62903064",
"0.6281845",
"0.61799705",
"0.6155422",
"0.61250526",
"0.61172664",
"0.61172664",
"0.61172664",
"0.6110459",
"0.60716426",
"0.60417986",
"0.6027615",
"0.60266054",
"0.60147935",
"0.59991... | 0.7556565 | 2 |
=begin rdoc Define a Symbol in scope by passing in a Symbol object. =end | def define(sym)
raise NameConflict if @symtab.include? sym.name
#FIXME: handle namespace better
@symtab[sym.fullname] = sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def def_symbol(name, address, memory_type = nil)\n @symbol_set.def_symbol name, address, memory_type\n end",
"def sym(name)\n SymEngine::Symbol.new(name)\nend",
"def use(sym); end",
"def symbol\n @symbol\n end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
"def symbol; end",
... | [
"0.73402077",
"0.69780415",
"0.69452524",
"0.69317997",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6848561",
"0.6681812",
"0.6610387",
"0.6557366",
"0.65378004",
"0.65213215",
"0.64922225",
"0.6477699",
"0.6470518",
"0.64517653",
"0.6363021",
"0.63421... | 0.61977637 | 31 |
=begin rdoc Resolve name to a Symbol object. This recurses to Parentresolve if necessary. =end | def resolve(name)
#FIXME: how to handle namespace
@symtab[name] || (parent ? parent.resolve(name) : nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve!(name)\n raise UnresolvedSymbol if not resolve(name) \n end",
"def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, found, ctx)\n found\n elsif dynamic = resolver.resolve_symbol(sym)\n dynamic\n else... | [
"0.75862575",
"0.6875471",
"0.6781045",
"0.6502915",
"0.64977247",
"0.6454168",
"0.6378003",
"0.6367195",
"0.63647264",
"0.6291669",
"0.6250075",
"0.6243137",
"0.61793715",
"0.6076152",
"0.6032398",
"0.601106",
"0.60109335",
"0.5996333",
"0.5954126",
"0.59341013",
"0.5931122"... | 0.7643453 | 0 |
=begin rdoc Resolve name to a Symbol object, raising an UnresolvedSymbol error if the symbol is not defined. This recurses to Parentresolve if necessary. =end | def resolve!(name)
raise UnresolvedSymbol if not resolve(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve(name)\n #FIXME: how to handle namespace\n @symtab[name] || (parent ? parent.resolve(name) : nil)\n end",
"def resolve_symbol(resolver, sym, ctx)\n if found = find_symbol(sym.to_sym, ctx)\n resolve_lexically(resolver, found, ctx)\n found\n elsif dynamic = resolver.... | [
"0.7561216",
"0.7144447",
"0.6465142",
"0.6414068",
"0.6355232",
"0.6293653",
"0.6159137",
"0.6137376",
"0.6115174",
"0.60982543",
"0.60907495",
"0.60878026",
"0.60678154",
"0.6013621",
"0.60131776",
"0.6002441",
"0.5997742",
"0.59965545",
"0.5977611",
"0.59694564",
"0.592306... | 0.8311625 | 0 |
Custom validator for currency | def validate_each(record, attribute, value)
return if value.is_a?(String) && value.length == 3 && value =~ CURRENCY_REGEX
record.errors.add(attribute, :invalid, message: 'must be a valid ISO 4217 Three-digit currency code')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_currency?\n self =~ /\\A[+-]?[0-9]{1,3}(?:[0-9]*(?:[.,][0-9]{2})?|(?:,[0-9]{3})*(?:\\.[0-9]{2})?|(?:\\.[0-9]{3})*(?:,[0-9]{2})?)\\z/i\n end",
"def validate_currency_format\n raise 'Value is not in currency format' unless ValuesLib.check_currency_format(text_value_one)\n raise 'Value is not in cu... | [
"0.7344712",
"0.7246969",
"0.69681907",
"0.68464684",
"0.6732954",
"0.6555829",
"0.65535253",
"0.65535253",
"0.6533844",
"0.63370097",
"0.6316244",
"0.6271905",
"0.6232283",
"0.62217766",
"0.6127661",
"0.6120054",
"0.6092502",
"0.6085789",
"0.6067468",
"0.6047139",
"0.6011598... | 0.6768185 | 4 |
Defining to_s on an object controls how the object is represented as a string, e.g., when you pass it to puts | def to_s
#Create an empty string
letter_array = @spaces
# puts letter_array.to_s
letter_array.map!{|char| char == "Q" ? char = "Qu " : char = char + " "}
output_string = String.new()
# output_string = output_string.split('').map!{|char| char = char + " "}.join('')
4.times do
output_string << letter_array.shift(4).join('') + "\n"
end
output_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s_safe(obj)\n if obj.respond_to?(:to_s)\n obj.to_s\n else\n 'to_s error'\n end\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n object.to_s\n end",
"def to_s\n @object.to... | [
"0.79306906",
"0.7474114",
"0.7474114",
"0.74625593",
"0.7317577",
"0.72644997",
"0.72644997",
"0.72644997",
"0.7256048",
"0.72376037",
"0.72376037",
"0.7234111",
"0.7147253",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.7140837",
"0.714083... | 0.0 | -1 |
test "the truth" do assert true end test "unsuccessful edit" do | def setup
@user = users(:david)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_truth\r\n assert true\r\n end",
"def test_truth\r\n assert true\r\n end",
"def test_truth\r\n assert true\r\n end",
"def test_the_truth\n assert true\nend",
"def test_the_truth\n assert true\n end",
"def test_the_truth\n assert true\n end",
"def test_edit\n #login_as(:j... | [
"0.7832046",
"0.7832046",
"0.7832046",
"0.7830646",
"0.7824353",
"0.7824353",
"0.7793456",
"0.7781827",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.77292895",
"0.7... | 0.0 | -1 |
Using the Ruby language, have the function SymmetricTree(strArr) take the array of strings stored in strArr, which will represent a binary tree, and determine if the tree is symmetric (a mirror image of itself). The array will be implemented similar to how a binary heap is implemented, except the tree may not be complete and NULL nodes on any level of the tree will be represented with a . For example: if strArr is ["1", "2", "2", "3", "", "", "3"] then this tree looks like the following: 1 / \ 2 2 /\ /\ 3 3 For the input above, your program should return the string true because the binary tree is symmetric. | def symmetric_tree(arr)
rows = Hash.new([])
n = 0
until arr.empty?
(2**n).times { rows[n] += [arr.shift] }
n += 1
end
rows.values.each do |row|
return false unless row == row.reverse
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isTreeSymmetric(t)\n return true if t.nil?\n return sym?(t.left, t.right)\nend",
"def is_symmetric(root)\n return true if root.nil?\n\n stack = []\n stack << root.left if root.left\n stack << root.right if root.right\n\n until stack.empty?\n return false unless stack.size.even?\n\n right = ... | [
"0.76344705",
"0.7289066",
"0.72687614",
"0.7133568",
"0.71197224",
"0.70306444",
"0.6889006",
"0.68572754",
"0.68020713",
"0.66402566",
"0.6397494",
"0.63641757",
"0.6351757",
"0.6246554",
"0.5997706",
"0.5786831",
"0.5756023",
"0.5700338",
"0.5629166",
"0.5627084",
"0.56096... | 0.78964055 | 0 |
GET /diningts GET /diningts.json | def index
@diningts = Diningt.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def index\n\n @dtests = Dtest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dtests }\n end\n end",
"def index\n @sightings = Sighting.all\n render json: @sightings\n en... | [
"0.62330526",
"0.6204509",
"0.6182461",
"0.6148789",
"0.61273634",
"0.60521287",
"0.60411656",
"0.59897697",
"0.5979209",
"0.59673804",
"0.5957402",
"0.59309524",
"0.59278667",
"0.58980876",
"0.5897708",
"0.58862567",
"0.58832157",
"0.5840625",
"0.58361256",
"0.5822054",
"0.5... | 0.64167345 | 0 |
GET /diningts/1 GET /diningts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @dailyStanding = DailyStanding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @dailyStanding }\n end\n end",
"def show\n @dteor = Dteor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\... | [
"0.62002575",
"0.6189296",
"0.611213",
"0.61069083",
"0.609398",
"0.607846",
"0.6062383",
"0.6059271",
"0.6058113",
"0.60314316",
"0.602575",
"0.60207784",
"0.60181993",
"0.6014756",
"0.5999919",
"0.59928167",
"0.5975059",
"0.59737444",
"0.59735423",
"0.5954846",
"0.59491247"... | 0.0 | -1 |
POST /diningts POST /diningts.json | def create
@diningt = Diningt.new(diningt_params)
respond_to do |format|
if @diningt.save
format.html { redirect_to @diningt, notice: 'Diningt was successfully created.' }
format.json { render :show, status: :created, location: @diningt }
else
format.html { render :new }
format.json { render json: @diningt.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @dino = Dino.new(dino_params)\n\n if @dino.save\n render json: @dino, status: :created, location: @dino\n else\n render json: @dino.errors, status: :unprocessable_entity\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def ... | [
"0.5908641",
"0.58811843",
"0.57162154",
"0.56615084",
"0.56588924",
"0.5652193",
"0.5630965",
"0.5581175",
"0.5578508",
"0.5555963",
"0.5536668",
"0.5527933",
"0.55238193",
"0.54983556",
"0.5497054",
"0.5462751",
"0.5457966",
"0.54449415",
"0.54132146",
"0.54127806",
"0.5405... | 0.6290197 | 0 |
PATCH/PUT /diningts/1 PATCH/PUT /diningts/1.json | def update
respond_to do |format|
if @diningt.update(diningt_params)
format.html { redirect_to @diningt, notice: 'Diningt was successfully updated.' }
format.json { render :show, status: :ok, location: @diningt }
else
format.html { render :edit }
format.json { render json: @diningt.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => ... | [
"0.67739964",
"0.6754369",
"0.6585494",
"0.6559263",
"0.65169626",
"0.63566947",
"0.6331992",
"0.62543374",
"0.6231796",
"0.6223077",
"0.6223077",
"0.6215657",
"0.61544627",
"0.61350644",
"0.61336416",
"0.6125809",
"0.6101666",
"0.6101666",
"0.6080951",
"0.607152",
"0.6067655... | 0.6174379 | 12 |
DELETE /diningts/1 DELETE /diningts/1.json | def destroy
@diningt.destroy
respond_to do |format|
format.html { redirect_to diningts_url, notice: 'Diningt was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete_tenant_circle(args =... | [
"0.7293433",
"0.69377613",
"0.69345194",
"0.6934444",
"0.6899812",
"0.6874044",
"0.67440325",
"0.67236",
"0.6709017",
"0.6699786",
"0.668089",
"0.6676442",
"0.6676442",
"0.6676442",
"0.6676442",
"0.6642736",
"0.6636409",
"0.66261876",
"0.66188353",
"0.66100144",
"0.66100144",... | 0.65600306 | 26 |
Use callbacks to share common setup or constraints between actions. | def set_diningt
@diningt = Diningt.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def diningt_params
params.require(:diningt).permit(:title, :description, :price, :image, :previewo, :previewt, :previewth, :sdescription, :offerprice, :coupon, :brand, :color, :warrenty, :material)
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.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
This action will show the summery information of the book, such as the summery of the book, authors and pictures. For brief overview only. To obtain the index of the book, use SectionsControllerindex. Since the sections is nested into the Book resource. | def show
@book = Book.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @book_infos = BookInfo.all\n @book_details = BookDetail.all\n end",
"def index\n @articles = @book.articles\n end",
"def index\r\n @books = Book.all\r\n end",
"def show\n @summaries = Summary.all \n end",
"def index\n\n @books = Book.all\n\n end",
"def index\n @book =... | [
"0.6635577",
"0.64410126",
"0.64224374",
"0.6402412",
"0.63980013",
"0.6395378",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
"0.6392027",
... | 0.63041395 | 44 |
Start writing a brand new book. If you want to join to a existing book authoring, authorings_controllercreate should be used. | def create
begin
@book = current_user.writings.create!(params[:book])
rescue Exception => e
render 'new', error: @book.errors.full_messages
end
redirect_to @book
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\t\t@book = Book.new(book_params)\n\t\t@book.save\n\t\tredirect_to books_path\n\tend",
"def create\n\t\t@book = Book.new(params[:book])\n\t\t@book.title = @book.title.titleize\n\t\t@book.author_first = @book.author_first.titleize\n\t\t@book.author_last = @book.author_last.titleize\n\t\t@all_categorie... | [
"0.6796125",
"0.66333073",
"0.6606919",
"0.65997714",
"0.6575322",
"0.65293664",
"0.6527419",
"0.65175927",
"0.64862627",
"0.6479582",
"0.6475011",
"0.6463886",
"0.64320886",
"0.64149773",
"0.6413278",
"0.64050424",
"0.6404338",
"0.639999",
"0.6377288",
"0.6374696",
"0.637103... | 0.6474023 | 11 |
choose the correct book layout | def books_layout
if params[:action] == 'show'
'reading'
elsif params[:action] == 'edit' || params[:action] == 'new'
'writing'
else
'application'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def book_pages\n\t\t@book = {\n\t\t\t\t\"sketch\" =>\n\t\t\t\t\"\t\t\t\t------------------------------------------\n\t\t\t\t| |\n\t\t\t\t| ----- |\n\t\t\t\t| / _ \\\\ |\n\t\t\t\t| / | | \\\... | [
"0.61108327",
"0.5933449",
"0.57440704",
"0.570697",
"0.56774646",
"0.56319666",
"0.5630188",
"0.56156915",
"0.560078",
"0.55663633",
"0.5564099",
"0.5556548",
"0.5556548",
"0.5526127",
"0.5516367",
"0.55161184",
"0.55047596",
"0.54790866",
"0.54705864",
"0.54630667",
"0.5447... | 0.6880656 | 0 |
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 212 15 = 7 + 222 21 = 3 + 232 25 = 7 + 232 27 = 19 + 222 33 = 31 + 212 It turns out that the conjecture was false. What is the smallest odd composite that cannot be written as the sum of a prime and twice a square? | def prime? n
return false if n < 2
return true if n == 2 || n == 3
(2..(n ** 0.5)).each{|x| return false if n % x == 0}
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def if_prime_pattern(n)\n return false if n % 3 == 0\n return false if n % 7 == 0\n return false if n % 13 == 0\n\n # (n^2 + 13) % 7 == 0\n return false if n % 7 == 1 or n % 7 == 6\n # (n^2 + 3) % 7 == 0\n return false if n % 7 == 2 or n % 7 == 5\n # (n^2 + 9) % 13 == 0\n return false if n % 13 == 2 or n ... | [
"0.70197606",
"0.6976313",
"0.697596",
"0.69655925",
"0.69559234",
"0.69549006",
"0.69368637",
"0.69122845",
"0.6885894",
"0.68812287",
"0.6868595",
"0.68174845",
"0.68174845",
"0.6804397",
"0.67900175",
"0.67875063",
"0.67739856",
"0.67710984",
"0.6762837",
"0.6762235",
"0.6... | 0.0 | -1 |
The ShareThis widget defines a bunch of attributes you can customize. Facebook seems to ignore them (it uses title and description meta tags instead). MySpace, however, only works if you set these attributes. | def sharethis_options(post)
content_tag :script, :type=>"text/javascript" do
<<-eos
SHARETHIS.addEntry({
title:'#{escape_javascript(post.title)}',
content:'#{escape_javascript(truncate_words(post.post, 75, '...' ))}'
}, {button:true});
eos
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def share_button(options={})\n %(\n <fb:share-button class=\"meta\">\n #{SHARE_META_OPTIONS.select {|o| options.keys.include?(o) }.collect {|o| %(<meta name=\"#{o}\" content=\"#{options[o]}\" />)}.join(\"\\n\") }\n #{SHARE_LINK_OPTIONS.select {|o| options.keys.include?(o) }.collect {|o| %(<... | [
"0.6164924",
"0.5774608",
"0.5755568",
"0.5733232",
"0.572383",
"0.5587251",
"0.5515964",
"0.54684615",
"0.5434264",
"0.54263157",
"0.54180944",
"0.537928",
"0.5374398",
"0.5374354",
"0.53705394",
"0.5350056",
"0.53472424",
"0.5346767",
"0.5313958",
"0.5299231",
"0.52656925",... | 0.6146092 | 1 |
tears down given string not to exceed specified length | def teardown_to_oneline(line, length = 60)
lines = []
line.split(" ").each {|line|
if !lines.empty? && lines[-1].size + line.size + 1 <= length
lines[-1].concat(" " + line)
else
lines << line
end
}
return lines
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shorten( str, length = 120 )\n\tmatched = str.gsub( /\\n/, ' ' ).scan( /^.{0,#{length - 2}}/ )[0]\n\tunless $'.empty?\n\t\tmatched + '..'\n\telse\n\t\tmatched\n\tend\nend",
"def longestSub(str)\n\n\nend",
"def smart_truncate(len = 30, ending = '...')\n len = Math.max(len, 5)\n return self if self.len... | [
"0.644595",
"0.6294009",
"0.6292511",
"0.6224895",
"0.6214699",
"0.6137282",
"0.6025561",
"0.60216963",
"0.6002136",
"0.59554386",
"0.59424245",
"0.59358233",
"0.5889621",
"0.58332324",
"0.58261377",
"0.5808979",
"0.5808912",
"0.57957745",
"0.57921857",
"0.57905453",
"0.57894... | 0.0 | -1 |
comments out given string or string array and returns as a string array | def get_commented_lines(str)
if str.respond_to? "gsub!"
str.gsub(/^(.+)$/) {|s| "# " + s}
elsif str.respond_to? "map"
str.map {|line| "# " + line}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stringify_comment_array(comments); end",
"def prettyify_array(gemspec_ruby, array_name); end",
"def prettyify_array(gemspec_ruby, array_name)\n gemspec_ruby.gsub(/s\\.#{array_name.to_s} = \\[.+?\\]/) do |match|\n leadin, files = match[0..-2].split(\"[\")\n leadin + \"[\\n #{files.split(\",\... | [
"0.7820429",
"0.63665843",
"0.6287018",
"0.6287018",
"0.6170988",
"0.61390966",
"0.6079058",
"0.58411205",
"0.582735",
"0.57843274",
"0.5729192",
"0.57181394",
"0.56674725",
"0.5663996",
"0.565588",
"0.5650214",
"0.5650214",
"0.5650214",
"0.5650214",
"0.5650214",
"0.564853",
... | 0.60875744 | 6 |
comments out given string or string array and returns as a multilined string | def get_commented_text(str)
get_commented_lines(str).join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stringify_comment_array(comments); end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def comment(string); end",
"def make_comment( content )\n\t\treturn [\n\t\t\tself.options[:comment_start],\n\t\t\tcontent,\n\t\t\tself.options[:comment_end],\n\t\t].join\n\ten... | [
"0.7203483",
"0.6579914",
"0.6579914",
"0.6579914",
"0.6579914",
"0.62640107",
"0.6136036",
"0.6130273",
"0.6062229",
"0.60561925",
"0.60320175",
"0.59862894",
"0.59648246",
"0.5960865",
"0.5913104",
"0.5907246",
"0.5890026",
"0.5889057",
"0.5889057",
"0.58862275",
"0.5875330... | 0.62279874 | 6 |
builds up a template header with given informatations | def buildup_template_header(basename, hash)
header = []
type = hash[:type] || :script
header << filename_for(basename, type)
header << ""
description = hash[:description] || "no description"
header << teardown_to_oneline(description)
header << ""
date = hash[:date] || Time.now
header << "created on : %04d.%02d.%02d" % [date.year, date.month, date.day]
header << "last update: %04d.%02d.%02d" % [date.year, date.month, date.day]
header << ""
author = hash[:author] || AUTHOR_NAME
header << teardown_to_oneline("by " + author)
return header.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_header(keys_template)\n header = ''\n names = []\n keys = deep_copy(keys_template)\n\n keys.each { |key|\n begin\n if @config.header_mappings.any? { |k| k.include? key }\n\n header_label = key\n\n @config.header_mappings.each { |k, v|\n if header_label... | [
"0.7156262",
"0.67640334",
"0.67077214",
"0.6619542",
"0.6611294",
"0.64873326",
"0.6458695",
"0.6441575",
"0.64270765",
"0.64014536",
"0.6365368",
"0.6335823",
"0.63165736",
"0.62995416",
"0.62925225",
"0.62826335",
"0.62714285",
"0.62425524",
"0.6222881",
"0.61947244",
"0.6... | 0.73268914 | 0 |
builds up a template file with given informations | def buildup_template_file(basename, header, hash)
type = hash[:type] || :script
filename = filename_for(basename, type)
if File.exist? filename
exit 0 unless prompt("* '#{filename}' already exists, overwrite it? (y/n): ") =~ /^y$/i
end
File.open(filename, "w") {|file|
file << "#!/usr/bin/env ruby"
file << "\n"
file << "# coding: #{get_encoding}"
file << "\n" * 2
file << get_commented_text(header)
file << "\n" * 2
case type
when :script
file << TEMPLATE_SCRIPT
when :test
file << TEMPLATE_TEST_UNIT
when :rspec
file << TEMPLATE_RSPEC
end
file.chmod SCRIPT_MOD
puts "* Successfully generated: #{filename}"
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_for(file); end",
"def templates_for(file); end",
"def build template\n erb = File.read(File.join(VIEWS_DIR, template + \".erb\"))\n content = ERB.new(erb).result(binding)\n File.open(template, 'w') do |f|\n f.write content.gsub(/\\n\\n\\n+/, \"\\n\\n\")\n end\n end",
... | [
"0.74489474",
"0.7246953",
"0.7205909",
"0.7065472",
"0.70124274",
"0.6989121",
"0.6951624",
"0.6889279",
"0.68815917",
"0.67283964",
"0.6722969",
"0.6719903",
"0.66892743",
"0.6642551",
"0.65460753",
"0.6542569",
"0.6531263",
"0.6517955",
"0.65082335",
"0.6504285",
"0.648799... | 0.70958006 | 3 |
TODO: this is silly, type should be the same | def global_entity
contained_object.to_global_id if contained_object.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; end",
"def type; e... | [
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534",
"0.70859534"... | 0.0 | -1 |
If the contained_object is a CollectionObject, it must have a parent container reference | def contained_object_is_container_when_parent_id_is_blank
if parent_id.blank? && container_id.blank? && container.blank?
errors.add(:parent_id, 'can only be blank if object is a container') if contained_object_type != 'Container'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_collection_object\n return self.resource_type == Resource::COLLECTION_OBJECT;\n end",
"def parent_contained_object_is_container\n unless parent_id.blank? && parent.nil?\n errors.add(:parent_id, \"can only be set if parent's contained object is a container\") if parent.contained_object_type != ... | [
"0.6812132",
"0.6766822",
"0.6600402",
"0.65625894",
"0.65428454",
"0.6017317",
"0.5969113",
"0.5962249",
"0.5933265",
"0.5902437",
"0.58872885",
"0.58872885",
"0.5816135",
"0.58038753",
"0.57956773",
"0.57833385",
"0.5768248",
"0.5767724",
"0.5750612",
"0.57403684",
"0.57309... | 0.6538655 | 5 |
parent_id links an object to a container through container_item | def parent_contained_object_is_container
unless parent_id.blank? && parent.nil?
errors.add(:parent_id, "can only be set if parent's contained object is a container") if parent.contained_object_type != 'Container'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_id\n object[\"parent_id\"]\n end",
"def parent_id\r\n return nil unless ar_object\r\n ar_object[ar_p]\r\n end",
"def container_parent\n parent_id = data.at_xpath(\"/c/did/container/@parent\")\n return unless parent_id\n parent = data.... | [
"0.7127039",
"0.675173",
"0.6740257",
"0.6707828",
"0.66208434",
"0.6599278",
"0.6541346",
"0.64778286",
"0.64744747",
"0.645836",
"0.64488983",
"0.64488983",
"0.64286",
"0.64271516",
"0.6420557",
"0.64191",
"0.6408357",
"0.6408357",
"0.6408357",
"0.6408357",
"0.6366782",
"... | 0.64513725 | 10 |
Loading map from a data | def from_data(data)
@map = data["map"]
for driver in data["drivers"]
driver_obj_rep = driver["object"]
driver_obj_real = Driver.new
driver_obj_real.name = driver_obj_rep["name"]
driver_obj_real.plate = driver_obj_rep["plate"]
driver_obj_real.rating = driver_obj_rep["rating"]
driver_obj_real.first_time = driver_obj_rep["first_time"]
x, y = driver["coord"]
@map[y][x] = driver_obj_real
@drivers.push({
"coord" => driver["coord"],
"object" => driver_obj_real
})
end
for restaurant in data["restaurants"]
restaurant_obj_rep = restaurant["object"]
restaurant_obj_real = Restaurant.new
restaurant_obj_real.name = restaurant_obj_rep["name"]
restaurant_obj_real.menu = restaurant_obj_rep["menu"]
x, y = restaurant["coord"]
@map[y][x] = restaurant_obj_real
@restaurants.push({
"coord" => restaurant["coord"],
"object" => restaurant_obj_real
})
end
# If there's more than 1 connected cave rooms
if populate_caves.length > 1
raise "There's can only one cave room!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_map(data)\n if data['guards']\n data['guards'].each_pair do |name, info|\n load_item('guard', name, info)\n end\n end\n\n if data['scenes']\n data['scenes'].each_pair do |name, info| \n load_item('scene', name, info)\n end\n end\n end",
"def load(existing_m... | [
"0.7464339",
"0.69085795",
"0.6726764",
"0.66259557",
"0.6553458",
"0.65366685",
"0.6406172",
"0.63425416",
"0.63390887",
"0.63012236",
"0.62634265",
"0.6253802",
"0.62102437",
"0.6195607",
"0.6188269",
"0.6081631",
"0.6075496",
"0.606865",
"0.59369147",
"0.59351695",
"0.5906... | 0.5827481 | 27 |
Generate initial map that only consist of wall | def generate_initial_map
for _ in 0...@height
temp = []
for _ in 0...@width
temp.push(@WALL)
end
@map.push(temp)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_map\n map = make_random_map\n map = add_borders(map)\n map = ensure_adjacent_rooms(map)\nend",
"def generate(north_west_corner,south_east_corner)\n\t\tn_y,n_x=north_west_corner.position\n\t\ts_y,s_x=south_east_corner.position\n\t\tsplit_point=Point.new(rand(n_y+2..s_y-2),rand(n_x+2..s_x-2),'wall'... | [
"0.76886547",
"0.6959513",
"0.69321233",
"0.6839378",
"0.6772527",
"0.67149854",
"0.6600952",
"0.6551186",
"0.6462697",
"0.6415269",
"0.63727856",
"0.63697803",
"0.6306374",
"0.6298288",
"0.6279866",
"0.627709",
"0.6257782",
"0.6238615",
"0.6180258",
"0.6159204",
"0.6156977",... | 0.8666017 | 0 |
Set up the border to be "unbreakable" | def set_border()
for row_i in 0...@height
@map[row_i][0] = @PERMANENT_WALL
@map[row_i][@width - 1] = @PERMANENT_WALL
end
for column_i in 0...@width
@map[0][column_i] = @PERMANENT_WALL
@map[@height - 1][column_i] = @PERMANENT_WALL
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bordered; self.border = true; self; end",
"def border; end",
"def border!\n border do\n # adds default border\n end\n end",
"def remove_border_mark(sexp)\n def sexp.inline_border?\n false\n end \n end",
"def outside_border_size\n renderer.... | [
"0.81409335",
"0.7536753",
"0.70074016",
"0.69198376",
"0.6810654",
"0.68106437",
"0.6764014",
"0.67237633",
"0.6670649",
"0.66500187",
"0.6558449",
"0.6514817",
"0.6467299",
"0.6443359",
"0.6437143",
"0.64086175",
"0.63793784",
"0.63750714",
"0.63693553",
"0.6362645",
"0.631... | 0.6206169 | 29 |
Clear unnecessary wall tht only have < 2 surrounding wall | def clear_small_wall
for row_i in 1...@height - 1
for column_i in 1...@width - 1
total_wall = count_adjacent_wall(row_i, column_i)
if @map[row_i][column_i] == @WALL
if total_wall < 2
@map[row_i][column_i] = @FLOOR
next
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_extra_walls\n a_count_number = $cells.length/2/5\n while a_count_number > 0 do\n cell_index = rand(0..$cells.length/2)\n remove_walls($cells[cell_index], $cells[cell_index+1])\n a_count_number -= 1\n end\n end",
"def input_remove_wall2\n # The mouse needs to b... | [
"0.732075",
"0.69721377",
"0.69222367",
"0.68305147",
"0.6526889",
"0.64435136",
"0.6385868",
"0.6376257",
"0.63558066",
"0.63275766",
"0.6321259",
"0.62610716",
"0.6236823",
"0.6193693",
"0.6174106",
"0.61476016",
"0.6131723",
"0.6089886",
"0.6089272",
"0.60892004",
"0.60845... | 0.80407876 | 0 |
Put user on given coordinate | def put_user(coord)
x_position = coord[0]
y_position = coord[1]
if !((0 < x_position && x_position < @width - 1) && (0 < y_position && y_position < @height - 1))
raise RangeError.new("User coordinate out of map size bound")
end
for row in [-1, 0, 1]
for column in [-1, 0, 1]
if !(row == 0 && column == 0) && @map[y_position + row][x_position + column] == @WALL
@map[y_position + row][x_position + column] = @FLOOR
end
end
end
@map[y_position][x_position] = @USER
join_rooms
clear_small_wall
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_location(user)\n geo = user.geolocation\n geo.latitude = 32.7157\n geo.longitude = -117.1611\n geo.fetch_address\n geo.save\n end",
"def place_at(x, y)\n\t\t@x = x\n\t\t@y = y\n\t\tcoords\n\tend",
"def at(*coordinates)\n position.coordinates = coordinates\n end",
"def update\n ... | [
"0.65855575",
"0.6493982",
"0.6444826",
"0.639282",
"0.63071984",
"0.62104",
"0.6171253",
"0.6163389",
"0.61334705",
"0.61031675",
"0.6080396",
"0.6057807",
"0.6008821",
"0.59542906",
"0.593535",
"0.589696",
"0.58684963",
"0.5863087",
"0.5862918",
"0.58574045",
"0.58562094",
... | 0.75476843 | 0 |
Counting the caves It will return a list of cave rooms coordinate | def populate_caves
for row_i in 1...@height - 1
for column_i in 1...@width - 1
if @map[row_i][column_i] == @FLOOR
union_adjacent_square(row_i, column_i)
end
end
end
@disjoinset.split_sets()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def door_count; end",
"def count_rooms\n room_count = 0\n rooms = Array.new(@width)\n rooms.each_index() do |index|\n rooms[index] = Array.new(@height, 0)\n end\n @map.each_index() do |x|\n @map[x].each_index() do |y|\n if(!is_solid?(x, y) && rooms[x][y] == 0)\n room_coun... | [
"0.6169896",
"0.6118285",
"0.60921013",
"0.60147",
"0.5817462",
"0.5817323",
"0.5746232",
"0.56724656",
"0.56181216",
"0.557766",
"0.5536837",
"0.55094105",
"0.54802287",
"0.54706615",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
"0.5459505",
... | 0.0 | -1 |
Joining the cave rooms | def join_rooms
all_caves = populate_caves
for cave in all_caves.keys()
join_points(all_caves[cave][0])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_room(id)\n @rooms.join id\n end",
"def join\n payload = { \"id\" => id }.to_json\n data = client.post \"#{api_prefix}/user/#{client.user.id}/rooms\", payload\n\n self\n end",
"def room\n end",
"def join\n @room = OnlineMeetingRoom.find_by_id(params[:id])\n ... | [
"0.6929115",
"0.65493333",
"0.6470753",
"0.6353431",
"0.629946",
"0.6285749",
"0.62440854",
"0.6226542",
"0.6131227",
"0.6118975",
"0.61099356",
"0.59364444",
"0.5933658",
"0.59272385",
"0.5920061",
"0.589729",
"0.5849205",
"0.5842395",
"0.5831786",
"0.57516813",
"0.5740848",... | 0.7822134 | 0 |
Find the shortest path from one coordinate to other coordinate | def shortest_path(start_coord, destination_coord)
queue = Queue.new
queue << [start_coord]
seen = Set.new([start_coord])
while queue
begin
path = queue.pop(non_block = true)
rescue ThreadError
return nil
end
x, y = path[-1]
if [x, y] == destination_coord
return path
end
for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]
if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])
queue << (path + [[x2, y2]])
seen.add([x2, y2])
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return pa... | [
"0.7697564",
"0.743759",
"0.73410743",
"0.7272909",
"0.7203339",
"0.7181298",
"0.7136766",
"0.7038711",
"0.69993603",
"0.69938767",
"0.69314754",
"0.69020987",
"0.68623686",
"0.681849",
"0.6803307",
"0.6781413",
"0.67556626",
"0.6724962",
"0.6721541",
"0.67188454",
"0.6713906... | 0.7386457 | 2 |
Find the nearest path to user from the given coordinate It will return the shortest path to the user | def shortest_path_to_user(start_coord)
queue = Queue.new
queue << [start_coord]
seen = Set.new([start_coord])
while queue
begin
path = queue.pop(non_block = true)
rescue ThreadError
return nil
end
x, y = path[-1]
if @map[y][x] == @USER
return path
end
for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]
if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])
queue << (path + [[x2, y2]])
seen.add([x2, y2])
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_step_to_shortest_path(from_x, from_y, to_x, to_y)\n move = shortest_path(from_x, from_y, to_x, to_y)&.first\n return nil unless move\n if move[0] == from_x && move[1] == from_y + 1\n return 'S'\n elsif move[0] == from_x && move[1] == from_y - 1\n return 'N'\n elsif move[0] == from... | [
"0.7033883",
"0.6896861",
"0.68080926",
"0.66212493",
"0.6564974",
"0.65628564",
"0.65618485",
"0.64153",
"0.64108837",
"0.63817585",
"0.6262553",
"0.6261021",
"0.6248313",
"0.6236319",
"0.6222654",
"0.6213536",
"0.6202141",
"0.62017614",
"0.6198533",
"0.61870044",
"0.6156369... | 0.7334569 | 0 |
Find the nearest driver from given coordinate It will return a hash about the nearest driver coordinate, driver object, and the shortest route to the driver | def nearest_driver(coord_from)
queue = Queue.new
queue << [coord_from]
seen = Set.new([coord_from])
while queue
begin
path = queue.pop(non_block = true)
rescue ThreadError
return nil
end
x, y = path[-1]
if @map[y][x].instance_of?(Driver) && [x, y] != coord_from
return { "coord" => [x, y], "route" => path, "object" => @map[y][x] }
end
for x2, y2 in [[x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]]
if (0 <= x2 && x2 < @map[0].length) && (0 <= y2 && y2 < @map.length) && (@map[y2][x2] != @WALL && @map[y2][x2] != @PERMANENT_WALL) && !seen.include?([x2, y2])
queue << (path + [[x2, y2]])
seen.add([x2, y2])
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nearest_driver(map,user)\n driver_pos=[]\n\n for i in 0..map.length-1\n for j in 0..map.length-1\n if map[i][j] == \" D \"\n driver_pos << [i,j]\n end\n end\n end\n @driver_pos=driver_pos\n\n nearest_driver_position = driver_pos[0]\n distance = driver_pos[0].z... | [
"0.6496551",
"0.6214725",
"0.59901685",
"0.5965178",
"0.5848656",
"0.58154273",
"0.56944966",
"0.5630501",
"0.55432105",
"0.55432105",
"0.55278695",
"0.5414297",
"0.5389519",
"0.53645104",
"0.5308795",
"0.5308255",
"0.5300886",
"0.5296709",
"0.52879435",
"0.5269035",
"0.52503... | 0.77339447 | 0 |
Put an object randomly on map floor | def put_random(object)
while true
random_row = rand(1...@height - 1)
random_column = rand(1...@width - 1)
if @map[random_row][random_column] == @FLOOR
@map[random_row][random_column] = object
return [random_column, random_row]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place_oject_randomly(object)\n while is_wall?(object.location)\n object.location_x = 1 + rand(width - 1)\n\n object.location_y = 1 + rand(height - 1)\n end\n\n objects << object\n end",
"def create_random_world\n randomize_terrain\n randomize_entities\n end",
"def rand_location\n... | [
"0.77853715",
"0.71777976",
"0.6342371",
"0.6325588",
"0.6325415",
"0.62598896",
"0.6256992",
"0.62299323",
"0.6205703",
"0.6198474",
"0.615919",
"0.6149883",
"0.6089877",
"0.6063938",
"0.6052327",
"0.60449165",
"0.6035289",
"0.60232246",
"0.60132855",
"0.60106415",
"0.600774... | 0.77610946 | 1 |
Delete driver from the map | def delete_driver(driver_coord)
@drivers.delete_if do |driver|
driver["coord"] == driver_coord
end
x, y = driver_coord
@map[y][x] = @FLOOR
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mind_map.destroy\n end",
"def destroy\n\t\t\t\trespond_with Driver.destroy(params[:id])\n end",
"def delete_maps\n own_maps.each do | map |\n logger.debug \"deleting map #{map.inspect}\"\n map.destroy\n end\n end",
"def delete_maps\n own_maps.each do | map |\n ... | [
"0.6448386",
"0.64195776",
"0.61932623",
"0.61932623",
"0.60951954",
"0.6063446",
"0.6034535",
"0.60285723",
"0.60175073",
"0.6015528",
"0.600267",
"0.59961265",
"0.598021",
"0.59604883",
"0.59193075",
"0.58729386",
"0.58729386",
"0.58729386",
"0.5870536",
"0.5807259",
"0.579... | 0.74614185 | 0 |
Show the path that has been passed Path should be an array of coordinate | def show_map_with_path(path)
map_temp = @map.map(&:clone) # Had to clone the map
for x, y in path
map_temp[y][x] = @PATH # Writing down the path
end
for row in map_temp
row_to_print = []
for item in row
if item == @FLOOR
row_to_print.push(" ") # Floor
elsif item == @PATH
row_to_print.push(".") # Path that the driver has passed
elsif item == @USER
row_to_print.push("\e[32m@\e[0m") # @ with green color
elsif item.instance_of?(Driver)
row_to_print.push("D") # Driver
elsif item.instance_of?(Restaurant)
row_to_print.push("R") # Restaurant
elsif item == @WALL || item == @PERMANENT_WALL
row_to_print.push("#") # Wall
else
row_to_print.push(" ")
end
end
puts row_to_print.join(" ")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_paths; end",
"def print_path\n @path.each{|x| puts x.inspect}\n end",
"def draw_paths=(_arg0); end",
"def drawMapPath(startPoint, endPoint, path)\n print \"Width: \"+@width.to_s+\"\\n\"\n print \"Height: \"+@height.to_s+\"\\n\"\n print \"Path Length: \"+path.count.to_s+\"\\n... | [
"0.6814275",
"0.67022854",
"0.66322815",
"0.65466475",
"0.64858454",
"0.63821626",
"0.6307617",
"0.6237354",
"0.6206942",
"0.6191151",
"0.61810964",
"0.6135012",
"0.6121396",
"0.6022216",
"0.6020184",
"0.59939325",
"0.598658",
"0.5950732",
"0.5915559",
"0.59137577",
"0.591139... | 0.6603907 | 3 |
See ActionController::RequestForgeryProtection for details | def location_path(location)
url_for(:controller => 'locations', :action => 'show', :city => location.city.gsub(' ','_'), :state => location.state)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def protect_against_forgery?; end",
"def disable_request_forgery_protection; end",
"def disable_request_forgery_protection=(_arg0); end",
"def allow_forgery_protection\n true\n end",
"def protect_against_forgery?\n end",
"def protect_against_forgery?\n\n end",
"def protect_from_forgery\n end... | [
"0.76337904",
"0.7546625",
"0.7545239",
"0.728618",
"0.7254646",
"0.72267616",
"0.7150694",
"0.7117463",
"0.711017",
"0.7095813",
"0.7085116",
"0.7084132",
"0.7084132",
"0.7084132",
"0.7084132",
"0.7084132",
"0.7084132",
"0.70564467",
"0.70140094",
"0.7009851",
"0.6961618",
... | 0.0 | -1 |
Included in the Logins concern | def index # This is what we'll need if we want our url/tags page to exist
@tags = Tag.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logged_in\r\n end",
"def log_in\n end",
"def logging_in\n end",
"def logging_in\n \t\t\n \tend",
"def login; end",
"def require_login\n end",
"def logging_in\n current_user.absorb_from(guest_user)\n end",
"def login\n end",
"def sign_in\n trait()\n end",
"def login\n e... | [
"0.74480385",
"0.74322075",
"0.73933727",
"0.73253226",
"0.67111313",
"0.66492784",
"0.65092254",
"0.649095",
"0.64809084",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6478524",
"0.6465449",
"0.645956",
"0.6453365... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.