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 /part_time_employees/1 DELETE /part_time_employees/1.json | def destroy
@part_time_employee.destroy
respond_to do |format|
format.html { redirect_to part_time_employees_url, notice: 'Part time employee was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteEntityEmployee( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/employee\",params)\n end",
"def destroy\n @hisd_employee = HisdEmployee.find(params[:id])\n @hisd_employee.destroy\n\n respond_... | [
"0.6858969",
"0.6697969",
"0.66694945",
"0.664149",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6623983",
"0.66137403",
"0.66059476",
"0.6593751",
"0.6593751",
"0.6593751",
"0.6593751",
"0.6576537",
"0.6573103",
"0.65705514",
... | 0.7205989 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_part_time_employee
@part_time_employee = PartTimeEmployee.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 part_time_employee_params
params.require(:part_time_employee).permit(:dateOfHire, :dateOfTermination, :hourlyRate)
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 |
sox $(ls .wav | sort n) out.wav | def execute(speed = false, repeat = 10)
folder = "/Users/THAO-NUS/Music/ProcessingMp3/Processing"
origin_folder = "public/audio/#{self.vol_aulm.name}"
speed = speed.present? ? "tempo #{speed}" : ''
each_durations.each_with_index do |arr, index|
duration = arr[1].to_i - arr[0].to_i
start = arr[0].to_i
name = "#{sprintf('%02d',index + 1)}.mp3"
full_name = "#{folder}/#{name}"
origin_full_name = Shellwords.shellescape "#{origin_folder}/#{self.name}"
command = "sox -e ima-adpcm #{origin_full_name} #{full_name} trim #{start} #{duration} repeat #{repeat} #{speed}"
system(command)
end
outname = Shellwords.shellescape("/Users/THAO-NUS/Music/ProcessingMp3/Results/#{self.name}")
command = "sox $(ls /Users/THAO-NUS/Music/ProcessingMp3/Processing/*.mp3 | sort -d) #{outname}"
system(command)
FileUtils.rm_rf("/Users/THAO-NUS/Music/ProcessingMp3/Processing/.", secure: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scribe\n raise 'bork' unless ARGV.any?\n\n name, type = ARGV.first.split('.')\n name_bits = name.to_s.ljust(64, ' ').to_bits\n type_bits = type.to_s.ljust(5, ' ').to_bits\n data_bits = File.open(ARGV.first) { |file| file.read }.to_bits\n size = data_bits.count / 8\n size_bits = (\"%032b\" % size).split(... | [
"0.60384905",
"0.590835",
"0.582267",
"0.5712577",
"0.5697814",
"0.567468",
"0.561638",
"0.5577669",
"0.5565335",
"0.5553919",
"0.55359274",
"0.5440316",
"0.54380584",
"0.54294443",
"0.53794223",
"0.5376741",
"0.53297716",
"0.5295352",
"0.52881324",
"0.5286454",
"0.5275517",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_pre_total_party_num
@pre_total_party_num = PreTotalPartyNum.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.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def pre_total_party_num_params
params.require(:pre_total_party_num).permit(:result_no, :generate_no, :e_no, :count_type, :party_num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Deepens elements through a Copier. | def deepen_copy! copier, src
@a = @a.map { | x | copier[x] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_clone; end",
"def __deep_copy__\n map { |value| value.__deep_copy__ }\n end",
"def deep_dup; end",
"def deep_copy\n answer = []\n %w[1 2 3 4 5 6].each do |elem|\n answer << elem.dup\n end\n answer\nend",
"def __deep_copy__\n self.class.new(aliases) do |copy|\n ... | [
"0.53555644",
"0.5301371",
"0.52057594",
"0.516215",
"0.5143115",
"0.50753987",
"0.50435585",
"0.49854043",
"0.4959328",
"0.4959328",
"0.49462602",
"0.4929271",
"0.49226788",
"0.49226788",
"0.49226788",
"0.491132",
"0.49070835",
"0.49054265",
"0.49022087",
"0.4898465",
"0.488... | 0.68174386 | 0 |
Updates the priviledges of a user | def update_user_role(params)
self.link.update_attributes(role: params[:rolname], active: params[:active_link])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_user_overrides(token, channel_id, user_id, allow, deny)\n request(\n __method__,\n :put,\n \"#{api_base}/channels/#{channel_id}/permissions/#{user_id}\",\n { type: 'member', id: user_id, allow: allow, deny: deny }.to_json,\n Authorization: token,\n content_type: :json\n ... | [
"0.65377885",
"0.63686997",
"0.63251936",
"0.63216645",
"0.61685115",
"0.61518425",
"0.6149679",
"0.61387736",
"0.61376715",
"0.61340845",
"0.6132937",
"0.6023069",
"0.6023069",
"0.6010269",
"0.5987902",
"0.5957384",
"0.59471345",
"0.59446675",
"0.5924825",
"0.589664",
"0.585... | 0.0 | -1 |
Build instance of model from fixture's DEFAULTS. | def build(model_name, attributes = {}) # rubocop:disable AbcSize, MethodLength
hash = begin
path = fixtures_path + '/' + model_name.to_s.pluralize + '.yml'
line = YAML.load(ERB.new(File.read(path)).result)['DEFAULTS'] # rubocop:disable YAMLLoad
instance_eval(ERB.new(line.to_s.gsub('$LABEL', 'sample')).result)
end
attributes.each { |key, value| hash[key] = value }
if model_name == :account
hash[:password] = APP::DEFAULT_PASSWORD
hash[:password_confirmation] = APP::DEFAULT_PASSWORD
end
##
correction = lambda do |ref|
if hash[ref].present?
hash["#{ref}_id"] = accounts(hash[ref].to_sym).id if ref == 'account'
hash["#{ref}_id"] = users(hash[ref].to_sym).id if ref == 'user'
hash["#{ref}_id"] = targets(hash[ref].to_sym).id if ref == 'target'
hash.delete(ref)
end
end
correction.call('account')
correction.call('user')
correction.call('target')
##
model_name.to_s
.classify
.constantize.new(hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_default_attributes\n self.config_params ||= DEFAULT_CONFIG_PARAMS\n self.has_inventory = true\n end",
"def default_model_attrs\n @default_model_attrs ||= begin\n config[:model].constantize.netzke_attributes.map do |attr| \n attr.merge(\n :label => attr[:lab... | [
"0.5761208",
"0.5693238",
"0.5670357",
"0.5561082",
"0.5439651",
"0.5435143",
"0.5305661",
"0.52687776",
"0.52553135",
"0.52140546",
"0.5160349",
"0.51529276",
"0.51505506",
"0.5137352",
"0.5136639",
"0.5120106",
"0.51023155",
"0.50991195",
"0.5077334",
"0.5076242",
"0.506746... | 0.609392 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_match
@match = Match.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 match_params
params.require(:match).permit(:meatcut_id, :technique_id, :good_idea, :notes)
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 |
TODO: add mode attr_accessor :mode | def initialize(string, project_id: nil, **keyword_args)
@query_string = ::ApplicationRecord.sanitize_sql(string)&.delete("\u0000") # remove null bytes
@project_id = project_id
build_terms # TODO - should remove this for accessors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mode; end",
"def mode; end",
"def mode; end",
"def mode; end",
"def mode() end",
"def mode\n @mode\n end",
"def modes; end",
"def mode() @mode ||= detect_mode end",
"def get_mode()\n end",
"def mode\n Initialize() if @_mode == nil\n\n @_mode\n end",
"def mode=(_arg0); ... | [
"0.8569273",
"0.8569273",
"0.8569273",
"0.8569273",
"0.8052261",
"0.79392755",
"0.792404",
"0.7699949",
"0.75456685",
"0.74582523",
"0.74266803",
"0.74266803",
"0.74266803",
"0.73595005",
"0.7313339",
"0.71546894",
"0.71342623",
"0.70657176",
"0.6966283",
"0.69587773",
"0.681... | 0.0 | -1 |
Match at two levels, for example, 'wa te" will match "Washington Co., Texas" | def parent_child_where
a,b = query_string.split(/\s+/, 2)
return table[:id].eq(-1) if a.nil? || b.nil?
table[:name].matches("#{a}%").and(parent[:name].matches("#{b}%"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_string( tree, string )\n # puts \"Checking for `#{string}` in tree (#{tree}).\"\n\n if tree.empty?\n # puts \"Tree is empty, returning empty\"\n return [ ]\n\n elsif string.empty?\n # puts \"No search string, returning empty\"\n return [ ]\n\n else\n matches = [ ]\n\n... | [
"0.5746868",
"0.57285446",
"0.568868",
"0.5543908",
"0.5459666",
"0.5459211",
"0.54466236",
"0.5395936",
"0.5356025",
"0.5349556",
"0.5347985",
"0.5330886",
"0.53215265",
"0.53215265",
"0.5320119",
"0.52464145",
"0.5221318",
"0.5215134",
"0.51807195",
"0.51771665",
"0.5173507... | 0.0 | -1 |
TODO: nil/or clause this | def with_project_id
if project_id.present?
table[:project_id].eq_any(project_id)
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maybe so, maybe: self\n so\n end",
"def or_d\n end",
"def or_c\n end",
"def or_b\n end",
"def or_e\n end",
"def maybe so, maybe: self\n maybe\n end",
"def or_l\n end",
"def or_a\n end",
"def conditionally(*) end",
"def conditionally(*) end",
"de... | [
"0.6419483",
"0.6408589",
"0.62934476",
"0.617495",
"0.6129299",
"0.6068851",
"0.602242",
"0.59848434",
"0.58939224",
"0.58939224",
"0.5744425",
"0.57355857",
"0.57355857",
"0.5687191",
"0.56871563",
"0.5669496",
"0.5650502",
"0.56458306",
"0.56374633",
"0.56013143",
"0.55770... | 0.0 | -1 |
match ALL wildcards, but unordered, if 2 6 pieces provided | def match_wildcard_end_in_cached
table[:cached].matches(end_wildcard)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(pattern); end",
"def match(*list)\n @match.concat(makelist(list)) unless list.empty?\n @match\n end",
"def imatches_all others, escape = nil\n grouping_all :imatches, others, escape, escape\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty... | [
"0.61320627",
"0.59943676",
"0.5917876",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5823603",
"0.58092517",
"0.5697889",
"0.5697889",
"0.56527233",
"0.5644001",
"0.5605667",
"0.5603727",
"0.55845654",
"0.5583268",
"0.55739975",
"0.5553339... | 0.0 | -1 |
match ALL wildcards, but unordered, if 2 6 pieces provided | def match_wildcard_in_cached
b = fragments
return nil if b.empty?
table[:cached].matches_all(b)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(pattern); end",
"def match(*list)\n @match.concat(makelist(list)) unless list.empty?\n @match\n end",
"def imatches_all others, escape = nil\n grouping_all :imatches, others, escape, escape\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty... | [
"0.61340636",
"0.5994068",
"0.5918028",
"0.58611745",
"0.58611745",
"0.58611745",
"0.58611745",
"0.58611745",
"0.58611745",
"0.582654",
"0.5809954",
"0.56997716",
"0.56997716",
"0.5654367",
"0.5645336",
"0.56065375",
"0.5602922",
"0.55860627",
"0.55830467",
"0.5574353",
"0.55... | 0.5256435 | 56 |
Autocomplete !! All methods must return nil of a scope | def autocomplete
all.to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autocomplete; end",
"def auto_complete\n @query = params[:auto_complete_query]\n @auto_complete = self.controller_name.classify.constantize.scoped(:limit => 10).search(@query)\n render :template => \"common/auto_complete\", :layout => nil\n end",
"def findorsuggest()\n \n end",
"def auto_co... | [
"0.82597834",
"0.7440826",
"0.7344279",
"0.7231499",
"0.7136554",
"0.708994",
"0.7024913",
"0.7002947",
"0.6929823",
"0.6929823",
"0.6929823",
"0.6903167",
"0.68102777",
"0.67807907",
"0.6771609",
"0.6759399",
"0.67557424",
"0.6754824",
"0.6750441",
"0.67503244",
"0.6746515",... | 0.6569784 | 26 |
Calculate the levenshtein distance for a value across multiple columns, and keep the smallest. | def least_levenshtein(fields, value)
levenshtein_sql = fields.map {|f| levenshtein_distance(f, value).to_sql }
Arel.sql("least(#{levenshtein_sql.join(", ")})")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_score(*args)\n rows = args.first\n # if there's only one word, everyone wins!\n if rows[0].size <= 2\n rows.to_hash { |row| [row[0], 1,0] }\n else\n min_dist = rows.to_hash { |row| [row[0], 1000000] }\n\n rows.each do |row|\n dist = 0\n (2..ro... | [
"0.69780916",
"0.68045384",
"0.6780291",
"0.66444075",
"0.6601021",
"0.65644115",
"0.6548052",
"0.6448385",
"0.6367415",
"0.6362948",
"0.63607544",
"0.6348901",
"0.62991655",
"0.6265237",
"0.6261299",
"0.62290937",
"0.6214679",
"0.6208014",
"0.6188738",
"0.61671233",
"0.61473... | 0.7554327 | 0 |
TEMPORARY PATCH TO GET THE GRID ROW FILTER FUNCTION. NEED TO REVIEW THIS. Implementation for the "get_data" endpoint | def get_data(*args)
params = args.first || {} # params are optional!
params["limit"] = nil if (params.empty? == false and config[:enable_pagination] == false)
session_name = (config[:item_id].to_s + "_filter").to_sym
if (params[:filter1] || component_session[session_name])
component_session[session_name] = params[:filter1] || component_session[session_name]
params[:filter] = component_session[session_name]
end
if !config[:prohibit_read]
{}.tap do |res|
records = get_records(params)
res[:data] = records.map{|r| r.netzke_array(columns(:with_meta => true))}
res[:total] = count_records(params) if config[:enable_pagination]
end
else
flash :error => "You don't have permissions to read data"
{ :netzke_feedback => @flash }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n self.data_grid.in_data.each do |d|\n if col.sort_by.class == Symbol\n col.filter_data << d.se... | [
"0.6162527",
"0.6090875",
"0.5870674",
"0.5672842",
"0.5644906",
"0.5632053",
"0.56187004",
"0.5609423",
"0.55813223",
"0.55688494",
"0.5558987",
"0.5553622",
"0.5519427",
"0.5518594",
"0.55093014",
"0.55067664",
"0.549222",
"0.54846996",
"0.54448706",
"0.5444231",
"0.5440396... | 0.60250616 | 2 |
main method magic at the bottom makes it run | def process
# here is a starting directory
main_dir = '/home/john/code/ruby/files'
# let's go to the directory we want
Dir.chdir(main_dir)
#print the present working directory (pwd)
puts Dir.pwd
# glob is stolen from Perl - list all the
# matches for the wildcard pattern "*"
listing = Dir.glob("*")
# put out the list
puts listing.inspect
#let's process the subdirectories and discard other files
listing.each do |f|
if File.directory? f
processDirectory f
else
puts "ignoring file: " + f
end
end
puts @power.inspect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main; end",
"def run_main\n end",
"def main\n\n end",
"def main\n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run() end",
"def run\n end",
"def run\n end",
"... | [
"0.8372393",
"0.82667977",
"0.82236934",
"0.82036453",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.7652363",
"0.76128864",
"0.76128864",
"0.76128864",
"0.76128864",
"0.76128864",
"0.76128864",
... | 0.0 | -1 |
Is the user logged in or not? | def authenticate
if signed_in? == false
flash.now[:error] = "User not logged in."
respond_with(flash)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n !!logged_user\n end",
"def logged_in?\n if current_user\n true\n else\n false\n end\n end",
"def user_is_logged_in?\n !!session[... | [
"0.9070548",
"0.8805575",
"0.8769474",
"0.87556773",
"0.8705976",
"0.8703326",
"0.8696083",
"0.8695365",
"0.86890256",
"0.86890256",
"0.8683884",
"0.86760247",
"0.8675657",
"0.8672885",
"0.8658672",
"0.8652611",
"0.8648053",
"0.86465716",
"0.8641195",
"0.8636966",
"0.8636966"... | 0.0 | -1 |
Write a method that takes an Array as an argument, and returns two Arrays (as a pair of nested Arrays) that contain the first half and second half of the original Array, respectively. If the original array contains an odd number of elements, the middle element should be placed in the first half Array. | def halvsies(arr)
halfway = arr.size / 2
halfway += 1 if arr.size.odd?
first_half = arr[0..(halfway - 1)]
second_half = arr[halfway..-1]
[first_half, second_half]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def halvsies(array)\n if array.size.even?\n arr1 = array.slice(0, (array.size / 2))\n arr2 = array.slice(array.size / 2, array.size)\n else\n arr1 = array.slice(0, (array.size / 2) + 1 )\n arr2 = array.slice((array.size / 2) + 1, array.size)\n end \n [arr1, arr2]\nend",
"def first_half(array)\n\n... | [
"0.77604485",
"0.7758353",
"0.7709774",
"0.7699967",
"0.7678196",
"0.76556075",
"0.7619841",
"0.76069474",
"0.75140005",
"0.75077814",
"0.7506743",
"0.74859536",
"0.74795204",
"0.7472657",
"0.7471359",
"0.7451214",
"0.7443248",
"0.74424607",
"0.74252826",
"0.74070036",
"0.740... | 0.73730475 | 31 |
GET /items GET /items.json | def index
@search = Item.search(params[:q])
@search.sorts = 'name asc' if @search.sorts.empty?
@items = @search.result
if params[:q].present?
params[:q].each do |k, v|
if v == 'name asc'
@items = @search.result.sort { |p1, p2| p1.name.downcase <=> p2.name.downcase }
elsif v == 'name desc'
@items = @search.result.sort { |p2, p1| p1.name.downcase <=> p2.name.downcase }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @items =... | [
"0.79562956",
"0.7546286",
"0.74375594",
"0.7434485",
"0.73975587",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7357372",
"0.7313286",
"0.73129123",
"0.7311041",
"0.7306297",
"0.7281173",
"0.7273615",
"0.72629416",
"0.72484964",
"0.72301924",
"0.71767205",
"0.71181... | 0.0 | -1 |
GET /items/1 GET /items/1.json | def show
@item = Item.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n item = I... | [
"0.77359843",
"0.75480026",
"0.7493958",
"0.7370239",
"0.73272145",
"0.72927445",
"0.7286665",
"0.7132088",
"0.712437",
"0.7119644",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.... | 0.65272504 | 72 |
POST /items POST /items.json | def create
@item = Item.new(item_params)
vendor = Vendor.find(item_params[:vendor_id])
@item.build_vendor(:id => vendor.id)
@item.save!
@current_item = @item
@items = Item.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n\t\titem = Item.create(item_params)\n\t\trender json: item\n\tend",
"def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { ... | [
"0.7971939",
"0.7285761",
"0.7231758",
"0.721958",
"0.71792215",
"0.71131957",
"0.7062943",
"0.7053179",
"0.6988855",
"0.69712186",
"0.6903009",
"0.68806237",
"0.6871792",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6839645",
... | 0.0 | -1 |
PATCH/PUT /items/1 PATCH/PUT /items/1.json | def update
@item.update!(item_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def update\n\n #update the item of request_item\n if (par... | [
"0.7442021",
"0.71437544",
"0.7139624",
"0.70251447",
"0.70026696",
"0.69958323",
"0.6980672",
"0.69373846",
"0.69218457",
"0.68723136",
"0.6832834",
"0.68177253",
"0.6805765",
"0.6805765",
"0.6794939",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.... | 0.6681448 | 47 |
DELETE /items/1 DELETE /items/1.json | def destroy
@item.destroy!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def destroy\n @item = Item.find(params[:id... | [
"0.7906849",
"0.76885504",
"0.7604411",
"0.7585917",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.7547388",
"0.7539847",
"0.7528851",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_item
@item = Item.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.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def item_params
params.require(:item).permit(:name, :price, :category)
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.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894"... | 0.0 | -1 |
Method to create a list input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: "read the items" set default quantity store the items print the list to the console "p" visualize without making it nil output: [hash] Method to add an item to a list input: item name and optional quantity steps: create a key and assign its value output: hash Method to remove an item from the list input: ask which item? steps: used built in delete method to delete the key output: hash Method to update the quantity of an item input: ask which key and update the value steps: within the assigned key update value output:hash Method to print a list and make it look pretty input: our wondeful hash steps: iterate through the hash output: all the keyvalue pairs. | def create_a_list(list)
shopping_list = {}
split_list = list.split(" ")
split_list.each do |item, value|
shopping_list[item] = 1
end
shopping_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(user_list)\n# input: string of items separated by spaces (example: \"carrots apples cereal pizza\")\n# puts \"\"\n# steps:\n # [fill in any steps here]\n list_array = user_list.split(\",\")\n # set default quantity\n quanity = 1\n # print the list to the console [can you use one of your other ... | [
"0.80289197",
"0.79332864",
"0.780832",
"0.7738323",
"0.7700039",
"0.76259136",
"0.7519497",
"0.7492596",
"0.74637675",
"0.7453621",
"0.73946893",
"0.7376693",
"0.7369323",
"0.73631585",
"0.73361844",
"0.73173",
"0.7307453",
"0.72594804",
"0.71793735",
"0.71606386",
"0.714650... | 0.0 | -1 |
Merge Sort Use this method if you want to sort. | def merge_sort(list)
length = list.length
if length <= 1
return list
end
mid = length/2
a = list.slice(0...mid)
b = list.slice(mid..-1)
ma = merge_sort(a)
mb = merge_sort(b)
merge(ma, mb)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_sort(&prc)\n end",
"def merge_print_sort\n @merge.print_sort\n end",
"def merge_sort\n if self.length <= 1\n return self\n else\n mid = self.length/2\n return merge(self[0...mid].merge_sort, self[mid..-1].merge_sort)\n end\n end",
"def merge_sort(&prc)\n prc || = proc... | [
"0.7736465",
"0.7735201",
"0.74303526",
"0.73996294",
"0.72023076",
"0.71895605",
"0.71866834",
"0.7141702",
"0.7137038",
"0.7131655",
"0.7127414",
"0.7122761",
"0.71124804",
"0.70826566",
"0.7075958",
"0.70707476",
"0.7040145",
"0.6997403",
"0.6997403",
"0.69971067",
"0.6975... | 0.70619637 | 16 |
between the square of the sum of the first n positive integers and the sum of the squares of the first n positive integers. | def sum_square_difference(num)
arr = (1..num).to_a
square_of_arr_summed = (arr.sum) ** 2
square_of_each_num = arr.reduce(0) { |sum, n| sum + n**2 }
# Alternatively
# square_of_each_num = 0
# arr.each { |element| square_of_each_num += element **2 }
return square_of_arr_summed - square_of_each_num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difference_between_sum_sq_and_sq_sum(n)\n square_sum(n) - sum_squares(n)\nend",
"def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end",
"def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end",
"def sum_sq_diff(n)\n nums_in_range = (1..n)\n # sq... | [
"0.793197",
"0.7931715",
"0.7897907",
"0.78956383",
"0.7857072",
"0.77559835",
"0.77504843",
"0.7740316",
"0.77225846",
"0.77178925",
"0.7686875",
"0.7667874",
"0.765986",
"0.7632239",
"0.76199853",
"0.7618291",
"0.7582311",
"0.7550638",
"0.75415814",
"0.753873",
"0.7516909",... | 0.6526799 | 100 |
arr3.to_s.each_char do |char| p char end | def arr_sum(array)
num_list = []
array.to_s.each_char do |char|
p char
if char.match(/[0-9]/) #== true
num_list << char
end
end
sum = 0
num_list.each do |s|
sum += s.to_i
end
return num_list, sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_output()\n\t#print \"$array= \\n\"\n\t$array.each { |i| i.each {\n\t\t\t\t\t |j|\n\t\t\t\t\t case j\n\t\t\t\t\t when 4\n\t\t\t\t\t \tprint \"•\"\n\t\t\t\t\t when 3\n\t\t\t\t\t \tprint \"x\"\n\t\t\t\t\t when 2\n\t\t\t\t\t \tprint \"*\"\n\t\t\t\t\t when 1\n\t\t\t\t\t \tprint \"█\"\n\t\t\t\t\t when 0\n\t\t\... | [
"0.6965731",
"0.6939056",
"0.6824498",
"0.67705745",
"0.6763379",
"0.66111684",
"0.6567642",
"0.6543147",
"0.65339977",
"0.6520474",
"0.651896",
"0.6423507",
"0.62692755",
"0.6260665",
"0.62372744",
"0.61934906",
"0.61292994",
"0.61099064",
"0.61079377",
"0.6084064",
"0.60377... | 0.5619675 | 63 |
Checks that the move is valid by making sure it is within the range of possible moves | def valid_move? (board, index)
if (0..8) === index && board[index] === " "
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validates_move move\n\t\t!@moves.include?(move) && move.index.between?(1,10)\n\tend",
"def valid_move?(move)\n move.to_i.between?(1,9) && !taken?(move)\n end",
"def is_move_valid(move)\n @moves.include? move\n end",
"def valid_move?\n\t\tvalid_1 = (0..2).include? (@take_from)\n\t\tvalid_2 = (0..2... | [
"0.82396686",
"0.81439435",
"0.7931976",
"0.7853597",
"0.78374326",
"0.78251886",
"0.77923495",
"0.77881753",
"0.77776957",
"0.77742714",
"0.7764888",
"0.77590144",
"0.7751034",
"0.7747991",
"0.7716483",
"0.77114975",
"0.7703074",
"0.7697626",
"0.76874596",
"0.76863134",
"0.7... | 0.0 | -1 |
Sets the position of the board to "X" or "O" | def move (board, index, token)
#token = current_player(board)
board[index] = token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(board, position, xo = \"X\")\n board[position] = xo\nend",
"def move(index, character = \"X\")\n if character == \"X\"\n @board[index] = \"X\"\n else character == \"O\"\n @board[index] = \"O\"\nend\nend",
"def move(board, index, character)\n character = \"X\"\nend",
"def move(board, index,... | [
"0.7539639",
"0.7498335",
"0.74851763",
"0.74424577",
"0.74150425",
"0.7159376",
"0.7153838",
"0.71064365",
"0.70961285",
"0.7075321",
"0.70524573",
"0.7024819",
"0.70148015",
"0.7008469",
"0.6980267",
"0.69736",
"0.6938956",
"0.6911046",
"0.689789",
"0.68960243",
"0.68895584... | 0.0 | -1 |
Converts the user input of board position (from 19) to the correct position in the zeroindexed array (08) | def input_to_index(user_input)
if user_input.to_i.class != Fixnum
return -1
end
user_input = user_input.to_i
user_input -=1
return user_input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_to_index(user_input)\n #take the user's input (\"1\"-\"9\") and convert it to the index of the board array (0-8)\n user_input.to_i - 1\nend",
"def input_to_index(user_input) #this method converts the user_input into the 0-8 index, AKA the position on the board\n user_input = user_input.to_i # assi... | [
"0.7440147",
"0.70697844",
"0.68589056",
"0.6848182",
"0.6550733",
"0.64466286",
"0.63977313",
"0.6328134",
"0.63238525",
"0.6311314",
"0.6238591",
"0.6218867",
"0.621603",
"0.61983496",
"0.6166908",
"0.61593604",
"0.61370987",
"0.6128387",
"0.61195743",
"0.6094401",
"0.60131... | 0.0 | -1 |
checks how many turns have been played | def turn_count(board)
turn_counter = 0
board.each do |spot|
if spot == "X" || spot.upcase == "O"
turn_counter +=1
end
end
return turn_counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_count\n turns_played = 0\n @board.each do |index|\n if index != \" \"\n turns_played += 1\n end\n end\n return turns_played\n end",
"def number_correct\n turns.count do |each_turn|\n each_turn.correct?\n end\n end",
"def turn_count\r\n turns_so_far = 0\... | [
"0.7793495",
"0.7577511",
"0.7561987",
"0.754469",
"0.7528732",
"0.7509197",
"0.74699503",
"0.74318963",
"0.7415337",
"0.7413886",
"0.7375327",
"0.73628116",
"0.7354928",
"0.7340143",
"0.73315424",
"0.7300869",
"0.7284414",
"0.7263449",
"0.7253604",
"0.7239764",
"0.7224517",
... | 0.0 | -1 |
tells us who the current player is, X or O | def current_player(board)
if turn_count(board) % 2 == 0
return "X"
else
return "O"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_player\n\t\tturn_count % 2 == 0 ? \"X\" : \"O\"\n\tend",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n return turn_count%2==0 ? \"X\" : \"O\"\n end",
"def current_player\r\n if turn_count % 2 != 0\r\n return \"O\"\r\n else\r\n ... | [
"0.7785548",
"0.77685636",
"0.7745381",
"0.7736633",
"0.7711894",
"0.7707101",
"0.7688385",
"0.7650499",
"0.75848806",
"0.75848806",
"0.758063",
"0.75792843",
"0.75531393",
"0.7549586",
"0.75310326",
"0.7529044",
"0.75264955",
"0.7519843",
"0.7494961",
"0.7493004",
"0.7488470... | 0.0 | -1 |
Define your play method below | def play(board)
9.times {turn(board)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play\n \n end",
"def play; end",
"def play \n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n\tend",
"def play\n #calls to all the methods that produce game!\n end",
"def play\n self\n end",
"def get_play(... | [
"0.91277385",
"0.9031555",
"0.90065134",
"0.900332",
"0.900332",
"0.900332",
"0.900332",
"0.8978301",
"0.88647234",
"0.8184945",
"0.80578035",
"0.79240173",
"0.78456163",
"0.7765175",
"0.77345335",
"0.76989305",
"0.7611273",
"0.7611273",
"0.7528091",
"0.74453044",
"0.74384725... | 0.0 | -1 |
method to find out if the board contains any of the win combinations | def won?(board)
WIN_COMBINATIONS.each do |combo|
win_combination = [combo[0], combo[1], combo[2]]
windex1 = win_combination[0]
windex2 = win_combination[1]
windex3 = win_combination[2]
pos1 = board[windex1]
pos2 = board[windex2]
pos3 = board[windex3]
win_combo = [pos1,pos2,pos3]
if pos1 == "X" && pos2 == "X" && pos3 == "X" || pos1 =="O" && pos2 == "O" && pos3 == "O"
return win_combination
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def won?(board)\n res = false\n WIN_COMBINATIONS.each do |win_combination|\n board_entries = [board[win_combination[0]], board[win_combination[1]], board[win_combination[2]]]\n board_entries == [\"X\", \"X\", \"X\"] || board_entries == [\"O\", \"O\", \"O\"] ? res = win_combination : false\n end\... | [
"0.86590326",
"0.86038566",
"0.85727125",
"0.85500234",
"0.853805",
"0.8537946",
"0.8521563",
"0.85176927",
"0.85156965",
"0.85156965",
"0.85156965",
"0.8508075",
"0.8491223",
"0.84568334",
"0.84568334",
"0.84557843",
"0.84549016",
"0.8442815",
"0.84313375",
"0.84222704",
"0.... | 0.81455946 | 94 |
Preview this email at | def shipped
OrderMailer.shipped
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = DirectEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview_email\r... | [
"0.71475905",
"0.71186084",
"0.70552814",
"0.6985626",
"0.6848472",
"0.6848472",
"0.6832406",
"0.6663229",
"0.64324814",
"0.631654",
"0.6304366",
"0.6181875",
"0.6167911",
"0.61338973",
"0.61305445",
"0.6115152",
"0.61100966",
"0.61100966",
"0.60882556",
"0.60132533",
"0.5982... | 0.0 | -1 |
GET /mensajes or /mensajes.json | def index
@mensajes = Mensaje.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end",
"def index\n @mentor_messages = MentorMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n for... | [
"0.6474655",
"0.64470345",
"0.6349967",
"0.6340613",
"0.6273685",
"0.6273383",
"0.6195066",
"0.6195066",
"0.6179346",
"0.6155237",
"0.6123657",
"0.611505",
"0.61145943",
"0.61027575",
"0.60651505",
"0.6064412",
"0.60322434",
"0.60308146",
"0.6023947",
"0.6022994",
"0.60214525... | 0.64247584 | 2 |
GET /mensajes/1 or /mensajes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @mensaje = Mensaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje }\n end\n end",
"def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n form... | [
"0.6719897",
"0.63115054",
"0.6285699",
"0.6268227",
"0.62421393",
"0.6217299",
"0.6213858",
"0.6188329",
"0.613486",
"0.6119665",
"0.6099896",
"0.6078144",
"0.606392",
"0.6054196",
"0.6044381",
"0.601308",
"0.60050523",
"0.6003318",
"0.59999484",
"0.5986368",
"0.5976768",
... | 0.0 | -1 |
POST /mensajes or /mensajes.json | def create
@mensaje = Mensaje.new(mensaje_params)
respond_to do |format|
if @mensaje.save
format.html { redirect_to @mensaje, notice: "Mensaje was successfully created." }
format.json { render :show, status: :created, location: @mensaje }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @mensaje.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @mensagem = Mensagem.new(params[:mensagem])\n @mensagem.autor = session[:current_user]\n id_to_post = String.new\n \n case @mensagem.recebedor_type\n when \"Turma\"\n aux = Turma.find(@mensagem.recebedor_id)\n id_to_post = aux.group_id\n end\n \n @mensagem.post_id ... | [
"0.66093904",
"0.6364882",
"0.63566566",
"0.62934035",
"0.62187797",
"0.6175252",
"0.6107447",
"0.6086889",
"0.6086532",
"0.60295355",
"0.6029447",
"0.6013697",
"0.60066587",
"0.59801626",
"0.5974442",
"0.594035",
"0.59205973",
"0.5899924",
"0.5899279",
"0.58917725",
"0.58806... | 0.65233135 | 1 |
PATCH/PUT /mensajes/1 or /mensajes/1.json | def update
respond_to do |format|
if @mensaje.update(mensaje_params)
format.html { redirect_to @mensaje, notice: "Mensaje was successfully updated." }
format.json { render :show, status: :ok, location: @mensaje }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @mensaje.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @mensagem.update(mensagem_params)\n format.html { redirect_to @mensagem, notice: 'Mensagem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @m... | [
"0.6980855",
"0.6486283",
"0.64420754",
"0.64306116",
"0.6394283",
"0.63912404",
"0.63697994",
"0.63569194",
"0.62643397",
"0.62565565",
"0.6241376",
"0.623684",
"0.62282264",
"0.62063974",
"0.6185084",
"0.61837757",
"0.6170775",
"0.61664444",
"0.615576",
"0.6150362",
"0.6135... | 0.64758664 | 2 |
DELETE /mensajes/1 or /mensajes/1.json | def destroy
@mensaje.destroy
respond_to do |format|
format.html { redirect_to mensajes_url, notice: "Mensaje was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mensagem = Mensagem.find(params[:id])\n api_client.delete_object(@mensagem.post_id)\n @mensagem.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.js { head :ok }\n end\n end",
"def destroy\n @mensaje = Mensaje.find(params[:id])\n @mensaje.dest... | [
"0.7568959",
"0.7388924",
"0.7284272",
"0.72007215",
"0.7189235",
"0.71758914",
"0.7164094",
"0.7153764",
"0.71487385",
"0.7112125",
"0.7111706",
"0.7098437",
"0.70939046",
"0.70911866",
"0.70823276",
"0.7066904",
"0.7056552",
"0.7046564",
"0.70450073",
"0.70429957",
"0.70269... | 0.71788293 | 5 |
Use callbacks to share common setup or constraints between actions. | def set_mensaje
@mensaje = Mensaje.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def mensaje_params
params.require(:mensaje).permit(:usuario_id, :comentario_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
METHODS Input file structure: PatientIDMutStartMutStopChr 267369 53186624 138826345 X | def load_file(file_name)
patients_info = {}
File.open(file_name).each do |line|
line.chomp!
fields = line.split("\t")
chrom_number = fields.delete_at(1)
fields = fields[0..2]
fields.map!{|a| a.to_i}
query = patients_info[chrom_number]
if query.nil?
patients_info[chrom_number] = [fields]
else
query << fields
end
end
return patients_info
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read\n $t1 = Time.now # Init procedure timestamp\n person = []\n IO.foreach(\"data_500.txt\") do |line| # Get all patients from file iterate each line\n line.chomp! # Remove trailing whitespace.\n person.push(line.split(\":\")) # Saving data split :\n end\n group(person) # Get blood... | [
"0.5320008",
"0.5305712",
"0.5243399",
"0.51444024",
"0.51398295",
"0.5089928",
"0.5044294",
"0.5038991",
"0.5015203",
"0.49416864",
"0.49401143",
"0.49243936",
"0.4893",
"0.48817113",
"0.48132303",
"0.47845253",
"0.476123",
"0.4760243",
"0.47430584",
"0.47430584",
"0.4734734... | 0.4965524 | 9 |
a config object with the default configuration | def config_default
lock(:c) do
@cache[:c][:default] ||= config_new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_config\n {}\n end",
"def default_config\n self.class.config[:default_config].nil? ? {} : {}.merge(self.class.config[:default_config])\n end",
"def default_config\n self.class.default_config\n end",
"def default_config\n <<~CONFIG\n defaults: &defaults\n ... | [
"0.86144465",
"0.8302287",
"0.8281043",
"0.8212024",
"0.81273854",
"0.79296815",
"0.7816127",
"0.771636",
"0.76702875",
"0.76702875",
"0.7637694",
"0.762037",
"0.75607115",
"0.7452792",
"0.7452792",
"0.7431353",
"0.73758",
"0.72866136",
"0.7270108",
"0.725861",
"0.72493464",
... | 0.7103115 | 34 |
delete a config object from the cache and return it (or nil if this did not exist) | def config_uncache(key)
cnf = nil
lock(:c) do
cnf = @cache[:c].delete(key)
end
log cnf ?
"config #{key} deleted" :
"config #{key} not cached, not deleted"
cnf
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_delete(ck)\n cache_op(:delete, ck)\n nil\n end",
"def delete(key)\n ref = @cache.delete(key)\n ref.__getobj__ rescue nil\n end",
"def destroy_cache(obj)\n storage.del(key(obj))\n end",
"def cache_delete\n model.send(:cache_delete, cache_k... | [
"0.63203675",
"0.6216962",
"0.6187307",
"0.6120253",
"0.6072019",
"0.5821527",
"0.57268876",
"0.5697902",
"0.5697902",
"0.5688667",
"0.5678976",
"0.5660041",
"0.5633941",
"0.56315655",
"0.56236655",
"0.56235796",
"0.56131256",
"0.5610702",
"0.55546546",
"0.5499076",
"0.549646... | 0.6778379 | 0 |
does the cache contain a config object for this key? | def config_cached?(key)
lock(:c) do
@cache[:c].has_key?(key)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_key?(key)\n @cache.has_key?(key)\n end",
"def cache?(key)\n auth_objects_cache.key? key\n end",
"def cached?(key)\n false\n end",
"def cached?(key)\n not @memcache.get(key).nil?\n end",
"def include?(key)\n File.exist?(cache_path(key))\n end",
"def has_key?... | [
"0.79252887",
"0.79077",
"0.7853994",
"0.7634765",
"0.7555837",
"0.7480635",
"0.7450861",
"0.74242336",
"0.7378295",
"0.7224839",
"0.71877193",
"0.7150397",
"0.71482897",
"0.71304995",
"0.70795715",
"0.70012224",
"0.6922986",
"0.68965566",
"0.68965226",
"0.68949485",
"0.68761... | 0.8443401 | 0 |
a new config object with settings from config/default.style | def config_new
cnf = GT::Style.new
style_file = File.expand_path("config/default.style",
"#{File.dirname(__FILE__)}/../..")
log "new config, trying to load #{style_file}", 2
cnf.load_file style_file
log "new config, default.style loaded", 2
return cnf
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def style_new\n st = GT::Style.new\n style_file = File.expand_path(\"config/default.style\",\n \"#{File.dirname(__FILE__)}/../..\")\n log \"new style, trying to load #{style_file}\", 2\n st.load_file style_file\n log \"new style, default.style loaded\", 2\n return... | [
"0.6772796",
"0.6758644",
"0.6638874",
"0.65170556",
"0.65158147",
"0.6425024",
"0.6389434",
"0.6209163",
"0.6183277",
"0.6170434",
"0.6106677",
"0.6085679",
"0.60800856",
"0.60750633",
"0.60426366",
"0.60343635",
"0.6034086",
"0.60013926",
"0.59797233",
"0.5952553",
"0.59443... | 0.7639467 | 0 |
a new color object | def color_new
return GT::Color.malloc
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @color = Color.new\n end",
"def dup\n Colorist::Color.from_rgb(@r,@g,@b)\n end",
"def color\n Color.new\n end",
"def initialize(color)\n @color = color\n end",
"def color=(c)\n @color = Color.new(c)\n end",
"def initialize(color=0x000000)\n string = \"%.6x... | [
"0.8007219",
"0.78093153",
"0.7280795",
"0.71924376",
"0.7184077",
"0.7170981",
"0.70304453",
"0.7011994",
"0.70032996",
"0.698195",
"0.69520444",
"0.69393486",
"0.69140613",
"0.6905236",
"0.68898904",
"0.68514836",
"0.6843216",
"0.6811877",
"0.6809771",
"0.67883414",
"0.6787... | 0.823423 | 1 |
Serialize timeline entry to a hash | def to_hash
# fields
result = {
'rcpt' => @timeline.recipient_id,
'routing' => @routing_kind,
'activity' => @activity.to_hash,
}
result['meta'] = @meta.stringify_keys unless @meta.blank?
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n hsh = {\n id: id,\n status: status.to_sym,\n connect: running? ? connect.to_h : nil,\n time: info.wallclock_time.to_i / 60 # only update every minute\n }\n Digest::SHA1.hexdigest(hsh.to_json)\n end",
"def hash\n @data.dup.concat([@ts]).hash\n ... | [
"0.6373876",
"0.62850106",
"0.6173977",
"0.61097634",
"0.6107942",
"0.60595894",
"0.6034601",
"0.6006015",
"0.60057294",
"0.5999017",
"0.5990471",
"0.5976088",
"0.59152186",
"0.5902666",
"0.5889972",
"0.58891016",
"0.58292323",
"0.5819369",
"0.58082813",
"0.57998794",
"0.5797... | 0.65883416 | 0 |
Get the corresponding timeline route | def timeline_route
@timeline_route ||= begin
result = @timeline.route_for_kind(Activr::Timeline::Route.kind_for_routing_and_activity(@routing_kind, @activity.kind))
raise "Failed to find a route for #{@routing_kind} / #{@activity.kind}: #{self.inspect}" if result.nil?
result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route\n @route\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def get_route\n data = {\n visits: visits,\n fleet: fleet\n }\n\n data[:options] = options if options\n result = Util.send_request(\"POST\", \"vr... | [
"0.66756177",
"0.63129956",
"0.6282473",
"0.61637825",
"0.6088629",
"0.6059778",
"0.6047729",
"0.6047729",
"0.6034971",
"0.59549046",
"0.59533983",
"0.58815783",
"0.5819056",
"0.58077365",
"0.5727245",
"0.57205427",
"0.5720095",
"0.5711996",
"0.5710896",
"0.5709491",
"0.56802... | 0.8354507 | 0 |
Humanize that timeline entry | def humanize(options = { })
if !self.timeline_route.settings[:humanize].blank?
# specialized humanization
Activr.sentence(self.timeline_route.settings[:humanize], self.humanization_bindings(options))
else
# default humanization
@activity.humanize(options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timeline_title\n if completed?\n \"Hearing type converted from #{appeal.readable_previous_hearing_request_type_for_task(id)}\"\\\n \" to #{appeal.readable_current_hearing_request_type_for_task(id)}\"\n end\n end",
"def parse_timeline\n\nend",
"def show\n # trying to place things on ti... | [
"0.7449541",
"0.65076625",
"0.61750156",
"0.58942235",
"0.5781432",
"0.5688995",
"0.56507516",
"0.55781966",
"0.55637515",
"0.55538285",
"0.5551372",
"0.5539719",
"0.5511138",
"0.54902947",
"0.5484185",
"0.5470789",
"0.54601717",
"0.5450992",
"0.54507565",
"0.54473513",
"0.54... | 0.6533922 | 1 |
Is it already stored | def stored?
!@_id.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stored?\n !@_id.nil?\n end",
"def store?\n true\n end",
"def store?\n false\n end",
"def already_stored?\n !file_uniqueness\n end",
"def is_to_be_stored?\n any?(&:is_to_be_stored?)\n end",
"def store?\n true\n end",
"def store?\n false\n end",... | [
"0.8003325",
"0.7999743",
"0.7850456",
"0.77591544",
"0.75428426",
"0.75012016",
"0.7455423",
"0.7455423",
"0.7176047",
"0.71278393",
"0.7103778",
"0.70197487",
"0.6997889",
"0.6943841",
"0.68439096",
"0.6842603",
"0.6841437",
"0.6836831",
"0.68290454",
"0.6796294",
"0.679060... | 0.76488566 | 4 |
unsing a while loop | def palindrome(string)
result = []
new_string = string.chars
loop do
result << new_string.pop
break if new_string.size == 0
end
result.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def while(&block)\n\t\t\t\t\trepeat &block\n\t\t\t\tend",
"def loop; end",
"def while(&blk)\n loop{ !blk[] }\n end",
"def endless_loop?; end",
"def using_while\n\tlevitation_force = 6\n\twhile levitation_force < 10\n puts \"Wingardium Leviosa\"\n levitation_force += 1\n end\nend",
"def using_w... | [
"0.7346873",
"0.68713546",
"0.67927545",
"0.6670351",
"0.6620793",
"0.65875137",
"0.6484291",
"0.64283484",
"0.6363932",
"0.63264674",
"0.6313584",
"0.6262427",
"0.6255061",
"0.6245796",
"0.6233771",
"0.61369324",
"0.612633",
"0.6111101",
"0.61053693",
"0.61007506",
"0.610075... | 0.0 | -1 |
using the times method and pop to quickly iterate the array. | def palindrome(string)
result = Array.new
new_string = string.chars
string.size.times { result << new_string.pop }
result.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_from_array(arr)\n arr.size.times do\n puts arr.pop\n end\nend",
"def times\n\t\t\tprogram = pop\n\t\t\tn = pop\n\t\t\traise ArgumentError, \"TIMEs: second element is not an Array.\" unless program.is_a? Array\n\t\t\tn.times { ~program.dup }\n\t\tend",
"def pop(time)\n index = bisect_left(@seq... | [
"0.70497787",
"0.6836621",
"0.67655873",
"0.64888424",
"0.64249843",
"0.64110243",
"0.63647074",
"0.6362134",
"0.6361268",
"0.63419086",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.6298405",
... | 0.0 | -1 |
using times method as well as delete_at to remove last item from array. | def palindrome(string)
result = Array.new
new_string = string.chars
string.size.times { result << new_string.delete_at(-1) }
result.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_retrieve_last\n # @array.pop\n @array.slice!(0)\n end",
"def remove_times(event)\n\t\tevent.times.each do |t|\n\t\t\tif t[1].to_i-t[0].to_i < event.length\n\t\t\t\tevent.times.delete(t)\n\t\t\tend\n\t\tend\n\tend",
"def pop(time)\n @entries.shift.item if !@entries.empty? && before_eq(@en... | [
"0.67091775",
"0.6673182",
"0.6656268",
"0.6628504",
"0.64877486",
"0.64794046",
"0.6456301",
"0.6456301",
"0.630479",
"0.62594247",
"0.62507254",
"0.62507254",
"0.6231363",
"0.62235665",
"0.62207985",
"0.62206256",
"0.62171066",
"0.6160276",
"0.6159519",
"0.6153257",
"0.6144... | 0.0 | -1 |
GET /products/1 GET /products/1.json | def show
@category = Category.find(params[:category_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end",
"def show\n @product = Product.find(params[:id])\n\n render json: @product\n end",
"def index\n @api_v1_products = Product.all\n jso... | [
"0.77224106",
"0.76329553",
"0.76313764",
"0.7607208",
"0.75760156",
"0.7552171",
"0.7506385",
"0.7484625",
"0.745622",
"0.74501616",
"0.74376804",
"0.7421124",
"0.7362056",
"0.7318765",
"0.73185545",
"0.73185545",
"0.73185545",
"0.7316062",
"0.7311976",
"0.73088664",
"0.7294... | 0.0 | -1 |
POST /products POST /products.json | def create
@category = Category.find(params[:category_id])
@product = Product.new(product_params)
@product.category_id = params[:category_id]
respond_to do |format|
if @product.save
binding.pry
UserMailer.send_email(@product.name,current_user).deliver
flash[:notice] = t('prod_message_create')
format.html { redirect_to category_products_path }
format.json { render :show, status: :created, location: @product }
else
format.html { render :new }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n if params[:products]\n params[:products].each do |product|\n @... | [
"0.7674954",
"0.7589692",
"0.756074",
"0.7531862",
"0.7531213",
"0.7507928",
"0.7420413",
"0.7391407",
"0.7374718",
"0.7355908",
"0.73231804",
"0.72869605",
"0.7144144",
"0.7050259",
"0.7047559",
"0.70415026",
"0.7037288",
"0.7037288",
"0.7037288",
"0.70322204",
"0.70255643",... | 0.0 | -1 |
PATCH/PUT /products/1 PATCH/PUT /products/1.json | def update
@category = Category.find(params[:category_id])
respond_to do |format|
if @product.update(product_params)
flash[:notice] =t('prod_message_update')
format.html { redirect_to category_products_path }
format.json { render :show, status: :ok, location: @product }
else
format.html { render :edit }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @colle... | [
"0.72706324",
"0.69353855",
"0.6868726",
"0.6846583",
"0.68131363",
"0.6768224",
"0.67510056",
"0.6743048",
"0.6715245",
"0.67010957",
"0.6686189",
"0.6659919",
"0.665496",
"0.6653816",
"0.66409653",
"0.66409653",
"0.66386145",
"0.6631324",
"0.6631324",
"0.6627554",
"0.662099... | 0.0 | -1 |
DELETE /products/1 DELETE /products/1.json | def destroy
if @product.destroy
respond_to do |format|
format.js
flash[:notice] = t('cat_message_delete')
format.html { redirect_to category_products_url }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n product = Product.find(params[:id])\n product.destroy\n\n render json: { deleted: params[:id] }\n end",
"def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end",
"def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\n end",
... | [
"0.77170193",
"0.7592065",
"0.7548574",
"0.75031716",
"0.750253",
"0.7473131",
"0.74397856",
"0.7417868",
"0.7408511",
"0.73704934",
"0.7352473",
"0.73480946",
"0.73359036",
"0.73359036",
"0.73359036",
"0.73310447",
"0.73310447",
"0.73310447",
"0.73310447",
"0.73310447",
"0.7... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_product
@product = Product.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 product_params
params.require(:product).permit(:name, :description, :price)
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 /user_follow_tags/1 GET /user_follow_tags/1.json | def show
@user_follow_tag = UserFollowTag.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user_follow_tag }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end",
"def create\n name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])\n\n if name_normalized.nil? || name_normalized.empty?\n render :nothing => true, :status => 403\n else\n @tag = ActsAsTaggableOn::Tag.find_or_cre... | [
"0.69172317",
"0.6571766",
"0.64808655",
"0.6477853",
"0.63970363",
"0.6386144",
"0.63544136",
"0.6300643",
"0.6269847",
"0.620483",
"0.61931103",
"0.6161084",
"0.6031078",
"0.59298474",
"0.59146285",
"0.59142137",
"0.5903233",
"0.58991754",
"0.5889567",
"0.5884425",
"0.58666... | 0.6997782 | 0 |
GET /user_follow_tags/new GET /user_follow_tags/new.json | def new
@user_follow_tag = UserFollowTag.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user_follow_tag }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @user_follow_tag = UserFollowTag.new(params[:user_follow_tag])\n\n respond_to do |format|\n if @user_follow_tag.save\n format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully created.' }\n format.json { render json: @user_follow_tag, status: :crea... | [
"0.7585731",
"0.744131",
"0.7102596",
"0.7054228",
"0.69083136",
"0.6651111",
"0.66156983",
"0.65851164",
"0.655412",
"0.6544734",
"0.6514242",
"0.6483012",
"0.6483012",
"0.6483012",
"0.6421365",
"0.6400922",
"0.6400922",
"0.63905257",
"0.63726586",
"0.63567376",
"0.63487256"... | 0.7897986 | 0 |
POST /user_follow_tags POST /user_follow_tags.json | def create
@user_follow_tag = UserFollowTag.new(params[:user_follow_tag])
respond_to do |format|
if @user_follow_tag.save
format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully created.' }
format.json { render json: @user_follow_tag, status: :created, location: @user_follow_tag }
else
format.html { render action: "new" }
format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end",
"def create\n name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])\n\n if name_normalized.nil? || name_normalized.empty?\n render :nothing => true, :status => 403\n else\n @tag = ActsAsTaggableOn::Tag.find_or_cre... | [
"0.7481366",
"0.7256622",
"0.6269165",
"0.62230766",
"0.6091537",
"0.6078135",
"0.59749514",
"0.5971757",
"0.5845161",
"0.58338755",
"0.58264333",
"0.58204836",
"0.5818444",
"0.5779157",
"0.57690245",
"0.5765219",
"0.5748843",
"0.57465994",
"0.56996894",
"0.569636",
"0.569202... | 0.7134189 | 2 |
PUT /user_follow_tags/1 PUT /user_follow_tags/1.json | def update
@user_follow_tag = UserFollowTag.find(params[:id])
respond_to do |format|
if @user_follow_tag.update_attributes(params[:user_follow_tag])
format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end",
"def create\n name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])\n\n if name_normalized.nil? || name_normalized.empty?\n render :nothing => true, :status => 403\n else\n @tag = ActsAsTaggableOn::Tag.find_or_cre... | [
"0.7139845",
"0.66610676",
"0.65788424",
"0.6238002",
"0.62051",
"0.6151745",
"0.60733384",
"0.60128903",
"0.5996109",
"0.59050095",
"0.5875298",
"0.58606714",
"0.5839642",
"0.5814438",
"0.58002245",
"0.57934636",
"0.5786955",
"0.57588696",
"0.574772",
"0.5741301",
"0.5734241... | 0.70458865 | 1 |
DELETE /user_follow_tags/1 DELETE /user_follow_tags/1.json | def destroy
@user_follow_tag = UserFollowTag.find(params[:id])
@user_follow_tag.destroy
respond_to do |format|
format.html { redirect_to user_follow_tags_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n tag_following = current_user.tag_followings.find_by_tag_id( params['id'] )\n \n if tag_following && tag_following.destroy\n respond_to do |format|\n format.any(:js, :json) { render :nothing => true, :status => 204 }\n end\n else\n respond_to do |format|\n form... | [
"0.71471536",
"0.7110488",
"0.70377684",
"0.6995492",
"0.67928106",
"0.67815906",
"0.6724435",
"0.66691434",
"0.6663651",
"0.6659276",
"0.66347915",
"0.659024",
"0.6580941",
"0.6580363",
"0.6565712",
"0.65651464",
"0.6538799",
"0.6538058",
"0.65360254",
"0.65245426",
"0.65183... | 0.79598224 | 0 |
but I still CAN provide an argument for the parameter, overriding the default value | def my_method_hash(attrs = {})
puts "Name is #{attrs[:name]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default=(_arg0); end",
"def param_default( param, value )\n param = value unless ( param && param.length > 0 )\n end",
"def foo(param = \"no\") #this is default param\n \"yes\"\nend",
"def set_default\n end",
"def method_missing(*args)\n default\n end",
"def meth( x = nil)\nend"... | [
"0.79086506",
"0.7807899",
"0.75724",
"0.713247",
"0.7108626",
"0.7106757",
"0.7043715",
"0.7039026",
"0.7024428",
"0.6997972",
"0.6990686",
"0.6982948",
"0.69826704",
"0.6970951",
"0.6970951",
"0.6946422",
"0.6930741",
"0.69297403",
"0.68954176",
"0.68739206",
"0.68739206",
... | 0.0 | -1 |
So we can return a Qsome::Job, not a Qless::Job | def get(jid)
results = @client.call('get', jid)
Job.new(@client, JSON.parse(results)) unless results.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job\n job_name.constantize.new({\n :context => self\n })\n end",
"def job\n @job\n end",
"def job # this is a getter\n @job\n end",
"def job\n @job\n end",
"def job\n @job\n end",
"def queue_job; end",
"def jobs\n raise NotImplementedError\n end",
"def ... | [
"0.6795402",
"0.67704654",
"0.6742676",
"0.6729724",
"0.6729724",
"0.6681992",
"0.6655046",
"0.6626932",
"0.642745",
"0.6382254",
"0.63598585",
"0.63112384",
"0.63021314",
"0.6276726",
"0.62735003",
"0.6265982",
"0.62589955",
"0.62364346",
"0.6171337",
"0.6170372",
"0.6166588... | 0.57333815 | 49 |
So we can return a Qsome::Job, not a Qless::Job | def multiget(*jids)
results = JSON.parse(@client.call('multiget', *jids))
results.map do |data|
Job.new(@client, data)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job\n job_name.constantize.new({\n :context => self\n })\n end",
"def job\n @job\n end",
"def job # this is a getter\n @job\n end",
"def job\n @job\n end",
"def job\n @job\n end",
"def queue_job; end",
"def jobs\n raise NotImplementedError\n end",
"def ... | [
"0.6795402",
"0.67704654",
"0.6742676",
"0.6729724",
"0.6729724",
"0.6681992",
"0.6655046",
"0.6626932",
"0.642745",
"0.6382254",
"0.63598585",
"0.63112384",
"0.63021314",
"0.6276726",
"0.62735003",
"0.6265982",
"0.62589955",
"0.62364346",
"0.6171337",
"0.6170372",
"0.6166588... | 0.0 | -1 |
Iterates over system_config.gaudi_modules and requires all tasks | def require_tasks system_config
system_config.gaudi_modules.each do |gm|
mass_require(Rake::FileList["#{system_config.base}/tools/build/lib/#{gm}/tasks/*.rb"])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_modules(module_list, base_directory)\n module_list.each do |gm|\n mass_require(Rake::FileList[\"#{base_directory}/tools/build/lib/#{gm}/helpers/*.rb\"])\n mass_require(Rake::FileList[\"#{base_directory}/tools/build/lib/#{gm}/rules/*.rb\"])\n end\n end",
"def gaudi... | [
"0.6188523",
"0.6097411",
"0.597447",
"0.5809013",
"0.5786821",
"0.5702531",
"0.5696795",
"0.5691863",
"0.5685323",
"0.5668211",
"0.5608038",
"0.5600038",
"0.5597406",
"0.55894846",
"0.5582907",
"0.5552567",
"0.55266285",
"0.5491753",
"0.5467483",
"0.54470986",
"0.54303867",
... | 0.8342751 | 0 |
Writes a file making sure the directory is created | def write_file filename,content
mkdir_p(File.dirname(filename),:verbose=>false)
File.open(filename, 'wb') {|f| f.write(content) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_file(content, dir, file)\n filename = File.basename(file).gsub(/(\\.s?[ac]ss)+/, options[:extension])\n path = File.join(dir, filename)\n\n unless options[:noop]\n FileUtils.mkdir_p(dir)\n File.open(path, 'w') {|f| f.write(content) }\n end\n\n path\n ... | [
"0.7758628",
"0.77174056",
"0.7669147",
"0.7526724",
"0.74939084",
"0.74851555",
"0.74124116",
"0.73894113",
"0.73765755",
"0.7322685",
"0.72489274",
"0.72189933",
"0.7204453",
"0.7199991",
"0.7167592",
"0.714699",
"0.71240133",
"0.710108",
"0.7098118",
"0.7068656",
"0.705241... | 0.7985259 | 0 |
Template suffix for variables (lowercase). | def tmpl_var_suffix
Hash.instance_variable_get :@tmpl_var_suffix
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def var_name()\n if self.id.start_with?(/\\Ah?l_/i)\n return self.id.downcase\n else\n return \"l_#{self.id.downcase}\"\n end\n end",
"def underscore_vars\r\n self.gsub(/\\b[a-z][a-z]*(?:[A-Z][a-z]*)(?:[A-Z][a-z]*)*\\b/) {|word|\r\n word.underscore\r\n }\r\n... | [
"0.6941256",
"0.68697774",
"0.67630404",
"0.67630404",
"0.6741851",
"0.64515334",
"0.6432811",
"0.6383109",
"0.635437",
"0.635437",
"0.635437",
"0.635437",
"0.635437",
"0.6351529",
"0.62755126",
"0.626218",
"0.62409097",
"0.6224396",
"0.6209271",
"0.6175734",
"0.6167799",
"... | 0.774759 | 0 |
def input Output a tarball. If the output path ends predictably (like in .tar.gz) it will try to obey the compression type. | def output(output_path)
output_check(output_path)
files = Find.find(staging_path).to_a
safesystem("zip", output_path, *files)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tarball(destination, paths)\n # check for filepath length limit\n full_destination = File.expand_path(destination)\n if full_destination.length > 259 # 256 chars max; \"C:\\\" doesn't count\n puts \"[TarBall] ERROR cannot generate #{destination} because path exceeds 256 char limit. shorten compon... | [
"0.62581843",
"0.6246144",
"0.6199679",
"0.61615384",
"0.6094651",
"0.608722",
"0.60778046",
"0.6067217",
"0.6024236",
"0.5979973",
"0.59264624",
"0.58868015",
"0.5874518",
"0.5846321",
"0.5844277",
"0.58330256",
"0.5818472",
"0.58160794",
"0.5793206",
"0.5776569",
"0.5763199... | 0.54078996 | 45 |
def output Generate the proper tar flags based on the path name. | def tar_compression_flag(path)
case path
when /\.tar\.bz2$/
return "-j"
when /\.tar\.gz$|\.tgz$/
return "-z"
when /\.tar\.xz$/
return "-J"
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_tar_file(path_to_file)\n tar_path = temp_path(path_to_file)\n command = \"tar --create --format=gnu --preserve-permissions --absolute-names --file=#{tar_path} #{path_to_file}\"\n bash_out(command)\n return tar_path\n end",
"def tar_compression_flag\n case compression\n w... | [
"0.6347066",
"0.62538254",
"0.6228467",
"0.6081101",
"0.6014752",
"0.5992274",
"0.5974912",
"0.59343016",
"0.5928332",
"0.5916771",
"0.5908022",
"0.58967286",
"0.58628297",
"0.58628297",
"0.5858365",
"0.57895356",
"0.5757531",
"0.57030237",
"0.5702482",
"0.56907505",
"0.56722... | 0.69283813 | 0 |
Tripprepare doesn't care what preparers are, it's a duck that responds to prepare_trip | def prepare(preparers)
preparers.each { |preparer| preparer.prepare_trip(self) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare(preparers)\n preparers.each do |prepaper|\n prepaper.prepape_trip(self)\n end\n end",
"def prepare(preparers)\n preparers.each {|preparer|\n preparer.prepare_trip(self) }\n end",
"def prepare(prepareers)\n\t\tprepareers.each { |prepare| prepare.prepare_trip(self)}\n\tend",
"def... | [
"0.73768985",
"0.7337407",
"0.6742725",
"0.6085478",
"0.6029285",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58153194",
"0.5802087",
"0.57979494",
"0.5710099",
"0.5710099",
"0.5710099",
"0.56982344",
"0.56982344",
"0.5... | 0.71852136 | 2 |
Starts the WebSocket client to consume the published info in the WebSocket Server | def start
logger.info('Starting the WebSocket Client...')
EventMachine.run do
puts '='*80, "Connecting to websockets server at ws://#{Settings.websocket.host}:#{Settings.websocket.port}", '='*80
http = EventMachine::HttpRequest.new("ws://#{Settings.websocket.host}:#{Settings.websocket.port}/websocket").get :timeout => 0
http.errback do
logger.error "something was wrong in the websocket_client"
end
http.callback do
puts "#{Time.now.strftime('%H:%M:%S')} : Connected to server"
end
http.stream do |msg|
puts msg
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n @thread = Thread.new do\n EM::WebSocket.start(ws_options) do |ws|\n ws.onopen do |handshake|\n log \"onopen: #{handshake.headers}\"\n @clients << ws\n end\n\n ws.onclose do |event|\n log \"closed: #{event}\"\n @clients.d... | [
"0.759693",
"0.75889146",
"0.75040096",
"0.74673706",
"0.73379916",
"0.7302696",
"0.7091175",
"0.7071319",
"0.70664835",
"0.69037634",
"0.68445",
"0.6770489",
"0.666549",
"0.6642469",
"0.6607377",
"0.6575878",
"0.6575878",
"0.6519944",
"0.6505101",
"0.6488238",
"0.64726967",
... | 0.8328781 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_workout
@workout = Workout.friendly.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 workout_params
params.require( :workout ).permit( :workout_type, :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.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894"... | 0.0 | -1 |
GET /retroalimentacions/1 GET /retroalimentacions/1.json | def show
@retroalimentacion = Retroalimentacion.find(params[:id])
@current_cliente=obtener_cliente(current_user)
respond_to do |format|
format.html # show.html.erb
format.json { render json: @retroalimentacion }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @retro = Retro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retro }\n end\n end",
"def show\n @retroaspecto = Retroaspecto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format... | [
"0.6561835",
"0.6257182",
"0.62030643",
"0.6189955",
"0.6154772",
"0.61511123",
"0.6117199",
"0.6066296",
"0.6059853",
"0.60521847",
"0.60429156",
"0.6040363",
"0.60234064",
"0.6011314",
"0.59818923",
"0.5978766",
"0.59613097",
"0.5953499",
"0.59325844",
"0.59307265",
"0.5876... | 0.60582006 | 9 |
GET /retroalimentacions/new GET /retroalimentacions/new.json | def new
@retroalimentacion = Retroalimentacion.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @retroalimentacion }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @retro = Retro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retro }\n end\n end",
"def new\n @immigrant = Immigrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @immigrant }\n ... | [
"0.7193069",
"0.71232325",
"0.7022495",
"0.70102686",
"0.6950694",
"0.6928896",
"0.6925936",
"0.6922406",
"0.6912741",
"0.688948",
"0.6888855",
"0.68855584",
"0.6883194",
"0.68728447",
"0.68728447",
"0.6867019",
"0.68633723",
"0.68572843",
"0.6842431",
"0.6840091",
"0.683457"... | 0.7555004 | 0 |
POST /retroalimentacions POST /retroalimentacions.json | def create
@retroalimentacion = Retroalimentacion.new(params[:retro])
respond_to do |format|
if @retroalimentacion.save
format.html { redirect_to @retroalimentacion, notice: 'Retroalimentacion was successfully created.' }
format.json { render json: @retroalimentacion, status: :created, location: @retroalimentacion }
else
format.html { render action: "new" }
format.json { render json: @retroalimentacion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @retroalimentacion = Retroalimentacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retroalimentacion }\n end\n end",
"def create\n @retro = Retro.new(params[:retro])\n\n respond_to do |format|\n if @retro.save\n format.... | [
"0.58812654",
"0.58588254",
"0.57641846",
"0.5677848",
"0.55983293",
"0.55472434",
"0.5527593",
"0.5481473",
"0.54783034",
"0.54699445",
"0.54505444",
"0.54477286",
"0.5423936",
"0.5420644",
"0.5415448",
"0.540614",
"0.5393993",
"0.5392094",
"0.5367207",
"0.53641605",
"0.5349... | 0.67328525 | 0 |
PUT /retroalimentacions/1 PUT /retroalimentacions/1.json | def update
@retroalimentacion = Retroalimentacion.find(params[:id])
respond_to do |format|
if @retroalimentacion.update_attributes(params[:retroalimentacion])
format.html { redirect_to @retroalimentacion, notice: 'Retroalimentacion was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @retroalimentacion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @retro = Retro.find(params[:id])\n\n respond_to do |format|\n if @retro.update_attributes(params[:retro])\n format.html { redirect_to @retro, notice: 'Retro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.6416364",
"0.6220023",
"0.59691745",
"0.59603894",
"0.595329",
"0.5953134",
"0.59020674",
"0.5901316",
"0.5894188",
"0.58929896",
"0.5867177",
"0.5837815",
"0.58215815",
"0.57805514",
"0.5778164",
"0.57765055",
"0.57553095",
"0.57390594",
"0.5736952",
"0.57358456",
"0.5731... | 0.66322505 | 0 |
DELETE /retroalimentacions/1 DELETE /retroalimentacions/1.json | def destroy
@retroalimentacion = Retroalimentacion.find(params[:id])
@retroalimentacion.destroy
respond_to do |format|
format.html { redirect_to retroalimentacions_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destro... | [
"0.7318092",
"0.7162978",
"0.7092663",
"0.7020363",
"0.7011858",
"0.70032704",
"0.6999551",
"0.6970893",
"0.69674957",
"0.69631535",
"0.69290596",
"0.69252896",
"0.6907412",
"0.69073576",
"0.6880774",
"0.68772125",
"0.6858631",
"0.6852518",
"0.6811732",
"0.6806073",
"0.680163... | 0.7735287 | 0 |
Decodes Base64 encoded inline string image. ==== Parameters +contents+ String, Base64 decoded inline image containing header: data:image/png;base64,... | def initialize(contents)
self.content_type, self.encoded_file = contents.split(';', 2)
raise UnsupportedFormat unless valid_extension?
super(Base64.decode64(encoded_file))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def decode_image(data)\r\n\r\n data_index = data.index('base64') + 7\r\n filedata = data.slice(data_index, data.lengt... | [
"0.7150761",
"0.7150761",
"0.6650627",
"0.6345846",
"0.6332592",
"0.6331287",
"0.63103366",
"0.62930286",
"0.62179923",
"0.6120855",
"0.5975564",
"0.5964627",
"0.5964627",
"0.5863977",
"0.58620006",
"0.5861358",
"0.5833516",
"0.5806828",
"0.5782316",
"0.5775441",
"0.576188",
... | 0.5259817 | 41 |
useful exercise for me and has made me more cognizant of how 'return' affects Ruby; Ruby basically stops reading the code in the method once there is an explicit 'Return'. | def scream(words)
words = words + "!!!!"
puts words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def demonstrate_early_return\n return\n puts \"You will never see this, because we never get here.\"\nend",
"def returns; end",
"def return_statement(num)\n puts \"this is before the explicit return...\"\n if num != 1\n return \"yeah you entered something other than 1 !\"\n end\n puts \"this is after ... | [
"0.759779",
"0.73193014",
"0.7235925",
"0.7148032",
"0.6907276",
"0.687679",
"0.68606764",
"0.6859005",
"0.68530375",
"0.6833588",
"0.68255156",
"0.67490286",
"0.6702677",
"0.66402215",
"0.656095",
"0.6495049",
"0.6493871",
"0.6466181",
"0.64038473",
"0.6342559",
"0.6318477",... | 0.0 | -1 |
by default we use static uri. If dynamic uri is required, override this method. | def endpoint
options.endpoint
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri\n raise NotImplementedError\n end",
"def uri(custom_uri = nil)\n if custom_uri\n @uri = custom_uri\n @http = create_http # yike, oh well. less intrusive this way\n else # if no custom passed, we use existing, which, if unset, is set to site uri\n @uri ||= URI.pars... | [
"0.7173378",
"0.7025454",
"0.6917354",
"0.69012004",
"0.6846952",
"0.677947",
"0.677947",
"0.677947",
"0.67715013",
"0.67630684",
"0.67630684",
"0.67328775",
"0.67328775",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
... | 0.0 | -1 |
Defines a has many relationship. | def has_many(*attrs)
associate(:has_many, attrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_many(*attrs)\n associate(Associations::HasMany, attrs)\n end",
"def has_many(name, *args, **opt)\n add_collection_property(name, *args, **opt)\n set_relation_field(name, args.first)\n end",
"def has_many(*args)\n require \"og/relation/has_many\"\n relations! << Og::Ha... | [
"0.78585994",
"0.77024937",
"0.764495",
"0.7631497",
"0.7570364",
"0.74782395",
"0.7425874",
"0.74113977",
"0.72593075",
"0.72062",
"0.6999131",
"0.6997127",
"0.6950218",
"0.6950218",
"0.6942962",
"0.6910537",
"0.6900084",
"0.6857081",
"0.67642456",
"0.67569685",
"0.6743898",... | 0.75441444 | 5 |
Defines a single relationship. | def has_one(*attrs)
associate(:has_one, attrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_relationship(name)\n end",
"def relationship=(value)\n @relationship = value\n end",
"def add_relationship(rel_attr); end",
"def relationship(rel_class)\n @relationship = rel_class\n self\n end",
"def set_relationship\n @relationship = Re... | [
"0.82040167",
"0.7669557",
"0.7382287",
"0.72430265",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7059134",
"0.69488704",
"0.68549126",
"0.6850454",
"0.67201585",
"0.6702721",
"0.6694518",
"0.65845454... | 0.6140535 | 51 |
Helper method that returns the names of defined associations. | def association_names
self.class._associations.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associations\n association_reflections.keys\n end",
"def association_names\n @association_names ||= []\n end",
"def model_association_names\n return unless model_associations\n\n model_associations.map do |assoc|\n assoc.name.to_sym\n end\n end",
"... | [
"0.83428484",
"0.83073413",
"0.7985347",
"0.7813317",
"0.7730785",
"0.771898",
"0.7673606",
"0.7636001",
"0.74432623",
"0.73519576",
"0.7264935",
"0.7243952",
"0.7237185",
"0.715249",
"0.7118639",
"0.7097484",
"0.70881003",
"0.7074808",
"0.7064371",
"0.70422935",
"0.7009091",... | 0.8476953 | 0 |
Read the specified association. | def read_association(name)
type = _association_type(name)
_associations.fetch(name, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_association(key, safe: true)\n if safe\n tools.assertions.validate_name(key, as: 'association')\n\n unless self.class.associations.key?(key.to_s)\n raise ArgumentError, \"unknown association #{key.inspect}\"\n end\n end\n\n @associations[key.to_s]\n end",
... | [
"0.71946263",
"0.61465603",
"0.608465",
"0.59120494",
"0.58049136",
"0.57787526",
"0.57650065",
"0.5755606",
"0.5674283",
"0.5643788",
"0.5635563",
"0.5632599",
"0.5617736",
"0.56120366",
"0.5611897",
"0.55944556",
"0.55020356",
"0.5463704",
"0.54500496",
"0.54500496",
"0.544... | 0.7951814 | 0 |
Set values for the key'd association. | def set_association(key, value)
_associations[key.to_sym] = _cast_association(key, value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(k,v)\n each do |e|\n e.set k,v\n end\n self\n end",
"def set(key, value); end",
"def set(key, value); end",
"def hset(key, *attrs); end",
"def set(key, value)\n\t\t\t\t# TODO This could be a bit more efficient:\n\t\t\t\tself.delete(key)\n\t\t\t\tself.add(key, value)\n\t\t\t... | [
"0.6771941",
"0.63998663",
"0.63998663",
"0.63564634",
"0.63531405",
"0.63133806",
"0.63133806",
"0.6275904",
"0.6275637",
"0.6267881",
"0.6267881",
"0.6259619",
"0.6252384",
"0.61989516",
"0.6158674",
"0.6151377",
"0.60822505",
"0.60592306",
"0.6056363",
"0.6051091",
"0.6050... | 0.6796056 | 0 |
Helper method that verifies a given association exists. | def has_association?(attr_name)
_associations.has_key?(attr_name.to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def association?(object, associations); end",
"def association?(attribute)\n @_associations.key?(attribute.to_sym)\n end",
"def is_association?(model_name, association_name)\n associations = @associations[model_name]\n associations && associations[association_name]\n end",
... | [
"0.7184749",
"0.69383264",
"0.6920262",
"0.69146967",
"0.6900469",
"0.6900464",
"0.6770389",
"0.65803486",
"0.64925086",
"0.64672035",
"0.64292127",
"0.64169145",
"0.6373131",
"0.63626486",
"0.6361157",
"0.63451",
"0.6320307",
"0.629548",
"0.62691486",
"0.6252318",
"0.6238124... | 0.7554773 | 0 |
Builds a new content as descriped in the elements.yml file. | def build(element, essence_hash)
if (description = content_description(element, essence_hash)).blank?
raise ContentDefinitionError, "No description found in elements.yml for #{essence_hash.inspect} and #{element.inspect}"
else
new(name: description['name'], element_id: element.id, skip_translate: description['translate'] == false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n logger.warn \"\\n++++++\\nWARNING! Could not find any content descriptions for element: #{self.name}\\n++++++++\\n\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Alchemy::Content.create_... | [
"0.6674145",
"0.6617033",
"0.65395",
"0.64949185",
"0.6203894",
"0.61040753",
"0.6097686",
"0.60529166",
"0.590941",
"0.581976",
"0.57462",
"0.5740439",
"0.57398385",
"0.5670683",
"0.56648636",
"0.56593835",
"0.55874324",
"0.5551073",
"0.55476224",
"0.5515719",
"0.5506568",
... | 0.6553667 | 2 |
Creates a new content from elements description in the +elements.yml+ file. 1. It builds the content 2. It creates the essence record (content object gets saved) | def create_from_scratch(element, essence_hash)
essence_hash.stringify_keys!
if content = build(element, essence_hash)
content.create_essence!(essence_hash['essence_type'])
end
content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n logger.warn \"\\n++++++\\nWARNING! Could not find any content descriptions for element: #{self.name}\\n++++++++\\n\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Alchemy::Content.create_... | [
"0.71293515",
"0.68951184",
"0.6851754",
"0.6749171",
"0.65592486",
"0.6249196",
"0.60438925",
"0.5960458",
"0.5770947",
"0.5758531",
"0.5735976",
"0.572055",
"0.5705038",
"0.564417",
"0.55416477",
"0.55314547",
"0.55260473",
"0.55172884",
"0.55120534",
"0.5512029",
"0.551177... | 0.58555186 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.