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 |
|---|---|---|---|---|---|---|
multiple full wallets => user address + residual + fee | def generate_withdrawal_transaction(exported_order)
tx = build_tx do |t|
input_amount = generate_inputs(t, exported_order)
validate_input_amount(input_amount, exported_order)
generate_withdrawal_output(t, exported_order)
generate_residual_output(t, input_amount, exported_order)
end
Base64.encode64(tx.to_payload)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_response(user)\n res = {email: user.email, wallets:[]}\n user.wallets.each{|wallet| res[:wallets] << { id: wallet.id, balance: wallet.display_balance, currency: wallet.balance_currency}}\n res\n end",
"def give_coins(from_addr, to_addr, coins, acc_balances)\n acc_balances[from_addr] = acc_bal... | [
"0.6424103",
"0.5942975",
"0.5940175",
"0.58603626",
"0.58356076",
"0.5773518",
"0.5760219",
"0.5751896",
"0.57362014",
"0.57227135",
"0.5708556",
"0.56459296",
"0.55991626",
"0.558161",
"0.5570114",
"0.5532367",
"0.5521252",
"0.55207366",
"0.55169135",
"0.55057484",
"0.55047... | 0.0 | -1 |
Internal: For a given +point+ in time, calculates the load which should be handled by transient energy producers, and assigns the calculated values to the producer's load curve. This is the "jumping off point" for calculating the merit order, and note that the method is called once per Merit::POINT. Since Calculator computes a value for every point (default 8,760 of them) even tiny changes can have large effects on the time taken to run the calculation. Therefore, always benchmark / profile your changes! order The Merit::Order being calculated. point The point in time, as an integer. Should be a value between zero and Merit::POINTS 1. producers An object supplying the always_on and transient producers. Returns nothing. | def compute_point(order, point, producers)
# Optimisation: This is order-dependent; it requires that always-on
# producers are before the transient producers, otherwise "remaining"
# load will not be correct.
#
# Since this method is called a lot, being able to handle always-on and
# transient producers in separate loops allows us to skip calling
# #always_on? in every iteration. This accounts for a 20% reduction in
# the calculation runtime.
if (remaining = demand(order, point)) < 0
raise SubZeroDemand.new(point, remaining)
end
producers.always_on(point).each do |producer|
remaining -= producer.max_load_at(point)
end
# Ignore the possibility for a Resortable to be delivered as the third
# method argument. We're going to resort the transients anyway.
transients = order.participants.transients(point)
.sort_by { |transient| Convergence.producer_cost(transient, point) }
while producer = transients.shift do
max_load = producer.max_load_at(point)
# Optimisation: Load points default to zero, skipping to the next
# iteration is faster then running the comparison / load_curve#set.
next if max_load.zero?
current = producer.load_curve.get(point)
headroom = max_load - current
chunk = producer.output_capacity_per_unit
remaining = 0 if remaining < 1e-10
next if headroom.zero?
if headroom <= remaining && headroom < chunk
# Strangely the producer has less than one unit of capacity left. We
# assign it to the maximum load.
add_load(producer, point, headroom)
remaining -= headroom
elsif remaining > chunk
# Assign load equal to the size of one plant.
add_load(producer, point, chunk)
remaining -= chunk
# Add the plant back to the collection. Determining the index of the
# first producer which is more expensive -- and inserting before
# that producer -- is 2x faster than resorting the list entirely.
insert_at = transients.index do |other|
Convergence.producer_cost(other, point) >=
Convergence.producer_cost(producer, point)
end
transients.insert(insert_at || transients.length, producer)
else
# There is less total load remaining to be assigned than the
# capacity of a new plant.
add_load(producer, point, remaining) if remaining > 0
assign_price_setting(order, producer, point)
# Optimisation: If all of the demand has been accounted for, there
# is no need to waste time with further iterations and expensive
# calls to Producer#max_load_at.
break
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_point(order, point, participants)\n if (demand = demand_at(order, point)).negative?\n raise SubZeroDemand.new(point, demand)\n end\n\n demand = compute_always_ons(\n point, demand,\n participants.always_on,\n participants.flex.at_point(point)\n )\n\n ... | [
"0.6321755",
"0.60812825",
"0.5981526",
"0.59455174",
"0.58839643",
"0.58198434",
"0.58046997",
"0.56684047",
"0.5536908",
"0.54751503",
"0.534222",
"0.52027094",
"0.51183224",
"0.50811666",
"0.5038798",
"0.501111",
"0.49826777",
"0.49811327",
"0.497791",
"0.49714407",
"0.494... | 0.76092327 | 0 |
Some methods require full username and password rather than just auth token | def fully_authed?
!(user.nil? || password.nil?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_auth(*args, &block); end",
"def token\n authenticate_with_http_basic do |username, password|\n\n user = User.find_by(username: username)\n if user && user.password == password\n render json: { token: user.token }\n else\n render json: { error: 'Incorrect credentials' }, ... | [
"0.7508128",
"0.7461789",
"0.7455585",
"0.7402264",
"0.73788977",
"0.7351924",
"0.734027",
"0.7333475",
"0.7330807",
"0.7279449",
"0.7247431",
"0.7243605",
"0.7224711",
"0.72111505",
"0.71989",
"0.71882564",
"0.7147553",
"0.71340126",
"0.7132361",
"0.7130672",
"0.7103286",
... | 0.0 | -1 |
create a new secondary_publication_number | def create
@secondary_publication_number = SecondaryPublicationNumber.new(params[:secondary_publication_number])
@secondary_publication_number.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @secondary_publication_number = SecondaryPublicationNumber.find(params[:id])\n\t@secondary_publication_number.update_attributes(params[:secondary_publication_number])\n end",
"def create\n\t@secondary_publication = SecondaryPublication.new(params[:secondary_publication])\n \t@secondary_publicati... | [
"0.66986525",
"0.6678229",
"0.66055155",
"0.6441804",
"0.6333184",
"0.59490246",
"0.5908597",
"0.560981",
"0.5555847",
"0.55500203",
"0.5516568",
"0.55064684",
"0.5495526",
"0.54855627",
"0.54673856",
"0.5450609",
"0.5412726",
"0.5382135",
"0.53705555",
"0.535286",
"0.5335613... | 0.8264091 | 0 |
update an existing secondary_publication_number | def update
@secondary_publication_number = SecondaryPublicationNumber.find(params[:id])
@secondary_publication_number.update_attributes(params[:secondary_publication_number])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @primary_publication_number = PrimaryPublicationNumber.find(params[:id])\n\n respond_to do |format|\n if @primary_publication_number.update_attributes(params[:primary_publication_number])\n format.html { redirect_to(@primary_publication_number, :notice => 'Primary publication number ... | [
"0.6854728",
"0.67690563",
"0.67131823",
"0.6328336",
"0.6055101",
"0.5972203",
"0.57662684",
"0.57261705",
"0.5677576",
"0.5607939",
"0.5600554",
"0.55821013",
"0.5572911",
"0.5495879",
"0.5495429",
"0.5473304",
"0.54580295",
"0.5451855",
"0.54463845",
"0.5443153",
"0.543836... | 0.8558592 | 0 |
destroy the secondary_publication_number with id = params[:id] | def destroy
thisNumber = SecondaryPublicationNumber.find(params[:id])
thisNumber.destroy
@secondary_publications = @study.get_secondary_publications(params[:extraction_form_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @primary_publication_number = PrimaryPublicationNumber.find(params[:id])\n @primary_publication_number.destroy\n\n respond_to do |format|\n format.html { redirect_to(primary_publication_numbers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @publication_num... | [
"0.80431896",
"0.79194057",
"0.77324915",
"0.74989593",
"0.74416924",
"0.72103095",
"0.70939016",
"0.70771974",
"0.69101995",
"0.6900275",
"0.68852246",
"0.67765635",
"0.6715107",
"0.66988254",
"0.6673118",
"0.6650622",
"0.66505426",
"0.6644315",
"0.6644315",
"0.6644315",
"0.... | 0.8735176 | 0 |
create a new secondary publication number | def new
@secondary_publication_number = SecondaryPublicationNumber.new
@secondary_publication_number.save
@study = Study.find(params[:study_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @secondary_publication_number = SecondaryPublicationNumber.new(params[:secondary_publication_number])\n\t@secondary_publication_number.save\n end",
"def update\n @secondary_publication_number = SecondaryPublicationNumber.find(params[:id])\n\t@secondary_publication_number.update_attributes(par... | [
"0.7821808",
"0.652723",
"0.6334438",
"0.62523",
"0.6138741",
"0.6051078",
"0.5921318",
"0.58881074",
"0.5673987",
"0.5639798",
"0.5617764",
"0.5617585",
"0.55672526",
"0.5545342",
"0.55273485",
"0.54887897",
"0.5443621",
"0.54332507",
"0.5428697",
"0.53808475",
"0.537051",
... | 0.6519648 | 2 |
this will be overriden by csv uploads if the file has the overriden date in it | def update_base_price
@calendar = Calendar.find_by(date: params[:date][:date])
@calendar.base_value = params[:cost][:cost]
@calendar.save
UpdatePrice.update_calendar_item(@calendar)
redirect_to admin_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUploadedDateFormat(uploadedDateFormat)\r\n\t\t\t\t\t@uploadedDateFormat = uploadedDateFormat\r\n\t\t\t\tend",
"def file_datetime\n @file_datetime\n end",
"def setUploadedDate(uploadedDate)\r\n\t\t\t\t\t@uploadedDate = uploadedDate\r\n\t\t\t\tend",
"def save_to_dropbox_only_on_date_chan... | [
"0.6413626",
"0.64014226",
"0.6307236",
"0.61452013",
"0.61316615",
"0.61126953",
"0.60991704",
"0.6078403",
"0.60653466",
"0.6032585",
"0.602153",
"0.6009576",
"0.5981251",
"0.59667706",
"0.5926942",
"0.5885968",
"0.58296746",
"0.5812186",
"0.5793294",
"0.5693234",
"0.566474... | 0.0 | -1 |
GET /product_cates GET /product_cates.json | def index
@product_cates = ProductCate.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @crates = Crate.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crates }\n end\n end",
"def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n ... | [
"0.635632",
"0.61790925",
"0.61187536",
"0.61152655",
"0.60723484",
"0.60031974",
"0.5997642",
"0.5995273",
"0.5953059",
"0.5925261",
"0.59197694",
"0.5915861",
"0.588498",
"0.5865731",
"0.5847437",
"0.5837887",
"0.58280647",
"0.5827365",
"0.5813459",
"0.5810902",
"0.5791068"... | 0.7525631 | 0 |
GET /product_cates/1 GET /product_cates/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @product_cates = ProductCate.all\n end",
"def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n ... | [
"0.72052526",
"0.64012355",
"0.62206465",
"0.607359",
"0.6059173",
"0.6050131",
"0.60356826",
"0.60250694",
"0.6020901",
"0.5984413",
"0.5976167",
"0.5973951",
"0.59602493",
"0.5946021",
"0.5932691",
"0.59313977",
"0.59236753",
"0.59057844",
"0.5895616",
"0.58921534",
"0.5891... | 0.0 | -1 |
POST /product_cates POST /product_cates.json | def create
@product_cate = ProductCate.new(product_cate_params)
respond_to do |format|
if @product_cate.save
format.html { redirect_to @product_cate, notice: 'Product cate was successfully created.' }
format.json { render :show, status: :created, location: @product_cate }
else
format.html { render :new }
format.json { render json: @product_cate.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @product_cates = ProductCate.all\n end",
"def create\n @candies_product = CandiesProduct.new(candies_product_params)\n\n respond_to do |format|\n if @candies_product.save\n format.html { redirect_to @candies_product, notice: 'Candies product was successfully created.' }\n ... | [
"0.6179065",
"0.6047354",
"0.58769214",
"0.58728254",
"0.58627504",
"0.5812873",
"0.5778166",
"0.56561",
"0.56438977",
"0.5642931",
"0.563476",
"0.562332",
"0.5602068",
"0.5562614",
"0.5558732",
"0.5547944",
"0.5540008",
"0.55357414",
"0.55110925",
"0.5501101",
"0.550062",
... | 0.66350067 | 0 |
PATCH/PUT /product_cates/1 PATCH/PUT /product_cates/1.json | def update
respond_to do |format|
if @product_cate.update(product_cate_params)
format.html { redirect_to @product_cate, notice: 'Product cate was successfully updated.' }
format.json { render :show, status: :ok, location: @product_cate }
else
format.html { render :edit }
format.json { render json: @product_cate.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @contract_product.update_attributes(params[:contract_product])\n format.html { redirect_to @contract_product, notice: 'Contract product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"... | [
"0.639863",
"0.62911946",
"0.62647307",
"0.6262825",
"0.62416273",
"0.6198839",
"0.6180561",
"0.6176916",
"0.61735255",
"0.6131851",
"0.6123692",
"0.6112642",
"0.6085035",
"0.6079833",
"0.6065551",
"0.6054328",
"0.60374725",
"0.60122794",
"0.6012121",
"0.6010751",
"0.60007423... | 0.6227128 | 5 |
DELETE /product_cates/1 DELETE /product_cates/1.json | def destroy
@product_cate.destroy
respond_to do |format|
format.html { redirect_to product_cates_url, notice: 'Product cate was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @product.destroy\n\n render json: @product, status: :ok#, location: @collection\n end",
"def destroy\n @product.destroy\n render json: {}\n end",
"def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\n end",
"def destroy\n @purchase.destroy... | [
"0.6717103",
"0.66579306",
"0.6639093",
"0.66334236",
"0.6604102",
"0.6576996",
"0.6570536",
"0.65475726",
"0.65408087",
"0.65389717",
"0.6515142",
"0.65117294",
"0.65108854",
"0.65104043",
"0.6507789",
"0.6505897",
"0.6497713",
"0.6489978",
"0.6483425",
"0.6475791",
"0.64581... | 0.69883144 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_product_cate
@product_cate = ProductCate.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def product_cate_params
params.require(:product_cate).permit(:name, :product_cate_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
arr_1 = [ ["a", "b", "c"], ["d", "e", "f"], ["g", "h", "i"] ] expected_1 = [ ["a", "d", "g"], ["b", "e", "h"], ["c", "f", "i"] ] | def my_transpose
ret = []
i=0
while i < self.length
j=0
ret2 = []
while j < self[i].length
ret2 << self[j][i]
j += 1
end
ret << ret2
i += 1
end
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(arr1, arr2)\n new_array = []\n arr2.each { |e| arr1 << e} \n arr1.each { |e| new_array << e unless new_array.include?(e)}\n new_array\nend",
"def custom_zip(arr1, arr2)\n final=[]\n arr1.each_with_index do |item, index|\n nested_array= []\n arr2.each_with_index do |item2, index2|\n i... | [
"0.6332554",
"0.6311515",
"0.6305388",
"0.62789583",
"0.6255395",
"0.6254024",
"0.62375754",
"0.62201613",
"0.615454",
"0.61422014",
"0.61388826",
"0.61375445",
"0.6132739",
"0.6127048",
"0.6112288",
"0.61070293",
"0.6104327",
"0.61003363",
"0.6088657",
"0.60740775",
"0.60608... | 0.0 | -1 |
def update like = Like.find(params[:id]) like.update_attributes(like_params) render json: like end | def destroy
authenticate!
if Dislike.find(params[:id]).user_id == current_user.id
Dislike.destroy(params[:id])
render json: { message: 'Item deleted' }
else
render:json => { :msg => "Dislike deletion failed.." }, :status => :bad_request
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Like.update(params[\"id\"], params[\"like\"])\n end",
"def update\n respond_to do |format|\n if @like.update(like_params)\n format.json { render json: @like, status: :ok }\n else\n format.json { render json: @like.errors, status: :unprocessable_entity }\n ... | [
"0.9527674",
"0.8961223",
"0.86984545",
"0.84735143",
"0.843261",
"0.8423937",
"0.8280598",
"0.8167784",
"0.8121424",
"0.8084288",
"0.7982549",
"0.7857411",
"0.7797125",
"0.7784984",
"0.777795",
"0.77765286",
"0.77279323",
"0.76378053",
"0.7630234",
"0.76281214",
"0.7558547",... | 0.0 | -1 |
Some order attribute might be short alias. | def convert_sort_order(order)
return nil if order.blank?
o = order.clone
SORT_ORDER_ALIASES.each_pair do|value_alias, real_value|
o.gsub!(value_alias, real_value)
end
o
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attrs_to_orderings(order)\n order.map do |o|\n Arel::Attribute === o ? o.asc : o\n end\n end",
"def common_name(tax_order = T.unsafe(nil)); end",
"def ordered_by(attribute_name)\n ordering[attribute_name]\n end",
"def build_order\n\t\t\tp = params.permit(:terms, :o... | [
"0.6177322",
"0.58498573",
"0.5814641",
"0.58099926",
"0.5791551",
"0.57220495",
"0.56635547",
"0.560482",
"0.5595079",
"0.55911016",
"0.5572567",
"0.5490295",
"0.5467577",
"0.5404054",
"0.537944",
"0.5378396",
"0.53201354",
"0.5293043",
"0.52819616",
"0.5271521",
"0.5266979"... | 0.5463952 | 13 |
method should return new scope based on base_scope | def get_conditions_for(base_scope, query)
unless query.blank?
base_scope = base_scope.like_any([:name, :description], query.split)
end
base_scope
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inherit_scope(other)\n @scope = other.scope\n end",
"def scope\n @scope.dup\n end",
"def scope( new_scope=nil )\n\t\tif new_scope\n\t\t\tself.log.debug \"cloning %p with new scope: %p\" % [ self, new_scope ]\n\t\t\treturn self.clone( :scope => new_scope.to_sym )\n\t\telse\n\t\t\treturn @options... | [
"0.7404326",
"0.7391623",
"0.71096414",
"0.69901305",
"0.6923455",
"0.6903669",
"0.6903669",
"0.6903669",
"0.6903669",
"0.6903669",
"0.6903669",
"0.6903669",
"0.6903669",
"0.6903669",
"0.6903669",
"0.69012696",
"0.68939453",
"0.68583786",
"0.68343097",
"0.6826762",
"0.6826762... | 0.0 | -1 |
Add or change an asset id in the asset id cache. This can be used for SASS on Heroku. :api: public | def add_to_asset_ids_cache(source, asset_id)
self.asset_ids_cache_guard.synchronize do
self.asset_ids_cache[source] = asset_id
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rails_asset_id(source)\n if asset_id = ENV[\"RAILS_ASSET_ID\"]\n asset_id\n else\n if self.cache_asset_ids && (asset_id = self.asset_ids_cache[source])\n asset_id\n else\n path = File.join(config.assets_dir, source)\n ass... | [
"0.69767493",
"0.6781146",
"0.67287135",
"0.65945554",
"0.60452086",
"0.60452086",
"0.60452086",
"0.60452086",
"0.60452086",
"0.60452086",
"0.60452086",
"0.60411817",
"0.6000291",
"0.59650934",
"0.591125",
"0.5885534",
"0.58758545",
"0.5866846",
"0.5865538",
"0.57829213",
"0.... | 0.7340529 | 0 |
Break out the asset path rewrite in case plugins wish to put the asset id someplace other than the query string. | def rewrite_asset_path(source, dir)
source = "/#{dir}/#{source}" unless source[0] == ?/
path = config.asset_path
if path && path.respond_to?(:call)
return path.call(source)
elsif path && path.is_a?(String)
return path % [source]
end
asset_id = rails_asset_id(source)
if asset_id.empty?
source
else
"#{source}?#{asset_id}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rewrite_asset_path(source)\n asset_id = rails_asset_id(source)\n if asset_id.blank?\n source\n else\n source + \"?#{asset_id}\"\n end\n end",
"def rewrite_asset_path(source, path = nil)\n if path && path.respond_to?(:call)\n return ... | [
"0.71739924",
"0.6779412",
"0.63515854",
"0.62743807",
"0.62141544",
"0.6133092",
"0.6133092",
"0.61316854",
"0.60997885",
"0.59017044",
"0.58894795",
"0.5798455",
"0.5776646",
"0.57129055",
"0.569508",
"0.568026",
"0.5677606",
"0.56591713",
"0.56591713",
"0.5656027",
"0.5643... | 0.6486046 | 2 |
Use the RAILS_ASSET_ID environment variable or the source's modification time as its cachebusting asset id. | def rails_asset_id(source)
if asset_id = ENV["RAILS_ASSET_ID"]
asset_id
else
if self.cache_asset_ids && (asset_id = self.asset_ids_cache[source])
asset_id
else
path = File.join(config.assets_dir, source)
asset_id = File.exist?(path) ? File.mtime(path).to_i.to_s : ''
if self.cache_asset_ids
add_to_asset_ids_cache(source, asset_id)
end
asset_id
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rails_asset_id(source)\n if asset_id = ENV[\"RAILS_ASSET_ID\"]\n asset_id\n else\n if @@cache_asset_timestamps && (asset_id = @@asset_timestamps_cache[source])\n asset_id\n else\n path = File.join(ASSETS_DIR, source)\n as... | [
"0.8229946",
"0.80967784",
"0.767262",
"0.6382397",
"0.6202062",
"0.6140736",
"0.6091757",
"0.6080483",
"0.6036446",
"0.60274965",
"0.59639984",
"0.5930305",
"0.5925075",
"0.58463526",
"0.5827893",
"0.58017486",
"0.5710232",
"0.56980085",
"0.5689497",
"0.56597155",
"0.5632776... | 0.7859806 | 2 |
Sort talks in descending order by duraion Find number of tracks needed, since we know the total duraion exactly And intialize tracks As per the Best fit algorithm, Fill each tracks by looping through sorted talks Do this till available talks become empty | def schedule_talks
until available_talks.empty?
Track.all.each do |track|
schedule_talks_for_track(track)
# When a track didn't fill exactly
# Removing already scheduled last element from track and
# Again trying for a exact match on available talks
# Not a perfect solution, But, It produces better result
# Kind of backtracking
backtrack_and_schedule_talks_for_track(track)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pack_talks\n\n @tracks << Track.new() # create first [0] Track object\n x = 0 # first object @tracks[0]\n\n @talks.each do |talk|\n\n # if it's morning session, set limit to 180min, otherwise to 240min\n len = get_max_length(x)\n\n # if the sum of Track's total length + current talk's l... | [
"0.66730255",
"0.6115911",
"0.605454",
"0.5993541",
"0.5781465",
"0.5744241",
"0.5714921",
"0.569363",
"0.5466948",
"0.54645944",
"0.53755265",
"0.536268",
"0.5361759",
"0.532656",
"0.5316245",
"0.5231652",
"0.523097",
"0.52071446",
"0.51980644",
"0.5172707",
"0.5172007",
"... | 0.617165 | 1 |
Function for logging the response of a stripe request | def stripe_handler
begin
result = yield
rescue Stripe::CardError, # Most common error, occurs when card cannot be charged
Stripe::RateLimitError, # Too many requests hit the API too quickly
Stripe::InvalidRequestError, # The request has invalid params
Stripe::AuthenticationError, # Failed to authenticate with stripes api
Stripe::APIConnectionError, # Failed to connect to stripes api
Stripe::StripeError => e # Generic stripe error
if e.json_body
error = {error: e.json_body[:error], status: e.http_status}
else
error = {error: e.message}
end
rescue => e
# Something else happened, completely unrelated to Stripe
Rails.logger.info "500 error"
Rails.logger.info e.message
Rails.logger.info e.backtrace
error = {error: "err_not_stripe"} # The error was not generated by stripe
end
# Return the result or error from the request
return result || error
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_response\n log \"SOAP response (status #{@response.code}):\"\n log @response.body\n end",
"def log_response_details(event)\n env = event.payload\n\n if env.response.nil?\n return error do\n \"[#{req_id(env)}] #{req_dest(env)} < #{res_result(env)}\"\n ... | [
"0.6674754",
"0.6652176",
"0.6446578",
"0.6410689",
"0.64049375",
"0.6279385",
"0.625225",
"0.61161417",
"0.6113425",
"0.60278785",
"0.6017588",
"0.60124356",
"0.60124356",
"0.6006889",
"0.59678406",
"0.5931649",
"0.5894964",
"0.5890001",
"0.5889774",
"0.58886933",
"0.5857757... | 0.5490677 | 40 |
Run a process ==== Exception Delayer::TooLate :: if already called run() ==== Return node | def run
unless @state == :stop
raise Delayer::StateError(@state), 'call twice Delayer::Procedure'
end
@state = :run
@proc&.call
@state = :done
@proc = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(node)\n process(node)\n end",
"def run\n info \"Run on node: #{node}\"\n self.status = :running\n node.run self\n end",
"def call\n process\n end",
"def run() end",
"def process_node(node)\n debug \"Process node: #{node}\"\n node.poll\n return unless... | [
"0.71472347",
"0.671742",
"0.60097736",
"0.59764075",
"0.594567",
"0.5941387",
"0.5941387",
"0.5877264",
"0.58155787",
"0.5795012",
"0.57657444",
"0.5727921",
"0.5712136",
"0.5694673",
"0.56898296",
"0.56442374",
"0.5635464",
"0.5593424",
"0.5576404",
"0.5565107",
"0.5563955"... | 0.5646955 | 15 |
Cancel this job ==== Exception Delayer::TooLate :: if already called run() ==== Return self | def cancel
unless @state == :stop
raise Delayer::StateError(@state), 'cannot cancel Delayer::Procedure'
end
@state = :cancel
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel\n return unless incomplete?\n\n # Set the stop flag for all cases.\n self.stop = true\n\n # If the run has a delayed job and it hasn't been locked yet, or it\n # has failed, then we just remove it from the queue directly and\n # mark the run as cance... | [
"0.7778178",
"0.73169965",
"0.7253018",
"0.71046746",
"0.6886759",
"0.6873432",
"0.68421346",
"0.6818729",
"0.6818729",
"0.68068725",
"0.6789899",
"0.674981",
"0.6724411",
"0.66926473",
"0.66926473",
"0.66926473",
"0.66580236",
"0.66544974",
"0.6647577",
"0.6620655",
"0.66133... | 0.6975411 | 4 |
Return true if canceled this task ==== Return true if canceled this task | def canceled?
@state == :cancel
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canceled?\n @__status == TaskStatus::CANCELED\n end",
"def cancelled?\n false\n end",
"def canceled?\n @current_state == Psc::ScheduledActivity::CANCELED\n end",
"def cancelled?\n return self.status == 'canceled'\n end",
"def rejected?\n self.status == Task::S... | [
"0.8562416",
"0.7738751",
"0.7672849",
"0.7612788",
"0.7597592",
"0.7509902",
"0.74425554",
"0.74425554",
"0.7420871",
"0.73126084",
"0.7265805",
"0.71293604",
"0.7126879",
"0.7091618",
"0.7024011",
"0.7016525",
"0.7013392",
"0.7001374",
"0.6988741",
"0.69690067",
"0.6925201"... | 0.7894771 | 1 |
insert node between self and self.next ==== Args [node] insertion ==== Return node | def break(node)
tail = @next
@next = node
node.next = tail
node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_after_node(node, to_insert)\n return unless node\n\n new_node = Node.new(to_insert, node, node.next)\n\n if node.next\n node.next.prev = new_node\n end\n\n if node == @tail\n @tail = new_node\n end\n\n node.next = new_node\n @length += 1\n return new_node\n end",
... | [
"0.7488942",
"0.7483634",
"0.74735194",
"0.7460311",
"0.7460311",
"0.7416949",
"0.71785975",
"0.71664536",
"0.71119",
"0.70905745",
"0.7068291",
"0.7030186",
"0.6966358",
"0.6958689",
"0.69403976",
"0.6927717",
"0.69160783",
"0.69002104",
"0.68977463",
"0.6720663",
"0.6717468... | 0.0 | -1 |
A getter for `gradle_task`, returning 'spotbugsRelease' if value is nil. | def gradle_task
@gradle_task ||= 'spotbugsRelease'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradle_task\n @gradle_task ||= \"ktlintCheck\"\n end",
"def get_task(task_name)\n if using_rake? and task_defined?(task_name)\n Rake::Task[task_name]\n end\n end",
"def release\n @release ||= ENV[\"RELEASE\"] || \"1\"\n end",
"def get_release(project)\n info = get... | [
"0.65598345",
"0.59358203",
"0.5737082",
"0.57256067",
"0.56674534",
"0.56023943",
"0.54701036",
"0.54523665",
"0.5441252",
"0.5330394",
"0.5264861",
"0.5240344",
"0.5227098",
"0.5202696",
"0.5185519",
"0.5168148",
"0.5163548",
"0.51371855",
"0.5109742",
"0.50849926",
"0.5075... | 0.838925 | 0 |
A getter for `skip_gradle_task`, returning false if value is nil. | def skip_gradle_task
@skip_gradle_task ||= false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ignore_force?(task)\n !(metadata[\"run_#{task}\"].nil? || metadata[\"run_#{task}\"])\n end",
"def ignore_task?(task)\n return true if metadata[\"run_#{task}\"] == false\n\n !clade? && @@INCLADE_TASKS.include?(task) && metadata[\"run_#{task}\"] != true\n end",
"def should_skip\n @skip = proc... | [
"0.6518595",
"0.64784586",
"0.62998265",
"0.6292668",
"0.6292668",
"0.6292668",
"0.6290563",
"0.62690115",
"0.62614036",
"0.61823386",
"0.61674595",
"0.61668545",
"0.61337686",
"0.6125552",
"0.60769284",
"0.6057696",
"0.6050467",
"0.601239",
"0.59567827",
"0.594658",
"0.59313... | 0.82654464 | 1 |
A getter for `root_path`, returning result of `git revparse showtoplevel` if value is nil. | def root_path
@root_path ||= `git rev-parse --show-toplevel`.chomp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repository_root\n return unless available?\n root = Licensed::Shell.execute(\"git\", \"rev-parse\", \"--show-toplevel\", allow_failure: true)\n return nil if root.empty?\n root\n end",
"def root(value = nil)\n if value\n @root = value\n else\n Utils::K... | [
"0.73593134",
"0.694649",
"0.6865729",
"0.6700843",
"0.66957176",
"0.6623494",
"0.6591485",
"0.6579465",
"0.6552028",
"0.6532682",
"0.64187455",
"0.6401191",
"0.6401191",
"0.6364244",
"0.6355525",
"0.634226",
"0.632569",
"0.6322528",
"0.6319492",
"0.6288777",
"0.6264779",
"... | 0.79346144 | 0 |
A getter for `report_file`, returning 'app/build/reports/spotbugs/release.xml' if value is nil. | def report_file
@report_file ||= 'app/build/reports/spotbugs/release.xml'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_file\n return @report_file || \"build/reports/detekt/detekt.xml\"\n end",
"def report_file\n return @report_file || 'app/build/reports/lint/lint-result.xml'\n end",
"def report_file\n @report_file || 'app/build/reports/ktlint/ktlintSourceSetCheck.json'\n end",
"def test_con... | [
"0.7797677",
"0.71298295",
"0.6664475",
"0.6060904",
"0.6012322",
"0.58259284",
"0.5654273",
"0.56019944",
"0.55606997",
"0.55336714",
"0.54858345",
"0.54858345",
"0.5479988",
"0.54769075",
"0.5468726",
"0.54221344",
"0.5403788",
"0.5374407",
"0.5364477",
"0.5328036",
"0.5310... | 0.84897304 | 0 |
A getter for `report_files`, returning ['app/build/reports/spotbugs/release.xml'] if value is nil. | def report_files
@report_files ||= [report_file]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_file\n @report_file ||= 'app/build/reports/spotbugs/release.xml'\n end",
"def report_file\n return @report_file || \"build/reports/detekt/detekt.xml\"\n end",
"def report_file\n return @report_file || 'app/build/reports/lint/lint-result.xml'\n end",
"def files\n @expor... | [
"0.6313074",
"0.6047547",
"0.5837352",
"0.5810982",
"0.5669092",
"0.56635225",
"0.56498194",
"0.5579815",
"0.5519284",
"0.54893845",
"0.54874134",
"0.54189825",
"0.54014516",
"0.53965956",
"0.53937376",
"0.53611314",
"0.53464466",
"0.53372395",
"0.53268003",
"0.5320092",
"0.5... | 0.75638413 | 0 |
Calls SpotBugs task of your Gradle project. It fails if `gradlew` cannot be found inside current directory. It fails if `report_file` cannot be found inside current directory. It fails if `report_files` is empty. | def report(inline_mode: true)
unless skip_gradle_task
raise('Could not find `gradlew` inside current directory') unless gradlew_exists?
exec_gradle_task
end
report_files_expanded = Dir.glob(report_files).sort
raise("Could not find matching SpotBugs report files for #{report_files} inside current directory") if report_files_expanded.empty?
do_comment(report_files_expanded, inline_mode)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lint\n unless gradlew_exists?\n fail(\"Could not find `gradlew` inside current directory\")\n return\n end\n\n unless SEVERITY_LEVELS.include?(severity)\n fail(\"'#{severity}' is not a valid value for `severity` parameter.\")\n return\n end\n\n system \"./gr... | [
"0.62935215",
"0.52596444",
"0.5257605",
"0.5242235",
"0.5207904",
"0.51342595",
"0.5102762",
"0.5047541",
"0.5025417",
"0.502484",
"0.4963007",
"0.49560726",
"0.49040627",
"0.48541266",
"0.4853064",
"0.48441255",
"0.48112792",
"0.48043206",
"0.47878724",
"0.47822118",
"0.476... | 0.712252 | 0 |
Check gradlew file exists in current directory. | def gradlew_exists?
!`ls gradlew`.strip.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_env_sample_exists\n assert(File.file?('./.env_sample'))\n end",
"def current_folder_has_souffle_config?\n File.exists? \"#{Dir.pwd}/souffle.json\"\n end",
"def gemfile_exists? \n File.exists? \"Gemfile\"\nend",
"def gemfile_exists? \n File.exists? \"Gemfile\"\nend",
"def file_exists?(fil... | [
"0.64557767",
"0.6333179",
"0.6217829",
"0.6217829",
"0.6056618",
"0.605368",
"0.6046435",
"0.6035463",
"0.6017085",
"0.5952188",
"0.5914218",
"0.5913326",
"0.5906898",
"0.5899916",
"0.58908534",
"0.5886532",
"0.5880113",
"0.58728504",
"0.5856368",
"0.5851407",
"0.5849155",
... | 0.8407961 | 0 |
A getter for `spotbugs_report`, returning SpotBugs report. | def spotbugs_report(report_file)
require 'oga'
Oga.parse_xml(File.open(report_file))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_file\n @report_file ||= 'app/build/reports/spotbugs/release.xml'\n end",
"def report\n return @report\n end",
"def bug_report_url()\n LibDrizzle.drizzle_bugreport\n end",
"def show\n @bugs = service_method(:bugs_by_board,boardid: @sprint.team.board_id,s... | [
"0.6322081",
"0.6055198",
"0.57680035",
"0.5750877",
"0.5711777",
"0.564839",
"0.5594099",
"0.5476167",
"0.5461613",
"0.5418667",
"0.5367439",
"0.5357381",
"0.53265905",
"0.5320875",
"0.52858853",
"0.5255507",
"0.51931953",
"0.517406",
"0.5171568",
"0.51465553",
"0.5144168",
... | 0.61145806 | 1 |
A getter for current updated files. | def target_files
@target_files ||= (git.modified_files - git.deleted_files) + git.added_files
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changed_files\n # FIXME: Implement properly once changed detection is available.\n files\n end",
"def get_current_files\n get_files(OcflTools::Utils.version_string_to_int(@head))\n end",
"def modified_files; end",
"def modified_files\n diff = git.diff(local_branch, remote_br... | [
"0.7069",
"0.7058835",
"0.68692845",
"0.6556569",
"0.65085495",
"0.64837146",
"0.64715886",
"0.6424989",
"0.63360256",
"0.62922543",
"0.6271411",
"0.6270139",
"0.62439066",
"0.6198547",
"0.6198386",
"0.6193268",
"0.61928463",
"0.61876255",
"0.6177017",
"0.61762935",
"0.614787... | 0.5951104 | 36 |
A getter for SpotBugs issues, returning SpotBugs issues. | def spotbugs_issues(report_file)
spotbugs_report = spotbugs_report(report_file)
source_dirs = spotbugs_report.xpath('//BugCollection//SrcDir').map(&:text)
spotbugs_report.xpath('//BugCollection//BugInstance').map do |bug_instance|
BugInstance.new(root_path, source_dirs, bug_instance)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def issues\n return @issues\n end",
"def issues\n Sifter.\n get(api_issues_url).\n fetch(\"issues\", []).\n map { |i| Sifter::Issue.new(i) }\n end",
"def actual_issues\n @actual_issues ||= issues.select { |i| i[:pull_request].nil? }\n end",
"def issues()\n\t\t... | [
"0.7769867",
"0.71680766",
"0.679394",
"0.6620497",
"0.64704466",
"0.63909864",
"0.6301553",
"0.61398476",
"0.61043245",
"0.60802215",
"0.6016841",
"0.59586143",
"0.59374195",
"0.5931796",
"0.59255105",
"0.5925111",
"0.5909187",
"0.5893545",
"0.58911854",
"0.5882012",
"0.5875... | 0.5862719 | 21 |
Generate report and send inline comment with Danger's warn or fail method. | def do_comment(report_files, inline_mode)
spotbugs_issues = []
report_files.each do |report_file|
spotbugs_issues(report_file).each do |bug_instance|
next unless target_files.include? bug_instance.relative_path
spotbugs_issues.push(bug_instance)
send_comment(bug_instance, inline_mode)
end
end
spotbugs_issues
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_report\n @notices << \"#{ActionController::Base.helpers.pluralize(@batch_ids.count, 'Item')} clearanced into batch #{batch.id}\" if batch.id\n @errors << \"#{ActionController::Base.helpers.pluralize(@errors.count, 'id')} raised errors and were not clearanced\" if errors.any?\n @errors << \"No... | [
"0.63580245",
"0.6348315",
"0.6310321",
"0.6310321",
"0.6279741",
"0.6279741",
"0.6181128",
"0.6136799",
"0.6136799",
"0.6136799",
"0.6136799",
"0.6136799",
"0.60452014",
"0.60393983",
"0.6013868",
"0.6013868",
"0.59600747",
"0.5933462",
"0.5912518",
"0.5901414",
"0.5901414",... | 0.0 | -1 |
Builds the max heap. | def build_heap
unless @elements.empty?
i = (@elements.size-1)/2
while i>=0
heapify(i)
i -= 1
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_maxheap\n\t\ti = @heap.length/2\n\t\twhile i >= 0\n\t\t\tn_heapify(@max, i)\n\t\t\ti -= 1\n\t\tend\n\tend",
"def build_heap\n @heap_size = length\n (length / 2).floor.downto(1) do |i| \n heapify_downward i \n end\n end",
"def buildMaxHeap(start = (@heapsize/2-1),finish = 0)\r\n\t\t#why... | [
"0.89116496",
"0.789719",
"0.75883394",
"0.7538729",
"0.7379855",
"0.701705",
"0.67564446",
"0.6732569",
"0.6526662",
"0.64928097",
"0.6401017",
"0.637071",
"0.63546556",
"0.63532704",
"0.6315817",
"0.6292672",
"0.60577893",
"0.60311806",
"0.5996245",
"0.5971777",
"0.5901051"... | 0.74222594 | 4 |
Returns the number of elements. | def size
@elements.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length\r\n elements.length\r\n end",
"def count\n elements.count\n end",
"def size\n @elements.length\n end",
"def size\n Integer.new.tap do |count|\n each { |element| count += 1 }\n end\n end",
"def size\n @elements.size\n end",
"def count_elements\nend",
"def... | [
"0.853207",
"0.8495818",
"0.84003276",
"0.8316746",
"0.8215376",
"0.81923026",
"0.8152281",
"0.80540985",
"0.79713565",
"0.779896",
"0.77745265",
"0.77620244",
"0.771393",
"0.76703143",
"0.7658091",
"0.76379055",
"0.7618548",
"0.75843835",
"0.7580884",
"0.7577447",
"0.7573529... | 0.82552713 | 4 |
First element on the heap. If not element, returns +nil+. | def first
@elements.empty? ? nil : @elements[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peek\n return nil if empty?\n\n @heap[0]\n end",
"def peek\n return self.heap[0]\n end",
"def poll()\n return nil if self.heap_container.length == 0\n return self.heap_container.pop() if self.heap_container.length == 1\n \n item = self.heap_container.pop()\n self.heap_contai... | [
"0.83486813",
"0.7708462",
"0.7455249",
"0.73558366",
"0.7290299",
"0.7234285",
"0.7048272",
"0.6877498",
"0.67974323",
"0.67726624",
"0.67687786",
"0.67599976",
"0.6741429",
"0.6740202",
"0.6739138",
"0.66896886",
"0.6675783",
"0.6666046",
"0.6585268",
"0.656704",
"0.6560210... | 0.64795375 | 26 |
Returns the first element and removes it from the heap. Returns +nil+ if the heap is empty. It will rearrange the other elements to keep the heap properties. | def shift
if @elements.empty?
return nil
end
swap(0,@elements.size-1)
ele = @elements.pop
heapify(0)
ele
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop\n return nil if @elements.length == 0\n tmp = @elements.shift\n @elements.unshift @elements.pop\n heapify_down\n return tmp\n end",
"def remove\n swap(0, self.heap.length-1, self.heap)\n value_to_remove = self.heap.pop\n self.sift_down(0, self.heap.length-1, heap)\n return val... | [
"0.83089435",
"0.78305835",
"0.7769467",
"0.770924",
"0.7654978",
"0.7638512",
"0.7621822",
"0.7616807",
"0.74841624",
"0.73663616",
"0.7361335",
"0.7354278",
"0.7274189",
"0.7259886",
"0.72552484",
"0.72482526",
"0.7234324",
"0.7233444",
"0.7225526",
"0.7205226",
"0.71977735... | 0.7445012 | 9 |
Adds a new +element+ to this max heap, and maintains the heap properties. | def add(elem)
@elements << elem
i = @elements.size-1
pa = parent(i)
while i>0 and @comparator.call(@elements[i],@elements[pa]) > 0
swap(i,pa)
i = pa
pa = parent(pa)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(el)\n @heap.add(el)\n self\n end",
"def add(element)\n\t\t@size += 1\n\t\t@data.push(element)\n\t\telement\n\tend",
"def add(el)\n\t\tif(@elements.length < @size)\n\t\t\t@elements.push(el)\n\t\t\tbubble_up()\n\t\telsif el[@orderBy] < max\n\t\t\t# remove the max\n\t\t\tbubble_down()\n\t\t\t# add ... | [
"0.74941945",
"0.7209935",
"0.71950823",
"0.699894",
"0.69802713",
"0.6931484",
"0.68147993",
"0.6787134",
"0.67707264",
"0.6746616",
"0.6729355",
"0.67134434",
"0.6691495",
"0.6684873",
"0.66762626",
"0.66752535",
"0.66625756",
"0.6617913",
"0.65601695",
"0.65470266",
"0.654... | 0.6722712 | 11 |
Returns +ture+ if the element is included in _self_. | def include?(elem)
@elements.include?(elem)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include?(element)\n @elements.include? element\n end",
"def include?(value)\n element.include? value\n end",
"def include?(other)\n `#{@el}.contains(#{DOM::NODE.get_element(other)})` || other == self\n end",
"def not_include?(element)\n !self.include?(element)\n end",
"d... | [
"0.72627753",
"0.71385694",
"0.7083272",
"0.7056407",
"0.7012274",
"0.6885466",
"0.68645346",
"0.67983544",
"0.67871845",
"0.67210245",
"0.66604084",
"0.64970434",
"0.649515",
"0.6487864",
"0.6472129",
"0.64663243",
"0.64399916",
"0.63391",
"0.6243539",
"0.62222195",
"0.62113... | 0.7206876 | 1 |
Deletes the +element+ from this max heap, and maintains the heap properties. If the element is not found, return +nil+. | def delete(elem)
deleted = @elements.delete(elem)
build_heap unless deleted.nil?
deleted
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop;\n\t\t@heap.empty? and\n\t\t\treturn;\n\t\t_remove 0;\n\tend",
"def remove_max\n return nil if heap.empty?\n deleted = @heap.delete_at 0\n last_one = @heap.pop\n if last_one #ei ole false tai nil\n @heap.insert 0, last_one\n heapify_down 0\n end\n deleted\n end",
"def remov... | [
"0.6819025",
"0.68113655",
"0.66549516",
"0.66510993",
"0.6562311",
"0.65469515",
"0.65469515",
"0.65193224",
"0.65153104",
"0.650952",
"0.6493301",
"0.6486128",
"0.6463992",
"0.6453655",
"0.6442046",
"0.6412629",
"0.640591",
"0.63867676",
"0.63867676",
"0.63826007",
"0.63634... | 0.75875956 | 0 |
Returns the elements in an +Array+ object. | def to_a
@elements.clone
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_a\n array\n end",
"def to_a\n Array(each)\n end",
"def to_a\n @arr\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def get_elements(array)\n\n elements = []\n if array != nil\n elements = array.to_a\n end\n return elements\n\nend",
"def get_array(path='.')\n ... | [
"0.7426894",
"0.73324",
"0.7218192",
"0.7153268",
"0.7101872",
"0.70424175",
"0.7023875",
"0.7003615",
"0.7000537",
"0.698376",
"0.6982483",
"0.69784325",
"0.69342333",
"0.69193715",
"0.68129015",
"0.6773325",
"0.6726881",
"0.66971076",
"0.66956264",
"0.66901094",
"0.66901094... | 0.6233045 | 53 |
Returns the parent index of the element at +i+. | def parent(i)
(i-1)/2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_index(i)\n (i / 2).floor\n end",
"def parent(i)\n\treturn ((i+1)/2).floor-1 #could be simpler\nend",
"def parent(index)\n case index\n when 0\n INVALID_INDEX\n else\n (index - 1) / 2\n end\n end",
"def parent(i); (i-1)/2; end",
"def idx_children(parent_i)... | [
"0.7558149",
"0.73898953",
"0.71897817",
"0.7093185",
"0.70867866",
"0.7070461",
"0.7049022",
"0.70467985",
"0.69362235",
"0.6783529",
"0.67319983",
"0.665753",
"0.66359806",
"0.6612102",
"0.6599606",
"0.65568405",
"0.6493102",
"0.6480639",
"0.63854927",
"0.62796384",
"0.6233... | 0.7501852 | 1 |
Returns the right child index of element at +i+. | def right(i)
i*2+2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_child_index(i)\n (i * 2) + 1\n end",
"def left_child_index(i)\n i * 2\n end",
"def right_child_node(index)\n index * 2 + 2\n end",
"def right_child(index)\n right = index * 2 + 2\n if right >= @tree.length\n return INVALID_INDEX\n else\n return right\n ... | [
"0.8359343",
"0.7713796",
"0.70983934",
"0.7077139",
"0.694932",
"0.66142154",
"0.66010356",
"0.65927094",
"0.6537299",
"0.65241504",
"0.6516412",
"0.6501256",
"0.6467879",
"0.6342492",
"0.6287001",
"0.6287001",
"0.62674755",
"0.6220796",
"0.6219898",
"0.6175682",
"0.61755466... | 0.53131205 | 68 |
Returns the left child index of element at +i+. | def left(i)
i*2+1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left_child_index(i)\n i * 2\n end",
"def left_child(index)\n left = index * 2 + 1\n if left >= @tree.length\n return INVALID_INDEX\n else\n return left\n end\n end",
"def left_child(parent_index)\n left = 2 * parent_index + 1\n return -1 if left > (@array.size... | [
"0.7992498",
"0.75561506",
"0.73425823",
"0.7250473",
"0.72252685",
"0.71124744",
"0.6747664",
"0.6571397",
"0.6561146",
"0.6510751",
"0.6406521",
"0.6373032",
"0.62634426",
"0.6245162",
"0.6222734",
"0.6217514",
"0.62061405",
"0.6140762",
"0.612902",
"0.6113794",
"0.60877943... | 0.6891426 | 6 |
Heapifies the element at position +i+. | def heapify(i)
left = left(i)
right = right(i)
target = i
if left < @elements.size and @comparator.call(@elements[i],@elements[left]) < 0
target = left
end
if right < @elements.size and @comparator.call(@elements[target],@elements[right]) < 0
target = right
end
unless target == i
swap(target,i)
heapify(target)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minheapify(i=0)\n\t\tn_heapify(@min, i)\n\t\t@heap\n\tend",
"def heap_up(i)\n return if i == 0\n\n pnode = (i-1) / 2\n if @store[i].key < @store[pnode].key\n swap(i, pnode)\n heap_up(pnode)\n end\n end",
"def heapify\n for i in (0..(@ary.size-1)).to_a.reverse\n upheap(i)\n ... | [
"0.7694692",
"0.73285645",
"0.7035773",
"0.699259",
"0.67716455",
"0.6696808",
"0.6610182",
"0.6593232",
"0.6411324",
"0.6297163",
"0.6227078",
"0.6164906",
"0.6147106",
"0.607659",
"0.6042002",
"0.60286844",
"0.60099924",
"0.59845155",
"0.59745103",
"0.59721166",
"0.59661084... | 0.8124133 | 0 |
account for File System Redirector | def servermanagercmd
@servermanagercmd ||= begin
locate_sysnative_cmd("servermanagercmd.exe")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirects; end",
"def follow_redirection(&block); end",
"def redirect_ok=(_arg0); end",
"def follow_get_redirection(&block); end",
"def filter_redirect=(_arg0); end",
"def filter_redirect=(_arg0); end",
"def follow_symlinks=(_arg0); end",
"def public_file_server=(_arg0); end",
"def public_file_... | [
"0.60034186",
"0.57965726",
"0.5679674",
"0.5635606",
"0.5547101",
"0.5547101",
"0.5516242",
"0.54984534",
"0.54984534",
"0.5479617",
"0.54660094",
"0.5464046",
"0.5442541",
"0.54375845",
"0.5420232",
"0.5420232",
"0.537118",
"0.53553826",
"0.535462",
"0.53241646",
"0.5317913... | 0.0 | -1 |
def total_cash(hash) start_sum = 0 for p in hash[:pets][:price] return start_sum += hash[:pets][:price] end end 2 | def total_cash(instance)
return instance[:admin][:total_cash]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def food_stand(hash)\n sum = 0\n hash.each do |k, v|\n # hash[k] = v\n sum += v\n end\n return sum\nend",
"def calcular_total hash\n p hash.inject(0) { |sum, tuple| sum += tuple[1] }\n end",
"def hash_sum\n total = 0\n places_hash.each do |k, v|\n total = total + v\n end\n return total\nen... | [
"0.776944",
"0.75251144",
"0.7444795",
"0.7365551",
"0.7202929",
"0.71748936",
"0.7166093",
"0.71222293",
"0.7121704",
"0.71095383",
"0.7102669",
"0.70723635",
"0.70578",
"0.6960724",
"0.6960724",
"0.6955277",
"0.6954052",
"0.69459796",
"0.6936525",
"0.6920396",
"0.6911237",
... | 0.0 | -1 |
12 Almost there? def remove_pet_by_name(pet_shop, name) for pet in pet_shop[:pets] if pet[:name] == name return pet_shop[:pets] pet[:name] end end end 12 Emily helped solution | def remove_pet_by_name(pet_shop, name)
for pet in pet_shop[:pets]
if pet[:name] == name
p pet_shop[:pets].delete(pet)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_pet_by_name(shop, name)\n for pet in shop[:pets]\n return pet.delete(:name) if name == pet[:name]\n end\nend",
"def remove_pet_by_name (pet_shop, pet_name)\n for pet in pet_shop[:pets]\n if pet_name == pet[:name]\n pet[:name].delete!(pet_name)\n end\n end\nend",
"def remove_pet_b... | [
"0.9184563",
"0.9174257",
"0.91589785",
"0.91375655",
"0.91375655",
"0.91314197",
"0.9120993",
"0.90534735",
"0.9050981",
"0.8964858",
"0.8941127",
"0.88858527",
"0.8855327",
"0.8779129",
"0.87577677",
"0.870927",
"0.870882",
"0.8651011",
"0.8648881",
"0.8623571",
"0.85577404... | 0.9138939 | 3 |
16 def customer_pet_count(customer) return customer[0].to_i end <omg i effed up here which is why i couldn't get 17 for ages i didn't realise, i over complicated things, i should just write functions to make the test pass rather than think of future possibilities urgh | def customer_pet_count(customer)
return customer[:pets].count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_customer_pet_count\n count = customer_pet_count(@customers[0])\n assert_equal(0, count)\n end",
"def customer_pet_count(customer)\n return customer[:pets].count()\n # return customer[:pets].length()\n # return customer[:pets].size()\n end",
"def customer_pet_count(supplied_customer)\n... | [
"0.82387346",
"0.82265157",
"0.79986286",
"0.79607755",
"0.7902534",
"0.78877056",
"0.78877056",
"0.7819954",
"0.7819954",
"0.78148544",
"0.7801166",
"0.77277195",
"0.7726995",
"0.7523292",
"0.7493414",
"0.73684174",
"0.7283029",
"0.7119066",
"0.6959188",
"0.6906957",
"0.6794... | 0.78623503 | 7 |
17 def add_pet_to_customer(customer, new_pet_hash) pet_count = customer[:pets].count for new_pet in new_pet_hash return pet_count.push(new_pet) end return pet_count.count end | def add_pet_to_customer(customer, new_pet_hash)
customer[:pets] << (new_pet_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_pet_to_customer(customer, new_pet)\n customer[:pets].push(new_pet)\n customer[:pets].count\nend",
"def add_pet_to_customer(customer,new_pet)\n customer[:pets].push(new_pet[:pet_type])\n return customer[:pets].count()\n end",
"def customer_pet_count (customer)\n return customer[:pets].count\ne... | [
"0.90553266",
"0.8698751",
"0.8384979",
"0.8365112",
"0.83562917",
"0.83540976",
"0.83540976",
"0.83428615",
"0.82892483",
"0.8226913",
"0.8202133",
"0.81318766",
"0.8095511",
"0.8086703",
"0.8086703",
"0.80545545",
"0.8009464",
"0.7921758",
"0.7884926",
"0.78743595",
"0.7869... | 0.80319065 | 16 |
17 draft def add_pet_to_customer(customer, new_pet_hash) pet_count = [] for new_pet in new_pet_hash return pet_count.push(new_pet) end return pet_count.count end 18 & 19 this actually only took me a minute with new mindset. do minimum to pass, then change function to fit future possibilities. also step back and pay attention to the arguments given to the test. | def customer_can_afford_pet(customer, new_pet_hash)
if customer[:cash] > new_pet_hash[:price]
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_pet_to_customer(customer, new_pet)\n customer[:pets].push(new_pet)\n customer[:pets].count\nend",
"def add_pet_to_customer(customer,new_pet)\n customer[:pets].push(new_pet[:pet_type])\n return customer[:pets].count()\n end",
"def add_pet_to_customer(customer_hash, new_pet)\n return customer_h... | [
"0.8437562",
"0.82346445",
"0.7966029",
"0.7920524",
"0.78519315",
"0.785171",
"0.77273715",
"0.7685846",
"0.76098126",
"0.7587711",
"0.75509024",
"0.75497115",
"0.75424784",
"0.75359094",
"0.7519772",
"0.7519772",
"0.7519772",
"0.7490877",
"0.73833287",
"0.738042",
"0.737313... | 0.65980977 | 66 |
Checks if this numeric range intersects with another | def intersect?(o)
self.class == o.class && !(@to < o.numeric_from || o.numeric_to < @from)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersects?(*args)\n other = coerce_range(*args)\n raise ArgumentError, \"#{self.begin.class} expected, received #{other.begin.class}\" unless other.begin.kind_of?(self.begin.class)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n other.begin... | [
"0.7757763",
"0.73951113",
"0.72122",
"0.7132891",
"0.712935",
"0.7093643",
"0.70667654",
"0.7037788",
"0.7002646",
"0.6988205",
"0.6983293",
"0.6955906",
"0.69552076",
"0.69027674",
"0.68826234",
"0.68679166",
"0.6837399",
"0.6806454",
"0.6787957",
"0.677411",
"0.6744015",
... | 0.74312043 | 1 |
Returns the lower bound of the numeric range or `nil` if no lower bound is set. | def from
@from == -Float::INFINITY ? nil : @from
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lower_bound_inclusive\n lower_bound\n end",
"def min(lower_bound, inclusive = nil)\n @min = lower_bound\n @min_inclusive = inclusive\n end",
"def min(lower_bound, inclusive = nil)\n @min = lower_bound\n @min_inclusive = inclusive\n end",
"def rang... | [
"0.70864326",
"0.6940991",
"0.6940991",
"0.6919367",
"0.68336606",
"0.682945",
"0.6618475",
"0.65854645",
"0.6330474",
"0.62928593",
"0.6227219",
"0.6217121",
"0.6120659",
"0.6094969",
"0.6069114",
"0.6019181",
"0.59719056",
"0.59341025",
"0.59183425",
"0.5891816",
"0.5853107... | 0.0 | -1 |
Returns the upper bound of the numeric range or `nil` if no upper bound is set. | def to
@to == Float::INFINITY ? nil : @to
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_upper_limit_of(range)\n range.max\nend",
"def get_upper_limit_of(range)\n range.last\nend",
"def get_upper_limit_of(range)\n range.max\nend",
"def upper_bound; end",
"def get_upper_limit_of(range)\n range.end\nend",
"def upper_bound_inclusive\n result = upper_bound\n\n # Some spec... | [
"0.7003224",
"0.6996898",
"0.6988062",
"0.694209",
"0.6913337",
"0.6880352",
"0.64768565",
"0.6392105",
"0.63720334",
"0.6326327",
"0.6326327",
"0.6283211",
"0.62788314",
"0.6253783",
"0.6228228",
"0.61970323",
"0.61684996",
"0.6139089",
"0.6065292",
"0.60475487",
"0.60424936... | 0.0 | -1 |
Same as from but will return `Float::Infinity` instead of `nil` if no lower bound is set. | def numeric_from
@from
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from\n @from == -Float::INFINITY ? nil : @from\n end",
"def lower_bound\n self.class.lower_bound(@obs, z_value)\n end",
"def lower_bound(data)\n return (q1(data) - (1.5 * iqr(data))).to_f\n end",
"def lower_bound_inclusive\n lower_bound\n end",
"def my_min2(array)\n lowest_... | [
"0.7108944",
"0.6166451",
"0.6125761",
"0.6098916",
"0.5978157",
"0.5925704",
"0.5925704",
"0.59229577",
"0.58828306",
"0.58828306",
"0.5734093",
"0.57071364",
"0.5632774",
"0.56241536",
"0.56192625",
"0.5617183",
"0.56114244",
"0.5604941",
"0.5604941",
"0.5603599",
"0.558878... | 0.5693271 | 12 |
Same as to but will return `Float::Infinity` instead of `nil` if no lower bound is set. | def numeric_to
@to
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to\n @to == Float::INFINITY ? nil : @to\n end",
"def from\n @from == -Float::INFINITY ? nil : @from\n end",
"def lower_bound\n self.class.lower_bound(@obs, z_value)\n end",
"def def_bound_float sym, range, name=nil\n def_numeric(sym, name) {|v|\n next false if (range.r... | [
"0.6894433",
"0.6541123",
"0.6048955",
"0.59837765",
"0.59837765",
"0.5933354",
"0.5909154",
"0.5861911",
"0.5817712",
"0.5742106",
"0.5704086",
"0.5608618",
"0.56060356",
"0.55992645",
"0.5587064",
"0.55531144",
"0.5545616",
"0.5528145",
"0.5515054",
"0.55074674",
"0.5486316... | 0.0 | -1 |
Concatenates this range with another range provided that the ranges intersect or are adjacent. When that's not the case, this method will return `nil` | def merge(o)
if intersect?(o) || adjacent?(o)
new_min = numeric_from <= o.numeric_from ? numeric_from : o.numeric_from
new_max = numeric_to >= o.numeric_to ? numeric_to : o.numeric_to
self.class.new(new_min, new_max)
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(other)\n if include?(other.begin) || other.include?(self.begin)\n cmp = self.begin <=> other.begin\n if cmp < 0\n min = self.begin\n excl_begin = exclude_begin?\n elsif cmp > 0\n min = other.begin\n excl_begin = other.exclude_b... | [
"0.6783698",
"0.66964114",
"0.65810907",
"0.6481763",
"0.644672",
"0.644672",
"0.6354599",
"0.6305759",
"0.6266257",
"0.6251048",
"0.6172385",
"0.6102747",
"0.5989016",
"0.58342797",
"0.58024406",
"0.57911277",
"0.5772159",
"0.57373995",
"0.57369435",
"0.5732757",
"0.5719501"... | 0.0 | -1 |
GET /event_elements GET /event_elements.json | def index
@event_elements = EventElement.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def events\n response = self.class.get('/v1/events.json')\n response.code == 200 ? JSON.parse(response.body) : nil\n end",
"def index\n #returns all events from eventbrite API, need to change to pull from her en... | [
"0.73061967",
"0.68866354",
"0.6868861",
"0.67947763",
"0.66653544",
"0.6641993",
"0.66249585",
"0.65587926",
"0.6506329",
"0.65009993",
"0.648142",
"0.64712006",
"0.6470211",
"0.6443841",
"0.64436775",
"0.64436775",
"0.6436641",
"0.64343876",
"0.6418604",
"0.63791955",
"0.63... | 0.72904515 | 1 |
GET /event_elements/1 GET /event_elements/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @event_elements = EventElement.all\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def index\n #returns all events from eventbrite API, need to change to pull from her endpoint\n @eventList = Event.retrieve_all_events params\n render json: @... | [
"0.6845841",
"0.6650304",
"0.6581152",
"0.6481863",
"0.647552",
"0.6405744",
"0.6343988",
"0.63414484",
"0.6334101",
"0.62903976",
"0.62903976",
"0.6279981",
"0.62682307",
"0.62266964",
"0.62256765",
"0.62162936",
"0.62150276",
"0.62129927",
"0.6205357",
"0.6204575",
"0.61976... | 0.0 | -1 |
POST /event_elements POST /event_elements.json | def create
@event_element = EventElement.new(event_element_params)
respond_to do |format|
if @event_element.save
format.html { redirect_to @event_element, notice: 'Event element was successfully created.' }
format.json { render :show, status: :created, location: @event_element }
else
format.html { render :new }
format.json { render json: @event_element.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_events\n saved = []\n jsonHash = request.POST[:_json];\n jsonHash.each do |jsonEvent|\n event = Event.new\n event.race_id = jsonEvent[\"raceId\"]\n event.walker_id = jsonEvent[\"walkerId\"]\n event.eventId = jsonEvent[\"eventId\"]\n event.eventType = jsonEvent[\"type\"]\n... | [
"0.6460685",
"0.59564286",
"0.5924289",
"0.5916261",
"0.5911022",
"0.5910056",
"0.58828604",
"0.5859368",
"0.58439016",
"0.5804608",
"0.5785104",
"0.57801235",
"0.57481337",
"0.573887",
"0.56989515",
"0.56960005",
"0.56655276",
"0.5614666",
"0.5586792",
"0.5584357",
"0.558233... | 0.65677327 | 0 |
PATCH/PUT /event_elements/1 PATCH/PUT /event_elements/1.json | def update
respond_to do |format|
if @event_element.update(event_element_params)
format.html { redirect_to @event_element, notice: 'Event element was successfully updated.' }
format.json { render :show, status: :ok, location: @event_element }
else
format.html { render :edit }
format.json { render json: @event_element.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_event\n user_id = params[\"user_id\"]\n group_id = params[\"group_id\"]\n event_id = params[\"event_id\"]\n\n #TODO Handle 404 if event not found\n event = Event.find(event_id)\n\n json_body = JSON.parse(request.body.read)\n\n @@event_service.patch_event(j... | [
"0.68292314",
"0.65027267",
"0.6403947",
"0.6382738",
"0.63632184",
"0.636033",
"0.63441545",
"0.6337041",
"0.6318268",
"0.6317005",
"0.631292",
"0.63085395",
"0.6307107",
"0.63040006",
"0.628511",
"0.62832874",
"0.62605256",
"0.62605256",
"0.6243118",
"0.6221383",
"0.6166579... | 0.69288176 | 0 |
DELETE /event_elements/1 DELETE /event_elements/1.json | def destroy
@event_element.destroy
respond_to do |format|
format.html { redirect_to event_elements_url, notice: 'Event element was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @event = Event.using(:shard_one).find(params[:id])\n @event.destroy\n\n respond_to do |format|\n format.html { redirect_to events_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n format.json { head :no_... | [
"0.7053537",
"0.7040418",
"0.7040418",
"0.7040418",
"0.7039979",
"0.69784653",
"0.6945369",
"0.6918084",
"0.689456",
"0.68933415",
"0.68933415",
"0.68933415",
"0.6880953",
"0.68658686",
"0.6861537",
"0.6835604",
"0.6835494",
"0.6819734",
"0.6815949",
"0.68095356",
"0.6809278"... | 0.7162513 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_event_element
@event_element = EventElement.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def event_element_params
params.require(:event_element).permit(:starting_at, :due_date, :created_at, :updated_at, :name, :reminder)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
TODO read /etc/services and support default numeric port match? allow addr to be regexp, glob, or literal | def _escape (addr)
addr =~ /\\./ ? addr
: addr =~ /\.\*/ ? addr.gsub(/\*/, '\d+').gsub(/\./, '\.')
: Regexp.escape(addr)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dns_get_srv(name)\n addr, port = '.', 0\n\n DNSRuby::DNS.open do |dns|\n srv = dns.getresource(name, DNSRuby::Types.SRV)\n addr, port = srv.target.to_s, srv.port\n end\n\n (addr == '.' || port == 0) ? [nil, nil] : [addr, port]\nend",
"def config_fgservice(servicename, lowport, highport, comment, ca... | [
"0.5956091",
"0.5928387",
"0.5927588",
"0.58764595",
"0.5846239",
"0.57991546",
"0.57599294",
"0.5747656",
"0.5745353",
"0.5733637",
"0.5729986",
"0.57153106",
"0.5619922",
"0.5574001",
"0.54904646",
"0.5474945",
"0.54748076",
"0.54709685",
"0.54575247",
"0.5447638",
"0.54425... | 0.0 | -1 |
change the ed.paid_by on line 72 to reflect profile_id of friend | def you_are_owed
detailed_expenses = self.expenses.includes(:expense_details)
amount = 0
more_details = Hash.new {|h,k| h[k] = k }
detailed_expenses.each do |ex|
id = Friend.includes(:profile).find(ex.payable_id)
friend_id = self.id != id.profile_id ? id.profile_id : id.friend_id
ex.expense_details.each do |ed|
if ed.paid_by == self.id
amount += (ed.amount_paid / 2.0)
more_details[friend_id] ||= {}
more_details[friend_id] += ed.amount_paid / 2.0
end
end
end
[amount, more_details]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associate_payment_profile\n order = Spree::Order.where(\"email = ?\", @user.email).order(\"created_at\").last\n if order.try(:payments).present?\n payment_source = order.payments.last.source\n payment_source.update_attributes(user_id: @user.id)\n end\n end",
"def update\n $lovedone = n... | [
"0.6438835",
"0.62872684",
"0.6132743",
"0.595829",
"0.58557457",
"0.5845514",
"0.5827744",
"0.5780614",
"0.5749414",
"0.5716976",
"0.5703836",
"0.56760716",
"0.5661688",
"0.56603104",
"0.5658655",
"0.5654952",
"0.5631802",
"0.56277275",
"0.5614434",
"0.5610527",
"0.56084245"... | 0.0 | -1 |
See escape >> require 'awltool/structures' >> AwlTool::Structures::StringType::unescape "one$ltwo$lthree$l" => "one\ntwo\nthree\n" | def unescape(escaped_string)
escaped_string.
gsub(/\$\$|\$'|\$L|\$P|\$R|\$P|\$T/i) do |match|
case match
when "$$"
"$"
when "$'"
"'"
when "$L", "$l"
"\n"
when "$R", "$r"
"\r"
when "$T", "$t"
"\t"
when "$P", "$p"
"\f"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n ... | [
"0.68075",
"0.66801375",
"0.6557451",
"0.63808054",
"0.6252174",
"0.62201196",
"0.61941385",
"0.61899817",
"0.6186463",
"0.61666256",
"0.61056936",
"0.60777396",
"0.60711956",
"0.6047817",
"0.602092",
"0.5932695",
"0.59232986",
"0.5880502",
"0.5852494",
"0.58016133",
"0.57858... | 0.6202425 | 6 |
up by identifiers for each block, print 1 message per failure or error found | def parse_message_from_log_entry
unique_messages = { }
id = ""
ARGF.each do |line|
block_id = line.match(/Loaded suite (.*)/)
failure_msg = line.match(/[1-9]+ failures/)
err_msg = line.match(/[1-9]+ errors/)
if ! block_id.nil?
id = block_id[1]
elsif ! failure_msg.nil?
unique_messages["FAIL: #{id}"] = ""
elsif ! err_msg.nil?
unique_messages["ERROR: #{id}"] = ""
end
end
puts unique_messages.keys.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_results\n if !@failures.empty?\n @failures.each do |test|\n pout \"\\nFailed: #{test[:desc]}\"\n puts test[:result]\n # print a newline for easier reading\n puts \"\"\n end\n abort\n else\n puts \"All passed!\".green\n end\nend",
"def display_error(i, given, correct)\... | [
"0.6025213",
"0.5931905",
"0.59062314",
"0.58988017",
"0.5816392",
"0.57000244",
"0.56740606",
"0.56740606",
"0.566949",
"0.5634256",
"0.5603858",
"0.5530434",
"0.5529261",
"0.5500961",
"0.5486108",
"0.54777855",
"0.5447047",
"0.54027534",
"0.5400522",
"0.5374856",
"0.5364118... | 0.602597 | 0 |
Logs in the user | def login(username, password)
db = connect_db("db/webshop.db")
params = [username, password]
is_valid(params)
result = db.execute("SELECT * FROM users WHERE username=?", username).first
if result != nil
password_digest = result["password_digest"]
id = result["id"]
if BCrypt::Password.new(password_digest) == password
session[:user] = username
session[:id] = id
redirect('/elever')
else
session[:error] = "Fel lösenord eller användarnamn. Försök igen."
redirect('/error')
end
else
session[:error] = "Fel lösenord eller användarnamn. Försök igen."
redirect('/error')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login\n\t\tif @current_user != nil\n\t\t\tredirect_to user_path(@current_user.id)\n\t\tend\n\tend",
"def sign_in(user)\n login_as user\n end",
"def login\n make_login_call\n end",
"def login\n end",
"def log_in\n end",
"def user_login(user)\n click_log_in\n fill_login_creden... | [
"0.7927981",
"0.78411305",
"0.7760687",
"0.7706317",
"0.77059376",
"0.7675741",
"0.76389486",
"0.76389486",
"0.76389486",
"0.76389486",
"0.76389486",
"0.76389486",
"0.76389486",
"0.76389486",
"0.76389486",
"0.7629262",
"0.7561739",
"0.7556148",
"0.7556148",
"0.753425",
"0.750... | 0.0 | -1 |
Checks if the parameters is nil or empty | def is_valid(params)
i = 0
while params.length > i
p params[i]
if params[i] == nil || params[i] == ""
session[:error] = "Du missade en parameter! Försök igen."
redirect('/error')
end
i += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_parameters?\n @parameters.nil? or @parameters.empty?\n end",
"def valid_params?\n params.none? do |k,v|\n v == \"\"\n end\n end",
"def blank_param?(data)\n data.blank? || data.try(:values).try(:all?, &:blank?)\n end",
"def blank?(param)\n param.nil? || pa... | [
"0.81044847",
"0.80776054",
"0.7780041",
"0.77025026",
"0.76324064",
"0.7492509",
"0.74421513",
"0.7429197",
"0.73902655",
"0.73306566",
"0.73306227",
"0.731064",
"0.7296624",
"0.7280447",
"0.7260977",
"0.7253157",
"0.7197281",
"0.71705437",
"0.7166903",
"0.7157128",
"0.71354... | 0.6961184 | 29 |
GET /contacters/1 GET /contacters/1.json | def show
@contacter = Contacter.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @contacter }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @characters = Character.all\n\n render json: @characters\n end",
"def index\n characters = @project.characters.all\n render json: { characters: characters }\n end",
"def character\n fetch('books.the_kingkiller_chronicle.characters')\n end",
"def show\n render json... | [
"0.68531054",
"0.68402904",
"0.6523547",
"0.6502124",
"0.64882624",
"0.6448222",
"0.6362267",
"0.63432556",
"0.6336987",
"0.6300404",
"0.6299343",
"0.6289104",
"0.61587685",
"0.61463916",
"0.6113191",
"0.6084237",
"0.60806876",
"0.6072516",
"0.60427064",
"0.6018265",
"0.60181... | 0.661086 | 2 |
GET /contacters/new GET /contacters/new.json | def new
@contacter = Contacter.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @contacter }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @collected_character = CollectedCharacter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collected_character }\n end\n end",
"def new\n @critic = Critic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.js... | [
"0.71536696",
"0.71376354",
"0.69860715",
"0.67932844",
"0.6752665",
"0.6752592",
"0.6743498",
"0.67230546",
"0.67180645",
"0.6714468",
"0.67022973",
"0.67022973",
"0.6701186",
"0.66965705",
"0.6694155",
"0.6668506",
"0.666785",
"0.666785",
"0.66590345",
"0.66305506",
"0.6621... | 0.7767325 | 0 |
POST /contacters POST /contacters.json | def create
@contacter = Contacter.new(params[:contacter])
respond_to do |format|
if @contacter.save
format.html { redirect_to @contacter, notice: 'Contacter was successfully created.' }
format.json { render json: @contacter, status: :created, location: @contacter }
else
format.html { render action: "new" }
format.json { render json: @contacter.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @character = Character.new(character_params)\n if @character.save\n render json: @character, status: 201\n else\n render json: @character.errors, status: :unprocessable_entity\n end\n end",
"def create\n respond_to do |format|\n if @character = Character.create_with_ch... | [
"0.62021315",
"0.5899664",
"0.5859626",
"0.5831439",
"0.5831439",
"0.5830957",
"0.58120394",
"0.5789484",
"0.5766159",
"0.5738923",
"0.57261497",
"0.5601559",
"0.55996436",
"0.5566699",
"0.5560417",
"0.55522454",
"0.55435294",
"0.55433327",
"0.54952383",
"0.5494391",
"0.54875... | 0.56132394 | 11 |
PUT /contacters/1 PUT /contacters/1.json | def update
@contacter = Contacter.find(params[:id])
respond_to do |format|
if @contacter.update_attributes(params[:contacter])
format.html { redirect_to @contacter, notice: 'Contacter was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @contacter.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @character.update(character_params)\n render json: @character, status: 201, location: @character\n else\n render json: @character.errors, status: :unprocessable_entity\n end\n end",
"def update\n # @character.update character_params\n if @character.update character_param... | [
"0.63220584",
"0.59847754",
"0.59705186",
"0.59299725",
"0.5897285",
"0.58740646",
"0.58708835",
"0.58698434",
"0.58609897",
"0.58260393",
"0.58260393",
"0.58260393",
"0.58260393",
"0.58260393",
"0.58086306",
"0.5805845",
"0.58056647",
"0.5793683",
"0.5789266",
"0.5747582",
"... | 0.643063 | 0 |
DELETE /contacters/1 DELETE /contacters/1.json | def destroy
@contacter = Contacter.find(params[:id])
@contacter.destroy
respond_to do |format|
format.html { redirect_to contacters_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @character.destroy\n respond_to do |format|\n format.html { redirect_to characters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cict.destroy\n respond_to do |format|\n format.html { redirect_to cicts_url }\n format.json { head :no_conten... | [
"0.67664516",
"0.6712981",
"0.6622304",
"0.6600404",
"0.6595037",
"0.6564816",
"0.6544008",
"0.65417403",
"0.65376085",
"0.65118873",
"0.6508892",
"0.6495616",
"0.64875376",
"0.6487026",
"0.6485353",
"0.6485353",
"0.6485353",
"0.6485353",
"0.6485353",
"0.6485353",
"0.6485353"... | 0.7373848 | 0 |
store! nil's the cache_id after it finishes so we need to remember it for deletition | def remember_cache_id(new_file)
@cache_id_was = cache_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_store; end",
"def cache_store; end",
"def cache_store=(_arg0); end",
"def cache_store=(_arg0); end",
"def escribe_cache\n Rails.cache.write(\"cache_service_#{id}\", true, :expires_in => 1.week)\n end",
"def before_commit\n cache.delete(id)\n end",
"def flush!\n @_cache = {}\n ... | [
"0.70733666",
"0.70733666",
"0.70002025",
"0.70002025",
"0.68247736",
"0.6720141",
"0.6549733",
"0.6517653",
"0.64939106",
"0.6480127",
"0.64477515",
"0.64399475",
"0.6386983",
"0.6386983",
"0.6386983",
"0.6386983",
"0.6386983",
"0.6386983",
"0.6386983",
"0.6334964",
"0.63299... | 0.6529188 | 13 |
Add a white list of extensions which are allowed to be uploaded. For images you might use something like this: | def extension_white_list
%w(jpg jpeg gif png)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extension_whitelist\n %w(jpg jpeg gif png)\n end",
"def extension_whitelist\n %w[jpg jpeg gif png]\n end",
"def extension_whitelist\n %w[jpg jpeg gif png]\n end",
"def extension_whitelist\n %w[jpg jpeg gif png]\n end",
"def extension_whitelist\n %w(jpg jpeg gif png)\n end",
... | [
"0.8159334",
"0.81505024",
"0.81505024",
"0.81505024",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81259763",
"0.81250226",
"0.80939883",
"0.80939883",... | 0.766807 | 36 |
Override the filename of the uploaded files: | def filename
@name ||= "#{model.firstname.parameterize}-#{model.lastname.parameterize}.#{model.image.file.extension}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filename\n if super.present?\n @name ||=\"#{SecureRandom.hex}.#{file.extension.downcase}\" if original_filename\n Rails.logger.debug(\"(BaseUploader.filename) #{@name}\")\n @name\n end\n end",
"def file_name\n uploaded_file_file_name\n end",
"def original_filename\n fake_file_n... | [
"0.77587795",
"0.77092165",
"0.7650253",
"0.76119834",
"0.76119834",
"0.7511504",
"0.7509861",
"0.7469618",
"0.7408529",
"0.7325303",
"0.7303221",
"0.7293142",
"0.72422063",
"0.7219045",
"0.717902",
"0.7177287",
"0.71570605",
"0.71570605",
"0.7156595",
"0.7156595",
"0.7119968... | 0.6885877 | 40 |
Helper method to delete znodes | def delete_node(path, force = false)
while true
begin
@zk.delete(path)
puts "Deleted #{path}"
rescue ZK::Exceptions::NotEmpty
# Catch node exists, walk lower, call delete_node w/ args on it.
# This will recursively delete nodes under a path.
if force
children = @zk.children(path)
children.each do |child_path|
delete_node("#{path}/#{child_path}", force)
end
else
puts "ERROR: Cannot delete #{path} as it is not empty. Delete with force to recursively delete"
break
end
rescue ZK::Exceptions::NoNode
# break the while loop if no node is reported
break
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_node\n node.destroy if node\n end",
"def destroy\n chef_server_rest.delete(\"nodes/#{name}\")\n end",
"def delete!\n PoolNode.rmdir(@id)\n super\n Address.delete(@id)\n Subnet.delete(@subnet)\n end",
"def delete_node(l)\n node = Node.find_by(layer: l).destroy\n Conne... | [
"0.650912",
"0.6470525",
"0.6456191",
"0.64444256",
"0.6336328",
"0.6295006",
"0.62753695",
"0.625475",
"0.6196137",
"0.617878",
"0.60367924",
"0.59813136",
"0.59520453",
"0.5942409",
"0.594054",
"0.58667934",
"0.58645576",
"0.5863295",
"0.575592",
"0.57541513",
"0.57482266",... | 0.5717679 | 23 |
If the passphrase contains one of "i", "o" or "l", we should skip past all the subsequent strings in the sequence that will also contain these letters. | def skip_known_failures(passphrase)
passphrase.gsub(/[iol].+$/) { |m| m.chars.first.next + ('a' * m[1..-1].size) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip?(char)\n !KEYMAP.include? char\n end",
"def is_valid_passchars?(passphrase)\n words = passphrase.split(' ').map { |word| word.chars.sort.join('') }\n words.uniq.length == words.length\nend",
"def encryptor(user_pass)\n counter = 0\n output = \"\"\n while counter < user_pass.length\n\n if u... | [
"0.62243783",
"0.6128043",
"0.59000134",
"0.58669007",
"0.5838073",
"0.582331",
"0.58108056",
"0.57477117",
"0.5714367",
"0.5712501",
"0.5688031",
"0.5656528",
"0.5651552",
"0.5646401",
"0.56370896",
"0.5628277",
"0.5612075",
"0.5587763",
"0.5585386",
"0.55820566",
"0.5563366... | 0.7532067 | 0 |
Handles response and error codes from the remote service. | def handle_response(response)
case response.code.to_i
when 200...400
response
when 404
raise NotFoundError.new(response)
else
raise ConnectionError.new(response)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_response(response)\n case response.code\n when 200..299\n response\n else\n if response.request.format == :json\n raise FreebaseAPI::ServiceError.new(response['error'])\n else\n raise FreebaseAPI::NetError.new('code' => response.code, 'message' => re... | [
"0.68822074",
"0.67487186",
"0.6747314",
"0.6656227",
"0.6633585",
"0.65465456",
"0.6535698",
"0.6535698",
"0.6498876",
"0.64748615",
"0.64741695",
"0.6401612",
"0.6363939",
"0.6346135",
"0.6337945",
"0.627549",
"0.6248701",
"0.6226966",
"0.6196111",
"0.61911094",
"0.61808723... | 0.6858358 | 2 |
A method that attempts to render content from rit and if none found will raise an error Arguments: layout_name: +String+ The name of the rit layout instance_name: +String+ The name of the rit instance (optional) plate_name: +String+ The name of the rit plate Returns: Returns content (string) or raises error if not found | def rit_plate!(layout_name, instance_name, plate_name)
Rit::Plate.get(layout_name, instance_name, plate_name, session[:preview_time])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rit_plate!(layout_name, instance_name, plate_name)\n RitClient::Plate.get(layout_name, instance_name, plate_name, nil) # session[:preview_time]\n end",
"def render(name, options = {})\n options = options.merge(:request => request, :params => params)\n content = render_template(name, opt... | [
"0.6837537",
"0.6112611",
"0.5998462",
"0.5934889",
"0.5829886",
"0.5757414",
"0.57359535",
"0.5678536",
"0.5645443",
"0.558501",
"0.55717665",
"0.5544386",
"0.55421066",
"0.5535778",
"0.55078614",
"0.55052394",
"0.55020916",
"0.5502012",
"0.5449088",
"0.5441717",
"0.5434127"... | 0.7066558 | 0 |
GET /fotos_empresas GET /fotos_empresas.json | def index
@fotos_empresas = FotosEmpresa.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @fotos = Foto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fotos }\n end\n end",
"def index\n @fotos = Foto.all\n end",
"def index\n @fotos = Foto.all\n end",
"def index\n @fotos = Foto.all\n end",
"def index\n @p... | [
"0.72819805",
"0.6677903",
"0.6677903",
"0.6677903",
"0.6607128",
"0.65713364",
"0.6549457",
"0.65436417",
"0.650856",
"0.64812297",
"0.6460189",
"0.6456988",
"0.6441628",
"0.64356804",
"0.64270514",
"0.64240247",
"0.64195305",
"0.6382988",
"0.6381398",
"0.6377611",
"0.636621... | 0.74116987 | 0 |
GET /fotos_empresas/1 GET /fotos_empresas/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @fotos = Foto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fotos }\n end\n end",
"def index\n @fotos_empresas = FotosEmpresa.all\n end",
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?... | [
"0.7256302",
"0.7246558",
"0.6848788",
"0.66275537",
"0.66275537",
"0.66275537",
"0.6611914",
"0.6610392",
"0.6604908",
"0.6599378",
"0.65280986",
"0.6503242",
"0.64934975",
"0.6472482",
"0.64681137",
"0.6461162",
"0.6455488",
"0.6449857",
"0.64384365",
"0.643168",
"0.6421537... | 0.0 | -1 |
POST /fotos_empresas POST /fotos_empresas.json | def create
@fotos_empresa = FotosEmpresa.new(fotos_empresa_params)
respond_to do |format|
if @fotos_empresa.save
format.html { redirect_to @fotos_empresa, notice: 'Fotos empresa was successfully created.' }
format.json { render :show, status: :created, location: @fotos_empresa }
else
format.html { render :new }
format.json { render json: @fotos_empresa.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fotos_empresa_params\n params.require(:fotos_empresa).permit(:name, :image, :estado)\n end",
"def set_fotos_empresa\n @fotos_empresa = FotosEmpresa.find(params[:id])\n end",
"def index\n @fotos_empresas = FotosEmpresa.all\n end",
"def create\n @photos = Photo.new(photos_params)\n ... | [
"0.6770414",
"0.6445009",
"0.62958515",
"0.59873664",
"0.59584296",
"0.5910884",
"0.5883888",
"0.5875258",
"0.58667576",
"0.58359736",
"0.5790208",
"0.5782646",
"0.57696867",
"0.5754405",
"0.57535523",
"0.57173353",
"0.56878203",
"0.5678379",
"0.5666089",
"0.5660587",
"0.5656... | 0.70054215 | 0 |
PATCH/PUT /fotos_empresas/1 PATCH/PUT /fotos_empresas/1.json | def update
respond_to do |format|
if @fotos_empresa.update(fotos_empresa_params)
format.html { redirect_to @fotos_empresa, notice: 'Fotos empresa was successfully updated.' }
format.json { render :show, status: :ok, location: @fotos_empresa }
else
format.html { render :edit }
format.json { render json: @fotos_empresa.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @empresas.update(empresa_params)\n #File.extname(params[:logo].path)\n format.html { redirect_to @empresas, notice: 'Empresa was successfully updated.' }\n format.json { render :show, status: :ok, location: @empresas }\n else\n forma... | [
"0.6514478",
"0.64352906",
"0.6353353",
"0.6338215",
"0.6337079",
"0.6337079",
"0.6287684",
"0.6222424",
"0.6222141",
"0.6207968",
"0.6204778",
"0.61978185",
"0.6168992",
"0.61014175",
"0.61005306",
"0.6087029",
"0.6066618",
"0.6065872",
"0.6045812",
"0.6030342",
"0.6011959",... | 0.6861167 | 0 |
DELETE /fotos_empresas/1 DELETE /fotos_empresas/1.json | def destroy
@fotos_empresa.destroy
respond_to do |format|
format.html { redirect_to fotos_empresas_url, notice: 'Fotos empresa was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @foto.destroy\n respond_to do |format|\n format.html { redirect_to fotos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @foto = Foto.find(params[:id])\n @foto.destroy\n\n respond_to do |format|\n format.html { redirect_to fotos_url }\n f... | [
"0.73268193",
"0.7246554",
"0.7215032",
"0.72038674",
"0.7198135",
"0.7140757",
"0.7135134",
"0.71095705",
"0.70867217",
"0.70660174",
"0.7062079",
"0.7054283",
"0.70417583",
"0.7038",
"0.7032899",
"0.7026498",
"0.7006211",
"0.6994916",
"0.69821143",
"0.6975315",
"0.697528",
... | 0.7468334 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_fotos_empresa
@fotos_empresa = FotosEmpresa.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def fotos_empresa_params
params.require(:fotos_empresa).permit(:name, :image, :estado)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Keep URIs like this as they were input: | def path=(new_path)
super
if new_path[0..0] != '/' # addressable adds a / but scp-style uris are altered by this behavior
@path = path.sub(%r|^/+|,'')
@normalized_path = nil
validate
end
path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri_normalizer; end",
"def normalize\n uri = dup\n uri.normalize!\n uri\n end",
"def normalize_uri(*strs)\n new_str = strs * '/'\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\n new_str\n end",
"def normalize_uri\r\n self.link = Addressable::URI.heur... | [
"0.7110346",
"0.65558916",
"0.63931084",
"0.6074482",
"0.6025108",
"0.59675574",
"0.5935905",
"0.5935905",
"0.591151",
"0.59091246",
"0.5891018",
"0.58639556",
"0.58330065",
"0.5801311",
"0.5792798",
"0.57888573",
"0.5788427",
"0.5783444",
"0.5783444",
"0.57736105",
"0.574905... | 0.0 | -1 |
Get the URI as a string in the same form it was input. Taken from Addressable::URI. | def to_s
@uri_string ||=
begin
uri_string = "#{normalized_authority}:#{normalized_path}"
if uri_string.respond_to?(:force_encoding)
uri_string.force_encoding(Encoding::UTF_8)
end
uri_string
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n uri.to_s\n end",
"def to_s\n uri_string\n end",
"def to_s\n @uri.to_s\n end",
"def to_s\n @uri.to_s\n end",
"def to_s\n uri\n end",
"def to_s\n reconstruct_uri\n end",
"def to_s\n self.uri.to_s\n end",
"def to_s\n @ur... | [
"0.8432645",
"0.83854246",
"0.82970846",
"0.82970846",
"0.8071216",
"0.80264616",
"0.7997858",
"0.7971643",
"0.794352",
"0.78279793",
"0.7679003",
"0.7640053",
"0.7484552",
"0.7458709",
"0.73864716",
"0.7316196",
"0.7296652",
"0.7273483",
"0.71955323",
"0.71955323",
"0.712558... | 0.7956929 | 8 |
Return the actual scheme even though we don't show it | def inferred_scheme
'ssh'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheme; end",
"def scheme; end",
"def scheme; end",
"def scheme; end",
"def scheme\n attributes.fetch(:scheme)\n end",
"def scheme\n attributes.fetch(:scheme)\n end",
"def scheme\n attributes.fetch(:scheme)\n end",
"def scheme\n\t\t\t@options[:schem... | [
"0.78328466",
"0.78328466",
"0.78328466",
"0.78328466",
"0.7430929",
"0.7430929",
"0.7430929",
"0.7211511",
"0.7109889",
"0.7078122",
"0.693763",
"0.68889755",
"0.68889755",
"0.68122107",
"0.67955506",
"0.67838484",
"0.66584194",
"0.65200454",
"0.6509008",
"0.6499369",
"0.642... | 0.64082265 | 22 |
Scp style URIs are always ssh | def ssh?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssh_uri\n new_uri = @uri.host\n new_uri = \"#{@uri.user}@#{new_uri}\" if @uri.user\n\n return new_uri\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri.scheme = 'ssh'\n uri.path = ''\n uri.fragment = nil\n uri\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri... | [
"0.72554946",
"0.70845014",
"0.70845014",
"0.70845014",
"0.696894",
"0.68910515",
"0.6838482",
"0.6838482",
"0.6838482",
"0.6736807",
"0.6676267",
"0.66227716",
"0.6365412",
"0.6365412",
"0.6365412",
"0.6365412",
"0.61838436",
"0.61682683",
"0.58329433",
"0.5824551",
"0.58226... | 0.5773217 | 22 |
Is this an scp formatted uri? (Yes, always) | def scp?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def absolute_url?(string); end",
"def url?(uri)\n /\\w+\\:\\/\\// =~ uri\n end",
"def validate_uri(uri)\n unless uri.is_a?(String)\n return false\n end\n\n unless uri.slice(GIT_REGEXP).nil?\n return true\n end\n\n unless uri.slice(SCP_REGEXP).nil... | [
"0.6560364",
"0.6531914",
"0.65225935",
"0.6519746",
"0.6457378",
"0.64513016",
"0.643928",
"0.6393079",
"0.63580143",
"0.62727237",
"0.6253669",
"0.6205099",
"0.61840314",
"0.6169451",
"0.6145825",
"0.6132675",
"0.60920477",
"0.6088567",
"0.60739416",
"0.6042817",
"0.6013927... | 0.7442469 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.