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 |
|---|---|---|---|---|---|---|
Never trust parameters from the scary internet, only allow the white list through. | def plan_params
params.require(:plan).permit(:title, :body, :is_pending, :team_ids, :plan_status, :user_id, team_ids: [])
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 |
Called after_commit for select_order_items | def recalc_totals item_status = :current
# Calculate subtotal based on the item_status passed in (defaults to :current)
running_total = Money.new(0)
subtotal_amount = Money.new(order_subtotal(item_status))
running_total = subtotal_amount
# Calculate delivery amount (based on the select event?)
delivery_amount = Money.new(65)
running_total += delivery_amount
# Calculate gratuity
gratuity_amount = calc_gratuity(running_total)
running_total += gratuity_amount
# Calculate tax amount: subtotal + gratuity
tax_amount = calc_tax(running_total)
running_total += tax_amount
# Update total
total_amount = running_total
# Subsidy
subsidy_amount = subsidy total_amount
total_amount -= subsidy_amount
# Return values to caller
{subtotal_amount_cents: subtotal_amount,
gratuity_amount_cents: gratuity_amount,
delivery_amount_cents: delivery_amount,
tax_amount_cents: tax_amount,
subsidy_amount_cents: subsidy_amount,
total_amount_cents: total_amount}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_save_new_order\n end",
"def after_commit(unit); end",
"def update_order_item\n \n end",
"def set_order_items\n @order_items = @order.order_items\n end",
"def checkout \n \t@order_items = current_order.order_items\n end",
"def after_save; model.reset_dropdown_cache; ... | [
"0.68916315",
"0.6207488",
"0.6107448",
"0.6089352",
"0.57639647",
"0.57325953",
"0.5728954",
"0.5722527",
"0.57132155",
"0.57109857",
"0.5655272",
"0.56108665",
"0.5586067",
"0.5586067",
"0.5586067",
"0.55751884",
"0.54956627",
"0.54577905",
"0.54133826",
"0.53538",
"0.53518... | 0.0 | -1 |
Notes on status values for select orders: cart : In the cart can be freely edited by user (select/userfacing engine) or by admin user (snappea). checkout : On the checkout page. The user (select engine) has gone to the checkout page but has not placed the order. checkout_complete : Checkout completed, payment has been authorized by Braintree (select engine). canceled : Canceled by user (select engine) or admin user (snappea) pending : Select event is closed: No new orders allowed; No edits to existing orders; Manifests have been generated; All select orders in :checkout_complete are switched to :pending completed : "Food is delivered" email has been sent. Submit all authorized transactions for settlement system_canceled : Order is canceled by cron job All select orders for this event in :cart or :checkout state are cleanedup on endofday cron job. | def editing?
if Time.now > self.select_event.ordering_window_end_time
# Cutoff time has passed
false
elsif self.edit_mode
# SnapPea user is editing this select order
true
else
# Default => not editing since the edit_mode field isn't set
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkout\n @order = current_order\n @order.order_status_id = 2\n if @order.update_attributes(order_params)\n\n if @order.agreement\n @payment = PaymentChoice.find(@order.payment_choice_id)\n\n if @payment.name == \"Braintree\"\n @order.order_status_id = 6\n @order.... | [
"0.6372586",
"0.6165534",
"0.60978407",
"0.6087016",
"0.6072661",
"0.60612524",
"0.60599273",
"0.5994147",
"0.5992697",
"0.5967205",
"0.5949428",
"0.5939117",
"0.5932423",
"0.5891728",
"0.58776146",
"0.5876617",
"0.586827",
"0.5862171",
"0.58587635",
"0.5855199",
"0.5848374",... | 0.0 | -1 |
Cancel an existing order Void/refund all associated payments Set order status to :canceled | def cancel status=:canceled
result = true
# Refund all transactions associated with order
self.select_order_transactions.payments.each do |t|
result = self.braintree_refund_transaction t
end
# Mark the order as canceled if all braintree refunds succeeded
if result
self.edit_mode = false
self.status = status
self.save
end
# Return result
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cancel_order\n if self.status.downcase == \"pending\"\n self.status = \"Canceled\"\n self.save\n self\n else \n \"Error in Order Model\"\n end\n end",
"def cancel_order(source_account, order_id)\n\tputs \"Canceling order: \" + order_id + \" ... | [
"0.78458303",
"0.7582877",
"0.7540186",
"0.7512472",
"0.74816763",
"0.7473918",
"0.7405878",
"0.73773605",
"0.7364883",
"0.7351844",
"0.7143407",
"0.7129811",
"0.7033592",
"0.7025931",
"0.6987079",
"0.69176793",
"0.6871031",
"0.681693",
"0.67890334",
"0.67761767",
"0.6776096"... | 0.764531 | 1 |
Mark editing complete for an existing order Optionally set order status if supplied | def editing_complete status=nil
self.edit_mode = false
self.status = status.to_s if status
self.save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_as_complete(options)\n self.is_complete = options[:is_complete]\n self.is_applicable = true # if item.is_complete\n self.save_with_validation(false)\n end",
"def mark_order_complete\n order_params = (driver_order_params)\n order_params[:payable_attributes][:driver_id] = current_user.cust... | [
"0.726247",
"0.7044821",
"0.6929145",
"0.6689185",
"0.66368777",
"0.65484715",
"0.6458082",
"0.64566225",
"0.643651",
"0.6435009",
"0.6430113",
"0.6428273",
"0.64060324",
"0.6393137",
"0.6351694",
"0.63497895",
"0.62927586",
"0.6283625",
"0.62684315",
"0.6243773",
"0.6242605"... | 0.6996031 | 2 |
Refund an existing transaction & save it as a new select order transaction transaction => the transaction to refund or void | def braintree_refund_transaction transaction
if transaction and !transaction.is_refund and !transaction.superceded
# Attempt to refund the requested amount
if [:settled, :settling].include? transaction.status.to_sym
result = Braintree::Transaction.refund(transaction.transaction_id, amount)
elsif [:authorized, :submitted_for_settlement].include? transaction.status.to_sym
result = Braintree::Transaction.void(transaction.transaction_id)
else
# Cannot handle the current transaction state
return false
end
result_data = self.braintree_result_data result
if result_data[:transaction_id]
# Create the select order transaction row
t = Select::SelectOrderTransaction.create(
# Snappea data
user_id: user.id,
select_event_id: self.select_event.id,
select_order_id: self.id,
card_id: nil, # TODO
account_id: nil, # TODO
timestamp: Time.now,
amount: transaction.amount,
is_refund: true,
notes: transaction.notes,
# Braintree data
superceded: false,
customer_id: nil, # TODO
transaction_id: result_data[:transaction_id],
transaction_type: result_data[:transaction_type],
status: result_data[:status],
response: result_data[:response],
# Metadata
cc_last4: result_data[:cc_last4],
card_type: result_data[:card_type],
expiration_date: result_data[:expiration_date]
)
# Update the existing transaction by superceding it
transaction.update_attributes({
superceded: true,
notes: transaction.notes + "; Superceded by transaction: " + t.id.to_s
})
end
# Return true if successful
result.success?
else
# No such transaction id
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refund_order\n Stripe.api_key = ENV['STRIPE_SECRET_KEY']\n order = Commit.find(params[:order_id])\n charge = Stripe::Charge.retrieve(order.sale.stripe_charge_id, :stripe_account => order.product.wholesaler.stripe_id)\n begin\n refund = charge.refunds.create(:amount => charge.amount, :refund_ap... | [
"0.7600811",
"0.75682425",
"0.716211",
"0.7126755",
"0.7068625",
"0.7058066",
"0.7056174",
"0.7049028",
"0.70214844",
"0.70095426",
"0.6954271",
"0.6883908",
"0.68317455",
"0.679138",
"0.6759196",
"0.6695405",
"0.6665431",
"0.66472715",
"0.6641184",
"0.6633623",
"0.66217804",... | 0.7439311 | 2 |
Get details of a stored procedure | def stored_procedure(name)
get "#{base_url}/storedprocedures/#{name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect\n \"<#{self.class.name}/StoredProcedure name=#{@sproc_name}>\"\n end",
"def get_procedures\n connect_db.fetch(\"SELECT RDB$PROCEDURE_NAME, RDB$PROCEDURE_SOURCE FROM RDB$PROCEDURES\")\n end",
"def procedure_params\n params[:procedure]\n end",
"def to_s\n \"#<procedu... | [
"0.7388445",
"0.6818748",
"0.6778475",
"0.6400616",
"0.63053",
"0.60947293",
"0.60722625",
"0.600247",
"0.583012",
"0.5824742",
"0.58188593",
"0.5730571",
"0.57286793",
"0.56737804",
"0.5666101",
"0.56406224",
"0.55920875",
"0.55916184",
"0.5542823",
"0.55324805",
"0.54893684... | 0.7205838 | 1 |
GET /api/users/1 GET /api/users/1.json | def show
@user = User.find_by(username: params[:id])
render :show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.82854503",
"0.8002468",
"0.7702122",
"0.76229024",
"0.75719595",
"0.7562091",
"0.75326085",
"0.74904794",
"0.7476293",
"0.7447042",
"0.74349654",
"0.7398113",
"0.7374086",
"0.7338114",
"0.7323381",
"0.73158956",
"0.73146147",
"0.73125494",
"0.72650015",
"0.72608525",
"0.72... | 0.0 | -1 |
POST /api/users POST /api/users.json | def create
@user = User.new(user_params)
if @user.save
login(@user)
render :show
else
render json: @user.errors.full_messages, status: 422
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77696055",
"0.7715399",
"0.74774957",
"0.72712666",
"0.7257523",
"0.72392815",
"0.7238419",
"0.71692145",
"0.7145948",
"0.7144342",
"0.7137745",
"0.7127959",
"0.71245164",
"0.7122874",
"0.71205556",
"0.70954525",
"0.70851696",
"0.7064169",
"0.7064169",
"0.7064169",
"0.7058... | 0.0 | -1 |
PATCH/PUT /api/users/1 PATCH/PUT /api/users/1.json | def update
if @user.update(user_params)
render :show
else
render json: @user.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.7255074",
"0.71287984",
"0.7023148",
"0.68843883",
"0.6871747",
"0.685192",
"0.67992973",
"0.67949516",
"0.67491424",
"0.6731493",
"0.67004377",
"0.66624266",
"0.6655125",
"0.66494757",
"0.66303724",
"0.66235024",
"0.6611312",
"0.6611312",
"0.6597745",
"0.659719",
"0.65861... | 0.0 | -1 |
DELETE /api/users/1 DELETE /api/users/1.json | def destroy
@user.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def destroy\n @user = User.find_by_id_or_username params[:id]\n @user.destroy\n render api_delete @user\n end",
"def d... | [
"0.8176099",
"0.8037374",
"0.7915856",
"0.7908018",
"0.78715193",
"0.7742257",
"0.7742257",
"0.773173",
"0.7714246",
"0.77097553",
"0.76965594",
"0.76766056",
"0.76670444",
"0.7663296",
"0.7639878",
"0.7609528",
"0.76033205",
"0.75689375",
"0.75667244",
"0.75652003",
"0.75648... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.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 user_params
params.require(:user).permit(:username, :password, :avatar, :token)
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 |
Liaison monnaies et prix | def trader
# Rappel des methodes :
symbols_array = scrap_symbols
prices_array = scrap_prices
a = [] # Initialisation d'un array pour les stocker
symbols_array.each_with_index do |x, y|
# -> On associe pour chaque item de symbols_array un item de prices_array
a << {x => (prices_array)[y]}
# -> On sauvegarde sous forme d'hash dans le tableau
end
print a
return a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nouveau_prix\n nouveau_prix = 0\n if(!bouteille.nil?)\n nouveau_prix = bouteille.prix\n nouveau_prix = nouveau_prix * (1 - (rabais/100)) if rabais?\n end\n ActionController::Base.helpers.number_to_currency(nouveau_prix, unit: \"\", separator: \".\", delimiter: \"\", format: \"%n\")\n end... | [
"0.70341676",
"0.69974715",
"0.681471",
"0.66220915",
"0.64249563",
"0.64218134",
"0.64130425",
"0.6388845",
"0.6377662",
"0.6339896",
"0.63332474",
"0.6299804",
"0.62984234",
"0.6284372",
"0.6255349",
"0.6245225",
"0.6238482",
"0.6184443",
"0.61788225",
"0.61601937",
"0.6157... | 0.0 | -1 |
used in their solution | def initialize(rank, suit)
@rank = rank
@suit = suit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def stderrs; end",
"def suivre; end",
"def malts; end",
"def formation; end",
"def terpene; end",
"def schumann; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def berlioz; end",
"def operat... | [
"0.714414",
"0.68340576",
"0.6587517",
"0.6575134",
"0.6473281",
"0.641674",
"0.6400062",
"0.6391294",
"0.63888365",
"0.6387626",
"0.6387626",
"0.6387626",
"0.6387626",
"0.6375789",
"0.63508105",
"0.63508105",
"0.63049036",
"0.6287088",
"0.6272002",
"0.6178363",
"0.6178363",
... | 0.0 | -1 |
GET /xmt/addons GET /xmt/addons.json | def index
@apps = Addon.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_addons(app=nil)\n path = if app\n \"/apps/#{app}/addons\"\n else\n \"/addons\"\n end\n request(\n :expects => 200,\n :method => :get,\n :path => path\n )\n end",
"def get_clients_addons(params = {})\n\t\tparams.merge!(:action => 'getcl... | [
"0.80395913",
"0.70687234",
"0.6925943",
"0.69099057",
"0.6887222",
"0.6730861",
"0.6683669",
"0.65749335",
"0.6477819",
"0.64372134",
"0.6391009",
"0.63181365",
"0.622692",
"0.6084708",
"0.60617995",
"0.6024379",
"0.58619875",
"0.5803104",
"0.5785684",
"0.57063586",
"0.56852... | 0.60830635 | 14 |
GET /xmt/addons/1 GET /xmt/addons/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_addons(app=nil)\n path = if app\n \"/apps/#{app}/addons\"\n else\n \"/addons\"\n end\n request(\n :expects => 200,\n :method => :get,\n :path => path\n )\n end",
"def get_clients_addons(params = {})\n\t\tparams.merge!(:action => 'getcl... | [
"0.7693937",
"0.6852981",
"0.6600357",
"0.65311754",
"0.6410955",
"0.6270688",
"0.624708",
"0.62325245",
"0.61582595",
"0.60578936",
"0.605743",
"0.6051019",
"0.5899223",
"0.5875562",
"0.58252865",
"0.58218765",
"0.5820797",
"0.57615274",
"0.57615274",
"0.57105094",
"0.567728... | 0.0 | -1 |
POST /xmt/addons POST /xmt/addons.json | def create
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addon_params\n params.require(:xmt_addon).permit!\n end",
"def get_addons(app=nil)\n path = if app\n \"/apps/#{app}/addons\"\n else\n \"/addons\"\n end\n request(\n :expects => 200,\n :method => :get,\n :path => path\n )\n end",
... | [
"0.65353346",
"0.6518918",
"0.6031212",
"0.5991275",
"0.58627856",
"0.58574337",
"0.58145547",
"0.57844406",
"0.5724894",
"0.5643226",
"0.5596802",
"0.5585432",
"0.5520566",
"0.5494717",
"0.54764175",
"0.5467544",
"0.54673",
"0.54587764",
"0.54587764",
"0.5340771",
"0.5319821... | 0.0 | -1 |
PATCH/PUT /xmt/addons/1 PATCH/PUT /xmt/addons/1.json | def update
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @addons_combo.update(addons_combo_params)\n format.html { redirect_to @addons_combo, notice: 'Addons combo was successfully updated.' }\n format.json { render :show, status: :ok, location: @addons_combo }\n else\n format.html { render :edit... | [
"0.6053457",
"0.60364205",
"0.591894",
"0.5825723",
"0.5813528",
"0.57991606",
"0.5745602",
"0.571238",
"0.5644848",
"0.56424874",
"0.5639468",
"0.5577133",
"0.55666286",
"0.554429",
"0.5539274",
"0.5536827",
"0.55263865",
"0.55183583",
"0.55123556",
"0.55123556",
"0.54741263... | 0.0 | -1 |
DELETE /xmt/addons/1 DELETE /xmt/addons/1.json | def destroy
@addon.drop
@addon.save(isinstall: 0)
respond_to do |format|
format.html { redirect_to xmt_addons_url, notice: '卸载成功.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @addons_combo.destroy\n respond_to do |format|\n format.html { redirect_to addons_combos_url, notice: 'Addons combo was successfully destroyed.' }\n format.json { head :no_content... | [
"0.6735214",
"0.67277354",
"0.6648859",
"0.65678364",
"0.6547034",
"0.6434617",
"0.6434617",
"0.6434617",
"0.6434617",
"0.6413081",
"0.6395515",
"0.6369724",
"0.6368613",
"0.6349269",
"0.6345683",
"0.6269185",
"0.6221252",
"0.6213265",
"0.6203898",
"0.6203898",
"0.6203589",
... | 0.7014161 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_addon
@addon = Addon.all.find {|a| a.name == 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 addon_params
params.require(:xmt_addon).permit!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /equipment_line_items GET /equipment_line_items.json | def index
@equipment_line_items = EquipmentLineItem.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @item_line = ItemLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_line }\n end\n end",
"def set_equipment_line_item\n @equipment_line_item = EquipmentLineItem.find(params[:id])\n end",
"def show\n puts p... | [
"0.6734687",
"0.66849494",
"0.66270417",
"0.65268165",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6526566",
"0.6501052",
"0.6473452",
"0.64032495",
"0.6299003",
"0.62967956",
"0.62814134",
"0.61766535",
"0.61766535",
"0.61766535",
"0.6176... | 0.7343322 | 0 |
GET /equipment_line_items/1 GET /equipment_line_items/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @equipment_line_items = EquipmentLineItem.all\n end",
"def show\n @item_line = ItemLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_line }\n end\n end",
"def show\n puts params.inspect.green\n\n @line_it... | [
"0.71892077",
"0.70756924",
"0.6912507",
"0.6869938",
"0.6869938",
"0.6869938",
"0.6869938",
"0.6869938",
"0.6869938",
"0.6869938",
"0.68697894",
"0.6834366",
"0.68304515",
"0.68218595",
"0.67362297",
"0.6667466",
"0.64395887",
"0.6328225",
"0.628078",
"0.62707734",
"0.626177... | 0.0 | -1 |
POST /equipment_line_items POST /equipment_line_items.json | def create
@equipment_move_buffer = current_equipment_buffer
equipment = Equipment.find(params[:equipment_id])
@equipment_line_item = @equipment_move_buffer.equipment_line_items.build(equipment_id: equipment.id)
respond_to do |format|
if @equipment_line_item.save
format.html { redirect_to @equipment_line_item.equipment_move_buffer, notice: 'Equipment line item was successfully created.' }
format.json { render action: 'show', status: :created, location: @equipment_line_item }
else
format.html { render action: 'new' }
format.json { render json: @equipment_line_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equipment_line_item_params\n params.require(:equipment_line_item).permit(:equipment_id, :equipment_move_buffer_id)\n end",
"def create\n @line_item = @order.line_items.new(line_item_params)\n\n if @line_item.save\n render json: @line_item, status: :created, location: [@order, @line_item]\n... | [
"0.715378",
"0.700165",
"0.6992175",
"0.6986218",
"0.69617456",
"0.68617606",
"0.66440517",
"0.6642671",
"0.6616322",
"0.65748125",
"0.65647274",
"0.6480147",
"0.64055717",
"0.63640094",
"0.63508433",
"0.6330478",
"0.63295215",
"0.6323234",
"0.63168323",
"0.63168323",
"0.6290... | 0.74162716 | 0 |
PATCH/PUT /equipment_line_items/1 PATCH/PUT /equipment_line_items/1.json | def update
respond_to do |format|
if @equipment_line_item.update(equipment_line_item_params)
format.html { redirect_to @equipment_line_item, notice: 'Equipment line item was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @equipment_line_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @item_line = ItemLine.find(params[:id])\n\n respond_to do |format|\n if @item_line.update_attributes(params[:item_line])\n format.html { redirect_to @item_line, notice: 'Item line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html ... | [
"0.72180456",
"0.7070916",
"0.7067693",
"0.7067693",
"0.7067693",
"0.7067693",
"0.7067693",
"0.7054382",
"0.6994966",
"0.6972458",
"0.69691306",
"0.69691306",
"0.69691306",
"0.69354904",
"0.69189715",
"0.68818164",
"0.68818164",
"0.68818164",
"0.68818164",
"0.68818164",
"0.68... | 0.7564775 | 0 |
DELETE /equipment_line_items/1 DELETE /equipment_line_items/1.json | def destroy
@equipment_line_item.destroy
respond_to do |format|
format.html { redirect_to equipment_line_items_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @item_line = ItemLine.find(params[:id])\n @item_line.destroy\n\n respond_to do |format|\n format.html { redirect_to item_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respo... | [
"0.74537766",
"0.73998326",
"0.73998326",
"0.73998326",
"0.73998326",
"0.7398179",
"0.73776263",
"0.7330342",
"0.7322835",
"0.7316112",
"0.7316112",
"0.7315366",
"0.7294381",
"0.7266991",
"0.72234195",
"0.7218495",
"0.7183648",
"0.7183648",
"0.7183648",
"0.7183648",
"0.718364... | 0.7829396 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_equipment_line_item
@equipment_line_item = EquipmentLineItem.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 equipment_line_item_params
params.require(:equipment_line_item).permit(:equipment_id, :equipment_move_buffer_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 |
Returns the UCB::LDAP::Person for this User | def ldap_person
@person ||= UCB::LDAP::Person.find_by_uid(self.login) if self.login
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_user\n results = @ldap.search( :base => options[:ldap][:base], :filter => user_filter)\n return results.first\n end",
"def get_active_directory_user(username, is_registered=false)\n user_attributes = get_ad_user_attributes(username, is_registered)\n return nil if user_attributes.nil?\... | [
"0.6858983",
"0.6063733",
"0.6018299",
"0.59120214",
"0.58487386",
"0.58237636",
"0.58237636",
"0.58237636",
"0.5784712",
"0.57712716",
"0.57703793",
"0.5739711",
"0.56722015",
"0.5615683",
"0.56151265",
"0.56083846",
"0.55936754",
"0.5590984",
"0.554399",
"0.5537872",
"0.552... | 0.7637795 | 0 |
Updates basic User information from LDAP Returns whether the LDAP lookup succeeded | def fill_from_ldap
person = self.ldap_person
if person.nil?
if Rails.development?
self.name = "Susan #{self.login}"
self.email = "beehive+#{self.login}@berkeley.edu"
self.major_code = 'undeclared'
self.user_type = case self.login
when 212388, 232588
User::Types::Grad
when 212381, 300846, 300847, 300848, 300849, 300850
User::Types::Undergrad
when 212386, 322587, 322588, 322589, 322590
User::Types::Faculty
when 212387, 322583, 322584, 322585, 322586
User::Types::Staff
else
User::Types::Affiliate
end
return true
else
self.name = 'Unknown Name'
self.email = ''
self.major_code = ''
self.user_type = User::Types::Affiliate
return false
end
else
self.name = "#{person.firstname} #{person.lastname}".titleize
self.email = person.email
self.major_code = person.berkeleyEduStuMajorName.to_s.downcase
self.user_type = case
when person.berkeleyEduStuUGCode == 'G'
User::Types::Grad
when person.student?
User::Types::Undergrad
when person.employee_academic?
User::Types::Faculty
when person.employee?
User::Types::Staff
else
User::Types::Affiliate
end
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ldap_verify_and_update\n return unless self.is_ldap?\n\n scanner = LdapQuery::Scanner.search self.login, :only=>:ldap\n\n if scanner.errors.size > 0\n errors.add(:login, 'Login is invalid or cannot be found in OHSU\\'s servers')\n return\n end\n\n # Update our information from ldap... | [
"0.79851204",
"0.72285575",
"0.71714485",
"0.6945893",
"0.66581243",
"0.6496271",
"0.6483121",
"0.64818895",
"0.6459651",
"0.64393765",
"0.6407154",
"0.63864374",
"0.6221488",
"0.61170936",
"0.610371",
"0.6073358",
"0.60655046",
"0.6035414",
"0.59940195",
"0.5949329",
"0.5925... | 0.63304704 | 12 |
Makes more sense to handle these for each job def received_jobs_list_of_user jobs = [] self.applics.all.each do |w| this_job = Job.find_by_id(w.job_id) if this_job && w.status == "accepted" then jobs << this_job end end jobs end Parses the textbox list of courses from "CS162,CS61A,EE123" etc. to an enumerable object courses | def handle_courses(course_names)
return if !self.undergrad? || course_names.nil?
self.courses = [] # eliminates any previous enrollments so as to avoid duplicates
course_array = []
course_array = course_names.split(',').uniq if course_names
course_array.each do |item|
self.courses << Course.find_or_create_by(name: item.upcase.strip)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def possible_jobs\n \n\n job = params[:job].titleize\n location = params[:location].titleize\n\n results = Cb.job.search({ location: location,\n keywords: job })\n jobs = results.model.jobs\n @job_data = {\n job: job,\n location: location,\n job_results... | [
"0.61990225",
"0.6037884",
"0.5983487",
"0.5902812",
"0.5829344",
"0.57987195",
"0.5748478",
"0.56658167",
"0.5556751",
"0.5543459",
"0.55333525",
"0.5448827",
"0.5423382",
"0.54153246",
"0.54114544",
"0.5368688",
"0.536731",
"0.5360066",
"0.53317136",
"0.53286946",
"0.532764... | 0.5316585 | 21 |
Parses the textbox list of categories from "signal processing,robotics" etc. to an enumerable object categories | def handle_categories(category_names)
return if !self.undergrad? || category_names.nil?
self.categories = [] # eliminates any previous interests so as to avoid duplicates
category_array = []
category_array = category_names.split(',').uniq if category_names
category_array.each do |cat|
self.categories << Category.find_or_create_by(name: cat.downcase.strip)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cats_input=(what)\n self.categories = if what.blank?\n []\n else\n what.chomp.split(\"\\n\").map(&:downcase).map(&:strip)\n end\nend",
"def cats_input\n self.categories.join(\"\\n\")\nend",
"def get_categories\n cats = [... | [
"0.64344484",
"0.63578373",
"0.62762845",
"0.6022241",
"0.5952684",
"0.58816195",
"0.5880453",
"0.58390874",
"0.581576",
"0.5803598",
"0.57045627",
"0.56885934",
"0.5664371",
"0.560471",
"0.5588805",
"0.5537497",
"0.55332404",
"0.553303",
"0.5487114",
"0.5484641",
"0.5481546"... | 0.58182085 | 8 |
Parses the textbox list of proglangs from "c++,python" etc. to an enumerable object proglangs | def handle_proglangs(proglang_names)
return if !self.undergrad? || proglang_names.nil?
self.proglangs = [] # eliminates any previous proficiencies so as to avoid duplicates
proglang_array = []
proglang_array = proglang_names.split(',').uniq if proglang_names
proglang_array.each do |pl|
self.proglangs << Proglang.find_or_create_by(name: pl.upcase.strip)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_command_list\n @list = SES::ExternalText::Languages\n end",
"def index\n words = params[:q] && Shellwords.split(params[:q]).map(&:squish)\n if words.present?\n @with = words.reject{|word| word.first == '-'}\n @without = words.select{|word| word.first == '-'}.map do |word|\n wo... | [
"0.5590375",
"0.5548614",
"0.5345294",
"0.5265395",
"0.52183896",
"0.5173649",
"0.5158272",
"0.51535046",
"0.5131342",
"0.5125924",
"0.51000714",
"0.50984925",
"0.50802815",
"0.50586385",
"0.5038667",
"0.50186735",
"0.49839416",
"0.49807596",
"0.49715447",
"0.49663463",
"0.49... | 0.58714145 | 0 |
def location_list locations = [] Board.all.each do |board| brands << board.brand end brands.uniq end | def set_profile
@profile = current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations\n\t\t[]\n\tend",
"def locations; end",
"def locations\n unless defined?(@locations)\n @locations=[]\n for loc in Location.order(\"id ASC\").includes(:bottom_right_coordinate, :top_left_coordinate)\n @locations << loc if do_overlap_with?(loc.area)\n end \n end \n @... | [
"0.74884546",
"0.7350971",
"0.72771066",
"0.7085344",
"0.6824672",
"0.6824672",
"0.6750698",
"0.67322356",
"0.67247367",
"0.670587",
"0.669715",
"0.6678223",
"0.66461",
"0.6642384",
"0.66328746",
"0.66328746",
"0.66164804",
"0.66113144",
"0.6526681",
"0.6424622",
"0.6421036",... | 0.0 | -1 |
for not showing new page to others before_filter :must_be_admin, only: [:edit, :new] | def search
if params[:search].present?
@books = Book.search(params[:search])
else
@books = Book.all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_admin\n unless view_context.admin?\n redirect_to root_url\n end\n end",
"def only_admin\n if user_role == 'admin'\n else\n redirect_to clients_path, notice: \"У вас нет прав для просмотра даного раздела, или редактирования информации\"\n end\n end",
"def admin_user\n redir... | [
"0.7284695",
"0.72518456",
"0.7233384",
"0.717837",
"0.71589315",
"0.7144592",
"0.7095423",
"0.709113",
"0.70763695",
"0.70763695",
"0.70763695",
"0.7070386",
"0.7046776",
"0.7044493",
"0.7011657",
"0.7011623",
"0.6999296",
"0.6998323",
"0.69762933",
"0.6958852",
"0.6946455",... | 0.0 | -1 |
DELETE /books/1 DELETE /books/1.json | def destroy
@book.destroy
respond_to do |format|
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n \n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n form... | [
"0.7483369",
"0.74432313",
"0.74432313",
"0.7437104",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74191445",
"0.7401149",
"0.7401149",
"0.7401149",
"... | 0.7147981 | 64 |
Use callbacks to share common setup or constraints between actions. | def set_book
@book = Book.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 book_params
params.require(:book).permit(:Title, :Summary, :Rating, :Author, :Ranking, :Awards, :Recommended_by, :Amazon, :Audiobook, :Animated_Review,:image,:category_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 |
Does its best to convert the input into a Boolean. | def convert_to_boolean(input)
case input
when false, 0, '0', 'false', 'no', nil then false
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_boolean\n # SECURE: BNS 2012-10-09: But may behave oddly for multi-line input\n return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)\n return false if self == false || self.nil? || self =~ (/^(false|f|no|n|0)$/i)\n fail ArgumentError, \"invalid value for Boolean: \\\"#{self}\\\"\"\n e... | [
"0.8342446",
"0.82365483",
"0.81131643",
"0.8107313",
"0.8014266",
"0.79928374",
"0.7984583",
"0.79372895",
"0.78685623",
"0.7838493",
"0.7763114",
"0.77619374",
"0.775726",
"0.7747159",
"0.77257603",
"0.7721171",
"0.7718274",
"0.7699234",
"0.7691891",
"0.7691891",
"0.7674086... | 0.8309957 | 1 |
sort by created_at, updated_at | def sort_accounts
if params[:sort_by].present?
criteria = params[:sort_by]
@accounts = if criteria == 'last_created_at'
@accounts.order('created_at desc')
elsif criteria == 'first_created_at'
@accounts.order('created_at asc')
else
@accounts.order('updated_at desc')
end
else # default sorting
@accounts = @accounts.order('updated_at desc')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_time\n (updated_at || published_at)\n end",
"def sort_tweets\n tweets.sort { |a, b| b.created_at <=> a.created_at }\n end",
"def chronological\n wrap(\n sort do |a, b|\n Time.parse(a['created_at']) <=> Time.parse(b['created_at'])\n end,\n )\n end",
... | [
"0.7467505",
"0.73870295",
"0.7340026",
"0.7310985",
"0.71304756",
"0.706289",
"0.7032139",
"0.69878143",
"0.6955125",
"0.69387084",
"0.6920193",
"0.6702314",
"0.66953933",
"0.66916895",
"0.66914904",
"0.66891557",
"0.66712296",
"0.66314167",
"0.6613219",
"0.65003717",
"0.645... | 0.61944926 | 33 |
Use callbacks to share common setup or constraints between actions. | def set_account
@account = Account.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 account_params
params.require(:account).permit(:balance, :account_number,
:cvv, :expiry_date, :currency, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
CALL adr_salt nr_par nivel Apel de subprogram: completeaza un nod nou in stiva BAZA, rezerva in stiva de lucru spatiu pentru variabilele locale, memoreaza adresa de revenire si executa saltul la codul subprogramului apelat. VBAZA = VBAZA + 1 BAZA[VBAZA].LEVEL = nivel BAZA[VBAZA].BLOC = SP nr_par + 1 SP = SP + STIVA[BAZA[VBAZA].BLOC 1].INFO STIVA[BAZA[VBAZA].BLOC 1].INFO = NI + 4 NI = adr_salt | def call(jmp_addr, no_params, level)
base << [level, sp-no_params+1]
s[base.last[1]-1] = ni + 4
self.ni = jmp_addr
@jump = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def informa(pippo)\n # 1. Calcolo i valori di c14_idaliquotaiva e la loro frequenza in lbooks\n ivaInLbooks = Lbook.gruppiIVA\n risultL = \"1. Segue hash ivaInLbooks: #{ivaInLbooks.inspect}\"\n pippo.scriviRiga(risultL)\n\n # 2. Calcolo i valori di idaliquotaiva e la loro frequenza in books\n ... | [
"0.5396362",
"0.51763636",
"0.5153415",
"0.5126988",
"0.5106015",
"0.5099818",
"0.50711536",
"0.50543875",
"0.505391",
"0.5045098",
"0.5033835",
"0.50246465",
"0.49894086",
"0.49797004",
"0.49671447",
"0.4953576",
"0.4929124",
"0.4905523",
"0.48781037",
"0.48706254",
"0.48280... | 0.49947336 | 12 |
RET Revenire dintrun subprogram. SP = BAZA[VBAZA].BLOC 2 NI = STIVA[SP + 1] VBAZA = VBAZA 1 | def ret
self.s = s[0..(base.pop[1]-1)]
self.ni = s.pop
@jump = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepara_palavra(palavra)\r\n\tusagi=[]\r\n\tfor t in 0..(palavra.length()-1)\r\n\t\tusagi.push(palavra[t])\r\n\tend\r\n\t#puts usagi\r\n\treturn usagi\r\nend",
"def conta_vicini(i,j,game)\n vicini = 0\n \n #### BORDI RIGIDI\n #if i > 0\n # vicini += 1 if game[:griglia][i-1][j]\n #end\n #if i > 0 && j... | [
"0.53620654",
"0.53321594",
"0.53125554",
"0.5295185",
"0.52044505",
"0.51788306",
"0.5160379",
"0.5145509",
"0.51386064",
"0.51342934",
"0.5120914",
"0.5099961",
"0.509007",
"0.5088421",
"0.5085721",
"0.508533",
"0.5083481",
"0.5047562",
"0.5039486",
"0.5016917",
"0.4988517"... | 0.4738375 | 77 |
The one where we don't have "" | def tests_song_not_found
assert_equal =
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def just_first\n first.split(' ')[0]\n end",
"def first_non_empty(*args)\n while !args.empty?\n ret = args.shift\n return ret unless ret.to_s.empty?\n end\n return ''\n end",
"def none?\n @value.to_s.empty? or /\\Anone\\z/io.match(@value.to_s)\n end",
"def skip_include_bla... | [
"0.6433048",
"0.6149718",
"0.6144712",
"0.61202455",
"0.6082769",
"0.6079247",
"0.5933599",
"0.5932659",
"0.58898187",
"0.58618945",
"0.58589274",
"0.5821242",
"0.57771647",
"0.57770556",
"0.576495",
"0.5733407",
"0.5726904",
"0.57193846",
"0.57083446",
"0.56912804",
"0.56767... | 0.0 | -1 |
On the initial new request, prototype from the layout. On subsequent form requests, build normally from the params. | def build_resource
get_resource_ivar || set_resource_ivar(built_resource)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(request)\n @params = {}\n @params.merge! request.class.query_parse(request.params[\"QUERY_STRING\"])\n \n # Check to see if a form was submitted and fill in the form values\n if request.is_multipart?\n @params.merge! request.split_multipart\n end #if\n end",
... | [
"0.67320037",
"0.635461",
"0.635461",
"0.62069917",
"0.61295956",
"0.61284316",
"0.6102219",
"0.60569906",
"0.60260606",
"0.5974883",
"0.59499466",
"0.59488857",
"0.59432083",
"0.5924008",
"0.58617014",
"0.586131",
"0.585891",
"0.58297026",
"0.5814387",
"0.57734686",
"0.57731... | 0.0 | -1 |
NOTE this will need to be overridden for controller routes that don't uesr permalink | def record_to_copy
params[:copy_id] && resource_class.find_by_permalink(params[:copy_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permalink; end",
"def permalink; end",
"def custom_routes; end",
"def _routes; end",
"def url_for_index; end",
"def url_for_index; end",
"def anchored_routes; end",
"def permalink\n return \"#{uri}\"\n end",
"def to_param\n return permalink if to_param_returns_permalink\n... | [
"0.7180377",
"0.7180377",
"0.6761075",
"0.6741748",
"0.6669785",
"0.6669785",
"0.66587895",
"0.6546003",
"0.650777",
"0.65068626",
"0.65063316",
"0.6477632",
"0.64562666",
"0.64562666",
"0.6405864",
"0.63942325",
"0.6319624",
"0.6319624",
"0.6302231",
"0.6302231",
"0.6302231"... | 0.0 | -1 |
GET /alternativas GET /alternativas.json | def index
@alternativas = Alternativa.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @alternativos = Alternativo.all\n end",
"def set_alternativa\n @alternativa = Alternativa.find(params[:id])\n end",
"def set_alternativa\n @alternativa = Alternativa.find(params[:id])\n end",
"def set_alternativo\n @alternativo = Alternativo.find(params[:id])\n end",
... | [
"0.69971466",
"0.6498366",
"0.6498366",
"0.64737713",
"0.6409124",
"0.62824976",
"0.61535627",
"0.6129971",
"0.6121928",
"0.60777694",
"0.60193807",
"0.60155755",
"0.59702927",
"0.58695287",
"0.57263297",
"0.5691227",
"0.5677521",
"0.56592166",
"0.56570584",
"0.56557494",
"0.... | 0.7347227 | 0 |
GET /alternativas/1 GET /alternativas/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @alternativas = Alternativa.all\n end",
"def index\n @alternativos = Alternativo.all\n end",
"def show\n @alternativa = Alternativa.find(params[:id])\n @caracteristica = @alternativa.caracteristica\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { r... | [
"0.720292",
"0.68971455",
"0.65599126",
"0.65155125",
"0.64964813",
"0.64964813",
"0.6463232",
"0.6081515",
"0.60740495",
"0.6046594",
"0.60087824",
"0.59776175",
"0.59313124",
"0.5906834",
"0.59039295",
"0.58847475",
"0.5867455",
"0.5865776",
"0.5865776",
"0.5865776",
"0.585... | 0.0 | -1 |
POST /alternativas POST /alternativas.json | def create
@alternativa = Alternativa.new(alternativa_params)
respond_to do |format|
if @alternativa.save
format.html { redirect_to @alternativa, notice: 'Alternativa was successfully created.' }
format.json { render :show, status: :created, location: @alternativa }
else
format.html { render :new }
format.json { render json: @alternativa.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @alternativo = Alternativo.new(alternativo_params)\n\n respond_to do |format|\n if @alternativo.save\n format.html { redirect_to @alternativo, notice: 'Alternativo was successfully created.' }\n format.json { render :show, status: :created, location: @alternativo }\n else... | [
"0.7301132",
"0.68833977",
"0.6863226",
"0.6854097",
"0.64734524",
"0.64412075",
"0.6407407",
"0.6292914",
"0.62471664",
"0.6233773",
"0.6233773",
"0.59148645",
"0.5905892",
"0.5817316",
"0.58154386",
"0.5765965",
"0.57640475",
"0.56542134",
"0.5650958",
"0.5562129",
"0.55086... | 0.72534 | 1 |
PATCH/PUT /alternativas/1 PATCH/PUT /alternativas/1.json | def update
respond_to do |format|
if @alternativa.update(alternativa_params)
format.html { redirect_to @alternativa, notice: 'Alternativa was successfully updated.' }
format.json { render :show, status: :ok, location: @alternativa }
else
format.html { render :edit }
format.json { render json: @alternativa.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @alternativo.update(alternativo_params)\n format.html { redirect_to @alternativo, notice: 'Alternativo was successfully updated.' }\n format.json { render :show, status: :ok, location: @alternativo }\n else\n format.html { render :edit }\n ... | [
"0.6872784",
"0.6501358",
"0.633831",
"0.61324465",
"0.61103684",
"0.6082221",
"0.6075222",
"0.6063081",
"0.60572714",
"0.60572714",
"0.6054513",
"0.6046305",
"0.60377055",
"0.60355407",
"0.60310507",
"0.60140586",
"0.60007405",
"0.59981537",
"0.5982089",
"0.5976963",
"0.5976... | 0.686758 | 1 |
DELETE /alternativas/1 DELETE /alternativas/1.json | def destroy
@alternativa.destroy
respond_to do |format|
format.html { redirect_to alternativas_url, notice: 'Alternativa was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @alternativo.destroy\n respond_to do |format|\n format.html { redirect_to alternativos_url, notice: 'Alternativo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delete\n ... | [
"0.73670256",
"0.706965",
"0.69742775",
"0.6925704",
"0.68907547",
"0.6864281",
"0.68156344",
"0.679814",
"0.67820907",
"0.676412",
"0.6752453",
"0.6752453",
"0.67454946",
"0.67203236",
"0.67168784",
"0.67168784",
"0.67168784",
"0.6705388",
"0.66898257",
"0.6679441",
"0.66747... | 0.7395869 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_alternativa
@alternativa = Alternativa.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 alternativa_params
params.require(:alternativa).permit(:desc, :question_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
METHODS FOR asins table | def add_asin(asin)
match = $db.execute("SELECT asin FROM asins WHERE asin = ?", [asin])
if match == []
$db.execute("INSERT INTO asins (asin) VALUES (?)", [asin])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table; end",
"def table; end",
"def table; end",
"def table; end",
"def table\n end",
"def _table; @table end",
"def table=(_arg0); end",
"def on_table?; @on_table; end",
"def initialize_table; end",
"def row; end",
"def as_table\n @as_table ||= Arel::Table.new(:authorized_objects_to_... | [
"0.68981117",
"0.68981117",
"0.68981117",
"0.68981117",
"0.66192466",
"0.6526396",
"0.625301",
"0.6209518",
"0.60598326",
"0.5998923",
"0.5965275",
"0.58618987",
"0.5845655",
"0.5777725",
"0.5771974",
"0.57706046",
"0.5769503",
"0.5755902",
"0.5742339",
"0.57124865",
"0.57124... | 0.0 | -1 |
METHODS FOR PRICES TABLE | def add_price(asin, title, price_s, price_i, day, day_i)
$db.execute("INSERT INTO prices (asin, title, price_s, price_i, day, day_i) VALUES (?,?,?,?,?,?)", [asin, title, price_s, price_i, day, day_i])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoices_by_id_select\n \n end",
"def relation_method\n :product\n end",
"def list_of_pvas\n super\n end",
"def pricing_policy\n car.pricing_policy\n end",
"def index\n @prizes = Prize.all\n end",
"def selected_price_model\n \t@selected_price_model\n \tend"... | [
"0.5640158",
"0.5582598",
"0.5515971",
"0.54730463",
"0.54309434",
"0.5427365",
"0.539952",
"0.5367814",
"0.53330946",
"0.5300905",
"0.52544",
"0.5216884",
"0.5216884",
"0.5216884",
"0.5216884",
"0.5210196",
"0.5202101",
"0.5171742",
"0.51688",
"0.51688",
"0.5133565",
"0.51... | 0.0 | -1 |
returns date as integer for sorting | def last_day_i
last_date = $db.execute("SELECT day_i FROM prices ORDER BY day_i DESC LIMIT 1")
last_date = last_date[0][0]
return last_date
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordinal_date(date)\n date - date.beginning_of_year\n end",
"def start_date_as_integer\n as_integer @start_date\n end",
"def pub_date_sort\n if pub_date\n pd = pub_date\n pd = '0' + pd if pd.length == 3\n pd = pd.gsub('--', '00')\n end\n fail \"pub_dat... | [
"0.68294954",
"0.6789244",
"0.6723997",
"0.6662796",
"0.65276384",
"0.6329748",
"0.62860316",
"0.6192552",
"0.61768067",
"0.61762977",
"0.61536807",
"0.61433184",
"0.61109555",
"0.61109555",
"0.61021763",
"0.6067088",
"0.6067088",
"0.6065549",
"0.6062195",
"0.60131454",
"0.59... | 0.0 | -1 |
returns date as a string | def last_date_s
last_date = $db.execute("SELECT day FROM prices ORDER BY day_i DESC LIMIT 1")
last_date = last_date[0][0]
return last_date
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_str d\n Util::date(d)\n end",
"def date_str\n date.strftime(\"%Y%m%d\")\n end",
"def to_s\n date.strftime(DATE_FORMAT)\n end",
"def as_string(date)\n date.strftime(\"%b %d, %Y\")\n end",
"def to_s()\n str = \"\" + @date.month.to_s() + \"/\" + @date.mday.to_s()... | [
"0.85151935",
"0.8181006",
"0.816546",
"0.8143443",
"0.8009265",
"0.79164374",
"0.78638256",
"0.78512883",
"0.7782049",
"0.77426165",
"0.77128625",
"0.7711172",
"0.7706592",
"0.7663945",
"0.7613667",
"0.7598566",
"0.7598339",
"0.7567169",
"0.7527767",
"0.75260013",
"0.7495547... | 0.0 | -1 |
operation a +Roomorama::Client::Operations::Diff+ instance client a +Roomorama::Client+ instance properly configured | def initialize(operation, client)
@operation = operation
@roomorama_client = client
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff\n @diff ||= instance.client.createDiffHTML(padID: pad.id, startRev: start_rev, endRev: end_rev)\n end",
"def differ\n @differ ||= Differ.new(externals)\n end",
"def diff(from, to=nil)\n scm :diff, repository, authentication, \"-r#{from}:#{to || head}\"\n end",
"def call\n... | [
"0.60112506",
"0.5681368",
"0.5672869",
"0.56727904",
"0.5665033",
"0.56148654",
"0.5597679",
"0.55949694",
"0.5545563",
"0.5542509",
"0.55396247",
"0.55098134",
"0.54937327",
"0.54937327",
"0.5407725",
"0.5405259",
"0.5381243",
"0.5359567",
"0.5359567",
"0.529869",
"0.528405... | 0.6126598 | 0 |
calendar a +Roomorama::Calendar+ instance representing the changes to be applied to a property's availability calendar. Returns a +Result+ that, when successful, wraps the given calendar instance. | def perform(calendar)
result = roomorama_client.perform(operation)
return result unless result.success?
Result.new(calendar)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(calendar)\n # if the property trying to have its calendar synchronised was not\n # synchronised by Concierge, then do not attempt to update its calendar,\n # since the API call to Roomorama is going to fail (the +identifier+\n # will not be recognised.)\n return unless synchron... | [
"0.576668",
"0.561302",
"0.5449672",
"0.53009444",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52841675",
"0.52441454",
"0.52355796",
"0.52255195",
"0.5224125",
"0.52055943",
"0.5170357",
"0.5111265",
"0.50909257",
"0.50413096",
"0.5038781",
"0.49... | 0.59264374 | 0 |
Provide a user friendly representation | def to_s
'#<Twilio.Messaging.V1.BrandRegistrationOtpList>'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@nam... | [
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0... | 0.0 | -1 |
Build an instance of BrandRegistrationOtpInstance | def get_instance(payload)
BrandRegistrationOtpInstance.new(@version, payload, brand_registration_sid: @solution[:brand_registration_sid])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect\n \"<Twilio.Messaging.V1.BrandRegistrationOtpInstance>\"\n end",
"def to_s\n \"<Twilio.Messaging.V1.BrandRegistrationOtpInstance>\"\n end",
"def to_s\n '#<Twilio.Messaging.V1.BrandRegistration... | [
"0.7384454",
"0.67743194",
"0.5816949",
"0.5563608",
"0.5242484",
"0.5218351",
"0.5096465",
"0.50843716",
"0.50616604",
"0.5013985",
"0.49961314",
"0.49814317",
"0.49792665",
"0.49792665",
"0.4971616",
"0.49658054",
"0.49262452",
"0.4915125",
"0.49097523",
"0.48610842",
"0.48... | 0.79249465 | 0 |
Provide a user friendly representation | def to_s
'<Twilio.Messaging.V1.BrandRegistrationOtpPage>'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@nam... | [
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0... | 0.0 | -1 |
Provide a user friendly representation | def to_s
"<Twilio.Messaging.V1.BrandRegistrationOtpInstance>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@nam... | [
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0... | 0.0 | -1 |
Provide a detailed, user friendly representation | def inspect
"<Twilio.Messaging.V1.BrandRegistrationOtpInstance>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def details; end",
"def to_s; description end",
"def get_detail\n return self.inspect\n end",
"def to_display\n raise NotImplementedError\n end",
"def formatted_info\n \"#{self.name} - #{self.description}\"\n end",
"def toString\n #Not sure if we want this or just use the getters for mor... | [
"0.68170065",
"0.68142146",
"0.6758589",
"0.6718451",
"0.66697186",
"0.6655344",
"0.6632312",
"0.66273594",
"0.6550127",
"0.65188134",
"0.6497969",
"0.6480078",
"0.6477721",
"0.6472211",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64... | 0.0 | -1 |
migrate sessions whenever nicks are changed | def listen(m)
oldmask = m.user.mask.to_s.split('!')
oldmask[0] = m.user.last_nick
oldmask = oldmask.join('!')
s = Justbot::Session.for(oldmask)
if s
synchronize(:session) do
s.mask = m.user.mask
end
else
debug "no session found for mask '#{oldmask}'"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migrate_user_data\n if logged_in? && session.key?(:user_name)\n # Mocks the response from URS providing only the necessary keys to store the user data\n store_user_data('endpoint' => \"/api/users/#{session[:user_name]}\")\n\n # Remove this old value from the session\n session.delete(:use... | [
"0.5848199",
"0.57532746",
"0.5500663",
"0.5500062",
"0.5484407",
"0.5453377",
"0.54375523",
"0.54311216",
"0.5419326",
"0.5413572",
"0.53056794",
"0.530056",
"0.52477354",
"0.52464783",
"0.5245627",
"0.52243704",
"0.5208756",
"0.5205467",
"0.5205287",
"0.51825094",
"0.518046... | 0.0 | -1 |
create a session for the messaging user and try to authenticate them with the password | def auth(m, password)
user = Justbot::Models::User.first(:name => m.user.nick)
if user.nil? or not user.authenticates? password
sleep 1 # prevent timing attacks?
m.reply(INVALID_USER_OR_PASSWORD, true)
return
end
s = Justbot::Session.new(user, m.user.mask)
# start session
start_session(s)
# run the hooks that any plugins may have
# this allows plugins to decrypt thier models with the user's password
bot.plugins.each do |plugin|
if plugin.respond_to? :session_authenticated
plugin.session_authenticated(s, password)
end
end
# tell the user as though they'd run the "session?" command
session_info(m)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_session\n login, password = get_login_and_password\n create_session_with authenticate_user(login, password, :trace => true)\n end",
"def create_session\n req_params = params[:user]\n unless req_params\n @msg = \"Login details not found\"\n render \"objects/msg.json\", status: :u... | [
"0.68972",
"0.6805464",
"0.6733524",
"0.6666626",
"0.6645078",
"0.6594873",
"0.6549482",
"0.65463686",
"0.6469449",
"0.6467599",
"0.6384241",
"0.63797206",
"0.6375418",
"0.6369394",
"0.63602734",
"0.635577",
"0.6317938",
"0.63097334",
"0.6300138",
"0.628385",
"0.6264617",
"... | 0.7019801 | 0 |
get info about your current session | def session_info(m)
s = Justbot::Session.for(m)
if s.nil?
m.reply("You don't currently have a session.")
return
end
reply_in_pm(m) do |r|
r << "You have a session!"
r << " mask: #{s.mask}"
r << " expires: #{s.expiration}"
r << " is authed: #{s.authed?}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_info\n @info ||= @instance.client.getSessionInfo(sessionID: @id)\n end",
"def C_GetSessionInfo()\n @pk.C_GetSessionInfo(@sess)\n end",
"def getSessionInfo(sessionID)\n call :getSessionInfo, :sessionID => sessionID\n end",
"def info()\n get(:session, {:method => \"user.g... | [
"0.8278546",
"0.78261185",
"0.75928706",
"0.7559244",
"0.73744226",
"0.73529536",
"0.7248007",
"0.7152242",
"0.7139137",
"0.7139137",
"0.7139137",
"0.7138843",
"0.71327955",
"0.7052144",
"0.69449824",
"0.6943596",
"0.6943596",
"0.6875419",
"0.68527496",
"0.6851623",
"0.684460... | 0.7457902 | 4 |
destroys the sending user's session | def session_terminate(m)
s = Justbot::Session.for(m)
if s.nil?
m.reply(NO_SESSION, true)
return
end
# run hooks on session termination
bot.plugins.each do |plugin|
if plugin.respond_to? :session_will_terminate
plugin.session_will_terminate(s)
end
end
s.end!
m.reply('session terminated.')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @session[:user_id] = nil\n @current_user = nil\n end",
"def destroy\n session.delete(:user)\n end",
"def delete_session\n session[:userid] = nil\n session[:attributes] = nil\n end",
"def destroy_session(user)\n session[:user_id] = nil\n end",
"def destroy_session\n... | [
"0.8185062",
"0.80972105",
"0.8066367",
"0.7992436",
"0.79642934",
"0.7957519",
"0.7957519",
"0.7957519",
"0.7932099",
"0.7932099",
"0.7887956",
"0.7876934",
"0.7848229",
"0.7848229",
"0.7847589",
"0.7825452",
"0.78239244",
"0.7823747",
"0.778829",
"0.7785274",
"0.7772825",
... | 0.0 | -1 |
start a session and set up a timer to stop it, too | def start_session(s)
# callback to remove the session from play
end_session_timer = Timer(
Justbot::Session::DURATION,
:stop_automatically => false,
:shots => 1,
:threaded => true
) do
s.stop!
end
end_session_timer.start
# start the session
synchronize(:session) do
s.storage[self] = {:timer => end_session_timer}
s.start
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_timer\n Thread.new do\n loop {\n sleep @session_ttl\n reap_expired_sessions\n } \n end \n end",
"def start_session\n generate_token(:token)\n setup_session\n update_last_session\n end",
"def start_session\n session_tracker.start_session\n ... | [
"0.7459779",
"0.7091194",
"0.7028706",
"0.662788",
"0.65835184",
"0.6501576",
"0.6431445",
"0.635446",
"0.6350405",
"0.62872934",
"0.62767124",
"0.615367",
"0.60600543",
"0.60576093",
"0.6052897",
"0.6034506",
"0.6018608",
"0.60170615",
"0.5985841",
"0.5985428",
"0.5923099",
... | 0.81947666 | 0 |
Assignments effectively end at the switchover hour on the following day. | def effective_end_datetime
end_date + 1.day + roster.switchover.minutes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_of_hour\n change(:min => 59, :sec => 59)\n end",
"def hour_out\n @hour_out ||= time_out.hour\n end",
"def end_of_day\n change(:hour => 23, :min => 59, :sec => 59, :usec => 999999.999)\n end",
"def end_of_hour\n change(min: 59, sec: 59.999)\n end",
"def end_of_hour\n change(... | [
"0.64609694",
"0.60901266",
"0.60707915",
"0.6000169",
"0.5933242",
"0.59280235",
"0.591529",
"0.58783823",
"0.5825955",
"0.5728313",
"0.56997913",
"0.56943655",
"0.56943655",
"0.56451094",
"0.5637707",
"0.5607265",
"0.5589551",
"0.5553425",
"0.5539481",
"0.54963624",
"0.5486... | 0.5756575 | 9 |
The current assignment this method accounts for the switchover hour. This should be called while scoped to a particular roster. | def current
joins(:roster).on(effective_date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hour_out\n @hour_out ||= time_out.hour\n end",
"def opening_hour\n 11\n end",
"def opening_hour\n 11 # 11am\n end",
"def set_happy_hour\n @happy_hour = HappyHour.find(params[:id])\n end",
"def set_working_hour\n @working_hour = WorkingHour.find(params[:id])\n end",
"def se... | [
"0.59603393",
"0.5943339",
"0.5832089",
"0.56313914",
"0.5620044",
"0.5563373",
"0.5561458",
"0.5559353",
"0.55429476",
"0.55383974",
"0.5499064",
"0.5492002",
"0.5474442",
"0.54667956",
"0.54607135",
"0.5459859",
"0.5459859",
"0.541981",
"0.5401476",
"0.53561205",
"0.5324209... | 0.0 | -1 |
Returns the day AFTER the last assignment ends. If there is no last assignment, returns the upcoming Friday. | def next_rotation_start_date
last = order(:end_date).last
if last.present?
last.end_date + 1.day
else
1.week.since.beginning_of_week(:friday).to_date
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_of_week; self + (6 - wday).days end",
"def end_of_week\n 6.days.from_now(beginning_of_week).end_of_day\n end",
"def end_of_week\n (beginning_of_week+6).end_of_day\n end",
"def end_date\n Date.new((@number + 1), 1, 1).tuesday? ? Date.new((@number + 1), 1, 1) : Date.new(@number, 12, 31)\n e... | [
"0.6665773",
"0.6571757",
"0.65549624",
"0.6552313",
"0.6514463",
"0.64600205",
"0.6371434",
"0.62932974",
"0.62706345",
"0.62115264",
"0.6155144",
"0.61234325",
"0.6094296",
"0.6092528",
"0.60734457",
"0.606774",
"0.60433465",
"0.6012819",
"0.5994655",
"0.5993787",
"0.595502... | 0.0 | -1 |
returns the assignment which takes place on a particular date | def on(date)
between(date, date).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_assignment\n assignments.all.map{|a| a unless a.end_date != nil}.compact.first \n end",
"def current_assignment\n self.assignments.where(:end_date => nil).first \nend",
"def open_on_date(date)\r\n todays_assignments = Assignment.find_all_by_truck_id_and_date(self, date)\r\n num_requests ... | [
"0.7113615",
"0.68184674",
"0.63658714",
"0.6326499",
"0.63047814",
"0.619628",
"0.6114636",
"0.61016524",
"0.6052961",
"0.6004059",
"0.5888222",
"0.5883967",
"0.5828371",
"0.5811822",
"0.57681596",
"0.5757377",
"0.57497746",
"0.56770533",
"0.56723183",
"0.56084013",
"0.55624... | 0.5442663 | 28 |
Adding && deleting carriages | def add_carriage(carriage)
puts 'Cначала остановите поезд!' if @speed != 0
if carriage.type != @type
puts 'Тип поезда и вагона не совпадают'
else
@carriages.push(carriage)
puts "К поезду #{num} был добавлен вагон,
в составе #{carriages.size} вагонов"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manage_cars_remove_car_check\n @ui.manage_cars_remove_car_input_msg\n car_to_del_id = gets.chomp\n raise 'Unexisting car' unless cars.find { |car| car.id == car_to_del_id }\n car_del = cars.find { |car| car.car_id == car_to_del_id }\n @cars.delete(car_del)\n @cars_free.delete(car_del)\n @u... | [
"0.60848486",
"0.59644866",
"0.58258575",
"0.5766144",
"0.5644753",
"0.56243825",
"0.5577626",
"0.55614036",
"0.55541706",
"0.5538879",
"0.55351627",
"0.5531679",
"0.552931",
"0.5501006",
"0.5492723",
"0.5400532",
"0.5375824",
"0.5340296",
"0.53242975",
"0.5318759",
"0.530040... | 0.530935 | 20 |
Moving trains between stations | def go_next_station
@current_station = next_station
puts "Поезд приехал на станцию #{@current_station}"
puts 'Это конечная станция' if @current_station == stations_last
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move\n @route.stations[@index_current_station].recieve_train(self)\n @route.stations[@index_current_station - 1].send_train(self)\n end",
"def move_station(next_station_index)\n @route.stations[@cur_station_index].send_train(self)\n @route.stations[next_station_index].pass_train(self)\n @cur_... | [
"0.7684426",
"0.73601276",
"0.72364026",
"0.7034206",
"0.68292123",
"0.68044275",
"0.66719425",
"0.6615868",
"0.6337989",
"0.63264865",
"0.62785697",
"0.61901706",
"0.618796",
"0.6143496",
"0.61225766",
"0.6122264",
"0.6106506",
"0.6101847",
"0.60941947",
"0.59907985",
"0.596... | 0.55911714 | 45 |
TODO: cache cities and countries in YAML file | def country
client.places.get_countries.select{|hash| hash["cid"] == @params[:country].to_i}.first[:title]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cities\n CS.get :us, :ca\n end",
"def load_geo_data\n countries_hash = JSON.parse(File.read(Rails.root.join('lib/countries_data/countries.json')))\n cities_hash = JSON.parse(File.read(Rails.root.join('lib/countries_data/cities.json')))\n countries_hash.each do |country_hash|\n cities_arr = cities_h... | [
"0.6921255",
"0.6892969",
"0.6796239",
"0.6542673",
"0.6477612",
"0.6346394",
"0.6230742",
"0.61930275",
"0.61710024",
"0.6160316",
"0.61234134",
"0.6123347",
"0.60928756",
"0.60779876",
"0.6045195",
"0.6013437",
"0.60099816",
"0.60065603",
"0.59746355",
"0.5934177",
"0.58269... | 0.0 | -1 |
Get the list of all flags | def flags
@flags ||= Set.new([])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flags\n match(/Flags\\s+:\\s+(.+)$/).split rescue []\n end",
"def flags\n match(/Flags\\s+:\\s+(.+)$/).split rescue []\n end",
"def flags\n return [] unless options[\"flags\"]\n options[\"flags\"].map do |options|\n Flag.new options\n end\n end",
"def fl... | [
"0.7917881",
"0.7917881",
"0.7916632",
"0.7690954",
"0.7455698",
"0.7369091",
"0.7369091",
"0.7258017",
"0.7258017",
"0.72234166",
"0.7165587",
"0.7157109",
"0.7021804",
"0.70147747",
"0.69823146",
"0.6971803",
"0.6962295",
"0.68898445",
"0.6878045",
"0.68644124",
"0.6844459"... | 0.7572252 | 4 |
Helper method to find if a module is feature flagged or not | def is_flagged?(feature)
flags.include?feature
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature?(feature)\n definition[:features]&.include?(feature)\n end",
"def legit_feature?\n Flipflop.feature_set.features.map(&:name).include?(params[:feature])\n end",
"def feature_enable?(feature)\n @features ||= config.features_enable\n @features[feature] == true\nend",
"def feature_enabl... | [
"0.7062146",
"0.7055016",
"0.7005162",
"0.6967362",
"0.6870849",
"0.6870849",
"0.67527944",
"0.6652036",
"0.65460396",
"0.6532536",
"0.6524228",
"0.6524228",
"0.64574194",
"0.64574194",
"0.64560455",
"0.6395618",
"0.635416",
"0.6352375",
"0.63476837",
"0.63088554",
"0.6300882... | 0.68847626 | 4 |
Returns if the flag is not set | def is_not_flagged?(feature)
!is_flagged?feature
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def not_found?\n @flags.empty?\n end",
"def unique_flag_negative?\n found_unique? ? @flags.first[2] : nil\n end",
"def value?\n return !self.flag?\n end",
"def flags?\n !@flags.empty?\n end",
"def empty?\n flags.empty?\n end",
"def is_gone?\n\n fexp.ni... | [
"0.7849023",
"0.72942424",
"0.7188332",
"0.7150519",
"0.70344764",
"0.6804566",
"0.66903037",
"0.6680496",
"0.66730887",
"0.6658002",
"0.6596251",
"0.6593762",
"0.6593762",
"0.6587383",
"0.6575987",
"0.655463",
"0.6554087",
"0.6536343",
"0.65151846",
"0.6480073",
"0.64710325"... | 0.72540367 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_unit
@unit = Unit.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def unit_params
params.fetch(:unit, {}).permit(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
fetch the url and return the source | def get_url
Nokogiri::HTML(open(@url))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_source\n @html_source ||= fetch_uri uri if uri\n @html_source\n end",
"def fetch\n open(to_url) { |io| io.read }\n end",
"def fetch_from_url url\n require \"net/http\"\n\n uri = URI.parse(url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.ne... | [
"0.75662494",
"0.7513219",
"0.7506727",
"0.746275",
"0.7353484",
"0.7325995",
"0.72676665",
"0.72316104",
"0.71909475",
"0.71909475",
"0.71123046",
"0.71009755",
"0.7057388",
"0.7048181",
"0.70321274",
"0.7032066",
"0.703004",
"0.6965557",
"0.6920167",
"0.6881421",
"0.6874394... | 0.6880714 | 20 |
Reads file from a folder and returns array of content lines. Strips leading and trailing whitespace, including newlines. | def read_file(file)
lines = []
IO.foreach(find(file)) do |line|
lines << line.strip unless line.strip == ''
end
lines
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFileContent(dir, file):Array\n arr = Array.new\n File.open(\"#{dir}/#{file}\", \"r\").each do |line|\n arr.push line\n end\n arr\n end",
"def get_from_file(path)\n\n array = []\n file = File.open(path)\n if file != nil\n array = file.readlines.map(&:chomp) # Discard the fin... | [
"0.6945614",
"0.6840127",
"0.672195",
"0.6704331",
"0.6659768",
"0.65465933",
"0.65057945",
"0.63903075",
"0.6358061",
"0.6334009",
"0.632364",
"0.63061744",
"0.62727046",
"0.6143623",
"0.6139557",
"0.6111584",
"0.61075675",
"0.6101849",
"0.6100708",
"0.6100708",
"0.6100708",... | 0.70520884 | 0 |
Search a file in all load_paths, starting from last to first, so last takes precedence over first. | def find(name)
Forgery.load_paths.reverse.each do |path|
file = "#{path}/#{@folder}/#{name}"
return file if File.exists?(file)
end
raise ArgumentError.new("File '#{name}' wasn't found in '#{@folder}' folder. Searched paths: \n#{Forgery.load_paths.join('\n')}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup!\n $LOAD_PATH.each do |base|\n Dir[File.join(base, *file_lookup_paths)].each do |path|\n path = path.delete_prefix(\"#{base}/\")\n require path\n rescue Exception\n # No problem\n end\n end\n ... | [
"0.6476289",
"0.6388653",
"0.6199042",
"0.6012572",
"0.60068613",
"0.5988974",
"0.59565234",
"0.59546757",
"0.59540284",
"0.59528446",
"0.58985597",
"0.5824822",
"0.5811136",
"0.57780075",
"0.57731533",
"0.5765977",
"0.5762344",
"0.57438564",
"0.5691378",
"0.56721854",
"0.566... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_event
@event = Event.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 |
def log_in Remembers a user in a persistent session. | def remember(user, type)
user.remember_token = user.new_token
user.update_attribute(:remember_digest, user.digest(user.remember_token))
cookies.permanent.signed[:user_id] = user.id
cookies.permanent[:remember_token] = user.remember_token
cookies.permanent[:user_type] = type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_log_in(user)\n session[:user_id] = user.id\n end",
"def log_in(user)\n session[:user_id] = user.id\n end",
"def log_in(user)\n session[:user_id] = user.id\n end",
"def log_in(user)\n session[:user_id] = user.id\n end",
"def log_in(user)\n session[:user_id] = user.id\n end... | [
"0.80320823",
"0.7927296",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.78954214",
"0.77384216",
"0.77266836",
"0.77230084",
"0.7610431",
... | 0.0 | -1 |
def remember Returns true if the given user is the current user. | def current_user?(user)
user == current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user?\n # First, is the user already authenticated?\n return true if !current_user_id.nil?\n\n # If not, is the user using a remember-me token?\n remember_me_token = cookies[:transport_remember_me_token]\n if !remember_me_token.nil?\n user_id, token = remember_me_token.split(\"_t_\",2)\n new_token =... | [
"0.77358985",
"0.7709441",
"0.7517684",
"0.7497852",
"0.7497852",
"0.7451521",
"0.74410003",
"0.74410003",
"0.74265105",
"0.7415466",
"0.73238564",
"0.7312187",
"0.731007",
"0.72891635",
"0.7287093",
"0.7282067",
"0.7282067",
"0.7282067",
"0.7282067",
"0.7282067",
"0.7282067"... | 0.0 | -1 |
Returns the current loggedin user (if any). | def current_user
if session[:user_id].present?
user_id = session[:user_id]
user_type = session[:user_type]
@current_user ||= find_user_by_type(user_type, user_id)
elsif cookies.signed[:user_id].present?
user_id = cookies.signed[:user_id]
user_type = cookies[:user_type]
user = find_user_by_type(user_type, user_id)
if user and user.authenticated?(:remember, cookies[:remember_token])
log_in(user, user_type)
@current_user = user
else
forget(user)
end # if user and user.authenticated?
end # if session[:user_id] / elsif
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end",
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n return unless session[:user_id... | [
"0.85960984",
"0.8593657",
"0.855797",
"0.8545853",
"0.8534344",
"0.8497545",
"0.847914",
"0.8460573",
"0.8457271",
"0.84556973",
"0.84472865",
"0.8442264",
"0.8441092",
"0.84366953",
"0.8400402",
"0.83765614",
"0.8368829",
"0.8337418",
"0.8337418",
"0.8314651",
"0.8311652",
... | 0.0 | -1 |
Returns true if the user is logged in, false otherwise. | def logged_in?
!current_user.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n r... | [
"0.9082417",
"0.8764097",
"0.87552106",
"0.8718715",
"0.86894006",
"0.86498255",
"0.86469626",
"0.86372185",
"0.8631328",
"0.86285406",
"0.86285406",
"0.8582609",
"0.85669243",
"0.85613596",
"0.85613596",
"0.8551865",
"0.85491496",
"0.85443276",
"0.85409296",
"0.8539988",
"0.... | 0.0 | -1 |
Forgets a persistent session. | def forget(user)
user.forget if user
cookies.delete(:user_id)
cookies.delete(:remember_token)
cookies.delete(:user_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_session!\n raw_session.clear\n end",
"def abandon!\n @user = nil\n session.delete\n end",
"def abandon!\n @user = nil\n session.delete\n end",
"def abandon!\n @user = nil\n session.clear\n end",
"def invalidate_session\n @sequence = 0\n ... | [
"0.7149095",
"0.7059213",
"0.7059213",
"0.70340604",
"0.69786507",
"0.68063825",
"0.6668415",
"0.6590212",
"0.65894204",
"0.65851307",
"0.65851307",
"0.6546038",
"0.6429771",
"0.6429771",
"0.6391262",
"0.63660854",
"0.63422614",
"0.6315281",
"0.63146967",
"0.62607706",
"0.625... | 0.0 | -1 |
Logs out the current loggedin user | def log_out
if !current_user.nil?
forget(current_user)
session.delete(:user_id)
session.delete(:user_type)
@current_user = nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
... | [
"0.8842174",
"0.8842174",
"0.8842174",
"0.8842174",
"0.8841855",
"0.8808438",
"0.8808438",
"0.8808438",
"0.8808438",
"0.8808438",
"0.88038373",
"0.87690127",
"0.8740812",
"0.87260973",
"0.8725622",
"0.8725622",
"0.8725622",
"0.8725622",
"0.8725622",
"0.8725622",
"0.8725622",
... | 0.86734074 | 47 |
def log_out Redirects to stored location (or to the default). | def redirect_back_or(default)
redirect_to(session[:forwarding_url] || default)
session.delete(:forwarding_url)
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_out\n session.delete(:user_id)\n session.delete(:destination)\n @current_user = nil\n @current_dest = nil\n end",
"def log_out\n\t\tforget(current_user)\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\t\t# Setting @current_user to nil would only matter if @current_user were created ... | [
"0.78961766",
"0.7694712",
"0.7688781",
"0.767132",
"0.7659582",
"0.765396",
"0.76530415",
"0.7647203",
"0.7616681",
"0.7599332",
"0.7546684",
"0.75398076",
"0.75398076",
"0.75398076",
"0.753667",
"0.7533064",
"0.7533064",
"0.7533064",
"0.7533064",
"0.7532151",
"0.7531822",
... | 0.0 | -1 |
Stores the URL trying to be accessed. | def store_location
session[:forwarding_url] = request.original_url if request.get?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location\n session[:forwarding_url] = request.url if request.get?\n # Makes sure that the URL is saved only for a GET request because submitting\n # DELETE, PATCH or POST will raise errors when the URL is expecting\n # a GET request.\n end",
"def store_location\n # store last url as lon... | [
"0.69116175",
"0.6895489",
"0.6884959",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6784313",
"0.6694612",
"0.66793954",
"0.6637457",
"0.6633661",
"0.66288584",
"0.6592983",
"0.6592983",
"0.6592983",
"0.6592983",
"0.6591829",
"0.6568926",
"0.6557964",
... | 0.0 | -1 |
Check wheter the user is a Client, SiteWorker or Distributor | def user_should_be(type)
unless logged_in?
store_location
redirect_to log_in_path and return
end
return true if current_user.class == type
redirect_to root_path and return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client?\n role == 'client'\n end",
"def user_site?\n !Site::RESERVED.include? site_subdomain\n end",
"def traveler?\n !admin_or_staff? && !superuser?\n end",
"def is_potential_user?\n\t\ttrue\n\tend",
"def owner_required?\n !Refinery::Multisites.user_class.nil?\n end",
"de... | [
"0.70089364",
"0.6857658",
"0.65950155",
"0.6573277",
"0.65287334",
"0.6484968",
"0.64253455",
"0.63954407",
"0.63953245",
"0.6387228",
"0.6359739",
"0.6357843",
"0.63400614",
"0.63039094",
"0.62891704",
"0.62762445",
"0.62679696",
"0.62429106",
"0.6236025",
"0.623381",
"0.62... | 0.0 | -1 |
GET /prioridades/1 GET /prioridades/1.json | def show
@prioridade = Prioridade.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @prioridade }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_prioridad\n @prioridad = Prioridad.find(params[:id])\n end",
"def priorities\n Sifter.\n get(\"/api/priorities\").\n parsed_response[\"priorities\"]\n end",
"def index\n @prioridads = Prioridad.all\n end",
"def show\n @prioridade_adocao = PrioridadeAdocao.find(params[:id]... | [
"0.68602914",
"0.6778299",
"0.6587319",
"0.63708174",
"0.635255",
"0.6246057",
"0.6198486",
"0.57488686",
"0.5736397",
"0.5710488",
"0.56294835",
"0.56272113",
"0.5626058",
"0.55687815",
"0.5524008",
"0.543677",
"0.53907895",
"0.5309862",
"0.5302487",
"0.5298157",
"0.5276758"... | 0.7228111 | 0 |
GET /prioridades/new GET /prioridades/new.json | def new
@prioridade = Prioridade.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @prioridade }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @prioridade = Prioridade.new(params[:prioridade])\n\n respond_to do |format|\n if @prioridade.save\n format.html { redirect_to @prioridade, notice: 'Prioridade was successfully created.' }\n format.json { render json: @prioridade, status: :created, location: @prioridade }\n ... | [
"0.7742832",
"0.7336337",
"0.725823",
"0.67994136",
"0.64959276",
"0.64771926",
"0.6462122",
"0.64571977",
"0.63699126",
"0.6359396",
"0.63409084",
"0.63339895",
"0.63205266",
"0.6320355",
"0.6302525",
"0.6287897",
"0.6266362",
"0.623412",
"0.62078196",
"0.6200844",
"0.619619... | 0.8134788 | 0 |
POST /prioridades POST /prioridades.json | def create
@prioridade = Prioridade.new(params[:prioridade])
respond_to do |format|
if @prioridade.save
format.html { redirect_to @prioridade, notice: 'Prioridade was successfully created.' }
format.json { render json: @prioridade, status: :created, location: @prioridade }
else
format.html { render action: "new" }
format.json { render json: @prioridade.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @prioridad = Prioridad.new(prioridad_params)\n\n respond_to do |format|\n if @prioridad.save\n format.html { redirect_to @prioridad, notice: 'Se ha creado una nueva Prioridad.' }\n format.json { render :show, status: :created, location: @prioridad }\n else\n format... | [
"0.70679057",
"0.6845849",
"0.6630831",
"0.62737477",
"0.5998517",
"0.58468163",
"0.5691621",
"0.56160337",
"0.5428785",
"0.5353195",
"0.53161705",
"0.5243606",
"0.5241518",
"0.52350783",
"0.5193632",
"0.5176723",
"0.51413196",
"0.5127833",
"0.51077884",
"0.5103316",
"0.50906... | 0.7365912 | 0 |
PUT /prioridades/1 PUT /prioridades/1.json | def update
@prioridade = Prioridade.find(params[:id])
respond_to do |format|
if @prioridade.update_attributes(params[:prioridade])
format.html { redirect_to @prioridade, notice: 'Prioridade was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @prioridade.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_prioridad\n @prioridad = Prioridad.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @prioridad.update(prioridad_params)\n format.html { redirect_to @prioridad, notice: 'Se ha actualizado la Prioridad.' }\n format.json { render :show, status: :ok, location:... | [
"0.7031581",
"0.7014665",
"0.6580757",
"0.6563585",
"0.63650113",
"0.6196224",
"0.6007768",
"0.5863597",
"0.5685698",
"0.563704",
"0.56051916",
"0.55289173",
"0.53719133",
"0.5347442",
"0.5304482",
"0.52856016",
"0.52787614",
"0.5269795",
"0.52475905",
"0.52205443",
"0.520637... | 0.71978825 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.