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 |
|---|---|---|---|---|---|---|
I worked on this challenge by myself. smallest_integer is a method that takes an array of integers as its input and returns the smallest integer in the array +list_of_nums+ is an array of integers smallest_integer(list_of_nums) should return the smallest integer in +list_of_nums+ If +list_of_nums+ is empty the method should return nil Your Solution Below | def smallest_integer(list_of_nums)
# Your code goes here!
return nil if list_of_nums.empty?
#itteration
smallest = list_of_nums[0]
i = 1
while(i < list_of_nums.size)
smallest = list_of_nums[i] if list_of_nums[i] < smallest
i += 1
end
return smallest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def smallest_integer(list_of_nums)\n smallest = list_of_nums[0]\n list_of_nums.each do |x|\n if x <= smallest\n smallest = x\n end\n end\n if list_of_nums.nil?\n return nil\n end\n return smallest\nend",
"def smallest_integer(list_of_nums)\n length = list_of_nums.length\n if length == 0\n... | [
"0.91123784",
"0.90863335",
"0.9063054",
"0.90546966",
"0.9011721",
"0.893854",
"0.8866158",
"0.8865889",
"0.88421893",
"0.88346416",
"0.8677305",
"0.8670344",
"0.8656316",
"0.8653132",
"0.86462903",
"0.8635065",
"0.85971576",
"0.85401565",
"0.8538809",
"0.85348487",
"0.84695... | 0.8829303 | 10 |
The frame's default execution context. | def execution_context
raise "Execution Context is not available in detached frame \"#{frame.url}\" (are you trying to evaluate?)" if @_detached
@_context_promise.value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execution_context\n initialize_context!(Object.new)\n end",
"def execution_context\n @context\n end",
"def run_context\n nil\n end",
"def default_view_context\n ActionController::Base.new.view_context\n end",
"def default_view_context\n ActionController::Base.new.... | [
"0.6777796",
"0.6683005",
"0.6544475",
"0.6507209",
"0.6507209",
"0.6379279",
"0.6375337",
"0.635769",
"0.634832",
"0.63318783",
"0.630878",
"0.63039845",
"0.63039845",
"0.6291997",
"0.62233007",
"0.6200452",
"0.61555564",
"0.6146917",
"0.6146917",
"0.61099464",
"0.6097495",
... | 0.67062175 | 1 |
The method queries frame for the selector. If there's no such element within the frame, the method will resolve to null. | def query_selector(selector)
document.query_selector selector
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_frame(selector, &block)\n using_wait_time(7) do\n frame = find(selector)\n within_frame(frame) do\n block.call\n end\n end\n end",
"def frame(selector, argument)\n case selector\n when :name\n driver.switch_to.frame(argument)\n when :index\n ... | [
"0.654698",
"0.6482461",
"0.6138322",
"0.6127928",
"0.60304815",
"0.5851893",
"0.5780555",
"0.5725222",
"0.5699062",
"0.56347495",
"0.5612283",
"0.5591809",
"0.55820054",
"0.55672544",
"0.5487718",
"0.5471602",
"0.5456332",
"0.54077494",
"0.5387105",
"0.5364496",
"0.5363186",... | 0.59274447 | 5 |
The method evaluates the XPath expression. | def xpath(expression)
document.xpath expression
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xpath; end",
"def xpath; end",
"def xpath(*args); end",
"def xpath(*args); end",
"def at_xpath(*args); end",
"def at_xpath(*args); end",
"def xpath(xpath)\n @doc.xpath(xpath)\n end",
"def evaluate(context)\n Parser.new(@expr).parse.evaluate(context)\n end",
"def xpath(path)\... | [
"0.7276239",
"0.7276239",
"0.71157575",
"0.71157575",
"0.6934695",
"0.6934695",
"0.66685826",
"0.6616184",
"0.6581248",
"0.64662045",
"0.6379013",
"0.635437",
"0.6266348",
"0.6164858",
"0.61581963",
"0.61435694",
"0.60825723",
"0.60510975",
"0.6043136",
"0.6040138",
"0.598646... | 0.7369241 | 0 |
The method runs document.querySelectorAll within the frame. If no elements match the selector, the return value resolves to []. | def query_selector_all(selector)
document.query_selector_all selector
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all(selector)\n DOM::NodeList.new `Array.prototype.slice.call(#{@el}.querySelectorAll(#{selector}))`\n end",
"def findAll(selector)\n DOM::NodeList.new `Array.prototype.slice.call(#{@el}.querySelectorAll(#{selector}))`\n end",
"def query_selector_all(node_id:, selector:)\n {\n ... | [
"0.74725795",
"0.7255658",
"0.6986995",
"0.64311063",
"0.6394186",
"0.6207973",
"0.618712",
"0.6004348",
"0.58796173",
"0.58427256",
"0.58425415",
"0.5754153",
"0.56960666",
"0.5677586",
"0.56144214",
"0.5559332",
"0.55009055",
"0.54397327",
"0.54327863",
"0.5429639",
"0.5377... | 0.7261152 | 1 |
Gets the full HTML contents of the frame, including the doctype. | def content
function = <<~JAVASCRIPT
() => {
let retVal = '';
if (document.doctype)
retVal = new XMLSerializer().serializeToString(document.doctype);
if (document.documentElement)
retVal += document.documentElement.outerHTML;
return retVal;
}
JAVASCRIPT
evaluate_function(function).value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFrameHTML( frameName = \"\" )\n container = getObjectFrameReference( \"\" , frameName )\n return container.body.innerHTML\n end",
"def doctype\n %|<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">|\n end",
"def doctype\n ... | [
"0.6864478",
"0.6356913",
"0.6062692",
"0.6023928",
"0.5981928",
"0.5953172",
"0.59475815",
"0.5923575",
"0.58931446",
"0.58770525",
"0.58632016",
"0.5811959",
"0.5801141",
"0.5787463",
"0.5772578",
"0.5761035",
"0.5754725",
"0.5687827",
"0.56830925",
"0.5677174",
"0.5675877"... | 0.56940645 | 17 |
Adds a tag into the page with the desired url or content. | def add_script_tag(url: nil, path: nil, content: nil, type: '')
# param url [String]
# param type [String]
#
# return [Promise<HTMLElement>]
#
add_script_url = <<~JAVASCRIPT
async function addScriptUrl(url, type) {
const script = document.createElement('script');
script.src = url;
if (type)
script.type = type;
const promise = new Promise((res, rej) => {
script.onload = res;
script.onerror = rej;
});
document.head.appendChild(script);
await promise;
return script;
}
JAVASCRIPT
unless url.nil?
begin
return execution_context.evaluate_handle_function(add_script_url, url, type).value.as_element
rescue => _error
raise "Loading script from #{url} failed"
end
end
# @param content [String]
# @param type [string]
#
# @return [HTMLElement]
#
add_script_content = <<~JAVASCRIPT
function addScriptContent(content, type = 'text/javascript') {
const script = document.createElement('script');
script.type = type;
script.text = content;
let error = null;
script.onerror = e => error = e;
document.head.appendChild(script);
if (error)
throw error;
return script;
}
JAVASCRIPT
unless path.nil?
contents = File.read path
contents += '//# sourceURL=' + path.delete("\n")
return execution_context.evaluate_handle_function(add_script_content, contents, type).value.as_element
end
unless content.nil?
return execution_context.evaluate_handle_function(add_script_content, content, type).value.as_element
end
raise 'Provide an object with a `url`, `path` or `content` property'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_tag(type, content, options = {}); end",
"def add_tag\n url = Url.find_by(id: params[:id])\n tag = Tag.find_by(name: params[:tag])\n if tag\n ## TODO: handle tag with url in backend\n # if not url.tags.where(:tag_id => tag.id).any?\n # url.tags... | [
"0.65680206",
"0.6514454",
"0.6390427",
"0.63733554",
"0.6351047",
"0.62397987",
"0.6226584",
"0.61808205",
"0.6175438",
"0.61540467",
"0.61315227",
"0.61004555",
"0.6040082",
"0.59960526",
"0.5989696",
"0.5960795",
"0.59564584",
"0.59128577",
"0.59049964",
"0.589464",
"0.589... | 0.0 | -1 |
Adds a tag into the page with the desired url or a tag with the content. | def add_style_tag(url: nil, path: nil, content: nil)
# @param url [String]
#
# @return [Promise<HTMLElement>]
#
add_style_url = <<~JAVASCRIPT
async function addStyleUrl(url) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = url;
const promise = new Promise((res, rej) => {
link.onload = res;
link.onerror = rej;
});
document.head.appendChild(link);
await promise;
return link;
}
JAVASCRIPT
# @param content [String]
#
# @return [Promise<HTMLElement>]
#
add_style_content = <<~JAVASCRIPT
async function addStyleContent(content) {
const style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(content));
const promise = new Promise((res, rej) => {
style.onload = res;
style.onerror = rej;
});
document.head.appendChild(style);
await promise;
return style;
}
JAVASCRIPT
unless url.nil?
begin
return execution_context.evaluate_handle_function(add_style_url, url).value!.as_element
rescue => _error
raise "Loading style from #{url} failed"
end
end
unless path.nil?
contents = File.read path
contents += '//# sourceURL=' + path.delete("\n")
return execution_context.evaluate_handle_function(add_style_content, contents).value!.as_element
end
unless content.nil?
return execution_context.evaluate_handle_function(add_style_content, content).value!.as_element
end
raise "Provide a `url`, `path` or `content`"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_tag\n url = Url.find_by(id: params[:id])\n tag = Tag.find_by(name: params[:tag])\n if tag\n ## TODO: handle tag with url in backend\n # if not url.tags.where(:tag_id => tag.id).any?\n # url.tags << tag\n # end\n url.tags << tag... | [
"0.6562378",
"0.64267516",
"0.62475646",
"0.6239432",
"0.6238579",
"0.6191911",
"0.6181136",
"0.6067945",
"0.60661626",
"0.6045257",
"0.6045257",
"0.6037953",
"0.6030934",
"0.6026329",
"0.60185575",
"0.5986718",
"0.5924376",
"0.592372",
"0.5912836",
"0.5912836",
"0.5912769",
... | 0.0 | -1 |
This method fetches an element with selector and focuses it. If there's no element matching selector, the method throws an error. | def focus(selector)
handle = query_selector selector
"No node found for selector: #{selector}" if handle.nil?
handle.focus
handle.dispose
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select!\n raise \"Locator at #{locator} is not visible\" unless visible?\n begin\n wd_element.click\n rescue\n raise \"Locator at #{locator} can not be interacted with\" unless visible?\n end\n check_errors\n end",
"def select!\n raise \"Locator at... | [
"0.67057604",
"0.66400516",
"0.6597134",
"0.6597134",
"0.65383637",
"0.63706785",
"0.6271941",
"0.6228774",
"0.6045374",
"0.5711961",
"0.568006",
"0.5662004",
"0.5633813",
"0.56214005",
"0.55724597",
"0.55421734",
"0.5492148",
"0.54739857",
"0.54595417",
"0.5449888",
"0.54310... | 0.7462675 | 0 |
Triggers a change and input event once all the provided options have been selected. If there's no element matching selector, the method throws an error. | def select(selector, *values)
values.each { |value| raise "Values must be strings. Found value '#{value}' of type '#{value.class}'" unless value.is_a? String }
select_values = <<~JAVASCRIPT
(element, values) => {
if (element.nodeName.toLowerCase() !== 'select')
throw new Error('Element is not a <select> element.');
const options = Array.from(element.options);
element.value = undefined;
for (const option of options) {
option.selected = values.includes(option.value);
if (option.selected && !element.multiple)
break;
}
element.dispatchEvent(new Event('input', { 'bubbles': true }));
element.dispatchEvent(new Event('change', { 'bubbles': true }));
return options.filter(option => option.selected).map(option => option.value);
}
JAVASCRIPT
query_selector_evaluate_function(selector, select_values, values).value!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def selected_changed\n return if searchable\n update_input\n trigger :change\n @input.blur unless multiple\n end",
"def selected_changed\n return if searchable\n update_input\n end",
"def select(*args, &block)\n _gestalt_call_tag(:select, args, &block)\n end",
"def... | [
"0.5454878",
"0.5300787",
"0.51445776",
"0.5014472",
"0.5013415",
"0.5001129",
"0.49698278",
"0.4951824",
"0.49396232",
"0.4923508",
"0.48932633",
"0.48751628",
"0.48133263",
"0.48100272",
"0.48018053",
"0.47727582",
"0.4759156",
"0.47244158",
"0.47163448",
"0.46808603",
"0.4... | 0.46249765 | 31 |
This method fetches an element with selector, scrolls it into view if needed, and then uses page.touchscreen to tap in the center of the element. If there's no element matching selector, the method throws an error. | def touchscreen_tap(selector)
handle = query_selector selector
raise "No node found for selector: #{selector}" if handle.nil?
handle.tap
handle.dispose
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scroll_and_touch(element, options = {})\n scroll_until_i_see(element, options)\n touch(element)\n end",
"def scroll_into_view(selector)\n el = find(selector)\n # only do this if the native element is a selenium element\n el.native.send_keys(:null) if el.native.class.to_s.split(\"::\").first =... | [
"0.6666636",
"0.6659074",
"0.66046506",
"0.6150177",
"0.6091912",
"0.60176575",
"0.60004973",
"0.59490055",
"0.5900012",
"0.5890448",
"0.5874212",
"0.58716375",
"0.5826666",
"0.5822378",
"0.58208746",
"0.5818627",
"0.58149624",
"0.5800615",
"0.57582855",
"0.5751799",
"0.57219... | 0.67288876 | 0 |
GET /paquetes GET /paquetes.xml | def index
@paquetes = Paquete.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @paquetes }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @paquete = Paquete.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @paquete }\n end\n end",
"def url\n\t\tagencia_paquete_path(self)\n\tend",
"def show\n @cavalete = Cavalete.find(params[:id])\n\n respond_to do |form... | [
"0.6419261",
"0.5860568",
"0.5766065",
"0.57640654",
"0.57264876",
"0.56885284",
"0.5685778",
"0.56707025",
"0.56707025",
"0.56422955",
"0.56301796",
"0.56099606",
"0.5608689",
"0.5606184",
"0.55851626",
"0.5571785",
"0.55622613",
"0.5543774",
"0.5540296",
"0.5491513",
"0.548... | 0.64097744 | 1 |
GET /paquetes/1 GET /paquetes/1.xml | def show
@paquete = Paquete.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @paquete }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @paquetes = Paquete.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @paquetes }\n end\n end",
"def show\n @clicker = Clicker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { rend... | [
"0.64007175",
"0.602023",
"0.5929332",
"0.58973825",
"0.5891376",
"0.5845938",
"0.58397174",
"0.58397174",
"0.5831822",
"0.58187705",
"0.5811458",
"0.5808906",
"0.5807807",
"0.5805684",
"0.5805487",
"0.5793554",
"0.57815385",
"0.57570106",
"0.5735918",
"0.5730853",
"0.5730853... | 0.6519604 | 0 |
GET /paquetes/new GET /paquetes/new.xml | def new
@paquete = Paquete.new
@orden = params[:id]
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @paquete }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @peca = Peca.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peca }\n end\n end",
"def new\n @cate... | [
"0.7089022",
"0.6923074",
"0.6792931",
"0.67672014",
"0.67100096",
"0.6709829",
"0.6696551",
"0.6696147",
"0.6696147",
"0.6673435",
"0.666804",
"0.66660714",
"0.6664202",
"0.6655539",
"0.6655539",
"0.66372865",
"0.66372865",
"0.66363996",
"0.6631379",
"0.6627802",
"0.6627802"... | 0.67013603 | 6 |
POST /paquetes POST /paquetes.xml | def create
@paquete = Paquete.new(params[:paquete])
respond_to do |format|
if @paquete.save
format.html { redirect_to(@paquete, :notice => 'Paquete was successfully created.') }
format.xml { render :xml => @paquete, :status => :created, :location => @paquete }
else
format.html { render :action => "new" }
format.xml { render :xml => @paquete.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def create\... | [
"0.55406106",
"0.5496011",
"0.5437388",
"0.53188324",
"0.5303812",
"0.52505594",
"0.52284896",
"0.52202505",
"0.52098995",
"0.5203851",
"0.5152939",
"0.51358366",
"0.5100844",
"0.50867236",
"0.507924",
"0.5078838",
"0.50661075",
"0.50578696",
"0.5049836",
"0.5040613",
"0.5032... | 0.6237619 | 0 |
PUT /paquetes/1 PUT /paquetes/1.xml | def update
@paquete = Paquete.find(params[:id])
respond_to do |format|
if @paquete.update_attributes(params[:paquete])
format.html { redirect_to(@paquete, :notice => 'Paquete was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @paquete.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def res... | [
"0.6471335",
"0.6220402",
"0.6212913",
"0.5825226",
"0.57659566",
"0.5746392",
"0.56363326",
"0.56172866",
"0.56137544",
"0.56069916",
"0.5604683",
"0.5599773",
"0.55682003",
"0.555846",
"0.5532273",
"0.545103",
"0.53865725",
"0.53727245",
"0.5369104",
"0.5339157",
"0.5338734... | 0.59593797 | 3 |
DELETE /paquetes/1 DELETE /paquetes/1.xml | def destroy
@paquete = Paquete.find(params[:id])
@paquete.destroy
respond_to do |format|
format.html { redirect_to(paquetes_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @acre = Acre.find(params[:id])\n @acre.destroy\n\n respond_to do |format|\n format.html { redirect_to(acres_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @aisl... | [
"0.7135331",
"0.6605438",
"0.65665966",
"0.6543116",
"0.6515017",
"0.6478686",
"0.64713323",
"0.6468143",
"0.6434875",
"0.6433774",
"0.6405007",
"0.64002377",
"0.639789",
"0.6393516",
"0.63865846",
"0.63790566",
"0.6369941",
"0.63674",
"0.6364069",
"0.63581955",
"0.6350041",
... | 0.70852363 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_pet
@pet = Pet.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 pet_params
params.require(:pet).permit(:category_id, :name, :price, :age, :weight, :date_of_birth, :adopted_at, :wakeup_time, :desexed, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_experience
@experience = Experience.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 experience_params
params.require(:experience).permit(:organization, :location, :position, :from, :to)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
GET /notesheets GET /notesheets.json | def index
@notesheets = Notesheet.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @notes = Note.all\n render json: @notes\n end",
"def list_notes\n notes = if unsafe_params[:editable]\n Note.editable_by(@context).where.not(title: nil).accessible_by_private\n else\n Note.accessible_by(@context).where.not(title: nil)\n end\n\n if unsafe_params[:scopes].p... | [
"0.6620252",
"0.65489125",
"0.6499742",
"0.64531994",
"0.64275813",
"0.63737583",
"0.63737583",
"0.6306056",
"0.62811774",
"0.6244164",
"0.6153337",
"0.61511666",
"0.6116539",
"0.6106703",
"0.6102543",
"0.6089911",
"0.604092",
"0.60393965",
"0.60176885",
"0.59905833",
"0.5978... | 0.75343657 | 0 |
GET /notesheets/1 GET /notesheets/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @notesheets = Notesheet.all\n end",
"def index\n @notes = Note.all\n render json: @notes\n end",
"def index\n @notes = Note.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @notes }\n end\n end",
"def show\n render json: ... | [
"0.7213959",
"0.6662136",
"0.65814406",
"0.6539396",
"0.64439654",
"0.63882273",
"0.6368453",
"0.6364772",
"0.6362344",
"0.6343219",
"0.6266902",
"0.6218674",
"0.6218674",
"0.6210735",
"0.6174881",
"0.61733425",
"0.60998106",
"0.60948205",
"0.6068242",
"0.60522306",
"0.601523... | 0.0 | -1 |
POST /notesheets POST /notesheets.json | def create
@notesheet = Notesheet.new(notesheet_params)
respond_to do |format|
if @notesheet.save
if !@notesheet.notepic.url
path = "#{@notesheet.title}-#{@notesheet.id}.txt"
File.open(path, "w+") do |f|
f.write(@notesheet.content)
@notesheet.notepic = f
end
@notesheet.save!
end
format.html { redirect_to @notesheet, notice: 'Notesheet was successfully created.' }
format.json { render :show, status: :created, location: @notesheet }
else
format.html { render :new }
format.json { render json: @notesheet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notesheet_params\n params.require(:notesheet).permit(:content, :title, :course_id, :user_id, :date_created, :notepic, :notepic_cache)\n end",
"def index\n @notesheets = Notesheet.all\n end",
"def set_notesheet\n @notesheet = Notesheet.find(params[:id])\n\n end",
"def create\n ticsh... | [
"0.666936",
"0.62605244",
"0.6200012",
"0.58830637",
"0.5775622",
"0.573048",
"0.5709784",
"0.5694335",
"0.5609547",
"0.55936563",
"0.5590921",
"0.55790657",
"0.55607307",
"0.5548598",
"0.5543869",
"0.5532662",
"0.55211306",
"0.5475616",
"0.54702806",
"0.5456696",
"0.54557216... | 0.7247544 | 0 |
PATCH/PUT /notesheets/1 PATCH/PUT /notesheets/1.json | def update
respond_to do |format|
if @notesheet.update(notesheet_params)
format.html { redirect_to @notesheet, notice: 'Notesheet was successfully updated.' }
format.json { render :show, status: :ok, location: @notesheet }
else
format.html { render :edit }
format.json { render json: @notesheet.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def update\n if @note.update(note_params)\n render json: @note\n else\n render json: @note.errors, status: :unprocessable_entity\n end\n end",
"def update\n note = Note.find(params[\"id\"])\n note.update_attributes(note_params)\n respond_wi... | [
"0.6522053",
"0.63813996",
"0.63578933",
"0.6301746",
"0.6291684",
"0.6266091",
"0.62050736",
"0.6165987",
"0.61568373",
"0.61482704",
"0.6143157",
"0.61344534",
"0.6128389",
"0.6096458",
"0.60702264",
"0.604873",
"0.60457677",
"0.60232913",
"0.6021925",
"0.6021424",
"0.60199... | 0.72586566 | 0 |
DELETE /notesheets/1 DELETE /notesheets/1.json | def destroy
@notesheet.destroy
respond_to do |format|
format.html { redirect_to notesheets_url, notice: 'Notesheet was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @weekly_note.destroy\n respond_to do |format|\n format.html { redirect_to weekly_notes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @note = Note.find(params[:id])\n @note.destroy\n\n respond_to do |format|\n format.html { redirect_to(notes_... | [
"0.7044337",
"0.69997126",
"0.69957507",
"0.6964713",
"0.6964713",
"0.6964713",
"0.6964713",
"0.69637614",
"0.6954986",
"0.6945465",
"0.6939364",
"0.6925723",
"0.69050974",
"0.68887085",
"0.68848366",
"0.6881083",
"0.6876354",
"0.6876074",
"0.6860639",
"0.68410367",
"0.682477... | 0.7807703 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_notesheet
@notesheet = Notesheet.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 notesheet_params
params.require(:notesheet).permit(:content, :title, :course_id, :user_id, :date_created, :notepic, :notepic_cache)
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 |
Set classname for concerns to set the other parameters | def set_resource_class_name
@resource_class_name = 'Cafe'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concerns(*args); end",
"def declare_concern( concern_name )\n concern concern_name do\n collection do\n get concern_name\n end\n end\n end",
"def concerns(*args)\n options = args.extract_options!\n args.flatten.each do |name|\n if concern = @concerns[nam... | [
"0.7065537",
"0.6229327",
"0.60437655",
"0.5686859",
"0.56718034",
"0.5662666",
"0.5662666",
"0.5636472",
"0.5636472",
"0.55258137",
"0.55257255",
"0.54790676",
"0.5468865",
"0.5408179",
"0.54029024",
"0.53834873",
"0.53586847",
"0.5314786",
"0.53100526",
"0.52948093",
"0.527... | 0.55633104 | 9 |
If adding new models also update filter_options_for_edition | def document_creation_dropdown
tag.ul(
class: "masthead-menu list-unstyled js-hidden js-navbar-toggle__menu hide-before-js-module-init",
id: "new-document-menu",
role: "menu",
"aria-labelledby" => "new-document-label",
) do
edition_types = [
Consultation,
Publication,
NewsArticle,
Speech,
DetailedGuide,
DocumentCollection,
FatalityNotice,
CaseStudy,
StatisticalDataSet,
CallForEvidence,
]
edition_types
.select { |edition_type| can?(:create, edition_type) }
.map { |edition_type|
tag.li(class: "masthead-menu-item") do
link_to(
edition_type.model_name.human,
polymorphic_path([:new, :admin, edition_type.name.underscore.to_sym]),
title: "Create #{edition_type.model_name.human.titleize}",
role: "menuitem",
)
end
}
.join
.html_safe
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_update\n super\n clear_instance_filters\n end",
"def add_filter\n @filter = true \n end",
"def add_edition\n @item.edition = @bib.edition.content if @bib.edition\n end",
"def update!(**args)\n @filter_options = args[:filter_options] if args.key?(:fi... | [
"0.6142707",
"0.5748352",
"0.5701453",
"0.5699751",
"0.5699751",
"0.5563118",
"0.55588156",
"0.55588156",
"0.554249",
"0.5527109",
"0.5527109",
"0.5517353",
"0.5468931",
"0.546321",
"0.5462756",
"0.54558617",
"0.54414874",
"0.5429254",
"0.5392273",
"0.5368892",
"0.5366381",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_room
@room = Room.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 room_params
params.require(:room).permit(:seats_count, :room_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_tadpole
@tadpole = Tadpole.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def tadpole_params
params.require(:tadpole).permit(:name, :color, :frog_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Import an ARD plist form | def import
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_plist(file)\n NSMutableDictionary.dictionaryWithContentsOfFile(file)\n end",
"def load_plist(bundle, path)\n data = bundle.storage.open(path, &:read)\n plist = CFPropertyList::List.new(data: data)\n CFPropertyList.native_types(plist.value)\n end",
"def import(libfile, lib... | [
"0.5882623",
"0.5781075",
"0.5724537",
"0.5577608",
"0.54625356",
"0.5457406",
"0.5362554",
"0.5349211",
"0.53478014",
"0.53280187",
"0.5304876",
"0.52994376",
"0.52994376",
"0.52613354",
"0.5257199",
"0.52511007",
"0.52511007",
"0.52426434",
"0.52337337",
"0.51598406",
"0.50... | 0.500104 | 30 |
Take ARD plist and create new computer objects TODO when a computer object import fails, tell the user what went wrong (by print the computer.errors hash) | def create_import
begin
@computers = ComputerService.import(params[:computer],current_unit)
rescue NoMethodError
e = "Please select a plist file"
rescue => e
end
unless @computers.nil?
@total = @computers.count
# Save each computer. If it doesn't save, leave it out of the array
@computers = @computers.collect {|e| e if e.save}.compact
end
respond_to do |format|
if @computers.nil?
flash[:error] = "There was a problem while parsing the plist: #{e}"
format.html { redirect_to import_new_computer_path(current_unit) }
elsif @computers.count > 0
flash[:notice] = "#{@computers.count} of #{@total} computers imported into #{@computers.first.computer_group}"
format.html { redirect_to computers_path(current_unit) }
else
flash[:warning] = "Zero computers were imported. Did the ARD list have any members?"
format.html { redirect_to computers_path(current_unit) }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_import\n begin\n @computers = ComputerService.import(params[:computer],current_unit)\n rescue NoMethodError\n end\n \n unless @computers.nil?\n @total = @computers.count\n # Save each computer. If it doesn't save, leave it out of the array\n @computers = @computers.... | [
"0.6408239",
"0.5724597",
"0.5448583",
"0.52582735",
"0.5172279",
"0.5143568",
"0.5139678",
"0.5074955",
"0.5073008",
"0.50712794",
"0.505662",
"0.49813265",
"0.49479967",
"0.49197778",
"0.4910568",
"0.49104005",
"0.49060348",
"0.49002755",
"0.48919582",
"0.48673034",
"0.4859... | 0.6494538 | 0 |
Allows a computer to checkin with the server, notifying it of the last successful munki run. May be extended in the future. | def checkin
@computer = Computer.find_for_show(nil, params[:id])
if params[:managed_install_report_plist].present?
report_hash = ManagedInstallReport.format_report_plist(params[:managed_install_report_plist]).merge({:ip => request.remote_ip})
@computer.managed_install_reports.build(report_hash)
end
if params[:system_profiler_plist].present?
system_profile_hash = SystemProfile.format_system_profiler_plist(params[:system_profiler_plist])
sp = SystemProfile.find_or_create_by_computer_id(@computer.id)
@computer.system_profile.attributes = system_profile_hash
end
@computer.save
@computer.warranty.destroy if @computer.serial_number != @computer.warranty.serial_number
AdminMailer.computer_report(@computer).deliver if @computer.report_due?
render :text => ''
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_in!\n ensure_can_check_in!\n self.update(status: :complete)\n end",
"def checkin\n end",
"def notify_users_and_add_it\n return # disabled for now\n return true if remote?\n User.find_all_by_notify_on_new_torrents(true).each do |user|\n Notifier.send_new(user,self) if user.notifi... | [
"0.5600158",
"0.55769444",
"0.54527855",
"0.5397629",
"0.5348797",
"0.52700305",
"0.5237163",
"0.5236375",
"0.5225316",
"0.51849437",
"0.5169335",
"0.51355827",
"0.5133926",
"0.51307064",
"0.51232654",
"0.51170665",
"0.51157415",
"0.510627",
"0.5102861",
"0.50992143",
"0.5064... | 0.62869346 | 0 |
Highlight some text with a given lexer and formatter. | def highlight(text, lexer, formatter, &b)
lexer = Lexer.find(lexer) unless lexer.respond_to? :lex
raise "unknown lexer #{lexer}" unless lexer
# XXX: maybe opal bug, `string.respond_to? :format` returns true in Opal.
# formatter = Formatter.find(formatter) unless formatter.respond_to? :format
formatter = Formatter.find(formatter)
raise "unknown formatter #{formatter}" unless formatter
formatter.format(lexer.lex(text), &b)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highlight(text, lexer, formatter, &b)\n lexer = Lexer.find(lexer) unless lexer.respond_to? :lex\n raise \"unknown lexer #{lexer}\" unless lexer\n\n formatter = Formatter.find(formatter) unless formatter.respond_to? :format\n raise \"unknown formatter #{formatter}\" unless formatter\n\n ... | [
"0.87901795",
"0.87890375",
"0.69050014",
"0.6761689",
"0.6756509",
"0.67013115",
"0.64033103",
"0.63785017",
"0.63533205",
"0.63533205",
"0.62713426",
"0.62316215",
"0.6202541",
"0.61890465",
"0.61890465",
"0.61890465",
"0.6174313",
"0.61204726",
"0.608457",
"0.5998763",
"0.... | 0.8647969 | 2 |
If value is contained in the buffer, it's value is set to 1 and true is returned, otherwise false | def try_touch(value)
result = contains? value
touch(value) if result
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(buffer); end",
"def [](position)\n (@field.getbyte(position >> 3) & (1 << (byte_position(position) % 8))) > 0 ? 1 : 0\n end",
"def value?(p0) end",
"def include?(flag)\n return ( @val & flag ) == flag\n end",
"def one_bit?\n identify.include?('1-bit')\n end",
"def alto?\n ... | [
"0.6590713",
"0.61349434",
"0.60505456",
"0.604489",
"0.600284",
"0.59591985",
"0.5930614",
"0.59196687",
"0.59119946",
"0.58338946",
"0.5817258",
"0.58005154",
"0.5791882",
"0.57834876",
"0.578149",
"0.5776193",
"0.5769432",
"0.5760731",
"0.57509124",
"0.5714549",
"0.5697207... | 0.0 | -1 |
If buffer slots are free, inserts value and returns true. | def try_insert_new(value)
return false if used == @size
entry = GClockBufferEntry.new(value, 1)
@buffer[@pointer] = entry
advance_pointer
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_last(value)\n if @queue.size < @size\n @queue.push(value)\n true\n else\n false\n end\n end",
"def add(value)\n found = true\n @values.delete(value) { found = false }\n @values[value] = true\n @values.shift if @values.length > @capacity\n found\n en... | [
"0.67836845",
"0.6649894",
"0.66428876",
"0.6640979",
"0.6544269",
"0.64828765",
"0.6445525",
"0.63733226",
"0.63253295",
"0.6085846",
"0.6000582",
"0.60005736",
"0.59499645",
"0.59248406",
"0.5897573",
"0.588062",
"0.58699095",
"0.5834886",
"0.57715684",
"0.5754918",
"0.5744... | 0.7857396 | 0 |
Initial property of an search_result | def initialize
self.description_map = Hash.new
self.found_items = []
self.closest_string = ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result\n return @result if defined?(@result)\n @search.populate_hits\n @result\n end",
"def initialize\n @result = result\n end",
"def set_result\n @result = Result.new\n end",
"def initialize(original_result); end",
"def set_search_result\n @search_result... | [
"0.61961645",
"0.61514485",
"0.6139942",
"0.6127339",
"0.6114387",
"0.6085309",
"0.60539526",
"0.59656245",
"0.5879024",
"0.5862086",
"0.5839043",
"0.58037156",
"0.58000684",
"0.58000684",
"0.58000684",
"0.5782447",
"0.5757625",
"0.57280385",
"0.5625291",
"0.562232",
"0.56201... | 0.0 | -1 |
Does the searching A search_result object will only provide results after calling this method The results depend of the given items, the search will return all matching items even if they are deactivated or belong to any current user. If you want to exclude some type of items you can exclude these items from the parameter 'items' or you can do it in the result 'found_items' | def find(items)
query_array = query.gsub(/_/," ").downcase.split
results = []
items.each{ |item|
match_all = true
query_array.each{ |query|
description = item.description.gsub("/,/","~")
if !item.name.gsub(/_/," ").downcase.include?(query) and !description.gsub(/_/," ").downcase.include?(query)
match_all = false
else
if description.gsub(/_/," ").downcase.include?(query)
self.description_map[item] = map_description_part(description, query)
else
self.description_map[item] = if item.description.size>=30 then item.description[0..27] + "..." else item.description end
end
end
}
if match_all
results.push(item)
end
}
self.found_items = results
if self.found_items.size == 0 and self.query.size >= 2
suggest_other_query(items, query)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_filter(search_term)\n @items = @items.where('client_name like ? OR client_ssn like ? OR case_id like ?', \"%#{search_term}%\", \"%#{search_term}%\", \"%#{search_term}%\")\n @old_items = @items.where('client_name like ? OR client_ssn like ? OR case_id like ?', \"%#{search_term}%\", \"%#{search_term... | [
"0.6554827",
"0.64927036",
"0.6492338",
"0.64481986",
"0.6393711",
"0.6393492",
"0.6367485",
"0.634915",
"0.6283476",
"0.627187",
"0.62682915",
"0.626485",
"0.62618065",
"0.62496674",
"0.6240863",
"0.6226537",
"0.6199801",
"0.618885",
"0.61831754",
"0.6152757",
"0.6131985",
... | 0.60895646 | 23 |
Selects the parts of description where query mathches to the items description | def map_description_part(description, query)
start_of_find = description.gsub(/_/, " ").downcase.index(query)
substring_start = if start_of_find - 17 < 0 then 0 else start_of_find - 17 end
substring_end = if start_of_find + 20 > description.size then description.size else start_of_find + 20 end
matching_description = description[substring_start..substring_end].gsub("/~/", ",")
if substring_end != description.size
matching_description << "..."
end
if substring_start != 0
matching_description = "..." + matching_description
end
matching_description
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def items_with_description(expected_description)\n filter = ObjectFilter.new { |filter| filter.accept(\"items.description\").when_it is(expected_description) }\n items_data = self.service.object_filter(filter).getItems()\n\n items_data.collect do |item_data|\n first_price = item_data['prices'... | [
"0.63168526",
"0.61614364",
"0.6091587",
"0.6067165",
"0.597548",
"0.5955041",
"0.59208214",
"0.58952385",
"0.58118385",
"0.57744914",
"0.57262135",
"0.5726114",
"0.5712092",
"0.5658058",
"0.56184465",
"0.56152254",
"0.55138016",
"0.54820466",
"0.54717505",
"0.54685795",
"0.5... | 0.62491643 | 1 |
Trys to find a similar query that would be successful | def suggest_other_query(items, query)
query = query.gsub(/_/," ").downcase
distance_levenshtein = 100
longest_subseq = 0
word = ""
matcher1 = Amatch::Levenshtein.new(query)
matcher2 = Amatch::LongestSubsequence.new(query)
items.each{ |item|
name_array = item.name.downcase.split
name_array.push(item.name.downcase)
new_distance_array_levenshtein = matcher1.match(name_array).sort
new_longest_subseq_array = matcher2.match(name_array).sort.reverse
if new_distance_array_levenshtein[0] < distance_levenshtein and new_longest_subseq_array[0] >= longest_subseq
word = item.name
distance_levenshtein = new_distance_array_levenshtein[0]
longest_subseq = new_longest_subseq_array[0]
end
}
if distance_levenshtein <= 3 and longest_subseq >=2
self.closest_string = word
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_query(query); end",
"def check_query\n self.query\n end",
"def find(query); end",
"def find(query); end",
"def query?\n !qr?\n end",
"def query_yields_solutions?\n true\n end",
"def unanswered_questions; questions_not_matching_query(answered_questions_query); end",
"def ... | [
"0.6518441",
"0.63046646",
"0.6034589",
"0.6034589",
"0.59890544",
"0.59427756",
"0.5879576",
"0.5816271",
"0.58057654",
"0.58047086",
"0.5777494",
"0.5738967",
"0.5725157",
"0.57235134",
"0.57147706",
"0.56446826",
"0.56415296",
"0.5634597",
"0.5598895",
"0.5594684",
"0.5590... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_job
@job = Job.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.6163821",
"0.6045432",
"0.5945441",
"0.5916224",
"0.58894575",
"0.5834073",
"0.57764685",
"0.5702474",
"0.5702474",
"0.5653258",
"0.56211996",
"0.54235053",
"0.5410683",
"0.5410683",
"0.5410683",
"0.53948104",
"0.5378064",
"0.5356684",
"0.53400385",
"0.53399503",
"0.533122... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def job_params
params.require(:job).permit(
:id, :title, :description, :deadline, :job_type, :event,
:salary_type, :salary_value, :salary_high, :salary_low, :salary_unit,
:position, :attachment_url, :employment_types, :periods,
:default_location, :has_bonus, :bonus_value, :photo, :job_tags_attributes => [:id, :tag_id, :_destroy]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
MIDI data must be encoded in 7bit bytes (most significat bit is used to mark STATUS bytes) Korg Monologue encodes data in 7byte chunks | def midi_encoder(bytes)
raise "Invalid data length #{bytes.size}" unless bytes.size % 7 == 0
result = []
(0...bytes.size).step(7).each do |start|
chunk = bytes[start, 7]
msbits = 0
chunk.each_with_index do |b, i|
msbits |= (b & 0x80) >> (7 - i)
end
result << msbits
result += chunk.map{|b| b & 0x7F}
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_program_midi_data(data)\n valid = data[0] == 0xF0 &&\n data[1] == 0x42 &&\n (data[2] & 0xF0 == 0x30) &&\n data[3] == 0x00 &&\n data[4] == 0x01 &&\n data[5] == 0x44 &&\n (data[6] == 0x4C || data[6] == 0x40) &&\n data[-1] == 0xF7\n if data[6] == 0x40\n # current program\n program... | [
"0.60295254",
"0.5705238",
"0.56088686",
"0.55482477",
"0.5426472",
"0.53987956",
"0.5362406",
"0.53152245",
"0.52974725",
"0.52758926",
"0.527021",
"0.52352166",
"0.5210215",
"0.5181947",
"0.5166361",
"0.5153549",
"0.51393884",
"0.51069003",
"0.51068693",
"0.51049584",
"0.50... | 0.6903426 | 0 |
Extract program data dump from midi message | def get_program_midi_data(data)
valid = data[0] == 0xF0 &&
data[1] == 0x42 &&
(data[2] & 0xF0 == 0x30) &&
data[3] == 0x00 &&
data[4] == 0x01 &&
data[5] == 0x44 &&
(data[6] == 0x4C || data[6] == 0x40) &&
data[-1] == 0xF7
if data[6] == 0x40
# current program
program = nil
start = 7
else
program = data[7]
start = 9
end
prog = data[start...-1]
raise "Invalid program" unless valid && prog.size == 512
from_bytes midi_decoder prog
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_program(prog)\n prog_bytes = to_bytes(prog)\n data = {}\n raise \"Invalid program\" unless prog[0, 4] == 'PROG'\n name = prog[4...16]\n data[:name] = program_name(prog)\n\n HR_PARAMS.each do |(key, ms_offset, ls_offset, ls_pos, units)|\n # single byte value\n value = prog_bytes[ms_offset]\n ... | [
"0.59759104",
"0.5656735",
"0.5452958",
"0.54080665",
"0.5392941",
"0.5352338",
"0.534459",
"0.52830565",
"0.5281976",
"0.52596194",
"0.5255477",
"0.5234659",
"0.5183154",
"0.51806927",
"0.5153215",
"0.5141619",
"0.5120715",
"0.5103102",
"0.5092581",
"0.5081025",
"0.5057778",... | 0.75217336 | 0 |
Extract program data dump from binary file (like the .prog_bin files that are part of .molglib/.molgpreset packs) | def get_program_file_data(program_file)
File.open(program_file,'rb'){|f| f.read}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_program(prog)\n prog_bytes = to_bytes(prog)\n data = {}\n raise \"Invalid program\" unless prog[0, 4] == 'PROG'\n name = prog[4...16]\n data[:name] = program_name(prog)\n\n HR_PARAMS.each do |(key, ms_offset, ls_offset, ls_pos, units)|\n # single byte value\n value = prog_bytes[ms_offset]\n ... | [
"0.6155024",
"0.61215544",
"0.59901685",
"0.5961997",
"0.5759024",
"0.57084185",
"0.56159574",
"0.5578849",
"0.5517678",
"0.54004574",
"0.5392215",
"0.5186379",
"0.5178744",
"0.5102294",
"0.5095169",
"0.50811595",
"0.50398755",
"0.49912056",
"0.49874336",
"0.49376357",
"0.490... | 0.6198225 | 0 |
Extract program name from program data dump | def program_name(prog)
name = prog[4...16]
while name.chomp!("\0")
end
name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def program_name\n File.basename($0)\n end",
"def program_name\n @program_name || File.basename($0, '.*')\n end",
"def app_name\n @data['CFBundleExecutable'].to_s\n end",
"def proc_name\n data = read_cpuinfo.match(/model name\\s*:\\s*(.+)/)[1]\n\n return data.strip\n end"... | [
"0.7339312",
"0.7284858",
"0.6688965",
"0.66580594",
"0.65611017",
"0.65355164",
"0.61558723",
"0.6115902",
"0.6110555",
"0.61011547",
"0.6089367",
"0.6089367",
"0.6089367",
"0.6019577",
"0.598158",
"0.5950097",
"0.5940333",
"0.59152186",
"0.59048283",
"0.58988595",
"0.5789",... | 0.6573369 | 4 |
Parse program data dump | def parse_program(prog)
prog_bytes = to_bytes(prog)
data = {}
raise "Invalid program" unless prog[0, 4] == 'PROG'
name = prog[4...16]
data[:name] = program_name(prog)
HR_PARAMS.each do |(key, ms_offset, ls_offset, ls_pos, units)|
# single byte value
value = prog_bytes[ms_offset]
data[key] = value
# high resolution value
value_hr = (value << 2) | ((prog_bytes[ls_offset] >> ls_pos) & 0x03)
data[:"#{key}_hr"] = value_hr
if units
# converted value:
data[:"#{key}_#{units}"] = CONVERTERS[units][value_hr]
end
end
CONV_PARAMS.each do |(key, offset, bit_pos, bit_len, units)|
value = bits(prog_bytes[offset], bit_pos, bit_len)
data[key] = CONVERTERS[units][value]
if value != data[key]
data[:"#{key}_value"] = value
end
end
data[:seq_notes] = (96..426).step(22).map{|offset| note_name prog_bytes[offset]}
(data[:step_length]...data[:seq_notes].size).each do |i|
data[:seq_notes][i] = ''
end
# puts data[:seq_notes].join(' ')
data[:lfo_rate_vis] = data[:lfo_bpm_sync] == 'ON' ? data[:lfo_rate_bpm] : data[:lfo_rate_hr]
data[:eg_int_abs] = data[:eg_int_signed].abs
data[:lfo_int_abs] = data[:lfo_int_signed].abs
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_program_midi_data(data)\n valid = data[0] == 0xF0 &&\n data[1] == 0x42 &&\n (data[2] & 0xF0 == 0x30) &&\n data[3] == 0x00 &&\n data[4] == 0x01 &&\n data[5] == 0x44 &&\n (data[6] == 0x4C || data[6] == 0x40) &&\n data[-1] == 0xF7\n if data[6] == 0x40\n # current program\n program... | [
"0.61019415",
"0.581704",
"0.58068043",
"0.5750443",
"0.56978065",
"0.5506315",
"0.548784",
"0.54501534",
"0.5434926",
"0.5398954",
"0.5338516",
"0.5315678",
"0.52658504",
"0.5259087",
"0.5259087",
"0.5207675",
"0.5193938",
"0.51726544",
"0.51682174",
"0.51467574",
"0.5143361... | 0.6969858 | 0 |
home page default ads management | def index
@home_page = DefaultAd.find(1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home\n error_404 unless (@page = Page.where(:link_url => '/').first).present?\n @banners = Banner.order('position ASC')\n #@banners = defined?(Banner).blank? ? [] : Banner.all\n end",
"def index\n @ad_banners = AdBanner.all\n @pages = Page.all\n end",
"def index\n \tset_user\n @ads = ... | [
"0.6816975",
"0.6763372",
"0.6579762",
"0.64423555",
"0.63973284",
"0.630541",
"0.62575495",
"0.6228657",
"0.61972076",
"0.61972076",
"0.61972076",
"0.61972076",
"0.61972076",
"0.6191948",
"0.618928",
"0.61436754",
"0.610948",
"0.60918",
"0.6087822",
"0.60848874",
"0.60753614... | 0.7642998 | 0 |
stories page default page ads managment | def stories_page
@stories_page = DefaultAd.find(2)
@stories_page_left_top = DefaultAd.find(3)
@stories_page_left_bottom = DefaultAd.find(4)
@stories_page_right = DefaultAd.find(5)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @home_page = DefaultAd.find(1) \nend",
"def index\n @ad_banners = AdBanner.all\n @pages = Page.all\n end",
"def index\n @story_pages = StoryPage.all\n end",
"def pages; end",
"def index\n @slider_ads = SliderAd.order(id: :desc).page(params[:page]).per(25)\n end",
"def pla... | [
"0.66294193",
"0.62805545",
"0.6124563",
"0.60792094",
"0.60645753",
"0.6016941",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.6002153",
"0.5988614",
"0.5985813",
"0.5944787",... | 0.6842739 | 0 |
~ def index ~ page = params[:page].blank? ? 1 : params[:page] ~ sort = case params['sort'] ~ when "sponser_name" then "sponser_name" ~ when "created_at" then "created_at" ~ when "title" then "title" ~ when "position" then "parient_id" ~ when "sponser_name_reverse" then "sponser_name DESC" ~ when "created_at_reverse" then "created_at DESC" ~ when "title_reverse" then "title DESC" ~ when "position_reverse" then "parient_id DESC" ~ end ~ sort = sort.blank? ? "created_at DESC" : sort ~ if !params[:search].blank? ~ condition = ["title like ? or sponser_name like ?", "%"+params[:search]+"%","%"+params[:search]+"%"] ~ else ~ condition = "" ~ end | def stories_header
@story = Story.find_by_id(params[:story_id],:select => "id,title")
@adver_id = params[:id]
sort = case params['sort']
when "sponser_name" then "sponser_name"
when "created_at" then "created_at"
when "status" then "status"
when "sponser_name_reverse" then "sponser_name DESC"
when "created_at_reverse" then "created_at DESC"
when "status_reverse" then "status DESC"
end
page = params[:page].blank? ? 1 : params[:page]
if !params[:search].blank?
condition = [ "sponser_name like ? and parient_id LIKE ?", "%"+params[:search]+"%",params[:id]]
else
condition = [ "parient_id LIKE ?", params[:id]]
end
@adv = Advertisement.paginate :per_page=>5, :page=>page,:conditions => condition,:order => sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\n filter = \"\"\n #Параметры быстрой фильтрации грида\n filter = get_qsearch_condition(filter,params[:search])\n #Параметры фильтрации грида\n if not (params[:filter].nil? or params[:filter].empty?) then\n filter = get_string_condition(filter,'name_f',params[:filter])\n filter ... | [
"0.78921735",
"0.76565874",
"0.7613753",
"0.75392514",
"0.7531622",
"0.745609",
"0.745091",
"0.73973113",
"0.7369869",
"0.73608994",
"0.73571634",
"0.7345369",
"0.7328837",
"0.7310315",
"0.7306687",
"0.7290449",
"0.7284465",
"0.72500384",
"0.7230329",
"0.72302294",
"0.7222449... | 0.715414 | 28 |
Valida que uns cadena enviado y una clave encriptada sean iguales cuando la cadena se encripta | def clave_valida?(cadena, clave)
# la clave recibida debería ser una instancia de bcrypt, por lo tanto
# implementa la comparación con ==
clave == cadena
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n encrypt\n end",
"def esClaveValida(clave)\n\tcadena_clave = clave.to_s\n\tmedio_clave = (cadena_clave[1]).to_i + (cadena_clave[2].to_i)\n\treturn medio_clave.even?\nend",
"def debe_ser_encarcelado\n if is_encarcelado\n return false\n else\n if !tiene_salvoconducto... | [
"0.6590535",
"0.6400664",
"0.61028624",
"0.5937549",
"0.59350425",
"0.5879187",
"0.5879187",
"0.57978594",
"0.5719973",
"0.5634549",
"0.56228495",
"0.5614995",
"0.5584627",
"0.5576075",
"0.5543845",
"0.5482864",
"0.547931",
"0.5472266",
"0.5456521",
"0.54185504",
"0.5412478",... | 0.69328207 | 0 |
upload a file without multipart local_file is the full absolute local filename destination should be the full remote file path, including the file name. | def upload_file(deployment_id, id, local_file, destination, params={})
if destination.empty? || destination == "/" || destination == "." || destination.include?("../")
raise "#{self.class}.upload_file() passed a bad destination: '#{destination}'"
end
# url = "#{@base_url}/#{base_path}/#{deployment_id}/versions/#{id}/files"
url = "#{base_path}/#{deployment_id}/versions/#{id}/files"
if !destination.to_s.empty?
url += "/#{destination}"
end
# use URI to escape path
uri = URI.parse(url)
url = uri.path
# params[:filename] = File.basename(destination)
if !local_file.kind_of?(File)
local_file = File.new(local_file, 'rb')
end
payload = local_file
headers = {'Content-Type' => 'application/octet-stream'}
headers['Content-Length'] = local_file.size # File.size(local_file)
execute(method: :post, url: url, headers: headers, payload: payload, params: params, timeout: 172800)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file(remote, local)\n write_file(remote, ::File.read(local))\n end",
"def upload!(local, remote, options = {}) # rubocop:disable Lint/UnusedMethodArgument\n end",
"def upload(local, remote = nil, opts={})\n remote ||= File.split(local).last\n remote = expand_path remote\n ssh.scp.u... | [
"0.83072245",
"0.77938145",
"0.77821726",
"0.76384795",
"0.76349217",
"0.7625202",
"0.74343544",
"0.7399754",
"0.7391588",
"0.7334839",
"0.7229629",
"0.72247857",
"0.7113984",
"0.7024774",
"0.70141464",
"0.6963329",
"0.6943939",
"0.6902225",
"0.6842788",
"0.674238",
"0.673101... | 0.75752836 | 6 |
upload a file without multipart local_file is the full absolute local filename destination should be the full remote file path, including the file name. | def destroy_file(deployment_id, id, destination, params={})
if destination.empty? || destination == "/" || destination == "." || destination.include?("../")
raise "#{self.class}.upload_file() passed a bad destination: '#{destination}'"
end
# url = "#{@base_url}/#{base_path}/#{deployment_id}/versions/#{id}/files"
url = "#{base_path}/#{deployment_id}/versions/#{id}/files"
if !destination.to_s.empty?
url += "/#{destination}"
end
# use URI to escape path
uri = URI.parse(url)
url = uri.path
execute(method: :delete, url: url, params: params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file(remote, local)\n write_file(remote, ::File.read(local))\n end",
"def upload!(local, remote, options = {}) # rubocop:disable Lint/UnusedMethodArgument\n end",
"def upload(local, remote = nil, opts={})\n remote ||= File.split(local).last\n remote = expand_path remote\n ssh.scp.u... | [
"0.83079976",
"0.77929074",
"0.77830356",
"0.7639388",
"0.76355326",
"0.7625878",
"0.75765216",
"0.7434657",
"0.73996556",
"0.73916835",
"0.7336373",
"0.7229966",
"0.7224018",
"0.71131295",
"0.7026892",
"0.7015228",
"0.6964005",
"0.69442505",
"0.69015735",
"0.68424445",
"0.67... | 0.0 | -1 |
Public: Initialize a Crocodoc api object opts A hash of options with which to initialize the object :token The api token to use to authenticate requests. Required. Examples crocodoc = Crocodoc::API.new(:token => ) => > | def initialize(opts)
self.token = opts[:token]
# setup the http object for ssl
@url = URI.parse(BASE_URL)
@http = Net::HTTP.new(@url.host, @url.port)
@http.use_ssl = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(opts=nil, doc=nil)\n super(opts, doc)\n require_opts :api_key, :api_base_url\n default_opts(:ssl_verify => true, :enable_gzip => true)\n end",
"def initialize(opts)\n if opts[:api_key].nil?\n raise ArgumentError, \"Required option missing. Please pass ':api_key'.\"\n e... | [
"0.7425202",
"0.68720186",
"0.6477755",
"0.64583945",
"0.6447252",
"0.63978803",
"0.634511",
"0.6314314",
"0.61362076",
"0.61342704",
"0.61306655",
"0.6129192",
"0.60981524",
"0.60837555",
"0.60818267",
"0.60563415",
"0.6048341",
"0.6038443",
"0.6025142",
"0.60239226",
"0.602... | 0.5960988 | 24 |
Public: Delete a document. POST uuid a single uuid to delete Examples delete("7cf917de22464ac3adab791a49454180") => true Returns true if the delete was successful | def delete(uuid)
raw_body = api_call(:post, "document/delete", { :uuid => uuid })
raw_body == "true"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(opts = {})\n response = Crocodoc.connection.post 'document/delete', :uuid => @uuid\n response.body.chomp.downcase == 'true'\n end",
"def delete\n @client.delete_document(@path)\n end",
"def remove_document_by_uuid(uuid)\n @documents.delete(uuid)\n end",
"def de... | [
"0.8003158",
"0.7327317",
"0.7097672",
"0.6696224",
"0.6694576",
"0.6627026",
"0.6558195",
"0.6547385",
"0.65295273",
"0.6516332",
"0.6512793",
"0.6511275",
"0.6491366",
"0.6468646",
"0.6451002",
"0.642768",
"0.6426247",
"0.642034",
"0.64196974",
"0.6400854",
"0.6368546",
"... | 0.8553729 | 0 |
Public: Get the url for the viewer for a session. session The uuid of the session (see session) Examples view("CFAmd3Qjm_2ehBI7HyndnXKsDrQXJ7jHCuzcRv_V4FAgbSmaBkF") => Returns a url string for viewing the session | def view(session_id)
"https://crocodoc.com/view/#{session_id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_viewing_url(session)\n \"https://crocodoc.com/view/#{session.key}\"\n end",
"def viewer\n authorize @session\n end",
"def get_viewer_link(urn,access_token)\n #absolute url = request.base_url\n url = \"/viewer1.html?token=#{access_token}&urn=#{urn}\"\n link = \"<a href=\\\"#{url}\\\... | [
"0.7522495",
"0.6145662",
"0.59553003",
"0.59191215",
"0.5768783",
"0.5741065",
"0.5604294",
"0.55353403",
"0.54902905",
"0.5478923",
"0.54365796",
"0.5401586",
"0.5388175",
"0.536817",
"0.53624254",
"0.530224",
"0.529813",
"0.5292428",
"0.5257301",
"0.5239954",
"0.5227571",
... | 0.7154142 | 1 |
API Glue Internal: make api_call, stream the response.body to a Tempfile see api_call for parameters Returns the Tempfile | def download_file(method, endpoint, params={})
params.merge!({ :token => self.token })
request = self.send("format_#{method}", "#{@url.path}/#{endpoint}", params)
file = Tempfile.new("crocodoc-download-#{params[:uuid]}")
# use streaming to keep memory usage sane
@http.request(request) do |response|
response.read_body {|chunk| file.write chunk }
end
file.close
file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call_api(http_method, path, opts = {})\n request = build_request(http_method, path, opts)\n attempt = 0\n loop do\n if opts[:stream_body]\n tempfile = nil\n encoding = nil\n\n response = request.perform do | chunk |\n unless tempfile\n co... | [
"0.67598665",
"0.60282916",
"0.59277385",
"0.5921887",
"0.5681845",
"0.5647022",
"0.5621172",
"0.5597098",
"0.55349404",
"0.5495097",
"0.5483887",
"0.5456928",
"0.54420626",
"0.54302967",
"0.5422362",
"0.54071105",
"0.5402083",
"0.53755784",
"0.5370233",
"0.5366782",
"0.53586... | 0.5343957 | 22 |
Binds callback on a net transition | def on(transition_identifier, &block)
raise ArgumentError, 'No block given' unless block
@execution_callbacks[transition_by_identifier!(transition_identifier)] = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_transition(*args, &block); end",
"def transition(&block)\n @transition_function = block\n end",
"def communicate_transition(_ = nil, _ = nil); end",
"def transitions; end",
"def callback(name)\n transition.send(\"do_#{name}\") || \"#{name}_#{previous}_to_#{current}\"\n end",
"de... | [
"0.7284752",
"0.6683871",
"0.64494836",
"0.6408935",
"0.63705444",
"0.6321475",
"0.6295704",
"0.62897205",
"0.6271549",
"0.622259",
"0.605585",
"0.59906477",
"0.597833",
"0.597833",
"0.59150565",
"0.5865437",
"0.58449554",
"0.58449554",
"0.5788951",
"0.57620686",
"0.5679535",... | 0.0 | -1 |
Binds producing callback on a net transition | def produce(transition_identifier, &block)
raise ArgumentError, 'No block given' unless block
@production_callbacks[transition_by_identifier!(transition_identifier)] = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_transition(*args, &block); end",
"def transition(&block)\n @transition_function = block\n end",
"def callback\n\n end",
"def callback\n end",
"def communicate_transition(_ = nil, _ = nil); end",
"def callbacks; end",
"def callbacks; end",
"def callback=(_arg0); end",
"def transiti... | [
"0.70252395",
"0.6532883",
"0.6521935",
"0.6481402",
"0.6377995",
"0.63317347",
"0.63317347",
"0.62993777",
"0.6296244",
"0.6258931",
"0.6234788",
"0.62274295",
"0.6160906",
"0.61542016",
"0.6040022",
"0.602157",
"0.5934154",
"0.5853432",
"0.57377404",
"0.573668",
"0.56167865... | 0.0 | -1 |
Puts tokens in start places Executes automated actions if any enabled Fills out weights for futher usage | def init
return if @initialized
# Fill start places with tokens to let the process start
put_token(start_place)
start_place[:enabled] = true
# Terminators are used to identify which transitions can be executed
@terminators = {}
@net.places.select(&:start?).each do |start_place|
outgoing_transitions(start_place).each do |transition|
(@terminators[transition] ||= []) << start_place
end
end
# Without weights assigned transition execution path search won't work
PetriTester::DistanceWeightIndexator.new(@net).reindex
@initialized = true
execute_automated!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_actions; end",
"def start\n @actions << :start\n end",
"def start\n assign_globals\n register_space\n start_message\n build_actions\n start_threads\n end",
"def start_run; end",
"def execute start\n # TODO: erase attributes once they're no longer n... | [
"0.58902663",
"0.5705497",
"0.56762755",
"0.55847746",
"0.5543325",
"0.5517922",
"0.5474361",
"0.54603976",
"0.54177123",
"0.5377966",
"0.53721416",
"0.5320664",
"0.5300634",
"0.529117",
"0.5249527",
"0.5214216",
"0.5211444",
"0.5198405",
"0.5194378",
"0.5190566",
"0.5190566"... | 0.5814666 | 1 |
Runs all automated transitions which are enabled at the moment | def execute_automated!(source: nil, params: {}, color: {})
@net.transitions.each do |transition|
if transition.automated? &&
source != transition &&
transition_enabled?(transition, color: color)
perform_action!(transition, params: params, color: color)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_transition\r\n # Execute transition\r\n if $data_system.battle_transition == \"\"\r\n Graphics.transition(20)\r\n else\r\n Graphics.transition(40, \"Graphics/Transitions/\" +\r\n $data_system.battle_transition)\r\n end\r\n # Start pre-battle phase\r\n start_phase1\r\n e... | [
"0.68035895",
"0.6741294",
"0.6566988",
"0.64490163",
"0.6074535",
"0.60683733",
"0.602775",
"0.6026691",
"0.59877396",
"0.59870976",
"0.59158295",
"0.5884009",
"0.58793586",
"0.5784965",
"0.5781985",
"0.5753808",
"0.5749438",
"0.5726816",
"0.5699352",
"0.56908995",
"0.569089... | 0.6785611 | 1 |
Fires transition if enabled, executes binded block | def perform_action(transition, params: {}, color: {})
if transition_enabled?(transition, color: color)
perform_action!(transition, params: params, color: color)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transition(&block)\n @transition_function = block\n end",
"def after_transition(*args, &block); end",
"def transition(&block)\n @d = block\n end",
"def do_transition!( transition )\n state.trigger( transition.to_sym )\n self.save\n end",
"def run(record, bang)\n from_state = rec... | [
"0.6767427",
"0.671598",
"0.664063",
"0.6394363",
"0.61014885",
"0.5858722",
"0.5777584",
"0.57334495",
"0.57166046",
"0.5662541",
"0.5615178",
"0.56069005",
"0.5574778",
"0.55693823",
"0.5527613",
"0.54980886",
"0.54980886",
"0.54751515",
"0.54633814",
"0.5441095",
"0.543452... | 0.0 | -1 |
Fires transition, executes binded block | def perform_action!(transition, params: {}, color: {})
Action.new(self, transition, params: params, color: color).perform!.tap do
execute_automated!(source: transition, params: params, color: color)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_transition(*args, &block); end",
"def transition(&block)\n @transition_function = block\n end",
"def transition(&block)\n @d = block\n end",
"def do_transition!( transition )\n state.trigger( transition.to_sym )\n self.save\n end",
"def fire!(record)\n run(record, true) || r... | [
"0.74840677",
"0.72575223",
"0.72412246",
"0.6878039",
"0.61046064",
"0.60508245",
"0.60325855",
"0.5896537",
"0.58738023",
"0.58711684",
"0.58711684",
"0.5865639",
"0.5858588",
"0.5858588",
"0.58424044",
"0.58421654",
"0.58256066",
"0.58203965",
"0.58121145",
"0.5808104",
"0... | 0.0 | -1 |
Creates a service by a service Providers | def addservice
@service = ServiceProvider.find_by(username: params[:serviceprovider][:username]);
permitted = params[:serviceprovider].permit( :description, :category_id);
@service.services.create(permitted);
render json: @service
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @providerservice = Providerservice.new(providerservice_params)\n\n respond_to do |format|\n if @providerservice.save\n format.html { redirect_to @providerservice, notice: 'Providerservice was successfully created.' }\n format.json { render :show, status: :created, location: @p... | [
"0.6662852",
"0.655914",
"0.6457722",
"0.63426983",
"0.62791264",
"0.61642975",
"0.6132738",
"0.6124477",
"0.6112092",
"0.61052823",
"0.60855204",
"0.6019014",
"0.60006094",
"0.59816635",
"0.5970865",
"0.59550506",
"0.59518224",
"0.5930472",
"0.59059626",
"0.5866501",
"0.5866... | 0.55921066 | 44 |
Returns a Hash of the YAML file, including EE specific data if EE is used. | def to_h
if merge_ee?
deep_merge(@hash, @ee_hash)
else
@hash
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n require 'yaml'\n hash = YAML.load(File.read(self.yaml_file)) #gets hash from yaml file\n return hash\n end",
"def yaml\n @yaml ||= YAML.load_file path\n rescue StandardError\n {}\n end",
"def fixture_hash(filename, data: {})\n file = File.read fixture_fi... | [
"0.7555531",
"0.60180765",
"0.59964794",
"0.5976259",
"0.59742755",
"0.594057",
"0.5938272",
"0.59244937",
"0.5893305",
"0.5852357",
"0.5849291",
"0.5849162",
"0.5836411",
"0.5816448",
"0.58009464",
"0.5774561",
"0.5745079",
"0.57298476",
"0.57248044",
"0.5685182",
"0.56753",... | 0.54298216 | 40 |
Using SHA2 => no collisions, 512 bits output | def gen_key(record)
return Digest::SHA2.hexdigest(record.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sha512; end",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def sha256; end",
"def sha2?; @sha2; end",
"def hash_secure\n sha256 = OpenSSL::Digest::SHA256.new\n enc64(sha256... | [
"0.7260978",
"0.71643627",
"0.70039165",
"0.6864043",
"0.6720527",
"0.66268545",
"0.65768754",
"0.6558237",
"0.65307873",
"0.65307873",
"0.65307873",
"0.65307873",
"0.65307873",
"0.65307873",
"0.65307873",
"0.6494163",
"0.6445982",
"0.64025366",
"0.6374809",
"0.63560045",
"0.... | 0.0 | -1 |
GET /options/1 GET /options/1.xml | def show
@option = Options.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @option }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @options = @question.options.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @options }\n end\n end",
"def show\n\t@option = Option.find(params[:id])\n\n\n\trespond_to do |format|\n\t format.html # show.html.erb\n\t format.xml ... | [
"0.6737998",
"0.6669854",
"0.6557185",
"0.6532269",
"0.6477579",
"0.6331469",
"0.6313355",
"0.6308954",
"0.62945104",
"0.62643063",
"0.6211199",
"0.62021637",
"0.6199756",
"0.6199756",
"0.61866087",
"0.61787176",
"0.6044787",
"0.603775",
"0.6035963",
"0.60276",
"0.6021486",
... | 0.68262917 | 0 |
GET /options/new GET /options/new.xml | def new
@option = Option.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @option }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @opt = Opt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @opt }\n end\n end",
"def new\n @option = OptionModel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @option }\n end\n... | [
"0.7455853",
"0.73404807",
"0.7013586",
"0.6895405",
"0.6882285",
"0.6882285",
"0.68157756",
"0.68148303",
"0.67561",
"0.674072",
"0.67350537",
"0.6730547",
"0.6524446",
"0.6522662",
"0.6495112",
"0.6409164",
"0.6382452",
"0.6370532",
"0.6348015",
"0.63223034",
"0.63173157",
... | 0.7571324 | 1 |
POST /options POST /options.xml | def create
count = Property.find(params[:property_id]).options.count
params[:option][:property_id] = params[:property_id]
params[:option][:sequence] = count
@option = Option.create(params[:option])
@property_id = params[:property_id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def options!\n request! :options\n end",
"def options\n\t\t# we don't support sending a payload in options' body.\n\t\treq = Net::HTTP::Opt... | [
"0.66530377",
"0.66530377",
"0.6445932",
"0.6010732",
"0.5971419",
"0.58164084",
"0.57869315",
"0.57353294",
"0.56707245",
"0.5656248",
"0.563952",
"0.56392634",
"0.5602891",
"0.55980694",
"0.5586404",
"0.5586404",
"0.5586404",
"0.5586404",
"0.5586404",
"0.5586404",
"0.558640... | 0.0 | -1 |
PUT /options/1 PUT /options/1.xml | def update
@option = Option.find(params[:id])
respond_to do |format|
if @option.update_attributes(params[:option])
notify :notice, 'Option was successfully updated.'
format.html { redirect_to(@option) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @option.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @option = Option.find(params[:id])\n\n respond_to do |format|\n if @option.updat... | [
"0.6678477",
"0.65433025",
"0.651461",
"0.6507875",
"0.6466096",
"0.6466096",
"0.6257501",
"0.6174435",
"0.6104741",
"0.6049963",
"0.6040195",
"0.6040195",
"0.6001774",
"0.6001774",
"0.59641",
"0.59572977",
"0.59527624",
"0.5913547",
"0.5886651",
"0.5860818",
"0.5832506",
"... | 0.6317479 | 6 |
DELETE /options/1 DELETE /options/1.xml | def destroy
@option = Option.find(params[:id])
@option.destroy
respond_to do |format|
format.html { redirect_to(options_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(options={})\n connection.delete(\"/\", @name)\n end",
"def destroy\n @opt = Opt.find(params[:id])\n @opt.destroy\n\n respond_to do |format|\n format.html { redirect_to(opts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @auto_option = AutoOption.find... | [
"0.6976978",
"0.6933382",
"0.682899",
"0.66711384",
"0.658292",
"0.6561163",
"0.6500211",
"0.6459917",
"0.6442409",
"0.6403972",
"0.6403972",
"0.6399349",
"0.6351671",
"0.6323481",
"0.6323413",
"0.6307222",
"0.6307222",
"0.63068646",
"0.62822574",
"0.62731606",
"0.62616515",
... | 0.70544225 | 0 |
GET /generator_infos/1 GET /generator_infos/1.json | def show
@generator_info = GeneratorInfo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @generator_info }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @generator = Generator.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @generator }\n end\n end",
"def new\n @generator_info = GeneratorInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.... | [
"0.7734949",
"0.76324904",
"0.7155637",
"0.7088739",
"0.692677",
"0.6912711",
"0.6613922",
"0.65839964",
"0.65614575",
"0.65559924",
"0.6482887",
"0.6467777",
"0.6376878",
"0.63721305",
"0.63492876",
"0.63188666",
"0.61869276",
"0.61526024",
"0.61267203",
"0.60332644",
"0.602... | 0.8017623 | 0 |
GET /generator_infos/new GET /generator_infos/new.json | def new
@generator_info = GeneratorInfo.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @generator_info }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @generator = Generator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator }\n end\n end",
"def create\n @generator_info = GeneratorInfo.new(params[:generator_info])\n\n respond_to do |format|\n if @generator_info.save\n ... | [
"0.8090992",
"0.7891322",
"0.76211685",
"0.7536716",
"0.73769194",
"0.7209613",
"0.7102757",
"0.7100119",
"0.7083458",
"0.70036584",
"0.6943618",
"0.6923939",
"0.68963504",
"0.6856303",
"0.68508047",
"0.6817471",
"0.6797899",
"0.67962635",
"0.6792967",
"0.6767336",
"0.6741940... | 0.85566103 | 0 |
POST /generator_infos POST /generator_infos.json | def create
@generator_info = GeneratorInfo.new(params[:generator_info])
respond_to do |format|
if @generator_info.save
format.html { redirect_to @generator_info, notice: 'Generator info was successfully created.' }
format.json { render json: @generator_info, status: :created, location: @generator_info }
else
format.html { render action: "new" }
format.json { render json: @generator_info.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @generator_info = GeneratorInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generator_info }\n end\n end",
"def create\n @generator = Generator.new(generator_params)\n\n respond_to do |format|\n if @generator.save\n for... | [
"0.7391535",
"0.71054304",
"0.70323473",
"0.66751105",
"0.6495501",
"0.640216",
"0.6315719",
"0.6311654",
"0.62511134",
"0.61948544",
"0.6192045",
"0.61844724",
"0.61558163",
"0.60629576",
"0.6049093",
"0.60213625",
"0.59857494",
"0.59639215",
"0.5924564",
"0.5886682",
"0.586... | 0.7918936 | 0 |
PUT /generator_infos/1 PUT /generator_infos/1.json | def update
@generator_info = GeneratorInfo.find(params[:id])
respond_to do |format|
if @generator_info.update_attributes(params[:generator_info])
format.html { redirect_to @generator_info, notice: 'Generator info was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @generator_info.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @generator.update(generator_params)\n format.html { redirect_to @generator, notice: 'Generator was successfully updated.' }\n format.json { render :show, status: :ok, location: @generator }\n else\n format.html { render :edit }\n for... | [
"0.71187365",
"0.71187365",
"0.7006139",
"0.69810915",
"0.6883088",
"0.6548272",
"0.6409518",
"0.63473666",
"0.62041783",
"0.61811197",
"0.6149131",
"0.6029252",
"0.6020267",
"0.59239465",
"0.58967006",
"0.58490807",
"0.58278203",
"0.5804549",
"0.57554704",
"0.5703897",
"0.57... | 0.7500496 | 0 |
DELETE /generator_infos/1 DELETE /generator_infos/1.json | def destroy
@generator_info = GeneratorInfo.find(params[:id])
@generator_info.destroy
respond_to do |format|
format.html { redirect_to generator_infos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @generator.destroy\n respond_to do |format|\n format.html { redirect_to generators_url... | [
"0.7413984",
"0.7197602",
"0.7197602",
"0.7176681",
"0.7007245",
"0.6760218",
"0.67331195",
"0.6680643",
"0.66520363",
"0.6522609",
"0.6521887",
"0.6520884",
"0.6376413",
"0.63665414",
"0.6344744",
"0.63343006",
"0.6313048",
"0.630916",
"0.630233",
"0.62833387",
"0.6255577",
... | 0.7860438 | 0 |
returns true iff the audience recalls the scenes happening in the given order. | def recall? *scenes
unmatched = scenes.dup
@@memories.each do |memory|
unmatched.shift if unmatched[0] == memory
end
unmatched.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_been_recorded?(order)\n unless Validation.validate(order.to_s) && Order.is_a_valid_item_code?(order.to_s)\n return false\n end\n @customer_order.push order.to_s\n return true\n end",
"def probe?\n self.order == -1\n end",
"def is_order_next?(order)... | [
"0.5849542",
"0.5725551",
"0.55982906",
"0.54192567",
"0.5344008",
"0.53244233",
"0.5223742",
"0.52198446",
"0.51924807",
"0.5176462",
"0.51671374",
"0.51642245",
"0.5154686",
"0.51529115",
"0.5137023",
"0.5137023",
"0.5108884",
"0.5108884",
"0.5085219",
"0.50763226",
"0.5063... | 0.5998559 | 0 |
releases all players from a team back into the field | def release_players
Player.where(team_id: id).update_all(team_id: nil, active: false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reordenate_team\n position = 1\n self.players.each do |player|\n player.update_attribute(:position, position)\n position += 1\n end\n end",
"def set_player_team!\n player.update!(team_name: team_name) if player.team_name != team_name\n piece.update!(team_name: team_name) if piece.te... | [
"0.65347",
"0.6506997",
"0.60988814",
"0.6079857",
"0.6026012",
"0.60199046",
"0.60080343",
"0.5988645",
"0.5953333",
"0.59214634",
"0.59138846",
"0.58738226",
"0.5826338",
"0.57706386",
"0.57124436",
"0.56759965",
"0.56383044",
"0.5626219",
"0.5619092",
"0.56145805",
"0.5596... | 0.7450621 | 0 |
to ensure that the manifest xml matches the API format e.g. bar becomes: bar | def canonicalize(_context, resources)
resources.each do |resource|
resource[:xml] = str_from_xml(resource[:xml])
end
resources
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_manifest_format(format)\n unless MANIFEST_FORMATS.include?(format)\n error = ArgumentError.new(\"#{format} is not a valid format: #{MANIFEST_FORMATS.join(',')}\")\n api_method = caller_locations.first&.label\n ErrorTracker.report_exception(error, nil, { format: format, method: api_me... | [
"0.65038174",
"0.6355783",
"0.6163974",
"0.5828324",
"0.5795993",
"0.5728057",
"0.5666818",
"0.5640075",
"0.55853146",
"0.55828726",
"0.55793273",
"0.55565786",
"0.5521045",
"0.5505758",
"0.54997236",
"0.5498478",
"0.54826987",
"0.5469758",
"0.5439326",
"0.542904",
"0.5426625... | 0.0 | -1 |
Recipeusers should return the user instances who have recipe cards with this recipe | def users
recipe_rc = RecipeCard.all.select {|rc| rc.recipe == self}
# recipe_rc.map {|rc| rc.user}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_recipes\n RecipeCard.all.select do |recipe_cards|\n recipe_cards.user == self \n end\n end",
"def users\n RecipeCard.all.select do |recipe_card|\n recipe_card.recipe == self\n end\n end",
"def recipes\n RecipeCard.all.select do |recipe_car... | [
"0.85119873",
"0.8280848",
"0.8184995",
"0.8129581",
"0.81121093",
"0.8044279",
"0.801113",
"0.7995644",
"0.78879833",
"0.78483945",
"0.775207",
"0.7734068",
"0.77138174",
"0.7708338",
"0.7701722",
"0.766035",
"0.7639224",
"0.7599163",
"0.759865",
"0.75705534",
"0.7559834",
... | 0.77488613 | 11 |
Recipe.most_popular should return the recipe instance with the highest number of users (the recipe that has the most recipe cards) | def most_popular
# Recipecard.all.select {|rc| rc.recipe ==self}
# most_popular.map {|rc| rc.users}
recipe_hash = {}
RecipeCard.all.each do |recipecard|
if recipe_hash[recipecard.name]==nil
recipe_hash[recipecard.name]=1
else
recipe_hash[recipecard.name]+= 1
end
end
recipe_hash.max_by{|k,v| v}[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_popular\n @books.sort_by {|book| book.rate}\n end",
"def get_most_popular_users(num_users = 5)\n get_most_generic_for_users(DOCS[:most_popular_users], num_users)\n end",
"def top_three_recipes\n recipe_cards.max_by(3) {|recipe_cards| recipe_cards.rating}\n end",
"def fetch_popu... | [
"0.7250678",
"0.7133249",
"0.71095616",
"0.70011556",
"0.6951119",
"0.69291145",
"0.6864851",
"0.68501496",
"0.668146",
"0.6642349",
"0.66181916",
"0.65168816",
"0.6508674",
"0.64781153",
"0.6431703",
"0.642971",
"0.63897693",
"0.635224",
"0.6345496",
"0.63325816",
"0.6332146... | 0.861034 | 0 |
Recipeingredients should return all of the ingredients in this recipe | def ingredients
recipeingredient.map {|ri| ri.ingredient}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ingredients\n recipe_ingredients.map do |r|\n r.ingredient\n end\n end",
"def ingredients\n my_recipe_ingredients = RecipeIngredient.all.select do |recipeingredient|\n recipeingredient.recipe == self\n end\n my_recipe_ingredients.map do |recipe_ingredient|\n ... | [
"0.831865",
"0.8068893",
"0.7958368",
"0.7869872",
"0.778758",
"0.77806467",
"0.77555805",
"0.77555805",
"0.7738875",
"0.77230746",
"0.77155066",
"0.7692386",
"0.759416",
"0.753531",
"0.75210756",
"0.7517456",
"0.74817824",
"0.745634",
"0.74436855",
"0.74042046",
"0.73536646"... | 0.81206983 | 1 |
Confirms a loggedin user. | def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Please log in."
redirect_to login_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n ... | [
"0.70087826",
"0.6982988",
"0.6919373",
"0.688131",
"0.6845446",
"0.68326277",
"0.67944413",
"0.67929715",
"0.6642435",
"0.6624581",
"0.66114175",
"0.66022736",
"0.6589018",
"0.65539706",
"0.65349805",
"0.65303934",
"0.6512816",
"0.650312",
"0.64878744",
"0.6487622",
"0.64804... | 0.0 | -1 |
Confirms the correct user. | def correct_user
@user = User.find(params[:id])
redirect_to(root_url) unless @user == current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n msg = \"You do not have permission to update another user's information\"\n require_correct_user(@user, msg)\n end",
"def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n... | [
"0.7474259",
"0.73411936",
"0.7317917",
"0.7183303",
"0.7174887",
"0.7049758",
"0.70130193",
"0.7012358",
"0.7006517",
"0.7006201",
"0.7003461",
"0.69663024",
"0.69136065",
"0.6911695",
"0.690295",
"0.6892608",
"0.68439376",
"0.6842948",
"0.68397075",
"0.683463",
"0.6826711",... | 0.6736732 | 39 |
GET /pedidos GET /pedidos.json | def index
@titulo = "Listado de Pedidos"
@clase = "Pedidos"
@pedidos = Pedido.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pedidos }\n end\n end",
"def show\n @pedido = Pedido.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.747071",
"0.7284166",
"0.7139874",
"0.7077127",
"0.69721276",
"0.6797264",
"0.67113876",
"0.65911716",
"0.6536522",
"0.6536243",
"0.6512971",
"0.651051",
"0.64852196",
"0.64847046",
"0.6455422",
"0.6450327",
"0.64078474",
"0.64078474",
"0.63977134",
"0.6377617",
"0.6341547... | 0.6442838 | 16 |
GET /pedidos/1 GET /pedidos/1.json | def show
@titulo = "Ver Pedido"
@clase = "Pedidos"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @pedido = Pedido.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pedido }\n end\n end",
"def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n ... | [
"0.74077165",
"0.73092943",
"0.71350664",
"0.6982091",
"0.6735974",
"0.66808826",
"0.66509664",
"0.6643285",
"0.6618696",
"0.6617846",
"0.6615189",
"0.65846115",
"0.65537375",
"0.65325993",
"0.6523077",
"0.65036094",
"0.65036094",
"0.648402",
"0.6463641",
"0.64592105",
"0.644... | 0.0 | -1 |
POST /pedidos POST /pedidos.json | def create
@pedido = Pedido.new(pedido_params)
respond_to do |format|
if @pedido.save
format.html { redirect_to @pedido, notice: 'Pedido was successfully created.' }
format.json { render :show, status: :created, location: @pedido }
else
format.html { render :new }
format.json { render json: @pedido.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @pedido = Pedido.new(params[:pedido])\n\n respond_to do |format|\n if @pedido.save\n format.html { redirect_to @pedido, notice: 'Pedido was successfully created.' }\n format.json { render json: @pedido, status: :created, location: @pedido }\n else\n format.html { r... | [
"0.69962037",
"0.6992545",
"0.6986143",
"0.67919403",
"0.6747205",
"0.6718652",
"0.67047507",
"0.6665179",
"0.6665134",
"0.6649807",
"0.66279685",
"0.661703",
"0.6612084",
"0.66078395",
"0.6603146",
"0.6523099",
"0.64969224",
"0.6495659",
"0.6465211",
"0.6391158",
"0.6362935"... | 0.69461566 | 5 |
PATCH/PUT /pedidos/1 PATCH/PUT /pedidos/1.json | def update
respond_to do |format|
if @pedido.update(pedido_params)
format.html { redirect_to @pedido, notice: 'Pedido was successfully updated.' }
format.json { render :show, status: :ok, location: @pedido }
else
format.html { render :edit }
format.json { render json: @pedido.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 update\n @pedido = Pedido.find(params[:id])\n\n respond_to do |... | [
"0.676559",
"0.6637143",
"0.6555321",
"0.65462554",
"0.65299714",
"0.6528869",
"0.65102583",
"0.65058804",
"0.6490501",
"0.6480612",
"0.6469509",
"0.6458863",
"0.64261717",
"0.64036804",
"0.63793707",
"0.6360554",
"0.63580817",
"0.6356117",
"0.6349855",
"0.6349295",
"0.634429... | 0.65150654 | 9 |
DELETE /pedidos/1 DELETE /pedidos/1.json | def destroy
@pedido.destroy
respond_to do |format|
format.html { redirect_to pedidos_url, notice: 'Pedido was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @pedido.destroy\n respond_to do |format|\n format.html { redirect_to pedidos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pedido = Pedido.find(params[:id])\n @pedido.destroy\n\n respond_to do |format|\n format.html { redirect_to pedidos_ur... | [
"0.7276846",
"0.71442586",
"0.71386904",
"0.70953083",
"0.70914274",
"0.7006441",
"0.6989652",
"0.69702727",
"0.6943676",
"0.69317776",
"0.6930003",
"0.6928245",
"0.69174296",
"0.6914946",
"0.69103324",
"0.6906367",
"0.6906091",
"0.69055575",
"0.6897594",
"0.68893635",
"0.687... | 0.6933144 | 12 |
Use callbacks to share common setup or constraints between actions. | def set_pedido
@pedido = Pedido.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 pedido_params
params.require(:pedido).permit(:empresa_id, :orden_numero, :cliente_id, :fecha_pedido, :direccion, :monto_total, :tiempo_estimado_envio, :recepcionado, :enviado, :entregado, :usuario_id, :repartidor_id, :estado, detalle_pedidos_attributes: [:pedido_id, :empresa_id, :plato_id, :cantidad, :costo_plato])
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 |
First set of errors when submitting empty form | def date_of_birth_error_present?
wait_for(5) { displayed?(DATE_OF_BIRTH_ERROR) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_errors_if_any(form)\n form.semantic_errors(*form.object.errors.keys)\n end",
"def errors_for(attrs = {})\n form = new_form\n form.validate(attrs)\n if attrs.keys.length == 1\n form.errors[attrs.keys.first]\n else\n form.errors\n end\n end",
"def set_errors\n @errors = ... | [
"0.65186554",
"0.64190537",
"0.63627654",
"0.6315276",
"0.6284908",
"0.6279437",
"0.6279437",
"0.6270145",
"0.6260721",
"0.62536794",
"0.6252884",
"0.619959",
"0.61974233",
"0.6162661",
"0.6144355",
"0.61429155",
"0.61353093",
"0.6115656",
"0.6115656",
"0.6064904",
"0.6019701... | 0.0 | -1 |
Second set of errors when first set of boxes are populated | def first_name_error_present?
wait_for(5) { displayed?(FIRST_NAME_ERROR) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_fields\n @edit[:wf].get_dialog_order.each do |d|\n @edit[:wf].get_all_fields(d, false).each_value do |field|\n if field[:error].present?\n @error_div ||= d.to_s\n add_flash(field[:error], :error)\n end\n end\n end\n end",
"def check_errors\n unless... | [
"0.5981516",
"0.5890561",
"0.5878731",
"0.5874576",
"0.58672255",
"0.5864572",
"0.5803936",
"0.5802728",
"0.57858664",
"0.57026386",
"0.5667468",
"0.56466866",
"0.55714715",
"0.55669904",
"0.54822206",
"0.5412345",
"0.5393219",
"0.53843045",
"0.53817576",
"0.5359873",
"0.5340... | 0.0 | -1 |
(0 + km) % n == 0 m = 4 n = 10 k = 5 km % n = 0 km = cn k = cn / m This works (100% performance) but is not best way O(log(n + m)) | def fast_solution(n, m)
# eaten = c * n / m. Find c that makes (c * n) % m == 0.
c = 0
begin
c += 1
c = m / n if m == 1000000000
end until (c * n) % m == 0
c * n / m
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recessive k, m, n\n all = k + m + n\n mix = m + n\n total = 4.0 * triangle(all) # 2 * squareish all = 2 * 2 * triangle all\n\n lhs = triangle n\n mid = n * mix - n\n rhs = triangle mix\n\n 1 - (lhs+mid+rhs) / total\n end",
"def flatlandSpaceStations(n,c,m)\r\n answer = 0\r\n cc = ... | [
"0.7120764",
"0.64746976",
"0.6395241",
"0.6296249",
"0.6258625",
"0.6237656",
"0.6222404",
"0.6161289",
"0.61592406",
"0.6100771",
"0.609553",
"0.6091242",
"0.6090429",
"0.60756063",
"0.6063286",
"0.6044005",
"0.60394984",
"0.6036066",
"0.6027755",
"0.60071015",
"0.6002906",... | 0.6896274 | 1 |
Build a new trip place from PlacesDetails element | def from_place_details details
components = details[:address_components]
unless components.nil?
components.each do |component|
types = component[:types]
if types.nil?
next
end
if 'street_address'.in? types
self.address1 = component[:long_name]
elsif 'route'.in? types
self.route = component[:long_name]
elsif 'street_number'.in? types
self.street_number = component[:long_name]
elsif 'administrative_area_level_1'.in? types
self.state = component[:long_name]
elsif 'locality'.in? types
self.city = component[:long_name]
elsif 'postal_code'.in? types
self.zip = component[:long_name]
end
end
end
self.raw_address = details[:formatted_address]
self.lat = details[:geometry][:location][:lat]
self.lon = details[:geometry][:location][:lng]
self.name = details[:name]
self.google_place_id = details[:place_id]
self.stop_code = details[:stop_code]
self.types = details[:types]
self.address_components_raw = details
if self.raw_address.nil?
self.raw_address = self.name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_place_details details\n\n components = details[:address_components]\n unless components.nil?\n components.each do |component|\n types = component[:types]\n if types.nil?\n next\n end\n if 'street_address'.in? types\n self.address = component[:long_n... | [
"0.72132593",
"0.64105964",
"0.6377707",
"0.6343581",
"0.61970913",
"0.61484677",
"0.60855484",
"0.605337",
"0.5919284",
"0.5918735",
"0.5836108",
"0.58226466",
"0.5803015",
"0.5792237",
"0.5768543",
"0.573575",
"0.5726044",
"0.5690981",
"0.5685284",
"0.5670187",
"0.5670187",... | 0.6943853 | 1 |
discover the location for this trip place from its relationships | def location
# TODO Check this
# return poi.location unless poi.nil?
# return place.location unless place.nil?
return get_location
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def location\n # If \"addresses\" was eager loaded; then search for the \"location\" address. Otherwise\n # do a scoped find.\n if addresses.length > 0\n addresses.select {|a| a.label == \"location\"}[0]\n else\n addresses[:location]\n end\n end",
"def neighborhood\n self.locations.f... | [
"0.67318213",
"0.6215978",
"0.61506414",
"0.61318624",
"0.6104892",
"0.60724217",
"0.6043568",
"0.599354",
"0.5975805",
"0.5952316",
"0.58884007",
"0.5875682",
"0.5828992",
"0.5805762",
"0.5805322",
"0.57914877",
"0.57756495",
"0.57629985",
"0.57590026",
"0.5745338",
"0.57409... | 0.5965833 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.