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 |
|---|---|---|---|---|---|---|
GET /customer_users/1 GET /customer_users/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @user = current_user\n @customers = @user.customers\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @customers }\n end\n end",
"def index\n @customers = @user.customers.all\n render json: @customers\n ... | [
"0.7416016",
"0.74013877",
"0.6927694",
"0.69048446",
"0.69048446",
"0.68475395",
"0.68373173",
"0.6823955",
"0.68135196",
"0.67877716",
"0.67836523",
"0.6776003",
"0.6753472",
"0.6753472",
"0.67411846",
"0.6731843",
"0.67249376",
"0.668473",
"0.66769946",
"0.66676176",
"0.66... | 0.0 | -1 |
POST /customer_users POST /customer_users.json | def create
@customer_user = CustomerUser.new(customer_user_params)
respond_to do |format|
if @customer_user.save
format.html { redirect_to login_url, alert: "Customer user #{@customer_user.name} was successfully created." }
format.json { render action: 'show', status: :created, location: @customer_user }
else
format.html { render action: 'new' }
format.json { render json: @customer_user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @customer = @user.customers.build(customer_params)\n if @customer.save\n render json: @customer, status: :created\n else\n render json: @customer.errors, status: :unprocessable_entity\n end\n\n ... | [
"0.7491036",
"0.72490185",
"0.7003268",
"0.68083495",
"0.67773503",
"0.67731065",
"0.66887033",
"0.6686378",
"0.6682531",
"0.6611727",
"0.6576755",
"0.6518717",
"0.65125144",
"0.64826393",
"0.6435251",
"0.64301914",
"0.6410813",
"0.6409883",
"0.6399922",
"0.63989323",
"0.6398... | 0.7161228 | 2 |
PATCH/PUT /customer_users/1 PATCH/PUT /customer_users/1.json | def update
respond_to do |format|
if @customer_user.update(customer_user_params)
format.html { redirect_to users_url, notice: "Customer user #{@customer_user.name} was successfully updated." }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @customer_user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @user.customer? and @user.update(user_params_update)\n format.html { redirect_to admin_customers_path, notice: 'The user was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render... | [
"0.6875741",
"0.6811379",
"0.6757901",
"0.66581225",
"0.6607307",
"0.65830755",
"0.65765476",
"0.65719026",
"0.6555065",
"0.65258634",
"0.6516538",
"0.65162563",
"0.6511523",
"0.6504533",
"0.6487113",
"0.6479674",
"0.6479674",
"0.6479674",
"0.6479674",
"0.6479674",
"0.6479674... | 0.69846743 | 0 |
DELETE /customer_users/1 DELETE /customer_users/1.json | def destroy
begin
@customer_user.destroy
flash[:notice] = "User #{@customer_user.name} deleted"
rescue Exception => e
flash[:notice] = e.message
end
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n \n @customer = Customer.find(params[:id])\n @custom... | [
"0.74469155",
"0.74214846",
"0.7356577",
"0.7171427",
"0.71094245",
"0.7088757",
"0.70513505",
"0.70513505",
"0.7042167",
"0.7042167",
"0.7042167",
"0.7042167",
"0.7042167",
"0.7042167",
"0.7042167",
"0.7042167",
"0.7029094",
"0.7028306",
"0.7028306",
"0.7028306",
"0.7028306"... | 0.6921021 | 34 |
Use callbacks to share common setup or constraints between actions. | def set_customer_user
@customer_user = CustomerUser.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 customer_user_params
params.require(:customer_user).permit(:name, :password, :password_confirmation, :email)
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 |
gets c(word_2 | word_1) | def bigram_count()
@corpus.each { |sentence_arr|
prev_word = ""
sentence_arr.each { |word|
if(prev_word != "")
@bifreq[prev_word + " " + word] += 1
else
@bifreq["PHI "+word] += 1
end
prev_word = word
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitwise_or(a, b)\n\tresult = ''\n\ta.each_char.with_index do |val, index|\n\t\tif val == '1' || b[index] == '1'\n\t\t\tresult.concat '1'\n\t\telse\n\t\t\tresult.concat '0'\n\t\tend\n\tend\n\treturn result\nend",
"def second_anagram?(word1, word2)\n w1_copy = word1.dup\n w2_copy = word2.dup\n w1_copy.each_... | [
"0.6312455",
"0.6115193",
"0.60888296",
"0.6020706",
"0.5973992",
"0.594146",
"0.5910836",
"0.5907535",
"0.59036034",
"0.5901428",
"0.5901428",
"0.589075",
"0.5874602",
"0.5841897",
"0.57952756",
"0.5777708",
"0.57760334",
"0.574149",
"0.57329607",
"0.5681136",
"0.5671368",
... | 0.0 | -1 |
gets c(word_3 | word_1 word_2) | def trigram_count()
@corpus.each { |sentence_arr|
prev_word_1 = ""
prev_word_2 = ""
sentence_arr.each { |word|
if(prev_word_1 != "" && prev_word_2 != "")
@trifreq[prev_word_1 + " " + prev_word_2 + " " + word] += 1
elsif(prev_word_1 == "" && prev_word_2 != "")
@trifreq["PHI "+prev_word_2+" "+word] += 1
elsif(prev_word_1 == "" && prev_word_2 == "")
@trifreq["PHI PHI "+word] += 1
end
prev_word_1 = prev_word_2
prev_word_2 = word
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combinations\nputs \"Enter text\"\ntext = gets.chomp\nputs text\nwords = text.scan /\\w/\n\n\n\nputs words\nend",
"def secondstrc(f)\n res = \"\"\n flag = 0\n while l = f.gets\n if flag == 2 then\n res << l\n flag = 0\n elsif flag == 1 then\n flag = 2\n elsif /^>/ =~ l then\n ... | [
"0.6176229",
"0.57886636",
"0.57886636",
"0.5743057",
"0.5568961",
"0.5372955",
"0.5369312",
"0.5365232",
"0.5332327",
"0.5262724",
"0.5248385",
"0.524807",
"0.52473235",
"0.5227573",
"0.52124655",
"0.521071",
"0.5202199",
"0.51969796",
"0.5196516",
"0.5187681",
"0.51863533",... | 0.0 | -1 |
return shortest path(as Array) from sp to ep. return nil if shortest way is no exit | def AStar(sp, ep, walkable)
nodes = Hash.new {|hash, key| hash[key] = nil}
for pos in walkable
h = (pos.row - ep.row).abs + (pos.col - ep.col).abs
g = @m * @n
nodes[pos] = Node .new(g, h, nil)
end
nodes[sp].g = 0
open_list = { sp => nodes[sp] }
close_list = {}
#searching
until open_list.empty?
key, node = open_list.min {|a, b| (a[1].g + a[1].h) <=> (b[1].g + b[1].h) }
open_list.delete(key)
close_list[key] = node
break if key == ep
#current
r, c = key
[[0,1],[0,-1],[1,0],[-1,0]].each do |dr,dc|
nr, nc, nkey = r+dr, c+dc, [r+dr, c+dc]
#ingnore
if (not walkable.include?(nkey)) or close_list.has_key?(nkey)
next
end
#adjacent
next_g, next_d = node.g + 1, [dr, dc]
next_node = nodes[nkey]
#already in openlist
if open_list.has_key?(nkey)
if next_g < next_node.g
next_node.g = next_g
next_node.d = next_d
end
end
#not in openlist
if not open_list.has_key?(nkey)
next_node.g = next_g
next_node.d = next_d
open_list[nkey] = next_node
end
end
end
# no shortest path
return nil if not close_list.include?(ep)
# find shortest path
pos, node = Array.new(ep) , close_list[ep]
ret = []
loop do
ret << Array.new(pos)
break if pos == sp
pos.col -= node.d.col
pos.row -= node.d.row
node = nodes[pos]
end
return ret.reverse!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return pa... | [
"0.69755864",
"0.68290687",
"0.67324525",
"0.6677658",
"0.6673822",
"0.65540713",
"0.65273005",
"0.6516278",
"0.650917",
"0.64267683",
"0.64223987",
"0.6387411",
"0.63870925",
"0.63182175",
"0.6293437",
"0.6283225",
"0.62775296",
"0.61802834",
"0.61568344",
"0.61428314",
"0.6... | 0.60134226 | 26 |
put a bomb explosion on position pos and regardless of wall. return explosion range as a set | def exposion_range_without_wall(pos)
range = Set.new
@template.each do |orig_pos|
trans_pos = Array.new(orig_pos)
trans_pos.row += pos.row
trans_pos.col += pos.col
if (0...n).cover?(trans_pos.row) and (0...m).cover?(trans_pos.col)
range << trans_pos
end
end
return range
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def explosion_range(bomb_pos)\n\t\tcandidate = exposion_range_without_wall(bomb_pos) - @wall\n\t\telect = Set.new\n\t\twalkable = Set.new(candidate)\n\t\t\n\t\tloop do\n\t\t\tbreak if candidate.empty?\n\t\t\ts, e = bomb_pos, candidate.first\n\t\t\t\n\t\t\tpath = AStar(s, e, walkable)\n\t\t\t\n\t\t\t#no shortest pa... | [
"0.7945777",
"0.71731836",
"0.5733069",
"0.5717691",
"0.56722784",
"0.5618275",
"0.56072676",
"0.55668104",
"0.54659235",
"0.5417783",
"0.5337474",
"0.5304462",
"0.52880955",
"0.52643615",
"0.5250653",
"0.5230598",
"0.5216091",
"0.518172",
"0.51293135",
"0.5114803",
"0.509975... | 0.6469481 | 2 |
put a bomb explosion on position pos. return explosion range as a set | def explosion_range(bomb_pos)
candidate = exposion_range_without_wall(bomb_pos) - @wall
elect = Set.new
walkable = Set.new(candidate)
loop do
break if candidate.empty?
s, e = bomb_pos, candidate.first
path = AStar(s, e, walkable)
#no shortest path
if not path
candidate.delete(s)
candidate.delete(e)
elect << s
next
end
#find shortest path
path.each_index do |step|
pos = path[step]
candidate.delete(pos)
elect << pos if step <= @d # bomb on bom_pos can reach pos
end
end
return elect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bomb_explosion_range(action = :increment)\n @bomb_manager.explosion_range action\n end",
"def exposion_range_without_wall(pos)\n\t\trange = Set.new\n\t\t@template.each do |orig_pos|\n\t\t\ttrans_pos = Array.new(orig_pos)\n\t\t\ttrans_pos.row += pos.row\n\t\t\ttrans_pos.col += pos.col\n\t\t\tif (0...n).co... | [
"0.7093686",
"0.6117279",
"0.5506248",
"0.5503385",
"0.54874474",
"0.5395577",
"0.53761524",
"0.53741246",
"0.53574306",
"0.5285964",
"0.5251987",
"0.52062863",
"0.5205123",
"0.5119077",
"0.5111693",
"0.50999427",
"0.5072266",
"0.5032305",
"0.50094706",
"0.49615857",
"0.49483... | 0.7783826 | 0 |
Remove the following if you're only using portrait | def will_animate_rotate(orientation, duration)
find.all.reapply_styles
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def portrait?; end",
"def landscape?; end",
"def set_portrait\n @orientation = 1\n end",
"def shouldAutorotateToInterfaceOrientation interfaceOrientation\n # // Return YES for supported orientations.\n # //return interfaceOrientation == UIInterfaceOrientationPortrait;\n true\n end",
"def port... | [
"0.8359375",
"0.7413271",
"0.7157937",
"0.68576723",
"0.6791786",
"0.6665831",
"0.65481746",
"0.64277995",
"0.6297777",
"0.61366683",
"0.61036855",
"0.6103258",
"0.6103258",
"0.60684985",
"0.60276175",
"0.60117775",
"0.59446466",
"0.5876145",
"0.58523935",
"0.57331425",
"0.57... | 0.0 | -1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.mod_submission_mailer.mail_to_admin.subject | def mail_to_admin(mod_submission)
@mod_submission = mod_submission
mail to: "matt@lebel.io" , subject: "One New Module Submission Available For Review"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject\n @mail.subject\n end",
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n ... | [
"0.7019005",
"0.6982073",
"0.69610137",
"0.6836579",
"0.6824567",
"0.68236315",
"0.68006516",
"0.6797426",
"0.67960495",
"0.67943686",
"0.6647366",
"0.6613251",
"0.65677065",
"0.65677065",
"0.65677065",
"0.65677065",
"0.64939994",
"0.6483839",
"0.6471161",
"0.6432198",
"0.643... | 0.60462695 | 48 |
GET /orders GET /orders.json | def index
@orders = Order.by_state(params[:state]).search(params[:keyword]).page params[:page]
respond_to do |format|
format.html
format.json
format.csv { send_data @orders.to_csv }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def index\n @orders = Order.all\n render json: @orders\n end",
"def index\n @orders = Order.all\n ... | [
"0.83267236",
"0.815406",
"0.80041754",
"0.7947603",
"0.7846487",
"0.7823147",
"0.78028905",
"0.76992875",
"0.76980406",
"0.7682792",
"0.7682792",
"0.7682792",
"0.7682792",
"0.76827645",
"0.75880665",
"0.7574349",
"0.756171",
"0.7531827",
"0.74860185",
"0.7432208",
"0.7369724... | 0.0 | -1 |
GET /orders/1 GET /orders/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def index\n @orders = Order.all\n render json: @orders\n end",
"def index\n @orders = Order.all\n render json: @orders, status: 200\n end",
"def index\n @orders = Order.order(\"id\").all\n\n resp... | [
"0.75533825",
"0.74895185",
"0.74764353",
"0.7378989",
"0.73719287",
"0.7341498",
"0.73393774",
"0.73174775",
"0.73031616",
"0.72925746",
"0.72925746",
"0.72925746",
"0.72925746",
"0.72924364",
"0.72804433",
"0.72674763",
"0.7250841",
"0.72291356",
"0.7214567",
"0.7183521",
"... | 0.0 | -1 |
POST /orders POST /orders.json | def create
@order = Order.new(order_params)
respond_to do |format|
if @order.save
persist_order_address
format.html { redirect_to [:admin, @order], notice: 'Order was successfully created.' }
format.json { render action: 'show', status: :created, location: @order }
else
format.html { render action: 'new' }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orders\n authenticated_post(\"orders\").body\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def create\n order = Order.create(order_params)\n render json: order\nend",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = ... | [
"0.75886714",
"0.7490972",
"0.7488501",
"0.74664384",
"0.72739846",
"0.7195349",
"0.7063682",
"0.69745994",
"0.6910657",
"0.68880194",
"0.68747663",
"0.685004",
"0.6840204",
"0.6838178",
"0.6838178",
"0.6838178",
"0.6838178",
"0.682244",
"0.6790037",
"0.67793274",
"0.6779247"... | 0.6485337 | 65 |
PATCH/PUT /orders/1 PATCH/PUT /orders/1.json | def update
respond_to do |format|
if @order.update(order_params)
persist_order_address
format.html { redirect_to [:admin, @order], notice: 'Order was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_content\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_conte... | [
"0.6803119",
"0.6803119",
"0.67749745",
"0.6743427",
"0.67353284",
"0.6726928",
"0.6723453",
"0.6719653",
"0.67047364",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
"0.6704673",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_order
@order = Order.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def order_params
params.require(:order).permit(:special_instructions, :shipping_method_id, line_items_attributes: [:id, :variant_id, :price, :quantity, :_destroy])
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.6981606",
"0.6784227",
"0.6746523",
"0.67439264",
"0.67361516",
"0.6593381",
"0.6506166",
"0.64994407",
"0.6483518",
"0.64797056",
"0.64578557",
"0.6441216",
"0.63811713",
"0.63773805",
"0.6366333",
"0.63217646",
"0.6301816",
"0.63009787",
"0.6294436",
"0.62940663",
"0.629... | 0.0 | -1 |
def facet_filter override this to provide additional constraints nil end | def es_facet_class
if is_distance?
GeoDistanceFacet
else
RangeFacet
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_facet_field(*) super end",
"def render_filter_element(facet, values, localized_params)\n # Overrride BL's render_filter_element\n # When creating remove filter links exclude the date range added parameters, if present\n # Otherwise the filter gets removed but the parameters stay in the URL\n ... | [
"0.69509584",
"0.68063945",
"0.66341025",
"0.66246533",
"0.6587306",
"0.6566637",
"0.65467894",
"0.64402914",
"0.64110863",
"0.6399205",
"0.6307552",
"0.6294035",
"0.6281053",
"0.6212003",
"0.62007004",
"0.61739266",
"0.6139975",
"0.6135269",
"0.61293995",
"0.610518",
"0.6097... | 0.0 | -1 |
NOTE: we use this pair of methods to transform between es and clientside units | def initialize_rows
@transform_lookup = {}
if is_time?
initialize_time_rows
elsif is_distance?
initialize_distance_rows
else
initialize_numeric_rows
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def units\n @units = SQF.units @this\n @units\n end",
"def unit_conversion\n if user.metric_system?\n self.distance = Goal.kms_to_miles(distance) if distance.present?\n self.vertical_gain = Goal.meters_to_feet(vertical_gain) if vertical_gain.present?\n end\n end",
"def value_from_units ... | [
"0.6690909",
"0.6566071",
"0.6484851",
"0.6444477",
"0.64376646",
"0.6410337",
"0.63341236",
"0.62523085",
"0.6204305",
"0.6203699",
"0.6202544",
"0.6128126",
"0.60987455",
"0.6066264",
"0.60201",
"0.59954417",
"0.5967133",
"0.5935795",
"0.5935795",
"0.58879924",
"0.5880713",... | 0.0 | -1 |
need to move to application controlller and except the auth.json | def grats
quants = [ 46043, 17140, 11105, 11956, 20928, ]
# [ 80431, 31000, 18133, 20000, 28778 ]
symbols = ['csco','crm','msft','intc','amat']
costs = [ 1076070.00, 1108836.00, 406866.00, 283692.00, 233090.00 ]
# [ 2104879.27, 2168140.00, 796038.70, 554400.00, 458721.32]
@cash = 235782 # 155000
@latest = [ ]
prices = Options.stock_price(symbols)
@total = 0
prices.each do |s|
symbol = s['Symbol']
index = symbols.index(symbol)
value = quants[index] * s['LastTrade'].to_d
profit = (quants[index] * s['LastTrade'].to_d) - costs[index]
change = (quants[index] * s['Change'].to_d)
@total += profit
@latest.push [ symbol.upcase, quants[index], change, profit, s['LastTrade'] ]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth_info\n render :action => 'auth_info.json', :layout => false\n end",
"def auth_store; end",
"def auth\n end",
"def auth\n end",
"def auth\n {}\n end",
"def authorize_application\n render json: { ok: false, message: 'unauthorized' }, status: 401 unless request.headers['App... | [
"0.6422438",
"0.6273565",
"0.62371933",
"0.62371933",
"0.61892486",
"0.6171844",
"0.5922347",
"0.5914494",
"0.5897142",
"0.58174866",
"0.5811394",
"0.5811394",
"0.5811394",
"0.5811394",
"0.5811394",
"0.57409936",
"0.5740043",
"0.5712492",
"0.5687165",
"0.56609106",
"0.5660910... | 0.0 | -1 |
Helper for windows clang compiling | def setCXXEnv
# Could store and restore these...
@Clang.setupEnv
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_clang()\n catch_error(\"You passed the --clang option and clang is not in your path. \\nPlease try again or do not use --clang.\") do\n exec_cmd(%[command -v clang])\n end\n return true\n end",
"def compile(compilable)\r\n compiler = File.expand_path @compiler_exe, @compiler_pat... | [
"0.63968444",
"0.61771774",
"0.5931661",
"0.5886322",
"0.581332",
"0.577381",
"0.5728605",
"0.56815547",
"0.565777",
"0.5630128",
"0.56062436",
"0.5596375",
"0.5581845",
"0.5578365",
"0.5558083",
"0.5547668",
"0.5503448",
"0.54798096",
"0.54627705",
"0.5406443",
"0.53834856",... | 0.5472407 | 18 |
Helper for windows clang compiling | def unsetCXXEnv
@Clang.unsetEnv
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_clang()\n catch_error(\"You passed the --clang option and clang is not in your path. \\nPlease try again or do not use --clang.\") do\n exec_cmd(%[command -v clang])\n end\n return true\n end",
"def compile(compilable)\r\n compiler = File.expand_path @compiler_exe, @compiler_pat... | [
"0.63968444",
"0.61771774",
"0.5931661",
"0.5886322",
"0.581332",
"0.577381",
"0.5728605",
"0.56815547",
"0.565777",
"0.5630128",
"0.56062436",
"0.5596375",
"0.5581845",
"0.5578365",
"0.5558083",
"0.5547668",
"0.5503448",
"0.54798096",
"0.5472407",
"0.54627705",
"0.5406443",
... | 0.0 | -1 |
Method to add an item to a list input: list, item name, and optional quantity steps: take a string, take an item from another input, [nil] output:list with new item added, and quantity | def add_item(grocery_list, item, quantity=1)
grocery_list[item]= quantity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(list, item, quantity=1)\r\n# input: item name and optional quantity\r\n# steps: \r\n # Use shopping list as input\r\n # Use the item to be added as 2nd input\r\n # Use the item quantity as a 3rd input (look up whether optional input is possible)\r\n # Add the item and quantity to the shopping list... | [
"0.8416545",
"0.82361287",
"0.8235973",
"0.8235973",
"0.8181764",
"0.8181764",
"0.816011",
"0.80380267",
"0.79817057",
"0.79689276",
"0.79129446",
"0.7896436",
"0.7882986",
"0.78582394",
"0.78233325",
"0.78039056",
"0.78034896",
"0.7787218",
"0.77802134",
"0.7777428",
"0.7770... | 0.0 | -1 |
Method to remove an item from the list input: list, string"key", quantity"value" steps: find key/value and delete it output: p the hash without the deleted key | def remove_item(grocery_list, item)
grocery_list.delete(item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_item(input_hash, item)\n# input: list, item name, and optional quantity\n# steps: use input item to delete key\n input_hash.delete(item)\n# output: hash data structure of key/value pairs\nreturn input_hash\nend",
"def remove_item(my_list, item)\r\n# input: an item (something already in the list)\r\n#... | [
"0.85334784",
"0.82279915",
"0.8173182",
"0.8148352",
"0.8082274",
"0.80267936",
"0.7893859",
"0.78660905",
"0.76861584",
"0.76582456",
"0.7614071",
"0.75751853",
"0.75597817",
"0.7526166",
"0.75247985",
"0.75247985",
"0.7509318",
"0.7505354",
"0.7504471",
"0.7498081",
"0.747... | 0.0 | -1 |
Method to update the quantity of an item input: List and updating quantity"value" string"key" steps: pass in grocery_list and change value of string output: p updated grocery_list | def update_quantity(grocery_list, item, quantity)
add_item(grocery_list, item, quantity)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_quantity_in_grocery_list(grocery_list, item_name, quantity)\n # steps: update quantity for item\n grocery_list[item_name.to_sym] = quantity\n # output: explicit return updated hash\n grocery_list\nend",
"def update_quantity(grocery_list, item_to_update, qty)\n grocery_list[item_to_update] = qty\n... | [
"0.8949828",
"0.8696384",
"0.86850566",
"0.86380774",
"0.857044",
"0.8537167",
"0.8535923",
"0.85338753",
"0.85338753",
"0.85156566",
"0.8491477",
"0.84675807",
"0.84233785",
"0.84010017",
"0.83982396",
"0.8363292",
"0.83294576",
"0.8319808",
"0.8300036",
"0.82935274",
"0.828... | 0.7998542 | 32 |
Method to print a list and make it look pretty input: take grocery_list steps: loop list, add title output: pretty list | def pretty_list(grocery_list)
puts "Your Grocery List for next week!"
grocery_list.each do |item, num|
puts "#{item} qty #{num}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_list(list)\n\tlist.each do |item, quantity|\n\t\tputs \"There are #{quantity} #{item} on the grocery list.\"\n\tend\nend",
"def look_pretty(list)\n puts \"Here is your grocery list:\"\n list.each { |item, quantity| puts \"#{item}: #{quantity}\" }\nend",
"def pretty_list(list)\n puts \"Grocery List... | [
"0.8215363",
"0.80579245",
"0.8027588",
"0.80151266",
"0.80043745",
"0.80043745",
"0.7907686",
"0.7894245",
"0.7850812",
"0.78442687",
"0.780863",
"0.7738925",
"0.77158856",
"0.7688331",
"0.7617733",
"0.7599587",
"0.75658864",
"0.7556144",
"0.75404185",
"0.7502246",
"0.749628... | 0.8106599 | 1 |
4) a new method that will create a new blog post | def new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_blog_post\n\t\t# Get current time when post was created\n\t\tcurrent_time = Time.now\n\n\t\t# Name of the content creator\n\t\tputs \"Enter your name: \"\n\t\tblog_author = gets.chomp\n\n\t\t# Title of blog post\n\t\tputs \"Post title: \"\n\t\tblog_title=gets.chomp\n\n\t\t# Content of blog post\n\t\tputs \... | [
"0.8236085",
"0.8045422",
"0.80337363",
"0.8011226",
"0.7987851",
"0.7932013",
"0.7822921",
"0.77063316",
"0.763832",
"0.75655353",
"0.756449",
"0.756449",
"0.75231963",
"0.7517265",
"0.7493231",
"0.745449",
"0.745114",
"0.745114",
"0.7430354",
"0.7428026",
"0.7416549",
"0.... | 0.0 | -1 |
Execute block after some time | def after(delay_sec, &block)
raise "Missing implementation 'after'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after(interval, &block); end",
"def with_timeout(time, &block)\n Timeout.timeout(time) do\n block.call(self)\n end\n end",
"def timeout_after(time); end",
"def on_timeout(options = {})\n timeout = options[:timeout] || 0.5\n\n sleep timeout\n\n yield\n end",
"def ru... | [
"0.734226",
"0.7173641",
"0.7108369",
"0.69678694",
"0.6843299",
"0.6763355",
"0.67600554",
"0.67062706",
"0.669345",
"0.66597766",
"0.6650306",
"0.66306275",
"0.6605968",
"0.66040796",
"0.6571928",
"0.65424556",
"0.65280503",
"0.6525048",
"0.64668745",
"0.6466149",
"0.646207... | 0.6165447 | 54 |
Periodically call block every interval_sec | def every(interval_sec, &block)
raise "Missing implementation 'every'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interval duration, &block\n `setInterval(function() { #{block.call} }, duration * 1000)`\n end",
"def every(interval, &block)\n Timer.new(self, interval, true, block)\n end",
"def periodically(interval, &block)\n EventMachine::PeriodicTimer.new(interval, &block)\n end",
"def periodically(... | [
"0.71171546",
"0.69778156",
"0.69612396",
"0.69612396",
"0.6935349",
"0.69055146",
"0.6846257",
"0.6805411",
"0.6782046",
"0.6715308",
"0.66548204",
"0.66058785",
"0.6601802",
"0.658373",
"0.6582203",
"0.65142286",
"0.6505487",
"0.64913076",
"0.6463782",
"0.64613104",
"0.6461... | 0.6637515 | 11 |
Call 'block' in the context of a separate thread. | def defer(&block)
raise "Missing implementation 'defer'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runblock\r\n\t\t\t@b.call\r\n\t\tend",
"def runblock\r\n\t\t\t@b.call\r\n\t\tend",
"def thread(&block)\n warn 'A Block is Needed' unless block_given?\n Java::JavaLang::Thread.new(&block).start\n end",
"def call_block\n @_block.call(self) if @_block\n end",
"def synchronize_block(&b... | [
"0.70992064",
"0.70992064",
"0.70462257",
"0.6973938",
"0.6843728",
"0.67711735",
"0.6705492",
"0.6687097",
"0.6685909",
"0.6606101",
"0.660264",
"0.6529717",
"0.6526353",
"0.65163046",
"0.6489503",
"0.64863855",
"0.6451361",
"0.6406846",
"0.6395413",
"0.6382068",
"0.63734394... | 0.0 | -1 |
Block calling thread until eventloop exits | def join()
raise "Missing implementation 'join'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_event_loop\n while true\n event = @event_queue.pop\n @worker_pool.dispatch event\n \n if @stopped\n Thread.stop;\n return\n end\n end\n end",
"def wake_event_loop!\n super\n end",
"def wake_event_loop!\n super\n end",
"def join\n require \"th... | [
"0.68293977",
"0.67887175",
"0.67887175",
"0.67329645",
"0.66352224",
"0.65671515",
"0.65609515",
"0.65282714",
"0.6523593",
"0.65003353",
"0.647598",
"0.647598",
"0.647598",
"0.64626145",
"0.6436229",
"0.6388149",
"0.6352852",
"0.63288015",
"0.6325552",
"0.63198155",
"0.6303... | 0.0 | -1 |
Calling 'block' before stopping eventloop | def on_stop(&block)
@@on_stop_proc << block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wake_event_loop!\n super\n end",
"def wake_event_loop!\n super\n end",
"def stop\n @event_loop.stop\n end",
"def stop\n yield\n end",
"def force_end\n stop\n end",
"def stop(&block)\n yield(DONE)\n puts stop_message\n end",
"def run_nonblock(&block)\n ... | [
"0.7116361",
"0.7116361",
"0.69921833",
"0.6747109",
"0.66986316",
"0.6674539",
"0.6607117",
"0.6583129",
"0.65828156",
"0.65612423",
"0.65526044",
"0.6534999",
"0.6524514",
"0.65144956",
"0.6511241",
"0.64684826",
"0.6467592",
"0.64470565",
"0.6444129",
"0.6431461",
"0.64314... | 0.6135901 | 74 |
Calling 'block' when having trapped an INT signal | def on_int_signal(&block)
# trap(:INT)
warn "Missing implementation 'on_int_signal'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_interrupt; end",
"def on_interrupt(&block)\n trap(\"INT\") { yield \"SIGINT\" }\n trap(\"QUIT\") { yield \"SIGQUIT\" }\n trap(\"TERM\") { yield \"SIGTERM\" }\n end",
"def interrupt_handler\n signal_handler(2)\n end",
"def run(&block)\n raise \"#{self} cannot run; it... | [
"0.6885704",
"0.68752533",
"0.6866606",
"0.6766158",
"0.6764911",
"0.674545",
"0.6618631",
"0.6530069",
"0.65250605",
"0.6524573",
"0.6524573",
"0.65173304",
"0.65173304",
"0.64479595",
"0.6390202",
"0.6321037",
"0.6320309",
"0.62833625",
"0.62184215",
"0.62168443",
"0.618842... | 0.8010634 | 0 |
Calling 'block' when having trapped a TERM signal | def on_term_signal(&block)
# trap(:TERM) {}
warn "Missing implementation 'on_term_signal'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(&block)\n yield(DONE)\n puts stop_message\n end",
"def signal; end",
"def signal; end",
"def signal_received; end",
"def trap_sigint(metabolizer, &block)\n trap 'SIGINT', proc {\n block.call if block\n metabolizer.stop\n }\nend",
"def user_interrupt\n write 'Terminating... | [
"0.6559758",
"0.65104586",
"0.65104586",
"0.63744813",
"0.6368255",
"0.63094765",
"0.62805223",
"0.6260285",
"0.6246381",
"0.6223103",
"0.62135446",
"0.6194549",
"0.6158756",
"0.61425453",
"0.6135079",
"0.6112899",
"0.6101866",
"0.60911554",
"0.60883284",
"0.60726094",
"0.605... | 0.71361977 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_lessor
@lessor = Lessor.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def lessor_params
params.require(:lessor).permit(:name, :street_address, :secondary_address, :city, :region, :postal_code)
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 |
Return list of jobs. | def jobs
@jobs || {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jobs\n self.ListJobs.first.map { |j| map_job(j) }\n end",
"def all_jobs\n\n find_jobs()\n end",
"def jobs(opts = {})\n api(\n @client.list_jobs(\n @project_id,\n deep_symbolize_keys(opts)\n )\n )\n end",
"def jobs\n command... | [
"0.8126788",
"0.8117135",
"0.80994934",
"0.8092008",
"0.80488855",
"0.78076774",
"0.7758362",
"0.7710676",
"0.76651984",
"0.7636592",
"0.76280385",
"0.7369261",
"0.7353377",
"0.7346987",
"0.7333097",
"0.72216576",
"0.72106916",
"0.7198069",
"0.71886104",
"0.71610457",
"0.7153... | 0.7759051 | 6 |
Enqueue a job into a particular queue. | def enqueue(job)
@jobs ||= {}
@jobs[job.key] = {}
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enqueue_to(queue, job_class, *args)\n with_error_handling(\"Unable to enqueue #{job_class} job\", args: args) do\n Ladon.q.enqueue_to(queue, job_class, *args)\n end\n end",
"def enqueue(job)\n enqueue_at(job, nil)\n end",
"def enqueue(job)\n sqs.send_message(\n ... | [
"0.8014748",
"0.7826505",
"0.7725549",
"0.7592699",
"0.7414797",
"0.7373411",
"0.7295768",
"0.72914034",
"0.7290652",
"0.72016895",
"0.71104693",
"0.71096313",
"0.7105313",
"0.7100409",
"0.7095674",
"0.7084536",
"0.7083227",
"0.7054562",
"0.6986887",
"0.69255364",
"0.6885057"... | 0.68385386 | 21 |
Dequeue a job from a particular queue. | def dequeue(job)
@jobs = @jobs.delete(job.key)
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dequeue; @queue.pop end",
"def dequeue\n self.job.destroy if self.job.present?\n self.job_id = nil\n end",
"def deq\n @queued = false\n nil\n end",
"def dequeue\n @queue.shift\n end",
"def delete_queue(queue_name)\r\n execute(:delete, queue_name, {}, {:x_ms_version => '20... | [
"0.69838077",
"0.6737052",
"0.6486255",
"0.6462884",
"0.6448187",
"0.6438257",
"0.642777",
"0.64235634",
"0.63131315",
"0.6302172",
"0.6301203",
"0.62997967",
"0.62590736",
"0.6258003",
"0.6223807",
"0.6210933",
"0.618593",
"0.61715263",
"0.6166351",
"0.6150891",
"0.61361855"... | 0.65016425 | 2 |
Returns the status of a job existing in a queue. | def include?(job)
jobs.keys.include?(job.key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_job_status(job_id)\n @dbh[:progress_bars].filter(:id => job_id).first\n end",
"def status\n job = delayed_job\n return 'queued' if job_queued?(job)\n return 'working' if job_working?(job)\n return 'completed' if job_completed?(job)\n return 'failed' if job_failed?(j... | [
"0.68900853",
"0.68393534",
"0.6745003",
"0.67309284",
"0.6697998",
"0.66489804",
"0.6630047",
"0.65943176",
"0.64722687",
"0.6439859",
"0.6397403",
"0.63956904",
"0.6361938",
"0.6348004",
"0.6336583",
"0.6308881",
"0.6304712",
"0.6273187",
"0.62699956",
"0.62672824",
"0.6229... | 0.5509822 | 91 |
Find the next available job id to work. | def next_availability
if job = jobs.detect { |k, v| v['reserved_at'].nil? }
job.first
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_job_id\n new_id = rand(10*5)\n get_job_status(new_id).nil? ? new_id : next_job_id\n end",
"def next_available_id\n last_id = all_ids.map do |key|\n key.sub(\"#{self.name}_\", \"\").to_i\n end.max.to_i\n\n last_id + 1\n end",
"def getNextJob()\n\t\t\t\tjob = nil\n\t\t\t\... | [
"0.79036564",
"0.7319212",
"0.68572474",
"0.6805253",
"0.655543",
"0.64407593",
"0.63851684",
"0.6381658",
"0.6381658",
"0.6325248",
"0.6299104",
"0.62964135",
"0.6267012",
"0.62111694",
"0.62026817",
"0.6197503",
"0.6156408",
"0.6155267",
"0.61458766",
"0.61289924",
"0.61287... | 0.6686222 | 4 |
Mark the job as reserved. | def make_reservation(job_id)
self.jobs[job_id]['reserved_at'] = Time.now.to_i
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reserve_with_restriction\n @job_in_progress = reserve_without_restriction\n return @job_in_progress\n end",
"def reserve\n db.transaction do\n if job = waiting.order(:id).last # asc\n job[:started_working_at] = Time.now\n update_job!(job)\n payl... | [
"0.6649992",
"0.6210308",
"0.61216795",
"0.60015666",
"0.5845675",
"0.58375907",
"0.58310795",
"0.582418",
"0.57884026",
"0.57077265",
"0.56065375",
"0.55709714",
"0.5553302",
"0.5550803",
"0.5543129",
"0.55062103",
"0.549373",
"0.5461285",
"0.54420185",
"0.5428861",
"0.53920... | 0.70366853 | 0 |
Generates a unique key to be used when creating the associated Riak object. | def default_key
Digest::SHA1.hexdigest("riaque:#{name}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_key; end",
"def gen_key(record)\n return Digest::SHA2.hexdigest(record.to_s)\n end",
"def create_key\n self.key = Digest::MD5.hexdigest(self.official_id.to_s + self.sent_to_email)\n end",
"def generate_key\n proposed_key = nil\n\n loop do\n num_part = rand(10**7).to_s.rjust(7,... | [
"0.8125229",
"0.7617282",
"0.7545355",
"0.7478967",
"0.74477893",
"0.74038094",
"0.7332637",
"0.72810644",
"0.7180655",
"0.7153357",
"0.7148903",
"0.7148903",
"0.71096706",
"0.7105881",
"0.70891494",
"0.7080526",
"0.6984075",
"0.69129705",
"0.69052917",
"0.68694407",
"0.68677... | 0.7108455 | 13 |
Seed multiple ethnicities by loading the YAML file | def db_seed_ethnicities
path = Rails.root.join('db','seeds','ethnicities.yml')
File.open(path) do |file|
# puts "Seeding App Ethnicities from #{path}"
YAML.load_stream(file) do |doc|
doc.keys.each do |group|
# puts "Seeding ethnicity with group #{group}"
names = doc[group]
names.each do |name|
db_seed_ethnicity(group, name)
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seed\n establish_connection(\n database_yaml_path: options.fetch('database_yaml'),\n environment: options.fetch('environment')\n )\n\n load_seeds\n end",
"def db_seed_questions\n path = Rails.root.join('db','seeds','questions.yml')\n File.open(path) do |file|\n # puts \"Seeding A... | [
"0.65405065",
"0.6289179",
"0.62849",
"0.6165538",
"0.6074019",
"0.6074019",
"0.6046924",
"0.6001355",
"0.59213084",
"0.589432",
"0.5819937",
"0.58128124",
"0.57850516",
"0.57461166",
"0.5740708",
"0.5727112",
"0.5717558",
"0.5716261",
"0.56970215",
"0.5696358",
"0.5672369",
... | 0.7922321 | 0 |
Produces > Thursday May 25, 2006 | def date_formatted
date.strftime("%A %B %d, %Y")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_day_published\r\n \"Published : #{created_at.strftime('%-b %-d, %Y')}\"\r\n end",
"def display_day_published\n \"Published : #{created_at.strftime('%-b %-d, %Y')}\"\n end",
"def wday() end",
"def week\n published_at.strftime('%W')\n end",
"def formatted_date\n \"#{self.day.date.s... | [
"0.6963673",
"0.686262",
"0.66893697",
"0.6641272",
"0.66404676",
"0.66287845",
"0.6593285",
"0.6473139",
"0.64703923",
"0.64516735",
"0.6395532",
"0.6374176",
"0.63724506",
"0.6358772",
"0.633706",
"0.633706",
"0.6332694",
"0.63323814",
"0.6321644",
"0.63023096",
"0.6278043"... | 0.5890699 | 98 |
Generate a mail code, we've just made up some random format for fun | def new
@mail_code = new_mail_code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mk_email\n ps = \"P.S. Jeg har vedhæftet relevante dokumenter, så som eksamensbevis og CV i mailen.\"\n ps += \"\\nP.P.S Denne email var genereret med, og sendt fra et Ruby script :)\" if @skills and @skills.include? \"Ruby\"\n \"#{mk_intro}\\n#{mk_body}#{mk_outro}#{mk_sender}#{ps}\"\n ... | [
"0.72666997",
"0.7083372",
"0.7003533",
"0.6906018",
"0.6809272",
"0.6696758",
"0.6658766",
"0.65831333",
"0.65177906",
"0.64972395",
"0.6428326",
"0.6405881",
"0.63336295",
"0.63279736",
"0.624863",
"0.62463194",
"0.6245141",
"0.6192106",
"0.61861986",
"0.6174866",
"0.616592... | 0.0 | -1 |
TODO: Add some validation | def upvote
self.votes += 1
save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def schubert; end",
"def probers; end",
"def formation; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def suivre; end",
"def verdi; end",
"def refutal()\n end",
"def who_we_are\r\n end",
"def identify; end",
"def custom; end",
... | [
"0.75198245",
"0.66113764",
"0.6524906",
"0.6506399",
"0.6479728",
"0.6479728",
"0.6479728",
"0.6479728",
"0.62942326",
"0.6069807",
"0.60287654",
"0.5979395",
"0.59318125",
"0.5893944",
"0.5893944",
"0.5848804",
"0.58361995",
"0.58361995",
"0.5789293",
"0.5789293",
"0.576212... | 0.0 | -1 |
Extracts properties from the constitutent external metadata file | def extract_metadata
raise ArgumentError, "MIME type unspecified or not configured" if schema.blank?
fn = "extract_#{schema.downcase}_metadata"
raise ArgumentError, "Unsupported metadata standard: #{schema}" unless respond_to?(fn.to_sym)
send(fn, metadata_xml)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_metadata; end",
"def fetch_metadata\n {\n \"public_fqdn\" => fetch_metadata_item(\"getFullyQualifiedDomainName.txt\"),\n \"local_ipv4\" => fetch_metadata_item(\"getPrimaryBackendIpAddress.txt\"),\n \"public_ipv4\" => fetch_metadata_item(\"getPrimaryIpAddress.txt\"),\n \"region\... | [
"0.7063772",
"0.6791552",
"0.67238957",
"0.66800815",
"0.66672",
"0.6636372",
"0.6631644",
"0.6623437",
"0.6492731",
"0.6476489",
"0.6413062",
"0.6380664",
"0.63793457",
"0.6362726",
"0.6352782",
"0.6352782",
"0.62828296",
"0.62828296",
"0.6239153",
"0.61996365",
"0.61969566"... | 0.61722845 | 22 |
Retrives data from PCDM::File | def metadata_xml
Nokogiri::XML(original_file.content)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(file)\n f = File.open(file, 'rb')\n buffer = f.read\n f.close\n\n buffer\n end",
"def data\n File.read(path)\n end",
"def file_data\n @client.get_file @file_url\n end",
"def read_data_file(path); end",
"def read\n file\n end",
"def read\n\t\t@file_con... | [
"0.7153853",
"0.6887972",
"0.67489123",
"0.6554701",
"0.65546364",
"0.649592",
"0.6493495",
"0.63358885",
"0.6288144",
"0.62759733",
"0.6240904",
"0.62229455",
"0.6179153",
"0.61727494",
"0.6171157",
"0.61616135",
"0.6152086",
"0.6131227",
"0.61237633",
"0.60918105",
"0.60476... | 0.0 | -1 |
GET /property_images/1 GET /property_images/1.json | def show
@property_image = PropertyImage.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @property_image }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @image = Image.find(params[:id])\n\n render json: @image\n end",
"def show\n @image = Image.find(params[:id])\n\n render json: @image\n end",
"def fetch_images(property_id)\n fetcher = Commands::ImageListFetcher.new(credentials)\n fetcher.call(property_id)\n end",
"def s... | [
"0.7120165",
"0.7120165",
"0.7105922",
"0.70650995",
"0.6934196",
"0.6862584",
"0.68547416",
"0.68543005",
"0.68533903",
"0.6827014",
"0.6810154",
"0.67906386",
"0.6789656",
"0.67575496",
"0.675285",
"0.67427236",
"0.67427236",
"0.67427236",
"0.67427236",
"0.67240596",
"0.669... | 0.77224433 | 0 |
GET /property_images/new GET /property_images/new.json | def new
@property_image = PropertyImage.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @property_image }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @property_picture = PropertyPicture.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @property_picture }\n end\n end",
"def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render... | [
"0.777635",
"0.7562134",
"0.7562134",
"0.7562134",
"0.7562134",
"0.7562134",
"0.7562134",
"0.75000316",
"0.7494919",
"0.7483253",
"0.7478794",
"0.7455325",
"0.73461235",
"0.7290786",
"0.72890764",
"0.7280207",
"0.71146154",
"0.71138805",
"0.71067756",
"0.7106229",
"0.7106229"... | 0.823767 | 0 |
POST /property_images POST /property_images.json | def create
@property_image = PropertyImage.new(params[:property_image])
respond_to do |format|
if @property_image.save
format.html { redirect_to property_images_path, notice: 'Property image was successfully created.' }
format.json { render json: @property_image, status: :created, location: @property_image }
else
format.html { render action: "new" }
format.json { render json: @property_image.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n image = PropertyImage.new()\n image.photo = params[:file]\n image.property_form = @property_form\n if image.save\n respond_to do |format|\n format.json do\n json = {id: image.id}\n render json: json\n end\n end\n end\n end",
"def add_images\n... | [
"0.7552794",
"0.7349602",
"0.72869056",
"0.7219757",
"0.7153606",
"0.69927925",
"0.6989445",
"0.6960517",
"0.66880286",
"0.6680542",
"0.6634192",
"0.6609078",
"0.65908194",
"0.6574689",
"0.65677834",
"0.6558739",
"0.6531264",
"0.64791864",
"0.64762497",
"0.6437422",
"0.641448... | 0.7515556 | 1 |
PUT /property_images/1 PUT /property_images/1.json | def update
@property_image = PropertyImage.find(params[:id])
respond_to do |format|
if @property_image.update_attributes(params[:property_image])
format.html { redirect_to property_images_path, notice: 'Property image was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @property_image.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @estate_agent_image = EstateAgentsImage.find(params[:id])\n\n respond_to do |format|\n if @estate_agent_image.update_attributes(params[:property_image])\n format.html { redirect_to @estate_agent_image, notice: 'Property image was successfully updated.' }\n format.json { head :... | [
"0.73272014",
"0.7085052",
"0.7002534",
"0.6977821",
"0.69507855",
"0.69049263",
"0.69049156",
"0.6879201",
"0.6794895",
"0.6707284",
"0.67003095",
"0.66444147",
"0.6618711",
"0.6615083",
"0.661299",
"0.65631896",
"0.6555667",
"0.65504545",
"0.642577",
"0.64194363",
"0.640991... | 0.7433387 | 0 |
DELETE /property_images/1 DELETE /property_images/1.json | def destroy
@property_image = PropertyImage.find(params[:id])
@property_image.destroy
respond_to do |format|
format.html { redirect_to property_images_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n render json: {status: \"success\"}, status: :ok\n end",
"def destroy\n #Finds selected image\n @image = Image.find(params[:id])\n #destroy image\n @image.destroy\n respond_to do |format|\n format.html { redirect_to '/... | [
"0.73616624",
"0.7265958",
"0.72610325",
"0.72505075",
"0.72239304",
"0.7183274",
"0.7182659",
"0.7166094",
"0.7142178",
"0.7142178",
"0.7142178",
"0.7142178",
"0.7142178",
"0.7142178",
"0.7142178",
"0.71404487",
"0.71404487",
"0.71404487",
"0.71404487",
"0.71404487",
"0.7140... | 0.79029274 | 0 |
1. Write a badge_maker method that will create and return this message, given a person's name. ex: badge_maker("Arel") => "Hello, my name is Arel." " should return a formatted badge" | def badge_maker(name)
return "Hello, my name is #{name}." # or skip 'return', just using it here to be explicit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def badge_maker(name)\n return \"Hello, my name is #{name}.\"\n end",
"def badge_maker(name)\n\treturn \"Hello, my name is #{name}.\" \nend",
"def badge_maker( name )\n return \"Hello, my name is #{name}.\"\nend",
"def badge_maker(name)\n return \"Hello, my name is #{name}.\"\nend",
"def badge_make... | [
"0.8725693",
"0.86042297",
"0.8558621",
"0.8495704",
"0.8476773",
"0.8476773",
"0.8476773",
"0.8476773",
"0.8476773",
"0.8476773",
"0.8476773",
"0.8476773",
"0.8457231",
"0.8457231",
"0.8417373",
"0.8417373",
"0.8417373",
"0.84007484",
"0.8386274",
"0.8386274",
"0.83823067",
... | 0.8172926 | 33 |
b. Write a batch_badge_creator method that takes a list of names as an argument and return a list of badge messages. Hint: Use the variable you created in part a. == speakers array collect iterates over the array and creates a new array containing modified values. | def batch_badge_creator(speakers) # because it takes array as an argument, it will go through each of the array contents
speakers.collect { |x| badge_maker(x) } #technically, it returns an array of new messages, not really separate messages
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_badge_creator(speakers)\n badge_messages = []\n for speaker in speakers do\n badge_messages << \"Hello, my name is #{speaker}.\" \n end\n return badge_messages\nend",
"def batch_badge_creator(names)\n names.collect { |array_value| badge_maker(array_value) }\nend",
"def batch_badge_creator(spe... | [
"0.8458191",
"0.8451556",
"0.8446363",
"0.83969724",
"0.8392957",
"0.83397466",
"0.82760596",
"0.8260213",
"0.823035",
"0.82086676",
"0.8206306",
"0.8194381",
"0.8176962",
"0.8166093",
"0.8164338",
"0.81437826",
"0.81309587",
"0.8077357",
"0.80665547",
"0.8006627",
"0.7890228... | 0.86165065 | 0 |
or use 'map', don't use collect like the below to see the transformed array: attendees.map do |attendee| badge_maker(attendee) end with each: attendees.each do |attendee| badge_maker(attendee) end this is basically using yield; the method takes us to an array, and the enumerator will go through attendeeds one by one 3. You just realized that you also need to give each speaker a room assignment. Write a method called assign_rooms that takes the list of speakers that will assign each speaker to a room. Make sure that each room only has one speaker. You have rooms 17. return a list of room assignments in the form of: "Hello, _____! You'll be assigned to room _____!" | def assign_rooms(speakers) # same logic -- using array as an argument
speakers.collect { |x| "Hello, #{x}! You'll be assigned to room #{speakers.index(x)+1}!" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_rooms(attendee)\n badges = []\n attendee.each.with_index(1) { |val,index| badges.push \"Hello, #{val}! You'll be assigned to room #{index}!\"}\n return badges\nend",
"def assign_rooms(attendees)\n#use #each_with_index to create a room pair for each name. use map to return as new array\n atte... | [
"0.75163215",
"0.75001603",
"0.73796827",
"0.73795754",
"0.73230606",
"0.73137933",
"0.7293626",
"0.72384405",
"0.72338235",
"0.7229176",
"0.7165625",
"0.71607494",
"0.7152063",
"0.7148399",
"0.7143087",
"0.7104131",
"0.70906377",
"0.70848817",
"0.7082804",
"0.7052302",
"0.70... | 0.6781814 | 29 |
set the status for the given node | def status
@node.status = request.raw_post
@node.save!
render :text => @node.status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setNodeON(node_id)\n cm_url = APP_CONFIG['cm_ip'] + ':' + APP_CONFIG['cm_port'].to_s\n\n options = {body: {state:\"on\"}.to_json, :headers => { 'Content-Type' => 'application/json' }}\n res = HTTParty.put(cm_url+\"/resources/node/\"+ node_id, options)\n \n end",
"def set_status(val)\n s... | [
"0.72162616",
"0.70840734",
"0.7028983",
"0.69587994",
"0.6822384",
"0.6748916",
"0.66424096",
"0.6572275",
"0.6521027",
"0.65065444",
"0.64727414",
"0.6472161",
"0.6472161",
"0.6472161",
"0.6472161",
"0.6472161",
"0.6472161",
"0.6472161",
"0.6472161",
"0.6472161",
"0.6472161... | 0.6145385 | 55 |
uppercase letters, no repeats). Consider the substrings of the string: consecutive sequences of letters contained inside the string. Find the longest such string of letters that is a palindrome. Note that the entire string may itself be a palindrome. You may want to use Array's `slice(start_index, length)` method, which returns a substring of length `length` starting at index `start_index`: "abcd".slice(1, 2) == "bc" "abcd".slice(1, 3) == "bcd" "abcd".slice(2, 1) == "c" "abcd".slice(2, 2) == "cd" Difficulty: hard. | def palindrome?(string)
i = 0
while i < string.length
if string[i] != string[(string.length - 1) - i]
return false
end
i += 1
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def longest_palindrome(string)\n\ti = 0\n\tlongest = \"\"\n\twhile i < string.length\n\t\tcurrent_palindrome = \"\"\n\t\tj = 1\n\t\twhile j <= string.length\n\t\t\tif palindrome?(string.slice(i,j))\n\t\t\t\tcurrent_palindrome = string.slice(i,j)\n\t\t\tend\n\n\t\t\tif longest == \"\" || current_palindrome.length >... | [
"0.8338428",
"0.8288934",
"0.82832694",
"0.82351744",
"0.81817216",
"0.8177087",
"0.81531215",
"0.8066029",
"0.80623484",
"0.8052572",
"0.8031901",
"0.7955093",
"0.79294676",
"0.7919743",
"0.79162496",
"0.78464746",
"0.78464746",
"0.7830216",
"0.78268725",
"0.7821299",
"0.780... | 0.0 | -1 |
specifies the URL on which to find categories | def start_url(url)
@start_url = url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_categories\n new_categories = extract_categories_from_url\n unless new_categories.nil?\n @categories = new_categories\n else\n @categories = Type::DefaultCategories\n end\n end",
"def calendar_category\n @request.path_parameters[:url][1]\n end",
"def discover_url\n \"... | [
"0.72489065",
"0.6903029",
"0.688453",
"0.6730876",
"0.66785306",
"0.6675466",
"0.6574682",
"0.65502435",
"0.6531038",
"0.6459287",
"0.6447425",
"0.6428674",
"0.641266",
"0.64035183",
"0.6395815",
"0.6330224",
"0.6295994",
"0.62713367",
"0.626723",
"0.62384194",
"0.61880934",... | 0.0 | -1 |
specifies the specific brand for that category | def brand_string(str)
@brand = str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_brand\n set_category\n @brand = @category.brands.find(params[:id]) if params[:id]\n end",
"def get_brand(brand)\n case brand\n when \"master\"\n return \"mastercard\"\n when \"american_express\"\n return \"amex\"\n else\n return brand\n ... | [
"0.7413724",
"0.72763336",
"0.69886476",
"0.69886476",
"0.69294107",
"0.69266593",
"0.6883197",
"0.6807878",
"0.6761751",
"0.6756354",
"0.6734865",
"0.67167133",
"0.6714422",
"0.67134464",
"0.6682297",
"0.6682297",
"0.6682297",
"0.6682297",
"0.6682297",
"0.6682297",
"0.666364... | 0.6305044 | 34 |
specifies a regular expression used to ignore categories if the name matches the specified regular expression | def ignore(regex)
@ignored = regex
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locale_exclude_regex(kind)\n Regexp.union(@exclude_objects[kind.to_sym].map do |identifier|\n if identifier.is_a? String\n # Add leading/trailing slashes if necessary\n new_identifier = identifier.dup\n new_identifier[/^/] = '/' if identifier[0,1] != '/'\n new_id... | [
"0.6018575",
"0.57293683",
"0.56914043",
"0.55394024",
"0.5514741",
"0.54915434",
"0.5430975",
"0.54145324",
"0.54131943",
"0.53974766",
"0.5396474",
"0.5388664",
"0.5372349",
"0.53656346",
"0.5339012",
"0.5329243",
"0.52785164",
"0.5269876",
"0.5232071",
"0.5232071",
"0.5189... | 0.6157789 | 0 |
specifies a regular expression to select only categories whose names match | def only(regex)
@only = regex
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category_conditions\n [\"words.category LIKE ?\", \"%#{category}\"]\n end",
"def category_matches? cat_name\n return cat_name.include?(category) || category == cat_name\n end",
"def category_candidates(category)\n return @category_cache[category] unless @category_cache[category].nil?\n ... | [
"0.6640181",
"0.64921373",
"0.64035004",
"0.6203284",
"0.597015",
"0.59113747",
"0.58240163",
"0.56399596",
"0.5637851",
"0.56202656",
"0.5564101",
"0.55602276",
"0.55597395",
"0.55504453",
"0.5531424",
"0.5494935",
"0.54743546",
"0.544384",
"0.5442288",
"0.5437962",
"0.54340... | 0.0 | -1 |
specifies the link to be excluded in scraping in order of appearance from top to bottom | def exclude_links(*array)
@excluded_link_indexes = array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ignore_links\n @link_rules.reject\n end",
"def skip_link!\n raise(SkipLink)\n end",
"def assert_absence_of_non_kamishibai_links(options = {})\n ignores = options[:except] || []\n ignores += accepted_non_kamishibai_links\n\n css_select(\"a\").each do |anchor|\n href = anchor.at... | [
"0.7324492",
"0.6665341",
"0.6572314",
"0.6433892",
"0.64058566",
"0.64058566",
"0.63779813",
"0.63513035",
"0.6261599",
"0.6244386",
"0.6244386",
"0.61454684",
"0.6128934",
"0.6115231",
"0.6086929",
"0.60516155",
"0.60129535",
"0.60029626",
"0.5953386",
"0.59207606",
"0.5916... | 0.6323119 | 8 |
used to specify subcategories. see Fetcher.categories | def categories(options=nil, &definition)
if options
if options[:for]
@embed_for = options[:for]
end
end
@embedded = CategoryScraper.new @fetcher_class,{:main_url => @main_url}, &definition
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subcategories\n @subcategories ||= Category.find_all_subcategories(category_name)\n end",
"def sub_categories(params = {})\n @sub_categories ||= client.categories.all(params.merge(parent: id))\n end",
"def index\n @subcategories = @category.subcategories\n end",
"def get_subcategories... | [
"0.7728158",
"0.7588042",
"0.6880803",
"0.68671745",
"0.68423116",
"0.6797682",
"0.67143977",
"0.67024696",
"0.66994005",
"0.6678905",
"0.66560155",
"0.65864986",
"0.6547976",
"0.6546187",
"0.65269643",
"0.6526152",
"0.6513359",
"0.6513359",
"0.64364403",
"0.64364403",
"0.643... | 0.0 | -1 |
The transport port to which the media stream is sent. | def transport_port=(port)
if port.match /\//
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def port\n @connection.port\n end",
"def port\n self.port\n end",
"def default_port\n transport.default_port\n end",
"def port\n return @port.to_i\n end",
"def remote_port\n return @remote_port\n end",
"def local_port\n retu... | [
"0.7513234",
"0.71351516",
"0.71020275",
"0.7032989",
"0.69719315",
"0.6951083",
"0.6916727",
"0.6916727",
"0.6916727",
"0.68983835",
"0.6897157",
"0.6877854",
"0.6851919",
"0.6851919",
"0.6841713",
"0.6832453",
"0.6832453",
"0.6766841",
"0.6677953",
"0.6671478",
"0.66423565"... | 0.68838 | 11 |
Checks to see if it has connection fields set. | def has_connection_fields?
!!(connection_network_type && connection_address_type &&
connection_address)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_connection?\n @connection && @connection.valid?\n end",
"def checkConnection\n unless connected?\n raise DictError.new(), \"Not connected.\"\n end\n end",
"def checkConnection\n unless connected?\n raise DictError.new(), \"Not connected.\"\n end\n end",
"def connecte... | [
"0.69252634",
"0.6743864",
"0.6743864",
"0.657802",
"0.6533757",
"0.6485211",
"0.6478045",
"0.6469435",
"0.6467915",
"0.6411449",
"0.6365215",
"0.6365215",
"0.63441753",
"0.6337181",
"0.63170624",
"0.63047093",
"0.6299431",
"0.6288328",
"0.6285538",
"0.62674135",
"0.62661785"... | 0.79839444 | 2 |
=> Methods! Gets Track Metadata from Spotify's Web Metadata API | def get_track(spotify_id)
content = HTTParty.get('http://ws.spotify.com/lookup/1/.json?uri=' + URI.escape("spotify:track:#{spotify_id}"))
if !content.body.empty?
Oj.load(content.body)
else
flash[:notice] = 'Error with Spotify! Try again in 10 seconds!'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_info( params )\n xml = LastFM.get( \"track.getInfo\", params )\n LastFM::Track.from_xml( xml )\n end",
"def tracks_get_info params = { :track_id => nil }\n json = send_request 'tracks_get_info', params\n if json['success'] == true\n json['data']\n else\n puts \"Error... | [
"0.68926036",
"0.6781096",
"0.6730962",
"0.6594536",
"0.65565485",
"0.65055186",
"0.649459",
"0.64723015",
"0.6459251",
"0.643704",
"0.6416832",
"0.63851583",
"0.6374228",
"0.6330928",
"0.6301184",
"0.6259826",
"0.6255222",
"0.6243315",
"0.61468714",
"0.61323196",
"0.61313915... | 0.64166534 | 11 |
Finds the song on youtube It does this by searching in format "Song Name Artist" on youtube Then it parses the XML data with nokogiri and picks the first video | def youtube
download = HTTParty.get("https://gdata.youtube.com/feeds/api/videos?q=#{URI.escape(@track)}")
if !download.body.empty?
doc = Nokogiri::HTML(download.body)
vids = doc.xpath('//link[contains(@href, "https://www.youtube.com/watch")]').to_a
video = vids.first
# Extracting the Video-ID
if video
query_string = URI.parse(video['href']).query
Hash[URI.decode_www_form(query_string)]
else
"Can't find a decent YouTube mirror."
end
else
flash[:notice] = 'Error with Youtube! Try again in 30 seconds!'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id\n url = \"https://www.youtube.com/results?search_query=#{@artist_name.gsub(\" \",\"+\")}+#{@song_name.gsub(\" \",\"+\")}\"\n#pp url\n web_page = HTTParty.get(url)\n\n @parsed = Nokogiri::HTML(web_page)\n ref = @parsed.css(\"a\").collect{|link| link[\"href\"]}.select{|href| href && href.include?(... | [
"0.7095424",
"0.63789326",
"0.6267256",
"0.62182397",
"0.62182397",
"0.6133526",
"0.594888",
"0.5894755",
"0.58848035",
"0.5850666",
"0.57705325",
"0.5742889",
"0.57082736",
"0.56800807",
"0.5664901",
"0.5637378",
"0.56163484",
"0.56132054",
"0.56091475",
"0.55646855",
"0.555... | 0.6912803 | 1 |
This method extracts the spotify track ID if the URI/URL is in the correct format If it isn't then it returns false | def extract_spotify_id(query)
if query.start_with?('http://open.spotify.com/track/', 'https://open.spotify.com/track/', 'https://play.spotify.com/track/', 'http://play.spotify.com/track/')
URI.split(query)[5].split('/')[2]
elsif query.start_with?('spotify:track:')
query.split(':')[2]
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def track_id\n @url.gsub(_url_regex, '')\n end",
"def extract_id_from_youtube_url\n if self.youtube_url.present?\n url = self.youtube_url\n self.external_id = Youtube.id_from_url(url) if url.present?\n self.errors.add(:youtube_url, 'is not a valid Youtube URL') unless self.external_id.prese... | [
"0.6885513",
"0.6647702",
"0.6527046",
"0.62536675",
"0.61541885",
"0.60888875",
"0.599258",
"0.5950304",
"0.5941533",
"0.59147716",
"0.588949",
"0.58433044",
"0.5798079",
"0.57464063",
"0.5733345",
"0.5707705",
"0.5699513",
"0.568366",
"0.56762314",
"0.56740475",
"0.56514555... | 0.81502295 | 0 |
that is evenly divisible by 4, unless the year is also divisible by 100. If the year IS divisible by 100, then it is not a leap year unless the year is divisible by 400. Write a method that takes any year greater than 0 as input, and returns true if the year is a leap year, or false if it is not a leap year. Examples: Pseudocode Given any year greater than 0 Determine if the year is divisible evenly by 400 If yes, return true. If no, determine if the year is divisible by 100 If yes, return true if no, determine if the year is divisible by 4. If yes, return true if no, return false. | def leap_year?(year)
if year < 1752 && year % 4 == 0
true
elsif year % 400 == 0
true
elsif year % 100 == 0
false
else
year % 4 == 0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leap_year?(year)\n #PSEUDOCODE\n #every four years is a leap year\n #2012,2016,2020 are leap years\n #check if input is divisble 4\n #2000 is a leap year because it is divisible by 400\n #1900 is NOT a leap year because its divisble by 100 but not 400\n\n year % 4 == 0 && (year % 100 !=0 || year % 400 =... | [
"0.906098",
"0.88388515",
"0.87225306",
"0.8712026",
"0.86061156",
"0.85405546",
"0.8539625",
"0.84958094",
"0.84656996",
"0.8424928",
"0.8423182",
"0.8422723",
"0.84201634",
"0.84133",
"0.84062076",
"0.8398416",
"0.8396825",
"0.8389221",
"0.8377899",
"0.8365543",
"0.83591807... | 0.81626004 | 89 |
adds repository hash to ENC global parameters | def params_with_repositories
# convert all repos to a format that puppet create_resource with yumrepo can consume
repos = Hash[attached_repositories.map { |repo| [repo.to_label, format_repo(repo)] }]
# adds a global parameter called repositories contain all repos
params_without_repositories.merge('repositories' => repos)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repository_params\n params.require(:repository).permit(:title, :path, :vcs_type, :weblink_to_commit, :hook_enabled, :hook_login, :hook_password)\n end",
"def register(params)\n @fields = params[\"fields\"]\n @tag = params[\"tag\"]\n @key = params[\"key\"]\n @digest = OpenSSL::Digest::SHA256.new\n... | [
"0.6254725",
"0.61494255",
"0.59811825",
"0.5894692",
"0.58299",
"0.58299",
"0.5826589",
"0.5807352",
"0.5807352",
"0.5777314",
"0.56591165",
"0.56591165",
"0.5653479",
"0.56063724",
"0.56062937",
"0.5558191",
"0.55314964",
"0.5517735",
"0.5511326",
"0.55107707",
"0.5458556",... | 0.6163446 | 1 |
product_ids from the os default and hostgroup. | def inherited_product_ids
products = []
products += operatingsystem.product_ids if operatingsystem
products += Content::HostgroupProduct.where(:hostgroup_id => hostgroup.path_ids).pluck(:product_id) if hostgroup_id
products.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ids products\n products.each do |k, sp|\n size= Size.find_by_name sp[:size]\n color = Color.find_by_name sp[:color]\n if !size.nil? && !color.nil?\n p= Product.where(\"reference = ? and size_id = ? and color_id = ?\", sp[:reference], size.id, color.id)[0]\n sp[:product_id] =... | [
"0.61072475",
"0.6084616",
"0.60518456",
"0.5812594",
"0.57197446",
"0.57166237",
"0.5677012",
"0.5660227",
"0.563267",
"0.5613932",
"0.5595846",
"0.55925477",
"0.55900997",
"0.5577285",
"0.5557805",
"0.555591",
"0.554748",
"0.55396104",
"0.55387276",
"0.5515468",
"0.54772526... | 0.7419128 | 0 |
convert a repository to a format that puppet create_resource with yumrepo can consume | def format_repo repo
{
'baseurl' => repo.full_path,
# yum repos have descr field but no name, if descr is empty use the repo name
'descr' => repo.description.blank? ? repo.name : repo.description,
'enabled' => repo.enabled ? '1' : '0',
'gpgcheck' => !!repo.gpg_key ? '1' : '0'
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_repository_template(name)\n %Q(\n @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\n @prefix rep: <http://www.openrdf.org/config/repository#>.\n @prefix sr: <http://www.openrdf.org/config/repository/sail#>.\n @prefix sail: <http://www.openrdf.org/config/sail#>.\n ... | [
"0.62212133",
"0.60758203",
"0.59144396",
"0.5874723",
"0.5872641",
"0.577458",
"0.5752192",
"0.5725992",
"0.57204676",
"0.56908524",
"0.56577855",
"0.56495017",
"0.563324",
"0.5542828",
"0.55235654",
"0.54997605",
"0.54997605",
"0.54989964",
"0.5482917",
"0.5474779",
"0.5467... | 0.73310894 | 0 |
see the sum of all up and down votes in our Answer database | def points
self.answer_votes.sum(:value).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_votes\n up_votes + down_votes\n end",
"def upvotes\n votes.sum(:upvote)\n end",
"def votes_count\n upvotes + downvotes\n end",
"def votes\n up_votes - down_votes\n end",
"def total_votes\n self.up - self.down\n end",
"def total_votes\n self.get_upvotes.size - self.get... | [
"0.80387414",
"0.7942898",
"0.7847634",
"0.7722391",
"0.76697755",
"0.7648796",
"0.7617088",
"0.75817317",
"0.75098",
"0.7483972",
"0.74685025",
"0.7431745",
"0.740563",
"0.73689187",
"0.72940624",
"0.72753847",
"0.72753847",
"0.72522324",
"0.72514665",
"0.72423214",
"0.72378... | 0.76181686 | 6 |
whoever created a post, should automatically be set to "voting" it up | def create_vote
user.answer_votes.create(value: 1, answer: self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_vote\n self.user.votes.create(value: 1, post: self)\n end",
"def create_vote\n self.user.votes.create(value: 1, post: self)\n end",
"def create_vote\n\t\tuser.votes.create(value: 1, post: self)\n\tend",
"def create_vote\n user.votes.create(value: 1, post: self)\n end",
"def cre... | [
"0.71825874",
"0.71825874",
"0.715724",
"0.71569854",
"0.7144041",
"0.70861995",
"0.7047792",
"0.69802547",
"0.6722854",
"0.65306336",
"0.65235966",
"0.6502019",
"0.64960873",
"0.6470705",
"0.64136326",
"0.63874906",
"0.63657665",
"0.63622963",
"0.63470256",
"0.63135093",
"0.... | 0.5990325 | 62 |
def current_user return unless session[:user_id] | def arrange
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n !session[:uid].nil?\n end",
"def current_user?\n return session[:user_id] != nil\n end",
"def current_user\n if session[:user] != nil\n # return the user id\n return session[:user]\n else\n return false\n end\nend",
"def current_user # Check the current user\n @c... | [
"0.9053675",
"0.8909354",
"0.8758037",
"0.862908",
"0.85814047",
"0.85674876",
"0.85674876",
"0.85239",
"0.85052484",
"0.8493934",
"0.84783936",
"0.84589034",
"0.8444358",
"0.84422547",
"0.8428561",
"0.8427593",
"0.8391325",
"0.83606094",
"0.8360404",
"0.8357033",
"0.8333456"... | 0.0 | -1 |
Reads current instance id from EC2 metadata. We are assuming instance id cannot change while current process is running and thus memoizing it. | def current_vm_id
@metadata_lock.synchronize do
return @current_vm_id if @current_vm_id
http_client = HTTPClient.new
http_client.connect_timeout = METADATA_TIMEOUT
# Using 169.254.169.254 is an EC2 convention for getting
# instance metadata
uri = "http://169.254.169.254/latest/meta-data/instance-id/"
response = http_client.get(uri)
unless response.status == 200
cloud_error("Instance metadata endpoint returned " \
"HTTP #{response.status}")
end
@current_vm_id = response.body
end
rescue HTTPClient::TimeoutError
cloud_error("Timed out reading instance metadata, " \
"please make sure CPI is running on EC2 instance")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_instance_id\n metadata_endpoint = 'http://169.254.169.254/latest/meta-data/'\n instance_id = Net::HTTP.get( URI.parse( metadata_endpoint + 'instance-id' ) )\n end",
"def instance_id\n return ec2_meta_data('instance-id')\n end",
"def current_vm_id\n # xxxx = coreCloud.cu... | [
"0.7583619",
"0.75733006",
"0.7213643",
"0.7139777",
"0.70686495",
"0.70601314",
"0.6842846",
"0.68295383",
"0.6734501",
"0.66981256",
"0.6679955",
"0.6452198",
"0.63420796",
"0.61435443",
"0.5894712",
"0.5879966",
"0.5863609",
"0.57861704",
"0.5744457",
"0.57294726",
"0.5706... | 0.77501756 | 1 |
Create an EC2 instance and wait until it's in running state | def create_vm(agent_id, stemcell_id, vm_type, network_spec, disk_locality = nil, environment = nil)
with_thread_name("create_vm(#{agent_id}, ...)") do
# do this early to fail fast
stemcell = StemcellFinder.find_by_id(@ec2_client, stemcell_id)
begin
instance, block_device_agent_info = @instance_manager.create(
agent_id,
stemcell.image_id,
vm_type,
network_spec,
(disk_locality || []),
environment,
options,
)
logger.info("Creating new instance '#{instance.id}'")
NetworkConfigurator.new(network_spec).configure(@ec2_client, instance)
registry_settings = initial_agent_settings(
agent_id,
network_spec,
environment,
stemcell.root_device_name,
block_device_agent_info
)
registry.update_settings(instance.id, registry_settings)
instance.id
rescue => e # is this rescuing too much?
logger.error(%Q[Failed to create instance: #{e.message}\n#{e.backtrace.join("\n")}])
instance.terminate(fast_path_delete?) if instance
raise e
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def launch\n puts \"==> Creating EC2 instance...\"\n\n @instance = @aws_ec2.instances.create( @config.env.merge( { \"key_name\" => key_name, \"security_groups\" => [security_group_name] } ) )\n @instance.tag(\"environment\", {value: @config.environment})\n\n while @instance.status == :pending\n... | [
"0.80714214",
"0.7141925",
"0.69733226",
"0.68613166",
"0.6840715",
"0.67878777",
"0.6746286",
"0.66830003",
"0.65129304",
"0.64713836",
"0.6448636",
"0.64054894",
"0.63889223",
"0.6353564",
"0.6341768",
"0.63023835",
"0.6283159",
"0.6266867",
"0.6251926",
"0.6223107",
"0.622... | 0.53971845 | 95 |
Delete EC2 instance ("terminate" in AWS language) and wait until it reports as terminated | def delete_vm(instance_id)
with_thread_name("delete_vm(#{instance_id})") do
logger.info("Deleting instance '#{instance_id}'")
@instance_manager.find(instance_id).terminate(fast_path_delete?)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(vpc_id, client, asg, elbv1, elbv2, region)\n begin\n response = client.describe_vpcs(vpc_ids: [vpc_id])\n rescue Aws::EC2::Errors::InvalidVpcIDNotFound => e\n puts \"Error: vpc_id [#{vpc_id}] does not exist... exiting.\"\n puts \"Make sure you passed the correct region on the command-line if i... | [
"0.7584375",
"0.73998404",
"0.7372983",
"0.7333556",
"0.71941835",
"0.7008991",
"0.6973817",
"0.6926044",
"0.6887981",
"0.68776006",
"0.6773368",
"0.6773368",
"0.67183524",
"0.6684249",
"0.66786456",
"0.66781765",
"0.65989",
"0.65977275",
"0.6567925",
"0.65571505",
"0.653775"... | 0.6502307 | 21 |
Creates a new EBS volume | def create_disk(size, cloud_properties, instance_id = nil)
raise ArgumentError, 'disk size needs to be an integer' unless size.kind_of?(Integer)
with_thread_name("create_disk(#{size}, #{instance_id})") do
volume_properties = VolumeProperties.new(
size: size,
type: cloud_properties['type'],
iops: cloud_properties['iops'],
az: @az_selector.select_availability_zone(instance_id),
encrypted: cloud_properties['encrypted'],
kms_key_arn: cloud_properties['kms_key_arn']
)
resp = @ec2_client.client.create_volume(volume_properties.persistent_disk_config)
volume = AWS::EC2::Volume.new_from(:create_volume, resp, resp.volume_id, config: @ec2_client.config)
logger.info("Creating volume '#{volume.id}'")
ResourceWait.for_volume(volume: volume, state: :available)
volume.id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n\t\tregion = resource[:availability_zone].to_s.gsub(/.$/,'') \n\t\tcompute = Fog::Compute.new(:provider => 'aws', :region => \"#{region}\")\n\t\tprint \"ebsvol[aws]->create: Region is #{region}\\n\" if $debug\n\t\tprint \"ebsvol[aws]->create: Availability_zone is #{resource[:availability_zone]}\\n\" if... | [
"0.8036493",
"0.7529088",
"0.75189686",
"0.7499501",
"0.7443673",
"0.7443673",
"0.74392515",
"0.7435074",
"0.7424645",
"0.7199022",
"0.7173891",
"0.71394473",
"0.7134112",
"0.700443",
"0.6923647",
"0.6822279",
"0.6817655",
"0.6755411",
"0.67133874",
"0.6647261",
"0.66386944",... | 0.6454264 | 23 |
Check whether an EBS volume exists or not | def has_disk?(disk_id)
with_thread_name("has_disk?(#{disk_id})") do
@logger.info("Check the presence of disk with id `#{disk_id}'...")
@ec2_client.volumes[disk_id].exists?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists?\n\t\t# Look for volume\n\t\t@vol_id = DSMAPIVolume.find_volume(@resource[:name], @resource[:storagecenter])\n\t\tif @vol_id == nil\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\tend",
"def exists?\n volumes = Hash.new\n qmgmt(['volume', 'list']).each_line { |l|\n if ( l.match... | [
"0.7644813",
"0.7362493",
"0.6975857",
"0.65798783",
"0.6441754",
"0.63350564",
"0.63269997",
"0.61548686",
"0.61523074",
"0.61519414",
"0.61339414",
"0.6129923",
"0.6063452",
"0.6062445",
"0.6060861",
"0.60347795",
"0.6015773",
"0.6012775",
"0.59822375",
"0.5974805",
"0.5953... | 0.55434453 | 81 |
Attach an EBS volume to an EC2 instance | def attach_disk(instance_id, disk_id)
with_thread_name("attach_disk(#{instance_id}, #{disk_id})") do
instance = @ec2_client.instances[instance_id]
volume = @ec2_client.volumes[disk_id]
device_name = attach_ebs_volume(instance, volume)
update_agent_settings(instance) do |settings|
settings["disks"] ||= {}
settings["disks"]["persistent"] ||= {}
settings["disks"]["persistent"][disk_id] = device_name
end
logger.info("Attached `#{disk_id}' to `#{instance_id}'")
end
# log registry settings for debugging
logger.debug("updated registry settings: #{registry.read_settings(instance_id)}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attachvol(compute,volume,instance,device)\n\t\tprint \"Running attachvol\\n\" if $debug\n\t\traise ArgumentError \"ebsvol[aws]->attachvol: Sorry, you must specify a valid device matching /dev/sd[a-m].\" if (device !~ /^\\/dev\\/sd[a-m]/)\n\t\tif (volume['status'] != \"in-use\" )\n\t\t\t# check instance is in t... | [
"0.7741415",
"0.77355874",
"0.7572211",
"0.75179416",
"0.7482979",
"0.7384399",
"0.7287279",
"0.7228706",
"0.7121573",
"0.7054218",
"0.6932078",
"0.69124585",
"0.6901333",
"0.67454475",
"0.6722063",
"0.6716593",
"0.6690154",
"0.6649605",
"0.6640001",
"0.6605321",
"0.63948745"... | 0.6268131 | 25 |
Detach an EBS volume from an EC2 instance | def detach_disk(instance_id, disk_id)
with_thread_name("detach_disk(#{instance_id}, #{disk_id})") do
instance = @ec2_client.instances[instance_id]
volume = @ec2_client.volumes[disk_id]
if volume.exists?
detach_ebs_volume(instance, volume)
else
@logger.info("Disk `#{disk_id}' not found while trying to detach it from vm `#{instance_id}'...")
end
update_agent_settings(instance) do |settings|
settings["disks"] ||= {}
settings["disks"]["persistent"] ||= {}
settings["disks"]["persistent"].delete(disk_id)
end
logger.info("Detached `#{disk_id}' from `#{instance_id}'")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detach()\n $ec2.describe_volumes([self.id]).each do |result|\n if result[:aws_attachment_status] == 'attached'\n $ec2.detach_volume(self.id)\n end\n end\n self.attached_instance = nil\n self.save()\n end",
"def terminate_volume\n device = get_device_mount_point(self.MountPo... | [
"0.80094284",
"0.7860202",
"0.7805397",
"0.75235146",
"0.74850506",
"0.7335772",
"0.7262752",
"0.72382694",
"0.715239",
"0.7067783",
"0.70534164",
"0.70353943",
"0.69209504",
"0.67825323",
"0.66788",
"0.66427445",
"0.64922065",
"0.6444169",
"0.64404655",
"0.6419261",
"0.63709... | 0.697606 | 12 |
Take snapshot of disk | def snapshot_disk(disk_id, metadata)
metadata = Hash[metadata.map { |key, value| [key.to_s, value] }]
with_thread_name("snapshot_disk(#{disk_id})") do
volume = @ec2_client.volumes[disk_id]
devices = []
volume.attachments.each { |attachment| devices << attachment.device }
name = ['deployment', 'job', 'index'].collect { |key| metadata[key] }
name << devices.first.split('/').last unless devices.empty?
snapshot = volume.create_snapshot(name.join('/'))
logger.info("snapshot '#{snapshot.id}' of volume '#{disk_id}' created")
['agent_id', 'instance_id', 'director_name', 'director_uuid'].each do |key|
TagManager.tag(snapshot, key, metadata[key])
end
TagManager.tag(snapshot, 'device', devices.first) unless devices.empty?
TagManager.tag(snapshot, 'Name', name.join('/'))
ResourceWait.for_snapshot(snapshot: snapshot, state: :completed)
snapshot.id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snapshot_disk(disk_id, metadata={})\n # TODO: Get vhd from 'vhd' container in vm storage account and use blob client to snapshot it\n end",
"def snapshot_disk(disk_id, metadata)\n metadata = Hash[metadata.map { |key, value| [key.to_s, value] }]\n\n with_thread_name(\"snapshot_disk(#{disk_id... | [
"0.713922",
"0.67944145",
"0.6793815",
"0.6761247",
"0.6709919",
"0.6596206",
"0.6394527",
"0.634374",
"0.62239885",
"0.6195495",
"0.61737245",
"0.6168773",
"0.614181",
"0.61157143",
"0.61157143",
"0.6018739",
"0.60147166",
"0.6005463",
"0.59679425",
"0.59664416",
"0.5944345"... | 0.68221915 | 1 |
Delete a disk snapshot | def delete_snapshot(snapshot_id)
with_thread_name("delete_snapshot(#{snapshot_id})") do
snapshot = @ec2_client.snapshots[snapshot_id]
if snapshot.status == :in_use
raise Bosh::Clouds::CloudError, "snapshot '#{snapshot.id}' can not be deleted as it is in use"
end
snapshot.delete
logger.info("snapshot '#{snapshot_id}' deleted")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snap_delete(volume,snapshot)\n output = @filer.invoke(\"snapshot-create\",\"volume\",volume,\"snapshot\",snapshot)\n if (output.results_status() == \"failed\")\n raise \"Error #{output.results_errno} creating snapshot #{snapshot} on #{volume}: #{output.results_reason()}\\n\"\n end\n end",
"def... | [
"0.80088663",
"0.79958016",
"0.77460605",
"0.7667114",
"0.75546783",
"0.75281346",
"0.7479069",
"0.74299383",
"0.7417895",
"0.73651665",
"0.73398304",
"0.7300385",
"0.72610056",
"0.7257571",
"0.72526306",
"0.7195017",
"0.7184923",
"0.7133952",
"0.695794",
"0.6955977",
"0.6933... | 0.71849513 | 16 |
Configure network for an EC2 instance. No longer supported. | def configure_networks(instance_id, network_spec)
raise Bosh::Clouds::NotSupported, "configure_networks is no longer supported"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_networks(instance_id, network_spec)\n raise Bosh::Clouds::NotSupported, 'configure_networks is no longer supported'\n end",
"def configure_private_network(config, ips, net_name)\n ips.each do |ip|\n config.vm.network 'private_network',\n ip: ip,\n ... | [
"0.7394466",
"0.7293648",
"0.7204996",
"0.7027411",
"0.70085776",
"0.7008117",
"0.68236405",
"0.6780012",
"0.67006415",
"0.66699696",
"0.66646504",
"0.6614899",
"0.6601932",
"0.6547433",
"0.6393244",
"0.6375365",
"0.63539976",
"0.616765",
"0.6159904",
"0.61547697",
"0.6110610... | 0.74011207 | 1 |
Creates a new EC2 AMI using stemcell image. This method can only be run on an EC2 instance, as image creation involves creating and mounting new EBS volume as local block device. | def create_stemcell(image_path, stemcell_properties)
with_thread_name("create_stemcell(#{image_path}...)") do
stemcell_properties.merge!(aws_properties['stemcell'] || {})
if stemcell_properties.has_key?('ami')
all_ami_ids = stemcell_properties['ami'].values
# select the correct image for the configured ec2 client
available_image = @ec2_client.images.filter('image-id', all_ami_ids).first
raise Bosh::Clouds::CloudError, "Stemcell does not contain an AMI at endpoint (#{@ec2_client.client.endpoint})" unless available_image
"#{available_image.id} light"
else
create_ami_for_stemcell(image_path, stemcell_properties)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_stemcell(image_path, stemcell_properties)\n with_thread_name(\"create_stemcell(#{image_path}...)\") do\n stemcell_properties.merge!(aws_properties['stemcell'] || {})\n\n if stemcell_properties.has_key?('ami')\n all_ami_ids = stemcell_properties['ami'].values\n\n # se... | [
"0.7089384",
"0.6847267",
"0.6640451",
"0.6573715",
"0.6484274",
"0.63905066",
"0.63649774",
"0.6353124",
"0.62630993",
"0.625121",
"0.62494844",
"0.62214583",
"0.6199846",
"0.6118713",
"0.6085152",
"0.6058307",
"0.6039063",
"0.6016051",
"0.5984712",
"0.5980602",
"0.59506595"... | 0.6965684 | 1 |
Delete a stemcell and the accompanying snapshots | def delete_stemcell(stemcell_id)
with_thread_name("delete_stemcell(#{stemcell_id})") do
stemcell = StemcellFinder.find_by_id(@ec2_client, stemcell_id)
stemcell.delete
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_stemcell(stemcell_id)\n with_thread_name(\"delete_stemcell(#{stemcell_id})\") do\n stemcell = StemcellFinder.find_by_id(@ec2_resource, stemcell_id)\n stemcell.delete\n end\n end",
"def delete_stemcell(stemcell_id)\n with_thread_name(\"delete_stemcell(#{stemcell_id})\") ... | [
"0.65500957",
"0.65500957",
"0.6464295",
"0.61432683",
"0.59583855",
"0.5821966",
"0.58048797",
"0.5801757",
"0.5801757",
"0.5780022",
"0.5767575",
"0.57407224",
"0.57278293",
"0.5714026",
"0.5684943",
"0.5684763",
"0.5663709",
"0.5648932",
"0.5641919",
"0.56105095",
"0.56038... | 0.6589975 | 0 |
Map a set of cloud agnostic VM properties (cpu, ram, ephemeral_disk_size) to a set of AWS specific cloud_properties | def calculate_vm_cloud_properties(vm_properties)
required_keys = ['cpu', 'ram', 'ephemeral_disk_size']
missing_keys = required_keys.reject { |key| vm_properties[key] }
unless missing_keys.empty?
missing_keys.map! { |k| "'#{k}'" }
raise "Missing VM cloud properties: #{missing_keys.join(', ')}"
end
instance_type = @instance_type_mapper.map(vm_properties)
{
'instance_type' => instance_type,
'ephemeral_disk' => {
'size' => vm_properties['ephemeral_disk_size'],
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_vm_cloud_properties(vm_properties)\n required_keys = ['cpu', 'ram', 'ephemeral_disk_size']\n missing_keys = required_keys.reject { |key| vm_properties[key] }\n unless missing_keys.empty?\n missing_keys.map! { |k| \"'#{k}'\" }\n raise \"Missing VM cloud properties: #{missi... | [
"0.8066609",
"0.7835972",
"0.6794016",
"0.624362",
"0.61670685",
"0.6039891",
"0.58982915",
"0.5856219",
"0.5856219",
"0.57928544",
"0.57892734",
"0.57689637",
"0.57237",
"0.5660547",
"0.5595816",
"0.5595334",
"0.5577137",
"0.55624706",
"0.5524775",
"0.5453265",
"0.5409062",
... | 0.80607426 | 2 |
Checks if options passed to CPI are valid and can actually be used to create all required data structures etc. | def validate_options
required_keys = {
"aws" => ["default_key_name", "max_retries"],
"registry" => ["endpoint", "user", "password"],
}
missing_keys = []
required_keys.each_pair do |key, values|
values.each do |value|
if (!options.has_key?(key) || !options[key].has_key?(value))
missing_keys << "#{key}:#{value}"
end
end
end
raise ArgumentError, "missing configuration parameters > #{missing_keys.join(', ')}" unless missing_keys.empty?
if !options['aws'].has_key?('region') && ! (options['aws'].has_key?('ec2_endpoint') && options['aws'].has_key?('elb_endpoint'))
raise ArgumentError, "missing configuration parameters > aws:region, or aws:ec2_endpoint and aws:elb_endpoint"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_options(options)\n raise 'Invalid output directory.' unless options.config.respond_to?(:output_dir)\n raise 'Invalid template.' unless options.config.respond_to?(:template)\n raise 'Invalid template directory.' unless options.config.respond_to?(:template_dir)\n raise 'Invalid autho... | [
"0.7486789",
"0.72412026",
"0.7234365",
"0.72204375",
"0.72187287",
"0.71798575",
"0.7179178",
"0.7087661",
"0.7074382",
"0.7071132",
"0.70461327",
"0.7026061",
"0.70239943",
"0.70226896",
"0.6992955",
"0.69809914",
"0.69570374",
"0.6945098",
"0.691861",
"0.69168293",
"0.6904... | 0.6584273 | 52 |
Checks AWS credentials settings to see if the CPI will be able to authenticate to AWS. | def validate_credentials_source
credentials_source = options['aws']['credentials_source'] || 'static'
if credentials_source != 'env_or_profile' && credentials_source != 'static'
raise ArgumentError, "Unknown credentials_source #{credentials_source}"
end
if credentials_source == 'static'
if options['aws']['access_key_id'].nil? || options['aws']['secret_access_key'].nil?
raise ArgumentError, "Must use access_key_id and secret_access_key with static credentials_source"
end
end
if credentials_source == 'env_or_profile'
if !options['aws']['access_key_id'].nil? || !options['aws']['secret_access_key'].nil?
raise ArgumentError, "Can't use access_key_id and secret_access_key with env_or_profile credentials_source"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_aws_keys()\n if (not (ENV['AWS_ACCESS_KEY'] and ENV['AWS_SECRET_KEY'])) then\n if not ENV['MORTAR_IGNORE_AWS_KEYS']\n return false\n else\n return true\n end\n else\n return true\n end\n end",
"def validate_aws_credential_file!\n Chef::Log.debug \"Using... | [
"0.7359459",
"0.70773035",
"0.65204555",
"0.6419615",
"0.6400618",
"0.6329888",
"0.6253651",
"0.61920524",
"0.6189333",
"0.6185766",
"0.6180546",
"0.6120668",
"0.6113438",
"0.6111507",
"0.6065728",
"0.5973568",
"0.59704953",
"0.59539354",
"0.5948529",
"0.5948529",
"0.59207237... | 0.58678293 | 25 |
Generates initial agent settings. These settings will be read by agent from AWS registry (also a BOSH component) on a target instance. Disk conventions for amazon are: system disk: /dev/sda ephemeral disk: /dev/sdb EBS volumes can be configured to map to other device names later (sdf through sdp, also some kernels will remap sd to xvd). | def initial_agent_settings(agent_id, network_spec, environment, root_device_name, block_device_agent_info)
settings = {
"vm" => {
"name" => "vm-#{SecureRandom.uuid}"
},
"agent_id" => agent_id,
"networks" => agent_network_spec(network_spec),
"disks" => {
"system" => root_device_name,
"persistent" => {}
}
}
settings["disks"].merge!(block_device_agent_info)
settings["disks"]["ephemeral"] = settings["disks"]["ephemeral"][0]["path"]
settings["env"] = environment if environment
settings.merge(agent_properties)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initial_agent_settings(vm_id, agent_id, network_spec, ephemeral_disk,\n existing_disk, environment, blobstore, mbus)\n disk_letters = ('a'..'z').to_a\n config = { vm: { name: vm_id }, agent_id: agent_id,\n environment: environment, blobstore: blobstore,\n ... | [
"0.74981487",
"0.72785604",
"0.6989644",
"0.6177954",
"0.6065063",
"0.59736824",
"0.5722319",
"0.5713777",
"0.56887895",
"0.560247",
"0.5570425",
"0.5552157",
"0.5528126",
"0.5523799",
"0.5490877",
"0.5490583",
"0.54324764",
"0.54210335",
"0.5394933",
"0.5392132",
"0.5388329"... | 0.75688684 | 1 |
GET /bairros/1 GET /bairros/1.xml | def show
@bairro = Bairro.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @bairro }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @boms = Bom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @boms }\n end\n end",
"def show\n @bairro_micro = BairroMicro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render ... | [
"0.65553904",
"0.64765036",
"0.6409114",
"0.63126993",
"0.6283116",
"0.6245994",
"0.62356037",
"0.62331575",
"0.62306",
"0.6182746",
"0.61414367",
"0.6128606",
"0.6123555",
"0.6078274",
"0.60770947",
"0.60497135",
"0.60411954",
"0.5990938",
"0.5985811",
"0.59728354",
"0.59431... | 0.6797028 | 0 |
GET /bairros/new GET /bairros/new.xml | def new
@bairro = Bairro.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bairro }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @barrio = Barrio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @barrio }\n end\n end",
"def new\n @nostro = Nostro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nostro }\n e... | [
"0.70185375",
"0.70065886",
"0.69854504",
"0.69701964",
"0.69656986",
"0.6926386",
"0.6883337",
"0.68671656",
"0.6852459",
"0.68497086",
"0.6839413",
"0.6831075",
"0.6807439",
"0.6787974",
"0.67793375",
"0.67761993",
"0.67753637",
"0.6768397",
"0.67658836",
"0.67598534",
"0.6... | 0.73753154 | 0 |
POST /bairros POST /bairros.xml | def create
@bairro = Bairro.new(params[:bairro])
respond_to do |format|
if @bairro.save
flash[:notice] = "Bairro criado com sucesso."
format.html { redirect_to(admin_bairros_path) }
format.xml { render :xml => @bairro, :status => :created, :location => @bairro }
else
format.html { render :action => "new" }
format.xml { render :xml => @bairro.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(xmldoc)\n headers = {'Content-Type' => 'text/xml'}\n check_response( @httpcli.post(@endpoint, xmldoc, headers) )\n end",
"def post(body)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true if uri.scheme == 'https'\n\n request = Net::HTTP::Post.new(uri)\n r... | [
"0.6109481",
"0.5931159",
"0.5924494",
"0.5912243",
"0.5894569",
"0.57990813",
"0.5770801",
"0.5735245",
"0.5691109",
"0.56860334",
"0.56578946",
"0.5609075",
"0.55740684",
"0.5571139",
"0.5555524",
"0.549797",
"0.5491862",
"0.5471097",
"0.5470009",
"0.54614395",
"0.54555416"... | 0.6218456 | 0 |
PUT /bairros/1 PUT /bairros/1.xml | def update
@bairro = Bairro.find(params[:id])
respond_to do |format|
if @bairro.update_attributes(params[:bairro])
flash[:notice] = "Bairro atualizado com sucesso."
format.html { redirect_to(admin_bairros_path) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @bairro.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def res... | [
"0.6471276",
"0.6349391",
"0.61486113",
"0.6087704",
"0.6031485",
"0.5948117",
"0.5842212",
"0.5778172",
"0.5773976",
"0.56518084",
"0.5553332",
"0.55451053",
"0.55291426",
"0.55029553",
"0.54884577",
"0.54634005",
"0.54506475",
"0.54460955",
"0.54380375",
"0.5436617",
"0.543... | 0.61298263 | 3 |
DELETE /bairros/1 DELETE /bairros/1.xml | def destroy
@bairro = Bairro.find(params[:id])
@bairro.destroy
respond_to do |format|
format.html { redirect_to(admin_bairros_path) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end",
"def destroy\n @browsenodeid = Browsenodeid.find(pa... | [
"0.6918107",
"0.6720777",
"0.66734356",
"0.6633984",
"0.6571922",
"0.65668035",
"0.6537507",
"0.6418858",
"0.64137757",
"0.63924545",
"0.63758075",
"0.63695467",
"0.6343922",
"0.6339396",
"0.6337218",
"0.63289523",
"0.6299543",
"0.62928206",
"0.62815976",
"0.6270704",
"0.6266... | 0.6927857 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.