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 |
|---|---|---|---|---|---|---|
DELETE /prioridades/1 DELETE /prioridades/1.json | def destroy
@prioridade = Prioridade.find(params[:id])
@prioridade.destroy
respond_to do |format|
format.html { redirect_to prioridades_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @prioridad.destroy\n respond_to do |format|\n format.html { redirect_to prioridads_url, notice: 'Se ha eliminado la Prioridad.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prioridade_adocao = PrioridadeAdocao.find(params[:id])\n @prioridade_adocao.de... | [
"0.7238399",
"0.7114864",
"0.6559257",
"0.6489752",
"0.64694107",
"0.63929635",
"0.6392403",
"0.63845396",
"0.6342004",
"0.63398266",
"0.63263386",
"0.63185185",
"0.63168615",
"0.6315532",
"0.6315532",
"0.6311681",
"0.63079846",
"0.63011056",
"0.63003945",
"0.62871087",
"0.62... | 0.7494435 | 0 |
Returns a hash with selected header fields. | def options
{
version: @version,
delim: @delim,
randomized: @flags[0],
ordered: @flags[1],
rotated: @flags[2],
comments: @flags[3]
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header_fields\n header.fields\n end",
"def headers\n fields.map(&:name).map(&:to_sym)\n end",
"def headers\n h = {}\n raw.headers_hash.each {|k,v| h[k] = v }\n h\n end",
"def getHeaderFieldNames\n\t\tend",
"def to_hash\n @headers\n end",
"def ... | [
"0.76029897",
"0.7440678",
"0.7068711",
"0.68863803",
"0.68485767",
"0.6643628",
"0.6640296",
"0.6601318",
"0.65462494",
"0.6480545",
"0.64641213",
"0.64422363",
"0.6388955",
"0.6364178",
"0.636414",
"0.6349031",
"0.6341213",
"0.6330138",
"0.63254786",
"0.63105243",
"0.628492... | 0.0 | -1 |
Returns a header. The header consists of six 32bit unsigned integers. Integers are stored in bigendian byte order. The order and meaning of the fields are as follows: [+version+] version number [+numstr+] number of pointers [+longlen+] size of longest fortune [+shortlen+] size of shortest fortune [+flags+] stores multiple booleans (bitfield) [1] randomize order [2] sorting in alphabetical order [4] Caesar encryption [8] allow comments [+delim+] 8bit unsigned integer packed to 32bit which represents a delimeter character | def header_fields
IO.binread(@path, HEADER_SIZE, 0).unpack("N5C1")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header\n @sfntVersion, @numTables, *rest = @bytes[0, 4 + 2 + 2 + 2 + 2].unpack('Nnnnn')\n end",
"def header_for_string string\n header = string.length << 1 # make room for a low bit of 1\n header = header | 1 # set the low bit to 1\n pack_int header\n end",
"def packed()\n ... | [
"0.7577788",
"0.7355922",
"0.6988792",
"0.6936034",
"0.6903621",
"0.6896628",
"0.68669695",
"0.6850049",
"0.68225014",
"0.67953503",
"0.6762603",
"0.66968715",
"0.65758455",
"0.6489688",
"0.6478887",
"0.6450188",
"0.64365697",
"0.6431695",
"0.63790965",
"0.63444895",
"0.62918... | 0.7280266 | 2 |
Returns a pointer from a certain position. | def get_pointer_at(index)
IO.binread(@path, POINTER_SIZE, HEADER_SIZE + POINTER_SIZE * index).unpack("N").first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def at(pos)\n pos = pos.to_int\n\n if 0 <= pos && !has_size?\n return read_access(pos)\n elsif 0 <= pos && pos < size\n return read_access(pos)\n elsif -size <= pos && pos < 0\n return read_access(size + pos)\n else\n return nil\n end\n end",
"def at(position)\n self[pos... | [
"0.6970928",
"0.6819975",
"0.66309315",
"0.6619104",
"0.6619104",
"0.64606345",
"0.63734245",
"0.6283717",
"0.6283717",
"0.6274268",
"0.62027806",
"0.6160391",
"0.6130122",
"0.604367",
"0.6026829",
"0.60121626",
"0.599911",
"0.59691626",
"0.5967498",
"0.596382",
"0.5949572",
... | 0.717713 | 0 |
before_filter :redirect_unless_admin, :except => [:destroy] | def index
@users = User.paginate(:per_page => 9, :page => params[:page], :order => 'created_at DESC')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_required\n redirect_to(\"/\") unless admin?\n end",
"def redirect_unless_admin\n redirect_to root_path unless current_user && current_user.admin?\n end",
"def restrictToAdmin! ; redirect to('/login'),303 unless admin? ; end",
"def require_admin\n unless view_context.admin?\n redirec... | [
"0.78114533",
"0.7809175",
"0.7726401",
"0.7714722",
"0.7624823",
"0.7536182",
"0.7533477",
"0.75055194",
"0.7386417",
"0.7371928",
"0.7367805",
"0.73637325",
"0.7358599",
"0.7354418",
"0.73437166",
"0.731265",
"0.7302716",
"0.7285374",
"0.7285374",
"0.72819865",
"0.7280039",... | 0.0 | -1 |
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms. In DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". You have function with one side of the DNA (string, except for Haskell); you need to get the other complementary side. DNA strand is never empty or there is no DNA at all (again, except for Haskell). DNA_strand ("ATTGC") return "TAACG" DNA_strand ("GTAT") return "CATA" | def DNA_strand(dna)
new_dna = ""
dna.each_char do |letter|
if letter == "A"
new_dna += "T"
elsif letter == "T"
new_dna += "A"
elsif letter == "C"
new_dna += "G"
elsif letter == "G"
new_dna += "C"
else
new_dna += letter
end
end
return new_dna
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DNA_strand(dna)\n arr = dna.split(//)\n another_arr = Array.new\n arr.each do |chr|\n case chr\n when \"A\"\n another_arr << \"T\"\n when \"T\"\n another_arr << \"A\"\n when \"C\"\n another_arr << \"G\"\n else\n another_arr << \"C\"\n end\n end\n \"Str... | [
"0.8217318",
"0.8165577",
"0.8039898",
"0.8033274",
"0.77156717",
"0.7475059",
"0.7097327",
"0.68559027",
"0.6777053",
"0.63311213",
"0.6179472",
"0.6169128",
"0.60611296",
"0.60525054",
"0.6024831",
"0.5999893",
"0.5912713",
"0.59122306",
"0.58293104",
"0.57746375",
"0.57452... | 0.8098095 | 2 |
DELETE /asignacions/1 DELETE /asignacions/1.xml | def destroy
@asignacionexa = Asignacionlabexa.find(params[:id])
@asignacionexa.destroy
respond_to do |format|
format.html { redirect_to(asignacionlabexas_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\r\n @asignacion = Asignacion.find(params[:id])\r\n @asignacion.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(asignacions_url) }\r\n format.xml { head :ok }\r\n end\r\n end",
"def destroy\n @correspondenciasasignada = Correspondenciasasignada.find(para... | [
"0.7131648",
"0.67933595",
"0.6673514",
"0.6633145",
"0.6617581",
"0.6615463",
"0.6613866",
"0.655674",
"0.65266186",
"0.6502938",
"0.646792",
"0.64372283",
"0.64339435",
"0.6392215",
"0.6372797",
"0.6368019",
"0.63528043",
"0.634449",
"0.63436955",
"0.63310266",
"0.63171494"... | 0.67171013 | 2 |
def tool_params params.permit(:tool_name) end | def tool_obits
params.require(:id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tool_params\n params.require(:tool).permit(\n :name,\n :slug,\n :type,\n :description,\n :source_url,\n :instructions,\n :up_for_adoption\n )\n end",
"def tool_params\n params.require(:tool).permit(:name, :language, :json_spec)\n end",
"def tool_params\n p... | [
"0.8913012",
"0.8863078",
"0.8719983",
"0.8698839",
"0.8627929",
"0.86091584",
"0.860656",
"0.85701895",
"0.83607966",
"0.8262755",
"0.8232917",
"0.74913794",
"0.74469185",
"0.72768396",
"0.7129551",
"0.71281147",
"0.70993614",
"0.7036273",
"0.7013189",
"0.6950364",
"0.694838... | 0.67549044 | 28 |
puts instance_variables send :attr_reader, instance_variables | def initialize args
index = 0
puts args
#iterates through all the instance variables declared at the time
#of class creation and sets
self.class.instance_variables.each do |instance_variable|
#To set instance_variable as per new object values
self.class.instance_variable_set( "#{ instance_variable}", args[ index ] )
#To get value of class_variable i.e. returns array
class_variable_array = self.class.class_variable_get( "@#{ instance_variable }" )
#To push new args value into class variable
self.class.class_variable_set( "@#{ instance_variable }", class_variable_array.push( "#{ args[ index ] }" ) )
index += 1
end
puts self.is_a? Sourcedetails
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_variables() end",
"def instance_variables; end",
"def inspect\n instance_variables.each_with_object([\n \"\\n#<#{self.class}:0x#{object_id.to_s(16)}>\",\n \"\\tInstance variables:\"\n ]) do |item, result|\n result << \"\\t\\t#{item} = #{instance_variable_get(item)}\"... | [
"0.748733",
"0.7472346",
"0.7401862",
"0.7135171",
"0.7009385",
"0.7009385",
"0.6978225",
"0.6968471",
"0.6893099",
"0.6837483",
"0.6822872",
"0.6815532",
"0.6725305",
"0.6725305",
"0.6651798",
"0.659805",
"0.659805",
"0.6589626",
"0.6528915",
"0.64905286",
"0.64892375",
"0... | 0.0 | -1 |
generate upper quartile value | def upper_quartile
return nil if self.empty?
sorted_array = self.sort
u = (0.25*(3*sorted_array.length))
if (u-u.truncate).is_a?(Integer)
return sorted_array[(u-u.truncate)-1]
else
sample = sorted_array[u.truncate.abs-1]
sample1 = sorted_array[(u.truncate.abs)]
return sample+((sample1-sample)*(u-u.truncate))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upperQuartile(node)\n\t\t# Max humidity value from the node in the past day\n\t\tmax_hum = Reading.select(:humidty, :recorded_at).where(node_id: node, recorded_at: Time.zone.now.beginning_of_day..Time.zone.now.end_of_day).maximum(:humidity)\n\t\t# Max temperature value from the node in the past day\n\t\tmax_te... | [
"0.76547885",
"0.75556237",
"0.74556005",
"0.73508096",
"0.72094834",
"0.71289724",
"0.69251245",
"0.68558437",
"0.68357986",
"0.6714768",
"0.6644293",
"0.6552409",
"0.6528319",
"0.65141267",
"0.64158475",
"0.6297665",
"0.6293136",
"0.6206528",
"0.6144667",
"0.6133184",
"0.58... | 0.8381107 | 0 |
generate lower quartile value | def lower_quartile
return nil if self.empty?
sorted_array = self.sort
u = 0.25*sorted_array.length + 1
if (u-u.truncate).is_a?(Integer)
return sorted_array[(u-u.truncate)-1]
else
sample = sorted_array[u.truncate.abs-1]
sample1 = sorted_array[(u.truncate.abs)]
return sample+((sample1-sample)*(u-u.truncate))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = (0.25*(3*sorted_array.length))\n if (u-u.truncate).is_a?(Integer)\n return sorted_array[(u-u.truncate)-1]\n else\n sample = sorted_array[u.truncate.abs-1]\n sample1 = sorted_array[(u.truncate.abs)]\n ... | [
"0.7934418",
"0.73654604",
"0.72243565",
"0.7124244",
"0.71010566",
"0.70272595",
"0.6925963",
"0.6925916",
"0.68456227",
"0.68196166",
"0.68000853",
"0.65981805",
"0.6504334",
"0.64692694",
"0.6363976",
"0.63264924",
"0.6234617",
"0.6131828",
"0.6009446",
"0.6008697",
"0.584... | 0.8052058 | 0 |
tabulate elements and frequencies of an Enumerable return [Hash] return a hash of :element => :freq_count | def count_freq
hash = Hash.new(0)
self.each do |element|
hash[element] +=1
end
return hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_frequency_count\n collection.each_with_object(Hash.new(0)) {|element, occurrence| occurrence[element] += 1}\n end",
"def frequencies\n inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n end",
"def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n ... | [
"0.78163415",
"0.73577553",
"0.71876377",
"0.7151512",
"0.70271146",
"0.69654363",
"0.67742014",
"0.6757071",
"0.6754002",
"0.6748162",
"0.67333263",
"0.6732251",
"0.67198086",
"0.65939933",
"0.6572978",
"0.65581775",
"0.6548955",
"0.6539481",
"0.6493705",
"0.64782935",
"0.64... | 0.80565524 | 0 |
Process for moving any binders | def moveitem
errors = []
@binder = Binder.find(params[:id])
if params[:target] != params[:id]
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
@binder.sift_siblings()
@inherited = inherit_from(params[:target])
@parenthash = @inherited[:parenthash]
@parentsarr = @inherited[:parentsarr]
@parentperarr = @inherited[:parentperarr]
@parent_child_count = @inherited[:parent_child_count]
#nps = new parents, ops = old parents
@nps = @parentsarr.collect {|x| x["id"] || x[:id]}
if !@nps.include?(params[:id])
@ops = @binder.parents.collect {|x| x["id"] || x[:id]}
@ops.each do |opid|
if opid != "0"
op = Binder.find(opid)
op.update_attributes( :owned_fork_total => op.owned_fork_total - (@binder.fork_total+@binder.owned_fork_total),
:files => op.files - @binder.files,
:folders => op.folders - @binder.folders - (@binder.type == 1 ? 1 : 0),
:total_size => op.total_size - @binder.total_size,
:pub_size => op.pub_size - @binder.pub_size,
:priv_size => op.priv_size - @binder.priv_size)
end
end
#Binder.find(op.last).inc(:children,-1)
# DELAYTAG
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@binder.parent["id"] || @binder.parent[:id])
#Save old permissions to remove childrens' inherited permissions
@ppers = @binder.parent_permissions
@binder.update_attributes( :parent => @parenthash,
:parents => @parentsarr,
:parent_permissions => @parentperarr,
:order_index => @parent_child_count)
# DELAYTAG
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@binder.parent["id"] || @binder.parent[:id])
# must update the common ancestor of the children before
@binder.update_parent_tags()
#@binder is the object being moved
#If directory, deal with the children
if @binder.type == 1 #Eventually will apply to type == 3 too
@children = @binder.subtree
@children.each do |h|
@current_parents = h.parents
@size = @current_parents.size
@npperarr = h.parent_permissions
@ppers.each {|p| @npperarr.delete(p)}
h.update_attributes(:parents => @parentsarr + @current_parents[(@current_parents.index({"id" => @binder.id.to_s, "title" => @binder.title}))..(@size - 1)],
:parent_permissions => @parentperarr + @npperarr)
h.update_parent_tags()
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
end
end
#Update new parents' folder/file/size counts
@parents = @binder.parents.collect {|x| x["id"] || x[:id]}
@parents.each do |pid|
if pid != "0"
parent = Binder.find(pid)
parent.update_attributes( :owned_fork_total => parent.owned_fork_total + (@binder.fork_total+@binder.owned_fork_total),
:files => parent.files + @binder.files,
:folders => parent.folders + @binder.folders + (@binder.type == 1 ? 1 : 0),
:total_size => parent.total_size + @binder.total_size,
:pub_size => parent.pub_size + @binder.pub_size,
:priv_size => parent.priv_size + @binder.priv_size)
end
end
else
errors << "Invalid target location"
end
else
errors << "You cannot put something inside itself"
end
rescue BSON::InvalidObjectId
errors << "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
errors << "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => errors.empty? ? 1 : errors.map{|err| "<li>#{err}</li>"}.join.html_safe}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_moves\n @delta[:moves].each do |move| process_move(move) end\n end",
"def move\n super\n gravitize\n end",
"def apply\n\t\tunless @already_added\n\t\t\t@space.entities.add @clone\n\t\t\t@already_added = true\n\t\tend\n\t\t\n\t\t@move_action.apply\n\tend",
"def move; end... | [
"0.580114",
"0.57578623",
"0.57086825",
"0.5699426",
"0.5699426",
"0.5660415",
"0.56019205",
"0.5526858",
"0.54920816",
"0.5490215",
"0.547453",
"0.54599464",
"0.5456849",
"0.54387",
"0.54387",
"0.54183704",
"0.5387154",
"0.5384284",
"0.5384211",
"0.5324632",
"0.5316352",
"... | 0.5851964 | 0 |
Copy Binders to new location | def copyitem
errors = []
@binder = Binder.find(params[:id])
@inherited = inherit_from(params[:folid])
@parenthash = @inherited[:parenthash]
@parentsarr = @inherited[:parentsarr]
@parentperarr = @inherited[:parentperarr]
# src = Mongo.log(current_teacher.id.to_s,
# __method__.to_s,
# params[:controller].to_s,
# @binder.id.to_s,
# params)
if @inherited[:parent].get_access(current_teacher.id.to_s) == 2
# fork will only be set if there is a teacher id mismatch
fav = !params[:favorite].nil?
fork = @inherited[:parent].owner != @binder.owner
@parent_child_count = @inherited[:parent_child_count]
@ppers = @binder.parent_permissions
@new_parent = Binder.new( :title => @binder.title,
:body => @binder.body,
:type => @binder.type,
:format => @binder.type == 2 ? @binder.format : nil,
:files => @binder.files,
:folders => @binder.folders,
:forked_from => fork ? @binder.id.to_s : nil,
:fork_stamp => fork ? Time.now.to_i : nil,
:total_size => @binder.total_size,
:fav_total => @binder.fav_total,
:pub_size => @binder.pub_size,
:priv_size => @binder.priv_size,
:order_index => @parent_child_count,
:parent => (fav ? { 'id'=>'-2', 'title'=>'' } : @parenthash),#@parenthash,
:parents => (fav ? [{ 'id'=>'-2', 'title'=>'' }] : @parentsarr),#@parentsarr,
:permissions => (fav ? [{"type"=>3, "auth_level"=>1}] : @binder.permissions),#@binder.permissions,
:parent_permissions => (fav ? [] : @parentperarr),#@parentperarr,
:owner => current_teacher.id,
:username => current_teacher.username,
:fname => current_teacher.fname,
:lname => current_teacher.lname,
:last_update => Time.now.to_i,
:last_updated_by => current_teacher.id,
:thumbimgids => @binder.thumbimgids)
#@new_parent.format = @binder.format if @binder.type == 2
# @new_parent.versions << Version.new(:owner => @binder.current_version.owner,
# :file_hash => @binder.current_version.file_hash,
# :timestamp => @binder.current_version.timestamp,
# :remote_imgfile_url => @binder.current_version.imgfile.url.to_s,
# :size => @binder.current_version.size,
# :ext => @binder.current_version.ext,
# :data => @binder.current_version.data,
# :croc_uuid => @binder.current_version.croc_uuid,
# :remote_file_url => @binder.format == 1 ? @binder.current_version.file.url.to_s : nil) if @binder.type == 2
@new_parent.versions << @binder.current_version
#TODO: copy related images?
if @new_parent.save
# due to shared functionality, define method var
if fav
method = "favorite"
@binder.inc(:fav_total, 1)
elsif fork
method = "forkitem"
# fork_total is
@binder.inc(:fork_total, 1)
Binder.delay(:queue => "email").sendforkemail(@binder.id.to_s, @new_parent.id.to_s)
# cascade upwards
@binder.parents.each do |f|
Binder.find(f['id'].to_s).inc(:owned_fork_total,1) if f['id'].to_i>0
end
else
method = __method__.to_s
end
src = Mongo.log(current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
Mongo.log( current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
@new_parent.id.to_s,
params,
{ :copy => @binder.id.to_s, :src => src })
@new_parent.tag = Tag.new( :node_tags => @binder.tag.node_tags)
@new_parent.update_parent_tags()
#Hash table for oldid => newid lookups
@hash_index = {params[:id] => @new_parent.id.to_s}
#If directory, deal with the children
if @binder.type == 1 #Eventually will apply to type == 3 too
@index = @binder.parents.length
#Select old children, order by parents.length
@children = @binder.subtree.sort_by {|binder| binder.parents.length}.reject{|binder| binder.id == @new_parent.id}
#Spawn new children, These children need to have updated parent ids
@children.each do |h|
Mongo.log( current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
@node_parent = {"id" => @hash_index[h.parent["id"]],
"title" => h.parent["title"]}
@node_parents = Binder.find(@hash_index[h.parent["id"]]).parents << @node_parent
@old_permissions = h.parent_permissions
@ppers.each {|p| @old_permissions.delete(p)}
#Swap old folder ids with new folder ids
@old_permissions.each {|op| op["folder_id"] = @hash_index[op["folder_id"]]}
h.inc(:fork_total, 1) if fork
@new_node = Binder.new( :title => h.title,
:body => h.body,
:parent => @node_parent,
:parents => fav ? [{ 'id'=>'-2', 'title'=>'' }] + (h.parents - {'id'=>'0','title'=>''}) : @node_parents,
:permissions => fav ? [] : h.permissions,
:parent_permissions => fav ? @parentperarr : @parentperarr + @old_permissions,
:owner => current_teacher.id,
:username => current_teacher.username,
:fname => current_teacher.fname,
:lname => current_teacher.lname,
:last_update => Time.now.to_i,
:last_updated_by => current_teacher.id,
:type => h.type,
:format => (h.type != 1 ? h.format : nil),
:files => h.files,
:folders => h.folders,
:forked_from => fork ? h.id.to_s : nil,
:fork_stamp => fork ? Time.now.to_i : nil,
:total_size => h.total_size,
:pub_size => h.pub_size,
:priv_size => h.priv_size,
:fav_total => h.fav_total,
:thumbimgids => @binder.thumbimgids,)
# @new_node.versions << Version.new( :owner => h.current_version.owner,
# :file_hash => h.current_version.file_hash,
# :timestamp => h.current_version.timestamp,
# :size => h.current_version.size,
# :ext => h.current_version.ext,
# :data => h.current_version.data,
# :croc_uuid => h.current_version.croc_uuid,
# :imgfile => h.current_version.imgfile,
# :file => h.format == 1 ? h.current_version.file : nil) if h.type == 2
@new_node.versions << h.current_version
#TODO: copy related images?
@new_node.save
Mongo.log( current_teacher.id.to_s,
method.to_s,
params[:controller].to_s,
@new_node.id.to_s,
params,
{ :copy => h.id.to_s, :src => src })
@new_node.tag = Tag.new(:node_tags => h.tag.node_tags)
@new_node.update_parent_tags()
@hash_index[h.id.to_s] = @new_node.id.to_s
end
end
#Update parents' folder/file/size counts
@parents = @new_parent.parents.collect {|x| x["id"] || x[:id]}
@parents.each do |pid|
if pid != "0"
parent = Binder.find(pid)
parent.update_attributes( :files => parent.files + @new_parent.files,
:folders => parent.folders + @new_parent.folders + (@new_parent.type == 1 ? 1 : 0),
:total_size => parent.total_size + @new_parent.total_size,
:pub_size => parent.pub_size + @new_parent.pub_size,
:priv_size => parent.priv_size + @new_parent.priv_size)
end
end
# DELAYTAG
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@new_parent.id)
else
end
else
errors << "You do not have permissions to write to #{@inherited[:parent].title}"
end
rescue BSON::InvalidObjectId
errors << "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
errors << "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => errors.empty? ? 1 : errors.map{|err| "<li>#{err}</li>"}.join.html_safe}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rebind(coordination_model)\n dup\n end",
"def copy\n \n end",
"def deep_copy(new_attributes = {})\n self.class.transaction do\n dup.tap do |blueprint|\n # TODO: there may be other attributes that need to be reset for the new template\n new_attribu... | [
"0.54650736",
"0.5182333",
"0.51592016",
"0.5135206",
"0.5121529",
"0.5023077",
"0.49406013",
"0.49390417",
"0.49344847",
"0.49185508",
"0.49127588",
"0.4889434",
"0.4880044",
"0.48425445",
"0.48312765",
"0.4800621",
"0.47974578",
"0.47799206",
"0.47649682",
"0.47580552",
"0.... | 0.48131093 | 15 |
This is so nasty. | def setpub
error = ""
@binder = Binder.find(params[:id])
# read/write access
if @binder.get_access(current_teacher.id.to_s) == 2
# check if parent binder has any type 3 permissions
if @binder.parent_permissions.find {|p| p["type"] == 3}.nil?
if @binder.permissions.find {|p| p["type"] == 3}.nil?
# this binder has no existing type 3 permissions, inherit!
@binder.permissions << {:type => 3,
:auth_level => params[:enabled] == "true" ? 1 : 0}
@binder.save
else
# set this binder's permissions
@binder.permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
end
if params[:enabled]=="true"
@binder.pub_size = @binder.pub_size + @binder.priv_size
@binder.priv_size = 0
else
@binder.priv_size = @binder.priv_size + @binder.pub_size
@binder.pub_size = 0
end
@binder.save
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
# deal with the naughty children
@binder.subtree.each do |h|
h.permissions.find{|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0 if !h.permissions.find{|p| p["type"] == 3}.nil?
if h.parent_permissions.find {|p| p["type"] == 3}.nil?
h.parent_permissions << { :type => 3,
:folder_id => params[:id],
:auth_level => params[:enabled] == "true" ? 1 : 0}
else
h.parent_permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
h.parent_permissions.find {|p| p["type"] == 3}["folder_id"] = params[:id]
end
if params[:enabled]=="true"
h.pub_size = h.pub_size + h.priv_size
current_teacher.pub_size += h.priv_size
h.priv_size = 0
else
h.priv_size = h.priv_size + h.pub_size
current_teacher.priv_size += h.pub_size
h.pub_size = 0
end
current_teacher.save
h.save
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
end
else
if @binder.parent_permissions.find {|p| p["type"] == 3}["auth_level"] == 1 && params[:enabled] == "false"
error = "Oops! The parent is currently shared."
else
if @binder.permissions.find {|p| p["type"] == 3}.nil?
@binder.permissions << {:type => 3,
:auth_level => params[:enabled] == "true" ? 1 : 0}
#@binder.save
else
@binder.permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
#@binder.save
end
if params[:enabled]=="true"
@binder.pub_size = @binder.pub_size + @binder.priv_size
@binder.priv_size = 0
@binder.parents.each do |f|
if f['id'].to_s!='0'
g = Binder.find(f['id'].to_s)
g.update_attributes(:pub_size => g.pub_size + @binder.priv_size,
:priv_size => 0)
end
end
else
@binder.priv_size = @binder.priv_size + @binder.pub_size
@binder.pub_size = 0
@binder.parents.each do |f|
if f['id'].to_s!='0'
g = Binder.find(f['id'].to_s)
g.update_attributes(:pub_size => 0,
:priv_size => g.priv_size + @binder.pub_size)
end
end
end
@binder.save
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
# take care of the naughty children
@binder.subtree.each do |h|
h.permissions.find{|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0 if !h.permissions.find{|p| p["type"] == 3}.nil?
if h.parent_permissions.find {|p| p["type"] == 3}.nil?
h.parent_permissions << { :type => 3,
:folder_id => params[:id],
:auth_level => params[:enabled] == "true" ? 1 : 0}
#h.save
else
h.parent_permissions.find {|p| p["type"] == 3}["auth_level"] = params[:enabled] == "true" ? 1 : 0
h.parent_permissions.find {|p| p["type"] == 3}["folder_id"] = params[:id]
#h.save
end
if params[:enabled]=="true"
h.pub_size = h.pub_size + h.priv_size
current_teacher.pub_size += h.priv_size
h.priv_size = 0
else
h.priv_size = h.priv_size + h.pub_size
current_teacher.priv_size += h.pub_size
h.pub_size = 0
end
current_teacher.save
h.save
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
h.id.to_s,
params,
{ :src => src })
end
end
end
else
error = "You are not allowed to change permissions on this item."
end
rescue BSON::InvalidObjectId
error = "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
error = "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => error.empty? ? 1 : error}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def anchored; end",
"def terpene; end",
"def berlioz; end",
"def suivre; end",
"def escaper=(_); end",
"def internal; end",
"def escaper; end",
"def p... | [
"0.7315698",
"0.6497994",
"0.62598854",
"0.6170922",
"0.6170922",
"0.6170922",
"0.6170922",
"0.5990019",
"0.5853454",
"0.5850553",
"0.58309746",
"0.5818816",
"0.5759156",
"0.56814903",
"0.5675477",
"0.5664375",
"0.5664375",
"0.5656127",
"0.5646239",
"0.56439847",
"0.5617267",... | 0.0 | -1 |
More validation needed, Permissions | def destroy
#debugger
errors = []
@binder = Binder.find(params[:id])
if @binder.get_access(current_teacher.id.to_s == 2)
# preserve parent ID before writing over
@parentid = @binder.parent["id"]
@binder.sift_siblings()
@parenthash = { :id => "-1",
:title => ""}
@parentsarr = [@parenthash]
#OP = Original Parent
if @binder.parent["id"] != "0"
@op = Binder.find(@binder.parent["id"])
@op.update_attributes( :owned_fork_total => @op.owned_fork_total - (@binder.fork_total+@binder.owned_fork_total),
:files => @op.files - @binder.files,
:folders => @op.folders - @binder.folders - (@binder.type == 1 ? 1 : 0),
:total_size => @op.total_size - @binder.total_size,
:pub_size => @op.pub_size - @binder.pub_size,
:priv_size => @op.priv_size - @binder.priv_size)
end
@binder.update_attributes( :parent => @parenthash,
:parents => @parentsarr)
src = Mongo.log(current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params)
#If directory, deal with the children
if @binder.type == 1 #Eventually will apply to type == 3 too
@binder.subtree.each do |h|
@current_parents = h.parents
@size = @current_parents.size
h.update_attributes(:parents => @parentsarr + @current_parents[(@current_parents.index({"id" => @binder.id.to_s, "title" => @binder.title}))..(@size - 1)])
Mongo.log( current_teacher.id.to_s,
__method__.to_s,
params[:controller].to_s,
@binder.id.to_s,
params,
{ :src => src })
end
end
@parents = @binder.parents.collect {|x| x["id"] || x[:id]}
@parents.each do |pid|
if pid != "-1"
parent = Binder.find(pid)
parent.update_attributes( :owned_fork_total => parent.owned_fork_total + (@binder.fork_total+@binder.owned_fork_total),
:files => parent.files + @binder.files,
:folders => parent.folders + @binder.folders + (@binder.type == 1 ? 1 : 0),
:total_size => parent.total_size + @binder.total_size,
:pub_size => parent.pub_size + @binder.pub_size,
:priv_size => parent.priv_size + @binder.priv_size)
end
end
current_teacher.total_size -= @binder.total_size
current_teacher.pub_size -= @binder.total_size if @binder.is_pub?
current_teacher.priv_size -= @binder.total_size unless @binder.is_pub?
current_teacher.save
Rails.logger.debug "generating parent "
Binder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@parentid)
else
errors << "You do not have permissions to delete this item"
end
rescue BSON::InvalidObjectId
errors << "Invalid Request"
rescue Mongoid::Errors::DocumentNotFound
errors << "Invalid Request"
ensure
respond_to do |format|
format.html {render :text => errors.empty? ? 1 : errors.map{|err| "<li>#{err}</li>"}.join.html_safe}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permissions = {}",
"def permitted?; end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def validate_permission\... | [
"0.74618053",
"0.73894244",
"0.7288124",
"0.7288124",
"0.7288124",
"0.67968214",
"0.67613757",
"0.675405",
"0.66822386",
"0.66687113",
"0.66521305",
"0.6628175",
"0.6606342",
"0.65824926",
"0.65687776",
"0.6541755",
"0.65338206",
"0.65215003",
"0.65164065",
"0.65154886",
"0.6... | 0.0 | -1 |
Because named_binder_route can accept an id or object, so can this check | def binder_routing_ok?(binder, action)
return request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_named_route?(name); end",
"def named_route; end",
"def has_named_route?(name)\n @set.named_routes.key?(name)\n end",
"def route_for(name, *args); end",
"def is_route?\n self.object_type.downcase.to_s == \"route\"\n end",
"def named?\n id.kind_of?(String)\n end",
"def... | [
"0.6605092",
"0.6031678",
"0.57937485",
"0.5731123",
"0.5641658",
"0.55204034",
"0.5489443",
"0.54461247",
"0.54316014",
"0.53647286",
"0.5362761",
"0.53321683",
"0.5304792",
"0.5274534",
"0.5248143",
"0.52430207",
"0.52430207",
"0.5232731",
"0.521501",
"0.5214525",
"0.521433... | 0.60411155 | 1 |
Function that returns routing given a binder object and action Only works for routes in the format of: /username/portfolio(/root)/title/id/action(s) Binder objects preferred over ids | def named_binder_route(binder, action = "show")
if binder.class == Binder
retstr = "/#{binder.handle}/portfolio"
if binder.parents.length != 1
retstr += "/#{CGI.escape(binder.root.gsub(" ", "-"))}"
end
retstr += "/#{CGI.escape(binder.title.gsub(" ", "-"))}/#{binder.id}"
if action != "show"
retstr += "/#{action}"
end
return retstr
elsif binder.class == String
return named_binder_route(Binder.find(binder), action)
else
return "/500.html"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binder_routing_ok?(binder, action)\n\n\t\treturn request.path[0..named_binder_route(binder, action).size - 1] == named_binder_route(binder, action)\n\n\tend",
"def action_routes action\n request_methods, route = REQUEST_METHODS, action.to_s\n REQUEST_METHODS.each do |m|\n regex = /\\A#{m}_/i\n ... | [
"0.65662134",
"0.6253663",
"0.5874944",
"0.5801643",
"0.5786832",
"0.5749082",
"0.5690723",
"0.5687544",
"0.5634518",
"0.5545291",
"0.55431104",
"0.54987216",
"0.54775435",
"0.54440445",
"0.543826",
"0.543826",
"0.54113626",
"0.5399569",
"0.53967315",
"0.53641367",
"0.5351828... | 0.76712173 | 0 |
add_product_to_order will call create_new_order by customer_id & add_product_to_order if statement for if order exists | def set_field
begin
gets.chomp
rescue SQLite3::Exception => e
p "Exception with set_field: #{e}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_current_order\n\n # get the first open order that the user has\n if current_user.orders.where(status:'Open').first\n current_order = current_user.orders.where(status:'Open').first\n OrderProduct.create({product_id: params[:product],order_id: current_order.id, quantity: params[:order][:or... | [
"0.7470572",
"0.73386693",
"0.714265",
"0.7056163",
"0.70298576",
"0.7024725",
"0.6956932",
"0.68955153",
"0.6814597",
"0.6795522",
"0.67782307",
"0.6738268",
"0.6735118",
"0.6676987",
"0.66629946",
"0.6601308",
"0.658048",
"0.6579002",
"0.6565726",
"0.65618026",
"0.65595996"... | 0.0 | -1 |
complete order would there be an order with no products??????? | def complete_customer_order
# call the get_customer_order with product price sum
customer_order_total = Order.new.get_customer_order(CustomersController.get_active_customer)
if get_customer_order.length == 0
puts "You have no products on your order. Please press any key to return to the main menu"
# if no products in order print "Please add some products to your order first. Press any key to return to main menu."
else
# display order total and "continue with the order? y/n"
puts "Ready to purchase? (Y/N)"
@add_payment_to_order = set_field
# add_payment_to_order
puts "Please select a payment type:"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty?\n order_items.empty?\n end",
"def empty?\n order_items.empty?\n end",
"def incomplete_products\n return self.products.select do |product|\n !product.passing? && !product.failing?\n end\n end",
"def test_empty\n order = orders(:santa_next_christmas_order)\n assert ... | [
"0.7015277",
"0.7015277",
"0.6753205",
"0.6693969",
"0.6429757",
"0.6401549",
"0.6401493",
"0.63852507",
"0.629773",
"0.6275499",
"0.61900157",
"0.6185921",
"0.61281693",
"0.61037266",
"0.60712636",
"0.606667",
"0.6059033",
"0.6035542",
"0.6034695",
"0.6033788",
"0.6031985",
... | 0.64728856 | 4 |
Fired when a client is connected. | def on_message(msg); @parent.on_message(@env, msg); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_client_connect(client)\n end",
"def client_connected\n end",
"def on_connected\n end",
"def on_connect(socket)\n Utils.logger.info(\"[Client Connected: #{socket.inspect}]\")\n end",
"def on_connect_event(ctx)\n logger.debug(\"Client connect from #{ctx[:server][:remote_ip]}:#{ctx[:server][... | [
"0.8019362",
"0.7960757",
"0.76705307",
"0.7568223",
"0.7376992",
"0.7271038",
"0.7113182",
"0.70947725",
"0.70002866",
"0.6959558",
"0.68677276",
"0.682789",
"0.6827336",
"0.6823648",
"0.6761378",
"0.6718987",
"0.6711217",
"0.6686068",
"0.66635996",
"0.6645629",
"0.66000336"... | 0.0 | -1 |
Fired when a message from a client is received. | def on_close; @parent.on_close(@env); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_message client, data\n controller(client).on_message(data)\n end",
"def message_received(client, msg)\n content = JSON.parse msg.data\n\n kind = content['type'] || 'empty message'\n\n OutputLogger.logger.info \"Received a message of the #{kind} type.\"\n OutputLogger.logge... | [
"0.7980777",
"0.7830214",
"0.7153363",
"0.71166396",
"0.70058095",
"0.7004378",
"0.699422",
"0.69365674",
"0.693363",
"0.6925809",
"0.6923524",
"0.691046",
"0.6851135",
"0.6838108",
"0.67898184",
"0.67717254",
"0.675263",
"0.67518604",
"0.67455953",
"0.6707072",
"0.66267747",... | 0.0 | -1 |
Fired when a client is disconnected. | def on_error(error); @parent.on_error(@env, error); end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client_disconnected\n end",
"def on_disconnect(client_id)\n @client_manager.remove(client_id)\n end",
"def on_disconnect(socket)\n Utils.logger.info(\"[Client Disconnected: #{socket.inspect}]\")\n end",
"def client_disconnected\n puts \"client #{current_user.email} disconnected\"\n curr... | [
"0.8104775",
"0.7987144",
"0.7954314",
"0.7841626",
"0.7655153",
"0.75557977",
"0.7487303",
"0.7256721",
"0.7048306",
"0.7036897",
"0.69862056",
"0.6966162",
"0.69268805",
"0.6912349",
"0.6867656",
"0.6845051",
"0.6843968",
"0.6843021",
"0.6824458",
"0.6819914",
"0.6767762",
... | 0.0 | -1 |
Fired when error occurs. Set application as parent and forward options | def initialize(parent, options = {})
@parent = parent
@options = options[:backend] || {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_error(error); @parent.on_error(@env, error); end",
"def setup_application\n error_msg = \"#{self.to_s}: you must override setup_application\"\n raise Backdat::Exceptions::Application, error_msg\n end",
"def fail_to_parent(error)\n @__context__.executor << FlowFiber.new { @parent.fail(sel... | [
"0.6660884",
"0.60131544",
"0.59758765",
"0.5908009",
"0.56029403",
"0.558656",
"0.55538",
"0.55538",
"0.55464697",
"0.5507478",
"0.5507478",
"0.54956",
"0.54787934",
"0.54689467",
"0.5429748",
"0.5429748",
"0.5393775",
"0.5366113",
"0.5281812",
"0.5271341",
"0.5264333",
"0... | 0.0 | -1 |
Creates a task that uses the various template wrappers to make a wrapped output file. There is some extra complexity because Dojo and YUI use different final locations. | def templated_build(name, opts={})
short = name.downcase
source = File.join("wrappers", short)
dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
CLEAN.include(opts[:location] ? opts[:location] : target_js)
desc "Package for #{name}"
task short.to_sym => dependencies do
puts "Packaging for #{name}"
mkdir_p opts[:location] if opts[:location]
files = [
"#{source}/mustache.js.pre",
'mustache.js',
"#{source}/mustache.js.post"
]
open("#{opts[:location] || '.'}/#{target_js}", 'w') do |f|
files.each {|file| f << File.read(file) }
end
puts "Done, see #{opts[:location] || '.'}/#{target_js}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def templated_build(name, opts={})\n short = name.downcase\n source = File.join(\"wrappers\", short)\n dependencies = [\"mustache.js\"] + Dir.glob(\"#{source}/*.tpl.*\")\n target_js = opts[:location] ? \"mustache.js\" : \"#{short}.mustache.js\"\n\n CLEAN.include(opts[:location] ? opts[:location] : target_js)\... | [
"0.7126494",
"0.69910395",
"0.6898831",
"0.6480727",
"0.63670325",
"0.6307068",
"0.6190587",
"0.611787",
"0.61012465",
"0.60927254",
"0.6072367",
"0.6064941",
"0.60631496",
"0.6052278",
"0.60421336",
"0.6000204",
"0.5987774",
"0.5936244",
"0.5930975",
"0.58978635",
"0.5897863... | 0.7240311 | 0 |
Provides either the passed in HTML, or uses the doc to generate the HTML | def html
@html ||= args.dig(:html) || doc.to_html
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_markup_rdoc(text); end",
"def html_markup_asciidoc(text); end",
"def documentation_html\n @documentation_html ||= generate_documentation_html\n end",
"def doc\n # get_html beforehand for good output messages\n html = get_html\n print \"Parsing doc...\"\n doc = Nokogiri::H... | [
"0.7058627",
"0.69723195",
"0.6849613",
"0.6786844",
"0.6728627",
"0.6704008",
"0.6704008",
"0.6662671",
"0.65805125",
"0.65707463",
"0.65493983",
"0.65493983",
"0.65206885",
"0.6505184",
"0.6505184",
"0.64965785",
"0.6481695",
"0.64762354",
"0.646726",
"0.6440871",
"0.641434... | 0.76175046 | 0 |
If the URL is passed in, we have acccess to it | def url
@url ||= args.dig(:url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(url); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url=(_arg0); end",
"def url\n end",
"def consume_url; end",
"def requested_url\n raise \"URL could not be detected.\" un... | [
"0.7153592",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.6825004",
"0.67207295",
"0.67093533",
"0.67057323",
"0.6599387",
"0.6580039",
"0.6557931",
"0.6557606",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307903",
"0.65307... | 0.638162 | 39 |
fetching common header for different variations | def convert_header(h)
changed_header = h.to_s.downcase.gsub('-', '').gsub(' ','_')
(User::HEADERS[changed_header].present? ? User::HEADERS[changed_header] : changed_header).intern
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; return {}; end",
"def headers; return {}; end",
"def read_headers!; end",
"d... | [
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6980834",
"0.6933759",
"0.6933759",
"0.6880598",
"0.68688357",
"0.6864616",
"0.6849195",
"0.67337555",
"0.6710942",
"0.66297835",
"0.66213477",
"0.65582484"... | 0.0 | -1 |
GET /file_list_items GET /file_list_items.xml | def index
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_items = @file_list.file_list_items.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @file_list_items }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_item = @file_list.file_list_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @file_list_item }\n end\n end",
"def index\n @list = Lis... | [
"0.7253695",
"0.6748305",
"0.67117727",
"0.66492766",
"0.6624679",
"0.65968746",
"0.6535257",
"0.6501938",
"0.6490047",
"0.6489521",
"0.64878076",
"0.6463209",
"0.6425785",
"0.6424752",
"0.6408849",
"0.6391161",
"0.63708115",
"0.6358394",
"0.6340381",
"0.6295728",
"0.62831795... | 0.7786718 | 0 |
GET /file_list_items/1 GET /file_list_items/1.xml | def show
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @file_list_item }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def index\n @list = List.f... | [
"0.7619156",
"0.6602612",
"0.65204906",
"0.6315112",
"0.6245342",
"0.6236728",
"0.62221396",
"0.62152797",
"0.6211031",
"0.6197166",
"0.61592674",
"0.6158384",
"0.6156805",
"0.6125392",
"0.61249447",
"0.60979193",
"0.60489106",
"0.6044213",
"0.6033936",
"0.60173285",
"0.60010... | 0.73082405 | 1 |
GET /file_list_items/new GET /file_list_items/new.xml | def new
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.build
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
format.js
format.html # new.html.erb
format.xml { render :xml => @file_list_item }
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 @title = \"New item\"\n @item = ItemTemplate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n ... | [
"0.6757881",
"0.6597636",
"0.6528176",
"0.65258914",
"0.64977515",
"0.64950424",
"0.6481976",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.64736533",
"0.6468618",
"0.64003515",
"0.6389975",
"0.63756377",
"0.6372262",
"0.... | 0.63872534 | 18 |
POST /file_list_items POST /file_list_items.xml | def create
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.build(params[:file_list_item])
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @file_list_item.save
flash[:notice] = 'FileListItem was successfully created.'
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js do
responds_to_parent do
render :js => "$('#page_section_" + @page_section.id.to_s + "').replaceWith('" + @template.escape_javascript(render_to_string(:partial => "page_sections/show")) + "');$('#modal-content').html("");$('#modal').jqmHide();"
end
end
format.xml { render :xml => @file_list_item, :status => :created, :location => @file_list_item }
else
format.html { render :action => "new" }
format.js do
responds_to_parent do
render :js => "$('#modal-content').html('" + @template.escape_javascript(render_to_string(:action => "new")) + "')"
end
end
format.xml { render :xml => @file_list_item.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def add_list_item(content,pag... | [
"0.66802996",
"0.6110032",
"0.6051943",
"0.60313255",
"0.6000208",
"0.5988239",
"0.59490603",
"0.5934109",
"0.5843036",
"0.5824926",
"0.5789077",
"0.57853335",
"0.5763051",
"0.56565714",
"0.5653314",
"0.5647765",
"0.55775994",
"0.5572881",
"0.55692655",
"0.5559203",
"0.555128... | 0.0 | -1 |
PUT /file_list_items/1 PUT /file_list_items/1.xml | def update
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.find(params[:id])
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @file_list_item.update_attributes(params[:file_list_item])
flash[:notice] = 'FileListItem was successfully updated.'
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js do
responds_to_parent do
render :js => "$('#file_list_item_" + @file_list_item.id.to_s + "').replaceWith('" + @template.escape_javascript(render_to_string(:partial => "file_list_items/show", :locals => { :file_list_item => @file_list_item })) + "');$('#modal-content').html("");$('#modal').jqmHide();"
end
end
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.js do
responds_to_parent do
render :js => "$('#modal-content').html('" + @template.escape_javascript(render_to_string(:action => "edit")) + "')"
end
end
format.xml { render :xml => @file_list_item.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @file_list = UploadedFileList.find(params[:uploaded_file_list_id])\n @file_list_items = @file_list.file_list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @file_list_items }\n end\n end",
"def update\n @file_item ... | [
"0.6275611",
"0.60256773",
"0.5959456",
"0.594907",
"0.59464186",
"0.59419596",
"0.5918617",
"0.5908268",
"0.58800936",
"0.58552647",
"0.5847207",
"0.5837163",
"0.5810882",
"0.58047724",
"0.57644105",
"0.5743155",
"0.56985414",
"0.5680712",
"0.5677487",
"0.567688",
"0.5570072... | 0.0 | -1 |
DELETE /file_list_items/1 DELETE /file_list_items/1.xml | def destroy
@file_list = UploadedFileList.find(params[:uploaded_file_list_id])
@file_list_item = @file_list.file_list_items.find(params[:id])
file_list_item_id = @file_list_item.id
@page_section = @file_list.page_section
@page = @page_section.page
@site_section = @page.site_section
@file_list_item.destroy
respond_to do |format|
format.html { redirect_to site_section_page_url(@site_section, @page) }
format.js { render :js => "$('#page_section_" + @page_section.id.to_s + "').replaceWith('" + @template.escape_javascript(render_to_string(:partial => "page_sections/show")) + "');$('#modal-content').html("");$('#modal').jqmHide();" }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @file_item = FileItem.cs(self.current_scope).find_by_path(params[:id])\n @file_item.destroy\n\n respond_to do |format|\n format.html { redirect_to file_items_url }\n format.json { head :ok }\n end\n end",
"def delete_file_from_database(file_id)\n $db.execute(\... | [
"0.66513693",
"0.65932494",
"0.65684396",
"0.6538054",
"0.6481305",
"0.6455834",
"0.645138",
"0.6422646",
"0.6422646",
"0.636243",
"0.6337595",
"0.632153",
"0.63033146",
"0.62866277",
"0.62531215",
"0.62372726",
"0.6229872",
"0.6218049",
"0.6202352",
"0.6199747",
"0.6167164",... | 0.0 | -1 |
start random generator threads and writer thread | def start
@running = true
gen_threads = start_generators
writer = start_writer
gen_threads.each(&:join)
kill_proccess
writer.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_generators\n threads = []\n 5.times do |idx|\n thread = Thread.new { contious_generation }\n thread[:id] = idx\n threads << thread\n end\n threads\n end",
"def run\r\n @cordinators.each do |c|\r\n @threads << Thread.new do\r\n c.run\r\n end\r\n ... | [
"0.6912321",
"0.5610358",
"0.55341935",
"0.53992677",
"0.5355878",
"0.528509",
"0.5261756",
"0.5258786",
"0.52472353",
"0.5246438",
"0.52297103",
"0.52289003",
"0.52289003",
"0.52289003",
"0.5208914",
"0.5201603",
"0.51988566",
"0.51877767",
"0.51774836",
"0.51246893",
"0.509... | 0.66465956 | 1 |
returns frequency for last hundred outputs | def get_freq
#instantiate with values to ensure consistent ordering
freq = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0 }
#sum up freqencies of each number
last_100 = get_last_100
last_100.each do |item|
freq[item.to_i] += 1
end
# convert to percentage
freq.each do |key, val|
#divide by real length to handle case of less than 100 outputs
freq[key] = val / last_100.length.to_f
end
freq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frequency\n growth_rate = 2 ** (1.0 / 12)\n frequency = 440 * (growth_rate ** semitones_from_A4)\n frequency.round(3)\n end",
"def get_frequency()\n return(get_cmd('FA;',0.1,0.5,3).gsub(/^FA/,'').gsub(/;$/,'').to_i)\nend",
"def frequency\n \n end",
"def frequency\n FREQUENCY\n ... | [
"0.6677098",
"0.66134214",
"0.65858567",
"0.6584553",
"0.6405751",
"0.6396108",
"0.63465613",
"0.6335369",
"0.6193089",
"0.616515",
"0.61158615",
"0.6107291",
"0.6054452",
"0.5971618",
"0.5827842",
"0.5822521",
"0.5798948",
"0.5795328",
"0.577622",
"0.5763896",
"0.5726173",
... | 0.7998869 | 0 |
helper method to return last 100 outputs | def get_last_100
last_100 = []
lines = File.readlines('./output.txt').reverse[0...100]
lines.each do |line|
last_100 << line.chomp.split(", ")[0]
end
last_100
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def last_output\n return @output_array[-1]\n end",
"def get_output(num)\n messages = @messages.last(num)\n messages.count < 2... | [
"0.6402576",
"0.6402576",
"0.6402576",
"0.6402576",
"0.61115795",
"0.5949863",
"0.5949863",
"0.5949863",
"0.5949863",
"0.5788936",
"0.5780951",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
"0.5760885",
... | 0.73927873 | 0 |
creates a Binary Min Heap to ensure ordered output | def setup_heap
@heap = BinaryMinHeap.new
@thread_queues.each do |queue|
@heap.push(queue.shift)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_minheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tminheapify(i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def heapsort(list)\n sorted_arr = []\n heap = MinHeap.new()\n list.each do |value|\n heap.add(value, value)\n end \n\nlist.length.times do |i|\n min = heap.remove()\n sorted_arr.push(min)\ne... | [
"0.8019722",
"0.69423044",
"0.679937",
"0.67993397",
"0.6789338",
"0.673547",
"0.664021",
"0.6619815",
"0.65664506",
"0.6561262",
"0.6552848",
"0.6548553",
"0.65336025",
"0.65301573",
"0.6496905",
"0.6485607",
"0.648445",
"0.6480424",
"0.6470397",
"0.6465959",
"0.64640635",
... | 0.6629703 | 7 |
ensure all queues remain filled until the generators are done generating and and the output queue has been emmptied | def fill_queues
while @thread_queues.any?(&:empty?) && (@running || !@output_queue.empty?)
el = @output_queue.shift
@thread_queues[el[:thread]] << el if el
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flusher_loop\n loop do\n # Blocks waiting for the flusher to be kicked...\n @flush_queue.pop\n\n should_bail = synchronize do\n @status != CONNECTED || @status == CONNECTING\n end\n return if should_bail\n\n # Skip in case nothing remains ... | [
"0.6355712",
"0.624103",
"0.6221606",
"0.6195629",
"0.6195026",
"0.6186957",
"0.61763436",
"0.61226183",
"0.60938627",
"0.6083213",
"0.60723025",
"0.6056801",
"0.60308313",
"0.6007526",
"0.6001148",
"0.6000283",
"0.59885955",
"0.5984256",
"0.5965351",
"0.58838326",
"0.5879026... | 0.7514605 | 0 |
uses a minheap to ensure ordered data output before writing to disc | def ensure_order_and_write
fill_queues
unless @heap.empty?
#extract the minimum element from the heap
extracted_el = @heap.extract
write_to_disk(extracted_el)
#add the next element from the same thread to the heap
from_queue = extracted_el[:thread]
fill_queues
next_el = @thread_queues[from_queue].shift
if next_el
@heap.push(next_el)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_minheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tminheapify(i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def heapsort(list)\n array = []\n myHeap = MinHeap.new()\n #return myHeap.store\n list.each do |item|\n myHeap.add(item)\n puts item \n end\n\n until myHeap.empty?\n array << myHeap.r... | [
"0.6689746",
"0.6371679",
"0.6280897",
"0.6259608",
"0.62022924",
"0.61617696",
"0.58815265",
"0.58796775",
"0.586939",
"0.58582425",
"0.5832433",
"0.58265454",
"0.57960653",
"0.5789457",
"0.57412255",
"0.5741173",
"0.5735473",
"0.5730162",
"0.5729206",
"0.5724106",
"0.570662... | 0.73906064 | 0 |
write rand val and timestamp to disc | def write_to_disk(output)
path = "./output.txt"
time = output[:time].strftime("%H:%M:%S:%N")
output_string = output[:value].to_s + ", " + time + "\n"
File.open(path, 'a') { |file| file.write(output_string) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_results_file\r\n\taFile = File.new(\"./random_number_result.txt\", \"r+\")\r\n\taFile.truncate(0)\r\n\tnumber = generate_random_number\r\n\tputs aFile.syswrite(\"#{number}\")\r\nend",
"def create_timestamp_file\n timestamp = Time.now.utc\n timestamp_file = File.new(report_timing_file, 'w')\n t... | [
"0.6358565",
"0.6044772",
"0.6030461",
"0.59834987",
"0.586772",
"0.5866691",
"0.57375175",
"0.57369983",
"0.57033104",
"0.5701967",
"0.5700457",
"0.5687286",
"0.56427246",
"0.5635373",
"0.5618079",
"0.56139666",
"0.55950683",
"0.55936855",
"0.55716926",
"0.5564042",
"0.55572... | 0.5515903 | 25 |
Generator Methods Creats 5 seperate writer generator threads | def start_generators
threads = []
5.times do |idx|
thread = Thread.new { contious_generation }
thread[:id] = idx
threads << thread
end
threads
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_intelligent_generator(jobs)\n jobs_gen = jobs.lazy.each\n Fiber.new do\n (jobs.length-1).times do\n Fiber.yield jobs_gen.next\n end\n jobs_gen.next\n end\n end",
"def start\n @running = true\n gen_threads = start_generators\n writer = start_writer\n gen_thre... | [
"0.6066507",
"0.5867134",
"0.5854366",
"0.5854366",
"0.5746162",
"0.5625355",
"0.5625355",
"0.5599094",
"0.55290556",
"0.55165744",
"0.5508261",
"0.54867053",
"0.5431468",
"0.5417689",
"0.54154974",
"0.5393715",
"0.5393553",
"0.53817165",
"0.5380286",
"0.53742003",
"0.5369251... | 0.76342887 | 0 |
genertes numbers in the specifiied proportions | def rand_gen
rand100 = rand(1..100)
if (0..50).cover?(rand100)
output_val = 1
elsif (51..75).cover?(rand100)
output_val = 2
elsif (76..90).cover?(rand100)
output_val = 3
elsif (91..95).cover?(rand100)
output_val = 4
elsif (96..100).cover?(rand100)
output_val = 5
end
handle_output(output_val)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def possible_proportions\n arr = Array.new(4, 0)\n proportions = []\n (0..100).to_a.each do |index0|\n arr[0] = index0\n (0..100 - index0).to_a.each do |index1|\n arr[1] = index1\n (0..100 - index0 - index1).to_a.each do |index2|\n arr[2] = index2\n arr[3] = 100 - index0 - index1 -... | [
"0.7365413",
"0.6766243",
"0.6511807",
"0.64483833",
"0.64081544",
"0.6401411",
"0.6336636",
"0.6294464",
"0.62422097",
"0.62414074",
"0.62299377",
"0.6219277",
"0.6203855",
"0.62036914",
"0.6195573",
"0.61904097",
"0.6149979",
"0.6086585",
"0.6047143",
"0.6022688",
"0.600152... | 0.0 | -1 |
handles output random number adds to last 100 and output queue | def handle_output(val)
thread_id = nil
while thread_id.nil?
thread_id = Thread.current[:id]
end
p val
output = { value: val, thread: thread_id, time: Time.now }
@output_queue << output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_num_gen()\n #puts 'This is a random number generator. The user will input the minimum \n #and maximum integers to declare the range the generator can output. The user \n #will also input the amount of times the generator will be called. The final\n #results will be stored in a table, which will be d... | [
"0.63140595",
"0.6294203",
"0.60098594",
"0.59087336",
"0.5782824",
"0.57827455",
"0.5767869",
"0.5752885",
"0.56497514",
"0.56010026",
"0.55951005",
"0.5588491",
"0.55883473",
"0.5511223",
"0.548834",
"0.54845077",
"0.5483907",
"0.5456574",
"0.5448022",
"0.5412136",
"0.54086... | 0.58664846 | 4 |
need things for the | def request_quote
@title = "Request a Quote"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probers; end",
"def private; end",
"def extra; end",
"def checks; end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def requirements; end",
"def stderrs; end",
"def used?; end",
"def operations; end",
"def operations; end",
"def prerequisites\n\tsuper\n ... | [
"0.6832558",
"0.6722757",
"0.62319183",
"0.6226191",
"0.6166615",
"0.6166615",
"0.6166615",
"0.6166615",
"0.6164982",
"0.6152642",
"0.609288",
"0.609288",
"0.6076976",
"0.6076976",
"0.6045996",
"0.60317576",
"0.6024511",
"0.6024511",
"0.6024511",
"0.6024511",
"0.60048133",
... | 0.0 | -1 |
GET /children GET /children.json | def index
if !signed_in?
redirect_to root_path
end
@children = Child.all
if !params[:search].nil?
@result = Child.search(params[:search])
end
if @result.nil? && params[:search].nil?
@result = Child.all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n render json: { status: 'ok', content: [] }\n end",
"def children\n @resource.children\n end... | [
"0.80130404",
"0.7882042",
"0.7781168",
"0.7538884",
"0.7376999",
"0.73671556",
"0.7354207",
"0.73513156",
"0.7289584",
"0.72810805",
"0.72810805",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7223111",
"0.7161739",
"0.71592",
"0.7154487",
"0.7149481",
"0.7119744",
"0.7077208",
... | 0.0 | -1 |
GET /children/1 GET /children/1.json | def show
if !signed_in?
redirect_to root_path
end
if !@child.dob.blank?
@child.age_years = ageYears(@child)
@child.age_months = ageMonths(@child)
@child.age_total_months = ageTotalMonths(@child)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n @pages = @page.children\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def children\n @id = fix_id(params[:id], params[:format], params[:extra])\n if params[:root]==\"source\" then\n @isRo... | [
"0.7499588",
"0.7324712",
"0.72646785",
"0.71289086",
"0.70389336",
"0.7035334",
"0.69792575",
"0.6978602",
"0.6978602",
"0.6977394",
"0.6936022",
"0.6908084",
"0.68532836",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6773779",
"0.6759537",
"0.66919076",
"0.66919076",
"0.667522... | 0.0 | -1 |
POST /children POST /children.json | def create
@child = Child.new(child_params)
respond_to do |format|
if @child.save
format.html { redirect_to @child, notice: 'Child was successfully created.' }
format.json { render action: 'show', status: :created, location: @child }
else
format.html { render action: 'new' }
format.json { render json: @child.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_post!(params)\n @children.create! params\n end",
"def create\n @children = Children.new(params[:children])\n\n respond_to do |format|\n if @children.save\n flash[:notice] = 'Children was successfully created.'\n format.html { redirect_to(@children) }\n format.xml {... | [
"0.74252766",
"0.7309307",
"0.68554646",
"0.666492",
"0.66533995",
"0.65639085",
"0.6544793",
"0.6512353",
"0.6507447",
"0.64626294",
"0.6390514",
"0.63477474",
"0.622188",
"0.61944646",
"0.6185938",
"0.61740005",
"0.6149718",
"0.6137717",
"0.61081606",
"0.6088241",
"0.608824... | 0.6166014 | 16 |
PATCH/PUT /children/1 PATCH/PUT /children/1.json | def update
respond_to do |format|
if @child.update(child_params)
format.html { redirect_to @child, notice: 'Child was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @child.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @children = Children.find(params[:id])\n\n respond_to do |format|\n if @children.update_attributes(params[:children])\n flash[:notice] = 'Children was successfully updated.'\n format.html { redirect_to(@children) }\n format.xml { head :ok }\n else\n format.... | [
"0.7087602",
"0.6747008",
"0.64609504",
"0.64609504",
"0.6425298",
"0.64243084",
"0.64243084",
"0.64243084",
"0.6372172",
"0.6325486",
"0.6317983",
"0.62796867",
"0.6267304",
"0.62311465",
"0.62205744",
"0.60959387",
"0.6091433",
"0.6057536",
"0.6040286",
"0.6024075",
"0.6024... | 0.65239745 | 2 |
DELETE /children/1 DELETE /children/1.json | def destroy
@child.destroy
respond_to do |format|
format.html { redirect_to children_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @children = Children.find(params[:id])\n @children.destroy\n\n respond_to do |format|\n format.html { redirect_to(childrens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @child = Child.find(params[:id])\n @child.destroy\n\n respond_to do |format|\n ... | [
"0.7690423",
"0.754166",
"0.7339654",
"0.7039886",
"0.7039886",
"0.70389456",
"0.70389456",
"0.68095887",
"0.67939544",
"0.6781426",
"0.6747409",
"0.67131644",
"0.67131644",
"0.6713039",
"0.6677913",
"0.667762",
"0.667456",
"0.66403186",
"0.6628512",
"0.6609712",
"0.660891",
... | 0.7553778 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_child
@child = Child.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 child_params
params.require(:child).permit(:created_at, :updated_at, :last_name, :first_name, :gender, :dob, :age_years, :age_months, :age_total_months, :location, :no_parent_present, :parental_permission_given, :allergies, :allergies_information, :immunization_utd, :dtap, :hib, :pneumovax, :hepa, :hepb, :influenza, :mmr, :immunization_needed, :revelant_information, :absences, :height_feet, :height_inches, :height_total_inches, :height_total_cm, :weight_lbs, :weight_oz, :weight_kg, :bmi_result, :bmi_percentile, :systolic_1, :diastolic_1, :systolic_2, :diastolic_2, :systolic_3, :diastolic_3, :hemoglobin, :blood_glucose, :hearing_hz_left_1, :hearing_db_left_1, :ear_left_pass_1, :hearing_hz_right_1, :hearing_db_right_1, :ear_right_pass_1, :hearing_hz_left_2, :hearing_db_left_2, :ear_left_pass_2, :hearing_hz_right_2, :hearing_db_right_2, :ear_right_pass_2, :hearing_hz_left_3, :hearing_db_left_3, :ear_left_pass_3, :hearing_hz_right_3, :hearing_db_right_3, :ear_right_pass_3, :hearing_comments, :vision_acuity_left_1, :vision_acuity_right_1, :vision_acuity_both_1, :vision_acuity_right_2, :vision_acuity_left_2, :vision_acuity_both_2, :vision_acuity_right_3, :vision_acuity_left_3, :vision_acuity_both_3, :vision_color_blindness, :cover_test_left, :cover_test_right, :cover_test_both, :wears_corrective_lenses, :vision_comments, :general_appearance, :general_appearance_c, :head, :head_c, :skin, :skin_c, :eyes, :eyes_c, :ears, :ears_c, :nose, :nose_c, :mouth, :mouth_c, :throat, :throat_c, :thyroid, :thyroid_c, :lymph_all_normal, :lymph_pre_auricular, :lymph_post_auricular, :lymph_anterior_cervical, :lymph_posterior_cervical, :lymph_occipital, :lymph_axillary, :lymph_c, :vascular, :vascular_c, :heart, :heart_c, :lungs, :lungs_c, :abdomen, :abdomen_c, :musculoskeletal, :musculoskeletal_c, :scoliosis, :scoliosis_c, :neuro, :neuro_c, :well_child_check, :children_01, :children_02, :children_03, :children_04, :children_05, :children_06, :children_07, :children_08, :children_09, :children_10, :follow_up_01, :follow_up_02, :follow_up_03, :follow_up_04, :follow_up_05, :follow_up_06, :follow_up_07, :follow_up_08, :follow_up_09, :follow_up_10, :text, :guidance, :chart_complete, :np_signature, :faculty_signature, :other_np_signature, :form_id_number)
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 |
Generates a random query | def random_query
# Use a fake query
# TODO: better random queries
'query ' + (rand*5000).to_i.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_quick_queries(types)\n allTypes = types.collect {|type| type.get_quick_queries}.flatten\n prng = Random.new\n random_qq = allTypes.sort {|item1, item2| prng.rand(-1 .. 1) }.slice(0, 5)\n random_qq.collect {|qq| render_quick_query(qq)}\n end",
"def random\n db = ActiveRecord::Bas... | [
"0.67428267",
"0.6579714",
"0.65100694",
"0.6459899",
"0.61614513",
"0.61167294",
"0.59826595",
"0.5957069",
"0.5907958",
"0.58903813",
"0.58845556",
"0.58440024",
"0.58408374",
"0.58172655",
"0.5815573",
"0.580951",
"0.5803809",
"0.5801294",
"0.5801294",
"0.5800222",
"0.5792... | 0.8608336 | 0 |
Generates a random (category, action) pair for an event | def random_category_action
category = (QuickSearch::Engine::APP_CONFIG['searchers'] + ['spelling-suggestion', 'result-types', 'doi-trap', 'more-options']).sample.dasherize
# Default action is a click
action = 'click'
# Typically, serves only happen for these categories
if category == 'best-bets' || category == 'spelling-suggestion'
action = ['click', 'serve'].sample
end
return category, action
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_event\n clear\n center \"Random Event\"\n new_line\n display_event(Event.all.sample)\n wait_and_clear\n end",
"def random_act *acts\n act acts[rand(acts.length)]\n end",
"def generateEventID\n Random.rand(10000)\n end",
"def random_event_by_tag_menu\n clear\n while @i... | [
"0.63106525",
"0.5994892",
"0.59504735",
"0.57473546",
"0.57009965",
"0.5692117",
"0.561502",
"0.5579096",
"0.5573902",
"0.5560656",
"0.5553878",
"0.55440325",
"0.5471812",
"0.5457403",
"0.5446332",
"0.5434204",
"0.54228395",
"0.531166",
"0.5303271",
"0.5282809",
"0.5277814",... | 0.7117247 | 0 |
Generates a random item for an event, based on the category | def random_item(category)
if category == 'best-bets'
# Sample a random Best Bet type from a static list
['webofscience', 'googlescholar', 'ieee', 'pubmed', 'morningstar', 'wgsn', 'standards', 'dissertation', 'refworks', 'ibis', 'proquest',
'psychinfo', 'sciencemagazine', 'sciencedirect', 'petition', 'compendex', 'jstor', 'software', 'naturejournal'].sample
elsif category == 'doi-trap'
# Sample a random DOI from a static list
['10.1080/10510974.2013.797483', '10.1111/j.1468-2958.1996.tb00379.x', 'http://dx.doi.org/10.1063/1.2741534', 'DOI: 10.1007/BF02887151',
'10.1039/C4RA16247A', '10.1002/sce.3730670213', 'DOI: 10.1007/s40596-014-0241-5', '10.1080/15348423.2012.697437',
'http://dx.doi.org/10.3168/jds.S0022-0302(86)80552-5', 'DOI: 10.1023/A:1005204727421', '10.1039/C3TA00019B', 'doi:10.1038/leu.2016.163',
'DOI: 10.1007/s10853-013-7374-x', 'doi: 10.1016/0167-2738(91)90233-2', 'doi: 10.1179/000705992798268927', '10.1038/nphys3794',
'doi: 10.1149/1.1393288', '10.1080/1554480X.2014.926052', '10.1002/adma.201506234', '10.1080/00958972.2016.1176158'].sample
elsif category == 'result-types'
# Use a defined searcher for found types
(QuickSearch::Engine::APP_CONFIG['searchers']).sample.dasherize
elsif category == 'more-options'
# Use a result number for more-options
['result-1', 'result-2', 'result-3', 'result-4'].sample
elsif category == 'spelling-suggestion'
# Use a fake string
'spelling suggestion ' + (rand*200).to_i.to_s
else
# Use one of the typical options for a searcher click (or anything else we haven't handled above)
['heading', 'result-1', 'result-2', 'result-3', 'see-all-results', 'no-results', 'error'].sample
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_item\n items.to_a.sample\n end",
"def random_item\n return @items[rand(@items.length)]\n end",
"def random_event\n clear\n center \"Random Event\"\n new_line\n display_event(Event.all.sample)\n wait_and_clear\n end",
"def random_item(electives)\n electives[rand(electiv... | [
"0.67726845",
"0.6486088",
"0.6484776",
"0.6410702",
"0.63882387",
"0.63415533",
"0.6227323",
"0.60879976",
"0.60795176",
"0.60710055",
"0.6042241",
"0.59937316",
"0.5938571",
"0.59200454",
"0.5870675",
"0.5853965",
"0.58490855",
"0.581952",
"0.58074826",
"0.5737065",
"0.5710... | 0.7389499 | 0 |
Save to file TODO: delete files in cms/Blocks/Modules | def dump (filepath = BLOCKS_PATH)
# Compare saved Hash with existing files in cms/Blocks/Modules
# Delete files which are not in the Hash anymore
self.compare true
# Save the .yaml
File.open(filepath, 'w') do |out|
YAML::dump(@source, out)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_level\n File.open(@file_name, 'w') do |file|\n @blocks_array.each do |block|\n new_block = Block.new block.relative_position\n puts new_block.to_s\n end\n end\n end",
"def save_to(path); end",
"def save\n file_path = self.class.file_path(@save_id)\n File.open(file_... | [
"0.6641077",
"0.65292114",
"0.64409125",
"0.6439034",
"0.6398398",
"0.63938165",
"0.6368766",
"0.63551515",
"0.6353025",
"0.63507384",
"0.63507384",
"0.6347216",
"0.633548",
"0.6319227",
"0.63181955",
"0.63129777",
"0.626229",
"0.6230679",
"0.61614186",
"0.6137314",
"0.613417... | 0.5701149 | 100 |
Raise error if no such block | def check_block name
raise "No such block: #{name}" unless @source.key? name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_block(blk_hash)\n raise \"Not implemented\"\n end",
"def raise_if_block(obj, name, has_block, type)\n return unless has_block\n\n puts \"Type passed in: #{type}\"\n puts \"#{obj.class}##{name} does not accept blocks\"\n\n raise Appom::UnsupportedBlockError\n end",
"de... | [
"0.7198107",
"0.7087166",
"0.68876505",
"0.6871596",
"0.6851032",
"0.6637109",
"0.6561613",
"0.654849",
"0.6518731",
"0.6463298",
"0.64455473",
"0.6403784",
"0.63923097",
"0.6387925",
"0.6384271",
"0.63789093",
"0.63658184",
"0.6271281",
"0.62580335",
"0.62580335",
"0.6258033... | 0.7525429 | 0 |
Raise error if no such module | def check_type type
raise "No such type: #{type}" unless Modules.constants.include? type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_module_exists(module_name)\n @forge.check_module_exists(module_name)\n end",
"def check_module_exists(module_name)\n @forge.check_module_exists(module_name)\n end",
"def check_module_exists(module_name)\n !get_module_data(module_name).nil?\n end",
"def get_module()\n raise NoMe... | [
"0.7106743",
"0.71055895",
"0.6870879",
"0.66052145",
"0.65267307",
"0.645325",
"0.622519",
"0.6125707",
"0.5913256",
"0.59077585",
"0.58327234",
"0.5758508",
"0.57405955",
"0.5727051",
"0.57244843",
"0.5713424",
"0.571274",
"0.57011473",
"0.56903917",
"0.56863034",
"0.565451... | 0.0 | -1 |
range of years and outputs those years which do not have any repeated digits. You should probably write a helper function, `no_repeat?(year)` which returns true/false if a single year doesn't have a repeat. Difficulty: 1/5 | def no_repeats(year_start, year_end)
result = []
(year_start..year_end).each do |yr|
result << yr if no_repeat?(yr)
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_repeat_years(first_yr, last_yr)\n result = []\n (first_yr..last_yr).each do |num|\n if not_repeat_year?(num)\n result << num\n end\n end\n result\nend",
"def no_repeat_years(first_yr, last_yr)\n years = (first_yr..last_yr)\n years.select { |year| year.to_s.chars.uniq == year.to_s.chars }\... | [
"0.8224817",
"0.8201339",
"0.8183692",
"0.817629",
"0.8149809",
"0.8136984",
"0.81052613",
"0.80987054",
"0.80939925",
"0.80634737",
"0.80312055",
"0.7970726",
"0.79629904",
"0.78959644",
"0.78614205",
"0.784222",
"0.78334177",
"0.7761601",
"0.7754601",
"0.77396744",
"0.77393... | 0.7623361 | 23 |
GET /groups GET /groups.json | def index
@user = User.find(current_user.id)
@groups = @user.groups.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetGroups params = {}\n\n params = params.merge(path: 'groups.json')\n APICall(params)\n\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def index\n @groups = Group.all\n\n respond_to do... | [
"0.8286577",
"0.8278107",
"0.7801243",
"0.7762667",
"0.77249485",
"0.765602",
"0.765602",
"0.76541275",
"0.7636101",
"0.7561083",
"0.7547335",
"0.74825233",
"0.74768126",
"0.7467619",
"0.74643844",
"0.73794276",
"0.7367821",
"0.7351049",
"0.7334809",
"0.72987163",
"0.7240665"... | 0.0 | -1 |
GET /groups/1 GET /groups/1.json | def show
@users = User.all
@group = Group.find(params[:id])
@contents = @group.contents.all
@usergroups = GroupsUser.all
@groupcategory = GroupCategory.where(:group_id => params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetGroup id\n\n APICall(path: \"groups/#{id}.json\")\n\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def show\n group = Group.find(params[:id])\n\n render json: group\n end",
"def GetGroup... | [
"0.7906696",
"0.77682996",
"0.77013576",
"0.7696094",
"0.76500016",
"0.7552326",
"0.7552326",
"0.7536221",
"0.74999285",
"0.74999285",
"0.74628925",
"0.7451343",
"0.7425182",
"0.7417058",
"0.7410386",
"0.7380656",
"0.73710245",
"0.7351068",
"0.7332308",
"0.73154056",
"0.73041... | 0.0 | -1 |
POST /groups POST /groups.json | def create
@user = User.find(current_user.id)
@group = Group.new(group_params)
@group.title = params[:title]
@group.description = params[:description]
@group.groupProfile = params[:groupProfile]
@group.groupCover = params[:groupCover]
respond_to do |format|
if @group.save
@user.groups << @group
GroupCategory.new(group_id: @group.id , category_id: params[:category]).save
format.html { redirect_to user_group_path(current_user.id, @group.id) }
format.json { render :show, status: :created, location: @group }
else
format.html { render :new }
format.json { render json: @group.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateGroup params = {}\n \n APICall(path: 'groups.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration], owner: current_user)... | [
"0.77380043",
"0.7621419",
"0.751383",
"0.74283075",
"0.738724",
"0.738724",
"0.7202902",
"0.7202091",
"0.7180679",
"0.71750224",
"0.71592236",
"0.71332103",
"0.7128259",
"0.70654404",
"0.7040274",
"0.7027708",
"0.70119005",
"0.70049846",
"0.70049846",
"0.70049846",
"0.700498... | 0.6687562 | 61 |
PATCH/PUT /groups/1 PATCH/PUT /groups/1.json | def update
@user = User.find(current_user.id)
@group = @user.groups.find(params[:id])
@group.title = params[:title]
@group.description = params[:description]
@group.groupProfile = params[:groupProfile]
@group.groupCover = params[:groupCover]
@groupcategory = GroupCategory.where(:group_id => params[:id])
@groupcategory.update(group_id: @group.id , category_id: params[:category])
respond_to do |format|
if @group.update(title: params[:title], description: params[:description])
format.html { redirect_to user_group_path(current_user.id, @group.id) }
format.json { render :show, status: :ok, location: @group }
else
format.html { render :edit }
format.json { render json: @group.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n logger.info \"Put parameters: #{params.to_json}\"\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def UpdateGroup params = {}\n \n ... | [
"0.7466507",
"0.74578977",
"0.74070287",
"0.7302792",
"0.7140245",
"0.7124225",
"0.7098948",
"0.70921224",
"0.7057236",
"0.7057236",
"0.70501083",
"0.70501083",
"0.70501083",
"0.70233816",
"0.6994502",
"0.6980002",
"0.69751716",
"0.69751716",
"0.69751716",
"0.69751716",
"0.69... | 0.64932644 | 97 |
DELETE /groups/1 DELETE /groups/1.json | def destroy
@content = Content.where("user_id = ? and group_id = ?" , params[:user_id] , params[:id])
# Delete All Comments Made Contents On User
@content.each do |c|
Comment.where(content_id: c.id).destroy_all()
end
# Delete All Contents Made On User
Content.where("user_id = ? and group_id = ?" , params[:user_id] , params[:id]).destroy_all
# Delete All Push In User On Group
Push.where("user_id = ? and pusher_id = ? and push_num = 1" ,params[:user_id] , params[:id]).destroy_all
# Delete Group
if GroupsUser.where(:group_id => params[:id]).count() == 1
Group.find(params[:id]).destroy
else
GroupsUser.where("user_id = ? and group_id = ?" , params[:user_id] , params[:id]).delete_all
end
respond_to do |format|
format.html { redirect_to home_index_path, notice: 'Group was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteGroup id\n \n APICall(path: \"groups/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n group = Group.find(params[:id])\n group.destroy\n render json: {}\n end",
"def deleteGroup( group_id)\n params = Hash.new\n params['group_id'] = group_id\n return... | [
"0.80822545",
"0.79805106",
"0.79167783",
"0.786261",
"0.786261",
"0.7848193",
"0.7848193",
"0.78414327",
"0.78414327",
"0.78414327",
"0.78414327",
"0.78414327",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7808105",
"0.7787947",
"0.7787941... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_group
@group = Group.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 group_params
# params.require(:group).permit(:title, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Save pem encoded content to a file. If the file doesn't exist, it will be created. Otherwise, the file will be overwritten. In both cases the contents will be overwritten atomically so other processes don't see a partially written file. | def save_pem(pem, path, owner: nil, group: nil, mode: 0644)
Puppet::FileSystem.replace_file(path, mode) do |f|
f.set_encoding('UTF-8')
f.write(pem.encode('UTF-8'))
end
if !Puppet::Util::Platform.windows? && Puppet.features.root? && (owner || group)
FileUtils.chown(owner, group, path)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_pem(filename_or_io)\n write_data(filename_or_io, @cert.to_pem)\n end",
"def write_pem(filename_or_io)\n write_data(filename_or_io, @spki.to_pem)\n end",
"def write\n File.open(path, 'w') { |file|\n file.write(FILE_HEADER + \"\\n\")\n file.write(encod... | [
"0.63669235",
"0.6342067",
"0.58729726",
"0.5854523",
"0.5818254",
"0.5799773",
"0.578276",
"0.57702744",
"0.576625",
"0.57602286",
"0.5708695",
"0.5687255",
"0.5687134",
"0.5685794",
"0.56578064",
"0.56578064",
"0.5649476",
"0.56432116",
"0.56415886",
"0.5636437",
"0.5625253... | 0.71479607 | 0 |
Delete a pem encoded object, if it exists. | def delete_pem(path)
Puppet::FileSystem.unlink(path)
true
rescue Errno::ENOENT
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @pem = Pem.find(params[:id])\n @pem.destroy\n\n respond_to do |format|\n format.html { redirect_to pems_url }\n format.json { head :no_content }\n end\n end",
"def delete\n result = exists\n raise RubyAem::Error.new('Certificate chain not found', result) if resu... | [
"0.6298715",
"0.62234724",
"0.6163683",
"0.601336",
"0.5942083",
"0.5860491",
"0.5818211",
"0.5764124",
"0.5761303",
"0.5738464",
"0.5720538",
"0.5691599",
"0.5683437",
"0.5671624",
"0.5642392",
"0.5637462",
"0.5621646",
"0.56120807",
"0.5608047",
"0.5607176",
"0.559704",
"... | 0.7268935 | 0 |
GET /albums GET /albums.json | def index
@albums = Album.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @albums = Album.all\n render json: @albums\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end",
"def get_albums(url)\n # should return albums\n # List o... | [
"0.8048931",
"0.7923151",
"0.79193866",
"0.78014976",
"0.77844",
"0.7780223",
"0.77119625",
"0.7673395",
"0.7659477",
"0.75729513",
"0.75276154",
"0.75228256",
"0.74572295",
"0.74433213",
"0.7395577",
"0.7365708",
"0.73508006",
"0.7322036",
"0.73183537",
"0.7268043",
"0.72548... | 0.73407245 | 23 |
GET /albums/1 GET /albums/1.json | def show
@artist = @album.artist
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def get_album album_id\n get(\"/albums/#{album_id}\")\n end",
"def index\n @albums = Album.all\n render json: @albums\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:ar... | [
"0.8010893",
"0.79601175",
"0.7838933",
"0.76931643",
"0.7598457",
"0.7579601",
"0.7575355",
"0.75562096",
"0.75089633",
"0.7500134",
"0.74333906",
"0.7426798",
"0.7391768",
"0.73389864",
"0.7287336",
"0.7271081",
"0.72389615",
"0.7209903",
"0.7200635",
"0.7192762",
"0.719262... | 0.0 | -1 |
POST /albums POST /albums.json | def create
label_params = {:name => params[:new_label]}
artist_params = {:name => params[:artist_name]}
@labels = Label.all
@label = Label.new(label_params)
@artist = Artist.new(artist_params)
@album = Album.new(album_params)
if @label.name != ''
if Label.exists?(:name => label_params[:name])
@label = Label.where(:name => label_params[:name]).first
@album.label = @label
else
@album.label = @label
end
end
if @artist.name != ''
if Artist.exists?(:name => artist_params[:name])
@artist = Artist.where(:name => artist_params[:name]).first
@album.artist = @artist
else
@album.artist = @artist
end
end
if Album.exists?(:title => album_params[:title])
if Album.exists?(:artist => album_params[:artist])
@album = Album.where(:title => album_params[:title], :artist => album_params[:artist]).first
redirect_to @album and return
end
end
if @album.save
redirect_to @album and return
else
render 'new' and return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend",
"def create\n @album = current_user.albums.build(album_params)\n\n res... | [
"0.77528495",
"0.7283492",
"0.7234256",
"0.71961457",
"0.7179153",
"0.70808494",
"0.70808494",
"0.70808494",
"0.7003637",
"0.7003637",
"0.69838834",
"0.6972035",
"0.697075",
"0.6958249",
"0.69494504",
"0.6927158",
"0.68965065",
"0.6890949",
"0.6846395",
"0.6823431",
"0.682324... | 0.0 | -1 |
PATCH/PUT /albums/1 PATCH/PUT /albums/1.json | def update
label_params = {:name => params[:new_label]}
artist_params = {:name => params[:artist_name]}
@labels = Label.all
@label = (@album.label.nil?) ? Label.new(label_params) : @album.label
@artist = (@album.artist.nil?) ? Artist.new(artist_params) : @album.artist
if Label.exists?(:name => label_params[:name])
@label = Label.where(:name => label_params[:name]).first
@album.label_id = @label.id
else
@label.save
@album.label_id = @label.id
end
if Artist.exists?(:name => artist_params[:name])
@artist = Artist.where(:name => artist_params[:name]).first
@album.artist = @artist
else
@artist.save
@album.artist = @artist
end
respond_to do |format|
if @album.update(album_params)
format.html { redirect_to @album, notice: 'Album was successfully updated.' }
format.json { render :show, status: :ok, location: @album }
else
format.html { render :edit }
format.json { render json: [@album.errors, @album.artist.errors, @album.label.errors], status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @album = current_user.albums.find(params[:id])\n\n respond_to do |format|\n if @Album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ... | [
"0.6955096",
"0.67836237",
"0.67753136",
"0.677528",
"0.67684835",
"0.67597175",
"0.67597175",
"0.6732082",
"0.6732082",
"0.6732082",
"0.6701589",
"0.6701589",
"0.6701589",
"0.6662536",
"0.6628176",
"0.65705246",
"0.65516347",
"0.65429837",
"0.6537242",
"0.6532796",
"0.650100... | 0.0 | -1 |
DELETE /albums/1 DELETE /albums/1.json | def destroy
@albums = Album.all
@album = Album.find(params[:id])
@album.destroy
respond_to do |format|
format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\n @album = @user.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n render json: @album\n end",
"def destroy\n @album = Albu... | [
"0.801051",
"0.79122156",
"0.7840477",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.7785304",
"0.7780388",
"0.77713436",
"0.77632475",
"0.77632475",
"0.77632475",
"0.7684608",
"0.7640788",
"0.7640206",
"0.76009154",
"0.7557025",
"0.75467694",
"0.75... | 0.7775917 | 10 |
Use callbacks to share common setup or constraints between actions. | def set_album
@album = Album.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 album_params
params.require(:album).permit(:user, :user_id, :label, :label_id, :title, :artist, :artist_id, :genre, :year, :added, :plays, :label_attributes => [:label, :id, :name], :artist_attributes => [:id, :artist_id, :name])
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 |
execute linux shell command return array with command result [execute status, execute result] | def run_command(shell, whether_show_log=true, whether_reject_empty=true)
result = IO.popen(shell) do |stdout|
stdout.readlines#.reject(&method)
end.map { |l| l.is_a?(String) ? string_format(l) : l }
status = $?.exitstatus.zero?
if !status or whether_show_log
shell = string_format(shell).split(/\n/).map { |line| "\t`" + line + "`" }.join("\n")
result = ["bash: no output"] if result.empty?
if result.length > 100
resstr = "\t\tbash: output line number more than 100 rows."
else
resstr = result.map { |line| "\t\t" + line }.join
end
puts "%s\n\t\t==> %s\n%s\n" % [shell, status, resstr]
end
return result.unshift(status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute\n { 'output' => `#{@cmd}`, 'process_status' => $? }\n end",
"def execute(cmd)\n captured_stdout = ''\n captured_stderr = ''\n exit_status = Open3.popen3(ENV, cmd) do |stdin, stdout, stderr, wait_thr|\n stdin.close\n captured_stdout = stdout.read\n captured_stderr =... | [
"0.73241246",
"0.726022",
"0.7168577",
"0.7034433",
"0.6871474",
"0.6863881",
"0.68520886",
"0.68465436",
"0.6747318",
"0.67449206",
"0.67040825",
"0.66577643",
"0.66012233",
"0.6589939",
"0.6570259",
"0.65511197",
"0.65262365",
"0.65232456",
"0.65232456",
"0.6510444",
"0.650... | 0.6565941 | 15 |
GET /academic_informations GET /academic_informations.json | def index
@academic_informations = AcademicInformation.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\r\n @academic_work = AcademicWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def index\n @educations = Education.all\n render json: @educations\n end",
"def show\n @an... | [
"0.6775217",
"0.65797335",
"0.65763885",
"0.6488956",
"0.64393044",
"0.63317746",
"0.631652",
"0.6284111",
"0.6239812",
"0.6193898",
"0.61796737",
"0.61765236",
"0.61765236",
"0.6160649",
"0.61407167",
"0.6119435",
"0.6099538",
"0.60833544",
"0.608291",
"0.6081734",
"0.607775... | 0.74520576 | 0 |
GET /academic_informations/1 GET /academic_informations/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @academic_informations = AcademicInformation.all\n end",
"def show\r\n @academic_work = AcademicWork.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def show\n @anniversary... | [
"0.73284096",
"0.708885",
"0.6798916",
"0.6777726",
"0.66206247",
"0.65678155",
"0.65272915",
"0.649892",
"0.649892",
"0.6420348",
"0.6413071",
"0.6399599",
"0.6377764",
"0.6376341",
"0.63746935",
"0.63714933",
"0.63566154",
"0.6355441",
"0.63545996",
"0.6344604",
"0.63325095... | 0.0 | -1 |
POST /academic_informations POST /academic_informations.json | def create
@academic_information = AcademicInformation.new(institution_id: academic_information_params[:institution_id],
academic_degree_id: academic_information_params[:academic_degree_id],
grade: academic_information_params[:grade],
description: academic_information_params[:description]
)
course = Course.where(name: academic_information_params[:course],institution_id: academic_information_params[:institution_id]).first_or_create!
@academic_information.course = course
begin
@academic_information.b_date = Date.parse(academic_information_params[:b_date])
rescue ArgumentError
return redirect_to new_academic_information_path(@academic_information)
end
if !academic_information_params[:e_date].blank?
begin
@academic_information.e_date = Date.parse(academic_information_params[:e_date])
rescue ArgumentError
return redirect_to new_academic_information_path(@academic_information)
end
end
@academic_information.teacher = Teacher.find(current_teacher.id)
respond_to do |format|
if @academic_information.save
format.html { redirect_to :home, notice: 'Academic information was successfully created.' }
format.json { render action: 'show', status: :created, location: @academic_information }
else
format.html { render action: 'new' }
format.json { render json: @academic_information.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @academic_informations = AcademicInformation.all\n end",
"def new\r\n @academic_work = AcademicWork.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @academic_work }\r\n end\r\n end",
"def academic_information_params\n par... | [
"0.65599",
"0.6471721",
"0.6466419",
"0.64598775",
"0.6459526",
"0.63923293",
"0.6364742",
"0.63430816",
"0.62972397",
"0.6289171",
"0.62624806",
"0.62569124",
"0.62409043",
"0.6226442",
"0.6211132",
"0.6203712",
"0.62025344",
"0.6106263",
"0.60670465",
"0.6022282",
"0.602103... | 0.61950046 | 17 |
PATCH/PUT /academic_informations/1 PATCH/PUT /academic_informations/1.json | def update
respond_to do |format|
if @academic_information.update(academic_information_params)
format.html { redirect_to @academic_information, notice: 'Academic information was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @academic_information.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\... | [
"0.67717165",
"0.67710716",
"0.6747215",
"0.6719126",
"0.66927475",
"0.66288173",
"0.66251254",
"0.66123307",
"0.6592651",
"0.65728956",
"0.6527749",
"0.65249974",
"0.6524159",
"0.6519908",
"0.6508089",
"0.65058064",
"0.6497485",
"0.64962745",
"0.64820474",
"0.64405894",
"0.6... | 0.71921223 | 0 |
DELETE /academic_informations/1 DELETE /academic_informations/1.json | def destroy
@academic_information.destroy
respond_to do |format|
format.html { redirect_to academic_informations_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @education_entry.destroy\n respond_to do |format|\n format.html { redirect_to education_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @academic_degree.destroy\n respond_to do |format|\n format.html { redirect_to '/maestricos/prueba?titu... | [
"0.716151",
"0.7134487",
"0.71005076",
"0.7094043",
"0.7063016",
"0.69871086",
"0.69762254",
"0.6955557",
"0.69534886",
"0.69499236",
"0.6947348",
"0.6929999",
"0.6906631",
"0.68977445",
"0.6897173",
"0.68924636",
"0.68924636",
"0.68848974",
"0.68766606",
"0.68683016",
"0.686... | 0.78330463 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_academic_information
@academic_information = AcademicInformation.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 academic_information_params
params.require(:academic_information).permit(:b_date, :e_date, :description, :grade, :academic_degree_id, :course, :institution_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /repondres GET /repondres.json | def index
@repondres = Repondre.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @... | [
"0.66810554",
"0.66384983",
"0.65938544",
"0.65374804",
"0.63630056",
"0.6361198",
"0.6354697",
"0.63461787",
"0.6306491",
"0.629827",
"0.6254358",
"0.6228207",
"0.6131714",
"0.6119192",
"0.60912645",
"0.6084219",
"0.6056029",
"0.60557944",
"0.60557836",
"0.6034126",
"0.60206... | 0.69111854 | 0 |
GET /repondres/1 GET /repondres/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show... | [
"0.68548715",
"0.6804808",
"0.67578286",
"0.6684862",
"0.6663994",
"0.66192037",
"0.6594375",
"0.6590454",
"0.6587788",
"0.6497196",
"0.6417393",
"0.63467866",
"0.6332764",
"0.6326117",
"0.6312485",
"0.6307782",
"0.62773067",
"0.62745696",
"0.6259949",
"0.62594545",
"0.625527... | 0.0 | -1 |
POST /repondres POST /repondres.json | def create
@repondre = Repondre.new(repondre_params)
respond_to do |format|
if @repondre.save
format.html { redirect_to @repondre, notice: 'Repondre was successfully created.' }
format.json { render :show, status: :created, location: @repondre }
else
format.html { render :new }
format.json { render json: @repondre.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @repuesto = Repuesto.new(repuesto_param... | [
"0.67486906",
"0.64910513",
"0.6474885",
"0.63194746",
"0.63150126",
"0.6292258",
"0.6246537",
"0.62076414",
"0.6195743",
"0.61589086",
"0.6140582",
"0.60337466",
"0.5992653",
"0.5990383",
"0.5952739",
"0.59474397",
"0.58888096",
"0.58568925",
"0.58505213",
"0.58457494",
"0.5... | 0.7267646 | 0 |
PATCH/PUT /repondres/1 PATCH/PUT /repondres/1.json | def update
respond_to do |format|
if @repondre.update(repondre_params)
format.html { redirect_to @repondre, notice: 'Repondre was successfully updated.' }
format.json { render :show, status: :ok, location: @repondre }
else
format.html { render :edit }
format.json { render json: @repondre.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\... | [
"0.6501582",
"0.6449516",
"0.64425606",
"0.64194584",
"0.64194584",
"0.6331684",
"0.63238007",
"0.6316814",
"0.6294377",
"0.6283186",
"0.62355757",
"0.6211169",
"0.6210132",
"0.6210132",
"0.6201105",
"0.61946887",
"0.6174476",
"0.6165434",
"0.61550134",
"0.6143365",
"0.614154... | 0.6540675 | 0 |
DELETE /repondres/1 DELETE /repondres/1.json | def destroy
@repondre.destroy
respond_to do |format|
format.html { redirect_to repondres_url, notice: 'Repondre was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(param... | [
"0.71015644",
"0.69831276",
"0.69712216",
"0.6917839",
"0.6917161",
"0.68178993",
"0.68178993",
"0.6794902",
"0.6757411",
"0.6756695",
"0.6751125",
"0.67044115",
"0.67030483",
"0.66971534",
"0.66971534",
"0.668791",
"0.6687842",
"0.6682473",
"0.6671442",
"0.6653417",
"0.66471... | 0.7078386 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_repondre
@repondre = Repondre.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 repondre_params
params.require(:repondre).permit(:user_id, :question_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
The prepare method prepares training data. | def prepare(options = {})
raise "prepare not implemented"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare\r\n\t\t@machine \t||= @machineClass.new @trainTestStruct.trainingData, @target, @parameters\r\n\t\t@machine.train\r\n\tend",
"def prepare\n prepare_prerequisites\n @prepared = true\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def ... | [
"0.73330617",
"0.68806666",
"0.6878072",
"0.6878072",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.6719182",
"0.67147785",
"0.66166973",
"0.6616436",
"0.64895463",
"0.63574576",
"0.6310802",
"0.6310802",
"0.6310802",
"0.63080657",
"0.629846... | 0.545315 | 58 |
Trains the ANN with the training data (Don't forget to call prepare first) The desired error is divided by the normalizaion factor to respect data normalization. | def train(options = {})
options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 })
#fann.train_on_data(train_data, 10000, 100, 0.00001)
fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * normalization_factor)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(iterations=1)\n all_errors = []\n\n 1.upto(iterations) do |iteration|\n arguments = input_proc.call\n target_outputs = target_proc.call(*arguments)\n inputs = inputs_with_bias(arguments)\n actual_outputs = compute(*inputs)\n errors = actual_outputs.zip(target_outputs).map {... | [
"0.62786293",
"0.5942058",
"0.59141207",
"0.58798444",
"0.5814036",
"0.58032566",
"0.5654799",
"0.55475736",
"0.55252194",
"0.5481473",
"0.5470412",
"0.5452019",
"0.5338243",
"0.5287792",
"0.52805334",
"0.5244875",
"0.52251166",
"0.52147555",
"0.5177056",
"0.5149112",
"0.5120... | 0.6087506 | 1 |
Reinits the ANN and forgets learned stuff | def reset
init_fann
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset\n @fann = RubyFann::Standard.new fann_opts\n if algo && algo != :rwg\n fann.set_training_algorithm(algo)\n end\n if actfn\n fann.set_activation_function_hidden(actfn)\n fann.set_activation_function_output(actfn)\n end\n if init_weights_range\n fann.randomize_weights(... | [
"0.7521403",
"0.6686727",
"0.65604556",
"0.6288221",
"0.6282612",
"0.6225561",
"0.6075317",
"0.5897425",
"0.5828759",
"0.58217466",
"0.5800422",
"0.579044",
"0.57703185",
"0.57560396",
"0.5717115",
"0.57141227",
"0.57123655",
"0.57012695",
"0.5661192",
"0.5656705",
"0.5639851... | 0.703791 | 1 |
Runs fann on real inputs | def run(inputs, normalize_outputs = true)
outputs = fann.run(inputs)
if normalize_outputs
return outputs.map { |value| value / normalization_factor }
else
return outputs
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(options = {})\n options.reverse_merge!({ :max_epochs => 100000, :epochs_between_reports => 500, :desired_error => 0.0001 })\n #fann.train_on_data(train_data, 10000, 100, 0.00001)\n fann.train_on_data(train_data, options[:max_epochs], options[:epochs_between_reports], options[:desired_error] * no... | [
"0.61476433",
"0.5915051",
"0.58816946",
"0.5364278",
"0.5209733",
"0.5180717",
"0.517215",
"0.51483524",
"0.50332147",
"0.5018713",
"0.49074113",
"0.4829197",
"0.47957715",
"0.47709677",
"0.46796986",
"0.4667795",
"0.46353972",
"0.46081483",
"0.45909443",
"0.45753038",
"0.45... | 0.66603 | 0 |
Saves the fann config to a file | def save
fann.save("#{Rails.root}/data/#{self.class.to_s.tableize.singularize}.conf")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save()\n File.open(CONFIG_FILE, 'w'){ |f| f.write config.to_yaml } # Store\n end",
"def save\n File.open(file_name, 'w') { |f| f.write config.to_yaml }\n end",
"def save_configuration\n File.open(config_file, \"w\") do |file|\n file.write(YAML.dump(@config))\n end\n end"... | [
"0.7859885",
"0.7826591",
"0.7706767",
"0.7404447",
"0.74038047",
"0.7197372",
"0.71766025",
"0.7032632",
"0.69455636",
"0.6920137",
"0.6918178",
"0.6889352",
"0.6831635",
"0.6809291",
"0.6793825",
"0.6720782",
"0.67181635",
"0.6687445",
"0.6678079",
"0.66646945",
"0.6653411"... | 0.70767057 | 7 |
Creates a train data object | def train_data
::RubyFann::TrainData.new(
:inputs => inputs,
:desired_outputs=> desired_outputs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_train(train_type)\n Train.new(\n @train_types.find do |type|\n type.to_s.eql? \"#{train_type.fetch('type')}T\"\n end\n )\n end",
"def get_data\n\t\tdata_hash = {path: @data_file_path, training: @training_file_name, testing: @testing_file_name}\n\t\tDataLoader.new(da... | [
"0.6902376",
"0.6741095",
"0.66243464",
"0.6612536",
"0.66034895",
"0.6421533",
"0.63924855",
"0.6388731",
"0.6362683",
"0.63475466",
"0.633105",
"0.6317757",
"0.6254829",
"0.62411696",
"0.62387985",
"0.6237182",
"0.62371397",
"0.6182625",
"0.61688024",
"0.6128827",
"0.611282... | 0.7517891 | 0 |
==================== Generate Dummy Data ==================== | def gen_dummy_users
num = (1..5).to_a
users = num.map {|n| "user" + n.to_s}
emails = users.map {|e| e + "@mailforspam.com" }
num.each{ |n| User.create(email: emails[n - 1], password: "12312312", password_confirmation: "12312312", username: users[n - 1]) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dummy_values\n\t\tstock_rec = @@val\n\t\t@stock = Stock.find_by_ticker_symbol(stock_rec[\"ticker_symbol\"])\n\t\t@in_val = stock_rec[\"initial_stock_value\"].to_f\n\t\t@first_val = (@in_val - 100) <= 0 ? 0 : @in_val-100\n\t\tcolumns = [:stock_value, :stock_id]\n\t\t@all_dummy =[]\n\t\t(1..20).each do\n\... | [
"0.68380237",
"0.5990347",
"0.5918289",
"0.5883012",
"0.5880438",
"0.5876096",
"0.5621978",
"0.5573727",
"0.5563637",
"0.5506718",
"0.54268116",
"0.5391417",
"0.5389615",
"0.5376903",
"0.5346934",
"0.5346644",
"0.5332797",
"0.53145105",
"0.5280209",
"0.5280209",
"0.52691686",... | 0.54397416 | 10 |
Grab file read opts in the context | def file_read_opts(context)
context.registers[:site].file_read_opts
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_read_opts(context); end",
"def file_read_opts(context)\n context.registers[:site].file_read_opts\n end",
"def file_read_opts; end",
"def file_read_opts=(_arg0); end",
"def merged_file_read_opts(site, opts); end",
"def read_file(file, context); end",
"def command_options(opts)\n ... | [
"0.9021648",
"0.8383723",
"0.82770896",
"0.8101842",
"0.7288544",
"0.7150626",
"0.6790383",
"0.6417459",
"0.63896096",
"0.63300806",
"0.6267239",
"0.6236957",
"0.62325937",
"0.6200525",
"0.61569834",
"0.60986346",
"0.6097233",
"0.6050391",
"0.6044381",
"0.5990629",
"0.5976276... | 0.83096886 | 2 |
This method allows to modify the file content by inheriting from the class. | def source(file, context)
File.read(file, file_read_opts(context))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content= content\n @file = content\n @content = content.dup\n @content &&= @content.read if @content.respond_to? :read\n @content &&= @content.to_s if @content.respond_to? :read\n end",
"def render\n File.open(@file.output_path, \"w\") { |file| file.write(super) }\n end... | [
"0.68086666",
"0.65491617",
"0.63522345",
"0.62686956",
"0.616935",
"0.61292666",
"0.60146105",
"0.6005256",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.6002504",
"0.59984416",
"0.5993044... | 0.0 | -1 |
GET /post_parts GET /post_parts.json | def index
@post_parts = PostPart.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parts\n body.parts\n end",
"def parts\n @audio_file = AudioFile.find(params[:id])\n @parts = @audio_file.parts\n\n respond_to do |format|\n format.html # parts.html.erb\n format.xml { render :xml => @parts }\n format.json { render :json => @parts }\n end\n end",
"def sho... | [
"0.64217854",
"0.6355506",
"0.6234015",
"0.61558855",
"0.61489296",
"0.61131287",
"0.6068686",
"0.6002622",
"0.598498",
"0.59259564",
"0.59259564",
"0.59259564",
"0.5896",
"0.58364743",
"0.5834151",
"0.5834151",
"0.5785025",
"0.57775843",
"0.5747439",
"0.57305986",
"0.5730596... | 0.6966223 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.