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 |
|---|---|---|---|---|---|---|
If a game overrides this to true, then if the possible actions for the current entity include any of buy_train, scrap_train, or reassign_train then the Operating view will be used instead of the Merger round view for train actiosn in a merger round. See | def train_actions_always_use_operating_round_view?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_train_wagons\n cases = { 1 => :add_wagon_to_train, 2 => :remove_wagon_from_train }\n if @trains.empty?\n puts 'There are no trains yet.'\n return\n end\n puts 'Select action with train: add wagon(1), remove wagon(2)'\n action = gets.chomp.to_i\n send(cases[action.to_s]) || inco... | [
"0.5491557",
"0.5478652",
"0.5274982",
"0.5254",
"0.5250479",
"0.5173644",
"0.51039237",
"0.5074027",
"0.5054079",
"0.50331503",
"0.5028223",
"0.5010257",
"0.50092244",
"0.4979717",
"0.49172023",
"0.4915564",
"0.4912487",
"0.49042237",
"0.48995432",
"0.4881755",
"0.485573",
... | 0.7472655 | 0 |
shows the number of times a recipe has been made (into a meal) | def popularity
array = []
Meal.all.select do |meal|
if meal.recipe == self
array << meal
end
end
puts "#{self.title} has been made #{array.length} times!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_calories\n self.ingredients.sum(\"calories\")\n end",
"def number_of_meals\n meals.count\n end",
"def get_ingredient_counts\n otc = 0\n legend = 0\n self.ingredients.each do |ingredient|\n if ingredient.get_base_item.drug_class == 'legend'\n legend += 1\n e... | [
"0.7499515",
"0.7187305",
"0.696922",
"0.68396914",
"0.67432964",
"0.6733377",
"0.6615463",
"0.6612846",
"0.65888524",
"0.6524582",
"0.6458687",
"0.64312047",
"0.6383248",
"0.63808286",
"0.63659835",
"0.6349536",
"0.6346893",
"0.6333778",
"0.6264197",
"0.625202",
"0.62501985"... | 0.7411945 | 1 |
GET /posts GET /posts.json | def index
@post = Post.where.not(genre_id: 5).includes(:user)
@q = Post.where.not(genre_id: 5).ransack(params[:q])
@post = @q.result(distinct: true)
@buy = PostOrder.where(user_id: current_user.id).pluck(:post_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n ... | [
"0.7865315",
"0.7494904",
"0.7494433",
"0.7494433",
"0.7488696",
"0.74314564",
"0.728645",
"0.728645",
"0.728645",
"0.72562826",
"0.72522277",
"0.7247287",
"0.7246305",
"0.72221965",
"0.72042215",
"0.72039723",
"0.7169929",
"0.71689725",
"0.71644753",
"0.7121855",
"0.71152896... | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @po... | [
"0.74463975",
"0.73221767",
"0.73072433",
"0.7123966",
"0.7015686",
"0.701327",
"0.69841874",
"0.6939327",
"0.69313824",
"0.69053805",
"0.68196476",
"0.6812792",
"0.6793222",
"0.6792862",
"0.6779654",
"0.6779654",
"0.67625546",
"0.67602354",
"0.67515427",
"0.6735786",
"0.6698... | 0.63714516 | 77 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json | def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.json { render :show, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n forma... | [
"0.7186474",
"0.70405704",
"0.67739415",
"0.67659944",
"0.6669133",
"0.66483206",
"0.6578608",
"0.65559244",
"0.6551464",
"0.6550263",
"0.6534225",
"0.65306836",
"0.6499975",
"0.6498063",
"0.6467755",
"0.6430829",
"0.6427865",
"0.64268035",
"0.64263964",
"0.64191043",
"0.6418... | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param... | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.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 post_params
params.require(:post).permit(:title, :content, :pay_id, :price, :category_id, :genre_id, :type_id, :number1, :number2, :number3, :number4, :number5).merge(user_id:current_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 |
(idle, within transaction block) | def smart_transaction
result = nil
ensure_in_transaction do
begin
handle = connection.lo_open(oid)
result = yield handle
connection.lo_close(handle)
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def within_transaction; end",
"def within_transaction; end",
"def transaction(&block); end",
"def transaction; end",
"def transaction; end",
"def transaction; end",
"def begin_db_transaction() end",
"def begin_db_transaction() end",
"def within_transaction(object); end",
"def begin\n db.... | [
"0.78467196",
"0.78467196",
"0.7345237",
"0.7283208",
"0.7283208",
"0.7283208",
"0.7196476",
"0.7196476",
"0.7168741",
"0.7073682",
"0.69124544",
"0.69124544",
"0.66259",
"0.66259",
"0.65958124",
"0.658386",
"0.658386",
"0.6566949",
"0.6565531",
"0.6560482",
"0.6560426",
"0... | 0.6040745 | 60 |
GET /line_items GET /line_items.json | def index
@line_items = LineItem.all
respond_to do |format|
format.html # index.html.erb
format.json {
render json: @line_items
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @line_items = @order.line_items\n\n render json: @line_items\n end",
"def line_items(account_id, options = {})\n get(\"/accounts/#{account_id}/line_items\", options)\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n... | [
"0.7579001",
"0.74959284",
"0.74669135",
"0.74669135",
"0.74669135",
"0.74669135",
"0.7447879",
"0.74131817",
"0.7400883",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
"0.73949015",
... | 0.7619621 | 0 |
GET /line_items/1 GET /line_items/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @line_item = @order.line_items.find(params[:id])\n\n render json: @line_item\n end",
"def show\n puts params.inspect.green\n\n @line_item = LineItem.find(params[:id])\n\n puts @line_items.inspect.magenta\n\n respond_to do |format|\n format.html # show.html.erb\n format.jso... | [
"0.7516719",
"0.7455452",
"0.7411653",
"0.7411344",
"0.7411344",
"0.7411344",
"0.7411344",
"0.7411344",
"0.7411344",
"0.7411344",
"0.73414266",
"0.73409605",
"0.73257744",
"0.73173285",
"0.7276364",
"0.7243391",
"0.7243391",
"0.7243391",
"0.7243391",
"0.7207736",
"0.71943223"... | 0.0 | -1 |
POST /line_items POST /line_items.json | def create
# Protect the application and prevent the use of an invalid product
begin
# Search for the product to be linked (add) to the item line.
product = Product.find(params[:product_id])
rescue
logger.error("Attempt to access an invalid product #(product_id)")
redirect_to index("invalid product")
else
# Add the product.
@line_item = @cart.add_product(product.id)
respond_to do |format|
if @line_item.save
format.html { redirect_to store_url}
format.js { @current_item = @line_item }
format.json { render json: @line_item, status: :created, location: @line_item }
else
puts "new line item #{@cart.id} with product #{@cart.product_id}."
format.html { render action: "new" }
format.json { render json: @line_item.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 else\n render json: @line_item.errors, status: :unprocessable_entity\n end\n end",
"def create \n @line_item = LineIte... | [
"0.7897943",
"0.7534406",
"0.7473746",
"0.733548",
"0.72741777",
"0.67031443",
"0.6671838",
"0.66696936",
"0.6668108",
"0.66411036",
"0.66236573",
"0.6582626",
"0.65817285",
"0.65817285",
"0.65817285",
"0.65817285",
"0.65817285",
"0.65817285",
"0.65817285",
"0.65817285",
"0.6... | 0.0 | -1 |
PATCH/PUT /line_items/1 PATCH/PUT /line_items/1.json | def update
respond_to do |format|
if @line_item.update(line_item_params)
format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }
format.json { render :show, status: :ok, location: @line_item }
else
format.html { render :edit }
format.json { render json: @line_item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @line_item = @order.line_items.find(params[:id])\n\n if @line_item.update(line_item_params)\n head :no_content\n else\n render json: @line_item.errors, status: :unprocessable_entity\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |fo... | [
"0.73892826",
"0.7364141",
"0.7359202",
"0.7354417",
"0.7354417",
"0.7354417",
"0.7354417",
"0.7354417",
"0.7311553",
"0.72748667",
"0.7235466",
"0.72313774",
"0.72313774",
"0.72313774",
"0.71971774",
"0.71760887",
"0.7166696",
"0.7166696",
"0.7166696",
"0.7166696",
"0.716669... | 0.71314996 | 25 |
DELETE /line_items/1 DELETE /line_items/1.json | def destroy
@line_item.destroy
respond_to do |format|
format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do... | [
"0.76948905",
"0.7686589",
"0.7686589",
"0.7686589",
"0.7686589",
"0.7636646",
"0.762686",
"0.75796646",
"0.75732917",
"0.75732917",
"0.75732106",
"0.75708914",
"0.7560935",
"0.7467829",
"0.7455441",
"0.74349874",
"0.73651075",
"0.73651075",
"0.73651075",
"0.73651075",
"0.736... | 0.7393856 | 16 |
Use callbacks to share common setup or constraints between actions. | def set_line_item
@line_item = LineItem.find_by(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 line_item_params
params.require(:line_item).permit(:product_id, :cart_id, product_attributes: [:title])
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 |
You have a bank of switches before you, numbered from 1 to n. Each switch is connected to exactly one light that is initially off. index You walk down the row of switches and toggle every one of them. 1, 2, 3 You go back to the beginning, and on this second pass, you toggle switches 2, 4, 6, and so on. On the third pass, you go back again to the beginning and toggle switches 3, 6, 9, and so on. 4, 8,12 You repeat this process and keep going until you have been through n repetitions. Write a method that takes one argument, the total number of switches, and returns an Array that identifies which lights are on after n repetitions. Example with n = 5 lights: round 1: every light is turned on [1,2,3,4,5] round 2: lights 2 and 4 are now off; 1, 3, 5 are on [1,3,5] round 3: lights 2, 3, and 4 are now off; 1 and 5 are on [1,5] (3,6,9) round 4: lights 2 and 3 are now off; 1, 4, and 5 are on (4,6,8..) round 5: lights 2, 3, and 5 are now off; 1 and 4 are on The result is that 2 lights are left on, lights 1 and 4. The return value is [1, 4]. With 10 lights, 3 lights are left on: lights 1, 4, and 9. The return value is [1, 4, 9]. =begin output should return an array algorithm define an empty array ligths_on to catch the ligths they are on in every iteration Initialize an array from 0 to n, with all of the values being "on", initialize to `lights` Initialize `switch` to "on" Iterate through a range of numbers from 2 to n. Check if the light number modulo the range number == 0 If it is "on", reassign to "off" If it's "off" reassign to "on" Delete the 0th light since it's an extra light Return the array =end | def create_lights(number)
lights = Array.new(number + 1, "on")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switches(n)\n lights = Array.new(n) { |el| el = false }\n\n 1.upto(n) do |i|\n lights = lights.map.with_index do |light, idx|\n (idx + 1) % i == 0 ? !light : light\n end\n end\n\n lights_on = []\n lights.each_with_index do |light, idx|\n lights_on << (idx + 1) if light\n end\n\n lights_on\... | [
"0.8497293",
"0.8356761",
"0.8323828",
"0.8313316",
"0.80864346",
"0.804605",
"0.78435344",
"0.77426046",
"0.7667341",
"0.74454343",
"0.73211217",
"0.72762764",
"0.7254042",
"0.7203531",
"0.7144663",
"0.7143611",
"0.71248096",
"0.7043121",
"0.70207626",
"0.6931748",
"0.688514... | 0.6090999 | 37 |
initialize the lights hash | def initialize_lights(number_of_lights)
lights = Hash.new
1.upto(number_of_lights) { |number| lights[number] = "off" }
lights
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_lights(number_of_lights)\n lights = Hash.new # initialize new hash\n 1.upto(number_of_lights) { |number| lights[number] = \"off\" } # initially all lights are off\n lights # return hash\nend",
"def initialize_lights(lights)\n lights_hash = {}\n 1.upto(lights) {|key_num| lights_hash[key_num] =... | [
"0.7609511",
"0.71707237",
"0.7103816",
"0.6834083",
"0.66361576",
"0.6566927",
"0.6540318",
"0.65237683",
"0.65237683",
"0.64742696",
"0.6334376",
"0.63299274",
"0.6254082",
"0.61947805",
"0.61947805",
"0.61786854",
"0.61786854",
"0.61624306",
"0.6149926",
"0.61047435",
"0.6... | 0.7366643 | 3 |
return list of light numbers that are on | def on_lights(lights)
lights.select { |_position, state| state == "on" }.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def light_ids\n @attributes.fetch('lights', [])\n end",
"def on_lights(lights)\n lights.select { |position, state| state == \"on\" }.keys\nend",
"def light_switches(num)\n lights_arr = []\n 1.upto(num) do |n|\n lights_arr.push([n, true])\n end\n\n 2.upto(num) do |n|\n lights_arr.each... | [
"0.76867306",
"0.72924787",
"0.70018935",
"0.6793556",
"0.67644",
"0.67610174",
"0.67605406",
"0.6638909",
"0.6630233",
"0.657831",
"0.657831",
"0.639834",
"0.63749444",
"0.63270664",
"0.6300824",
"0.6273703",
"0.6260979",
"0.6260979",
"0.6232312",
"0.6208414",
"0.616246",
... | 0.7184447 | 4 |
toggle every nth light in lights hash | def toggle_every_nth_light(lights, nth)
lights.each do |position, state|
if position % nth == 0
lights[position] = (state == "off") ? "on" : "off"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle_every_nth_light(lights, nth)\n lights.each do |position, state|\n if position % nth == 0\n lights[position] = (state == 'off') ? \"on\" : \"off\"\n end\n end\nend",
"def toggle_every_nth_light(lights, nth) # works for 1st, 2nd, 3rd, etc for all cases\n lights.each do |position, state| # ... | [
"0.8753488",
"0.85586935",
"0.8289793",
"0.8142312",
"0.8142312",
"0.80062383",
"0.78277874",
"0.7816234",
"0.776805",
"0.7682932",
"0.75552136",
"0.7522069",
"0.75215226",
"0.738737",
"0.7344461",
"0.72866845",
"0.7270582",
"0.7250213",
"0.7232217",
"0.716745",
"0.70783395",... | 0.8755824 | 1 |
Run entire program for number of lights | def toggle_lights(number_of_lights)
lights = initialize_lights(number_of_lights)
1.upto(lights.size) do |iteration_number|
toggle_every_nth_light(lights, iteration_number)
end
on_lights(lights)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def light1000(num)\n lights = []\n counter = 1\n\n num.times { |i| lights << false} # initalize lights\n\n while counter <= num\n light_switcher(lights, counter)\n counter += 1\n end\n\n lights\nend",
"def get_on_lights(n)\n lights = initialize_lights(n)\n print_lights_state(lights) unless n > 10\n... | [
"0.6872255",
"0.63860846",
"0.6302018",
"0.5972148",
"0.58995664",
"0.5881807",
"0.5814575",
"0.58012146",
"0.57375646",
"0.5725829",
"0.56968653",
"0.5687244",
"0.56730103",
"0.56333005",
"0.5592361",
"0.55883783",
"0.5584892",
"0.5567888",
"0.55651957",
"0.55429804",
"0.553... | 0.6489842 | 2 |
GET /kotis/1 GET /kotis/1.json | def show
@koti = Koti.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @koti }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n # Retrieve kpis templates from impac api.\n # TODO: improve request params to work for strong parameters\n attrs = params.slice('metadata', 'opts')\n auth = { username: MnoEnterprise.tenant_id, password: MnoEnterprise.tenant_key }\n\n response = begin\n MnoEnterprise::ImpacClient.se... | [
"0.69364536",
"0.67170435",
"0.6711466",
"0.6518236",
"0.65007037",
"0.6449733",
"0.63726604",
"0.6359045",
"0.63254434",
"0.62631017",
"0.6256442",
"0.6238656",
"0.613433",
"0.6130103",
"0.61164457",
"0.60830843",
"0.6080621",
"0.6073123",
"0.6050244",
"0.60278183",
"0.60208... | 0.7303592 | 0 |
GET /kotis/new GET /kotis/new.json | def new
@koti = Koti.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @koti }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @kolegij = Kolegij.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kolegij }\n end\n end",
"def new\n @kisalli = Kisalli.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kisalli }\n ... | [
"0.7244365",
"0.7093972",
"0.7083777",
"0.70506227",
"0.7037311",
"0.70217323",
"0.7015883",
"0.6960871",
"0.6919345",
"0.69055647",
"0.68702126",
"0.6866271",
"0.68657184",
"0.68469125",
"0.6838026",
"0.68071806",
"0.67868567",
"0.6764441",
"0.6762116",
"0.67545015",
"0.6750... | 0.7641246 | 0 |
POST /kotis POST /kotis.json | def create
@koti = Koti.new(params[:koti])
respond_to do |format|
if @koti.save
format.html { redirect_to @koti, notice: 'Koti was successfully created.' }
format.json { render json: @koti, status: :created, location: @koti }
else
format.html { render action: "new" }
format.json { render json: @koti.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @kumo = Kumo.new(kumo_params)\n\n respond_to do |format|\n if @kumo.save\n format.html { redirect_to kumos_path, notice: 'Kumo was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kumo }\n else\n format.html { render acti... | [
"0.6279789",
"0.6084696",
"0.6072329",
"0.59265506",
"0.5880004",
"0.585454",
"0.58383447",
"0.5819117",
"0.5799825",
"0.5784292",
"0.5780402",
"0.5778943",
"0.5768232",
"0.57557744",
"0.57339406",
"0.5713512",
"0.56887406",
"0.5678827",
"0.566714",
"0.56585765",
"0.5648834",... | 0.68245703 | 0 |
PUT /kotis/1 PUT /kotis/1.json | def update
@koti = Koti.find(params[:id])
respond_to do |format|
if @koti.update_attributes(params[:koti])
format.html { redirect_to @koti, notice: 'Koti was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @koti.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put!\n request! :put\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def put(*args)\n request :put, *args\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update\n respond_to do |format|\n if @kumo.updat... | [
"0.66050994",
"0.6287504",
"0.624276",
"0.6227635",
"0.62257725",
"0.61513126",
"0.6141441",
"0.61317796",
"0.61140996",
"0.6102009",
"0.6080433",
"0.60761184",
"0.60707974",
"0.6033398",
"0.6026285",
"0.598341",
"0.598341",
"0.598341",
"0.59789264",
"0.59773743",
"0.59551585... | 0.676656 | 0 |
DELETE /kotis/1 DELETE /kotis/1.json | def destroy
@koti = Koti.find(params[:id])
@koti.destroy
respond_to do |format|
format.html { redirect_to kotis_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @kumo.destroy\n respond_to do |format|\n format.html { redirect_to kumos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def destroy\n @kisalli = Kisalli.find_by... | [
"0.7196523",
"0.708914",
"0.7004995",
"0.70018417",
"0.69594437",
"0.6929521",
"0.68798",
"0.68798",
"0.68798",
"0.68798",
"0.6854835",
"0.68501717",
"0.6838424",
"0.6828857",
"0.68206626",
"0.6816451",
"0.680978",
"0.6806271",
"0.6803567",
"0.67997515",
"0.6790133",
"0.678... | 0.74983966 | 0 |
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge [by myself, with: Nathan Park]. 0. total Pseudocode make sure all pseudocode is commented out! Input: collection of numbers Output: sum of numbers Steps to solve the problem. create a loop create counter for index starting at zero set intial sum equal to the first number increment counter by one close loop after iterating through entire collection 1. total initial solution def total (array) len = array.length index = 0 sum = 0 until index == len sum += array[index] index += 1 end return sum end 3. total refactored solution | def total(array)
index = 0
sum = 0
until index == array.length
sum += array[index]
index += 1
end
return sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_of_sums(array)\n sequence_total = 0\n sum = 0\n array.each do |n|\n sequence_total += n\n sum += sequence_total\n end\n sum\nend",
"def reduce_to_total(source_array, starting_point = 0)\n #source_array.reduce(starting_point) {|sum, n| sum + n}\n i = 0\n sum = starting_point\n while... | [
"0.75494784",
"0.7485537",
"0.7473761",
"0.7436196",
"0.7400663",
"0.73840743",
"0.7365266",
"0.7361523",
"0.73609895",
"0.73609895",
"0.7355892",
"0.73460025",
"0.7316078",
"0.7312413",
"0.73044956",
"0.72924894",
"0.72853047",
"0.72832805",
"0.7282291",
"0.7273691",
"0.7272... | 0.74786985 | 2 |
4. sentence_maker pseudocode make sure all pseudocode is commented out! Input: list of strings Output: capitalized sentence Steps to solve the problem. create a loop create counter for index starting at zero set intial sentence equal to the first string increment counter by one close loop after iterating through entire list capitalize sentence 5. sentence_maker initial solution def sentence_maker (array) index = 0 sentence = '' until index == array.length sentence += array[index] + ' ' index += 1 end return sentence.capitalize end 6. sentence_maker refactored solution | def sentence_maker (array)
index = 0
sentence = ""
array = array.map {|x| x.to_s}
until index == array.length-1
sentence += array[index] + " "
index += 1
end
sentence += array[-1] + "."
return sentence.capitalize
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_maker(array_of_strings)\n\n sentence = array_of_strings[0].capitalize\n \n for i in array_of_strings[1..-1]\n sentence += \" \" + i\n end \n p sentence + \".\"\n \nend",
"def sentence_maker(array_of_strings)\n sentence = array_of_strings[0].capitalize\n for i in array_of_strings[1..-1]\n ... | [
"0.826242",
"0.82323337",
"0.80811685",
"0.80214787",
"0.79578364",
"0.79404056",
"0.7929261",
"0.7904701",
"0.78897834",
"0.785983",
"0.78590846",
"0.7807664",
"0.7803027",
"0.778562",
"0.776315",
"0.7760344",
"0.7759078",
"0.7756449",
"0.7744993",
"0.77306163",
"0.77254593"... | 0.8013371 | 4 |
GET /matches or /matches.json | def index
@matches = Match.where("player2_id IS NOT NULL").order("#{:id} desc")
respond_to do |format|
format.html { @matches }
format.json { render json: @matches}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(id)\r\n self.get(\"/matches/#{id}\")\r\n end",
"def index\n @matches = Match.all\n @recent = Match.recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @matches }\n end\n end",
"def index\n @matches = @current_user.matches.include... | [
"0.7380734",
"0.7200314",
"0.679855",
"0.6796086",
"0.6768394",
"0.6730811",
"0.6710027",
"0.6704931",
"0.66993684",
"0.6654551",
"0.66420245",
"0.66108286",
"0.65325433",
"0.6531065",
"0.6527334",
"0.64620763",
"0.64620763",
"0.64620763",
"0.64620763",
"0.64620763",
"0.63886... | 0.67659086 | 5 |
GET /matches/1 or /matches/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(id)\r\n self.get(\"/matches/#{id}\")\r\n end",
"def index\n @matches = Match.all\n @recent = Match.recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @matches }\n end\n end",
"def index\n @matches = Match.where(\"player2_id IS N... | [
"0.75004536",
"0.7159631",
"0.695746",
"0.68594503",
"0.68522507",
"0.6821511",
"0.67767507",
"0.6762628",
"0.67455226",
"0.66436344",
"0.66431236",
"0.6595351",
"0.65934783",
"0.6533367",
"0.6499619",
"0.64500004",
"0.6382383",
"0.63511395",
"0.6338763",
"0.6338763",
"0.6338... | 0.0 | -1 |
POST /matches or /matches.json | def create
@match = Match.new(match_params)
respond_to do |format|
if @match.save
format.html { redirect_to @match, notice: "Match was successfully created." }
format.json { render :show, status: :created, location: @match }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @match.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @match = Match.new(params[:match])\n\n respond_to do |format|\n if @match.save\n format.html { redirect_to @match, :notice => 'Match was successfully created.' }\n format.json { render :json => @match, :status => :created, :location => @match }\n else\n format.html... | [
"0.6869135",
"0.68498874",
"0.67484564",
"0.67484564",
"0.67484564",
"0.67413795",
"0.67413795",
"0.67179877",
"0.67179877",
"0.67179877",
"0.67179877",
"0.67179877",
"0.67179877",
"0.6674089",
"0.66270566",
"0.65777713",
"0.65613216",
"0.6529487",
"0.64834005",
"0.6475298",
... | 0.67231536 | 7 |
PATCH/PUT /matches/1 or /matches/1.json | def update
respond_to do |format|
if @match.update(match_params)
format.html { redirect_to @match, notice: "Match was successfully updated." }
format.json { render :show, status: :ok, location: @match }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @match.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n match = Match.find_by(id: match_params[:id])\n\n match.update match_params\n if match.valid?\n render json: { match: match}, status: :created\n else\n render json: { errors: match.errors.full_messages }, status: :not_accepted\n end\n end",
... | [
"0.71572256",
"0.69489497",
"0.69344443",
"0.6929674",
"0.69070786",
"0.68920994",
"0.68724173",
"0.6859671",
"0.6760589",
"0.6760589",
"0.6760589",
"0.6760589",
"0.6760589",
"0.6760589",
"0.6760589",
"0.6760589",
"0.6760589",
"0.6760589",
"0.67599684",
"0.6634391",
"0.658486... | 0.67700547 | 8 |
DELETE /matches/1 or /matches/1.json | def destroy
@match = Match.find(params[:id])
respond_to do |format|
if @match
if @match.destroy
format.json { head :no_content, status: :ok}
end
else
format.json { render json: @match.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @match.destroy\n respond_to do |format|\n format.html { redirect_to matches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @match = match.find(params[:id])\n @match.destroy\n\n respond_to do |format|\n format.html { redirect_to matchs_url }\n... | [
"0.75342494",
"0.74745786",
"0.7473979",
"0.7473979",
"0.7473979",
"0.7420062",
"0.72408277",
"0.7216382",
"0.72120047",
"0.71737385",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419",
"0.7163419"... | 0.7417092 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_match
@match = Match.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def match_params
params.require(:match).permit(:id, :player1_id, :player2_id, :player1_score, :player2_score, :guild1_id, :guild2_id, :addons_id, :is_end, :is_inprogress, :is_player1_online, :is_player2_online, :rating, :is_ranked, :created_at, :updated_at, :war, :current_user, :player1, :player2, :guild1, :guild2, :addons)
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 |
The audio files are converted to transcript.srt files by the VoiceBase vendor these files are stored within the project directory. There are existing rake tasks that reference these files and support the content review process. | def store_dir
"#{Rails.root}/app/files/uploads/#{ENV['PROJECT_ID']}/"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speech_sync_recognize audio_file_path: nil\n # [START speech_transcribe_sync]\n # audio_file_path = \"Path to file on which to perform speech recognition\"\n\n require \"google/cloud/speech\"\n\n speech = Google::Cloud::Speech.speech\n\n # [START speech_ruby_migration_sync_response]\n audio_file = File.b... | [
"0.62932044",
"0.6176344",
"0.60858905",
"0.6055249",
"0.60044634",
"0.5714344",
"0.56757426",
"0.5643507",
"0.56254137",
"0.5617581",
"0.56093955",
"0.56040984",
"0.5588555",
"0.55717593",
"0.55691767",
"0.54885995",
"0.5487315",
"0.547486",
"0.5461294",
"0.5461036",
"0.5422... | 0.0 | -1 |
Determine whether the specified package is registered (installed). | def package?(package)
# implement inside child
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def installed?(package)\n\t\t\t\tif(!package.kind_of?(Regexp))\n\t\t\t\t\tpackage = Regexp.new(Regexp.escape(package.to_s))\n\t\t\t\tend\n\n\t\t\t\tCfruby.controller.inform('debug', \"Getting installed? status of \\\"#{package.source}\\\"\")\n\n\t\t\t\tinstalled_packages.each_value() { |packageinfo|\n\t\t\t\t\tif(... | [
"0.7951447",
"0.79319876",
"0.7814233",
"0.77583724",
"0.7672694",
"0.7671199",
"0.7657014",
"0.7612358",
"0.73527545",
"0.73456246",
"0.72912115",
"0.7232956",
"0.71966034",
"0.7194443",
"0.7162978",
"0.70794076",
"0.70730454",
"0.7043947",
"0.7042719",
"0.7031602",
"0.70188... | 0.68779796 | 28 |
Searches for the first match of a package by name and version. | def find_package(name, constraint)
# implement inside child
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_package_by_name(name)\n @packages[name]\n end",
"def package_from_name(package_name)\n return self if package_name == self.name\n local_deps.find { |pkg| pkg.name == package_name }\n end",
"def find_gem(name, version)\n spec = source_index.find_name(name, version).las... | [
"0.73253804",
"0.68807966",
"0.6773175",
"0.6674667",
"0.6674667",
"0.6637975",
"0.66011095",
"0.65687627",
"0.6533143",
"0.64758706",
"0.6456763",
"0.6430713",
"0.64009035",
"0.63949305",
"0.6295817",
"0.625948",
"0.6242612",
"0.6240533",
"0.61945736",
"0.6191994",
"0.618158... | 0.56128585 | 55 |
Searches for all packages matching a name and optionally a version. | def find_packages(name, constraint = nil)
# implement inside child
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_package_by_name(name)\n @packages[name]\n end",
"def scan(name)\n raise NotImplementedError, \"Repositories must return an Array of matching packages.\"\n end",
"def find_package_set(name)\n each_package_set.find { |set| set.name == name }\n end",
"def fin... | [
"0.71873015",
"0.7039836",
"0.67553025",
"0.662894",
"0.6556919",
"0.65506226",
"0.65429294",
"0.6515822",
"0.6494935",
"0.64812064",
"0.64618766",
"0.64205015",
"0.640928",
"0.630108",
"0.6202274",
"0.61558205",
"0.6150257",
"0.6067902",
"0.5978247",
"0.5951928",
"0.59273386... | 0.6788423 | 2 |
Returns list of registered packages. | def packages
# implement inside child
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def packages\n ::Packages::Package.all\n end",
"def packages\n @packages ||= []\n end",
"def packages\n @packages ||= []\n end",
"def installed_packages()\n\t\t\t\treturn(PackageList.new())\n\t\t\tend",
"def packages()\n\t\t\t\treturn(PackageList.new())\n\t\t\tend",
"def packa... | [
"0.7964586",
"0.7730711",
"0.7730711",
"0.75759715",
"0.7412114",
"0.7376516",
"0.72474575",
"0.7223179",
"0.71544886",
"0.71438885",
"0.71176594",
"0.6972615",
"0.6941576",
"0.6868483",
"0.68301976",
"0.6683314",
"0.6674286",
"0.6586486",
"0.6575666",
"0.65510285",
"0.651995... | 0.0 | -1 |
Downloads the patch into the current directory. | def fetch
dst = Pathname.pwd+File.basename(@url.to_s)
blah "Fetching patch..."
begin
curl @url.to_s, '-o', dst
rescue => ex
raise "Patch #{File.basename(@url.to_s)} could not be fetched."
debug ex.message
end
@cached_location = dst
debug "Patch downloaded into #{@cached_location}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_patch!(opts={})\n download!(:patch, opts)\n end",
"def patch\n fetch unless exist?\n return unless has_patches?\n dont_debug { patched_location.rmtree if patched_location.exist? } # Make sure that no previous patched copy exists\n dont_debug { @local_path.ditto patched_lo... | [
"0.8003066",
"0.744927",
"0.64440995",
"0.6391729",
"0.62614995",
"0.62548596",
"0.6129323",
"0.6075426",
"0.5969686",
"0.59236276",
"0.5914293",
"0.5849386",
"0.5797943",
"0.5764307",
"0.5758952",
"0.5701235",
"0.5687695",
"0.5686128",
"0.5676491",
"0.56340855",
"0.5598725",... | 0.7909627 | 1 |
Applies this patch in the current directory. Raises an error if the patch cannot be applied. | def apply
debug "Applying patch at #{Dir.pwd}"
raise "Patch not fetched." if !(@cached_location and @cached_location.exist?)
patch_levels = ['-p1', '-p0']
patched = false
output = ''
# First try with git apply
patch_levels.each do |pl|
begin
runBabyRun 'git', ['apply', '--check', pl, @cached_location], :redirect_stderr_to_stdout => true
runBabyRun 'git', ['apply', pl, @cached_location], :redirect_stderr_to_stdout => true
patched = true
break
rescue => ex
output << ex.to_s
end
end
if not patched
patch_levels.each do |pl|
begin
runBabyRun 'patch', ['--no-backup-if-mismatch', '-f', pl, '-d', Dir.pwd, '-i', @cached_location], :redirect_stderr_to_stdout => true
patched = true
break
rescue => ex
output << ex.to_s
end
end
end
if not patched
if descr and descr != @cached_location.basename.to_s
d = " (#{descr})"
else
d = ''
end
raise "Patch #{@cached_location.basename}#{d} could not be applied.\n" + output
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_patch( patch_file, location )\n Dir.chdir( location ) do\n %x[ patch -p0 < #{patch_file} ]\n end\n end",
"def apply_patch(patch_file)\n working_dir = Dir.pwd\n repo_root = `git rev-parse --show-toplevel`.strip\n ios_project_path = Pathname.new(working_dir).relative_path_from(Path... | [
"0.67368263",
"0.665721",
"0.66271365",
"0.658704",
"0.6214006",
"0.5951241",
"0.5281438",
"0.52263975",
"0.5200488",
"0.517801",
"0.5134046",
"0.50964016",
"0.50465137",
"0.5009147",
"0.49177513",
"0.4837655",
"0.4819857",
"0.4815447",
"0.47724298",
"0.4769196",
"0.47612908"... | 0.7104601 | 0 |
Calls +underscore+ on the validator and returns it's class name as a symbol. Namespaces and the trailing "_validator" text will be trimmed type = Bodhi::TypeValidator.new("String") is_not_blank = Bodhi::IsNotBlankValidator.new(true) type.to_sym => :type is_not_blank.to_sym => :is_not_blank | def to_sym
name = self.underscore.gsub("bodhi::", "").gsub("_validator", "")
Bodhi::Support.reverse_camelize(name).to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schema_key\n @schema_key ||= self.class.name.demodulize.gsub('Validator', '').underscore\n end",
"def validate_class_name(name)\n only_basic_type(name) || name.gsub(/-/, \"_\").camelcase\n end",
"def validator_name_for(constraint_name)\n \"#{self.name}::#{constraint_name.to_s.cameliz... | [
"0.62370884",
"0.5881024",
"0.5788379",
"0.5696956",
"0.5683915",
"0.5666957",
"0.5662024",
"0.5658371",
"0.5648385",
"0.55366516",
"0.5532949",
"0.5525905",
"0.5496869",
"0.54917645",
"0.5485282",
"0.54741514",
"0.54651594",
"0.53996295",
"0.538858",
"0.538574",
"0.5378349",... | 0.68782324 | 0 |
Returns the validation's class name in snake_case. type = Bodhi::TypeValidator.new("String") is_not_blank = Bodhi::IsNotBlankValidator.new(true) type.underscore => "bodhi/type_validator" is_not_blank.underscore => "bodhi/is_not_blank_validator" | def underscore
Bodhi::Support.underscore(self.class.name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def underscorized_classname\n self.class.name.split(\"::\").last.\n gsub( /([A-Z]+)([A-Z][a-z])/, '\\1_\\2' ).\n gsub( /([a-z\\d])([A-Z])/, '\\1_\\2' ).downcase\n end",
"def validate_class_name(name)\n only_basic_type(name) || name.gsub(/-/, \"_\").camelcase\n end",
... | [
"0.72529936",
"0.70640475",
"0.6935765",
"0.6922206",
"0.669088",
"0.6497199",
"0.64355034",
"0.64127445",
"0.6329845",
"0.6291694",
"0.62881017",
"0.6251029",
"0.6246323",
"0.6228948",
"0.62152886",
"0.6213079",
"0.6203953",
"0.6194722",
"0.61860126",
"0.6182524",
"0.6174504... | 0.6088153 | 30 |
checks if teh input is one of the valid operators | def is_operator?(x)
#x.size == 1 && ( x == '+' || x == '-' || x == '*' || x =='/')
x =~ /^[\+\-\*\/]$/
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_operator(user_operator)\n possible_operators = [ \"add\", \"+\", \"subtract\", \"-\", \"multiply\", \"x\", \"*\", \"divide\", \"/\" ]\n possible_operators.include?(user_operator)\nend",
"def is_operator char\n\t\t@@allowed_operator.include? char\n\tend",
"def operator?(str)\n return ['+', '-', '... | [
"0.83995306",
"0.77286935",
"0.7631885",
"0.7565265",
"0.7527093",
"0.7430605",
"0.7374353",
"0.72778386",
"0.72557217",
"0.72538275",
"0.7059775",
"0.69958645",
"0.6951079",
"0.6904048",
"0.68875325",
"0.686143",
"0.6855505",
"0.676878",
"0.6742377",
"0.6722033",
"0.67145896... | 0.80540925 | 1 |
prompts and gets a valid number or q. For q, modify the "cont" string to indicate a quit. | def get_valid_number(cont)
loop do
puts "Enter number or q:"
val = gets.chomp()
if (val == "q")
cont << val
break
end
if is_num?(val)
return val.to_f
else
puts "Input was not numerical."
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getinput(question, default = '')\n askuser = question + \" ('q' to quit)\"\n askuser << (!default.empty? ? \" [#{default}]: \" : \": \")\n puts askuser\n myui = gets.chomp\n if myui.casecmp('q').zero? then\n puts \"Okay, g'bye!\"\n exit\n end\n return myui\nend",
"def prompt(msg, default)\n r... | [
"0.7231286",
"0.67685163",
"0.673699",
"0.672809",
"0.6719061",
"0.67124736",
"0.6711352",
"0.6676798",
"0.66411144",
"0.6617315",
"0.65255487",
"0.651635",
"0.6457496",
"0.64242184",
"0.6403846",
"0.6361484",
"0.6318605",
"0.63171357",
"0.6310024",
"0.6302764",
"0.62881905",... | 0.677206 | 1 |
Format the Ruby Time object returned from a post's created_at method into a string that looks like this: 06 Jan 2012 | def pretty_date(time)
time.strftime("%d %b %Y")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatted_created_at\n object.created_at.strftime('%b %-d, %Y')\n end",
"def formatted_created_at\n article.created_at.strftime(\"%m/%d/%Y - %H:%M\")\n end",
"def create_date(post)\n \" created at: \" + post.created_at.strftime(\"%d %b. %Y\") + \" - \" + post.created_at.strftime(\"%H:%M\")... | [
"0.7828946",
"0.77611053",
"0.7739608",
"0.76658237",
"0.7575332",
"0.7527383",
"0.75219345",
"0.75109375",
"0.7476592",
"0.7470069",
"0.7424419",
"0.7418588",
"0.7407166",
"0.7401692",
"0.7375269",
"0.73447794",
"0.7341712",
"0.73374784",
"0.7302442",
"0.7302442",
"0.7302442... | 0.7130082 | 30 |
Return true if the given answer is correct, false otherwise | def is_correct?(answer)
self.answer.to_s == answer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answer_correct?(answer)\n @correct_answer == answer\n end",
"def validate_answer(answer)\n answer == @result\n end",
"def check_answer(answer)\n result = @num_1 + @num_2\n if answer == result\n return true\n end\n return false\n end",
"def check_answer?(input)\n if @answer ==... | [
"0.85755277",
"0.827943",
"0.8122538",
"0.805976",
"0.80350226",
"0.7998455",
"0.78686213",
"0.78505373",
"0.78255033",
"0.78180903",
"0.78145164",
"0.7792816",
"0.77062887",
"0.76375335",
"0.75685906",
"0.75343317",
"0.7510038",
"0.74854964",
"0.74747074",
"0.7461351",
"0.74... | 0.8533228 | 1 |
Return the question as a formatted string | def question
num1, num2 = self.values
"What does #{num1} plus #{num2} equal?"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_str( )\n @question\n end",
"def questions_formated\n questions_ids_2_display.collect{ |qid| Question.new(self, qid).output }.join('')\n end",
"def to_s\n string = (id.nil? ? \"unsaved survey\" : \"survey #{id}\")\n string += \" [#{self.questions_count} \" +\n 'question'.pluralize... | [
"0.7932559",
"0.72574604",
"0.71713376",
"0.7055708",
"0.68599504",
"0.68599504",
"0.68573964",
"0.67693037",
"0.66108114",
"0.6589923",
"0.6578503",
"0.65072125",
"0.6475251",
"0.6471113",
"0.6456515",
"0.6415269",
"0.6411383",
"0.63634163",
"0.63004106",
"0.63004106",
"0.63... | 0.0 | -1 |
Return the answer of the question | def answer
add(*@values)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def question\n answer.question\n end",
"def questionAnswer(question)\n answer = questionAnswerRaw(question)\n \n answer = \"No Answer\" if answer == nil\n return answer\nend",
"def answer\n if answered?\n answers.last.answer\n else\n [{:answer => \"not answered\"}]\n end\n end",
"... | [
"0.7717591",
"0.73450696",
"0.726807",
"0.72162735",
"0.72162735",
"0.72135377",
"0.7211813",
"0.7208095",
"0.71970016",
"0.719237",
"0.71704113",
"0.7139775",
"0.7122346",
"0.71222955",
"0.7099908",
"0.70983857",
"0.7066736",
"0.706056",
"0.7040258",
"0.70112044",
"0.6993599... | 0.0 | -1 |
Return a random number within the min and max values | def get_random(min, max)
rand(min..max)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_number(min, max)\n rand(max-min+1)+min\n end",
"def random_on_interval(min, max)\n min + @prng.rand(max - min)\n end",
"def rand_in_bounds(min, max)\n return min + (max-min)*rand()\nend",
"def random_num(min, max)\n rand(max - min + 1) + min\nend",
"def random_num(min, max)\n r... | [
"0.84728557",
"0.8404681",
"0.8247544",
"0.82367826",
"0.82342905",
"0.8228452",
"0.8189896",
"0.81114787",
"0.80491257",
"0.8034381",
"0.8030006",
"0.7918688",
"0.78653365",
"0.7834344",
"0.78281224",
"0.7799759",
"0.77947956",
"0.7788651",
"0.77704936",
"0.7706146",
"0.7686... | 0.8418311 | 1 |
Return the sum of two given numbers | def add(num1, num2)
num1 + num2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum num1, num2\n\ttotal = num1 + num2\n\treturn total\nend",
"def add_numbers(number1, number2)\n return sum\nend",
"def sum(number, other)\n number + other\n end",
"def sum_two_numbers(a, b)\n a + b\nend",
"def sumoftwonumbers(number1, number2)\n return number1 + number2\nend",
"def get_sum(a... | [
"0.8192085",
"0.80076385",
"0.7999766",
"0.79188293",
"0.7857874",
"0.78448325",
"0.7844623",
"0.78344",
"0.7755537",
"0.7755537",
"0.7735126",
"0.7659296",
"0.7603004",
"0.758157",
"0.7579703",
"0.75699586",
"0.75648254",
"0.7560814",
"0.7557386",
"0.7556966",
"0.75555694",
... | 0.0 | -1 |
try to convert to a Hash. it may return an Array if this contains none. | def tcl_options_to_hash(hints = {})
if first.respond_to?(:to_ary)
hash = {}
each do |key, _, _, _, value|
next if !value || (value.respond_to?(:empty?) && value.empty?)
key = key.sub(/^-/, '').to_sym
hash[key] =
case hint = hints[key]
when :boolean
Tk.boolean(value)
when :symbol
value.to_sym
when :float
Float(value)
else
value
end
end
hash
elsif first =~ /^-/
::Hash[each_slice(2).map{|key, value|
key = key.sub(/^-/, '').to_sym
case hint = hints[key]
when :boolean
[key, Tk.boolean(value)]
when :symbol
[key, value.to_sym]
when :float
[key, Float(value)]
else
[key, value]
end
}]
else
self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n Hash[to_a]\n end",
"def _to_hash(value)\n if value.is_a?(Array)\n value.compact.map{ |v| _to_hash(v) }\n elsif value.is_a?(Hash)\n {}.tap do |hash|\n value.each { |k, v| hash[k] = _to_hash(v) }\n end\n elsif value.respond_to? :to_ha... | [
"0.701495",
"0.6877848",
"0.6877848",
"0.6877848",
"0.6877848",
"0.6877848",
"0.6874061",
"0.6874061",
"0.687203",
"0.68703264",
"0.68703264",
"0.68612075",
"0.682919",
"0.6775987",
"0.6775987",
"0.6775987",
"0.6775987",
"0.6775987",
"0.6775987",
"0.6775987",
"0.6775987",
"... | 0.0 | -1 |
Get line +line_number+ from file named +filename+. | def line_at(filename, line_number)
source_reload
return "\n" unless File.exist?(filename)
line = Tracer::Single.get_line(filename, line_number)
return "#{line.gsub(/^\s+/, '').chomp}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_line(filename, lineno)\n File.open(filename) do |f|\n f.gets until f.lineno == lineno - 1\n f.gets\n end\n end",
"def read_line_number(filename, number)\n return nil if number < 1\n line = File.readlines(filename)[number-1]\n line ? line.chomp : nil\n end",
... | [
"0.7939525",
"0.77649134",
"0.73907256",
"0.7374364",
"0.7374364",
"0.71665376",
"0.69212055",
"0.6635629",
"0.65938056",
"0.6399818",
"0.6270285",
"0.6192722",
"0.61359906",
"0.61099154",
"0.60620713",
"0.6048927",
"0.60451424",
"0.6042715",
"0.5985878",
"0.5983062",
"0.5960... | 0.7980011 | 0 |
Add a new breakpoint | def add_breakpoint(file, line, expr=nil)
breakpoint = Breakpoint.new(file, line, expr)
breakpoints << breakpoint
breakpoint
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def breakpoint()\n #This is a stub, used for indexing\n end",
"def add_break\n\t\tcheck_if_myself\n\t\t@break = Break.new\n\tend",
"def enable_breakpoint(bp)\n bp.enable\n end",
"def debug it\n PryByebug::BreakCommand.new.send :add_breakpoint, \"Testo::Test#run\", nil\n # How to \... | [
"0.69875",
"0.6866089",
"0.65213877",
"0.64125",
"0.63738704",
"0.63625914",
"0.6358487",
"0.6347611",
"0.6313434",
"0.6279197",
"0.62511516",
"0.62386817",
"0.623022",
"0.62048274",
"0.6141737",
"0.60813886",
"0.6072881",
"0.59664327",
"0.5879173",
"0.58637017",
"0.5819766",... | 0.76757556 | 0 |
Runs normal byebug initialization scripts. Reads and executes the commands from init file (if any) in the current working directory. This is only done if the current directory is different from your home directory. Thus, you can have more than one init file, one generic in your home directory, and another, specific to the program you are debugging, in the directory where you invoke byebug. | def run_init_script(out = handler.interface)
cwd_script = File.expand_path(File.join(".", INITFILE))
run_script(cwd_script, out) if File.exist?(cwd_script)
home_script = File.expand_path(File.join(ENV['HOME'].to_s, INITFILE))
if File.exist?(home_script) and cwd_script != home_script
run_script(home_script, out)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n Byebug.mode = :standalone\n\n option_parser.order!($ARGV)\n return if non_script_option? || error_in_script?\n\n $PROGRAM_NAME = program\n\n Byebug.run_init_script if init_script\n\n loop do\n debug_program\n\n break if quit\n\n ControlProcessor.new(nil,... | [
"0.63262236",
"0.6231949",
"0.6231949",
"0.6046379",
"0.5926553",
"0.5870151",
"0.58633745",
"0.5847022",
"0.57460564",
"0.57257867",
"0.5717965",
"0.57089657",
"0.56571203",
"0.564702",
"0.55381644",
"0.5491915",
"0.5486711",
"0.5484334",
"0.5446203",
"0.5422022",
"0.5377718... | 0.6132056 | 3 |
Runs a script file | def run_script(file, out = handler.interface, verbose=false)
interface = ScriptInterface.new(File.expand_path(file), out)
processor = ControlCommandProcessor.new(interface)
processor.process_commands(verbose)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_script(file=nil)\n\tif file == nil\n\t\tfile = $screen.ask(\"run script file: \",[\"\"],false,true)\n\t\tif (file==nil) || (file==\"\")\n\t\t\t$screen.write_message(\"cancelled\")\n\t\t\treturn\n\t\tend\n\tend\n\tif File.directory?(file)\n\t\tlist = Dir.glob(file+\"/*.rb\")\n\t\tlist.each{|f|\n\t\t\tscript... | [
"0.7966749",
"0.76009625",
"0.73898834",
"0.7290241",
"0.7206386",
"0.71685165",
"0.71681404",
"0.7163935",
"0.71039546",
"0.7081781",
"0.6979073",
"0.6955391",
"0.6930358",
"0.68747675",
"0.68747675",
"0.68709",
"0.68599135",
"0.6852345",
"0.6834088",
"0.676434",
"0.675755",... | 0.7386452 | 5 |
Activates the postmortem mode. By calling Byebug.post_mortem method, you install an at_exit hook that intercepts any exception not handled by your script and enables postmortem mode. | def post_mortem
return if self.post_mortem?
self.post_mortem = true
at_exit { handle_post_mortem if post_mortem? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_mortem!\n self.enabled = true \n self.post_mortem = true\n end",
"def handle_post_mortem; end",
"def allow_in_post_mortem; end",
"def allow_in_post_mortem=(_arg0); end",
"def debug it\n PryByebug::BreakCommand.new.send :add_breakpoint, \"Testo::Test#run\", nil\n # How to \"next next... | [
"0.75168127",
"0.7024495",
"0.6583708",
"0.6298816",
"0.58594584",
"0.54909486",
"0.51963615",
"0.5139909",
"0.508564",
"0.5023443",
"0.49511313",
"0.49465683",
"0.49298984",
"0.4885929",
"0.4864608",
"0.48632827",
"0.47944057",
"0.4753744",
"0.47496736",
"0.47421828",
"0.472... | 0.8474223 | 0 |
store all songs here | def initialize(name)
@name = name
@@all << self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save \n# # - this method will add Song instances to the @@all array\n @@all << self \n end",
"def add_songs(songs)\n songs.each { |song| add_song(song) }\n end",
"def add_songs(songs)\n songs.each { |song| add_song(song) }\n end",
"def add_songs(songs)\n songs.each { |song| add_song(song)... | [
"0.75164443",
"0.72431844",
"0.72431844",
"0.72431844",
"0.7238987",
"0.72147197",
"0.7208672",
"0.72080064",
"0.71841383",
"0.71612453",
"0.7155892",
"0.71453226",
"0.71403676",
"0.70837283",
"0.7074215",
"0.7045515",
"0.70390034",
"0.70256114",
"0.70256114",
"0.70256114",
"... | 0.0 | -1 |
GET /admin/types GET /admin/types.json | def index
@admin_types = Type.joins(:language).order('types.code DESC').all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @all_type=Api::V1::AdminType.all\n render json: @all_type\n end",
"def index\n @api_v1_admin_types = Api::V1::AdminType.all\n end",
"def index\n @types = Type.all\n end",
"def get_lesson_types\n get \"lessonTypes.json\"\n end",
"def show\n @api_v1_user_types = Api::V1::... | [
"0.7722486",
"0.7529136",
"0.7143732",
"0.70036155",
"0.69521475",
"0.69053453",
"0.6885681",
"0.6882073",
"0.68726695",
"0.679455",
"0.6758502",
"0.6729855",
"0.67178345",
"0.6700061",
"0.66942316",
"0.6675409",
"0.666354",
"0.66395056",
"0.6629085",
"0.6615679",
"0.6594841"... | 0.6248692 | 49 |
GET /admin/types/1 GET /admin/types/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @all_type=Api::V1::AdminType.all\n render json: @all_type\n end",
"def index\n @api_v1_admin_types = Api::V1::AdminType.all\n end",
"def show\n @api_v1_user_types = Api::V1::UserType.all\n end",
"def index\n @types = Type.all\n end",
"def index\n render json: usage(params... | [
"0.78296673",
"0.7663994",
"0.7045537",
"0.69570506",
"0.6938147",
"0.6889492",
"0.67870814",
"0.6733861",
"0.672316",
"0.6712159",
"0.6678957",
"0.66361743",
"0.65957177",
"0.6593721",
"0.65830356",
"0.65715605",
"0.6566285",
"0.6548414",
"0.65130556",
"0.6509444",
"0.650258... | 0.0 | -1 |
DELETE /admin/types/1 DELETE /admin/types/1.json | def destroy
@admin_type.destroy
redirect_to admin_types_url, notice: 'kaydı silindi.'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n ... | [
"0.8081988",
"0.75500906",
"0.7352538",
"0.72168976",
"0.7187108",
"0.7159649",
"0.7141157",
"0.7094593",
"0.7087615",
"0.70732784",
"0.7066181",
"0.705843",
"0.7040619",
"0.7039158",
"0.7026549",
"0.70120865",
"0.7003689",
"0.69974923",
"0.69927996",
"0.69794714",
"0.6958372... | 0.72645766 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_admin_type
@admin_type = Type.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 admin_type_params
params.require(:type).permit(:code, :text, :is_active, :language_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 |
Public: Initialize a new ping request sitemap_url A String url of the sitemap we're submitting Returns a Pingr::Request object | def initialize(sitemap_url)
Pingr::SearchEngines::Bing.new(sitemap_url).ping
Pingr::SearchEngines::Google.new(sitemap_url).ping
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ping_url\n URI(\"https://www.google.com/webmasters/tools/ping?sitemap=#{URI.escape(sitemap_url)}\")\n end",
"def run(url = nil)\n url ||= sitemap_url\n\n raise \"sitemap_url not set - use SitemapNotifier::Notifier.sitemap_url = 'http://domain.com/sitemap.xml'\" unless url\n\n ... | [
"0.6151012",
"0.59372574",
"0.58665586",
"0.57027286",
"0.5675409",
"0.5675409",
"0.5631189",
"0.55777836",
"0.54924345",
"0.54449964",
"0.5359614",
"0.53446233",
"0.5339046",
"0.53303075",
"0.530507",
"0.5245034",
"0.52437603",
"0.5240933",
"0.5232268",
"0.5218628",
"0.51879... | 0.6882358 | 0 |
Returns a poltergeist driver | def setup_capybara
@poltergeist_driver = nil
# Capybara will not re-run the block if the driver name already exists, so the driver name
# will have a time integer appended to ensure uniqueness.
driver_name = "poltergeist_crawler_#{Time.now.to_f}".to_sym
Grell.logger.info "GRELL Registering poltergeist driver with name '#{driver_name}'"
Capybara.register_driver driver_name do |app|
@poltergeist_driver = Capybara::Poltergeist::Driver.new(app,
js_errors: false,
inspector: false,
phantomjs_logger: FakePoltergeistLogger,
phantomjs_options: ['--debug=no', '--load-images=no', '--ignore-ssl-errors=yes', '--ssl-protocol=TLSv1.2'])
end
Capybara.default_max_wait_time = 3
Capybara.run_server = false
Capybara.default_driver = driver_name
Capybara.current_session.driver.headers = { # The driver gets initialized when modified here
"DNT" => 1,
"User-Agent" => USER_AGENT
}
raise 'Poltergeist Driver could not be properly initialized' unless @poltergeist_driver
@poltergeist_driver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def driver; end",
"def getDriver\n @driver\n end",
"def getDriver\n @driver\n end",
"def initialize driver\n @driver = driver\n end",
"def driver\n\t\t\t_load_driver unless @driver\n\t\t\t@driver\n\t\tend",
"def driver\n @driver ||= self.class.default_driver\n end",
"def driver\... | [
"0.6476556",
"0.63957393",
"0.63957393",
"0.62519187",
"0.62196314",
"0.6050889",
"0.5967989",
"0.5881456",
"0.5859942",
"0.5859942",
"0.5794145",
"0.5747565",
"0.5738498",
"0.5738498",
"0.57112",
"0.5675096",
"0.5621221",
"0.56107324",
"0.55575496",
"0.5528984",
"0.55213034"... | 0.6131862 | 5 |
Even if the user can manage some event proposals (i.e. their own), only allow access to this controller if they can manage arbitrary ones in this con | def authorize_admin
permission = params[:action] == 'update' ? :manage : :read
authorize! permission, convention.event_proposals.new(status: 'reviewing')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prevent_self\n if current_user.proposals.include?(@proposal)\n redirect_to reviewer_event_proposals_path\n end\n end",
"def require_authorization!\n unless current_user == @event.user\n render json: {}, status: :forbidden\n end\n end",
"def define_eccept\n if current_user.inf... | [
"0.6640579",
"0.661129",
"0.6531705",
"0.6500305",
"0.6476846",
"0.64645904",
"0.6412221",
"0.64011276",
"0.63178724",
"0.6298317",
"0.6285399",
"0.6281722",
"0.6281532",
"0.627368",
"0.62593013",
"0.6245561",
"0.622982",
"0.6188342",
"0.6184136",
"0.61662996",
"0.6160652",
... | 0.7030839 | 0 |
GET /user_admins GET /user_admins.json | def index
@user_admins = UserAdmin.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_admins\n service_response = ManagerManagement::Team::ListAdmins.new(params).perform\n return render_api_response(service_response)\n end",
"def index\n @admins = Admin.all\n\n render json: @admins\n end",
"def index\n @admins = Admin.all\n\n respond_to do |format|\n format.htm... | [
"0.7575526",
"0.74068177",
"0.7253745",
"0.70870405",
"0.7020878",
"0.6934293",
"0.69280875",
"0.69213283",
"0.6847066",
"0.6847066",
"0.6847066",
"0.6847066",
"0.6847066",
"0.6847066",
"0.68206155",
"0.6818822",
"0.6812175",
"0.6812175",
"0.67999125",
"0.67923635",
"0.677922... | 0.7196631 | 3 |
GET /user_admins/1 GET /user_admins/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @admins = Admin.all\n\n render json: @admins\n end",
"def show\n @useradmin = Useradmin.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @useradmin }\n end\n end",
"def index\n @admins = Admin.all\n\n respond_to... | [
"0.73344696",
"0.725803",
"0.7205409",
"0.7171828",
"0.7158008",
"0.71291465",
"0.71246594",
"0.7016367",
"0.69751406",
"0.6970404",
"0.69383746",
"0.6897763",
"0.68842405",
"0.6870607",
"0.68172395",
"0.68170744",
"0.6813081",
"0.67862064",
"0.6737291",
"0.67338413",
"0.6699... | 0.0 | -1 |
POST /user_admins POST /user_admins.json Will be the "Create Your Account" Route | def create
user = user_admin_params
invite_only = UserAdmin.find_by(username: 'invite_only') unless cookies[:authentication_token].present? || params[:user_type].eql?('normal')
if (cookies[:authentication_token].present?) || (invite_only.valid_password? params[:invite_password] )
@user_admin = UserAdmin.new(user_admin_params.merge(user_type: 'admin'))
@user_admin.encrypt_password(user[:password])
end
if @user_admin.valid?
respond_to do |format|
if @user_admin.save
flash[:notice] = "Congrats! User Account Created!"
format.html { redirect_to admin_homepage_path, notice: 'Account Successfully Created!.' }
format.json { render :show, status: :created, location: @user_admin }
else
format.html { render :new }
format.json { render json: @user_admin.errors, status: :unprocessable_entity }
end
end
else
if cookies[:authentication_token].nil?
flash[:danger] = @user_admin.errors.full_messages.join(' <br>') || "Need an Invite Code to become an Admin. "
redirect_to :back
else
flash[:danger] = "One user already has an account name with username #{params[:user_admin][:username]}"
redirect_to :back
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @admins = Admin.new(admin_params)\n respond_to do |format|\n if @admins.save\n format.html { redirect_to admins_path, notice: 'Admin was successfully created.' }\n format.json { render :show, status: :created, location: @admins }\n else\n format.html { render :new ... | [
"0.7257113",
"0.69951063",
"0.699237",
"0.69612825",
"0.69355685",
"0.6871238",
"0.6868472",
"0.684373",
"0.6822682",
"0.67870045",
"0.6780469",
"0.67429626",
"0.6727702",
"0.6727121",
"0.67189574",
"0.66969293",
"0.668952",
"0.66786796",
"0.6654088",
"0.66401374",
"0.6603214... | 0.6393983 | 32 |
PATCH/PUT /user_admins/1 PATCH/PUT /user_admins/1.json | def update
respond_to do |format|
new_password = params[:user_admin][:password]
password = new_password.present? ? @user_admin.encrypt_password(new_password) : @user_admin.password
if @user_admin.update(user_admin_params.merge(password: password))
format.html { redirect_to @user_admin, notice: 'User admin was successfully updated.' }
format.json { render :show, status: :ok, location: @user_admin }
else
format.html { render :edit }
format.json { render json: @user_admin.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @user.update(user_params)\n respond_with( [ :admin, @user] )\n end",
"def change_admin\n user_id = params[:user].to_i\n admin = params[:admin]\n\n if user_id == 0 || admin.nil?\n render :json => {error:'please enter params'}\n return\n end\n\n user = User.find(user_id... | [
"0.7044912",
"0.70062035",
"0.6920401",
"0.6847175",
"0.6794185",
"0.67735523",
"0.67340505",
"0.67340505",
"0.67340505",
"0.67340505",
"0.67340505",
"0.67340505",
"0.6711088",
"0.670924",
"0.6618588",
"0.66077155",
"0.65919614",
"0.65889496",
"0.65878713",
"0.65428334",
"0.6... | 0.0 | -1 |
DELETE /user_admins/1 DELETE /user_admins/1.json | def destroy
@user_admin.destroy
respond_to do |format|
format.html { redirect_to user_admins_url, notice: 'User admin was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @useradmin = Useradmin.find(params[:id])\n @useradmin.destroy\n\n respond_to do |format|\n format.html { redirect_to useradmins_url }\n format.json { head :no_content }\n end\n end",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{a... | [
"0.76383054",
"0.74361074",
"0.73437554",
"0.7341942",
"0.73316723",
"0.7330526",
"0.7316051",
"0.73132867",
"0.72806084",
"0.7275505",
"0.725276",
"0.7229396",
"0.7162493",
"0.7108168",
"0.7092355",
"0.70411634",
"0.70065427",
"0.6992554",
"0.6987076",
"0.69816434",
"0.69735... | 0.7199374 | 12 |
Use callbacks to share common setup or constraints between actions. | def set_user_admin
@user_admin = UserAdmin.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_admin_params
params.require(:user_admin).permit(:name, :username, :password, :user_type, :email)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Calls .capitalize! on a field only if it is all lowercase or uppercase | def safe_capitalize(field)
field.capitalize! if needs_capitalize(field)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capitalize!() end",
"def capitalize() end",
"def capitalize(input); end",
"def uppercase_fields\n\t self.fname.capitalize!\n\t self.lname.capitalize!\n\t self.address.capitalize!\n\t self.city.capitalize!\n\t self.state.upcase!\n\t self.email.downcase!\n\t # self.area.capitalize!\n\t self.discipl... | [
"0.7959306",
"0.7882073",
"0.76706815",
"0.7449863",
"0.74363256",
"0.74284744",
"0.7420271",
"0.7409909",
"0.7372594",
"0.7362678",
"0.73383623",
"0.7329564",
"0.730246",
"0.7268984",
"0.7265974",
"0.726585",
"0.7265483",
"0.7265483",
"0.7221315",
"0.7215957",
"0.7204482",
... | 0.8661473 | 0 |
only admin and premium user who owns the private wiki can see it def show? | def create?
user.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_private_tab\n current_user && (current_user.admin? || # if current_user is an admin\n current_user.premium? || # current_user is a premium\n current_user.wiki_collaborations.any?) # current_user has any private wiki collaborations\n end",
"def index\n #anyone\n # @wiki... | [
"0.76595825",
"0.736127",
"0.7133419",
"0.70377344",
"0.69960284",
"0.6973048",
"0.6973048",
"0.6973048",
"0.6962073",
"0.69513583",
"0.6942782",
"0.69222957",
"0.6891615",
"0.688714",
"0.68410933",
"0.68393594",
"0.6835926",
"0.68153846",
"0.68147403",
"0.6802628",
"0.679440... | 0.0 | -1 |
puts "v" 80 pp ARGV puts "^" 80 invocations | def re_encode_to_utf8(s)
(s.valid_encoding? ?
s :
s.encode('UTF-16be', invalid: :replace, replace: '?')
).encode('UTF-8')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def p(*args)\n i = 0\n len = args.size\n while i < len\n __printstr__ args[i].inspect\n __printstr__ \"\\n\"\n i += 1\n end\n args[0]\n end",
"def argv; end",
"def vest _args\n \"vest _args;\" \n end",
"def print_usage(options)\n puts\n puts \"Usage: \"+$0+\" -[\"+opt... | [
"0.6291158",
"0.6089926",
"0.6041044",
"0.60186696",
"0.5984638",
"0.59060794",
"0.58879375",
"0.5866358",
"0.58464384",
"0.5823453",
"0.5817234",
"0.577933",
"0.5752065",
"0.57327807",
"0.5714509",
"0.5694103",
"0.5690419",
"0.5682036",
"0.5651663",
"0.5647031",
"0.5625512",... | 0.0 | -1 |
GET /shiftmaps/1 GET /shiftmaps/1.json | def show
@shiftmap = Shiftmap.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @shiftmap }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @shiftmap = Shiftmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shiftmap }\n end\n end",
"def show\n @system_site_map = SystemSiteMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js... | [
"0.69269544",
"0.67321336",
"0.65671474",
"0.65471447",
"0.64994097",
"0.64784044",
"0.64784044",
"0.64556134",
"0.6445524",
"0.64121383",
"0.6393777",
"0.62633395",
"0.6262058",
"0.62182844",
"0.62150216",
"0.6188293",
"0.617809",
"0.61708206",
"0.61203694",
"0.6117504",
"0.... | 0.78645027 | 0 |
GET /shiftmaps/new GET /shiftmaps/new.json | def new
@shiftmap = Shiftmap.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @shiftmap }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @shiftmap = Shiftmap.new(params[:shiftmap])\n\n respond_to do |format|\n if @shiftmap.save\n format.html { redirect_to @shiftmap, notice: 'Shiftmap was successfully created.' }\n format.json { render json: @shiftmap, status: :created, location: @shiftmap }\n else\n ... | [
"0.76809496",
"0.7205277",
"0.71511173",
"0.7148215",
"0.7125227",
"0.7123903",
"0.69924754",
"0.6968181",
"0.6905596",
"0.68761533",
"0.68437463",
"0.6773352",
"0.6743493",
"0.6738542",
"0.6716584",
"0.6645686",
"0.664242",
"0.6628046",
"0.6619586",
"0.6591297",
"0.6485806",... | 0.83820873 | 0 |
POST /shiftmaps POST /shiftmaps.json | def create
@shiftmap = Shiftmap.new(params[:shiftmap])
respond_to do |format|
if @shiftmap.save
format.html { redirect_to @shiftmap, notice: 'Shiftmap was successfully created.' }
format.json { render json: @shiftmap, status: :created, location: @shiftmap }
else
format.html { render action: "new" }
format.json { render json: @shiftmap.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @shiftmap = Shiftmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shiftmap }\n end\n end",
"def create\n @sasmap = Sasmap.new(params[:sasmap])\n\n respond_to do |format|\n if @sasmap.save\n format.html { redirect_to @sas... | [
"0.660331",
"0.6425722",
"0.63063866",
"0.619712",
"0.61946636",
"0.6167073",
"0.6111352",
"0.6078473",
"0.6077343",
"0.6065942",
"0.6045785",
"0.59977",
"0.59977",
"0.5980799",
"0.5965313",
"0.591951",
"0.58963555",
"0.58824027",
"0.58810914",
"0.587798",
"0.587081",
"0.58... | 0.77579314 | 0 |
PUT /shiftmaps/1 PUT /shiftmaps/1.json | def update
@shiftmap = Shiftmap.find(params[:id])
respond_to do |format|
if @shiftmap.update_attributes(params[:shiftmap])
format.html { redirect_to @shiftmap, notice: 'Shiftmap was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @shiftmap.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @shiftmap = Shiftmap.new(params[:shiftmap])\n\n respond_to do |format|\n if @shiftmap.save\n format.html { redirect_to @shiftmap, notice: 'Shiftmap was successfully created.' }\n format.json { render json: @shiftmap, status: :created, location: @shiftmap }\n else\n ... | [
"0.7024791",
"0.68244123",
"0.6580088",
"0.65610415",
"0.6519724",
"0.6519724",
"0.6519724",
"0.6519724",
"0.64892113",
"0.6417741",
"0.64170635",
"0.6361011",
"0.62896144",
"0.62223035",
"0.61851037",
"0.60872686",
"0.60819644",
"0.60796523",
"0.6073792",
"0.6038828",
"0.601... | 0.7591063 | 0 |
DELETE /shiftmaps/1 DELETE /shiftmaps/1.json | def destroy
@shiftmap = Shiftmap.find(params[:id])
@shiftmap.destroy
respond_to do |format|
format.html { redirect_to shiftmaps_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @sasmap = Sasmap.find(params[:id])\n @sasmap.destroy\n\n respond_to do |format|\n format.html { redirect_to sasmaps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @map.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n ... | [
"0.73867786",
"0.72529703",
"0.7194076",
"0.7190465",
"0.7174554",
"0.71734077",
"0.71656126",
"0.71656126",
"0.71656126",
"0.7153788",
"0.7034083",
"0.70239663",
"0.7022169",
"0.70160073",
"0.6946354",
"0.69418883",
"0.6939055",
"0.69263667",
"0.69252914",
"0.69252914",
"0.6... | 0.79010034 | 0 |
compare first two indexes and compare the values | def bubble_sort(array)
index = array.length - 1
loop do
sorted = false
index.times do |i|
if array[i] > array[i + 1]
array[i], array[i + 1] = array[i + 1], array[i]
sorted = true
end
end
break if not sorted
end
array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_diff_betw_indexes(hash, key_1, value_1, key_2, value_2)\n array_1 = hash[:bay_1].to_a\n array_2 = hash[:bay_2].to_a\n\n full_array = array_1 + array_2\n object_1 = key_1 , value_1\n object_2 = key_2, value_2\n for item_selection in full_array\n if (item_selection == object_1) || (item_selection... | [
"0.6429632",
"0.6369578",
"0.63069534",
"0.62928104",
"0.62133336",
"0.6172718",
"0.6153445",
"0.61122453",
"0.6093968",
"0.59660786",
"0.59085375",
"0.5896019",
"0.5883891",
"0.5862567",
"0.58579594",
"0.58423096",
"0.58341604",
"0.5828649",
"0.58064145",
"0.57683223",
"0.57... | 0.0 | -1 |
Writes the user data back to the database | def update
@user = User.find(params[:id])
if @user.update(user_params)
redirect_to users_path(), notice: "Profile updated!"
else
render 'edit'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_user\n data = load_data\n user_details = {\n 'id' => @user.uid.to_s,\n 'username' => @user.username,\n 'password' => @user.password,\n 'playlist' => @user.playlist,\n 'mylist' => @user.mylist\n }\n data << user_details\n write_user(data)\n end",
"def save_user\n... | [
"0.6997292",
"0.68710583",
"0.68241006",
"0.65149885",
"0.6390843",
"0.63895303",
"0.637031",
"0.63674057",
"0.63280326",
"0.61976963",
"0.61249536",
"0.61246",
"0.61101574",
"0.61059743",
"0.610543",
"0.61033493",
"0.6064642",
"0.5994526",
"0.5978397",
"0.5954297",
"0.594528... | 0.0 | -1 |
Redirects to `signin_path` if the user hasn't signed in yet | def signed_in_user
redirect_to signin_path, :status => 302 unless signed_in?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_signin_status\n unless user_signed_in?\n redirect_to root_url\n end\n end",
"def require_signin\n\t\tunless current_user\n\t\t\t# session[:intended_url] = request.url\n\t\t\t# redirect_to new_session_url, alert: \"Please sign in first\"\n\t\t\trender nothing: true, status: :unauthorized\n\t\... | [
"0.8193081",
"0.7988081",
"0.7926018",
"0.7902795",
"0.7859818",
"0.78131187",
"0.7799716",
"0.7784087",
"0.77631354",
"0.7730241",
"0.76628417",
"0.76628417",
"0.76628417",
"0.76419526",
"0.7616575",
"0.7547718",
"0.7547373",
"0.75130504",
"0.74963444",
"0.74780726",
"0.7466... | 0.7867584 | 5 |
Checks if the requested user id matches the session user's id Otherwise it will redirect to the root | def correct_user
@user = User.find(params[:id])
# Redirect to the root if the user isn't perform requests on this resource
redirect_to root_path, :status => 302, :flash => {:error => "You can't do that!"} unless current_user[:id]==@user[:id]
# Redirect to the root path if the user isn't found
rescue ActiveRecord::RecordNotFound
redirect_to root_path, :status => 404
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n @user = User.find(params[:id])\n # {Function}current_user? in sessions_helper.rb\n redirect_to(root_url) unless current_user?(@user)\n end",
"def correct_user?(id)\n user = User.find_by(id: id)\n redirect_to(root_url) unless current_user == user\n end",
"def co... | [
"0.8104617",
"0.8091846",
"0.8036057",
"0.79831344",
"0.79723823",
"0.79674137",
"0.7949874",
"0.794926",
"0.79394203",
"0.7936476",
"0.79155225",
"0.7914793",
"0.7914793",
"0.7909525",
"0.7909525",
"0.7909525",
"0.7909525",
"0.7909525",
"0.7909525",
"0.7909525",
"0.7909525",... | 0.7872762 | 28 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash) #will need to iterate through the hash, compare values, and then return the key with the smallest value
key_of_min_value = nil
min_value = nil
name_hash.each do |key, value|
if min_value == nil || value < min_value
min_value = value
key_of_min_value = key
end
end
key_of_min_value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585... | 0.0 | -1 |
GET /leads GET /leads.json def index | def create
@lead = Lead.new(lead_params)
respond_to do |format|
if verify_recaptcha(model: @lead) && @lead.save
mg_client = Mailgun::Client.new
message = {
:from => @lead.email,
:to => 'ordrhub@gmail.com',
:subject => "New Lead (ID: #{@lead.id})",
:text => params['beta_body']
}
mg_client.send_message 'mg.ordrhub.com', message
format.html { redirect_to root_url, notice: 'Thank you for your interest! We\'ll review your request shortly.' }
format.json { render :show, status: :created, location: @lead }
else
format.html { redirect_to root_url, alert: 'Uh-oh, it looks like you\'re either a robot or have already a submitted a request using that email. We still may be reviewing your request and we\'ll let you know when you\'re able to access OrdrHub as soon as possible!' }
format.json { render json: @lead.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @leads = Lead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leads }\n end\n end",
"def index\n\t\t@leads = Lead.all\n\t\t\n\t\t\n\n\t\tlogger.info params[:status]\n\t\trespond_to do |format|\n\t\t format.html # index.html.erb\n\t\t f... | [
"0.8421764",
"0.77476454",
"0.77465457",
"0.77465457",
"0.7744631",
"0.77436805",
"0.77202076",
"0.72241616",
"0.71232504",
"0.710031",
"0.7078159",
"0.70519304",
"0.69741076",
"0.691258",
"0.6893583",
"0.6893583",
"0.68479204",
"0.6827181",
"0.68223536",
"0.67656475",
"0.674... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_lead
@lead = Lead.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def lead_params
params.require(:lead).permit(:email, :grubhub, :yelp, :chownow, :doordash)
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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
puts "this is a debug message" | def solution(a)
return 0 if a.length < 3
a.sort!
for i in 0..(a.length - 3)
return 1 if a[i] + a[i + 1] > a[i + 2]
end
return 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug(msg)\n #puts msg\n end",
"def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend",
"def print_debug(msg)\n puts msg if (@debug) \n STDOUT.flush\n end",
"def debug(message)\n puts message if debug?\n end",
"def debug(s) if $DEBUG then $stderr.print(\"#{s}\\n\") end end",
"def debug_ms... | [
"0.8406359",
"0.8268479",
"0.8211071",
"0.8138492",
"0.8107914",
"0.80671936",
"0.8004696",
"0.79987866",
"0.7975501",
"0.7975501",
"0.7975501",
"0.79284",
"0.78572273",
"0.78488684",
"0.7837523",
"0.7821288",
"0.7821288",
"0.7792199",
"0.7773948",
"0.7743215",
"0.7739327",
... | 0.0 | -1 |
all page functions are loaded set base url for test cases this can be default set in config.yml or can be passed with cucumber command | def set_base_url
$base_url = (ENV['base_url'].nil? || ENV['base_url'].empty?) ? CONFIG['default_base_url'] : ENV['base_url']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goto_base_url\n @browser.goto base_url\n end",
"def setup\n @page = pages(:homepage)\n end",
"def url\n raise \"The 'URL' environment variable was not specified on the cucumber command line.\" if ENV['URL'].nil?\n ENV['URL']\n end",
"def url\n send(\"url_#{page.env}\")\n end",
"def s... | [
"0.62968636",
"0.621762",
"0.60762906",
"0.6062897",
"0.6049923",
"0.6037365",
"0.5996079",
"0.5963893",
"0.5963306",
"0.595366",
"0.59192824",
"0.59085274",
"0.58034843",
"0.58034843",
"0.57999295",
"0.57801783",
"0.5724753",
"0.5719869",
"0.5706494",
"0.5705008",
"0.5698605... | 0.5978174 | 7 |
Redirect to dashboard on login success | def after_sign_in_path_for(resource)
dashboard_path(current_user.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to_dashboard_if_logged_in\n if logged_in?\n redirect_to dashboard_path\n return\n end\n end",
"def landing\n redirect_to dashboard_path if current_user\n end",
"def login_checkpoint\n redirect to '/' if !logged_in?\n end",
"def user_login\n unless logged_in?\n na... | [
"0.7865472",
"0.7500483",
"0.74511015",
"0.7334935",
"0.7259905",
"0.72488475",
"0.7243672",
"0.72392464",
"0.72328347",
"0.7219127",
"0.72034824",
"0.71993965",
"0.7137018",
"0.71347904",
"0.7115229",
"0.70894575",
"0.708437",
"0.70490515",
"0.7048135",
"0.7034531",
"0.70289... | 0.0 | -1 |
parses parameters for 'i' value which indicates associations to include in the rendering of JSON data these variables are used by RABL to in/exclude the association data | def set_includes
@includes = params[:i].nil? ? [] : eval(params[:i])
@includes_list = @includes.map{|b| b.is_a?(Hash) ? b.to_a.flatten : b}.flatten || []
#Rails.logger.debug @includes
#Rails.logger.debug @includes_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_association_items(ar, opts)\n s = {}\n if(opts[:include] != nil) \n opts[:include].each do |j|\n if ar.send(j).kind_of? Array\n m_a = []\n ar.send(j).each do |m|\n m_a.push m.attributes \n end\n s[j.to_s] ... | [
"0.59826094",
"0.5683023",
"0.564391",
"0.56352574",
"0.5448891",
"0.53015304",
"0.51892084",
"0.5180492",
"0.5164217",
"0.51419413",
"0.5138152",
"0.50876075",
"0.50734663",
"0.50715625",
"0.5066926",
"0.5054823",
"0.5047441",
"0.50396013",
"0.5019769",
"0.500952",
"0.500460... | 0.542072 | 5 |
Deprecated: See fucntionality in McpAuth initializer for devise token authentication | def get_api_key
if api_key = params[:auth_token].blank? && request.headers["X-API-KEY"]
params[:auth_token] = api_key
end
#Rails.logger.debug params #.to_yaml
#Rails.logger.debug "API KEY passed is #{request.headers['X-API-KEY']}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_authentication_tokens\n self.client = Devise.friendly_token\n self.access_token = Devise.friendly_token\n end",
"def token_auth(*args, &block); end",
"def token_auth(token=nil, options={})\n return @token_auth unless token\n @token_auth = [token, options]\n end",
"def authen... | [
"0.6900919",
"0.6855767",
"0.67840767",
"0.6699301",
"0.6676028",
"0.66729695",
"0.66679734",
"0.664696",
"0.65907097",
"0.65714526",
"0.65714526",
"0.65714526",
"0.65714526",
"0.6559788",
"0.6550227",
"0.65442336",
"0.65437156",
"0.65360254",
"0.6531727",
"0.6517674",
"0.651... | 0.0 | -1 |
GET /step_comments GET /step_comments.json | def index
@step_comments = StepComment.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end",
"def co... | [
"0.76296234",
"0.69458055",
"0.69458055",
"0.68708766",
"0.66790396",
"0.6557748",
"0.65324026",
"0.6521532",
"0.65194684",
"0.64099115",
"0.63786644",
"0.6350778",
"0.6344735",
"0.6308113",
"0.6294868",
"0.6284277",
"0.6263872",
"0.625538",
"0.6253088",
"0.62209207",
"0.6210... | 0.7431277 | 1 |
GET /step_comments/1 GET /step_comments/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def index\n @step_comments = StepComment.all\n end",
"def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n ... | [
"0.7466982",
"0.73430014",
"0.67509955",
"0.6685839",
"0.6685839",
"0.6588799",
"0.65819913",
"0.6567342",
"0.65664274",
"0.65663695",
"0.64310396",
"0.6427872",
"0.63644385",
"0.6266938",
"0.6257845",
"0.62470865",
"0.6240574",
"0.6239519",
"0.6232776",
"0.62283134",
"0.6212... | 0.0 | -1 |
POST /step_comments POST /step_comments.json | def create
@step_comment = StepComment.new(step_comment_params)
respond_to do |format|
if @step_comment.save
format.html { redirect_to @step_comment, notice: 'Step comment was successfully created.' }
format.json { render :show, status: :created, location: @step_comment }
else
format.html { render :new }
format.json { render json: @step_comment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step_comment_params\n params.require(:step_comment).permit(:step_id, :text, :user_id)\n end",
"def comment_params\n params.require(:comment).permit(:content, :step)\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create_comments\n end",
"def comment options={... | [
"0.6992928",
"0.69515157",
"0.66250134",
"0.66250134",
"0.66250134",
"0.65945214",
"0.6555131",
"0.63133395",
"0.63062406",
"0.62889683",
"0.62863374",
"0.6264488",
"0.62580943",
"0.6250125",
"0.6242073",
"0.6233609",
"0.6216042",
"0.6206234",
"0.61922085",
"0.61744934",
"0.6... | 0.7558353 | 0 |
PATCH/PUT /step_comments/1 PATCH/PUT /step_comments/1.json | def update
respond_to do |format|
if @step_comment.update(step_comment_params)
format.html { redirect_to @step_comment, notice: 'Step comment was successfully updated.' }
format.json { render :show, status: :ok, location: @step_comment }
else
format.html { render :edit }
format.json { render json: @step_comment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_step_comment\n @step_comment = StepComment.find(params[:id])\n end",
"def update\n @step = Step.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n @step_activity = StepActivity.new(:activity_type => 'edit', :description => @step.descriptio... | [
"0.6495602",
"0.63373035",
"0.6291205",
"0.6260094",
"0.6254557",
"0.6253744",
"0.62027174",
"0.6125351",
"0.61180145",
"0.6100172",
"0.6095201",
"0.6075113",
"0.60615736",
"0.60513484",
"0.6039648",
"0.6030871",
"0.60293156",
"0.60213107",
"0.6013032",
"0.600602",
"0.5995267... | 0.7317265 | 0 |
DELETE /step_comments/1 DELETE /step_comments/1.json | def destroy
@step_comment.destroy
respond_to do |format|
format.html { redirect_to step_comments_url, notice: 'Step comment was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_comments\n end",
"def destroy\n @step = Step.find(params[:id])\n @step.status = \"deleted\"\n @step.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def delete_comment1\n params[:comment].each { |key, value|\n comment=Comment... | [
"0.68660504",
"0.68461466",
"0.68078333",
"0.66939956",
"0.6654585",
"0.6649471",
"0.66165286",
"0.66056705",
"0.65999097",
"0.6590643",
"0.65766793",
"0.65666664",
"0.65666664",
"0.6563699",
"0.65404254",
"0.6534011",
"0.65258646",
"0.65181005",
"0.651235",
"0.64979005",
"0.... | 0.7515619 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.