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 |
|---|---|---|---|---|---|---|
generate positions names for players | def generate_positions!
position_names = Utils::Rules.position_names(players_count)
sorted_players = players.sort_by(&:seat)
# Find the button and name the seats after the button
sorted_players.each do |player|
player.position_name = 'BTN' if player.seat == @button_seat
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_all_players\n (0..num_players - 1).each { |i| @players[i].name_player('Player' + i.to_s)}\n end",
"def std_player_names\n\t\tnames = []\n\t\tfor i in 1..Constants::MAX_PLAYERS\n\t\t\tnames << \"Player\" + i.to_s\n\t\tend\n\t\tnames\n\tend",
"def player_position(name)\n @players_info[name][0]\n ... | [
"0.68774736",
"0.6583467",
"0.63141197",
"0.62952286",
"0.62876976",
"0.6236128",
"0.6233863",
"0.6189206",
"0.6163693",
"0.6120306",
"0.6097686",
"0.60634834",
"0.60436624",
"0.603904",
"0.59471434",
"0.5945879",
"0.5935235",
"0.59344625",
"0.5900837",
"0.58785874",
"0.58415... | 0.77006894 | 0 |
1 deck in the game 52 card deck must have suits (ace of diamonds) | def initialize
@cards = []
suits = [:hearts, :diamonds, :spades, :clubs]
suits.each do |suit|
(2..10).each do |value|
@cards << Card.new(suit, value)
end
["J", "Q", "K", "A"].each do |facecard|
@cards << Card.new(suit, facecard)
end
end
def shuffle!
cards.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_suit(c)\n Card::VALID_SUITS.include?(c)\n end",
"def suits\n cards.map(&:suit)\n end",
"def setTheSuit(suit) #generating the deck\n i =1;\n for i in 1..13\n if i === 1\n @cards << Card.new(\"Ace\", suit)\n elsif i < 11 && i > 1\n @cards << Car... | [
"0.6969675",
"0.6920003",
"0.67958224",
"0.66627955",
"0.66430116",
"0.66395205",
"0.66314054",
"0.6571674",
"0.6550886",
"0.65020764",
"0.64924765",
"0.64466196",
"0.6445846",
"0.64380914",
"0.6393958",
"0.6387258",
"0.63846",
"0.6383767",
"0.6381418",
"0.63543844",
"0.63475... | 0.6047438 | 56 |
PATCH/PUT /asserts/1 def update | def assert_params
params.require(:assert).permit(:item_name, :item_price, :company_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @assert = Assert.find(params[:id])\n\n respond_to do |format|\n if @assert.update_attributes(params[:assert])\n format.html { redirect_to @assert, notice: 'Assert was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | [
"0.7650971",
"0.7589099",
"0.700783",
"0.67059106",
"0.652093",
"0.6507984",
"0.64956504",
"0.64696836",
"0.6465715",
"0.64472437",
"0.64399725",
"0.6416675",
"0.6381284",
"0.638045",
"0.6380133",
"0.6347079",
"0.6335844",
"0.63184357",
"0.63117784",
"0.630641",
"0.6299517",
... | 0.0 | -1 |
returns a hash: filenames and contents | def process
filename = "index.markdown"
markdowns = {filename => []}
state = :message
message = ["\n"]
patch = []
commit = nil
(@gitlogp.split("\n")+["DONE"]).each { |line|
words=line.split
if line.slice(0,1)==" " || words.length==0
# commit messages start with 4 spac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n ... | [
"0.74854064",
"0.7255028",
"0.7179437",
"0.6959004",
"0.69000375",
"0.68833077",
"0.6856259",
"0.6831276",
"0.678139",
"0.6712385",
"0.6685843",
"0.6642572",
"0.6627232",
"0.6577476",
"0.6572631",
"0.65377647",
"0.65310705",
"0.6463139",
"0.64466137",
"0.64466137",
"0.6444027... | 0.0 | -1 |
a method used to specify which keys are allowed through params into the controller we use this method to create a list of what's permitted to be passed to .create or .update within controller actions. | def walk_params
allowed_params = %w(time dog_ids)
params.select {|param,value| allowed_params.include?(param)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permit_params_on_create *keys\n filter_strong_params :permit, [:create], keys\n end",
"def permitted_keys\n @permitted_keys ||= properties.map(&:to_sym)\n end",
"def keylist_params\n params.require(:keylist).permit(:keywords, :active, resources: [:id, :name] )\n end"... | [
"0.7147714",
"0.6955821",
"0.6941693",
"0.683812",
"0.682238",
"0.67554337",
"0.66487604",
"0.6591119",
"0.65802836",
"0.6559487",
"0.65301645",
"0.6509898",
"0.65082914",
"0.6488556",
"0.6459581",
"0.64169955",
"0.6373326",
"0.6325519",
"0.63219917",
"0.63131684",
"0.6312840... | 0.0 | -1 |
Return array containing absolute values of original | def abs()
self.map{ |v| v.abs }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abs!\n @data = @data.map {|x| x.abs }\n return self\n end",
"def abs\n return map {|currency, money| money.abs}\n end",
"def map_to_negativize(source_array)\n temp = []\n i = 0\n while i < source_array.length do\n temp[i] = -source_array[i]\n i += 1\n end\n return temp\nend",
"d... | [
"0.724306",
"0.70654184",
"0.69593173",
"0.6890281",
"0.6638135",
"0.6632852",
"0.6567719",
"0.65495694",
"0.64827174",
"0.64827174",
"0.6432505",
"0.64267576",
"0.64181334",
"0.6410095",
"0.63605046",
"0.6352464",
"0.63471997",
"0.6320979",
"0.6251272",
"0.62216717",
"0.6189... | 0.7808931 | 0 |
Return sum of absolute values of numbers within array | def abs_sum()
self.abs().sum()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_abs_sum(arr)\n\tsum = 0;\n\tarr.each { |n| sum += n.abs}\n\tsum\nend",
"def positive_sum(arr)\r\n sum = 0\r\n arr.each do |number|\r\n if number > 0\r\n sum += number\r\n end\r\n end\r\n sum\r\n end",
"def sum_of_negative(arr)\n sum = 0\n arr.each do |num|\n ... | [
"0.8598804",
"0.7311355",
"0.7122415",
"0.6982639",
"0.69207317",
"0.6876026",
"0.68760145",
"0.68760145",
"0.6864081",
"0.6858621",
"0.68533933",
"0.68380684",
"0.6827609",
"0.6824974",
"0.6799637",
"0.67900294",
"0.67506033",
"0.6706351",
"0.6699032",
"0.6696596",
"0.657375... | 0.7729588 | 1 |
Return difference (a b c ... z) of numbers in array | def diff(options={})
local = self.dup
local = local.reverse if options.fetch(:ordered, false)
value = local[0]
local[1..-1].each { |v| value -= v }
return value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_diff(a, b)\n a - b\nend",
"def array_diff(a, b)\n a - b\nend",
"def missing1(array)\n (array.first..array.last).to_a - array\nend",
"def substracted_array(array)\n sub_array = array.clone\n\n (sub_array.length).step(0, -1) do |i|\n sub_array[i] -= 9 if sub_array[i] > 9\n en... | [
"0.7208351",
"0.7208351",
"0.7035718",
"0.68743527",
"0.6756096",
"0.67457014",
"0.6720404",
"0.659195",
"0.6513841",
"0.6415499",
"0.63984185",
"0.6369533",
"0.63648355",
"0.6261772",
"0.62515986",
"0.6237862",
"0.6237353",
"0.62082624",
"0.61637586",
"0.61637324",
"0.614673... | 0.0 | -1 |
Only works if archive is a multipart file upload | def save
path = UPLOADS_DIR.join(archive.original_filename)
File.open(path, 'w') do |file|
file.write(archive.read)
end
if backend = Instance.backend
backend.deploy path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multipart?; end",
"def mock_archive_upload(archive_path, type)\n return ActionDispatch::Http::UploadedFile.new(:tempfile => File.new(Rails.root + archive_path , :type => type, :filename => File.basename(File.new(Rails.root + archive_path))))\n end",
"def multipart_upload\n end",
"def multipart; end"... | [
"0.7147338",
"0.6988758",
"0.68652976",
"0.68364024",
"0.648398",
"0.6401672",
"0.6382446",
"0.62473804",
"0.6215243",
"0.6127007",
"0.6127007",
"0.6127007",
"0.6127007",
"0.6127007",
"0.6127007",
"0.6117676",
"0.6111658",
"0.60960877",
"0.6037687",
"0.60280615",
"0.60268974"... | 0.0 | -1 |
Convenience methods for serializing models: | def serialize_model(model, options = {})
options[:is_collection] = false
JSONAPI::Serializer.serialize(model, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(model)\n end",
"def serialize_model(model, options = {})\n options[:is_collection] = false\n options[:skip_collection_check] = true\n JSONAPI::Serializer.serialize(model, options)\n end",
"def serialize(object) end",
"def serializer; end",
"def serialize; end",
"def seria... | [
"0.82833874",
"0.7652637",
"0.7510672",
"0.7398571",
"0.73767096",
"0.73767096",
"0.72810614",
"0.72810614",
"0.72512096",
"0.7127691",
"0.7080087",
"0.699744",
"0.68518126",
"0.6844842",
"0.6834337",
"0.67955464",
"0.6744942",
"0.66880125",
"0.6687968",
"0.6686662",
"0.66494... | 0.75259274 | 2 |
sorts the words based on their part of speech; some go in multiple arrays | def words_to_pos_array(filename)
corpus = File.new(filename, "r")
while(line = corpus.gets)
word = line.chomp.split(":")
if(word[1] == "Noun")
@noun << word[0].split(";")
end
if(word[1] == "Proper_Noun")
@proper_noun << word[0]
end
if(word[1] == "Noun_Phrase")
@noun_phrase << word[0]
end
if(w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sortwords(words\n return words.sort\nend",
"def sort_words\n audit\n @_sort_words ||= words.sort { |a, b| b.last <=> a.last }\n end",
"def word_sort(sentence)\n\t\n\t# require 'pry'\n\tword_split = sentence.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '') # Removes punctuation marks.\n\tword_array= word_sp... | [
"0.7464131",
"0.7427356",
"0.73915905",
"0.7316747",
"0.72889",
"0.7286274",
"0.7275316",
"0.72161365",
"0.7187843",
"0.71536905",
"0.71388364",
"0.71337235",
"0.70993227",
"0.7068526",
"0.7053777",
"0.70175743",
"0.69830406",
"0.6972317",
"0.6917348",
"0.6914123",
"0.6852761... | 0.0 | -1 |
GET /autos/1 GET /autos/1.xml | def show
@auto = Auto.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @auto }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def show\n @docent = Docent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @docent }\n ... | [
"0.60406405",
"0.5940906",
"0.59324235",
"0.59179825",
"0.58803165",
"0.58156735",
"0.58110446",
"0.58056253",
"0.5794515",
"0.57823056",
"0.57706326",
"0.577006",
"0.5757781",
"0.5734219",
"0.5722147",
"0.5720443",
"0.57038957",
"0.5698643",
"0.56928235",
"0.56928235",
"0.56... | 0.6570879 | 0 |
GET /autos/new GET /autos/new.xml | def new
@auto = Auto.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @auto }
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 => @ontology }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @docent... | [
"0.70491153",
"0.68690974",
"0.6841091",
"0.68097574",
"0.67756706",
"0.6761551",
"0.67568964",
"0.6728112",
"0.67130524",
"0.6706592",
"0.66770506",
"0.66647524",
"0.6653889",
"0.66515535",
"0.66515535",
"0.66515535",
"0.6636051",
"0.66348445",
"0.6631642",
"0.66310364",
"0.... | 0.7381461 | 0 |
POST /autos POST /autos.xml | def create
@auto = Auto.new(params[:auto])
respond_to do |format|
if @auto.save
format.html { redirect_to(@auto, :notice => 'Auto was successfully created.') }
format.xml { render :xml => @auto, :status => :created, :location => @auto }
else
format.html { render :action => ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post #:doc:\n end",
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post_save xml, options={:mapping=>:_default}\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/loan/v1\")... | [
"0.5848325",
"0.583876",
"0.5794263",
"0.5695455",
"0.5654528",
"0.55622554",
"0.5548257",
"0.5534813",
"0.5534496",
"0.5454454",
"0.5451348",
"0.54501027",
"0.54458433",
"0.54255784",
"0.5388089",
"0.5383285",
"0.5374578",
"0.53706384",
"0.5364691",
"0.53428626",
"0.53420246... | 0.5928877 | 0 |
PUT /autos/1 PUT /autos/1.xml | def update
@auto = Auto.find(params[:id])
respond_to do |format|
if @auto.update_attributes(params[:auto])
format.html { redirect_to(@auto, :notice => 'Auto was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def 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 upd... | [
"0.6443357",
"0.6142807",
"0.6024091",
"0.60069466",
"0.5854342",
"0.5844606",
"0.57985556",
"0.57459605",
"0.5740298",
"0.5730341",
"0.57261604",
"0.5631558",
"0.56310546",
"0.56232",
"0.5589611",
"0.5577066",
"0.5528798",
"0.5512342",
"0.5506836",
"0.54856735",
"0.5473823",... | 0.6274812 | 1 |
DELETE /autos/1 DELETE /autos/1.xml | def destroy
@auto = Auto.find(params[:id])
@auto.destroy
respond_to do |format|
format.html { redirect_to(autos_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 @auto = Auto.find(params[:id])\n @auto.destroy\n\n respond_to do |format|\n format.html { redirect_to autos_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n ... | [
"0.6981808",
"0.67058957",
"0.6616621",
"0.6597414",
"0.65192944",
"0.6519141",
"0.6492773",
"0.6481907",
"0.6481544",
"0.6415403",
"0.6410752",
"0.6390101",
"0.6368608",
"0.63668394",
"0.63480353",
"0.6341667",
"0.6334551",
"0.63127893",
"0.63127893",
"0.629805",
"0.62834173... | 0.73484993 | 0 |
Returns a URL for a thumbnail for this model's attachment. | def thumbnail_url
(ipaper_document && ipaper_document.thumbnail_url) || public_filename(:thumb)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thumbnail_url\n return self.endpoint.thumbnail_url(self.id)\n end",
"def thumbnail_url(attribute)\n doc = scribd_document_for(attribute)\n\n (doc && doc.thumbnail_url) or self.send(attribute).url(:thumb)\n end",
"def thumb_url\n if object.photo_url(:thumb)\n BASE_URL + ... | [
"0.84331304",
"0.7872871",
"0.7854112",
"0.78071266",
"0.77373344",
"0.7709763",
"0.7705207",
"0.7693354",
"0.76515293",
"0.76515293",
"0.7645849",
"0.76332843",
"0.7484646",
"0.7484217",
"0.7436902",
"0.7428418",
"0.73830533",
"0.737424",
"0.73735017",
"0.7372951",
"0.734832... | 0.7921569 | 1 |
Returns the content type for this model's attachment. | def get_content_type
self.content_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_type\n @content_type || object.content_type\n end",
"def content_type\n @resource.content_type\n end",
"def content_type\n instance_read(:content_type)\n end",
"def content_type\n return @content_type\n end",
"def content_type\n r... | [
"0.80318",
"0.8019006",
"0.79729074",
"0.7888877",
"0.78134274",
"0.78026074",
"0.77670604",
"0.7749299",
"0.767768",
"0.7675873",
"0.76176995",
"0.7557579",
"0.7548199",
"0.7474949",
"0.74733835",
"0.7461264",
"0.7453433",
"0.7410344",
"0.73923796",
"0.7378036",
"0.7362655",... | 0.8303311 | 0 |
Yields the correct path to the file, either the local filename or the S3 URL. | def file_path
public_filename =~ ScribdFu::S3 ? public_filename : "#{RAILS_ROOT}/public#{public_filename}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with_file_path_for(attribute, &block) # :yields: full_file_path\n attachment = attachment_for(attribute)\n\n if attachment.respond_to?(:s3)\n yield attachment.url\n elsif File.exists?(attachment.path)\n yield attachment.path\n else # file hasn't been s... | [
"0.67785275",
"0.67759126",
"0.64423054",
"0.63338375",
"0.6329639",
"0.62924635",
"0.62520695",
"0.6238966",
"0.6166494",
"0.6101677",
"0.6085722",
"0.60338676",
"0.59642005",
"0.59512967",
"0.5950308",
"0.5950308",
"0.5950308",
"0.59385157",
"0.5936016",
"0.5922419",
"0.592... | 0.6644782 | 2 |
GET /city_bs GET /city_bs.json | def index
@city_bs = CityB.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cities\n CS.get :us, :ca\n end",
"def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend",
"def api_request(city)\n url = \"https://jobs.github.com/positions.json?utf8=%E2%9C%93&description=&location=\"+... | [
"0.6437929",
"0.6435355",
"0.6360911",
"0.6290537",
"0.62250555",
"0.62099653",
"0.6186716",
"0.61463666",
"0.61354846",
"0.6091846",
"0.60755",
"0.60414547",
"0.60072553",
"0.5980863",
"0.5980438",
"0.59702015",
"0.59690917",
"0.5929768",
"0.5921687",
"0.58825123",
"0.587311... | 0.688635 | 0 |
GET /city_bs/1 GET /city_bs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @city_bs = CityB.all\n end",
"def index\n @cities = City.where(state_id: params[:id])\n respond_to do |format|\n format.json { render :json => @cities.to_json }\n end\n end",
"def getCity\n @city_id=ReceiverAddress.where(id: params[:address_id]).first.city_id\n @city=City.... | [
"0.6764457",
"0.6622489",
"0.6576757",
"0.6562479",
"0.6548969",
"0.6433215",
"0.63848925",
"0.63804746",
"0.63000983",
"0.6297865",
"0.62934697",
"0.6248745",
"0.6233014",
"0.62266994",
"0.62168723",
"0.6166677",
"0.6157572",
"0.6144171",
"0.61129373",
"0.61101466",
"0.60980... | 0.0 | -1 |
POST /city_bs POST /city_bs.json | def create
@city_b = CityB.new(city_b_params)
respond_to do |format|
if @city_b.save
format.html { redirect_to @city_b, notice: 'City b was successfully created.' }
format.json { render :show, status: :created, location: @city_b }
else
format.html { render :new }
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @city = City.new(city_params)\n\n if @city.save\n render json: @city, status: :created, location: @city\n # 'city model was successfully created.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end",
"def create\n @city = City.new(city_params... | [
"0.62737113",
"0.62529117",
"0.6103329",
"0.61032677",
"0.6089066",
"0.6073813",
"0.6065247",
"0.6043185",
"0.60256886",
"0.59737563",
"0.59691375",
"0.59340924",
"0.5896598",
"0.5877015",
"0.5873279",
"0.5867585",
"0.5867585",
"0.5867585",
"0.5849067",
"0.5812795",
"0.575621... | 0.7003735 | 0 |
PATCH/PUT /city_bs/1 PATCH/PUT /city_bs/1.json | def update
respond_to do |format|
if @city_b.update(city_b_params)
format.html { redirect_to @city_b, notice: 'City b was successfully updated.' }
format.json { render :show, status: :ok, location: @city_b }
else
format.html { render :edit }
format.json { render json: @ci... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @city.update(city_params)\n render json: @city\n # 'city was successfully updated.'\n else\n render json: @city.errors, status: :unprocessable_entity\n end\n end",
"def update\n @city = City.find(params[:id])\n if @city.update_attributes(:name=>params[:body][:name],... | [
"0.6838407",
"0.6814078",
"0.67937875",
"0.66032887",
"0.652717",
"0.6493126",
"0.64850175",
"0.64792204",
"0.64641565",
"0.63836884",
"0.6371357",
"0.6371357",
"0.6371357",
"0.6371357",
"0.6371357",
"0.6371136",
"0.62969106",
"0.62770927",
"0.6275237",
"0.62047964",
"0.61879... | 0.70601726 | 0 |
DELETE /city_bs/1 DELETE /city_bs/1.json | def destroy
@city_b.destroy
respond_to do |format|
format.html { redirect_to city_bs_url, notice: 'City b was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @city = City.find(params[:id])\n @city.destroy\n\n respond_to do |format|\n format.html { redirect_to country_s... | [
"0.7075109",
"0.70454824",
"0.7023453",
"0.69674253",
"0.6929005",
"0.6861613",
"0.68360287",
"0.6767941",
"0.6717794",
"0.6717794",
"0.6717794",
"0.6717794",
"0.6717794",
"0.6700305",
"0.6664531",
"0.6664504",
"0.6621401",
"0.6603824",
"0.6594647",
"0.6587219",
"0.6565848",
... | 0.73729396 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_city_b
@city_b = CityB.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 city_b_params
params.require(:city_b).permit(:address)
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 /threds GET /threds.xml | def index
@threds = Thred.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @threds }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @thres = Thre.all\n end",
"def index\n @node = Fedora.rest('rest/')\n end",
"def fetch_thesauri\n doc = create_doc('gaz-thesauri/administrativeThesaurus.xml')\n ## loop through each <term> element in the thesaurus\n vocabs=[]\n (doc/\"thesaurus/root/term\").each do |term... | [
"0.6313721",
"0.59318435",
"0.58644605",
"0.5804514",
"0.5705521",
"0.5705",
"0.5698605",
"0.5687858",
"0.5662065",
"0.5661437",
"0.56112105",
"0.5610917",
"0.56053025",
"0.55881417",
"0.55810964",
"0.55740416",
"0.5531222",
"0.5529222",
"0.551535",
"0.5514739",
"0.55134493",... | 0.7344564 | 0 |
GET /threds/1 GET /threds/1.xml | def show
@post = Post.new
@thred = Thred.find(params[:id])
@posts = @thred.posts
session[:threds_id] = params[:id]
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @thred }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @threds = Thred.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @threds }\n end\n end",
"def index\n @node = Fedora.rest('rest/')\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.header... | [
"0.712982",
"0.6086532",
"0.60585576",
"0.6014556",
"0.5911549",
"0.5907324",
"0.5907305",
"0.5858746",
"0.57622737",
"0.5754246",
"0.5702624",
"0.5701559",
"0.56505823",
"0.56328887",
"0.56191516",
"0.5612822",
"0.56123304",
"0.5596067",
"0.55674326",
"0.5565366",
"0.5560983... | 0.0 | -1 |
GET /threds/new GET /threds/new.xml | def new
@thred = Thred.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @thred }
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 @threat = Threat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @threat }\n end\n end",
"def new\n ... | [
"0.7127226",
"0.69348603",
"0.68887275",
"0.6806959",
"0.67995447",
"0.6750424",
"0.6674581",
"0.66575706",
"0.66553324",
"0.66517204",
"0.6648401",
"0.66200286",
"0.6614945",
"0.6610426",
"0.660895",
"0.6608138",
"0.6608138",
"0.6606919",
"0.65942514",
"0.65926903",
"0.65620... | 0.7798967 | 0 |
POST /threds POST /threds.xml | def create
@thred = Thred.new(params[:thred])
@thred.user_id = current_user
@thred.topic_id = session[:topic_id]
respond_to do |format|
if @thred.save
format.html { redirect_to(topic_path(@thred.topic_id)) }
flash[:notice] = 'Thread was successfully created.'
format.xml { re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(name=\"Default Name\", age=\"50\")\r\n xml_req =\r\n \"<?xml version='1.0' encoding='UTF-8'?>\r\n <person>\r\n <name>#{name}</name>\r\n <age>#{age}</age>\r\n </person>\"\r\n \r\n request = Net::HTTP::Post.new(@url)\r\n request.add_field \"Content-Type\", \"application/xml\"\r... | [
"0.57566625",
"0.5711922",
"0.55963504",
"0.5575562",
"0.55748504",
"0.5564624",
"0.5562722",
"0.5551708",
"0.5456386",
"0.5439193",
"0.54006994",
"0.53784215",
"0.5367831",
"0.53621924",
"0.53581387",
"0.5333475",
"0.5319124",
"0.53019387",
"0.5282829",
"0.52784723",
"0.5277... | 0.5307707 | 17 |
PUT /threds/1 PUT /threds/1.xml | def update
@thred = Thred.find(params[:id])
respond_to do |format|
if @thred.update_attributes(params[:thred])
format.html { redirect_to(@thred, :notice => 'Thread was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start... | [
"0.654606",
"0.6465994",
"0.6402641",
"0.6040251",
"0.59379596",
"0.5813524",
"0.5708722",
"0.5704163",
"0.5665429",
"0.56125087",
"0.5601064",
"0.55667937",
"0.5556977",
"0.55083185",
"0.5495238",
"0.54427534",
"0.54103255",
"0.5401289",
"0.53928417",
"0.5384982",
"0.5379096... | 0.55803096 | 11 |
DELETE /threds/1 DELETE /threds/1.xml | def destroy
@thred = Thred.find(params[:id])
if @thred.user_id == current_user.id
@thred.destroy
end
respond_to do |format|
format.html { redirect_to(:controller => "topics", :action => "topicsList") }
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 netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def delete()\n response = send_post_request(@xml_api_del... | [
"0.6985385",
"0.68152696",
"0.6599473",
"0.65403426",
"0.6514609",
"0.6454993",
"0.6405784",
"0.6326717",
"0.63217026",
"0.6248778",
"0.624739",
"0.6222331",
"0.6215027",
"0.62053436",
"0.6203248",
"0.6186887",
"0.6183332",
"0.6164731",
"0.6125953",
"0.6115404",
"0.6115233",
... | 0.60344464 | 44 |
Uploads install.sh from Host's Vagrant TMP directory to guest and executes. | def install(version, env)
shell_escaped_version = Shellwords.escape(version)
@machine.communicate.tap do |comm|
comm.upload(@install_sh_temp_path, 'install.sh')
# TODO: Execute with `sh` once install.sh removes it's bash-isms.
install_cmd = "bash install.sh -v #{... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provision_ssh(args)\n env = config.env.map { |k,v| \"#{k}=#{quote_and_escape(v.to_s)}\" }\n env = env.join(\" \")\n\n command = \"chmod +x '#{config.upload_path}'\"\n command << \" &&\"\n command << \" #{env}\" if !env.empty?\n command << \" #{config.upload_path}#{arg... | [
"0.70711714",
"0.68039584",
"0.6653613",
"0.6605517",
"0.6599578",
"0.6561956",
"0.6450166",
"0.6293504",
"0.6255275",
"0.6187389",
"0.61701596",
"0.61701596",
"0.6090534",
"0.60751975",
"0.60746723",
"0.6026254",
"0.6015361",
"0.5970736",
"0.59518826",
"0.59417206",
"0.59254... | 0.57015413 | 36 |
Fetches install.sh file to the Host's Vagrant TMP directory. Mostly lifted from: mitchellh/vagrant/blob/master/lib/vagrant/action/builtin/box_add.rb | def fetch_install_sh(env)
@install_sh_temp_path =
env[:tmp_path].join(Time.now.to_i.to_s + '-install.sh')
@logger.info("Downloading install.sh to: #{@install_sh_temp_path}")
url = INSTALL_SH
if File.file?(url) || url !~ /^[a-z0-9]+:.*$/i
@logger.info('Ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_install_sh\n Mixlib::Install.install_sh(base_url: url(settings.virtual_path).chomp('/'))\n end",
"def bootstrap(box)\n install = INSTALL[box]\n archive = GO_ARCHIVES[box]\n\n profile = <<-PROFILE\n export GOPATH=$HOME\n export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin\n export CDPATH=.... | [
"0.6482285",
"0.6476615",
"0.6457078",
"0.64435273",
"0.6257551",
"0.6215867",
"0.60663444",
"0.60467744",
"0.60467744",
"0.5970182",
"0.5960317",
"0.5933752",
"0.59334075",
"0.5920989",
"0.58885634",
"0.5851299",
"0.5839288",
"0.5818574",
"0.57779384",
"0.57333356",
"0.57142... | 0.7263677 | 0 |
Initializes a new object with attributes for the values passed to the constructor. | def initialize(attrs = {})
@attrs = attrs || {}
@attrs.each do |key, value|
self.class.class_eval { attr_reader key }
instance_variable_set("@#{key}", value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(*attrs)\n set_attributes(attrs.extract_options!)\n end",
"def initialize(attributes={})\n\t\t\t@attributes = attributes\n\t\tend",
"def initialize(attributes={})\n attributes.each do |key, value|\n self.send(\"#{key}=\", value)\n end\n @attributes = attributes\n end",
"d... | [
"0.8122249",
"0.8093827",
"0.79904944",
"0.79685163",
"0.79685163",
"0.79606146",
"0.79461443",
"0.7941421",
"0.7913621",
"0.7912809",
"0.7906486",
"0.79032063",
"0.79031163",
"0.79031163",
"0.7902702",
"0.7893931",
"0.7883122",
"0.7883122",
"0.7883122",
"0.7880533",
"0.78786... | 0.0 | -1 |
If table_options is not present then it will assume that table tag is already present in the web page source, where we are pasting the html code. | def to_html(id=nil, options={})
# More things can be added into table_script.erb
path = File.expand_path('../../templates/table_script.erb', __FILE__)
template = File.read(path)
id ||= SecureRandom.uuid # TODO: remove it or Use it for table tag.
table_script = show_script(id, scr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_table_from_html(html_fragment, options={})\n @main_doc.add_table(create_table_fragment_from_html(html_fragment, options))\n end",
"def replace_offensive_html\n html_tables.each do |tablename|\n if self.respond_to? tablename\n html_replacements.each_pair do |replacable,replaceme... | [
"0.62305534",
"0.59512484",
"0.5553503",
"0.55059844",
"0.5337334",
"0.52897674",
"0.5285585",
"0.52838445",
"0.52489924",
"0.520596",
"0.51852065",
"0.5182222",
"0.516921",
"0.51658744",
"0.51571226",
"0.51400363",
"0.51294655",
"0.5125167",
"0.51124",
"0.5111927",
"0.510371... | 0.5832695 | 2 |
Generates JavaScript and renders the tabke in the final HTML output. Parameters: element_id [Required] The ID of the DIV element that the table should be rendered in. | def to_js(element_id)
js = ''
js << "\n<script type='text/javascript'>"
js << draw_js(element_id)
js << "\n</script>"
js
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_js(element_id)\n js = ''\n js << \"\\n function #{chart_function_name(element_id)}() {\"\n js << \"\\n #{to_js}\"\n js << \"\\n var table = new google.visualization.Table(\"\n js << \"document.getElementById('#{element_id}'));\"\n js << add_listeners_js('table')\n ... | [
"0.7415876",
"0.69839007",
"0.6395143",
"0.601404",
"0.59792745",
"0.5944508",
"0.57575244",
"0.5679092",
"0.52764165",
"0.52416307",
"0.52319044",
"0.5160733",
"0.5121786",
"0.50900424",
"0.50764775",
"0.50453067",
"0.5023863",
"0.49927163",
"0.49636105",
"0.49353054",
"0.49... | 0.6727912 | 2 |
=begin to_snake_case In: String (camelCase) Out: String (snake_case) Rules: convert the string into snake_case Al: def a method that takes a string split the string into an array for iteration purposes iterate oever the array for transformation purpose if any letter is uppercase, downcase it and add '_' before it. join... | def to_snake_case(str)
str.chars.map { |e| e == e.upcase ? "_#{e.downcase}" : e }.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snake_case_to_capitalised(str)\n str.split(\"_\").map(&:capitalize).join(\" \")\n end",
"def to_snake_case(s)\n s.to_s.split(/(?=[A-Z])/).join(\"_\").downcase\nend",
"def snake_to_camel(snake_string)\n string = snake_string.gsub(/(_[a-z])/) {|match| match[1].upcase}\n string\nend",
"def camel_to_s... | [
"0.81989086",
"0.8045749",
"0.8015578",
"0.7979653",
"0.788634",
"0.78659797",
"0.7776466",
"0.77201766",
"0.77169955",
"0.77024436",
"0.7689317",
"0.76834923",
"0.76348555",
"0.763462",
"0.7627876",
"0.76087534",
"0.76016563",
"0.75946134",
"0.75907445",
"0.7580754",
"0.7577... | 0.8001212 | 3 |
GET /users or /users.json | def index
users = User.all
render json: users
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestC... | [
"0.806055",
"0.7744234",
"0.7634615",
"0.7550921",
"0.75122553",
"0.7415926",
"0.7389357",
"0.7241328",
"0.7228267",
"0.71839374",
"0.7124725",
"0.7091516",
"0.7090949",
"0.7085982",
"0.7035943",
"0.7027195",
"0.70099634",
"0.6991462",
"0.6990362",
"0.6990362",
"0.6969571",
... | 0.0 | -1 |
GET /users/1 or /users/1.json | def show
user = User.find(params[:id])
render json: user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.7887163",
"0.7557183",
"0.75152683",
"0.72985786",
"0.72269154",
"0.72222257",
"0.7199761",
"0.7149148",
"0.71043855",
"0.70956045",
"0.70776516",
"0.69572675",
"0.69495904",
"0.6933776",
"0.6928676",
"0.69063896",
"0.6887545",
"0.6831413",
"0.6831413",
"0.68155235",
"0.68... | 0.6729649 | 28 |
POST /users or /users.json | def create
user = User.new(user_params)
if user.save
render json: user
else
render json: {errors: "Cannot create user"}, :status => 420
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end",
"def CreateUser params = {}\n \n ... | [
"0.7237885",
"0.7191614",
"0.6843977",
"0.67813146",
"0.6722938",
"0.6687058",
"0.66412586",
"0.6619202",
"0.6612563",
"0.6606661",
"0.6604914",
"0.6583068",
"0.64702535",
"0.64686507",
"0.6454322",
"0.64413595",
"0.64403987",
"0.6424176",
"0.6424176",
"0.6416927",
"0.6416927... | 0.66074103 | 9 |
PATCH/PUT /users/1 or /users/1.json | def update
if user.update(user_params)
render json: user
else
render json: {errors: "Cannot create user"}, :status => 420
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.7218687",
"0.7152267",
"0.69586194",
"0.68886995",
"0.687557",
"0.6872444",
"0.6864246",
"0.68546486",
"0.68465436",
"0.6830651",
"0.6811558",
"0.6810179",
"0.6796577",
"0.6788132",
"0.6781627",
"0.6769231",
"0.6769231",
"0.67691255",
"0.674409",
"0.6735335",
"0.67350453",... | 0.6875362 | 5 |
DELETE /users/1 or /users/1.json | def destroy
user.destroy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete\n @user.destroy\n respond_to do |form... | [
"0.768551",
"0.7500913",
"0.745141",
"0.73403746",
"0.73091286",
"0.72879285",
"0.71791536",
"0.7176651",
"0.7158077",
"0.71385807",
"0.71305686",
"0.710351",
"0.7097527",
"0.7095211",
"0.7091993",
"0.7091239",
"0.7091239",
"0.7090048",
"0.7089146",
"0.7089146",
"0.7089146",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def user_params
params.require(:user).permit(:first_name, :last_name, :username, :email, :password, :city, :state, :birth_year, :birth_day, :about_me)
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_memory
@memory = Memory.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 trusted parameter "white list" through. | def memory_params
params.require(:memory).permit(:title, :caption, :date, :label, :address, :latitude, :longitude, :avatar)
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.7122899",
"0.7054107",
"0.69478",
"0.6902101",
"0.67359334",
"0.67178756",
"0.66889167",
"0.6677724",
"0.6661157",
"0.6555896",
"0.6527207",
"0.64584696",
"0.64517015",
"0.6450208",
"0.644749",
"0.6435074",
"0.6413329",
"0.6413329",
"0.6391818",
"0.6380081",
"0.6380081",
... | 0.0 | -1 |
GET /nha_xuat_bans or /nha_xuat_bans.json | def index
@nha_xuat_bans = NhaXuatBan.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @nhaxuatbans = Nhaxuatban.all\n end",
"def index\n\n @bans = @cloud.bans.where(\n params.select { |k,v| [:offender_id,:enforcer_id].include?(k.to_sym) }\n ).order_by(due: :desc)\n\n render status: 200\n end",
"def index\n user_id = params[:user_id]\n user_id=current_user.us... | [
"0.6557494",
"0.6526814",
"0.6352285",
"0.6240986",
"0.60403526",
"0.6025318",
"0.60091823",
"0.5928755",
"0.58844835",
"0.58353925",
"0.58342224",
"0.58316106",
"0.58221084",
"0.5818551",
"0.5805397",
"0.5791002",
"0.57878363",
"0.576695",
"0.5751677",
"0.5737269",
"0.573692... | 0.6553088 | 1 |
GET /nha_xuat_bans/1 or /nha_xuat_bans/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @nhaxuatbans = Nhaxuatban.all\n end",
"def index\n @nha_xuat_bans = NhaXuatBan.all\n end",
"def index\n user_id = params[:user_id]\n user_id=current_user.user_id unless user_id.present?\n\n @fans = User.get_fans(user_id)\n\n respond_to do |format|\n format.html # index.html... | [
"0.6555169",
"0.6545024",
"0.63186306",
"0.62547165",
"0.6215351",
"0.61261064",
"0.61111116",
"0.6075117",
"0.6049434",
"0.60301065",
"0.6016878",
"0.5979248",
"0.59659356",
"0.59246355",
"0.5923923",
"0.59179926",
"0.5912341",
"0.5907933",
"0.5877581",
"0.5858874",
"0.58416... | 0.0 | -1 |
POST /nha_xuat_bans or /nha_xuat_bans.json | def create
@nha_xuat_ban = NhaXuatBan.new(nha_xuat_ban_params)
respond_to do |format|
if @nha_xuat_ban.save
format.html { redirect_to @nha_xuat_ban, notice: "Nha xuat ban was successfully created." }
format.json { render :show, status: :created, location: @nha_xuat_ban }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @nhaxuatban = Nhaxuatban.new(nhaxuatban_params)\n\n respond_to do |format|\n if @nhaxuatban.save\n format.html { redirect_to @nhaxuatban, notice: \"Nhaxuatban was successfully created.\" }\n format.json { render :show, status: :created, location: @nhaxuatban }\n else\n ... | [
"0.6663562",
"0.6098382",
"0.5871929",
"0.5856842",
"0.585545",
"0.58245844",
"0.5814963",
"0.5713518",
"0.57046545",
"0.5653624",
"0.5646523",
"0.56361854",
"0.5608308",
"0.5593821",
"0.557986",
"0.55241853",
"0.5504221",
"0.54989463",
"0.5488993",
"0.54846936",
"0.5467811",... | 0.6841373 | 0 |
PATCH/PUT /nha_xuat_bans/1 or /nha_xuat_bans/1.json | def update
respond_to do |format|
if @nha_xuat_ban.update(nha_xuat_ban_params)
format.html { redirect_to @nha_xuat_ban, notice: "Nha xuat ban was successfully updated." }
format.json { render :show, status: :ok, location: @nha_xuat_ban }
else
format.html { render :edit, status: :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @nhaxuatban.update(nhaxuatban_params)\n format.html { redirect_to @nhaxuatban, notice: \"Nhaxuatban was successfully updated.\" }\n format.json { render :show, status: :ok, location: @nhaxuatban }\n else\n format.html { render :edit, status... | [
"0.670745",
"0.6503315",
"0.63509065",
"0.6334395",
"0.6245802",
"0.6150187",
"0.6133864",
"0.6123517",
"0.6118438",
"0.611286",
"0.61116457",
"0.60664815",
"0.6052603",
"0.60161173",
"0.592766",
"0.59247494",
"0.5907507",
"0.5897823",
"0.58912474",
"0.58894914",
"0.5889306",... | 0.7010193 | 0 |
DELETE /nha_xuat_bans/1 or /nha_xuat_bans/1.json | def destroy
@nha_xuat_ban.destroy
respond_to do |format|
format.html { redirect_to nha_xuat_bans_url, notice: "Nha xuat ban was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @nhaxuatban.destroy\n respond_to do |format|\n format.html { redirect_to nhaxuatbans_url, notice: \"Nhaxuatban was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bahan = Bahan.find(params[:id])\n @bahan.destroy\n\n respond_t... | [
"0.7016961",
"0.699308",
"0.6958809",
"0.67339265",
"0.67335147",
"0.6647549",
"0.6645507",
"0.66436845",
"0.66290545",
"0.66263163",
"0.66263163",
"0.66263163",
"0.66263163",
"0.6623177",
"0.6610434",
"0.6603771",
"0.6603123",
"0.6603123",
"0.66029096",
"0.6585357",
"0.65624... | 0.70129806 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_nha_xuat_ban
@nha_xuat_ban = NhaXuatBan.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 nha_xuat_ban_params
params.fetch(:nha_xuat_ban, {})
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 |
Returns a Boolean indicating whether this character is a hiragana or katakana character. (This string must contain only one character.) | def kana?
codepoint.kana?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def japanese?\n !!(self =~ /\\p{Katakana}|\\p{Hiragana}/)\n end",
"def trans_kana?(vstring)\n /[ア-ンヴヵヶ]/ =~ vstring || /[ア-ン]/ =~ vstring\n end",
"def ppp?(morpheme)\n morpheme[:pos] == '助詞'\n end",
"def han?(str)\n str =~ /\\p{Han}/\nend",
"def spanish_char?\n ord = self.ord\n retur... | [
"0.76915556",
"0.7339704",
"0.6728773",
"0.66495585",
"0.6604562",
"0.65399086",
"0.6479676",
"0.6461593",
"0.638027",
"0.6342552",
"0.6337289",
"0.6326561",
"0.6322726",
"0.63071156",
"0.62518114",
"0.6246334",
"0.62264943",
"0.6212482",
"0.6201228",
"0.6187397",
"0.61860883... | 0.71586406 | 2 |
Returns a Boolean indicating whether this character is a fullwidth latin character. (This string must contain only one character.) | def wide_latin?
codepoint.wide_latin?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_latin_only?(input)\n !!(input.match(LATIN_ALPHABET_PLUS_SYMBOLS))\n end",
"def unicode?\n self.local =~ /[^\\p{InBasicLatin}]/ ? true : false\n end",
"def is_ascii?\n self.length == self.tr(\"\\200-\\377\", '').length\n end",
"def spanish_char?\n ord = self.ord\n return tru... | [
"0.7055126",
"0.70407486",
"0.7015116",
"0.68814504",
"0.6775708",
"0.6770142",
"0.67394125",
"0.6654448",
"0.6568269",
"0.65361154",
"0.6517135",
"0.6517135",
"0.6457438",
"0.6439691",
"0.64047354",
"0.63502216",
"0.63326097",
"0.6298608",
"0.6296667",
"0.62708586",
"0.62028... | 0.671197 | 7 |
Returns the UCS codepoint of this character. (This string must contain only one character.) Currently only UTF8 encoding is supported. | def codepoint
unless $KCODE =~ /^u/i
raise ArgumentError, "unsupported encoding (#{$KCODE})"
end
unless jlength == 1
raise RangeError, "string must be exactly one character long"
end
case self.length
when 1
UCSCodepoint.new(self[0])
when 2
UCSCodepoint.new(
((s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_codepoint(character)\n \"%04x\" % character.unpack(\"U\")[0]\n end",
"def char\n self.class.codepoint2char(@codepoint)\n end",
"def char_to_codepoint(c)\n codepoint = charset.index c\n if codepoint.nil?\n fail NotInCharset, \"Char \\\"#{c}\\\" not part of the suppor... | [
"0.7401675",
"0.73875356",
"0.7083435",
"0.69318175",
"0.69318175",
"0.68950194",
"0.67998207",
"0.6733697",
"0.663133",
"0.6616885",
"0.6568802",
"0.65656006",
"0.6547719",
"0.64401865",
"0.6316139",
"0.6107337",
"0.60846347",
"0.604716",
"0.6045543",
"0.6043531",
"0.6039094... | 0.8147921 | 0 |
Like index, but returns a character offset instead of a byte offset. The starting offset is also in characters instead of bytes. | def uindex(substr, uoffset = 0)
offset = uindex_to_index(uoffset)
index_to_uindex(index(substr, offset))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char_offset(byte_offset)\n end",
"def char_offset(offset)\n raise \"Should not be called\"\n end",
"def char_offset(byte_offset)\n if multibyte?\n @string.byteslice(0, byte_offset).length\n else\n byte_offset\n end\n end",
"def line_char_to_offset(text, line, char... | [
"0.73595417",
"0.7269311",
"0.7269015",
"0.7138464",
"0.7070019",
"0.7029594",
"0.69150543",
"0.6751049",
"0.67342687",
"0.67142797",
"0.66294676",
"0.65738636",
"0.64227486",
"0.64006436",
"0.6394876",
"0.638593",
"0.6364955",
"0.6350283",
"0.6335671",
"0.63291174",
"0.63056... | 0.0 | -1 |
Like slice, but takes a character offset and length (instead of bytes). Can't handle negative lengths. | def uslice(uoffset, ulength)
offset = uindex_to_index(uoffset)
substr = slice(offset, length)
substr.split('')[0,ulength].join('')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slice(start, length)\n end",
"def slice(index, length = undefined)\n index += @length if index < 0\n\n return if index >= @length || index < 0\n\n if length\n `self.slice(index, index + length)`\n else\n `self.slice(index, 1)[0]`\n end\n end",
"def slice!(index, length = undefine... | [
"0.72439635",
"0.7084324",
"0.7021133",
"0.70208865",
"0.68172824",
"0.67353725",
"0.67062587",
"0.6696031",
"0.6677746",
"0.6669689",
"0.66393757",
"0.6621263",
"0.6594273",
"0.6583983",
"0.64345735",
"0.6388772",
"0.6350474",
"0.63295096",
"0.63295096",
"0.63217163",
"0.629... | 0.67302275 | 6 |
Converts a byte offset to a character offset. The byte offset must be greater than or equal to zero and less than or equal to the byte length of the string. Returns +nil+ if the offset is in the middle of a character. | def index_to_uindex(byte_index)
return nil if byte_index.nil?
if byte_index < 0 || byte_index > length
raise RangeError, 'index out of range'
end
chars = split('')
char_index = 0
chars.each do |ch|
break if byte_index == 0
byte_index -= ch.length
return nil if byte_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char_offset(byte_offset)\n if multibyte?\n @string.byteslice(0, byte_offset).length\n else\n byte_offset\n end\n end",
"def char_offset(byte_offset)\n string.byteslice(0, byte_offset).length\n end",
"def char_offset(byte_offset)\n end",
"def translate_offset(str, ... | [
"0.7799634",
"0.7487934",
"0.7120675",
"0.67463815",
"0.6733679",
"0.64444405",
"0.6370035",
"0.62119704",
"0.6160196",
"0.5950268",
"0.57843024",
"0.5773772",
"0.57451946",
"0.5646692",
"0.5524795",
"0.5496446",
"0.54665405",
"0.5450994",
"0.54175305",
"0.54113305",
"0.54080... | 0.4947158 | 50 |
Converts a character offset to a byte offset. The character offset must be greater than or equal to zero and less than or equal to the character length of the string. | def uindex_to_index(char_index)
return nil if char_index.nil?
if char_index < 0 || char_index > jlength
raise RangeError, 'index out of range'
end
chars = split('')
byte_index = 0
char_index.times do |i|
byte_index += chars[i].length
end
byte_index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char_offset(byte_offset)\n if multibyte?\n @string.byteslice(0, byte_offset).length\n else\n byte_offset\n end\n end",
"def char_offset(byte_offset)\n string.byteslice(0, byte_offset).length\n end",
"def char_offset(byte_offset)\n end",
"def translate_offset(str, ... | [
"0.76843625",
"0.7540724",
"0.72482884",
"0.70918685",
"0.6651365",
"0.61517656",
"0.61477566",
"0.6075541",
"0.60741794",
"0.59957886",
"0.5905481",
"0.58650005",
"0.5690217",
"0.56889236",
"0.5656514",
"0.5625027",
"0.55722076",
"0.55112475",
"0.54640275",
"0.5461448",
"0.5... | 0.52345896 | 29 |
GET /admin/counter_agents GET /admin/counter_agents.json | def index
@admin_counter_agents = CounterAgent.order(created_at: :desc).page params[:page]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def agents_index\n @agents = User.agents\n end",
"def index\n @registered_agents = RegisteredAgent.all\n end",
"def index\n @agents = Agent.all\n end",
"def index\n @user_agents = UserAgent.all.order(:counter)\n respond_to do |format|\n format.html\n format.json {\n render ... | [
"0.7233658",
"0.6735753",
"0.67000496",
"0.6592698",
"0.6459598",
"0.64017516",
"0.63920134",
"0.63195413",
"0.6251481",
"0.59900206",
"0.5955135",
"0.59029156",
"0.5899754",
"0.58968973",
"0.58399254",
"0.5766138",
"0.56977105",
"0.5679868",
"0.56542295",
"0.5615993",
"0.558... | 0.7361644 | 0 |
GET /admin/counter_agents/1 GET /admin/counter_agents/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @admin_counter_agents = CounterAgent.order(created_at: :desc).page params[:page]\n end",
"def agents_index\n @agents = User.agents\n end",
"def set_admin_counter_agent\n @admin_counter_agent = CounterAgent.find(params[:id])\n end",
"def index\n @agents = Agent.all\n end",
"def i... | [
"0.7276335",
"0.6743819",
"0.6729541",
"0.6491717",
"0.64659286",
"0.6435876",
"0.61982256",
"0.6126758",
"0.6097743",
"0.60889256",
"0.58804405",
"0.5755135",
"0.5752676",
"0.56993437",
"0.56727755",
"0.5633748",
"0.561252",
"0.5548783",
"0.5501441",
"0.54976195",
"0.5490544... | 0.0 | -1 |
POST /admin/counter_agents POST /admin/counter_agents.json | def create
@admin_counter_agent = CounterAgent.new(admin_counter_agent_params)
@admin_counter_agent.user.set_user_password
@admin_counter_agent.user.set_role("counter_agent")
respond_to do |format|
if @admin_counter_agent.save
format.html { redirect_to [:admin, @admin_counter_agent], noti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @admin_counter_agents = CounterAgent.order(created_at: :desc).page params[:page]\n end",
"def set_admin_counter_agent\n @admin_counter_agent = CounterAgent.find(params[:id])\n end",
"def agents_index\n @agents = User.agents\n end",
"def add\n # load agent\n @helper = Services::H... | [
"0.62646943",
"0.6156153",
"0.61223626",
"0.5723729",
"0.5699625",
"0.5690279",
"0.56737477",
"0.55605125",
"0.5556322",
"0.55122834",
"0.5498243",
"0.5432227",
"0.5428371",
"0.54095787",
"0.5376967",
"0.5372921",
"0.53337955",
"0.53328013",
"0.5332538",
"0.5268482",
"0.52385... | 0.6941678 | 0 |
PATCH/PUT /admin/counter_agents/1 PATCH/PUT /admin/counter_agents/1.json | def update
respond_to do |format|
if (@admin_counter_agent.update(number: admin_counter_agent_params[:number],
centre: admin_counter_agent_params[:centre], country_iso_code: admin_counter_agent_params[:country_iso_code]) && @admin_counter_agent.user.update_without_passwor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_admin_counter_agent\n @admin_counter_agent = CounterAgent.find(params[:id])\n end",
"def update\n @agent = @business.agents.find(params[:id])\n\n respond_to do |format|\n if @agent.update_attributes(agent_params || {})\n format.html { redirect_to business_agent_path(@business, @agen... | [
"0.65080976",
"0.62172073",
"0.608326",
"0.60576236",
"0.59966063",
"0.595715",
"0.59080815",
"0.59080815",
"0.5886227",
"0.5793102",
"0.5784826",
"0.5729215",
"0.5727817",
"0.5638257",
"0.5582715",
"0.5509779",
"0.5508928",
"0.55002654",
"0.5494019",
"0.54705393",
"0.546511"... | 0.63621986 | 1 |
DELETE /admin/counter_agents/1 DELETE /admin/counter_agents/1.json | def destroy
@admin_counter_agent.destroy
respond_to do |format|
format.html { redirect_to admin_counter_agents_url, notice: "Counter agent was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @agent.destroy\n respond_to do |format|\n format.html { redirect_to admin_agents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agent.destroy\n\n respond_to do |format|\n format.html { redirect_to agents_url, notice: t('controller.successfully_... | [
"0.7369127",
"0.70861536",
"0.70682144",
"0.69702214",
"0.6948698",
"0.68596464",
"0.67841005",
"0.67199755",
"0.6641481",
"0.66178435",
"0.6603365",
"0.6595816",
"0.65699226",
"0.65653265",
"0.6504678",
"0.65038246",
"0.6496225",
"0.6495329",
"0.6490884",
"0.6476606",
"0.642... | 0.77239615 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_admin_counter_agent
@admin_counter_agent = CounterAgent.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 admin_counter_agent_params
params.require(:counter_agent).permit(:number, :centre, :country_iso_code,
user_attributes: [:email, :first_name, :last_name, :phone_number, :avatar, :airport_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.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 |
Return a new FuzzyTime clock, intialized to the given time. If no intial time is specified, the current time is used. The default fuzz is 1 digit; the default wobble is 5 minutes; times are represented in 12hour style by default. | def initialize ( actual=nil )
@actual = actual || Time.new() # the actual time (Time)
@current = nil # the time that we report (Time)
@updated = Time.new # when @current was last updated (Time)
@wobble = 5 # the maximum error in @current (minutes)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_fuzz_time\n last_display = @fuzz_history.last[:display]\n min_fuzz_factor = @actual - @fuzz_factor\n lower_bound = last_display > min_fuzz_factor ? last_display : min_fuzz_factor\n\n upper_bound = @actual + @fuzz_factor\n\n range = upper_bound - lower_bound... | [
"0.5996044",
"0.5683593",
"0.55133057",
"0.5253675",
"0.50663906",
"0.49999663",
"0.49593922",
"0.4954107",
"0.48461896",
"0.4795131",
"0.4787517",
"0.47603184",
"0.47585955",
"0.4753248",
"0.4725507",
"0.46944",
"0.46916792",
"0.46692365",
"0.46516144",
"0.4640948",
"0.46393... | 0.6284047 | 0 |
Advance the actual time by the given number of seconds (The reported time may or may not change.) | def advance ( delta=0 )
@actual += delta
@current = @actual + offset
@current_offset = @current.to_i/60 - @actual.to_i/60
@updated = Time.new
@update_count += 1
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance(seconds:)\n @time += (seconds.to_i * 1_000)\n end",
"def advance_seconds(secs)\n self + secs\n end",
"def tick(seconds)\n\t\t@time += seconds\n\tend",
"def advance_1sec!\n\t\tTimecop.travel(Time.now + 1)\n\tend",
"def step(time)\n warn %(Timer step must be >= 0, but #{time} was... | [
"0.835187",
"0.77463293",
"0.71414804",
"0.6821964",
"0.67210037",
"0.66520834",
"0.6526834",
"0.6495534",
"0.6457169",
"0.64517057",
"0.6394747",
"0.6320531",
"0.6319638",
"0.6309017",
"0.63011044",
"0.6289072",
"0.6198879",
"0.6185489",
"0.6163354",
"0.61184144",
"0.6060033... | 0.61480397 | 19 |
Advance the actual time to account for the time since it was last changed. (The reported time may or may not change.) | def update
advance( (Time.new - @updated).to_i )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance ( delta=0 ) \n @actual += delta\n @current = @actual + offset\n @current_offset = @current.to_i/60 - @actual.to_i/60\n @updated = Time.new\n @update_count += 1\n self\n end",
"def update_time\n delta = Gosu.milliseconds - @last_ms\n @last_ms = Gosu.milliseconds\n ... | [
"0.6840308",
"0.6564169",
"0.65074044",
"0.64878964",
"0.6323087",
"0.63063276",
"0.62569153",
"0.62439364",
"0.62393785",
"0.6233699",
"0.61549735",
"0.61510205",
"0.6096451",
"0.6079925",
"0.60510725",
"0.6038506",
"0.603421",
"0.6026597",
"0.59906137",
"0.5988956",
"0.5980... | 0.68233407 | 1 |
Calculate a new offset (in minutes) between the actual and reported times. (This is called whenever the actual time changes.) | def offset
max_range = 2*@wobble + 1
min_offset = @current.to_i/60 - @actual.to_i/60
if @current.nil? || min_offset < -@wobble
range = max_range
else
range = @wobble - min_offset + 1
end
range = max_range if range > max_range
if range == 0
new_offset = 0
else
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_time_offset\n @last_time_offset = Time.now\n @time_offset = official_time - Time.now.localtime \n end",
"def time_offset\n calc_time_offset unless @time_offset\n @time_offset\n end",
"def observed_utc_offset; end",
"def observed_utc_offset; end",
"def observed_utc_offset;... | [
"0.6939158",
"0.6477519",
"0.5994034",
"0.5994034",
"0.5994034",
"0.5994034",
"0.5953575",
"0.5953575",
"0.5953575",
"0.5953575",
"0.58964974",
"0.5870988",
"0.5782431",
"0.57503116",
"0.5717093",
"0.56875604",
"0.56857884",
"0.565775",
"0.56142247",
"0.5610071",
"0.56088024"... | 0.61050624 | 2 |
Report the difference (in minutes) between the reported and actual times. | def error
@current_offset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difference_in_minutes time_one, time_two\n time_one_with_resetted_date = reset_date_for_time time_one\n time_two_with_resetted_date = reset_date_for_time time_two\n (time_one_with_resetted_date - time_two_with_resetted_date) / 60\n end",
"def get_minutes\n de = self.string_to_datetime(@from)\n ... | [
"0.6814957",
"0.6478716",
"0.6416415",
"0.63811576",
"0.62770677",
"0.6270761",
"0.6192533",
"0.6155526",
"0.6130397",
"0.6130397",
"0.60726845",
"0.5990693",
"0.5904441",
"0.5867001",
"0.5811487",
"0.5803625",
"0.5775888",
"0.57384086",
"0.5735429",
"0.57174796",
"0.571501",... | 0.0 | -1 |
Return a string representation of the fuzzy time. The number of digits obscured by tildes is controlled by the 'fuzz' attribute. Whether the time is in 12 or 24hour style is controlled by 'am_pm'. | def to_s
if @am_pm
display = @current.strftime("%I:%M")
else
display = @current.strftime("%H:%M")
end
@fuzz.times { display.sub!(/\d(\D*)$/, '~\1') } if @fuzz > 0
display
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tt(time, format=:short); '13:37'; end",
"def format_time\n hours = format_hour @hour\n minutes = format_minute @minutes\n ampm = @hour < 12 ? @@ampm_hash['a'] : @@ampm_hash['p']\n time = ''\n time += hours[0] + minutes[0] + ' ' + ampm[0] + \"\\n\"\n time += hours[1] + minutes[1] + ' ' + amp... | [
"0.61921513",
"0.6162243",
"0.611953",
"0.5873932",
"0.58328414",
"0.5783139",
"0.5657676",
"0.5596201",
"0.5548182",
"0.5545197",
"0.5540513",
"0.55404687",
"0.5501897",
"0.5477473",
"0.5468284",
"0.54298043",
"0.54213876",
"0.54111123",
"0.54109013",
"0.54001004",
"0.539452... | 0.75954765 | 0 |
has_many :steps, dependent: :destroy | def date_cannot_be_in_the_past
if end_time.present? && end_time < Time.zone.today
errors.add(:end_time, "end_date can't be in the past")
elsif start_time.present? && start_time < Time.zone.today
errors.add(:start_time, "start_date can't be in the past")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @step.destroy\n end",
"def destroy\n @step.destroy\n end",
"def removeline(step, order)\n\t\t#active_steps.find_by(line_id: line.id).destroy\n\t\tactive_steps.find_by(id: step.id).destroy\n\t\t\n\t\t#active_relationships.find_by(followed_id: other_user.id).destroy\n\t\t#steps.find_by(inst... | [
"0.77188003",
"0.77188003",
"0.6782391",
"0.67811334",
"0.66850114",
"0.6595682",
"0.65524447",
"0.65130097",
"0.65130097",
"0.65130097",
"0.65130097",
"0.6506767",
"0.6383365",
"0.6347723",
"0.63402534",
"0.6325402",
"0.6304042",
"0.624405",
"0.622266",
"0.62181664",
"0.6194... | 0.0 | -1 |
This returns the length of a Fixnum as if it were a string. | def split
arr = []
x = self.to_s
y = x.split(//)
y.each do |x|
arr << x.to_i
end
arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_length(num)\r\n num.to_s.length\r\nend",
"def length()\n return to_s.size\n end",
"def get_length(str)\n @str.length.to_i\n end",
"def length\n to_s.length\n end",
"def length\n to_s.length\n end",
"def num_digits\n self.to_s.length\n end",
"def length(str)\n g_u... | [
"0.77050126",
"0.736038",
"0.73442477",
"0.71680677",
"0.71482307",
"0.7137359",
"0.69692475",
"0.68767786",
"0.6859022",
"0.6832901",
"0.68220395",
"0.68163985",
"0.68004185",
"0.6770687",
"0.6764884",
"0.6712595",
"0.6617993",
"0.65969276",
"0.65596217",
"0.6488963",
"0.648... | 0.0 | -1 |
Adds a split method to Fixnum. | def read (integer)
hbasic= {0 => "zero", 1=>"one", 2=>"two", 3=>"three", 4=>"four", 5=>"five", 6=>"six", 7=>"seven", 8=>"eight", 9=>"nine"}
hteen= {10=>"ten",11=>"eleven", 12=>"twelve", 13=>"thirteen", 14=>"fourteen", 15=>"fifteen", 16=>"sixteen", 17=>"seventeen", 18=>"eighteen", 19=>"nineteen"}
hdec= {20=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split\n raise NotImplementedError, \"#{__method__} has to be implemented in #{self.class}.\"\n end",
"def split; end",
"def split(position)\n end",
"def split(position)\n end",
"def split\r\n\t\tarr = []\r\n\t\tx = self.to_s\r\n\t\ty = x.split(//)\r\n\t\ty.each do |x|\r\n\t\t\tarr << x.to... | [
"0.6150165",
"0.6147323",
"0.60488075",
"0.60488075",
"0.5854609",
"0.5854609",
"0.57917523",
"0.5740308",
"0.5704677",
"0.56953216",
"0.5682651",
"0.5622506",
"0.5576179",
"0.5499546",
"0.547575",
"0.54681104",
"0.54529357",
"0.538839",
"0.5387079",
"0.5387079",
"0.5350052",... | 0.0 | -1 |
I will admit I wrote these two methods without testing in my defense I wrote the total_inventory logic first and was in the zone My next step would be to make sure these have a test, or privatize them if I didn't want them in the public interface | def info_for(item)
# Create quantity & trucks hash for this item
{
quantity: quantity_for(item),
food_trucks: food_trucks_that_sell(item.name)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_inventory\n add_to_inventory(\"cats\", 4, 50.0)\n add_to_inventory(\"dogs\", 10, 150.0)\n add_to_inventory(\"unicorn\", 1, 1000.0)\nend",
"def inventory_without_hiting_the_database\n variants.inject(0) {|total, variant| total += variant.inventory}\n end",
"def expected_inventory\n result = ... | [
"0.7134972",
"0.7067449",
"0.6845746",
"0.68051195",
"0.6768251",
"0.6756087",
"0.6682862",
"0.6628565",
"0.6611476",
"0.6608589",
"0.65792495",
"0.6572645",
"0.64360875",
"0.6405933",
"0.63877064",
"0.6382037",
"0.63737863",
"0.63550675",
"0.63388294",
"0.6337921",
"0.633792... | 0.0 | -1 |
POST /orders POST /orders.json | def create
name = params["name"]
email_address = params["email_address"]
shipping_address = params["shipping_address"]
order_details = params["order_details"]
referred_by_id = params["referred_by_id"]
auth_token = params["auth_token"]
@current_user = User.find_by(email_address: email_address)
if @curren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orders\n authenticated_post(\"orders\").body\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def create\n order = Order.create(order_params)\n render json: order\nend",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = ... | [
"0.75886714",
"0.7490972",
"0.7488501",
"0.74664384",
"0.72739846",
"0.7195349",
"0.7063682",
"0.69745994",
"0.6910657",
"0.68880194",
"0.68747663",
"0.685004",
"0.6840204",
"0.6838178",
"0.6838178",
"0.6838178",
"0.6838178",
"0.682244",
"0.6790037",
"0.67793274",
"0.6779247"... | 0.0 | -1 |
DELETE /orders/1 DELETE /orders/1.json | def delete
@order = Order.find_by(id: params["id"])
if @order
if(Time.now > (@order.created_at + 24.hours))
status = "order can't be deleted because its more than 24 hours"
else
email_address = params["email_address"]
auth_token = params["auth_token"]
@user = User.authenticate_user(auth_toke... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @v1_order = V1::Order.find(params[:id])\n @v1_order.destroy\n\n head :no_content\n end",
"def destroy\n @order1 = Order1.find(params[:id])\n @order1.destroy\n\n respond_to do |format|\n format.html { redirect_to order1s_url }\n format.json { head :no_content }\n end\... | [
"0.7592003",
"0.7475092",
"0.74298924",
"0.7371978",
"0.7371411",
"0.7371187",
"0.7357556",
"0.7357556",
"0.7357556",
"0.7357556",
"0.7357556",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_order
@order = Order.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 order_params
params.require(:order).permit(:name, :email_address, :shipping_address, :order_details, :referred_by)
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 |
Provide a default URL as a default if there hasn't been a file uploaded: | def default_url
#"/assets/fallback/" + [version_name, "default.jpg"].compact.join('_')
ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.jpg"].compact.join('_'))
#"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_with_default *args\n unless file_name.nil?\n url_without_default *args\n else\n nil\n end\n end",
"def default_url\n nil\n end",
"def default_url\n end",
"def default_url\n url 'default'\n end",
"def default_url\n file_path = [\n 'fallbacks',\n ... | [
"0.788327",
"0.77585304",
"0.74635595",
"0.7161452",
"0.713886",
"0.7078496",
"0.69854933",
"0.69454616",
"0.6932205",
"0.69272566",
"0.6924041",
"0.6924041",
"0.6924041",
"0.691804",
"0.690665",
"0.6888884",
"0.6869819",
"0.68616575",
"0.68318623",
"0.67751837",
"0.676878",
... | 0.6916976 | 14 |
last_element = array.pop array << word array << last_element array.join(delimiter) end | def joinor(array, delimiter = ', ', word = 'or')
if array.size == 2
array.join(" #{word} ")
else
array[-1] = "#{word} #{array.last}"
array.join(delimiter)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def joiner(arr, delimiter = ', ', word = 'or')\n case arr.size\n when 0 then ''\n when 1 then arr.first\n when 2 then arr.join(\" #{word} \")\n else\n all_but_last = arr[0, arr.length - 1].join(delimiter)\n \"#{all_but_last}#{delimiter}#{word} #{arr[-1]}\"\n end\nend",
"def main_thing(arr, delimiter = \"... | [
"0.7333782",
"0.7259036",
"0.70974034",
"0.6922107",
"0.691095",
"0.68929905",
"0.6865184",
"0.6831651",
"0.6813774",
"0.67779577",
"0.67719805",
"0.6702196",
"0.6698229",
"0.66828257",
"0.66567916",
"0.6607007",
"0.6589456",
"0.65761864",
"0.65759104",
"0.65667766",
"0.65656... | 0.67201 | 11 |
Use callbacks to share common setup or constraints between actions. | def set_game
@game = Game.includes(game_players: %i[force user]).find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def game_params
params.require(:game).permit(:date, :scenario_id, :gamingtime, :turnsplayed, :status, game_players_attrs)
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 |
making this method public so it can be stubbed in tests TODO: find a way to stub without this ugly hack | def current_cart
#ORDER_ID IN PARAMS BECAUSE HAVE EMAIL SEND IN PAST
cart_id_session = session[:cart_id]
cart_id_params = params[:cart_id]
cart_id_legacy = params[:order_id]
cart = @user.carts.find_by_id(cart_id_params) if @user && cart_id_params
cart = @user.carts.find_by_legacy_id(cart_id_le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def private_method\n end",
"def internal; end",
"def private_method; end",
"def implementation; end",
"def implementation; end",
"def public_method; end",
"def stub_implementation; end",
"def wrapper; end",
"def public; end",
"def public; end",
"def custom; end",
"d... | [
"0.78609765",
"0.75109184",
"0.7121607",
"0.6684215",
"0.6657858",
"0.6657858",
"0.6578786",
"0.65536106",
"0.643234",
"0.6430205",
"0.6430205",
"0.63775957",
"0.63775957",
"0.6373064",
"0.63194555",
"0.63194555",
"0.63194555",
"0.63194555",
"0.6297035",
"0.6278842",
"0.62773... | 0.0 | -1 |
Create an Excel file from list of ActiveRecord objects | def export(file_name, export_records, options = {})
@file_name = file_name
records = [*export_records]
if(records.nil? || records.empty?)
logger.warn('Excel Export - No objects supplied for export - no file written')
return
end
first = records[0]
raise ArgumentEr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_xls(items=[])\n\n @excel = ExcelFile.new(items[0].class.name)\n \n @excel.create_row(0)\n \n sheet = @excel.sheet\n\n # header row\n if !items.empty?\n row = sheet.createRow(0)\n cell_index = 0\n items[0].class.columns.each do |column|\n row.createCell(cell_index).se... | [
"0.7089007",
"0.7068868",
"0.66757494",
"0.6543157",
"0.6450813",
"0.63894045",
"0.63889",
"0.6358277",
"0.63366073",
"0.6320836",
"0.63026804",
"0.6299654",
"0.6234919",
"0.62332785",
"0.62241226",
"0.62135905",
"0.6207061",
"0.6191802",
"0.6187767",
"0.6180499",
"0.61797476... | 0.61277086 | 28 |
Create an Excel file from list of ActiveRecord objects, includes relationships Association Options See lib/exporters/configuration.rb | def export_with_associations(file_name, klass, records)
@file_name = file_name
start_excel(klass)
klass_to_headers(klass)
excel.set_headers( headers )
logger.info("Wrote headers for #{klass} to Excel")
row = 1
logger.info("Processing #{records.size} records to Excel")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def export(file, export_records, options = {})\n records = [*export_records]\n\n if records.blank?\n logger.warn('Excel Export - No objects supplied for export - no file written')\n return\n end\n\n first = records[0]\n\n raise(ArgumentError, 'Please supply set of ActiveRecor... | [
"0.6852644",
"0.6641052",
"0.63577855",
"0.63365275",
"0.62115294",
"0.610126",
"0.6072777",
"0.6000019",
"0.59538525",
"0.59535533",
"0.59342545",
"0.5920156",
"0.58987045",
"0.5879501",
"0.58575577",
"0.5848408",
"0.5842732",
"0.5806059",
"0.57885474",
"0.57829905",
"0.5781... | 0.70775646 | 0 |
Can we use this connection to make requests? | def connected?
@stream&.connected?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connection\n response&.request\n end",
"def send_request; end",
"def send_request(req); end",
"def raw_connection; end",
"def test_connection\n args = get_connection_args(\"#{endpoint}/auth\")\n args[:raw_response] = true\n RestClient::Request.execute(args)\n end",
"def conn... | [
"0.6947803",
"0.6917533",
"0.685353",
"0.67585444",
"0.6747857",
"0.6743862",
"0.66307425",
"0.6591077",
"0.65591997",
"0.6543487",
"0.6539431",
"0.6508233",
"0.64929444",
"0.64909476",
"0.6474887",
"0.6442654",
"0.6439342",
"0.6431512",
"0.6421862",
"0.6389346",
"0.6375986",... | 0.0 | -1 |
Generate a cachebusted URL for assets. | def asset_path(url)
"/assets/cb#{settings.cachebust}/#{url}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asset_url(asset_name)\n \"#{@server.base_uri}?sabreAction=asset&assetName=#{URI.escape(asset_name)}\"\n end",
"def asset_path(*args)\n path = args.join('/')\n page = sitemap[path]\n if production?\n raise \"Missing asset #{path}\" if page.blank?\n if page[:digest]... | [
"0.68774104",
"0.68023646",
"0.6760567",
"0.6748008",
"0.6742872",
"0.67002165",
"0.6670256",
"0.66563493",
"0.66256005",
"0.66078407",
"0.6438346",
"0.63860536",
"0.63296807",
"0.6271706",
"0.6270063",
"0.6253906",
"0.624422",
"0.6242689",
"0.62105453",
"0.62105453",
"0.6159... | 0.7740062 | 0 |
interesting solution from others | def prefill(n, v = nil)
Array.new(Integer(n)) { v }
rescue
raise TypeError.new "#{n} is invalid"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def rassoc(p0) end",
"def formation; end",
"def stderrs; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def anchored; end",
"def terpene; end",
"def offences_by; end",
"def trd; end",
"def t... | [
"0.62482184",
"0.5957675",
"0.58776796",
"0.576215",
"0.5721091",
"0.5716223",
"0.5716223",
"0.5716223",
"0.5716223",
"0.56920624",
"0.5691219",
"0.55716074",
"0.5565598",
"0.5528606",
"0.5522915",
"0.55080414",
"0.54648346",
"0.5461733",
"0.5461733",
"0.5439998",
"0.5425927"... | 0.0 | -1 |
Public: Get a node from the database. fqn String Node FQN. Returns a Config::Node or nil. | def get_node(fqn)
@database.all_nodes.find { |node| node.fqn == fqn }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node(fqn)\n node = @nodes.get_node(fqn)\n node if context?(node)\n end",
"def node(name)\n return node_manager.find(name)\n end",
"def node\n datasource.document.xpath(xpath).first\n end",
"def get_node(node)\n return nil unless node[:name]\n\n #Convert the node into a ... | [
"0.6812518",
"0.6435689",
"0.6205249",
"0.615553",
"0.61396146",
"0.6067225",
"0.6067225",
"0.599313",
"0.58189565",
"0.57992065",
"0.5783945",
"0.5759154",
"0.575198",
"0.5735184",
"0.5715589",
"0.5682087",
"0.56692964",
"0.5644733",
"0.56221956",
"0.5578035",
"0.5486671",
... | 0.7800456 | 0 |
Public: Find a single node. args TBD parameters to match against. Returns a Config::Node or nil. Raises AmbiguousNode if more than one node matches the parameters. | def find_node(*args)
nodes = find_all_nodes(*args)
raise AmbiguousNode if nodes.size > 1
nodes.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_node(*args)\n node = @nodes.find_node(*args)\n node if context?(node)\n end",
"def getNode(*args)\n if(args.size == 1)\n return retNode(args[0])\n else\n if (@nodeValues.size > @INDEX)\n tmp = @nodeValues[@INDEX]\n #puts \"----------------\\nSea... | [
"0.7729925",
"0.66392785",
"0.6213542",
"0.60797995",
"0.6029711",
"0.598838",
"0.5976282",
"0.5874443",
"0.5832057",
"0.5767491",
"0.56697685",
"0.56697685",
"0.56496006",
"0.5606872",
"0.5606872",
"0.55864096",
"0.55852926",
"0.55829304",
"0.55613667",
"0.55335826",
"0.5516... | 0.8389867 | 0 |
Public: Find all nodes. args TBD parameters to match against. Returns an Array of Config::Node. | def find_all_nodes(*args)
raise NotImplementedError
nodes = @database.all_nodes
# TODO: design node finder syntax
nodes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_all_nodes(*args)\n nodes = @nodes.find_all_nodes(*args)\n nodes.find_all { |n| context?(n) }\n end",
"def all_nodes\n Pathname.glob(node_file(\"*\", false)).map do |file|\n json = JSON.parse(file.read)\n Config::Node.from_json(json)\n end\n end",
"def find_nodes... | [
"0.7404772",
"0.7389411",
"0.6839918",
"0.6785146",
"0.6609216",
"0.6591435",
"0.65091544",
"0.64172083",
"0.6353767",
"0.63301903",
"0.6288029",
"0.6270759",
"0.62694275",
"0.62661725",
"0.6210207",
"0.6175653",
"0.61745393",
"0.6128293",
"0.6128088",
"0.60814995",
"0.604021... | 0.7865262 | 0 |
Public: Update the stored node data by inspecting the current execution environment. fqn String Node FQN. facts Config::Facts to store for the node. Returns a Config::Node. | def update_node(fqn, facts)
node = get_node(fqn) || Config::Node.from_fqn(fqn)
node.facts = facts
@database.update_node(node)
node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_chef_node\n step(\" updating chef node\", :blue)\n set_chef_node_attributes\n set_chef_node_environment\n sync_ipconfig_attribute\n sync_volume_attributes\n chef_api_server_as_admin.put_rest(\"nodes/#{@chef_node.name}\", @chef_node)\n end",
"def put_facts(name, envir... | [
"0.5171092",
"0.51694244",
"0.51691175",
"0.508585",
"0.4840804",
"0.47761303",
"0.47714087",
"0.4755074",
"0.47305432",
"0.47027215",
"0.46736953",
"0.46606472",
"0.46544036",
"0.4628961",
"0.45963755",
"0.45389354",
"0.44923115",
"0.44707388",
"0.4470614",
"0.44262037",
"0.... | 0.79293877 | 0 |
Public: Remove the node from the database. fqn String Node FQN. Returns nothing. | def remove_node(fqn)
node = get_node(fqn)
@database.remove_node(node) if node
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_node(node)\n return if !node_file(node).exist?\n\n txn do\n @repo.rm node_file(node)\n\n message = \"remove node #{node.fqn}\"\n @repo.commit message\n log << \"Database commit: #{message}\"\n end\n end",
"def remove(node)\n node = node.name if Node =... | [
"0.68582195",
"0.66534835",
"0.6437001",
"0.63138515",
"0.6268418",
"0.61686957",
"0.6165582",
"0.60259145",
"0.59764063",
"0.5829364",
"0.5804213",
"0.5801362",
"0.57687706",
"0.57565874",
"0.5746337",
"0.57030636",
"0.5681752",
"0.5633308",
"0.5613124",
"0.55866504",
"0.556... | 0.81704223 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_bulk_action
@bulk_action = current_user.bulk_actions.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 trusted parameter "white list" through. | def bulk_action_params
params.require(:bulk_action).permit(
:action_type,
:description,
:pids,
manage_release: [:tag, :what, :who, :to],
set_governing_apo: [:new_apo_id],
manage_catkeys: [:catkeys]
)
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 |
add druid: prefix to list of pids if it doesn't have it yet | def pids_with_prefix(pids)
return pids if pids.blank?
pids.split.flatten.map { |pid| pid.start_with?('druid:') ? pid : "druid:#{pid}" }.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_prefix_to(a)\n Kamelopard.id_prefix = a\n end",
"def prepend(prefix)\n lambda do |rec, acc|\n acc.collect! { |v| prefix + v }\n end\n end",
"def prefixed(p)\n condition { env['enron.api.prefix'] == p }\n end",
"def use_prefix\n prefix, @prefix = @prefix, n... | [
"0.66486907",
"0.62304205",
"0.6133131",
"0.60603356",
"0.59852076",
"0.59030616",
"0.576461",
"0.5718094",
"0.56981105",
"0.56930554",
"0.56841123",
"0.56457275",
"0.5605322",
"0.5595173",
"0.55637157",
"0.5556901",
"0.5549506",
"0.5548901",
"0.5530671",
"0.553042",
"0.55243... | 0.78531873 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.