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 |
|---|---|---|---|---|---|---|
Overrides local method from the ones in module | def print_id
puts "Id"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overrides; end",
"def extended(*) end",
"def special\n override\n end",
"def custom; end",
"def custom; end",
"def internal; end",
"def original_method; end",
"def internal_methods; end",
"def source(override); end",
"def implementation; end",
"def implementation; end",
"def methods()... | [
"0.7090869",
"0.7059276",
"0.6968681",
"0.6967124",
"0.6967124",
"0.6924156",
"0.66856176",
"0.6528463",
"0.6528079",
"0.64420974",
"0.64420974",
"0.6437933",
"0.64330304",
"0.63925123",
"0.63925123",
"0.63925123",
"0.63925123",
"0.6380315",
"0.63799816",
"0.6377472",
"0.6241... | 0.0 | -1 |
Encoding Encodes the node into a hash. | def to_hash(*a)
hash = {}
hash['id'] = id
hash['label'] = label unless label.nil?
hash['x'] = x unless x.nil?
hash['y'] = y unless y.nil?
hash['width'] = width unless width.nil?
hash['height'] = height unless height.nil?
hash['label_x'] = label_x unless label_x.nil?
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_encode(i)\n @hasher.encode i\n end",
"def hex; @node_id.hexlify; end",
"def hash\n node_id.hash\n end",
"def hash # Hack for Ruby 1.8.6\n @node.id.hash ^ self.class.hash\n end",
"def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # ... | [
"0.6484534",
"0.6447756",
"0.6426405",
"0.61961347",
"0.6160188",
"0.6090646",
"0.60711783",
"0.6063737",
"0.60512066",
"0.60324234",
"0.5993535",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.59742177",
"0.5871934",
"0.58716244",
"0.5... | 0.0 | -1 |
Layout Applies layout information to the source object. | def apply_layout(options={})
if object.is_a?(Hash)
object["x"] = x
object["y"] = y
object["width"] = width
object["height"] = height
object["points"] = points
object["label_x"] = label_x
object["label_y"] = label_y
end
nodes.each do |node|
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _layout(*_arg0); end",
"def layout()\n layout_children()\n end",
"def layout(layout)\n self._layout = layout\n end",
"def render_layout(output, layout, info); end",
"def do_layout(payload, layouts)\n end",
"def layout=(_arg0); end",
"def layout\n\n raise \"Missing bulletin... | [
"0.6186296",
"0.6185601",
"0.6100133",
"0.5952073",
"0.57825565",
"0.5782418",
"0.57714653",
"0.5703565",
"0.5666437",
"0.56112254",
"0.55494964",
"0.54733807",
"0.546586",
"0.5426156",
"0.5421659",
"0.535804",
"0.533002",
"0.53151804",
"0.53135353",
"0.5311427",
"0.5254293",... | 0.614691 | 2 |
Fill billing address on payment tab | def fill_billing_address(billing_address)
add_credit_card_form.bl_street_addr_input.set billing_address[:street]
add_credit_card_form.bl_city_input.set billing_address[:city]
# display state option
if page.has_css?('.stateSelect', wait: TimeOut::WAIT_SMALL_CONST)
page.execute_script("$('#stateSel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_in_buyer_stripe_form(obj = billing_address_example_data)\n fill_in('account[billing_address][name]', with: obj[:first_name])\n fill_in('account[billing_address][address1]', with: obj[:street_address])\n fill_in('account[billing_address][address2]', with: obj[:extra_address])\n fill_in('account[billing... | [
"0.7463737",
"0.73818403",
"0.7241998",
"0.723517",
"0.7148776",
"0.71184134",
"0.7043155",
"0.6992645",
"0.68744665",
"0.6874304",
"0.6826245",
"0.6780723",
"0.6763353",
"0.6748353",
"0.6735298",
"0.6735298",
"0.6727876",
"0.6727876",
"0.6727876",
"0.67195237",
"0.6714171",
... | 0.80183905 | 0 |
Add credit card on payment tab Return review tab | def add_credit_card(credit_card, billing_address = nil)
add_credit_card_form.card_number_input.set credit_card[:card_number]
add_credit_card_form.name_on_card_input.set credit_card[:card_name]
# display expiration month option
page.execute_script("$('#vin_PaymentMethod_creditCard_expirationDate_Month')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_credit_card(name = 'LTRC DN', cardnumber = '5111005111051128', exp_month = '01', exp_year = '2017', cvv = '123', country = 'US')\n wait_for_ajax\n # open add new credit card popup\n billing_section.add_new_credit_card_lnk.click\n\n wait_for_ajax\n # fill information\n add_new_credit_c... | [
"0.6897703",
"0.68912905",
"0.68727607",
"0.67950857",
"0.67049307",
"0.66833454",
"0.656524",
"0.6540334",
"0.6536022",
"0.65015244",
"0.6495551",
"0.64735353",
"0.64356935",
"0.64125687",
"0.6409902",
"0.6390594",
"0.6376964",
"0.6376964",
"0.63540894",
"0.6342632",
"0.6334... | 0.7846991 | 0 |
Order jobs by: their stage number their allow_failure status their original order | def apply
jobs.sort_by.with_index { |job, ix| order(job, ix) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_checks_on_new_jobs\n @total_jobs_hash = @total_jobs.index_by(&:id)\n @checks.sort_by! do |check|\n if check.job.split_parent_job_id.present? || check.job.parent_job_id.present?\n split_image_values = check.job.initial_image_name.split('.').first.split('_').from(1)\n @compare_job ... | [
"0.62496305",
"0.61569655",
"0.6081873",
"0.5985731",
"0.5839663",
"0.56682956",
"0.5542638",
"0.54588515",
"0.54560703",
"0.54460883",
"0.5430229",
"0.54204166",
"0.5398697",
"0.5327998",
"0.52838296",
"0.5238117",
"0.52352196",
"0.52217776",
"0.5207978",
"0.52036643",
"0.52... | 0.67354697 | 0 |
Showcases a specific project. | def spotlight
@project = Project.find_by_guid(params[:guid])
@main_heading = spanitize(@project.name)+" <span class=\"punctuation\">#{@project.completed_on.strftime("%Y")}</span>"
@assets = @project.assets
@assets.shift
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @project = Project.find params[:id]\n @page_title = \"Project #{@project.name}\"\n end",
"def pick_demo_project(dir)\n projs = projects_in_dir(dir)\n if projs.count == 0\n raise Informative, 'Unable to find any project in the source files' \\\n \" of the Pod: `... | [
"0.63962287",
"0.6232627",
"0.62316436",
"0.621612",
"0.62108773",
"0.61737895",
"0.61737895",
"0.61718553",
"0.6095874",
"0.6070048",
"0.6066141",
"0.60609514",
"0.6023641",
"0.60217977",
"0.60068315",
"0.6003659",
"0.5989172",
"0.5989172",
"0.59808344",
"0.59803337",
"0.597... | 0.0 | -1 |
Displays about me page. | def about
@main_heading='<span>Hello</span> <span>my</span> <span>name</span> <span>is</span> <span>Jim</span><span class="punctuation">.</span>'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about\r\n end",
"def about; render; end",
"def about\n end",
"def about\n\t\t@user = current_user\n\tend",
"def about\n\n end",
"def about\n\tend",
"def about\n\tend",
"def about\n \n end",
"def about_me\n\tend",
"def about\n\n \tend",
"def about\n end",
"def about\n end",
... | [
"0.7451907",
"0.73669726",
"0.7351496",
"0.73436224",
"0.73277146",
"0.72607416",
"0.72607416",
"0.7220392",
"0.72112465",
"0.718813",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.715296",
"0.7152... | 0.0 | -1 |
Wraps content words in individual spans. | def spanitize(content)
content.split(" ").map { |s| "<span>#{s}</span>" }.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_in_spans(**options)\n safe_join(options.fetch(:value, []).map { |v| content_tag(:span, html_escape(v)) })\n end",
"def wrap( content )\n content\n end",
"def span_wrap tag, text\n \"<span class='#{tag}' markdown='1'>#{text}</span>\"\nend",
"def wrap\n @text\n end",
"def words\n ... | [
"0.6453105",
"0.6385358",
"0.62999296",
"0.62721914",
"0.6076125",
"0.60640967",
"0.58964074",
"0.58885306",
"0.5692121",
"0.56615716",
"0.56406766",
"0.5631153",
"0.5605348",
"0.5601667",
"0.5601264",
"0.5580383",
"0.55583394",
"0.55454296",
"0.5544432",
"0.55317855",
"0.553... | 0.65256125 | 0 |
READ CSV DATA Method to get the data from a csv in hash map | def get_csv_data(csv_data)
csv_file = nil
#Get the path and name of the CSV file
if csv_data.to_s.include? '.csv'
csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}")
elsif (
csv_file = File.join(File.dirname(__FILE__), "../venture/config/csv_data/#{csv_data}.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_csv(file)\n data = CSV.read(file, {encoding: \"UTF-8\", headers: true, header_converters: :symbol, converters: :all})\n hashed_data = data.map { |d| d.to_hash } \n \n puts \"CSV Loaded...\"\n\n return hashed_data\n end",
"def get_csv_data(infile)\n csv_data = CSV.read infile\n header... | [
"0.7417968",
"0.72490907",
"0.72490907",
"0.7213275",
"0.71767604",
"0.7123355",
"0.70743215",
"0.7051665",
"0.697614",
"0.6874475",
"0.681373",
"0.67446506",
"0.67120284",
"0.67027617",
"0.6691012",
"0.6689355",
"0.66708124",
"0.6616215",
"0.6603404",
"0.653157",
"0.65192586... | 0.7975117 | 0 |
FILTER CSV DATA (HASH MAP FILTER) Allows you to filter a hash map from csv data | def get_data_by_filters(filters, csv)
filters_a = filters.to_s.split(',')
csv_tmp = Array.new
csv_tmp = csv
for i in 0..(filters_a.size - 1)
filter = filters_a[i].to_s.downcase.strip
filter_data = get_filter_data filter
#The array is cleaned
data_filtered = Array.new
csv_tm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefilter_csv_data(raw_csv_data)\n # De-dup emails absolutely\n csv_data = raw_csv_data.uniq{|row| row[:email]}\n\n # Remove data with duplicate names scoped in company and address (parameterized)\n #csv_data.uniq{|row| \"#{row[:first_name]} #{row[:last_name]} #{row[:company]} #{row[:addres... | [
"0.6322489",
"0.6280653",
"0.6217684",
"0.60133225",
"0.59794575",
"0.58892584",
"0.5803522",
"0.5799369",
"0.57303035",
"0.56759834",
"0.56759834",
"0.56759834",
"0.5597768",
"0.5558027",
"0.55175036",
"0.5508664",
"0.5507356",
"0.5499295",
"0.5477099",
"0.5471953",
"0.54608... | 0.6452923 | 0 |
== Instance Methods ===================================================== | def perform(operation_id)
operation = BackOps::Operation.find(operation_id)
process(operation)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def initialize\n\t\t\n\tend",
"def initialize\n \n end",
"def initialize\n\n end",
"def initialize\n\n end",
"def initialize\r\n\r\n end",
"def implementation; end",
"def implementation; end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n ... | [
"0.84469724",
"0.7322652",
"0.73202515",
"0.7296683",
"0.7296683",
"0.72934824",
"0.7273197",
"0.7273197",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.7219093",
"0.71615446",
"0.71429765",
"0.71429765... | 0.0 | -1 |
tracking table remaining hours | def remaining(g, a)
goal = g.to_f
actual = a.to_f
if goal == 0 && actual == 0
""
else
r = goal - actual
if goal > actual
"<div class=\"act sum\"><div class=\"num\">#{r}</div></div>".html_safe
elsif goal <= actual
"<div class... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remaining_hours\n \n end",
"def remaining_hours_by_day\n values_by_day(0, true) { |x| model.remaining_hours_for_day_number(x) }\n end",
"def hours\n \n end",
"def spent_hours\n @spent_hours ||= time_entries.sum(:hours) || 0\n end",
"def hours\n _nudge[0]\n end",
"def total_timeshe... | [
"0.7676171",
"0.7173557",
"0.6600199",
"0.65166014",
"0.6462451",
"0.64035916",
"0.6358075",
"0.6335529",
"0.6332385",
"0.63228506",
"0.6300982",
"0.62360656",
"0.62245053",
"0.6215398",
"0.62150073",
"0.62085503",
"0.6174296",
"0.6172661",
"0.6171145",
"0.61647373",
"0.61322... | 0.0 | -1 |
tracking table remaining currency | def remaining_currency(g, a)
goal = g.to_f
actual = a.to_f
if goal == 0 && actual == 0
""
else
r = goal - actual
number_to_currency(r, :precision => 0)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def currency; end",
"def currency; end",
"def dollar_total\n total / 100.0\n end",
"def charge\n subtotal * 0\n end",
"def remaining_total\n total\n end",
"def memo(_row)\n 'EUR'\n end",
"def amount; end",
"def currency\n nil\n end",
"def currency\n ... | [
"0.68829226",
"0.68829226",
"0.6693771",
"0.6661102",
"0.6640936",
"0.66256446",
"0.6599034",
"0.6470488",
"0.6470488",
"0.6465763",
"0.64164734",
"0.6405326",
"0.6361261",
"0.63534707",
"0.63534707",
"0.6337433",
"0.63216555",
"0.631954",
"0.62777054",
"0.62714416",
"0.62243... | 0.627164 | 19 |
Override ResourceController collection method | def collection
feature_id = nil
if params[:feature_id]
feature_id = params[:feature_id]
elsif params[:id]
feature_id = object.feature_id
end
if params[:filter].blank? && !feature_id.blank?
search_results = parent_object.definitions
elsif !params[:filter].blank?
search_res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decorated_collection\n @collection.map do |element|\n Resource.new(element, @controller)\n end\n end",
"def collection\n resource_class.all\n end",
"def make_collection\n @resource.make_collection\n end",
"def resource_collection\n @resource_collection ||= @run_co... | [
"0.75454414",
"0.75432986",
"0.7115129",
"0.68111414",
"0.6715225",
"0.6696003",
"0.66899097",
"0.6684242",
"0.66061133",
"0.66061133",
"0.6576192",
"0.6530712",
"0.65107936",
"0.65043175",
"0.6489149",
"0.6489149",
"0.64478284",
"0.643337",
"0.64229524",
"0.64229524",
"0.640... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def definition_params
params.require(:definition).permit(:feature_id, :is_public, :is_primary, :ancestor_ids, :position, :content, :author_id, :language_id, :numerology, :tense)
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.71230334",
"0.70530915",
"0.69479465",
"0.6902122",
"0.67367256",
"0.67172784",
"0.6689043",
"0.66784793",
"0.6660117",
"0.6555213",
"0.6528485",
"0.6458438",
"0.6452378",
"0.6451654",
"0.64478326",
"0.6433326",
"0.6413599",
"0.6413599",
"0.63907677",
"0.63787645",
"0.6378... | 0.0 | -1 |
for each hypothetical day. It should return a pair of days representing the best day to buy and the best day to sell. Days start at 0. You need to buy before you can sell Pay attention to edge cases like when the lowest day is the last day or the highest day is the first day. | def stock_picker(prices)
acc_profit = 0
acc_buy_date = 0
acc_sell_date = 0
profits = prices.map.with_index do |price, index|
remaining_days = prices[index..-1] # to create an array that becomes smaller each iteration from index 0
maximum = remaining_days.max # to identify the maximum nu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_best_day(optimized, days)\n\tbuy_day = 0\n\tsell_day = 0\n\tprofit = 0\n\tdays.each do |day|\n\t\tdaily_profit = days[optimized[days.index day]] - day\n\t\tif daily_profit > profit\n\t\t\tprofit = daily_profit\n\t\t\tbuy_day = days.index day\n\t\t\tsell_day = optimized[days.index day]\n\t\tend\n\tend\n\t[... | [
"0.77537197",
"0.7420683",
"0.74012536",
"0.7281791",
"0.72262144",
"0.7198446",
"0.71598256",
"0.6956908",
"0.69431067",
"0.6935232",
"0.69343877",
"0.6900047",
"0.68958485",
"0.6879493",
"0.68667895",
"0.68548983",
"0.6835317",
"0.6833143",
"0.68035907",
"0.6799005",
"0.678... | 0.63693416 | 50 |
GET /candidates GET /candidates.json | def index
@candidates = Candidate.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end",
"def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end",
"def index\n if Candidate.count == 0\n... | [
"0.7828381",
"0.73522097",
"0.72219783",
"0.6928002",
"0.6899774",
"0.6775134",
"0.67688996",
"0.6342606",
"0.6194655",
"0.6079805",
"0.6058217",
"0.60146403",
"0.596775",
"0.5949632",
"0.5942194",
"0.59386665",
"0.5871397",
"0.58210623",
"0.5799082",
"0.57743657",
"0.5762294... | 0.73016286 | 6 |
GET /candidates/1 GET /candidates/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @candidates = Candidate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @candidates }\n end\n end",
"def index\n @candidates = Candidate.all.order(:id)\n #render json: @candidates\n end",
"def show\n @candidate = Candidate.fin... | [
"0.7576062",
"0.719828",
"0.71253955",
"0.71249306",
"0.7115344",
"0.7115344",
"0.7115344",
"0.7115344",
"0.7115344",
"0.674099",
"0.66213965",
"0.6574931",
"0.64875436",
"0.64646935",
"0.61951876",
"0.60203767",
"0.60195625",
"0.601726",
"0.597598",
"0.5966151",
"0.5957981",... | 0.0 | -1 |
POST /candidates POST /candidates.json | def create
@candidate = Candidate.new(candidate_params)
if @candidate.resume.resume_data.nil?
@candidate.resume = nil
else
@candidate.resume.file_name, @candidate.resume.content_type, @candidate.resume.resume_data = extract_file(@candidate.resume.resume_data)
end
if current_user.role =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @candidate = current_user.candidates.new(candidate_params)\n respond_to do |format|\n if @candidate.save\n format.html { redirect_to @candidate, notice: 'Candidate was successfully created.' }\n format.json { render :show, status: :created, location: @candidate }\n else\n... | [
"0.73996586",
"0.69050306",
"0.6875307",
"0.6840989",
"0.6840989",
"0.6840989",
"0.6840989",
"0.68375486",
"0.68206316",
"0.6752525",
"0.67350394",
"0.6661347",
"0.6624552",
"0.65386087",
"0.64996314",
"0.64925003",
"0.6466578",
"0.6317362",
"0.63112783",
"0.6292041",
"0.6274... | 0.0 | -1 |
PATCH/PUT /candidates/1 PATCH/PUT /candidates/1.json | def update
if @candidate.update(candidate_params)
redirect_to (current_user.role == 'candidate' ? root_path : @candidate), notice: 'Candidate was successfully updated.'
else
render :edit
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @candidate = Candidate.find(params[:id])\n\n respond_to do |format|\n if @candidate.update_attributes(params[:candidate])\n format.html { redirect_to @candidate, notice: 'Candidate was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | [
"0.6997068",
"0.6843286",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.6768482",
"0.67535204",
"0.6686334",
"0.65477365",
"0.6542974",
"0.6518262",
"0.6458349",
"0.64341927",
"0.6364452",
"0.63492894",
"0.624964",
"0.61845785",
"0.6174728",... | 0.5920511 | 26 |
DELETE /candidates/1 DELETE /candidates/1.json | def destroy
@candidate.destroy
redirect_to candidates_url, notice: 'Candidate was successfully destroyed.'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n respond_to do |format|\n format.html { redirect_to candidates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candidate = Candidate.find(params[:id])\n @candidate.destroy\n\n res... | [
"0.7436304",
"0.7436304",
"0.7173674",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.717342",
"0.71688795",
"0.71688795",
"0.71688795",
"0.7097595",
"0.7083692",
"0.68879616",
"0.67611915",
"0.67196244",
"0.6716783",
"0.6674849",
"0.6648467",
"0... | 0.6708224 | 19 |
Use callbacks to share common setup or constraints between actions. | def set_candidate
@candidate = Candidate.includes(:user, :resume).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 candidate_params
params.require(:candidate).permit(:user_id, :first_name, :last_name, :email, :phone, :desired_position, :current_company, :linked_in_url, :twitter_url, :git_hub_url, :portfolio_url, :website_url,
resume_attributes:[:resume_data])
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.6981273",
"0.6783789",
"0.67460483",
"0.6742222",
"0.67354137",
"0.65934366",
"0.65028495",
"0.6497783",
"0.64826745",
"0.6479415",
"0.6456823",
"0.6440081",
"0.63800216",
"0.6376521",
"0.636652",
"0.6319898",
"0.6300256",
"0.62994003",
"0.6293621",
"0.6292629",
"0.6291586... | 0.0 | -1 |
before_action :authenticate_applicant!, only: [:index, :show] | def index
@application = Application.new
@vacancies = Vacancy.all.order("deadline ASC")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n # authorize Admin\n end",
"def show\n authorize @career\n end",
"def show\n authorize @activist_front\n end",
"def show\n authorize @staff_request\n end",
"def show\n authorize!\n end",
"def show\n authorize!\n end",
"def show\n authorize!\n end",
"def show\n a... | [
"0.7231183",
"0.70272654",
"0.70261455",
"0.6985931",
"0.6967366",
"0.6967366",
"0.6967366",
"0.69617504",
"0.69617504",
"0.6900996",
"0.6887286",
"0.6850788",
"0.6836222",
"0.6830097",
"0.6805661",
"0.6805661",
"0.679926",
"0.67859143",
"0.67700255",
"0.6749594",
"0.6744",
... | 0.0 | -1 |
Default behavior for calculating the next_run date, which will be generally overriden by the subclass (except for the case of a run once job). When a job completes, the task scheduler will invoke this method to persist a new instance of the job to run based on the value returned by this method. A return value of nil in... | def calc_next_run
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_next_run\n RunAtPeriodicJob.new(:name => self.name, :job => self.job, :run_at_minutes => self.run_at_minutes)\n end",
"def set_next_run\n self.next_run_at = calc_next_run_at_date\n end",
"def calc_next_run\n self.next_run_at = nil\n end",
"def last_run_at\n super || self.schedule.try(... | [
"0.72519344",
"0.7017858",
"0.6573886",
"0.64207494",
"0.64111346",
"0.63758737",
"0.6369535",
"0.6367696",
"0.6367696",
"0.60448647",
"0.60129595",
"0.59517425",
"0.59456",
"0.59294236",
"0.5834945",
"0.57872",
"0.56720597",
"0.56209594",
"0.55748844",
"0.55748844",
"0.55748... | 0.6091187 | 10 |
When a new record is created, calculate the time when it should first run | def set_initial_next_run
self.next_run_at = Time.zone.now if self.next_run_at.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_time(); @create_time; end",
"def instance_create_time\n data[:instance_create_time]\n end",
"def enter_created; end",
"def create\n self[:created] = Time.now.to_s\n save\n end",
"def time_since_creation\n ((Time.now - created_at) / 3600).round\n end",
"def before_create\n ... | [
"0.7812308",
"0.7321703",
"0.6958651",
"0.6904216",
"0.67879105",
"0.6738086",
"0.6736327",
"0.6733391",
"0.6731828",
"0.67078125",
"0.66799533",
"0.66673815",
"0.65622777",
"0.65558004",
"0.6481178",
"0.6462483",
"0.6459509",
"0.64408976",
"0.64320576",
"0.64148587",
"0.6396... | 0.0 | -1 |
Runs a job and updates the +last_run_at+ field. | def run!
PeriodicJob.log_error "Executing job id #{self.id}, #{self.to_s}..."
begin
self.last_run_at = Time.now
self.next_run_at = nil
self.save
command = self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, Rails.root.to_s)
puts command
eval(command)
self.last_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run!\n TaskServerLogger.instance.error \"Executing job id #{self.id}, #{self.to_s}...\"\n begin\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.save\n eval(self.job.gsub(/#JOBID#/, self.id.to_s).gsub(/#RAILS_ROOT#/, RAILS_ROOT))\n self.last_run_result = \"OK\"\... | [
"0.7211853",
"0.63806945",
"0.62906766",
"0.60734063",
"0.6009462",
"0.59831697",
"0.5980262",
"0.59266365",
"0.58394057",
"0.5718038",
"0.55837923",
"0.55430067",
"0.5506809",
"0.54610294",
"0.5419358",
"0.5409527",
"0.5385332",
"0.5309621",
"0.5297598",
"0.5290517",
"0.5290... | 0.68404543 | 1 |
Mark the current job as Timed out, and rerun it...used to process zombie jobs | def fail_job
self.last_run_at = Time.now
self.next_run_at = nil
self.last_run_result = "Timeout"
self.save
# ...and persist the next run of this job if one exists
set_next_job
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requeue_timed_out_jobs\n # older than x\n jobs.where{started_working_at <= (Time.now - EQ.config.job_timeout)}\\\n .update(started_working_at: nil)\n end",
"def fail_job\n self.last_run_at = Time.zone.now\n self.next_run_at = nil\n self.last_run_result = \"Timeout\"\n self.s... | [
"0.73669684",
"0.66212237",
"0.6544433",
"0.6540633",
"0.6449734",
"0.63333625",
"0.6280775",
"0.6166026",
"0.60948735",
"0.607705",
"0.60596967",
"0.6026616",
"0.5998994",
"0.5998957",
"0.59879327",
"0.59879327",
"0.59696597",
"0.5961413",
"0.59424746",
"0.5910612",
"0.58976... | 0.6585353 | 2 |
GET /world_instances/1 GET /world_instances/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @instances = Instance.all\n render json: @instances\n end",
"def index\n @instances = Instance.all\n render :json => @instances\n end",
"def destroy\n @world_instance.destroy\n respond_to do |format|\n format.html { redirect_to world_instances_url, notice: 'World instance w... | [
"0.6351823",
"0.63199824",
"0.62205565",
"0.62056786",
"0.6202137",
"0.6101092",
"0.60921156",
"0.6024565",
"0.5999781",
"0.5966",
"0.59372294",
"0.5923806",
"0.5918633",
"0.5906558",
"0.58607775",
"0.5837128",
"0.57803255",
"0.57553566",
"0.57553566",
"0.57405645",
"0.569619... | 0.0 | -1 |
POST /world_instances POST /world_instances.json | def create
world_name = params["name"]
superclass_uri = params["type-parent"]
container_uri = params["location-parent"]
description = params["description"]
if params.has_key?(:options)
options = {protected: false, locked: false}
options[:protected] = true if (params["options"].include?("... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @world_region = WorldRegion.new(world_region_params)\n\n respond_to do |format|\n if @world_region.save\n format.html { redirect_to @world_region, notice: 'World region was successfully created.' }\n format.json { render :show, status: :created, location: @world_region }\n ... | [
"0.62200654",
"0.606405",
"0.5965815",
"0.58907104",
"0.58460814",
"0.5845035",
"0.5787671",
"0.57634324",
"0.57342815",
"0.57021827",
"0.56860375",
"0.566433",
"0.56354827",
"0.5526175",
"0.5477664",
"0.5467237",
"0.5433888",
"0.5413798",
"0.5384082",
"0.53668237",
"0.533280... | 0.6729135 | 0 |
PATCH/PUT /world_instances/1 PATCH/PUT /world_instances/1.json | def update
respond_to do |format|
if @world_instance.update(world_instance_params)
format.html { redirect_to @world_instance, notice: 'World instance was successfully updated.' }
format.json { render :show, status: :ok, location: @world_instance }
else
format.html { render :edit ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update!(**args)\n @instances = args[:instances] if args.key?(:instances)\n @parameters = args[:parameters] if args.key?(:parameters)\n end",
"def update\n respond_to do |format|\... | [
"0.61995953",
"0.6135081",
"0.6067482",
"0.60623163",
"0.60295266",
"0.6027825",
"0.5984719",
"0.5972078",
"0.5853953",
"0.579697",
"0.5763218",
"0.5728873",
"0.5702792",
"0.56962323",
"0.568443",
"0.5683357",
"0.5679044",
"0.56556773",
"0.5655598",
"0.56532097",
"0.56518537"... | 0.72476095 | 0 |
DELETE /world_instances/1 DELETE /world_instances/1.json | def destroy
@world_instance.destroy
respond_to do |format|
format.html { redirect_to world_instances_url, notice: 'World instance was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @resource.destroy\n @myWorld = World.where(:title => @user[:email])\n worldID = @myWorld[0].id\n invoke(\"Resource destroyed: \" + @resource.title, @user[:email], \"admin\", worldID)\n respond_to do |format|\n format.html { redirect_to resources_url, notice: 'Resource was successf... | [
"0.6947151",
"0.68925005",
"0.6871639",
"0.68688583",
"0.68147826",
"0.6753604",
"0.66819865",
"0.66485727",
"0.66289926",
"0.66065156",
"0.6598677",
"0.6580668",
"0.65695715",
"0.65672123",
"0.65670717",
"0.65354246",
"0.65161675",
"0.64934194",
"0.6490549",
"0.648567",
"0.6... | 0.77915865 | 0 |
This is the only way I found to prevent deleting materials from a set via 'patch' | def check_lock
if Aker::Set.find(resource_id).locked?
return render json: { errors: [{ status: '422', title: 'Unprocessable entity', detail: 'Set is locked' }]}, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @material.destroy\n end",
"def material_use\n materials = []\n materials\n end",
"def unpatch!(patchset)\n Diff::LCS.unpatch!(self, patchset)\n end",
"def clear_materials\n\t\t@materials_charged_hash = Hash.new\n\tend",
"def clear_patches\n @patches.clear\n end",
... | [
"0.5997042",
"0.5908725",
"0.58023065",
"0.5708017",
"0.5529989",
"0.55141705",
"0.54935527",
"0.54932624",
"0.54703134",
"0.5464181",
"0.5439459",
"0.543778",
"0.542281",
"0.5418227",
"0.54018164",
"0.5374226",
"0.5368965",
"0.53652287",
"0.5359539",
"0.534018",
"0.53384286"... | 0.0 | -1 |
Fail request if the materials do not exist in materials service | def validate_uuids
unless Material.valid?(param_uuids)
return render json: { errors: [{ status: '422', title: 'Unprocessable entity', detail: 'Invalid Material UUIDs' }]}, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_exists\n @material = Material.check_exists(material_params)\n\n if @material\n respond_to do |format|\n format.html { redirect_to @material }\n #format.json { render json: @material }\n format.json { render :show, location: @material }\n end\n else\n respond_t... | [
"0.66627777",
"0.65781474",
"0.61721826",
"0.6014381",
"0.5985374",
"0.5942441",
"0.590904",
"0.58551633",
"0.5833826",
"0.5802574",
"0.5786202",
"0.57150567",
"0.5705983",
"0.56958604",
"0.56693405",
"0.566086",
"0.56494504",
"0.56472915",
"0.563557",
"0.5635382",
"0.5635382... | 0.60793185 | 4 |
If a buffer needs to modify, override this method. | def allow_sample?(sample)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def monkey_patch_buffer!\n unless @buffer.respond_to? :buffer\n @buffer.class.send(:include, BufferUtil) \n end\n end",
"def buffer; end",
"def buffer; end",
"def buffer; end",
"def _buffer( the_binding )\n @_buffer = eval( \"_buf\", the_binding )\n end",
"def swithOverwrite buffer\n ... | [
"0.7725814",
"0.7008587",
"0.7008587",
"0.7008587",
"0.69872695",
"0.66430175",
"0.6607979",
"0.65427816",
"0.650823",
"0.6484023",
"0.6450955",
"0.6413245",
"0.6393828",
"0.6361965",
"0.6361965",
"0.6329481",
"0.6248375",
"0.62143266",
"0.6202665",
"0.6185301",
"0.60851216",... | 0.0 | -1 |
If a buffer needs to modify, override this method. | def enabled?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def monkey_patch_buffer!\n unless @buffer.respond_to? :buffer\n @buffer.class.send(:include, BufferUtil) \n end\n end",
"def buffer; end",
"def buffer; end",
"def buffer; end",
"def _buffer( the_binding )\n @_buffer = eval( \"_buf\", the_binding )\n end",
"def swithOverwrite buffer\n ... | [
"0.77251905",
"0.70076716",
"0.70076716",
"0.70076716",
"0.69855905",
"0.6642355",
"0.66071886",
"0.65404665",
"0.650667",
"0.64841956",
"0.6450255",
"0.6410933",
"0.6393178",
"0.6361105",
"0.6361105",
"0.63295007",
"0.62466353",
"0.62131417",
"0.6202356",
"0.61843985",
"0.60... | 0.0 | -1 |
Capacity is the desired number of samples a buffer will hold. This can be user dictated via config if a feature wants. This value will be forcibly capped by the max_capacity | def capacity
raise NotImplementedError.new("TransactionSampleBufferBase subclasses must provide a capacity override")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capacity\n @capacity\n end",
"def capacity\n @capacity ||= DEFAULT_CAPACITY\n end",
"def capacity\n data[:capacity]\n end",
"def input_capacity\n typical_input_capacity\n end",
"def capacity=(value)\n @capacity = value\n end",
"def available_i... | [
"0.72650856",
"0.72281146",
"0.70058465",
"0.69601595",
"0.68685365",
"0.6824391",
"0.6810686",
"0.6744432",
"0.6648285",
"0.6466202",
"0.6442263",
"0.643262",
"0.6420256",
"0.6420256",
"0.6355884",
"0.63441414",
"0.63323355",
"0.63323355",
"0.63313586",
"0.6328554",
"0.62938... | 0.7964951 | 0 |
Our default truncation strategy is to keep max_capacity worth of the longest samples. Override this method for alternate behavior. | def truncate_samples
@samples.sort!{|a,b| a.duration <=> b.duration}
@samples.slice!(0..-(max_capacity + 1))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def truncate(max)\n resize([max, self.length].min)\n end",
"def truncate(max)\n length = Math.min(max, length)\n self\n end",
"def reduce_max_size\n @max_size /= 2\n end",
"def truncate(max, omission = '...')\n (length > max ? self[0...max] + omission : self)\n end",
"def length_... | [
"0.65088516",
"0.63382155",
"0.61215913",
"0.5840665",
"0.5728863",
"0.56309325",
"0.56064284",
"0.55611795",
"0.5530185",
"0.5523246",
"0.5455481",
"0.5452657",
"0.54229337",
"0.54226035",
"0.54155016",
"0.54083043",
"0.54032636",
"0.540153",
"0.5399925",
"0.5399512",
"0.539... | 0.7334056 | 0 |
If a buffer needs to modify an added sample, override this method. Bounds checking, allowing samples and truncation belongs elsewhere. | def add_sample(sample)
@samples << sample
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_sample?(sample)\n true\n end",
"def add_sample(sample)\n samples << sample\n end",
"def postprocess_sampled_data(data, desired_samples, drawing_area_width)\n if data.length > desired_samples\n resample_data(data, desired_samples)\n end\n \n data\n end",
... | [
"0.5963213",
"0.56874555",
"0.56216115",
"0.55630696",
"0.55279404",
"0.5517108",
"0.55160487",
"0.5475028",
"0.54514503",
"0.53746283",
"0.53689736",
"0.5332063",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.5328832",
"0.53288... | 0.5775565 | 1 |
Make a filename from the outside safe for use as a file on our system. | def sanitizeFilename(fn)
fn.gsub(/[^-A-Za-z0-9_.]/, "_")[0,80]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filesystem_safe_name\n name.\n gsub(ReservedCharacters) {|sub| '%%%02X' % sub.ord }.\n gsub(ReservedFilenameRegexp) {|sub| sub.gsub(/[^.]/) {|c| '%%%02X' % c.ord } }\n end",
"def safe_filepath\n filename.gsub!(/[\\?<>\\\\:\\*\\|\":]/, '_')\n full_path = File.join(root_path, fi... | [
"0.7398633",
"0.70158803",
"0.6917455",
"0.6733096",
"0.67037296",
"0.6700798",
"0.6695681",
"0.6695257",
"0.666186",
"0.6641997",
"0.6637534",
"0.6609923",
"0.6583505",
"0.65704876",
"0.6535614",
"0.65172595",
"0.65172595",
"0.65172595",
"0.651545",
"0.65094024",
"0.6450596"... | 0.65287256 | 15 |
Take a DepositItemInput and make a UCI record out of it. Note that if you pass existing UCI data in, it will be retained if Elements doesn't override it. NOTE: UCI in this context means "UC Ingest" format, the internal metadata format for eScholarship. | def uciFromInput(input, ark)
uci = Nokogiri::XML("<uci:record xmlns:uci='http://www.cdlib.org/ucingest'/>").root
# Top-level attributes
uci[:id] = ark.sub(%r{ark:/?13030/}, '')
uci[:dateStamp] = DateTime.now.iso8601
uci[:peerReview] = input['isPeerReviewed'] ? "yes" : "no"
uci[:state] = 'new'
uci[:state... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upc\n upc_code = params[:upc]\n redirect_to root_url, alert: 'Not a valid UPC' and return unless upc_code\n @item = Item.code_find_or_create_by(upc_code)\n redirect_to root_url, alert: 'No product matches found' and return unless @item.errors.empty?\n redirect_to add_item_to_cart_path(@item.id) ... | [
"0.5255674",
"0.5139402",
"0.50545406",
"0.5048498",
"0.48972556",
"0.48949417",
"0.48896214",
"0.48467955",
"0.4815196",
"0.48040518",
"0.48013783",
"0.47662178",
"0.47616273",
"0.47544327",
"0.46931592",
"0.4686183",
"0.4678388",
"0.4678388",
"0.46566775",
"0.46551114",
"0.... | 0.5917898 | 0 |
url is something like: | def load_spreadsheet(opts)
if opts[:url]
@session.spreadsheet_by_key parse_gdoc_url_for_key(opts[:url])
elsif opts[:key]
@session.spreadsheet_by_key(opts[:key])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def URI(url); end",
"def url\n \t@url.to_s\n end",
"def url\n end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"def url; end",
"d... | [
"0.7945686",
"0.7736013",
"0.7718381",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"0.7659639",
"... | 0.0 | -1 |
returns a string for key | def parse_gdoc_url_for_key(url)
u = URI.parse(url)
key = CGI.parse(u.query)['key'][0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n key.to_s\n end",
"def full_key\n [name, key].join(\"/\")\n end",
"def to_s\n @real_key\n end",
"def key\n @key ||= name.to_s\n end",
"def key_name\n data[:key_name]\n end",
"def to_s\n self.key\n end",
"def key\n @key.id2name\n end"... | [
"0.819309",
"0.8070051",
"0.7871787",
"0.7828393",
"0.7810379",
"0.77917576",
"0.7728263",
"0.77043295",
"0.76748455",
"0.7671681",
"0.7649763",
"0.76262105",
"0.75948733",
"0.7559358",
"0.7559358",
"0.7494856",
"0.74742633",
"0.7446051",
"0.74334306",
"0.7408465",
"0.7405108... | 0.0 | -1 |
sets up the table structure | def init_podunk_table(gsheet, opts={})
opts[:connection] = self
Table.new(gsheet.rows, opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_table; end",
"def bootstrap\n sql = 'CREATE TABLE IF NOT EXISTS states(uuid VARCHAR(128) PRIMARY KEY,'\n sql << ' id INTEGER, name VARCHAR(128), deploy_id VARCHAR(128), timestamp INTEGER,'\n sql << ' missing INTEGER, state VARCHAR(128), hyperv VARCHAR(128))'\n\n @db.exe... | [
"0.7133207",
"0.67908645",
"0.6688479",
"0.6685495",
"0.6668918",
"0.6592868",
"0.65927255",
"0.6570841",
"0.6537456",
"0.6498126",
"0.6498126",
"0.6498126",
"0.6498126",
"0.6484169",
"0.64773256",
"0.64678484",
"0.6423183",
"0.6410907",
"0.63890564",
"0.6388926",
"0.6357414"... | 0.0 | -1 |
Iterating Arrays as a method | def print_array(arr) # define method with one parameter
i = 0 # set starting index value
while i < arr.length
puts arr[i] # Returns the value in the array at index value iteration
i += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_method(array)\n i = 0\n while i< array.length\n yield array[i]\n i +=1\n end\nend",
"def method_2(array)\n array.each do |element|\n puts element\n end\nend",
"def explore_array(method, *arguments)\n ['a', 'b', 'c'].send(method, *arguments)\nend",
"def each &b\n\t\t@array.each(&b)\n\t... | [
"0.7475319",
"0.73420703",
"0.71562105",
"0.7032782",
"0.6956302",
"0.68995607",
"0.68725187",
"0.68366116",
"0.6793016",
"0.6793016",
"0.6793016",
"0.67750037",
"0.6769126",
"0.6744369",
"0.6726113",
"0.67214924",
"0.65871596",
"0.65871596",
"0.6543277",
"0.6538401",
"0.6538... | 0.0 | -1 |
Calls method with 1 argument | def doubler(numbers)
doubled_nums = [] # Creates empty array to store double nums
i = 0
while i < numbers.length
old_elem = numbers[i] # Creates temporary variable to hold number for each iteration
new_elem = old_elem * 2 # Multiplies old element by two and saves to new variable
doubled_nums << new_elem
i ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(method, args)\n send(method, *args)\n end",
"def call(*args); end",
"def call(*args)\n __call__( args )\n end",
"def call(*) end",
"def call(*) end",
"def method(arg0)\n end",
"def method(arg0)\n end",
"def call( *args )\n raise NotImplementedError\n end",
... | [
"0.77558124",
"0.77541155",
"0.74915016",
"0.72631276",
"0.72631276",
"0.72164166",
"0.72164166",
"0.7130901",
"0.70469326",
"0.70057976",
"0.69117576",
"0.6884915",
"0.6873748",
"0.6868988",
"0.68608147",
"0.68527955",
"0.684637",
"0.682998",
"0.682344",
"0.682344",
"0.68234... | 0.0 | -1 |
REmember to print your method call YELL PROBLEM Write a method yell(words) that takes in an array of words and returns a new array where every word from the original array has an exclamation point after it. | def yell(words) # DEFINE METHOD WITH ONE PARAM
i = 0 # SET FIRST INDEX VALUE
new_array = [] # CREATE AN EMPTY ARRAY
while i < words.length # WHILE LOOP THAT CHECKS IF I IS LESS THAN THE ARRAY LENGTH
old_ele = words[i] # VARIABLE TO STORE INDEXED VALUE OF ARRAY
exclamations = old_ele + "!" # VARIA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yell(words)\n words.map{|word| word + \"!\"}\nend",
"def yell(words)\n newArr = []\n i = 0\n while i<words.length\n newWord = words[i] + \"!\"\n newArr << newWord\n i += 1\n end\n return newArr\n end",
"def yell(words)\n new_words = []\n words.each {|word| new_words << w... | [
"0.826867",
"0.82177955",
"0.8172636",
"0.81165105",
"0.8102291",
"0.8082906",
"0.80328226",
"0.801409",
"0.7976287",
"0.79433",
"0.78415424",
"0.7798243",
"0.7561543",
"0.7532299",
"0.75265366",
"0.7297072",
"0.7051282",
"0.7010715",
"0.6745765",
"0.6722094",
"0.6645795",
... | 0.82064646 | 2 |
=> ["code!", "is!", "cool!"] | def element_times_index(numbers)
i = 0 # i represents to the index current index always
new_array = []
while i < numbers.length # We cant do less than or equal to here
new_array << numbers[i] * i # You can shovel directly into a new array
i += 1
end
return new_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yell(words)\n words.map{|word| word + \"!\"}\nend",
"def whisper_words(words)\nreturn words.map{ |elem| elem.downcase + \"...\"}\nend",
"def yell(words)\n\twords_bang = []\n\n\ti = 0\n\twhile i < words.length\n\t\twords_temp = words[i]\n\t\twords_new = words_temp + '!'\n\n\t\twords_bang << words_new\n\... | [
"0.6505465",
"0.6394712",
"0.6342969",
"0.6210279",
"0.61674124",
"0.61049163",
"0.6087833",
"0.6036144",
"0.6019176",
"0.6014929",
"0.6005572",
"0.5982568",
"0.59821266",
"0.59723264",
"0.5958852",
"0.5948041",
"0.593246",
"0.5907912",
"0.5904128",
"0.5873415",
"0.5865522",
... | 0.0 | -1 |
=> [0, 1, 2, 3, 4, 5] EVEN NUMS Write a method even_nums(max) that takes in a number max and returns an array containing all even numbers from 0 to max | def even_nums(max)
i = 0
even = []
while i <= max
if i % 2 == 0
even << i
end
i += 1
end
return even
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def even_nums(max)\n result = []\n\tfor i in 0..max\n \tif i % 2 == 0 \n result << i\n end\n end\n return result\nend",
"def even_nums(max)\n\tnums = []\n \n\ti = 0\n\twhile i <= max\n\t\tif i % 2 == 0\n\t\t\tnums << i\n\t\tend\n\t\ti += 1\n end\n \n\treturn nums\nend",
"def even_num... | [
"0.9112309",
"0.9052321",
"0.8976567",
"0.896618",
"0.8920272",
"0.89127636",
"0.89072543",
"0.8524075",
"0.8500073",
"0.8495281",
"0.8315231",
"0.7784933",
"0.7777802",
"0.77590245",
"0.7720529",
"0.75907725",
"0.75417733",
"0.74574524",
"0.74352",
"0.74346256",
"0.741943",
... | 0.88621944 | 7 |
=> [0, 2, 4] ARRAY CHALLENGE Write a method range(min, max) that takes in two numbers min and max. The function should return an array containing all numbers from min to max inclusive. | def range(min, max)
i = min
new_array = [] # The reason this is here and not in while loop is because we would be setting it to an empty array at the beginning of every instance and it would return the last iteration value of i.
while i <= max
new_array << i # Shovels each iteration of i in to arr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range(min, max)\n \tarr = []\n\tfor i in min..max\n arr << i\n end\n return arr\nend",
"def range(min, max)\n\trange = []\n\n\ti = min\n\twhile i <= max\n\t\trange << i\n\t\ti += 1\n end\n \n\treturn range\nend",
"def range(min, max)\n range_array = []\n\n i = min\n while i <= max\n range... | [
"0.89293134",
"0.8709388",
"0.8692145",
"0.8656729",
"0.8631398",
"0.85065615",
"0.845822",
"0.8451943",
"0.842452",
"0.83919835",
"0.83897895",
"0.838254",
"0.8374754",
"0.8298095",
"0.8233475",
"0.82334495",
"0.82193536",
"0.813814",
"0.80861455",
"0.8065947",
"0.8041493",
... | 0.81280476 | 18 |
=> [13, 14, 15, 16, 17, 18, 19, 20] ODD RANGE CHALLENGE Write a method odd_range(min, max) that takes in two numbers min and max. The method should return an array containing all odd numbers from min to max (inclusive). | def odd_range(min, max) # Define method with 2 params
i = min # since we are being to ask to start with first param we set i to start at min; the first param
new_array = [] # Create an empty array to shovel values into
while i <= max # Sets condition
if i % 2 != 0 # If statement that uses an expres... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def odd_range(min, max)\n\trange = []\n \n\ti = min\n\twhile i <= max\n\t\tif i % 2 != 0\n\t\t\trange << i\n\t\tend\n \ti += 1\n end\n\n\treturn range\nend",
"def odd_range(min, max)\n\tarr = []\n \tfor i in min..max\n if i % 2 != 0 \n arr << i\n end\n end\n return arr\n \nend",
... | [
"0.89546275",
"0.8939354",
"0.89030206",
"0.8902239",
"0.8878985",
"0.88209575",
"0.88187855",
"0.88109636",
"0.8752287",
"0.87434334",
"0.87421113",
"0.86884135",
"0.86154836",
"0.70886725",
"0.7036854",
"0.70299983",
"0.69627863",
"0.6946262",
"0.6942438",
"0.6935137",
"0.6... | 0.87216485 | 11 |
=> [3, 5, 7] REVERSE RANGE CHALLENGE Write a method reverse_range(min, max) that takes in two numbers min and max. The function should return an array containing all numbers from min to max in reverse order. The min and max should be excluded from the array | def reverse_range(min, max) # Define method
i = max - 1 # Because we are trying to reverse the order of array we have to start with the max value; minus one because it does not include min or max
new_array = [] # Create an empty array to shovel values into
while i > min # We have to start from the max va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_range(min, max)\n reversed = [] \n \n index = max - 1 \n \n while index > min \n reversed << index \n index -= 1\n end \n \n return reversed \n \nend",
"def reverse_range(min, max)\n newArr = []\n i = max - 1\n while i >= min +1\n newArr << i\n i ... | [
"0.89516217",
"0.8909612",
"0.8899485",
"0.8897072",
"0.87962884",
"0.8792103",
"0.8769101",
"0.87444884",
"0.8699591",
"0.8693999",
"0.85637313",
"0.7295437",
"0.7295437",
"0.7207642",
"0.71983993",
"0.7163555",
"0.711424",
"0.71120095",
"0.71120095",
"0.710353",
"0.70958763... | 0.89373326 | 1 |
=> [6, 5, 4, 3, 2] FIRST HALF Write a method first_half(array) that takes in an array and returns a new array containing the first half of the elements in the array. If there is an odd number of elements, turn the first half including the middle element. | def first_half(array)
i = 0
new_array = []
while i < array.length / 2.0 # This is makes sure that the loop runs while i is less than half of the length; thus the divided by two expression. This will always include the middle element since the index value is still less than half the whole array length value.
ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_half(array)\n half = []\n i = 0\n max = array.length - (array.length / 2)\n while i < max\n half << array[i]\n i += 1\n end\n return half\n \n end",
"def first_half(array)\n\n new_arr = []\n even_arr = array.length / 2\n odd_arr = even_arr + 1\n \n i = 0\n \n if a... | [
"0.8961302",
"0.8950954",
"0.8875156",
"0.88587683",
"0.88571215",
"0.88189095",
"0.8802105",
"0.8718996",
"0.86347073",
"0.86131454",
"0.85957915",
"0.85068303",
"0.8335926",
"0.8272722",
"0.827134",
"0.826673",
"0.8188495",
"0.81455004",
"0.8115913",
"0.8110046",
"0.8103419... | 0.87171954 | 8 |
FACTORS OF Write a method factors_of(num) that takes in a num and returns an array of all positive numbers less than or equal to num that can divide num. | def factors_of(num) # Define method with one param
i = 1 # To prevent dividing by zero start at one because of future modula expression
new_array = [] # Create and empty array to shovel numbers while they meet requirements of the if statement
while i <= num
if num % i == 0 # Parameter entered must... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def factors_of(num)\n factors = []\n \n i = 1\n while i <= num\n # if num is divided by i\n if num % i == 0\n factors << i\n end\n \n i += 1\n end\n \n return factors\n end",
"def factors_of(num)\n array = []\n i = 1\n while i <= num\n if num % i == 0\n... | [
"0.86133254",
"0.8602405",
"0.85794353",
"0.85481006",
"0.83708006",
"0.8348235",
"0.8309214",
"0.829599",
"0.82940227",
"0.82782644",
"0.8276724",
"0.8270363",
"0.8234743",
"0.8226091",
"0.8210875",
"0.8193632",
"0.81910175",
"0.8189199",
"0.81800485",
"0.8176216",
"0.815655... | 0.7942186 | 41 |
=> [1, 2, 4, 8, 16] Select Odds Challenge Write a method select_odds(numbers) that takes in an array of numbers and returns a new array containing the odd numbers of the original array. | def select_odds(numbers)
i = 0
new_array = []
while i < numbers.length
if numbers[i] % 2 != 0
new_array << numbers[i]
end
i += 1
end
return new_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_odds(numbers)\n odds = []\n \n i = 0\n while i < numbers.length\n num = numbers[i]\n if num % 2 == 1\n odds << num\n end\n \n i += 1\n end\n \n return odds\n end",
"def select_odds(numbers)\n\todds = []\n \tfor i in 0..numbers.length-1\n number = num... | [
"0.8712902",
"0.86577994",
"0.8645806",
"0.85709745",
"0.8566933",
"0.85528225",
"0.85220385",
"0.85206103",
"0.84716445",
"0.83593404",
"0.8301404",
"0.7827947",
"0.76841897",
"0.7562744",
"0.7556489",
"0.7534714",
"0.745706",
"0.742582",
"0.7416964",
"0.7403567",
"0.7392426... | 0.83804184 | 9 |
=> [] Select Long Words Write a method select_long_words(words) that takes in an array of words and returns a new array containing all of the words of the original array that are longer than 4 characters. | def select_long_words(words) # Define method
i = 0 # Set starting index value
new_array = [] # Create new empty array to shovel values into
while i < words.length # Length of word argument array must be less than index value of current iteration
if words[i].length > 4 # Character length of words of index v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_long_words(words)\n i = 0\n newArr = []\n while i < words.length\n if words[i].length > 4\n newArr << words[i]\n end\n i += 1\n end\n return newArr\n end",
"def select_long_words(words)\n\tlongWords = []\n\n\ti = 0\n\twhile i <= words.length\n\t\ttemp = words[i]\n... | [
"0.8966248",
"0.8897085",
"0.87760544",
"0.8744303",
"0.8666364",
"0.8653017",
"0.8542003",
"0.8309315",
"0.7300351",
"0.71955514",
"0.71024877",
"0.69761753",
"0.6923362",
"0.68781626",
"0.6877794",
"0.68221897",
"0.68090147",
"0.6804265",
"0.668648",
"0.667948",
"0.66296613... | 0.78049564 | 8 |
SUM ELEMENTS CHALLENGE Write a method sum_elements(arr1, arr2) that takes in two arrays. The method should return a new array containing the results of adding together corresponding elements of the riginal arrays. You can assume the arrays have the same length. | def sum_elements(arr1, arr2)
i = 0
new_array = []
while i < arr1.length
new_array << arr1[i] + arr2[i]
i += 1
end
return new_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_elements(arr1, arr2)\n i = 0\n newArr = []\n while i < arr1.length\n newArr << arr1[i] + arr2[i]\n i += 1\n end\n return newArr\n end",
"def sum_elements(arr1, arr2)\n\tsum_array = []\n\n\ti = 0\n\twhile i < arr1.length && i < arr2.length\n\t\ttemp = arr1[i] + arr2[i]\n\t\tsum_a... | [
"0.8315299",
"0.82721746",
"0.80863374",
"0.80506027",
"0.80035174",
"0.7944498",
"0.7908413",
"0.73121536",
"0.7032691",
"0.6919748",
"0.6906139",
"0.6871124",
"0.68354064",
"0.6771543",
"0.6759266",
"0.6736558",
"0.67344266",
"0.6689309",
"0.6530208",
"0.65017974",
"0.64869... | 0.7848273 | 7 |
=> ["catdog", "pizzapie", "bootcamp"] FIZZ BUZZ CHALLENEGE Write a method fizz_buzz(max) that takes in a number max and returns an array containing all numbers greater than 0 and less than max that are divisible by either 4 or 6, but not both. | def fizz_buzz(max) # Define method
i = 0 # Set iteration start
new_array = [] # Create array
while i < max # Set condition that determines how long loop iterates
if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)
new_array << i
end
i += 1 # Increment loop by 1
end
return ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fizz_buzz(max)\n\ti = 0\n\tnewArr = []\n \twhile i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i % 4 == 0 && i % 6 == 0)\n newArr << i\n end\n i += 1\n end\n return newArr\nend",
"def fizz_buzz(max)\n\tnewArr = []\n i = 1\n while i < max\n if (i % 4 == 0 || i % 6 == 0) && !(i %... | [
"0.8674005",
"0.862002",
"0.861987",
"0.8609624",
"0.86006236",
"0.8569152",
"0.85605323",
"0.84954715",
"0.8493324",
"0.84929466",
"0.84867674",
"0.8390373",
"0.8390373",
"0.8390373",
"0.83895755",
"0.83839566",
"0.8375027",
"0.8315841",
"0.8214323",
"0.820697",
"0.79041404"... | 0.8362696 | 17 |
Checks if the action is currently supported | def validate_action(label, body)
action = PaneAction.for(label)
raise ArgumentError, "Unsupported action: #{label}" unless action
action.validate(body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_argument_required?\n !AVAILABLE_ACTIONS.empty?\n end",
"def available_action?(action_name); end",
"def supported?\n return false unless ALL_SUPPORTED_ACTIONS.include?(request.action_type)\n type = @type = request.action_type.to_sym\n @normalized_type = NORMALIZED_ACTION_MAP.fe... | [
"0.7865723",
"0.78390485",
"0.7521905",
"0.72955316",
"0.72715336",
"0.72662115",
"0.72453874",
"0.72301155",
"0.7182697",
"0.717772",
"0.7119915",
"0.7035781",
"0.7024137",
"0.7005573",
"0.6927771",
"0.68774325",
"0.6872005",
"0.6849777",
"0.68364644",
"0.68363476",
"0.67038... | 0.0 | -1 |
Checks if the given hash only contains one mapping from a nonempty string to a hash | def single_spec?(spec, *klasses)
(key, value), second = spec.take(2)
second.nil? && valid_name?(key) &&
(klasses.empty? || klasses.any? { |k| value.is_a?(k) })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empty?(hash)\n hash unless hash.empty?\n end",
"def is_unique_with_hash?(str)\n hash = {}\n str.each_char do |ch|\n if hash[ch]\n return false\n else \n hash[ch] = true\n end \n end \n true\nend",
"def hash?(hash)\n return false if hash.nil?\n if hash =~ /^[a-fA-F0-... | [
"0.6872515",
"0.653527",
"0.64753824",
"0.63653773",
"0.63653773",
"0.6327134",
"0.61998135",
"0.61828476",
"0.61455345",
"0.6136147",
"0.6129145",
"0.60743505",
"0.60740703",
"0.6071318",
"0.60477054",
"0.6025387",
"0.6015785",
"0.60072166",
"0.59972966",
"0.59713346",
"0.59... | 0.0 | -1 |
Is this a RHELcompatible OS with a minimum major version number of `version` | def el_min_version?(version)
self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def major_version(version = nil)\n version ||= installed_version?\n return \"0\" if version.nil?\n\n version.sub(/(\\.\\d+)+$/, '')\n end",
"def major(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*(\\d+)\\.\\d+\\.\\d+/\n res\n end",
"def major ; version... | [
"0.7731996",
"0.7731392",
"0.7710112",
"0.76567256",
"0.76567256",
"0.73321724",
"0.73151785",
"0.71896255",
"0.71794736",
"0.71794736",
"0.7167988",
"0.7146111",
"0.7146111",
"0.7146111",
"0.71318275",
"0.7128724",
"0.7121457",
"0.7121457",
"0.7103959",
"0.7102385",
"0.70955... | 0.8040562 | 0 |
Is this a RHELcompatible OS with a maximum major version number of `version` | def el_max_version?(version)
self.rhel_family? && FB::Version.new(self['platform_version']) <= self._canonical_version(version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def el_min_version?(version)\n self.rhel_family? && FB::Version.new(self['platform_version']) >= self._canonical_version(version)\n end",
"def major(version)\n res = 0\n res = Regexp.last_match(1) if version =~ /^\\s*(\\d+)\\.\\d+\\.\\d+/\n res\n end",
"def major_version(version = nil... | [
"0.7908768",
"0.778943",
"0.7641181",
"0.75656223",
"0.74951726",
"0.73930484",
"0.73029363",
"0.72966486",
"0.72966486",
"0.7276666",
"0.72604084",
"0.7234367",
"0.7230939",
"0.7185924",
"0.7123798",
"0.7100777",
"0.70891786",
"0.70891786",
"0.7075512",
"0.7075512",
"0.70752... | 0.78176755 | 1 |
Takes one or more AWS account IDs as strings and return true if this node is in any of those accounts. | def in_aws_account?(*accts)
return false if self.quiescent?
return false unless self['ec2']
accts.flatten!
accts.include?(self['ec2']['account_id'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_include?(*user_ids)\n user_ids.map { |user_id| @users.include?(user_id) }.all?\n end",
"def contains(uid)\n #This doesn't work in ruby 1.8.5\n #return self[\"USERS/ID[.=#{uid}]\"] != nil\n\n id_array = retrieve_elements('USERS/ID')\n return id_array != ni... | [
"0.6463729",
"0.5934939",
"0.5934939",
"0.58159834",
"0.5791001",
"0.57766926",
"0.57446176",
"0.5658904",
"0.5648091",
"0.5631529",
"0.5608362",
"0.56019205",
"0.5571382",
"0.5539207",
"0.55386674",
"0.5517688",
"0.54203606",
"0.5391145",
"0.5376663",
"0.5371528",
"0.5369195... | 0.7621516 | 0 |
Take a string representing a mount point, and return the device it resides on. | def device_of_mount(m)
fs = self.filesystem_data
unless Pathname.new(m).mountpoint?
Chef::Log.warn(
"fb_helpers: #{m} is not a mount point - I can't determine its " +
'device.',
)
return nil
end
unless fs && fs['by_pair']
Chef::Log.warn(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_of_mount(m)\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"#{m} is not a mount point - I can't determine its device.\",\n )\n return nil\n end\n node['filesystem2']['by_pair'].to_hash.each do |pair, info|\n # we skip fake filesystems 'rootf... | [
"0.7978163",
"0.7947849",
"0.67994153",
"0.6692301",
"0.6387517",
"0.62892807",
"0.62242097",
"0.59843117",
"0.59592485",
"0.592807",
"0.5920276",
"0.5916922",
"0.5877466",
"0.58217335",
"0.5814342",
"0.5814342",
"0.58069736",
"0.57812154",
"0.5777981",
"0.57406163",
"0.57402... | 0.77884984 | 2 |
Takes a string corresponding to a filesystem. Returns the size in GB of that filesystem. | def fs_value(p, val)
key = case val
when 'size'
'kb_size'
when 'used'
'kb_used'
when 'available'
'kb_available'
when 'percent'
'percent_used'
else
fail "fb_helpers: Unknown FS val #{va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_string_size_in_kb string\n total_bytes = 0\n string.each_byte {|b| total_bytes += 1}\n result = total_bytes.to_f / 1024.to_f\n end",
"def size\n size = popen(%W(du -s), full_path).first.strip.to_i\n (size.to_f / 1024).round(2)\n end",
"def convertsize(... | [
"0.722561",
"0.7021257",
"0.69915",
"0.69172364",
"0.6838267",
"0.68184334",
"0.67541575",
"0.6747483",
"0.6691074",
"0.6665308",
"0.65760976",
"0.6521253",
"0.6512398",
"0.64639455",
"0.6439165",
"0.63662434",
"0.63384694",
"0.6327546",
"0.63271976",
"0.6322732",
"0.6319997"... | 0.0 | -1 |
This method allows you to conditionally shard chef resources | def shard_block(threshold, &block)
yield block if block_given? && in_shard?(threshold)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shard; end",
"def run_w_shard(mongo, config_source, config_reader_builder,\n config_writer_builder, opt = {})\n @stop_mutex.synchronize { @stop = false }\n\n config_poll_interval = opt[:config_poll_interval] || 1\n err_retry_interval = opt[:err_retry_interval] || 10\n l... | [
"0.65044063",
"0.5700196",
"0.56292653",
"0.56289804",
"0.54907453",
"0.5487057",
"0.54701674",
"0.54701674",
"0.54226494",
"0.5355603",
"0.53491527",
"0.53360707",
"0.5304525",
"0.5271161",
"0.5245763",
"0.52338797",
"0.5229104",
"0.5222399",
"0.5178472",
"0.5132586",
"0.511... | 0.563348 | 2 |
Shard range is 099 | def rollout_shard(start_date)
rollout_map = [
1,
10,
25,
50,
99,
]
rd = Date.parse(start_date)
# Now we use today as an index into the rollout map, except we have to
# discount weekends
today = Date.today
numdays = (today - rd).to_i
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rdfs_range\n end",
"def shard; end",
"def m_range\r\n end",
"def range; end",
"def range; end",
"def range; end",
"def shard_index(n)\n orig_n = n\n n = n.to_i if n.is_a?(GenericNumeric)\n if n.is_a?(Numeric) || n.to_s =~ /^[+-]\\d+$/\n n = n.to_i if n.is_a?(St... | [
"0.6611703",
"0.66045314",
"0.6315301",
"0.6259179",
"0.6259179",
"0.6259179",
"0.62228215",
"0.6189474",
"0.60474354",
"0.60474354",
"0.60474354",
"0.6000904",
"0.5977611",
"0.5940206",
"0.59218925",
"0.5908179",
"0.5908179",
"0.5900818",
"0.5892729",
"0.5892535",
"0.5890437... | 0.5906514 | 17 |
is this device a SSD? If it's not rotational, then it's SSD expects a short device name, e.g. 'sda', not '/dev/sda', not '/dev/sda3' | def device_ssd?(device)
unless node['block_device'][device]
fail "fb_helpers: Device '#{device}' passed to node.device_ssd? " +
"doesn't appear to be a block device!"
end
node['block_device'][device]['rotational'] == '0'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_device_name(volume_attachments, first_device_name_letter)\n (first_device_name_letter..'z').each do |char|\n # Some kernels remap device names (from sd* to vd* or xvd*).\n device_names = [\"/dev/sd#{char}\", \"/dev/vd#{char}\", \"/dev/xvd#{char}\"]\n # Bosh Agent will lookup fo... | [
"0.64648587",
"0.6390836",
"0.6318847",
"0.6230825",
"0.6149251",
"0.6143996",
"0.61226445",
"0.6002282",
"0.5961526",
"0.5947527",
"0.58912826",
"0.58758265",
"0.58645123",
"0.5856323",
"0.5852366",
"0.5843651",
"0.57776934",
"0.57702684",
"0.57570446",
"0.57345617",
"0.5692... | 0.67621386 | 0 |
On Linux and Mac, as of Chef 13, FS and FS2 were identical and in Chef 14, FS2 is dropped. For FreeBSD and other platforms, they become identical in late 15 and FS2 is dropped in late 16 So we always try 2 and fail back to 1 (if 2 isn't around, then 1 is the new format) This will return modern filesystem data, where it... | def filesystem_data
self['filesystem2'] || self['filesystem']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filesystem_type(host)\n case host['platform']\n when %r{aix}\n 'jfs2'\n when %r{el-|centos|fedora|sles|debian|ubuntu}\n 'ext3'\n else\n # TODO: Add Solaris and OSX support, as per PUP-5201 and PUP-4823\n fail_test(\"Unable to determine a standard filesystem table type for #{host... | [
"0.6409167",
"0.6298371",
"0.62385446",
"0.6204947",
"0.6158275",
"0.60359377",
"0.5938951",
"0.5910641",
"0.58961666",
"0.58135825",
"0.5793706",
"0.5763402",
"0.56151956",
"0.5602559",
"0.5602408",
"0.55545163",
"0.55434644",
"0.5538523",
"0.55028903",
"0.54697496",
"0.5460... | 0.6442593 | 0 |
returns the versionrelease of an rpm installed, or nil if not present | def rpm_version(name)
if (self.centos? && !self.centos7?) || self.fedora? || self.redhat8? || self.oracle8? || self.redhat9?
# returns epoch.version
v = Chef::Provider::Package::Dnf::PythonHelper.instance.
package_query(:whatinstalled, name).version
unless v.nil?
v.sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def el_version\n if File.exists?('/etc/fedora-release')\n nil\n elsif File.exists?('/etc/redhat-release')\n rpm = Pkg::Util::Tool.find_tool('rpm', :required => true)\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{rpm} -q --qf \\\"%{VERSION}\\\" $(#{rpm} -q --whatprovides /etc/red... | [
"0.73902994",
"0.69928986",
"0.6868143",
"0.6667904",
"0.66559",
"0.6363557",
"0.63081396",
"0.6286012",
"0.6278648",
"0.6278648",
"0.6228528",
"0.6159336",
"0.61371917",
"0.6126809",
"0.6117446",
"0.6108582",
"0.6106775",
"0.605658",
"0.60458213",
"0.6038254",
"0.6030145",
... | 0.73622614 | 1 |
Safely dig through the node's attributes based on the specified `path`, with the option to provide a default value in the event the key does not exist. | def attr_lookup(path, delim: '/', default: nil)
return default if path.nil?
node_path = path.split(delim)
# implicit-begin is a function of ruby2.5 and later, but we still
# support 2.4, so.... until then
node_path.inject(self) do |location, key|
if key.respond_to?(:to_s) && locat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_attribute(path, default = nil)\n node.dig(*path.split('.')) || default\nend",
"def get_attribute_from_path(obj, attribute_path, default=nil)\n for attr in attribute_path.split(\".\") do\n case obj\n when Hash\n obj = !obj[attr.to_sym].nil? ? obj[attr.to_sym] : obj[attr]\n ... | [
"0.73300654",
"0.6849942",
"0.57888705",
"0.5745849",
"0.5479487",
"0.5461313",
"0.54462945",
"0.54340315",
"0.5425057",
"0.5383187",
"0.5359801",
"0.5353659",
"0.53333986",
"0.5269127",
"0.52258873",
"0.5223862",
"0.5156812",
"0.5145474",
"0.5112456",
"0.5112202",
"0.5099680... | 0.6996469 | 1 |
We can change interface configs if nw_changes_allowed? or we are operating on a DSR VIP | def interface_change_allowed?(interface)
method = node['fb_helpers']['interface_change_allowed_method']
if method
return method.call(node, interface)
else
return self.nw_changes_allowed? ||
['ip6tnl0', 'tunlany0', 'tunl0'].include?(interface) ||
interface.match(Rege... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @network_interfaces = args[:network_interfaces] if args.key?(:network_interfaces)\n end",
"def config_update( name )\n @ndev_res.update name\n @@netdev.edit_config( @ndev_res, \"xml\" )\n end",
"def update_network_interfaces(name, address)\n default_nm = '255.255.2... | [
"0.6173955",
"0.60474354",
"0.5944021",
"0.5873205",
"0.5819781",
"0.5768081",
"0.57122844",
"0.570934",
"0.57059175",
"0.56624365",
"0.565729",
"0.5625125",
"0.55513424",
"0.5550935",
"0.5538155",
"0.55335784",
"0.5512803",
"0.55036944",
"0.5495416",
"0.54888123",
"0.5476123... | 0.68822914 | 0 |
A gate which can be used to limit dangerous code to only run during provisioning or upon boot | def disruptable?
@disruptable ||=
node.firstboot_any_phase? || ENV['CHEF_BOOT_SERVICE'] == 'true'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def taint() end",
"def provision!; end",
"def sharded?; true; end",
"def sharded?; false; end",
"def allow_production=(_arg0); end",
"def sandbox?; end",
"def sandbox?; end",
"def allow_in_post_mortem; end",
"def allowed?; true end",
"def distracted?\n false\n end",
"def one_gradable_ex_onl... | [
"0.62861425",
"0.62122357",
"0.6168107",
"0.6159649",
"0.6132658",
"0.6076362",
"0.6076362",
"0.6048164",
"0.6006247",
"0.5969954",
"0.59371656",
"0.59067506",
"0.5905686",
"0.5878779",
"0.5870758",
"0.57948",
"0.5752462",
"0.5741829",
"0.57318795",
"0.57315296",
"0.5708797",... | 0.0 | -1 |
Creates and initialize new instance of the HttpOperationResponse class. | def initialize(request, response, body = nil)
@request = request
@response = response
@body = body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_response(request, http_response, body = nil)\n HttpOperationResponse.new(request, http_response, body)\n end",
"def initialize(http_response, request)\n @http_response = http_response\n @request = request\n end",
"def initialize(http_resp)\n @content = http_resp.body\... | [
"0.72643906",
"0.66876644",
"0.64851916",
"0.6429136",
"0.6403305",
"0.6398606",
"0.6334115",
"0.6333564",
"0.6221711",
"0.61988544",
"0.6135737",
"0.6125259",
"0.6037016",
"0.6036697",
"0.60138065",
"0.6012002",
"0.59961396",
"0.59953105",
"0.5988709",
"0.59845096",
"0.59644... | 0.6204797 | 9 |
show method specific page for opportunity | def show
@opp = Opp.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n end",
"def show\n\n \n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show\n # TODO\n end",
"def show\n # TODO\n end",
"def show\n \n # \n end",
"def show\n @page_id = \"opinions\"\n @opinion = Opinion.find(params[:i... | [
"0.7210297",
"0.7163404",
"0.7162369",
"0.7162369",
"0.7162369",
"0.71623135",
"0.71623135",
"0.71586764",
"0.7130144",
"0.71261644",
"0.71261644",
"0.71208555",
"0.71208555",
"0.71208555",
"0.71208555",
"0.71186465",
"0.7117115",
"0.7117115",
"0.7117115",
"0.7115804",
"0.710... | 0.0 | -1 |
Time field on form sets year to 2000 so this will give correct date | def update_time_date
start_year = self.start_at.change(:year => self.lesson_date.year)
start_month = start_year.change(:month => self.lesson_date.month)
start_day = start_month.change(:day => self.lesson_date.day)
self.start_at = start_day
end_year = self.end_at.change(:year => self.lesson_date.yea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_date\n \"#{date.month}/#{date.day}/#{date.year - 2000}\"\n end",
"def datetime_select_jp(form, method, options ={})\n options[:use_month_numbers].nil? and options[:use_month_numbers] = true\n options[:end_year] ||= (form.object.send(method) || @show_time).year + 10 \n form.datetime_select(... | [
"0.7463294",
"0.63760287",
"0.63396454",
"0.6309744",
"0.6309744",
"0.628385",
"0.628385",
"0.62558466",
"0.61991215",
"0.61755955",
"0.6175128",
"0.6150757",
"0.6073218",
"0.6043121",
"0.6036899",
"0.603354",
"0.60294235",
"0.60194415",
"0.59884024",
"0.59841526",
"0.5954875... | 0.0 | -1 |
Gives total lesson time in hours | def lesson_length
seconds = self.end_at - self.start_at
seconds / 3600.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hours() 60 * minutes end",
"def hours\n self.to_i * 3_600\n end",
"def hours\n return \"There are #{self * (60 * 60)} seconds in #{self} hours\"\n end",
"def total_hours\n ('%.02f' % ((ends_at - starts_at) / 1.hour)).to_f\n end",
"def hours\n self * SECONDS_IN_HOUR\n end",
"def hours\... | [
"0.74050367",
"0.72218186",
"0.7165386",
"0.7143947",
"0.7096685",
"0.7079745",
"0.7073863",
"0.707299",
"0.70044774",
"0.69709665",
"0.69577",
"0.6931018",
"0.68911767",
"0.68692887",
"0.6864626",
"0.6863891",
"0.6857693",
"0.68430966",
"0.6816562",
"0.6813651",
"0.6813651",... | 0.75305045 | 0 |
If you have extra params to permit, append them to the sanitizer. | def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :company_id])
devise_parameter_sanitizer.for(:sign_up).push(:company_id, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindat... | [
"0.6905034",
"0.683687",
"0.68280804",
"0.67889357",
"0.6674015",
"0.66522104",
"0.66448265",
"0.6595933",
"0.65606564",
"0.64921725",
"0.6489163",
"0.64781183",
"0.64483696",
"0.64394945",
"0.6419598",
"0.6419251",
"0.63999707",
"0.63977224",
"0.63977224",
"0.63934815",
"0.6... | 0.0 | -1 |
default 4.times do |i| WS2801.set :pixel => i3, :r => 127 WS2801.set :pixel => (i3)+1, :g => 127 WS2801.set :pixel => (i3)+2, :b => 127 end sleep(1) | def guage(n)
r = (255 * n) / 100
g = (255 * (100 - n)) / 100
b = 0
return { :r => r, :g => g, :b => b }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_one_pixel(pixelno,r,g,b)\n# puts \"Set one pixel length packetdata in \" + @@packetdata.size.to_s\n pixelno = pixelno % @@numpixels\n if r < 256 then\n temp = [r]\n @@packetdata[pixelno * 3] = temp.pack(\"C\")\n end\n if g < 256 then\n temp = [g]\n @@packetdata[(pixelno * 3) + 1] = temp.pa... | [
"0.6504237",
"0.61832976",
"0.6111973",
"0.6099334",
"0.6056286",
"0.60539997",
"0.5939408",
"0.58347994",
"0.5831059",
"0.57764095",
"0.57642883",
"0.5759403",
"0.5722849",
"0.571854",
"0.5703995",
"0.5685345",
"0.5659769",
"0.56507176",
"0.56322813",
"0.56197083",
"0.561577... | 0.0 | -1 |
The position of the task in the board list determines its priority This method sets the position of the task in the list (acts_as_list gem) According to the index passed by the ajax call. | def set_position(index)
first_item_position = board.tasks.by_status(self.status)[index].position
insert_at(first_item_position)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_position\n\n puts params[:tasks].to_json\n\n @tasksvalues = params[:tasks].values.map do |task|\n @task = Task.find_by(id: task[:id])\n @task.update(position:task[:position])\n end\n\n\n\n end",
"def update_position\n if self.simple_acts_as_list_scope.length == 0\n self.po... | [
"0.5924361",
"0.56312937",
"0.5601406",
"0.55601424",
"0.5548982",
"0.5534822",
"0.5512286",
"0.5488283",
"0.54663444",
"0.5423879",
"0.5382966",
"0.5339327",
"0.53325564",
"0.5332331",
"0.5320368",
"0.5319066",
"0.53031844",
"0.527709",
"0.5270131",
"0.5269593",
"0.52648896"... | 0.7345166 | 0 |
GET /list_items GET /list_items.xml | def index
@list = List.find(params[:list_id])
@list_items = @list.list_items.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @list_items }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n respond_with @items\n end",
"def items\n # Since we'r... | [
"0.73681515",
"0.7245629",
"0.7172651",
"0.7144363",
"0.7072838",
"0.70601827",
"0.699434",
"0.69893384",
"0.69827557",
"0.69751376",
"0.68912953",
"0.68452215",
"0.68293315",
"0.6819314",
"0.6806944",
"0.67967117",
"0.6751051",
"0.67395335",
"0.67359596",
"0.67359596",
"0.66... | 0.7516307 | 0 |
GET /list_items/1 GET /list_items/1.xml | def show
@list = List.find(params[:list_id])
@list_item = @list.list_items.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @list_item }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @list_items }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @items = @list.items\n\n... | [
"0.74913013",
"0.6927452",
"0.6771285",
"0.6749842",
"0.6674167",
"0.65780854",
"0.652523",
"0.6520168",
"0.64768356",
"0.6455133",
"0.6449316",
"0.64414245",
"0.6434415",
"0.6417664",
"0.6415853",
"0.6414747",
"0.64140445",
"0.63829",
"0.635195",
"0.63431084",
"0.63274163",
... | 0.71897435 | 1 |
GET /list_items/new GET /list_items/new.xml | def new
@list = List.find(params[:list_id])
@list_item = @list.list_items.build
@page_section = @list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
format.js { render :partial => 'ajax_new' }
format.html # new.html.erb
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @list = List.find(params[:list_id])\n @item = @list.items.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item }\n end\n end",
"def new\n @item = Item.factory('local')\n \n respond_to do |format|\n format.html # new.html... | [
"0.752519",
"0.7446631",
"0.7367704",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7348029",
"0.7333662",
"0.73181874",
"0.72891396",
"0.7268241",
"0.7250376",
"0.711803",
"0.7107238",
"0.709797",
"0.70627785",
"0.70335287",
... | 0.0 | -1 |
POST /list_items POST /list_items.xml | def create
@list = List.find(params[:list_id])
@list_item = @list.list_items.build(params[:list_item])
@page_section = @list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @list_item.save
flash[:notice] = 'ListItem was suc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n @item = @list.items.create(item_params)\n redirect_to @list\n end",
"def create\n\n nested = params[:list].delete(:list_items_attributes)\n\n @list = List.n... | [
"0.6939243",
"0.6640042",
"0.66219974",
"0.6580838",
"0.65639144",
"0.6539049",
"0.65368",
"0.65124077",
"0.6483423",
"0.63886154",
"0.63838345",
"0.6376204",
"0.6310107",
"0.6281453",
"0.6260847",
"0.6202426",
"0.61957246",
"0.6160829",
"0.61469996",
"0.61276853",
"0.6106216... | 0.0 | -1 |
PUT /list_items/1 PUT /list_items/1.xml | def update
@list = List.find(params[:list_id])
@list_item = @list.list_items.find(params[:id])
@page_section = @list.page_section
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
if @list_item.update_attributes(params[:list_item])
flash[:no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n @item.update_attributes(item_params)\n @items = List.find(item_params[:list_i... | [
"0.6984748",
"0.69329256",
"0.6790025",
"0.67708486",
"0.6667355",
"0.6630834",
"0.66150033",
"0.65653706",
"0.65477073",
"0.6526097",
"0.64774257",
"0.64527977",
"0.64524394",
"0.6435126",
"0.64300007",
"0.64283556",
"0.6338978",
"0.6321061",
"0.62865925",
"0.6275006",
"0.62... | 0.0 | -1 |
DELETE /list_items/1 DELETE /list_items/1.xml | def destroy
@list = List.find(params[:list_id])
@list_item = @list.list_items.find(params[:id])
@page_section = @list.page_section
@list_item.destroy
@page = @page_section.page
@site_section = @page.site_section
respond_to do |format|
format.html { redirect_to site_section_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @list_id = @item.list.id\n @item.destroy\n @items = List.find(@list_id).items.order(\"id ASC\")\n end",
"def destroy\n @list_item.destroy\n\n head :no_content\n end",
"def delete_list_item(client, uri, headers)\n # log what we are doing\n log(:info, \"Deleting Sharepoint li... | [
"0.6930925",
"0.691129",
"0.6884909",
"0.68283284",
"0.68153644",
"0.67423713",
"0.6675455",
"0.6659997",
"0.66557074",
"0.6648087",
"0.6647733",
"0.6635589",
"0.6635589",
"0.6635589",
"0.6635589",
"0.6635589",
"0.6635589",
"0.66337746",
"0.66323316",
"0.6629893",
"0.66055876... | 0.0 | -1 |
GET /comments/1 GET /comments/1.json | def show
#@comment = Comment.find(params[:id])
redirect_to "/home/index"
#respond_to do |format|
#format.html # show.html.erb
#format.json { render json: @comment }
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @article = Article.find(params[:id])\n @comments = @article.comments\n\n respond_... | [
"0.8280257",
"0.74416476",
"0.74416476",
"0.7434451",
"0.7404793",
"0.7303314",
"0.7282542",
"0.72574276",
"0.72542727",
"0.72470427",
"0.7242218",
"0.7219159",
"0.7217871",
"0.72176784",
"0.71734184",
"0.7157483",
"0.7156849",
"0.71178067",
"0.7117778",
"0.71012414",
"0.7099... | 0.0 | -1 |
GET /comments/new GET /comments/new.json | def new
#@comment = Comment.new
redirect_to "/home/index"
#respond_to do |format|
#format.html # new.html.erb
#format.json { render json: @comment }
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @comment = @commentable.comments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @... | [
"0.8087922",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8077042",
"0.8074817",
"0.8012823",
"0.80119",
"0.80119",
"0.80058974",
"0.76914775",
"0.7650126",
"0.7645689",
"0.... | 0.71943396 | 56 |
POST /comments POST /comments.json | def create
@comment = Comment.new(params[:comment])
@comment.user_id = current_user.id
@comment.modifier = current_user.id
respond_to do |format|
if @comment.save
#redis保存评论数
ask_answers_comments_count @comment.answer.ask_id
@one_comment = OneComment.new(@comment)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @comment = @post.comments.new(comment_params)\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n\n end",
"def comment options={}\n client.post(\"/#{id}/comments\", options)\n end",
... | [
"0.75120175",
"0.74212646",
"0.7374645",
"0.72364116",
"0.7205224",
"0.7086658",
"0.7069151",
"0.70549524",
"0.7049054",
"0.6989455",
"0.69825",
"0.69657713",
"0.69578165",
"0.6910411",
"0.6909373",
"0.68731725",
"0.6871654",
"0.6822542",
"0.6810818",
"0.6787486",
"0.6785412"... | 0.0 | -1 |
PUT /comments/1 PUT /comments/1.json | def update
redirect_to "/home/index"
#@comment = Comment.find(params[:id])
#respond_to do |format|
#if @comment.update_attributes(params[:comment])
#format.html { redirect_to @comment, notice: 'Comment was successfully updated.' }
#format.json { head :ok }
#else
#format.h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def update\n @comment = Comment.find(params[:comment_id])\n @comment.update(comment_params)\n render json: @comme... | [
"0.74237627",
"0.72877294",
"0.72015166",
"0.7041067",
"0.7038625",
"0.7016224",
"0.6951647",
"0.6932251",
"0.69247323",
"0.6889922",
"0.68619525",
"0.6827522",
"0.6823996",
"0.6765764",
"0.6764756",
"0.6764756",
"0.67415977",
"0.66934323",
"0.6693032",
"0.6677461",
"0.664950... | 0.62886804 | 91 |
DELETE /comments/1 DELETE /comments/1.json | def destroy
redirect_to "/home/index"
#@comment = Comment.find(params[:id])
#respond_to do |format|
#format.html { redirect_to comments_url }
#format.json { head :ok }
#end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @comment.destroy\n render json: @comment, status: :ok\n\n end",
"def destroy\n @comment1 = Comment1.find(params[:id])\n @comment1.destroy\n\n respond_to do |f... | [
"0.75611866",
"0.74358994",
"0.73740494",
"0.73681736",
"0.7359092",
"0.7355231",
"0.7294599",
"0.7294599",
"0.727844",
"0.7270565",
"0.72603524",
"0.72603524",
"0.72603524",
"0.72558737",
"0.72558737",
"0.72558737",
"0.7241665",
"0.7240772",
"0.7240202",
"0.7240202",
"0.7240... | 0.69425315 | 80 |
TODO: caching (like etags and stuff) | def getRoutes
# [["MTA NYCT_B65", "B65", "Downtown Brooklyn - Crown Heights", "via Bergen St & Dean St"]...]
url = "http://bustime.mta.info/api/where/routes-for-agency/MTA%20NYCT.xml?key=#{APIKEY}"
xml_str = Net::HTTP.get URI(url)
xml = Nokogiri::XML(xml_str)
xml.css("response data list route").to_a.map{|rte|... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_tags\n self[:tag_s] = self.tags.collect{|tag| tag.pattern}.reject{|p| p.starts_with?('wait') }.sort.join(' ')\n end",
"def cache_tags\n self[:tag_s] = self.tags.collect{|tag| tag.pattern}.reject{|p| p.starts_with?('wait') }.sort.join(' ')\n end",
"def extract_tags!\n @tagmap = {}\n ... | [
"0.63389456",
"0.63389456",
"0.60042936",
"0.59716046",
"0.5962481",
"0.5948608",
"0.5901294",
"0.58995426",
"0.57903916",
"0.5781116",
"0.57682556",
"0.57682556",
"0.57682556",
"0.57682556",
"0.57682556",
"0.5755753",
"0.5748969",
"0.5739459",
"0.5739459",
"0.57206833",
"0.5... | 0.0 | -1 |
Argument: integer, number Side effects: None Return value: Boolean. true if argument is prime, false otherwise. Edge cases: prime?(1) prime?(2) Algorithm: number <= argument 1) is_prime = true 2) for all integers between 2 and (number 1): |index| check whether number is divisible by index if it is, then: is_prime = fal... | def prime?(number)
return false if number == 1
2.upto(number - 1) do |index|
return false if number % index == 0
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PrimeNumber?(number)\n return false if number<2 || number%2 ==0\n (3..number-1).select(&:odd?).each do |i|\n return false if number%i == 0\n end\n true\nend",
"def prime?(number)\n if number > 1 \n number_range = (2..number-1).to_a\n number_range.detect{ |test_number| number % test_number == 0} ... | [
"0.85317254",
"0.84911567",
"0.84838957",
"0.8461209",
"0.841997",
"0.84190595",
"0.84190595",
"0.8414049",
"0.8408009",
"0.8393138",
"0.8391178",
"0.8381351",
"0.8378008",
"0.8378008",
"0.8378008",
"0.83719385",
"0.8366088",
"0.836071",
"0.8359709",
"0.8347902",
"0.8341994",... | 0.8473722 | 3 |
Each subarray will have strings which are anagrams of each other Time Complexity: O(n) if you pretend line 12 is a simple mathematically based hashing function, probably O (n n log n) as for each string you have to sort the string to get a key for the hash. Space Complexity: O(n) worst case is one string to one key, wh... | def grouped_anagrams(strings)
string_hash = {}
strings.each do |string|
key = string.split("").sort.join # probably an O(n log n) operation, I couldn't find an integer based hashing function i liked
string_hash[key] ||= [] # trying this thing out
string_hash[key] << string
end
return string_has... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_anagrams(arr)\n hash = Hash.new { |h, k| h[k] = [] }\n arr.each do |str|\n hash[str.chars.sort] << str\n end\n\n hash.values.map(&:sort)\nend",
"def anagrams(array_of_words)\n ana_hash = Hash.new { |hash, key| hash[key] = [] }\n array_of_words.each { |word| ana_hash[word.split(\"\").sort.join]... | [
"0.79885423",
"0.7935334",
"0.7923127",
"0.7874945",
"0.7807073",
"0.7719393",
"0.7689198",
"0.76115584",
"0.7574334",
"0.7565763",
"0.755894",
"0.755675",
"0.7552811",
"0.7519341",
"0.7513236",
"0.7502722",
"0.74964917",
"0.7465122",
"0.7446689",
"0.744336",
"0.74047935",
... | 0.7949817 | 1 |
This method will return the k most common elements in the case of a tie it will select the first occuring element. Time Complexity: O(n) First runs through length of list, then all elements in list via list param, then all hash objects in hash, then another array with size of list sequentially, which adds up to O(3n) o... | def top_k_frequent_elements(list, k)
return [] if list.empty?
# list tracking quantities
total_ele = list.length # O(n) operation
return list if total_ele == 1
top_k = Array.new(total_ele + 1){[]} # plus one for better tracking
count_hash = {}
# get frequencies of each element, O(n)
list.each do |e|
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_k_frequent_elements(list, k)\n\n return [] if list.empty?\n \n # create a hash that has each element as key and number of occurrences as value: [1, 1, 1, 2, 2, 3] => {1=>3, 2=>2, 3=>1}\n hash = {}\n list.each do |element|\n if hash[element].nil?\n hash[element] = 1\n else \n hash[eleme... | [
"0.8200631",
"0.8159024",
"0.8084402",
"0.7990214",
"0.7959866",
"0.7956065",
"0.7918516",
"0.79163265",
"0.79089487",
"0.7906697",
"0.7893889",
"0.7865139",
"0.78523624",
"0.78516424",
"0.7837732",
"0.7833812",
"0.78095806",
"0.7793178",
"0.77845746",
"0.777552",
"0.7762357"... | 0.77806693 | 19 |
This method will return the true if the table is still a valid sudoku table. Each element can either be a ".", or a digit 19 The same digit cannot appear twice or more in the same row, column or 3x3 subgrid Time Complexity: I want to say this is O(1) since the number of elements in a 3x3 grid you have to check is alway... | def valid_sudoku(table)
sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {},
[1, 0] => {}, [1, 1] => {}, [1, 2] => {},
[2, 0] => {}, [2, 1] => {}, [2, 2] => {}}
sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {},
4 => {}, 5 => {}, 6 => {},
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_sudoku(table)\n # edge cases\n return false if table.nil? || table.size != 9 || table[0].size != 9\n # 3 new storages will count number of occurances of each element for columns, rows and sub-boxes\n rows = Array.new(9)\n i = 0\n while i < rows.size\n rows[i] = {\"1\"=>0,\"2\"=>0,\"3\"=>0,\"4\"=... | [
"0.8122185",
"0.8087225",
"0.80445236",
"0.8037947",
"0.8000477",
"0.7858658",
"0.7618002",
"0.751144",
"0.74835074",
"0.71662134",
"0.6996734",
"0.6786182",
"0.6760026",
"0.6748393",
"0.6654424",
"0.6517259",
"0.6499932",
"0.64429265",
"0.6407294",
"0.64067",
"0.6398252",
... | 0.8228795 | 0 |
GET /sales GET /sales.json | def index
@sales = Sale
.where("EXTRACT(MONTH FROM transaction_date)=EXTRACT(MONTH FROM CURRENT_DATE) AND EXTRACT(YEAR FROM transaction_date)=EXTRACT(YEAR FROM CURRENT_DATE)")
.order(:created_at).reverse_order
.pagination(params[:page])
@customers = Customer.order(:name)
respond_to do |format|... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sales = Sale.all\n\n render json: @sales\n end",
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def show\n render json: @invoice, methods: [:sales]\n end",
"def show\n render json: @sale\n end",
"def index\n @sales = Sale.all\n end",
"def index\... | [
"0.8167744",
"0.81421864",
"0.7505555",
"0.734486",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.7266149",
"0.72475237",
"0.72210985",
"0.7124364",
"0.70870465",
"0.70870465",
"0.70577073",
"0.7030278",
"0.7018311",
"0.7000222",
"0.695755",... | 0.6918693 | 21 |
GET /sales/1 GET /sales/1.json | def show
@sale = Sale.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sale }
format.pdf do
pdf = SaleIndividualPdf.new(@sale.id, view_context, ApplicationController.helpers.get_company_identity)
send_data pdf.render, filename: "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sales = Sale.all\n\n render json: @sales\n end",
"def index\n @sales = @saleService.all_to_json().as_json;\n end",
"def show\n render json: @invoice, methods: [:sales]\n end",
"def show\n render json: @sale\n end",
"def show\n @sale = Sale.find(params[:id])\n\n res... | [
"0.7998383",
"0.7861703",
"0.7389379",
"0.73709834",
"0.7334243",
"0.7334243",
"0.7176787",
"0.71458316",
"0.70973235",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.7082648",
"0.69916207",
"0.6967121",
"0.69211215",
"0.6917201",
"0.68852955... | 0.0 | -1 |
GET /sales/new GET /sales/new.json | def new
@sale = Sale.new
respond_to do |format|
format.html
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"def new\n @sale = Sale.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sale }\n end\n end",
"d... | [
"0.8026322",
"0.8026322",
"0.8026322",
"0.7617632",
"0.7348117",
"0.7332829",
"0.7321252",
"0.7276389",
"0.7250406",
"0.7248883",
"0.71988344",
"0.7197199",
"0.7196902",
"0.71611774",
"0.7089569",
"0.70761955",
"0.70761955",
"0.70761955",
"0.7022161",
"0.7003506",
"0.6946766"... | 0.7193064 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.