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 |
|---|---|---|---|---|---|---|
Filter for check if user is logged in or not | def authenticate
unless session[:loggedin]
redirect_to :action => 'login'
return false
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_filter\n if current_user\n true\n end\n end",
"def signed_in_user_filter\n if signed_in?\n redirect_to root_path, notice: \"Already logged in\"\n end\n end",
"def logged_in\n logged_in_user != nil\n end",
"def logged_in\n current_user != nil\n end",
"def log... | [
"0.7959867",
"0.7732768",
"0.76609755",
"0.7642864",
"0.75749564",
"0.75350416",
"0.75256205",
"0.75136024",
"0.75078684",
"0.75027996",
"0.74873996",
"0.7474706",
"0.74667454",
"0.7457837",
"0.7454239",
"0.74388826",
"0.74275947",
"0.7424705",
"0.7418628",
"0.7418628",
"0.74... | 0.0 | -1 |
GET /administration/discounts/new GET /administration/discounts/new.json | def new
@discount = Discount.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @discount }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @store = Store.find(params[:store_id])\n @dish_discount = @store.dish_discounts.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dish_discount }\n end\n end",
"def create\n @discount = Discount.new(params[:discount])\n\n respond_to... | [
"0.7241379",
"0.7185507",
"0.69331545",
"0.69142354",
"0.67885697",
"0.6754972",
"0.6754972",
"0.6748556",
"0.6684997",
"0.66819423",
"0.66796905",
"0.66746145",
"0.6669666",
"0.66612744",
"0.6651796",
"0.66471237",
"0.6637479",
"0.66373247",
"0.66373247",
"0.6637278",
"0.662... | 0.7828485 | 1 |
POST /administration/discounts POST /administration/discounts.json | def create
@discount = Discount.new(params[:discount])
respond_to do |format|
if @discount.save
format.html { redirect_to administration_discounts_url, notice: 'Discount was successfully created.' }
format.json { render json: @discount, status: :created, location: @discount }
else
format.html { render action: "new" }
format.json { render json: @discount.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @admin_discount = Admin::Discount.new(admin_discount_params)\n\n respond_to do |format|\n if @admin_discount.save\n format.html { redirect_to @admin_discount, notice: 'Discount was successfully created.' }\n format.json { render :show, status: :created, location: @admin_discou... | [
"0.6872339",
"0.68095905",
"0.6773775",
"0.677042",
"0.6306822",
"0.62951756",
"0.62380785",
"0.6222267",
"0.6190148",
"0.6190148",
"0.6174386",
"0.60841006",
"0.6058156",
"0.6015785",
"0.6009005",
"0.5949332",
"0.5936176",
"0.5935223",
"0.5930696",
"0.5911422",
"0.5902925",
... | 0.71370447 | 0 |
PUT /administration/discounts/1 PUT /administration/discounts/1.json | def update
@discount = Discount.find(params[:id])
@discount.products = Product.find(params[:products].keys.select{|key| params[:products][key] != '0'})
respond_to do |format|
if @discount.update_attributes(params[:discount])
format.html { redirect_to administration_discounts_url, notice: 'Discount was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @discount.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @discount = Discount.find(params[:id])\n\n respond_to do |format|\n if @discount.update_attributes(params[:discount])\n format.html { redirect_to @discount, notice: 'Discount was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren... | [
"0.6599441",
"0.6522552",
"0.64340496",
"0.63642037",
"0.617967",
"0.61346936",
"0.612238",
"0.60543",
"0.59935486",
"0.5976763",
"0.596784",
"0.5960307",
"0.59407675",
"0.5915656",
"0.58520097",
"0.58416414",
"0.5840161",
"0.5831379",
"0.5809548",
"0.5796155",
"0.5766704",
... | 0.65696967 | 1 |
DELETE /administration/discounts/1 DELETE /administration/discounts/1.json | def destroy
@discount = Discount.find(params[:id])
@discount.destroy
respond_to do |format|
format.html { redirect_to administration_discounts_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @discount = Discount.find(params[:id])\n @discount.destroy\n\n respond_to do |format|\n format.html { redirect_to discounts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_discount.destroy\n respond_to do |format|\n format.html { redire... | [
"0.7301742",
"0.7125411",
"0.7115391",
"0.7027455",
"0.69943833",
"0.6981079",
"0.6830518",
"0.6830518",
"0.6830518",
"0.6830518",
"0.67976457",
"0.6754323",
"0.6754323",
"0.6736279",
"0.6733819",
"0.67224336",
"0.6720271",
"0.6689188",
"0.6682561",
"0.66773903",
"0.66687095"... | 0.7483739 | 0 |
Limit support to purchase() for the time being JRuby chokes here undef_method :authorize, :capture, :void, :credit undef_method :authorize undef_method :capture undef_method :void undef_method :credit | def test?
Base.gateway_mode == :test
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purchase!\n if ratepay?\n capture!\n elsif adyen_cc_payment?\n authorize!\n capture!\n else\n super\n end\n end",
"def purchase\n #@cart = Cart.find(self.cart_id)\n #cart.update_attribute(:purchased_at, Time.now)\n if cart.tip && c... | [
"0.7250341",
"0.69842875",
"0.6752433",
"0.67229706",
"0.665672",
"0.66450477",
"0.6517181",
"0.64203435",
"0.6398294",
"0.6317802",
"0.62920225",
"0.6290466",
"0.6289815",
"0.6282743",
"0.62700015",
"0.62249404",
"0.62238204",
"0.62181264",
"0.6186857",
"0.6185872",
"0.61702... | 0.0 | -1 |
:granted integer either 1 or 0 for true or false :granted_by user id of admin who approved or declined the request :restaurant_id integer :restaurant_name string(255) :user_id integer | def deny
self.granted = -1
restaurant = Restaurant.find(self.restaurant_id)
restaurant.mark_collaborative
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n set_params\n @restaurant = Restaurant.find(params[:id])\n authorize! :update, @restaurant\n if (params[:restaurant][:status] == \"Exclusive\" &&\n @restaurant.owned_by != current_user.id)\n params[:restaurant][:status] = \"Pending Approval\"\n send_request\n @restaura... | [
"0.650397",
"0.6331228",
"0.6016958",
"0.5913272",
"0.58801514",
"0.5864774",
"0.58500963",
"0.5831588",
"0.57822675",
"0.57694536",
"0.573665",
"0.5733912",
"0.57185626",
"0.5710238",
"0.5698153",
"0.5682808",
"0.5662922",
"0.5616416",
"0.55886835",
"0.5586017",
"0.5582073",... | 0.6975305 | 0 |
TODO: time should be a required argument | def test_case_started(event, desired_time = ReportPortal.now)
test_case = event.test_case
feature = test_case.feature
if report_hierarchy? && !same_feature_as_previous_test_case?(feature)
end_feature(desired_time) unless @parent_item_node.is_root?
start_feature_with_parentage(feature, desired_time)
end
name = "#{test_case.keyword}: #{test_case.name}"
description = test_case.location.to_s
tags = test_case.tags.map(&:name)
type = :STEP
ReportPortal.current_scenario = ReportPortal::TestItem.new(name: name, type: type, id: nil, start_time: time_to_send(desired_time), description: description, closed: false, tags: tags)
scenario_node = Tree::TreeNode.new(SecureRandom.hex, ReportPortal.current_scenario)
@parent_item_node << scenario_node
ReportPortal.current_scenario.id = ReportPortal.start_item(scenario_node)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def time; end",
"def report_time time\n end",
"def atime() end",
"def atime() end",
"def time\n\n end",
"def start=(time); end",
"def cstime=(*) ... | [
"0.7177122",
"0.7177122",
"0.7177122",
"0.7177122",
"0.7177122",
"0.7177122",
"0.7177122",
"0.7177122",
"0.7177122",
"0.706178",
"0.69701695",
"0.69701695",
"0.6831799",
"0.6804068",
"0.6715374",
"0.6710896",
"0.6696465",
"0.6696465",
"0.6696465",
"0.6696465",
"0.6696465",
... | 0.0 | -1 |
Report Portal sorts logs by time. However, several logs might have the same time. So to get Report Portal sort them properly the time should be different in all logs related to the same item. And thus it should be stored. Only the last time needs to be stored as: only one test framework process/thread may send data for a single Report Portal item that process/thread can't start the next test until it's done with the previous one | def time_to_send(desired_time)
time_to_send = desired_time
if time_to_send <= @last_used_time
time_to_send = @last_used_time + 1
end
@last_used_time = time_to_send
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @logs = Log.all.order(:delivery_time)\n end",
"def sort_abschnitte_and_umschlaege\n abschnitt_umschlag_list = []\n # Hilfsmethode, baut einen nach Orten sortierten Hash auf.\n ort_to_detail = sort_abschnitte_and_umschlaege_by_ort\n File.open(\"log/transport.log\",\"w\"){|f| f.puts \"O... | [
"0.6221566",
"0.59867805",
"0.59453636",
"0.58677",
"0.57988477",
"0.57832164",
"0.57450765",
"0.569951",
"0.56988",
"0.5667375",
"0.5665648",
"0.56524277",
"0.5651264",
"0.5647559",
"0.5639732",
"0.5607777",
"0.5607087",
"0.5606738",
"0.55951816",
"0.5543623",
"0.5540703",
... | 0.0 | -1 |
Rename this if more options will apear(time range, convert etc) | def call
query_params = {
base: params[:base_currency],
symbols: params[:exchange_currency],
start_at: params[:duration].to_i.days.ago.to_date.to_s, # remove this magic
end_at: Date.today.to_s # this one too
}.to_query
url = "#{URL_BASE}/history?#{query_params}"
self.class.fetch(url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rename\n @rename ||= settings[:option] ? (settings[:as] || name) : name\n end",
"def generate_name_target(opts={})\n # check if file already renamed to YYYYMMDD-hhss-AAA[AAA] format\n if (/^(\\d{8}-\\d{4}_\\w{3,6}_)(.*)/ =~ @name)\n name_clean = $2 \n # check if file already rename... | [
"0.5704486",
"0.562776",
"0.5554044",
"0.55333936",
"0.55189663",
"0.5508282",
"0.55022043",
"0.54612476",
"0.5421302",
"0.5332396",
"0.5310721",
"0.5257304",
"0.51871175",
"0.51719755",
"0.50937307",
"0.50864893",
"0.5081997",
"0.5081997",
"0.5079602",
"0.50656545",
"0.50539... | 0.0 | -1 |
returns a Pathbuilder object for manipulating the query parameters | def pb
@pb ||= SFRest::Pathbuilder.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_path(path, params)\n path + \"?\" + build_query_params(params)\n end",
"def build_path path, params = {}\n params.size > 0 ? [path, hash_to_params(params)].join(\"?\") : path\n end",
"def build_path_query\n @path = '/' + @dn\n\n query = []\n [@extensions, @filter, @scope,... | [
"0.7320665",
"0.7280481",
"0.72717524",
"0.68705726",
"0.6714175",
"0.65620124",
"0.65200186",
"0.6519456",
"0.64796543",
"0.64120436",
"0.6398689",
"0.6394511",
"0.6359638",
"0.6336727",
"0.63150567",
"0.6311691",
"0.63087535",
"0.62602943",
"0.62319905",
"0.62268287",
"0.62... | 0.0 | -1 |
Test accessing v13 and v200906 with bad logins | def test_bad_login
cred_hash = {
'developerToken' => 'INVALID',
'useragent' => 'INVALID',
'password' => 'INVALID',
'email' => 'INVALID',
'clientEmail' => 'INVALID',
'applicationToken' => 'IGNORED',
'environment' => 'SANDBOX'
}
adwords = AdWords::API.new(AdWords::AdWordsCredentials.new(cred_hash))
# See if we get the right error back from the v13 sandbox
campaign_srv_v13 = adwords.get_service(13, 'Campaign')
assert_raise(AdWords::Error::GoogleInternalError) do
campaign_srv_v13.getAllAdWordsCampaigns(0)
end
# See if we get the right error back from the v200906 sandbox
campaign_srv_v200906 = adwords.get_service(200906, 'Campaign')
assert_raise(AdWords::Error::AuthError) do
result = campaign_srv_v200906.get(@selector)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_login\n for int in 1..1000\n begin\n login_user = Login.authenticate(\"gordon\", get_string_of_length(rand(10)))\n assert false\n rescue LoginException\n assert true\n end\n end\n end",
"def test_bad_login_v2009\n cred_hash = {\n 'developerToke... | [
"0.683717",
"0.6674872",
"0.6572684",
"0.6501756",
"0.6461089",
"0.64380574",
"0.6415437",
"0.63858914",
"0.6373751",
"0.63616586",
"0.6359036",
"0.63539994",
"0.63469505",
"0.6267586",
"0.6248505",
"0.6234667",
"0.6221451",
"0.6207395",
"0.61532456",
"0.6092651",
"0.6077015"... | 0.6205772 | 18 |
Test accessing v13 and v200906 with valid logins | def test_good_login
account_srv_v13 = @adwords.get_service(13, 'Account')
result = account_srv_v13.getClientAccounts
assert_not_nil(result, 'Invalid result set returned')
campaign_srv_v200906 = @adwords.get_service(200906, 'Campaign')
result = campaign_srv_v200906.get(@selector)
assert_not_nil(result, 'Invalid result set returned')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test05_ValidLogin_TC_24862\n\t\t$browser.cookies.clear\n\t\t$browser.goto($patch_login)\n\t\t$email.set(\"#{$user_master_email}\")\n\t\t$password.set(\"#{$user_master_password}\")\n\t\t$sign_in_button.click\n\t\tsleep 4\n\t\t\n\t\tbegin \n\t\t\tassert $logged_in_avatar.exists?\n\t\t\trescue => e\n\t\t\tputs e\... | [
"0.66886675",
"0.66760916",
"0.65089095",
"0.6505133",
"0.6488645",
"0.6486787",
"0.6466205",
"0.6456692",
"0.64275974",
"0.6417602",
"0.6392042",
"0.6298956",
"0.6291472",
"0.6199488",
"0.61940163",
"0.61883056",
"0.61816406",
"0.6168185",
"0.6155944",
"0.615099",
"0.6129333... | 0.61484855 | 20 |
Test making an API call with wrong parameter types | def test_wrong_type
campaign_srv_v13 = @adwords.get_service(13, 'Campaign')
assert_raise(ArgumentError) do
result = campaign_srv_v13.getAllAdWordsCampaigns('Invalid')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_multiple_params()\n # Parameters for the API call\n number = 123412312\n precision = 1112.34\n string = '\"\"test./;\";12&&3asl\"\";\"qw1&34\"///..//.'\n url = 'http://www.abc.com/test?a=b&c=\"http://lolol.com?param=no&another=lol\"'\n\n # Perform the API call through the SDK function\n ... | [
"0.6939572",
"0.6762344",
"0.665991",
"0.64891",
"0.64854157",
"0.6479549",
"0.6373949",
"0.6323663",
"0.6206268",
"0.6174342",
"0.6121479",
"0.61207783",
"0.61207783",
"0.60705656",
"0.60639006",
"0.60620093",
"0.60296905",
"0.5986795",
"0.5983933",
"0.5973214",
"0.5920521",... | 0.0 | -1 |
Test making an API call with wrong number of parameters | def test_wrong_number
campaign_srv_v13 = @adwords.get_service(13, 'Campaign')
assert_raise(ArgumentError) do
result = campaign_srv_v13.getAllAdWordsCampaigns(0, 0)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_multiple_params()\n # Parameters for the API call\n number = 123412312\n precision = 1112.34\n string = '\"\"test./;\";12&&3asl\"\";\"qw1&34\"///..//.'\n url = 'http://www.abc.com/test?a=b&c=\"http://lolol.com?param=no&another=lol\"'\n\n # Perform the API call through the SDK function\n ... | [
"0.76463646",
"0.6903327",
"0.68100256",
"0.67260236",
"0.67240727",
"0.64276254",
"0.6399185",
"0.63570666",
"0.633338",
"0.62916005",
"0.6281348",
"0.6256242",
"0.622006",
"0.6219791",
"0.6209095",
"0.62066346",
"0.6188173",
"0.61749387",
"0.61346513",
"0.61181647",
"0.6096... | 0.0 | -1 |
Returns whether the route set is empty set = Usher.new set.empty? => true set.add_route('/test') set.empty? => false | def empty?
@routes.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def any_empty_routing?\n self.empty?(self, \"routings\", false)\n end",
"def empty?\n @directions.empty?\n end",
"def empty?\n @path.size == 0\n end",
"def is_empty(value)\n return @mappings.path_exists(value)\n end",
"def empty?\n @path.empty?\n end",
"d... | [
"0.77245116",
"0.71578103",
"0.6782814",
"0.6782176",
"0.67776436",
"0.6416961",
"0.6368235",
"0.63421243",
"0.628984",
"0.6266948",
"0.62570167",
"0.6235251",
"0.6234245",
"0.62236804",
"0.6191292",
"0.6184129",
"0.6171425",
"0.6153248",
"0.61470515",
"0.613644",
"0.6126817"... | 0.78682035 | 0 |
Returns the number of routes | def route_count
@routes.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_routes(n)\n\n\treturn 0\nend",
"def route_count\n\t\treturn 0 if self.gis_region.nil?\n\t\tself.gis_region.geom2.size\n\tend",
"def dir_count(route, dir)\n route.count(dir)\nend",
"def num_routes(x,y)\n unless @num_routes[x][y]\n if (x == size - 1) # right side\n @num_routes[x][y] =... | [
"0.9128313",
"0.78695685",
"0.7632933",
"0.74151695",
"0.7325774",
"0.7049944",
"0.6802291",
"0.6776434",
"0.6746865",
"0.66864806",
"0.6648324",
"0.6604177",
"0.65456146",
"0.6506841",
"0.6489684",
"0.6470239",
"0.6450025",
"0.64429134",
"0.64414656",
"0.64324474",
"0.642135... | 0.91443324 | 0 |
Resets the route set back to its initial state set = Usher.new set.add_route('/test') set.empty? => false set.reset! set.empty? => true | def reset!
@root = Node::Root.new(self, request_methods)
@named_routes = {}
@routes = []
@grapher = Grapher.new(self)
@priority_lookups = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset!\n @route_map = {}\n end",
"def clear_routes\n @routes = Hash.new { |h, k| h[k] = Set.new }\n end",
"def reset!\n @routes = []\n @current = 0\n @prepared = nil\n end",
"def reset!\n @routes = []\n @current_order = 0\n @prepared = ni... | [
"0.68146706",
"0.67656416",
"0.674677",
"0.6682732",
"0.653629",
"0.6370655",
"0.63055867",
"0.5942511",
"0.5910398",
"0.59064037",
"0.5903072",
"0.5878669",
"0.5763619",
"0.56665677",
"0.5643102",
"0.56417143",
"0.5618402",
"0.56175196",
"0.56090105",
"0.56083405",
"0.555499... | 0.6179189 | 7 |
Creates a route set, with options :delimiters: Array of Strings. (default ['/', '.']). Delimiters used in path separation. Array must be single character strings. :valid_regex: String. (default '[09AZaz\$\_\+!\\',]+'). String that can be interpolated into regex to match valid character sequences within path. :request_methods: Array of Symbols. (default [:protocol, :domain, :port, :query_string, :remote_ip, :user_agent, :referer, :method, :subdomains]) Array of methods called against the request object for the purposes of matching route requirements. :generator: +nil+ or Generator instance. (default: +nil+) Take a look at Usher::Util::Generators for examples.. :ignore_trailing_delimiters: +true+ or +false+. (default: +false+) Ignore trailing delimiters in recognizing paths. :consider_destination_keys: +true+ or +false+. (default: +false+) When generating, and using hash destinations, you can have Usher use the destination hash to match incoming params. :allow_identical_variable_names: +true+ or +false+. (default: +true+) When adding routes, allow identical variable names to be used. Example, you create a route with a destination of :controller => 'test', :action => 'action'. If you made a call to generator with :controller => 'test', :action => 'action', it would pick that route to use for generation. | def initialize(options = nil)
self.generator = options && options.delete(:generator)
self.delimiters = Delimiters.new(options && options.delete(:delimiters) || ['/', '.'])
self.valid_regex = options && options.delete(:valid_regex) || '[0-9A-Za-z\$\-_\+!\*\',]+'
self.request_methods = options && options.delete(:request_methods)
self.ignore_trailing_delimiters = options && options.key?(:ignore_trailing_delimiters) ? options.delete(:ignore_trailing_delimiters) : false
self.consider_destination_keys = options && options.key?(:consider_destination_keys) ? options.delete(:consider_destination_keys) : false
self.allow_identical_variable_names = options && options.key?(:allow_identical_variable_names) ? options.delete(:allow_identical_variable_names) : true
reset!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def routes(routes_def)\n RouterDefinition.new(routes_def)\n end",
"def routes(set_name = :main, &block)\n if set_name && block\n @@routes[set_name] = block\n else\n @@routes\n end\n end",
"def route_descriptor_ar(routeset)\n routeset.routes.collect d... | [
"0.6173389",
"0.6114168",
"0.60185903",
"0.5989412",
"0.5876718",
"0.5816294",
"0.580118",
"0.5723463",
"0.5415292",
"0.536239",
"0.52988106",
"0.5293939",
"0.52771807",
"0.5261213",
"0.52106917",
"0.52072614",
"0.5140551",
"0.5135353",
"0.5106259",
"0.5081347",
"0.50746",
... | 0.628552 | 0 |
Adds a route referencable by +name+. See add_route for format +path+ and +options+. set = Usher.new set.add_named_route(:test_route, '/test') | def add_named_route(name, path, options = nil)
add_route(path, options).name(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addName(name)\n @path << name\n end",
"def name(name, route)\n @named_routes[name.to_sym] = route\n route\n end",
"def name(name, route)\n named_routes[name.to_sym] = route\n route\n end",
"def route(name=nil, &block)\n if name\n @named_routes[name] = block\n ... | [
"0.74897796",
"0.7249922",
"0.72200865",
"0.70282614",
"0.69385576",
"0.66109854",
"0.64723265",
"0.6396521",
"0.6395651",
"0.6379861",
"0.6304176",
"0.62843496",
"0.62643236",
"0.62503225",
"0.62466305",
"0.624543",
"0.62211645",
"0.6196049",
"0.61603904",
"0.6154687",
"0.61... | 0.8433324 | 0 |
Deletes a route referencable by +name+. At least the path and conditions have to match the route you intend to delete. set = Usher.new set.delete_named_route(:test_route, '/test') | def delete_named_route(name, path, options = nil)
delete_route(path, options)
@named_routes.delete(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_named_route(name, path, options = nil)\n delete_route(path, options)\n named_routes.delete(name)\n end",
"def delete_route!(name)\n route_added_to_list if @routes.delete(name.to_sym)\n end",
"def delete(name)\n @ctx.delete(@path + name)\n end",
"def delete(name)\n @driver.del... | [
"0.80580574",
"0.75121915",
"0.73021597",
"0.69952196",
"0.6916883",
"0.6821144",
"0.6821144",
"0.6754285",
"0.6713252",
"0.67071253",
"0.668851",
"0.66163737",
"0.6527011",
"0.65067905",
"0.64835054",
"0.64744616",
"0.64416444",
"0.6385316",
"0.6343479",
"0.6331846",
"0.6331... | 0.80146134 | 1 |
Attaches a +route+ to a +name+ set = Usher.new route = set.add_route('/test') set.name(:test, route) | def name(name, route)
@named_routes[name.to_sym] = route
route
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(name, route)\n named_routes[name.to_sym] = route\n route\n end",
"def addName(name)\n @path << name\n end",
"def set(name, &block)\n @sets[name] = RouteSet.new\n @sets[name].eval(&block)\n end",
"def add_named_route(name, path, options = nil)\n add_route(path, options).nam... | [
"0.689",
"0.66027755",
"0.64915144",
"0.6300178",
"0.6155333",
"0.61255485",
"0.60599166",
"0.60500056",
"0.6049554",
"0.60098237",
"0.6000039",
"0.5998021",
"0.5967807",
"0.5891185",
"0.5848427",
"0.5822784",
"0.58102185",
"0.5805468",
"0.5794994",
"0.577393",
"0.5768126",
... | 0.6785414 | 1 |
Deletes a route. At least the path and conditions have to match the route you intend to delete. set = Usher.new set.delete_route('/test') | def delete_route(path, options = nil)
route = get_route(path, options)
@root.delete(route)
@routes = @root.unique_routes
rebuild_grapher!
route
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_route(route={})\n request :delete, '/routes', route\n end",
"def delete_route(path, options = nil)\n route = get_route(path, options)\n root.delete(route)\n routes.replace(root.unique_routes)\n build_grapher!\n route\n end",
"def destroy\n Rails.logger.info('👻 Disraptor: Dest... | [
"0.722952",
"0.6974055",
"0.69299257",
"0.6918893",
"0.6702743",
"0.65922683",
"0.64889765",
"0.6478166",
"0.6478166",
"0.6478166",
"0.6478166",
"0.64651906",
"0.6449319",
"0.6442566",
"0.63969475",
"0.63897747",
"0.63848406",
"0.63428706",
"0.6342246",
"0.6339536",
"0.633953... | 0.6841017 | 4 |
Recognizes a +request+ and returns +nil+ or an Usher::Node::Response, which is a struct containing a Usher::Route::Path and an array of arrays containing the extracted parameters. Request = Struct.new(:path) set = Usher.new route = set.add_route('/test') set.recognize(Request.new('/test')).path.route == route => true | def recognize(request, path = request.path)
response = @root.find(request, path, @splitter.split(path))
if response && !response.path.dynamic?
response.path.cached_response = response
end
response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recognize(request)\n prepare! unless prepared?\n pattern, verb, params = parse_request(request)\n fetch(pattern, verb){|route| [route, params_for(route, pattern, params)] }\n end",
"def match(request)\n path = String.normalize_path(request.path)\n method = request.method\n\n ... | [
"0.76412416",
"0.6667717",
"0.6442717",
"0.62666285",
"0.6254574",
"0.62027586",
"0.6191531",
"0.61140084",
"0.609784",
"0.60694796",
"0.6064565",
"0.6021364",
"0.5986597",
"0.59724027",
"0.59318656",
"0.59141815",
"0.58406705",
"0.58278525",
"0.5820091",
"0.57851744",
"0.576... | 0.6499327 | 2 |
Recognizes a +path+ and returns +nil+ or an Usher::Node::Response, which is a struct containing a Usher::Route::Path and an array of arrays containing the extracted parameters. Convenience method for when recognizing on the request object is unneeded. Request = Struct.new(:path) set = Usher.new route = set.add_route('/test') set.recognize_path('/test').path.route == route => true | def recognize_path(path)
recognize(nil, path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recognize_path(path)\n responses = @router.recognize_path(path)\n [responses[0], responses[1]]\n end",
"def recognize(request, path = request.path)\n response = @root.find(request, path, @splitter.split(path))\n if response && !response.path.dynamic?\n response.path.cached_respo... | [
"0.68062073",
"0.6626052",
"0.6439168",
"0.6436161",
"0.6397388",
"0.6290849",
"0.6228047",
"0.6127796",
"0.60424757",
"0.6039721",
"0.5919966",
"0.5916771",
"0.59082466",
"0.5903886",
"0.58832526",
"0.58461547",
"0.57932717",
"0.5721847",
"0.5664305",
"0.5580889",
"0.5566237... | 0.6287456 | 6 |
Converts the given _value_ | def convert(value)
@path = []
@values = {}
to_data(value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_value(value)\n value\n end",
"def convert(value) value end",
"def cast_value(value) # :doc:\n value\n end",
"def cast_value(value)\n value\n end",
"def cast_value(value) # :api: public\n value\n end",
"def convert_value(value)\n value.to_s\... | [
"0.8674282",
"0.83322555",
"0.78155863",
"0.78007483",
"0.77171224",
"0.7528662",
"0.74517435",
"0.7446101",
"0.7416945",
"0.7294018",
"0.7251425",
"0.705857",
"0.70306057",
"0.7025509",
"0.6957219",
"0.69468015",
"0.6944288",
"0.69203883",
"0.6910677",
"0.6859471",
"0.685630... | 0.7426835 | 9 |
Turns an ASCII8BIT encoded string into a Binary, returns US_ASCII encoded and transforms all other strings to UTF8 with replacements for non Unicode characters. If String cannot be represented as UTF8 | def to_string_or_binary(value)
encoding = value.encoding
if encoding == Encoding::ASCII_8BIT
Puppet::Pops::Types::PBinaryType::Binary.from_binary_string(value).to_s
else
# Transform to UTF-8 (do not assume UTF-8 is correct) with source invalid byte
# sequences and UTF-8 undefined characters replaced by the default unicode uFFFD character
# (black diamond with question mark).
value.encode(Encoding::UTF_8, encoding, :invalid => :replace, :undef => :replace)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end",
"def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encod... | [
"0.73512924",
"0.7304825",
"0.7281212",
"0.7023872",
"0.7015175",
"0.6826562",
"0.6786333",
"0.6725928",
"0.6714755",
"0.66759723",
"0.6671647",
"0.6664323",
"0.66554254",
"0.66553557",
"0.65983486",
"0.6571397",
"0.6571397",
"0.6568449",
"0.65648234",
"0.6563804",
"0.6521275... | 0.6239406 | 46 |
Performs a check for endless recursion before it yields to the given block. The result of yielding is returned. | def process(value, &block)
with_recursive_guard(value, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def candidate_block(block)\n return unless (my_index = block.parent.blocks.find_index block)\n\n next_block = block.parent.blocks[my_index + 1]\n return unless next_block && next_block.context == :pass\n\n next_block\n end",
"def verify_block(&blk)\n begin\n return true if yield\n rescue\... | [
"0.6335335",
"0.6329712",
"0.6263035",
"0.62499243",
"0.6239338",
"0.6110053",
"0.6106968",
"0.60409504",
"0.59770364",
"0.5975318",
"0.5936211",
"0.59337044",
"0.5890505",
"0.58867776",
"0.58683974",
"0.58449095",
"0.5844147",
"0.5838042",
"0.5822498",
"0.5788672",
"0.577736... | 0.5910233 | 12 |
Pushes `key` to the end of the path and yields to the given block. The `key` is popped when the yield returns. | def with(key)
@path.push(key)
value = yield
@path.pop
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(key, &block)\n if @value\n yield(key, @value)\n end\n @children.each do |letter, child|\n child.each(key + letter, &block)\n end\n end",
"def move_to_end(key)\n return unless key? key\n\n @semaphore.synchronize do\n node = @hashed_storage[key... | [
"0.6077554",
"0.5819286",
"0.5738654",
"0.57302827",
"0.5655716",
"0.5618751",
"0.5582121",
"0.55285394",
"0.542438",
"0.5407221",
"0.53915286",
"0.53783625",
"0.53783625",
"0.5366252",
"0.53344464",
"0.53008467",
"0.5283312",
"0.5280599",
"0.5255458",
"0.52537394",
"0.523072... | 0.76736104 | 1 |
A hash key that is non conforming | def unknown_key_to_string(value)
unknown_to_string(value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(key); end",
"def missing_hash_key(key:, source_row:, node_id:)\n # nothing\n end",
"def hash_key(key, options = T.unsafe(nil)); end",
"def hash_key(name); end",
"def unmatched_keys; end",
"def to_key; nil end",
"def missing_keys; end",
"def test_hash_empty_string\n knot = KnotHash... | [
"0.7246227",
"0.71751046",
"0.71594733",
"0.7055737",
"0.68164563",
"0.67730266",
"0.6644895",
"0.664272",
"0.66061026",
"0.6457127",
"0.6457127",
"0.6457127",
"0.6404218",
"0.6378734",
"0.628278",
"0.62733877",
"0.62733877",
"0.6248383",
"0.6237861",
"0.6231901",
"0.6231291"... | 0.0 | -1 |
to avoid getting filtered as junk, set 'from' to match the source 'gmail' as the setup | def notify_question_owner(answer)
@answer = answer
@question = answer.question
@receiver = @question.user
mail(to: @receiver.email,
subject: "You've got a new answer!")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mailfrom(from_addr); end",
"def process_mail_from sender\n if @state.include? :mail_from\n @state -= [:mail_from, :rcpt, :data]\n receive_reset\n end\n\n super\n end",
"def duplicateds_filter\n from_filter = from.split('@').last == ENV['HEALTH_IQ_DOMAIN']\n to_domains = Email.get_... | [
"0.6701214",
"0.6331679",
"0.6201497",
"0.61438113",
"0.6109092",
"0.6006461",
"0.5963956",
"0.5949507",
"0.59347105",
"0.5908399",
"0.5902875",
"0.5877735",
"0.58520573",
"0.5834811",
"0.5765751",
"0.57335496",
"0.5709452",
"0.56915975",
"0.56774044",
"0.5629428",
"0.5618357... | 0.0 | -1 |
Param: rec Record that contains the information used to create the User object | def create(rec)
@name = rec.fields["name"]
@email = rec.fields["email"]
@phone = rec.fields["phone"]
@title = rec.fields["title"]
@business_name = rec.fields["businessname"]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(rec)\n @name = rec.fields[\"name\"]\n @address = rec.fields[\"address\"]\n @city = rec.fields[\"city\"]\n @state = rec.fields[\"state\"]\n @zip = rec.fields[\"zip\"]\n @phone << rec.fields[\"phone\"] if !rec.fiel... | [
"0.64784914",
"0.636496",
"0.6164612",
"0.6148152",
"0.61346614",
"0.6121359",
"0.6117782",
"0.6115626",
"0.60498375",
"0.604938",
"0.6032259",
"0.5991426",
"0.5987979",
"0.5978881",
"0.59480256",
"0.59480256",
"0.59480256",
"0.59360325",
"0.5933626",
"0.591764",
"0.5901992",... | 0.6623978 | 0 |
Prints the User object to STD_OUT | def output
puts "Name: #{@name}"
puts "Email: #{@email}"
puts "Phone: #{@phone}"
puts "Title: #{@title}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user\n user = User.new\n user.read_creddentials\n user.login\n puts user.to_str\n end",
"def echo_user\n return find_user.to_s\n end",
"def user\n puts self.name\n end",
"def print_user\n \"#{sender}(#{identification})\"\n end",
"def output object\n STDOUT.puts \"#... | [
"0.6656704",
"0.64827716",
"0.64276785",
"0.63635886",
"0.63196826",
"0.63188505",
"0.61919785",
"0.6170753",
"0.61352396",
"0.6134601",
"0.6057988",
"0.60229117",
"0.6013842",
"0.5960561",
"0.59550625",
"0.59528226",
"0.5952065",
"0.5932342",
"0.59128594",
"0.58931404",
"0.5... | 0.6182431 | 7 |
Returns a Project object identified by given string The following identifiers are accepted /gdc/md/ /gdc/projects/ | def [](id)
return id if id.respond_to?(:is_project?) && id.is_project?
if id == :all
Project.all
else
if id.to_s !~ /^(\/gdc\/(projects|md)\/)?[a-zA-Z\d]+$/
raise ArgumentError.new('wrong type of argument. Should be either project ID or path')
end
id = id.match(/[a-zA-Z\d]+$/)[0] if id =~ /\//
response = GoodData.get PROJECT_PATH % id
Project.new response
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](id, options = {})\n return id if id.respond_to?(:project?) && id.project?\n if id == :all\n Project.all\n else\n if id.to_s !~ %r{^(\\/gdc\\/(projects|md)\\/)?[a-zA-Z\\d]+$}\n fail(ArgumentError, 'wrong type of argument. Should be either project ID or path')... | [
"0.69064707",
"0.6386621",
"0.63723457",
"0.6326401",
"0.6259494",
"0.6232249",
"0.62284213",
"0.61856896",
"0.6160181",
"0.61549294",
"0.6149304",
"0.61176693",
"0.61118615",
"0.6094538",
"0.59694237",
"0.59694237",
"0.596359",
"0.5962958",
"0.595814",
"0.5940311",
"0.594031... | 0.71459484 | 0 |
Create a project from a given attributes Expected keys: :title (mandatory) :summary :template (default /projects/blank) | def create(attributes, &block)
GoodData.logger.info "Creating project #{attributes[:title]}"
auth_token = attributes[:auth_token] || GoodData.connection.auth_token
json = {:project =>
{
'meta' => {
'title' => attributes[:title],
'summary' => attributes[:summary] || 'No summary'
},
'content' => {
'guidedNavigation' => 1,
'authorizationToken' => auth_token,
'driver' => 'Pg'
}
}
}
json['meta']['projectTemplate'] = attributes[:template] if attributes[:template] && !attributes[:template].empty?
project = Project.new json
project.save
if block
GoodData::with_project(project) do |p|
block.call(p)
end
end
project
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(attributes={})\n raw_response = post_request('projects', project: attributes)\n parse_response(raw_response, :project)\n end",
"def create(attributes, &block)\n GoodData.logger.info \"Creating project #{attributes[:title]}\"\n\n auth_token = attributes[:auth_toke... | [
"0.79765165",
"0.79264057",
"0.74957275",
"0.7232568",
"0.7229171",
"0.7162558",
"0.7096451",
"0.7062794",
"0.6832642",
"0.6807937",
"0.6771487",
"0.6755886",
"0.67540926",
"0.67441654",
"0.6701378",
"0.6692249",
"0.66911817",
"0.6651623",
"0.6636654",
"0.66215837",
"0.660963... | 0.8320541 | 0 |
Words delivered by a standard request should be on the standard wordlist. | def test_standard_words
@words = @tester.words(42)
@words.each {|w| assert @standard_wordlist.include?(w) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def words\n @words ||= (\n word_suggestions = []\n spellcheck = self.response[:spellcheck]\n if spellcheck && spellcheck[:suggestions]\n suggestions = spellcheck[:suggestions]\n unless suggestions.nil?\n # suggestions is an array: \n # (query ter... | [
"0.6524689",
"0.6466518",
"0.63703156",
"0.6300084",
"0.6300084",
"0.62766993",
"0.6185138",
"0.61832225",
"0.61681885",
"0.61582094",
"0.6122092",
"0.61209583",
"0.6113728",
"0.6078967",
"0.60524166",
"0.60320723",
"0.6016189",
"0.59725296",
"0.5935458",
"0.59295404",
"0.591... | 0.63426405 | 3 |
Faker::Hodor.word generates random word from standart wordlist | def test_word
42.times { assert @standard_wordlist.include?(@tester.word) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_word\r\n @word_list.sample\r\n end",
"def random_word\n\t\tLEGAL_WORDS.sample # Gets random element from array\n\tend",
"def random_word\n wordpair = nil\n File.foreach(\"wordlist\").each_with_index do |line, number|\n wordpair = line if rand < 1.0/(number+1)\n ... | [
"0.7940731",
"0.78663415",
"0.7815572",
"0.77769816",
"0.76852214",
"0.7620778",
"0.7531476",
"0.7523507",
"0.7511388",
"0.75084317",
"0.7477042",
"0.7433483",
"0.7384841",
"0.73656744",
"0.7299828",
"0.72935164",
"0.7262926",
"0.72411585",
"0.71484804",
"0.7117654",
"0.71108... | 0.0 | -1 |
GET /groups GET /groups.json | def index
if coordinator? || admin?
@groups = Group.all
elsif professor?
@groups = Group.where(course_id: Course.where(professor_id: current_user.id).all.ids ).all
elsif student?
@groups = User.find(current_user.id).groups.references( :students ).where( students: { user_id: current_user.id })
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetGroups params = {}\n\n params = params.merge(path: 'groups.json')\n APICall(params)\n\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def index\n @groups = Group.all\n\n respond_to do... | [
"0.8286577",
"0.8278107",
"0.7801243",
"0.7762667",
"0.77249485",
"0.765602",
"0.765602",
"0.76541275",
"0.7636101",
"0.7561083",
"0.7547335",
"0.74825233",
"0.74768126",
"0.7467619",
"0.74643844",
"0.73794276",
"0.7367821",
"0.7351049",
"0.7334809",
"0.72987163",
"0.7240665"... | 0.0 | -1 |
GET /groups/1 GET /groups/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetGroup id\n\n APICall(path: \"groups/#{id}.json\")\n\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def show\n group = Group.find(params[:id])\n\n render json: group\n end",
"def GetGroup... | [
"0.7906696",
"0.77682996",
"0.77013576",
"0.7696094",
"0.76500016",
"0.7552326",
"0.7552326",
"0.7536221",
"0.74999285",
"0.74999285",
"0.74628925",
"0.7451343",
"0.7425182",
"0.7417058",
"0.7410386",
"0.7380656",
"0.73710245",
"0.7351068",
"0.7332308",
"0.73154056",
"0.73041... | 0.0 | -1 |
POST /groups POST /groups.json | def create
@group = Group.new(group_params)
respond_to do |format|
if @group.save
@course = Course.find([@group.course_id]).first
@course.cfolders.each do |cfolder|
gfolder = @group.gfolders.create(name: cfolder.name, group_id: @group.id)
cfolder.cposts.each do |cpost|
gpost = gfolder.gposts.create(title: cpost.id, body: cpost.body, link: cpost.link, gfolder_id: gfolder.id)
end
end
format.html { redirect_to [@group], notice: 'group was successfully created.' }
format.json { render :show, status: :created, location: [@group] }
else
format.html { render :new }
format.json { render json: @group.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateGroup params = {}\n \n APICall(path: 'groups.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration], owner: current_user)... | [
"0.77375674",
"0.76210034",
"0.7513403",
"0.7427926",
"0.73867583",
"0.73867583",
"0.72025937",
"0.72016823",
"0.71804947",
"0.71746653",
"0.71588963",
"0.7133053",
"0.7127803",
"0.70649743",
"0.70399696",
"0.7027253",
"0.70115995",
"0.7004535",
"0.7004535",
"0.7004535",
"0.7... | 0.66922486 | 57 |
PATCH/PUT /groups/1 PATCH/PUT /groups/1.json | def update
respond_to do |format|
if @group.update(group_params)
format.html { redirect_to [@group], notice: 'group was successfully updated.' }
format.json { render :show, status: :ok, location: [@group] }
else
format.html { render :edit }
format.json { render json: @group.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n logger.info \"Put parameters: #{params.to_json}\"\n @group = Group.find(params[:id])\n\n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n end",
"def UpdateGroup params = {}\n \n ... | [
"0.746645",
"0.74581313",
"0.7406971",
"0.7302663",
"0.7139866",
"0.712383",
"0.70985276",
"0.70916516",
"0.7056811",
"0.7056811",
"0.7049661",
"0.7049661",
"0.7049661",
"0.70233005",
"0.69945014",
"0.6980164",
"0.6974823",
"0.6974823",
"0.6974823",
"0.6974823",
"0.6967361",
... | 0.68471295 | 43 |
DELETE /groups/1 DELETE /groups/1.json | def destroy
@group.destroy
respond_to do |format|
format.html { redirect_to groups_path, notice: 'group was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteGroup id\n \n APICall(path: \"groups/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n group = Group.find(params[:id])\n group.destroy\n render json: {}\n end",
"def deleteGroup( group_id)\n params = Hash.new\n params['group_id'] = group_id\n return... | [
"0.80822545",
"0.79805106",
"0.79167783",
"0.786261",
"0.786261",
"0.7848193",
"0.7848193",
"0.78414327",
"0.78414327",
"0.78414327",
"0.78414327",
"0.78414327",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7832357",
"0.7808105",
"0.7787947",
"0.7787941... | 0.7587671 | 30 |
Use callbacks to share common setup or constraints between actions. | def set_group
@group = Group.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 group_params
params.require(:group).permit(:code, :name, :description, :startDate, :endDate, :active, :course_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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
attribute :repo, :kind_of => String attribute :desc, :kind_of => String | def initialize(name, run_context=nil)
super
@action = :create
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repo\n @attributes[:repo]\n end",
"def repo\n @attributes[:repo]\n end",
"def repo!\n read_attribute :repo\n end",
"def repo_type\n repo_params[:type].camelize\n end",
"def description_for_repo(repo)\n repo.description\n end",
"def description; attributes[:descript... | [
"0.6487723",
"0.6487723",
"0.6319735",
"0.60137653",
"0.58721685",
"0.5840858",
"0.5744745",
"0.57401156",
"0.5680305",
"0.56634265",
"0.56634265",
"0.56634265",
"0.56634265",
"0.56634265",
"0.56634265",
"0.56634265",
"0.56256896",
"0.5505182",
"0.5469845",
"0.5448089",
"0.54... | 0.0 | -1 |
Creates a temp directory executing the block provided. When done the temp directory and all it's contents are garbage collected. | def with_tmp_dir(&block)
Dir.mktmpdir do |tmp_dir|
Dir.chdir(tmp_dir, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tmp &block\n tmp_dir = \"/tmp_#{rand(10**6)}\"\n if block\n begin\n create_dir tmp_dir\n block.call tmp_dir\n ensure\n delete_dir tmp_dir\n end\n else\n create_dir tmp_dir\n tmp_dir\n end\n end",
"d... | [
"0.7931087",
"0.7892316",
"0.7809086",
"0.75888133",
"0.75423104",
"0.75049275",
"0.7290694",
"0.7224371",
"0.7211073",
"0.7150679",
"0.7150679",
"0.70700467",
"0.67872953",
"0.6755762",
"0.6745536",
"0.67326725",
"0.658913",
"0.65806293",
"0.6444991",
"0.6443658",
"0.641782"... | 0.77865016 | 3 |
Shorter way to return the file_cache_path path | def file_cache_path
Chef::Config[:file_cache_path]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_path\n File.join @path, 'cache.ri'\n end",
"def file_path\n Dir.glob(config.cache).first || File.join(File.dirname(config.cache),\n File.basename(config.cache).gsub(/_.+\\.txt/, '_0.txt'))\n end",
"def cache_file_path\n raise IOError.new 'Writ... | [
"0.83109355",
"0.8232371",
"0.81669927",
"0.81298536",
"0.79135436",
"0.77911973",
"0.77172697",
"0.7621499",
"0.7586903",
"0.7558409",
"0.74889654",
"0.7478345",
"0.7463094",
"0.7463094",
"0.74528354",
"0.73820204",
"0.73746824",
"0.73412174",
"0.7289603",
"0.72692984",
"0.7... | 0.7801757 | 5 |
Requires the external ruby configuration properly set, and the external ruby must have chunky_png installed. Verifies that the number of images specified in each patient's first listed CT Series matches the number of images in the plan creator view. It does this by scrolling down to the bottom of the image slider in the upper right of the screen, then scrolling up (number of images)/2 times and verifies that the green slider line is in the center of the slider. Parameters: mainScreen the initialized MainScreen object. patients_list a list of patient id's to run the test on. | def testImageCount(mainScreen, patient)
details = patient.openPatientDetails
imageCount = Integer(details.patientCTPlans.first.ct.getImageCount.to_s.split[0])
addTargetsScreen = details.clickCreateNewPlan
addTargetsScreen.imageArea.click
for n in (0..(imageCount/2))
nativeType("<PageDown>")
end
Test.vp("image_slider_bottom")
for n in (0..(imageCount/2))
nativeType("<PageUp>")
end
Test.vp("image_slider_centered")
addTargetsScreen.clickLoadImages
mainScreen.deletePatientPlans(patient.id)
patient.closePatientDetails
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_images\n assert_privileges(\"image_scan\")\n showlist = @lastaction == \"show_list\"\n ids = showlist ? find_checked_items : find_current_item(ContainerImage)\n\n if ids.empty?\n add_flash(_(\"No %{model} were selected for Analysis\") % {:model => ui_lookup(:tables => \"container_image\")... | [
"0.5516852",
"0.528437",
"0.50780106",
"0.5036379",
"0.49374926",
"0.49286634",
"0.48828724",
"0.48677945",
"0.4854796",
"0.48489797",
"0.4848273",
"0.48358843",
"0.48331878",
"0.48112273",
"0.48050296",
"0.47805405",
"0.47753248",
"0.47433135",
"0.47402406",
"0.47363594",
"0... | 0.70718765 | 0 |
Get a test platform and the connector prepared the same way Actions Executor does before calling remote_ methods Parameters:: expected_cmds (Array): The expected commands that should be used, and their corresponding mocked code [default: []] expected_stdout (String): Expected stdout after client code execution [default: ''] expected_stderr (String): Expected stderr after client code execution [default: ''] timeout (Integer or nil): Timeout to prepare the connector for [default: nil] additional_config (String): Additional config [default: ''] Proc: Client code to execute testing | def with_test_platform_for_remote_testing(
expected_cmds: [],
expected_stdout: '',
expected_stderr: '',
timeout: nil,
additional_config: ''
)
with_test_platform(
{ nodes: { 'node' => { meta: { local_node: true } } } },
additional_config: additional_config
) do
with_cmd_runner_mocked(expected_cmds) do
test_connector.with_connection_to(['node']) do
stdout = ''
stderr = ''
test_connector.prepare_for('node', timeout, stdout, stderr)
yield
expect(stdout).to eq expected_stdout
expect(stderr).to eq expected_stderr
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test2ActionsDifferentTools\n initTestCase do\n $Context[:SlaveActions] = [\n [ 'DummyTool', 'DummyAction', [] ],\n [ 'DummyTool2', 'DummyAction2', [] ]\n ]\n executeMaster( [ '--process', 'DummyProcess', '--user', 'DummyUser' ],\n ... | [
"0.57075924",
"0.5660894",
"0.56274647",
"0.56139153",
"0.54886806",
"0.5410387",
"0.53937584",
"0.5359281",
"0.5274837",
"0.52334",
"0.5224452",
"0.52018607",
"0.51588786",
"0.51588786",
"0.51505476",
"0.51494753",
"0.51441944",
"0.5126099",
"0.5122958",
"0.5110779",
"0.5110... | 0.77835387 | 0 |
routes through a grid algorithm is n n grid = (n+n)! / (n! n!) | def factorial(n)
(1..n).inject(:*)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid(number)\n v = number + 1 # number of vertices\n coefficient = 1\n routes = 0\n 1.upto(v) do |i|\n routes += coefficient * coefficient\n coefficient = coefficient * (v - i) / i\n end\n routes\n end",
"def routes_for(grid_size)\n choices = grid_size * 2\n \n factorial(choic... | [
"0.78346777",
"0.7730186",
"0.7111078",
"0.6975385",
"0.6880555",
"0.6848078",
"0.68150496",
"0.6786375",
"0.6659367",
"0.6619055",
"0.6596416",
"0.6551779",
"0.6547604",
"0.6544787",
"0.6478903",
"0.6472854",
"0.6442765",
"0.6388119",
"0.63827896",
"0.63758314",
"0.6328579",... | 0.0 | -1 |
Wraps block execution in a threadsafe transaction | def transaction(force_sync = false, &block)
# Ruby 1.9.3 does not support @mutex.owned?
if @mutex.respond_to?(:owned?)
force_sync = false if @mutex.locked? && @mutex.owned?
else
# If we allowed this in Ruby 1.9.3, it might possibly cause recursive
# locking within the same thread.
force_sync = false
end
if !force_sync && (@in_transaction || options[:without_mutex])
block.call self
else
@mutex.synchronize do
@in_transaction = true
result = block.call
@in_transaction = false
result
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction(&block); end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n block.call\n end",
"def transaction(&block)\n @@semaphore.synchronize{\n block.call\n }\n end",
"def transaction(&blo... | [
"0.81861055",
"0.7986313",
"0.7986313",
"0.79684037",
"0.79389924",
"0.79327935",
"0.76466423",
"0.7643628",
"0.7617146",
"0.7603295",
"0.75987655",
"0.75863326",
"0.75703305",
"0.7544261",
"0.7530601",
"0.7510887",
"0.74541277",
"0.7409394",
"0.7383946",
"0.73258847",
"0.722... | 0.71486896 | 25 |
Iterate over rate tuples (iso_from, iso_to, rate) | def each_rate(&block)
enum = Enumerator.new do |yielder|
index.each do |key, rate|
iso_from, iso_to = key.split(Memory::INDEX_KEY_SEPARATOR)
iso_to, date = iso_to.split(INDEX_DATE_SEPARATOR)
date = Date.parse(date) if date
yielder.yield iso_from, iso_to, rate, date
end
end
block_given? ? enum.each(&block) : enum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_rate(&block)\n enum = Enumerator.new do |yielder|\n index.each do |key, rate|\n iso_from, iso_to = key.split(Memory::INDEX_KEY_SEPARATOR)\n iso_to, date = iso_to.split(INDEX_DATE_SEPARATOR)\n date = Date.parse(date)\n yielder.yield iso_from, iso_to, rate, da... | [
"0.7307535",
"0.7078939",
"0.70136684",
"0.6612889",
"0.65302247",
"0.64697313",
"0.64697313",
"0.6246917",
"0.6179447",
"0.6159945",
"0.60973346",
"0.6074648",
"0.59517896",
"0.5914766",
"0.58972335",
"0.58740634",
"0.58712214",
"0.5859631",
"0.5818374",
"0.58006155",
"0.577... | 0.7314147 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_season
id = season_params[:id]
@season = ::Season.find(id)
authorize_action_for @season
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.61642385",
"0.60448",
"0.5945487",
"0.5915654",
"0.58890367",
"0.58330417",
"0.5776098",
"0.5703048",
"0.5703048",
"0.5654613",
"0.5620029",
"0.5423114",
"0.540998",
"0.540998",
"0.540998",
"0.5393666",
"0.53783023",
"0.53568405",
"0.53391176",
"0.5339061",
"0.53310865",
... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def season_params
params.permit(:id, :format, :game_id, :filters => [:season_id, :game_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
vim: set ft=ruby : Collect information on the current environment. | def is_arm?
!RUBY_PLATFORM.index("arm64e").nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describe\n f = file!\n puts \"Current environment: #{f.basename}\"\n puts '*' * 70\n File.open(f).each do |line|\n puts \" #{line}\"\n end\n puts '*' * 70\n end",
"def current_snippets\n self[Vim.evaluate('&filetype')]\n end",
"def vim_mappings\n... | [
"0.57602584",
"0.57485044",
"0.56361926",
"0.5537937",
"0.5481683",
"0.54284275",
"0.53625244",
"0.5293003",
"0.5199667",
"0.5152458",
"0.5130711",
"0.5076142",
"0.5076142",
"0.5076142",
"0.5076142",
"0.5076142",
"0.5076142",
"0.5076142",
"0.5076142",
"0.5076142",
"0.5076142"... | 0.0 | -1 |
countdown method counts from the input until 0 then returns "HAPPY NEW YEAR" | def countdown(number)
while (number > 0) do
puts "#{number} SECOND(S)!";
number -= 1;
end
"HAPPY NEW YEAR!";
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countdown(number)\n while number > 0 \n puts \"#{number} SECOND(S)!\"\n number -=1 \nend \n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(seconds)\n \n while seconds > 0\n puts \"#{seconds} SECOND(S)!\"\n seconds -= 1\nend\n\n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(seconds)\... | [
"0.71488285",
"0.71472794",
"0.70734787",
"0.6999145",
"0.6951594",
"0.68420744",
"0.6746673",
"0.64589894",
"0.6377381",
"0.6210141",
"0.6141085",
"0.6076348",
"0.59539354",
"0.59454054",
"0.592971",
"0.5914958",
"0.58678067",
"0.5850118",
"0.58368474",
"0.58212143",
"0.5807... | 0.6723959 | 7 |
countdown_with_sleep counts down from the input until 0 with one second between each number then returns "HAPPY NEW YEAR!" | def countdown_with_sleep(number)
while (number > 0) do
puts "#{number} SECONDS!";
sleep(1);
number -= 1;
end
"HAPPY NEW YEAR!";
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countdown_with_sleep(number)\n while number > 0 \n puts \"#{number} SECOND(S)!\"\n number -=1 \n sleep(1)\nend \n return \"HAPPY NEW YEAR!\"\nend",
"def countdown(seconds)\n \n while seconds > 0\n puts \"#{seconds} SECOND(S)!\"\n seconds -= 1\nend\n\n return \"HAPPY NEW YEAR!\"\nend",
... | [
"0.7721473",
"0.75069875",
"0.7361712",
"0.7345085",
"0.7338911",
"0.72278714",
"0.7217903",
"0.71556526",
"0.7117162",
"0.7081368",
"0.70344704",
"0.6346931",
"0.62693435",
"0.6090731",
"0.60815775",
"0.59896326",
"0.59727556",
"0.5956795",
"0.5912938",
"0.5912938",
"0.58628... | 0.75267667 | 1 |
computer outputs a goodbye message and exits User can input QUIT | def exit_now
puts "Goodbye!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def goodbye \n\t\tsystem(\"clear\")\n puts \"#######################\"\n puts \"# #\"\n puts \"# Thank you for #\"\n puts \"# #\"\n puts \"# visiting the #\"\n puts \"# #\"\n puts \"# Bank o... | [
"0.83994734",
"0.8038734",
"0.78140306",
"0.7785633",
"0.776647",
"0.771283",
"0.76884073",
"0.7662466",
"0.7640936",
"0.76288533",
"0.76167595",
"0.76119596",
"0.7594113",
"0.7557072",
"0.7485585",
"0.74769866",
"0.7360527",
"0.7349727",
"0.7339779",
"0.7330237",
"0.73100424... | 0.7577382 | 13 |
computer outputs a random answer | def response
puts @answers[rand(@answers.length - 1)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magicEightball \n\tanswered = \n\t[\n\t\"Most def.\", \"No doubt\", \"Hell yes\", \n\t\"maybe...\", \"It's a possibility.\", \"It could happen.\",\n\t\"never eva eva!\", \"NO!\", \"Not in a thousand years.\"\n\t] \n\n\tputs \"Please ask me a question.\"\n\tquestion = gets.chomp\n\tputs \"So your question is #{... | [
"0.74815136",
"0.7373462",
"0.7097148",
"0.7005486",
"0.6944577",
"0.6904244",
"0.6835461",
"0.6783539",
"0.6773514",
"0.6718125",
"0.67123944",
"0.6661673",
"0.66401434",
"0.6635283",
"0.6609652",
"0.65901846",
"0.6579855",
"0.65679985",
"0.6513367",
"0.65114605",
"0.6506033... | 0.79304516 | 0 |
Support for random text (crypto), text (lorem) name (name), numbers(number) time(time) TODO Make sure this can't be abused | def generate
length = 500
if params[:length]
length = params[:length].to_f
if length > 10000 then length = 10000 end
if length < 10 then length = 10 end
end
type = params[:type] ? params[:type] : 'L'
words = ''
case type
when 'Lat'
#35 is the shortest value for sentences which consistently gives at least the correct character count
words = Faker::Lorem.sentences(length/35).join(' ')
when 'Ran'
while words.length < length do
words += Faker::Internet.password(5, 20).to_s + " "
end
when 'Nam'
while words.length < length do
words += Faker::Name.name + " "
end
when 'Num'
while words.length < length do
words += (rand(10 ** rand(1..15))).to_s + " "
puts 'Length ' + words.length.to_s
end
when 'Dat'
while words.length < length do
words += Faker::Date.between(10.years.ago, 10.years.from_now).to_s + " "
end
else
render json:{text: "Invalid type"}
end
render json:{text: words[0..length-1]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Name(name)\n\tname = SecureRandom.alphanumeric\nend",
"def name\n\t\t\tnew_name_letters = (0...2).map { ('a'..'z').to_a[rand(26)] }.join.upcase\n\t\t\tnew_name_numbers = (0...3).map { (0..9).to_a[rand(10)] }.join\n\t\t\tnew_name = [new_name_letters, new_name_numbers].join\n\t\t\t3.times do\n\t\t\t\tputs new_... | [
"0.6978526",
"0.66871446",
"0.6546029",
"0.64490205",
"0.6357321",
"0.6279435",
"0.61826074",
"0.61506695",
"0.61423534",
"0.6135853",
"0.6135853",
"0.6103708",
"0.60490596",
"0.60307",
"0.5991049",
"0.5963693",
"0.59433824",
"0.59326327",
"0.5890262",
"0.58888495",
"0.588290... | 0.0 | -1 |
This isn't used when this class is used as middleware; it returns an object you can use to unzip/inflate a streaming response. | def stream_response_handler(response)
if gzip_disabled?
Chef::Log.trace "disable_gzip is set. \
Not using #{response[CONTENT_ENCODING]} \
and initializing noop stream deflator."
NoopInflater.new
else
case response[CONTENT_ENCODING]
when GZIP
Chef::Log.trace "Initializing gzip stream deflator"
GzipInflater.new
when DEFLATE
Chef::Log.trace "Initializing deflate stream deflator"
DeflateInflater.new
else
Chef::Log.trace "content_encoding = '#{response[CONTENT_ENCODING]}' \
initializing noop stream deflator."
NoopInflater.new
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decompress_response(response)\n if response['content-encoding'] == 'gzip'\n Zlib::GzipReader.new(StringIO.new(response.body)).read\n else\n response.body\n end\n end",
"def uncompress_body(response)\n case response['content-encoding']\n when 'gzip'\n ... | [
"0.62069994",
"0.6196943",
"0.6073694",
"0.6021913",
"0.6001664",
"0.58465827",
"0.58441365",
"0.5839941",
"0.5832177",
"0.57711464",
"0.57529396",
"0.5715084",
"0.57049716",
"0.5660072",
"0.5659145",
"0.55891997",
"0.55725473",
"0.5535643",
"0.5504961",
"0.54879737",
"0.5442... | 0.61478025 | 2 |
gzip is disabled using the disable_gzip => true option in the constructor. When gzip is disabled, no 'AcceptEncoding' header will be set, and the response will not be decompressed, no matter what the ContentEncoding header of the response is. The intended use case for this is to work around situations where you request +file.tar.gz+, but the server responds with a content type of tar and a content encoding of gzip, tricking the client into decompressing the response so you end up with a tar archive (no gzip) named file.tar.gz | def gzip_disabled?
@disable_gzip
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gzip_enabled; end",
"def gzip_enabled; end",
"def enable_gzip; @opts[:enable_gzip]; end",
"def configure_compression(options, env)\n return unless (env[:method] == :get) &&\n !options[:head].key?('accept-encoding')\n\n options[:head]['accept-encoding'] = 'gzip, compressed'\n ... | [
"0.7169218",
"0.7169218",
"0.7154997",
"0.71119887",
"0.70148116",
"0.69969654",
"0.68856066",
"0.6868401",
"0.6598267",
"0.6579759",
"0.65263283",
"0.64493287",
"0.6429264",
"0.6385595",
"0.63205934",
"0.63078165",
"0.62943333",
"0.62804765",
"0.62446356",
"0.61921436",
"0.6... | 0.6247678 | 18 |
TODO: Update to find by name | def show
@user = User.find_by_id(params[:id])
if @user
render json: @user.to_json(include: [:games]), status: 200
else
render json: {error: "User not found"}, status: 404
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(name); end",
"def find_by_name(name)\n end",
"def find_object(name); end",
"def find_by_name(id)\n end",
"def find(name)\n list[name]\n end",
"def find_by_name(name)\n find_by('name', name)\n end",
"def find_by_name(name)\n binding.pry\n self.name\n e... | [
"0.847342",
"0.8243723",
"0.7747381",
"0.7671443",
"0.76392317",
"0.76362455",
"0.74345875",
"0.73596376",
"0.72186595",
"0.7130588",
"0.70377344",
"0.70205086",
"0.70128757",
"0.6915294",
"0.6878661",
"0.68782634",
"0.68640167",
"0.68350303",
"0.68322515",
"0.6794673",
"0.67... | 0.0 | -1 |
GET /users GET /users.json | def index
respond_to do |format|
format.html { render 'shared/index'}
format.js { render @filter.errors.empty? ? 'shared/index' : 'filter' }
format.json { render json: @users }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n para... | [
"0.82096034",
"0.78738815",
"0.78587097",
"0.78113025",
"0.7805043",
"0.7677112",
"0.7657447",
"0.7631558",
"0.75814617",
"0.7529342",
"0.7488569",
"0.7447786",
"0.7438884",
"0.7436842",
"0.7425483",
"0.7397733",
"0.7397733",
"0.7397733",
"0.7397733",
"0.7375005",
"0.73723507... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
@expanded << @user.id if params.has_key?(:expanded)
respond_to do |format|
format.html { render template: 'shared/show' }
format.js { render 'user' }
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.8105615",
"0.7702007",
"0.7700872",
"0.7625178",
"0.75821507",
"0.748073",
"0.7460195",
"0.7447183",
"0.73047197",
"0.72984964",
"0.72879744",
"0.72762334",
"0.72337043",
"0.7231386",
"0.7231386",
"0.7231386",
"0.7231386",
"0.7231386",
"0.7231386",
"0.7231386",
"0.72231823... | 0.0 | -1 |
GET /users/new GET /users/new.json | def new
@edited << 'new'
@expanded << 'new'
respond_to do |format|
format.html { render template: 'shared/new' }
format.js { render 'user' }
format.json { render json: @user }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end",
"def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n ... | [
"0.8287397",
"0.8169197",
"0.8155916",
"0.80483407",
"0.8022376",
"0.8021751",
"0.8009459",
"0.7950995",
"0.793078",
"0.793078",
"0.7873476",
"0.7873476",
"0.7873476",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0.7860956",
"0... | 0.0 | -1 |
POST /users POST /users.json | def create
respond_to do |format|
if @user.save
flash[:notice] = 'User was successfully created.'
@changed << @user.id
format.html { redirect_to users_path }
format.js { render 'shared/index'; flash.discard }
format.json { render json: @user, status: :created, location: @user }
else
@edited << 'new'
@expanded << 'new'
format.html { render action: 'new', template: 'shared/new' }
format.js { render 'user' }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69... | 0.0 | -1 |
PUT /users/1 PUT /users/1.json | def update
respond_to do |format|
if params[:user][:password].present? ? @user.update_attributes(params[:user]) : @user.update_without_password(params[:user])
flash[:notice] = 'User was successfully updated.'
@changed << @user.id
sign_in @user, bypass: true if current_user.id == @user.id
format.html { redirect_to :back }
format.js { render 'shared/index'; flash.discard }
format.json { head :no_content }
else
@edited << @user.id
@expanded << @user.id
format.html { render action: 'edit', template: 'shared/edit' }
format.js { render 'user' }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.7411068",
"0.73911154",
"0.7303527",
"0.7254355",
"0.7202468",
"0.7074142",
"0.7052407",
"0.7026916",
"0.7006102",
"0.6987369",
"0.69825596",
"0.6941196",
"0.6939539",
"0.6921509",
"0.69073355",
"0.68771124",
"0.6848875",
"0.68336725",
"0.682009",
"0.6800596",
"0.6768416",... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user.destroy
flash[:notice] = 'User was successfully deleted.'
respond_to do |format|
format.html { redirect_to users_path }
format.js { render 'shared/index'; flash.discard }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.78748846",
"0.7751809",
"0.771363",
"0.76100063",
"0.74723196",
"0.7407186",
"0.7407186",
"0.7369039",
"0.73459107",
"0.7340053",
"0.7327986",
"0.7309642",
"0.73096335",
"0.7306661",
"0.729729",
"0.7291124",
"0.72909784",
"0.72883743",
"0.72836834",
"0.7250263",
"0.7250263... | 0.0 | -1 |
Start the CLI APP | def run
self.clear
greet
username_input = @@prompt.ask('Tell me your username: ',required: true)
username_input = username_input.downcase
user = User.find_create_user(username_input)
main_menu(user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli(*args)\n CLI.start(args.flatten, :env => self)\n end",
"def run(*args)\n cli.run(*args)\n end",
"def run_app(command, arguments)\nend",
"def start_apps\n check_apps\n remove_sockets\n _start_apps(ARGV[1])\nend",
"def cli(*args)\n CLI.new(args.flatten, self).execute\n ... | [
"0.77273387",
"0.6815517",
"0.6814008",
"0.6649283",
"0.66074157",
"0.66074157",
"0.65290785",
"0.65142363",
"0.6436675",
"0.6430883",
"0.64190125",
"0.63545036",
"0.6325583",
"0.6319504",
"0.6278703",
"0.6276687",
"0.62746614",
"0.62724805",
"0.626161",
"0.6261555",
"0.62523... | 0.0 | -1 |
Main Menu > My Plants/ Add plant/ Delete Account/ Quit | def main_menu(user)
user = user
self.clear
Ascii.image
menu = ["See all my plants","Add new plant","Delete my account","Quit"]
menu_selection = @@prompt.select("What would you like to do?",menu)
case menu_selection
when "See all my plants"
my_plant(user)
when "Add new plant"
add_plant(user)
when "Delete my account"
answer = @@prompt.yes?("Are you sure?")
answer == true ? user.destroy : self.main_menu(user)
when "Quit"
index = 0
# binding.pry
color = ["#7FFF00","#6B8E23","#008000","#2F4F4F","#00008B"]
5.times do
self.clear
# binding.pry
puts Paint[Ascii.goodbye, color[index]]
index += 1
sleep(0.7)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_plant(user)\n self.clear\n Ascii.image\n show_my_plants_table(user)\n\n if user.all_plants.blank?\n menu = [\"Add new plant\",\"back\"]\n menu_selection = @@prompt.select(\"Looks like you don't have any plants\",menu)\n \n case menu_sel... | [
"0.6751568",
"0.6537724",
"0.6391536",
"0.63269734",
"0.63002735",
"0.62952495",
"0.6234165",
"0.6233536",
"0.6229752",
"0.62283295",
"0.622606",
"0.61256635",
"0.6114035",
"0.61128914",
"0.6064483",
"0.6051742",
"0.60321015",
"0.60295427",
"0.60212374",
"0.60082334",
"0.6004... | 0.619633 | 11 |
SubMenu: My Plants (displays all the plant user owns, leads to update them) | def my_plant(user)
self.clear
Ascii.image
show_my_plants_table(user)
if user.all_plants.blank?
menu = ["Add new plant","back"]
menu_selection = @@prompt.select("Looks like you don't have any plants",menu)
case menu_selection
when "Add new plant"
add_plant(user)
when "back"
main_menu(user)
end
else
menu = ["Water plant","Add new plant","Change nickname","Delete plants","back"]
menu_selection = @@prompt.select("Select from below",menu)
nicknames = user.my_plants.nicknames
case menu_selection
when "Water plant"
nickname = @@prompt.select("Which plant did you water?", nicknames)
selected_plant = user.find_plant_nickname(nickname)
update_plant(selected_plant,user)
when "Add new plant"
add_plant(user)
when "Change nickname"
nickname = @@prompt.select("Which plant should we change?", nicknames)
nickname = nickname.downcase
selected_plant = user.find_plant_nickname(nickname)
new_name = @@prompt.ask("Enter #{nickname.capitalize}'s new name:") do |q|
q.required true
q.modify :strip, :down
end
selected_plant.update_nickname(new_name)
self.my_plant(user)
when "Delete plants"
nicknames = @@prompt.multi_select("Which plant should we remove?", nicknames)
plants = user.find_plant_nicknames(nicknames)
MyPlant.delete_plants(plants)
self.my_plant(user)
when "back"
main_menu(user)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @user = current_user\n @individual_plants = @user.individual_plants\n end",
"def edit\n @plant = current_user.plants.find(params[:id])\n end",
"def display_and_add_superpower\n user.reload\n system 'clear'\n superhero_choosen?\n puts \"~~~~~~~~~~~~~~~~~~~~~~~~~... | [
"0.66391087",
"0.63995194",
"0.63061184",
"0.62683696",
"0.6085186",
"0.60755575",
"0.60091776",
"0.5921759",
"0.58340126",
"0.58221686",
"0.5821498",
"0.5793115",
"0.57924014",
"0.57864106",
"0.5776887",
"0.5774189",
"0.5742293",
"0.57403743",
"0.57376224",
"0.57331145",
"0.... | 0.718235 | 0 |
Submenu of My Plants: Updates watering status and cycle | def update_plant(selected_plant, user, menu_sel=nil)
menu = ["update watering status","change watering cycle","back"]
menu_selection = @@prompt.select("options",menu)
case menu_selection
when "update watering status"
# binding.pry
date = get_date(selected_plant)
date = date.to_date
# binding.pry
selected_plant.update_waterdate_status(date)
my_plant(user)
when "change watering cycle"
days = @@prompt.ask("Change #{selected_plant.nickname}'s watering cycle to every 'x' days?") do |q|
q.required true
q.validate /\d{1,2}/
q.messages[:valid?] = "only numbers please"
q.convert :int
end
selected_plant.change_watercycle(days)
my_plant(user)
when "back"
my_plant(user)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weekend_menu\n active = 2\n if @alive == true\n weekend_header\n else\n offline_header\n end\n @selected_activity = []\n chosen_weekend_activity = @prompt.select(\"\\nSelect an activity to find out more\\n\".blue, @processed_weekend.push({name: \"--Back t... | [
"0.56492525",
"0.55581325",
"0.55581325",
"0.546507",
"0.54128844",
"0.53489983",
"0.5297542",
"0.52926326",
"0.51805574",
"0.5171466",
"0.51487595",
"0.510427",
"0.5088987",
"0.5073828",
"0.50499886",
"0.5037754",
"0.5031379",
"0.5027802",
"0.5026479",
"0.50146717",
"0.50119... | 0.5854725 | 0 |
Table Related functions Default table setup and settings | def create_display_table(title, headings, rows)
Terminal::Table.new :title=> title, :headings => headings, :rows => rows
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_table?; @on_table; end",
"def relation_table(model)\n validate_model(model)\n model.arel_table\n end",
"def table\n end",
"def model_relationships; end",
"def table\n model_class.arel_table\n end",
"def table; end",
"def table; end",
"def table; end",
"def table; end",
... | [
"0.67852074",
"0.6773678",
"0.66779566",
"0.6663823",
"0.65934086",
"0.65716887",
"0.65716887",
"0.65716887",
"0.65716887",
"0.653173",
"0.62910384",
"0.61510324",
"0.6146045",
"0.61311144",
"0.6121523",
"0.6109174",
"0.61041987",
"0.60883117",
"0.6076729",
"0.6060441",
"0.60... | 0.0 | -1 |
Get data from curr_user's MyPlant | def my_plant_list(my_plant, index)
my_plant.show_each_plant_spec(index)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merchant_defined_data1\n @user\n end",
"def user()\n return @data[\"access\"][\"user\"]\n end",
"def user_data\n User.user_data login\n end",
"def fluidfeatures_current_user(verbose=false)\n if current_user\n if verbose\n {\n :id => @current_user[:id],\... | [
"0.6964385",
"0.672438",
"0.67074496",
"0.6697762",
"0.6561238",
"0.64898205",
"0.6423017",
"0.6403587",
"0.6297467",
"0.6245127",
"0.62389785",
"0.62352616",
"0.623171",
"0.6229909",
"0.6221856",
"0.6203654",
"0.61796635",
"0.61796635",
"0.6176825",
"0.6170758",
"0.6165586",... | 0.0 | -1 |
Start the CI process | def initiate_check_run
logger.debug "initiate_check_run"
token = get_installation_token
installation_client = Octokit::Client.new(bearer_token: token)
# This method is called in response to GitHub acknowledging our request to create a check run.
# We'll first update the check run to "in progress"
# Then we'll run our CI process
# Then we'll update the check run to "completed" with the CI results.
# Octokit doesn't yet support the Checks API, but it does provide generic HTTP methods we can use!
# https://developer.github.com/v3/checks/runs/#update-a-check-run
# notice the verb! PATCH!
result = installation_client.patch(@payload['check_run']['url'], {
accept: 'application/vnd.github.antiope-preview+json', # This header is necessary for beta access to Checks API
name: 'Maximum lines of code',
status: :in_progress
})
# ***** DO IT! *****
# This is where we would kick off our CI process. Ideally this would be performed async, so we could
# return immediately. But for now we'll do a simulated CI process syncronously, and update the check run right here..
pull_requests = result['pull_requests']
pr = pull_requests[0]
logger.debug "Pull Request #{pr}"
repo = pr['base']['repo']['id']
pr_number = pr['number']
logger.debug "Repo: #{repo} PR: #{pr_number}"
pull = installation_client.pull_request(repo, pr_number)
logger.debug "====================="
logger.debug pull
logger.debug "====================="
additions = pull['additions']
# Was this a success?
result = additions < 400 ? :success : :failure # could also be :failure
logger.debug "RESULT IS: #{result}"
opts = {
accept: 'application/vnd.github.antiope-preview+json', # This header is necessary for beta access to Checks API
name: 'Maximum lines of code',
status: :completed,
conclusion: result,
completed_at: Time.now.utc.iso8601,
head_branch: @payload['check_suite'].nil? ? @payload['check_run']['check_suite']['head_branch'] : @payload['check_suite']['head_branch'],
head_sha: @payload['check_suite'].nil? ? @payload['check_run']['head_sha'] : @payload['check_suite']['head_sha']
}
# If there were more details from a real CI, such as warning details, line numbers, and so forth, we could add them to
# the opts object here, like this:
# if result == :failure
# output = {
# title: 'Awesome CI Warnings',
# summary: 'There were problems with the submitted code',
# annotations: []
# }
# ci_output.warnings.each do |warning|
# # we need to take the local relative path, and extract the repo-relative path
# filename = warning.filename
# annotation = {
# path: filename,
# blob_href: "#{@payload['repository']['blobs_url']}/#{filename}".sub('{/sha}', "/#{sha}"),
# start_line: warning.line_number,
# end_line: warning.line_number,
# annotation_level: :warning, #or :failure
# message: warning.message
# }
# output[:annotations].push annotation
# end
#
# opts[:output] = output
# end
# Now, mark the check run as complete! And if there are warnings, share them
result = installation_client.patch(@payload['check_run']['url'], opts)
result.attrs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n if Process.respond_to?(:fork)\n fork {\n runner = Test::Runner.new(config)\n success = runner.run\n exit -1 unless success\n }\n Process.wait\n else\n runner = Test::Runner.new(config)\n success = runner.run\n ... | [
"0.6741387",
"0.67236555",
"0.66981065",
"0.66414267",
"0.65253544",
"0.64918107",
"0.64126253",
"0.6407517",
"0.63445956",
"0.63445956",
"0.6296701",
"0.62851834",
"0.62472486",
"0.6229032",
"0.62050086",
"0.6065035",
"0.6039351",
"0.60312814",
"0.6024052",
"0.60195404",
"0.... | 0.59398264 | 26 |
This is code for checking the security signature that is included in all legitimate webhooks calls from GitHub | def check_signature!
request.body.rewind
payload_raw = request.body.read # We need the raw text of the body to check the webhook signature
begin
@payload = JSON.parse payload_raw
rescue
@payload = {}
end
# Check X-Hub-Signature to confirm that this webhook was generated by GitHub, and not a malicious third party.
# The way this works is: We have registered with GitHub a secret, and we have stored it locally in WEBHOOK_SECRET.
# GitHub will cryptographically sign the request payload with this secret. We will do the same, and if the results
# match, then we know that the request is from GitHub (or, at least, from someone who knows the secret!)
# If they don't match, this request is an attack, and we should reject it.
# The signature comes in with header x-hub-signature, and looks like "sha1=123456"
# We should take the left hand side as the signature method, and the right hand side as the
# HMAC digest (the signature) itself.
their_signature_header = request.env['HTTP_X_HUB_SIGNATURE'] || 'sha1='
method, their_digest = their_signature_header.split('=')
our_digest = OpenSSL::HMAC.hexdigest(method, WEBHOOK_SECRET, payload_raw)
halt 401 unless their_digest == our_digest
@payload
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_webhook_signature\n their_signature_header = request.env['HTTP_X_HUB_SIGNATURE'] || 'sha1='\n method, their_digest = their_signature_header.split('=')\n our_digest = OpenSSL::HMAC.hexdigest(method, ENV['GITHUB_WEBHOOK_SECRET'], @payload_raw)\n halt 401 unless their_digest == our_digest\n\n ... | [
"0.78756094",
"0.7562292",
"0.7535734",
"0.7450367",
"0.728433",
"0.7157956",
"0.7107514",
"0.691613",
"0.6915232",
"0.6915232",
"0.69136673",
"0.68784016",
"0.68702984",
"0.6852542",
"0.6790892",
"0.677699",
"0.6765348",
"0.6728212",
"0.6702442",
"0.6701262",
"0.6664349",
... | 0.80079395 | 0 |
The greeting method, which puts out the greeting and asks the user if he/she wants the help text to be displayed. This method then also catches the user's first and last name and stores them in global variables that can be used in other methods: | def greeting
puts "\n Welcome to my GPA calculator"
puts $divide
puts "\nDo you want instructions. (Y/N)"
ins = gets.chomp.upcase
instructions if ins[0] == "Y"
print "Please enter your first name: \n"
$first = gets.chomp
print "Please enter your last name: \n"
$last = gets.chomp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greet_user\n greetings = %w[\n bonjour hola hallo sveiki namaste shalom salaam szia halo ciao\n ]\n first_name = message.from.nil? ? '' : ', ' + message.from.first_name\n send_message \"#{greetings.sample.capitalize}#{first_name}!\\n Enter /help for options.\"\n end",
"def greeting\n\t\t#ma... | [
"0.7373178",
"0.7230997",
"0.71039367",
"0.7075479",
"0.70417506",
"0.68937063",
"0.68688416",
"0.68488944",
"0.6729309",
"0.6720074",
"0.6714121",
"0.67054087",
"0.67021114",
"0.6654588",
"0.66253406",
"0.6625156",
"0.66234696",
"0.6620871",
"0.66183424",
"0.6614821",
"0.661... | 0.678831 | 8 |
This is the main function of this script which deals with the math part. This function creates three arrays, one with the grade names and two that will be filled with the user's input. The each.with_index loop goes through the grade_names array and and stores each grade_value as given by the user to then automatically calculate the grade_weight by taking the user input and dividing it by 4 minus the index. TIPP: if you want to see the array that is created in the back ground to calculate the GPA, just add the letter p on line 72, before the "grade_weight << grades (4 i)" part, and run the code. Instead of storing the grade_values and grade_weight in a global variable, they are directly passed on to the results method/function, which is explained later: | def gpaCalc
grade_names = [ "As", "Bs", "Cs", "Ds", "Fs" ]
grade_values = []
grade_weight = []
grade_names.each.with_index do |grade, i|
puts "How many #{grade} do you have?"
grades = gets.chomp.to_i
grade_values << grades
p grade_weight << grades * (4 - i) # Delete the p for cleaner output
end
results(grade_values, grade_weight)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results(values, weight)\n gpa = weight.reduce(:+).to_f / values.reduce(:+)\n\n puts $divide\n puts \"\\n#{$first.capitalize} #{$last.capitalize}, your GPA is #{gpa.to_s} \\n\\n\"\nend",
"def submissions(rogue_score=5)\r\n return @submissions if @submissions\r\n #puts \"enter new submissions\"\r\n @subm... | [
"0.6381442",
"0.6327302",
"0.6201882",
"0.6173251",
"0.61414623",
"0.6004618",
"0.59852386",
"0.5967969",
"0.59666485",
"0.5926954",
"0.5885489",
"0.5878476",
"0.5878153",
"0.58772457",
"0.5870702",
"0.585499",
"0.585499",
"0.58522254",
"0.584948",
"0.5799741",
"0.5794232",
... | 0.86029416 | 0 |
The results funtion/method accepts two params to be passed into it, the values and the weight. We pass those two params in the form of two arrays that were populated in the gpaCalc method. The results function then adds all the values in each of these arrays with the reduce(:+) method and weight by values to get the GPA score, which this function then also puts out in the console. | def results(values, weight)
gpa = weight.reduce(:+).to_f / values.reduce(:+)
puts $divide
puts "\n#{$first.capitalize} #{$last.capitalize}, your GPA is #{gpa.to_s} \n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gpaCalc\n grade_names = [ \"As\", \"Bs\", \"Cs\", \"Ds\", \"Fs\" ]\n grade_values = []\n grade_weight = []\n\n grade_names.each.with_index do |grade, i|\n puts \"How many #{grade} do you have?\"\n\n grades = gets.chomp.to_i\n grade_values << grades\n\np grade_weight << grades * (4 - i) # Delete... | [
"0.66883653",
"0.64568895",
"0.62420374",
"0.6152576",
"0.6060873",
"0.6033002",
"0.59385425",
"0.58551586",
"0.5819626",
"0.57804847",
"0.57132566",
"0.5687486",
"0.56853914",
"0.56816906",
"0.5670918",
"0.56294656",
"0.5607272",
"0.5603623",
"0.55951136",
"0.559346",
"0.555... | 0.8035033 | 0 |
Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. The current interval's fund fee settlement is based on the previous interval's fund rate. For example, at 16:00, the settlement is based on the fund rate generated at 8:00. The fund rate generated at 16:00 will be used at 0:00 on the next day. | def funding_my_last_fee(symbol, opts = {})
data, _status_code, _headers = funding_my_last_fee_with_http_info(symbol, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def taxi_fare_rate_calculation(distance_travelled, booking_fee)\n \n #basic flag down fee is $2.8\n flag_down_fee = 2.8\n hour = Time.new.hour\n \n # if booking fee exists, how much is it depends on what time of day it is.\n if booking_fee\n case hour\n when 7..9\n flag_down_fee = 3.5 + 2.8\n... | [
"0.53475904",
"0.52813005",
"0.50503904",
"0.5038823",
"0.5026845",
"0.5006853",
"0.49682716",
"0.4967414",
"0.49436656",
"0.49374932",
"0.493214",
"0.49309614",
"0.49272868",
"0.49217722",
"0.49077505",
"0.48494336",
"0.4831889",
"0.48249784",
"0.48186266",
"0.47994438",
"0.... | 0.0 | -1 |
Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC. The current interval&39;s fund fee settlement is based on the previous interval&39;s fund rate. For example, at 16:00, the settlement is based on the fund rate generated at 8:00. The fund rate generated at 16:00 will be used at 0:00 on the next day. | def funding_my_last_fee_with_http_info(symbol, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FundingApi.funding_my_last_fee ...'
end
# verify the required parameter 'symbol' is set
if @api_client.config.client_side_validation && symbol.nil?
fail ArgumentError, "Missing the required parameter 'symbol' when calling FundingApi.funding_my_last_fee"
end
# resource path
local_var_path = '/open-api/funding/prev-funding'
# query parameters
query_params = {}
query_params[:'symbol'] = symbol
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['apiKey', 'apiSignature', 'timestamp']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Object')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FundingApi#funding_my_last_fee\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def taxi_fare_rate_calculation(distance_travelled, booking_fee)\n \n #basic flag down fee is $2.8\n flag_down_fee = 2.8\n hour = Time.new.hour\n \n # if booking fee exists, how much is it depends on what time of day it is.\n if booking_fee\n case hour\n when 7..9\n flag_down_fee = 3.5 + 2.8\n... | [
"0.5363024",
"0.5324295",
"0.50666726",
"0.5047185",
"0.5009544",
"0.5002554",
"0.4990289",
"0.49642298",
"0.49432397",
"0.49179548",
"0.48961326",
"0.48853946",
"0.48624384",
"0.4859106",
"0.48539683",
"0.48423514",
"0.48352283",
"0.48192048",
"0.48159432",
"0.48027763",
"0.... | 0.0 | -1 |
Get predicted funding rate and funding fee. | def funding_predicted(symbol, opts = {})
data, _status_code, _headers = funding_predicted_with_http_info(symbol, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prediction_payment\n group.ffs_payment * 3\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def insurance_fee\n (COMMISSION_RATE * INSURANCE_PART_RATE * price).round\n end",
"def current_payment_fee\n payment.try(:current_fee) || 0\n end",
... | [
"0.67622805",
"0.62667966",
"0.62575006",
"0.6152372",
"0.60778505",
"0.60715383",
"0.6052416",
"0.59756553",
"0.59466106",
"0.59177184",
"0.5904894",
"0.5903469",
"0.5891141",
"0.58889294",
"0.5871505",
"0.5859186",
"0.5859186",
"0.5857031",
"0.5839301",
"0.5830787",
"0.5813... | 0.6386168 | 1 |
Get predicted funding rate and funding fee. | def funding_predicted_with_http_info(symbol, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FundingApi.funding_predicted ...'
end
# verify the required parameter 'symbol' is set
if @api_client.config.client_side_validation && symbol.nil?
fail ArgumentError, "Missing the required parameter 'symbol' when calling FundingApi.funding_predicted"
end
# resource path
local_var_path = '/open-api/funding/predicted-funding'
# query parameters
query_params = {}
query_params[:'symbol'] = symbol
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['apiKey', 'apiSignature', 'timestamp']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Object')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FundingApi#funding_predicted\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prediction_payment\n group.ffs_payment * 3\n end",
"def funding_predicted(symbol, opts = {})\n data, _status_code, _headers = funding_predicted_with_http_info(symbol, opts)\n data\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def insuran... | [
"0.6762033",
"0.6383966",
"0.6268788",
"0.62587726",
"0.61538905",
"0.607904",
"0.6073687",
"0.60536796",
"0.59449583",
"0.59181404",
"0.5905154",
"0.5904594",
"0.5892654",
"0.5890342",
"0.5873296",
"0.58592653",
"0.58592653",
"0.5858539",
"0.58402145",
"0.5831636",
"0.581484... | 0.59758025 | 8 |
Get predicted funding rate and funding fee. | def funding_prev_rate(symbol, opts = {})
data, _status_code, _headers = funding_prev_rate_with_http_info(symbol, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prediction_payment\n group.ffs_payment * 3\n end",
"def funding_predicted(symbol, opts = {})\n data, _status_code, _headers = funding_predicted_with_http_info(symbol, opts)\n data\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def insuran... | [
"0.67629045",
"0.63880044",
"0.6267118",
"0.6256459",
"0.6151601",
"0.6077087",
"0.6071554",
"0.6051101",
"0.59767985",
"0.59504694",
"0.59170324",
"0.5904252",
"0.59017867",
"0.589083",
"0.5886655",
"0.58691955",
"0.5858982",
"0.5858982",
"0.58566767",
"0.5836947",
"0.582975... | 0.0 | -1 |
Get predicted funding rate and funding fee. | def funding_prev_rate_with_http_info(symbol, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FundingApi.funding_prev_rate ...'
end
# verify the required parameter 'symbol' is set
if @api_client.config.client_side_validation && symbol.nil?
fail ArgumentError, "Missing the required parameter 'symbol' when calling FundingApi.funding_prev_rate"
end
# resource path
local_var_path = '/open-api/funding/prev-funding-rate'
# query parameters
query_params = {}
query_params[:'symbol'] = symbol
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded'])
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['apiKey', 'apiSignature', 'timestamp']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Object')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FundingApi#funding_prev_rate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prediction_payment\n group.ffs_payment * 3\n end",
"def funding_predicted(symbol, opts = {})\n data, _status_code, _headers = funding_predicted_with_http_info(symbol, opts)\n data\n end",
"def withdrawal_rate\n (youngest_person_retirement_age - 15.0) / 1000.0\n end",
"def insuran... | [
"0.67622805",
"0.6386168",
"0.62667966",
"0.62575006",
"0.6152372",
"0.60778505",
"0.60715383",
"0.6052416",
"0.59756553",
"0.59466106",
"0.59177184",
"0.5904894",
"0.5903469",
"0.5891141",
"0.58889294",
"0.5871505",
"0.5859186",
"0.5859186",
"0.5857031",
"0.5839301",
"0.5830... | 0.5324413 | 97 |
Floyd's Tortoise and Hare Algorithm | def has_cycle?(head)
return false if head.nil?
slow = head
fast = head
while !slow.nil? && !fast.nil? && !fast.next.nil?
slow = slow.next
fast = fast.next.next
return true if slow == fast
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on w... | [
"0.6189521",
"0.5951525",
"0.5845413",
"0.58144605",
"0.5790098",
"0.56892514",
"0.5681485",
"0.56636095",
"0.56566566",
"0.56392086",
"0.56383556",
"0.56220335",
"0.56000644",
"0.5590749",
"0.5568565",
"0.5552818",
"0.55518246",
"0.55286294",
"0.55210614",
"0.55009615",
"0.5... | 0.0 | -1 |
extract correct url for video from youtube/vimeo urls, etc. | def modify_media_file_url_if_from_video_site
if media_file_url.present? && !ImageSrcUrl.new(media_file_url).is_image?
video_src_url = VideoSrcUrl.new(media_file_url)
self.media_file_url = video_src_url.value if video_src_url.is_video?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_video_url(url)\n url_video = case url.downcase\n when /^http:\\/\\/(www\\.)?youtube\\.com/\n parse_youtube(url)\n # when /tudou/\n # parse_tudou(url)\n when /^http:\\/\\/(www\\.)?dailymotion\\.com/\n parse_... | [
"0.8062439",
"0.73240936",
"0.72275186",
"0.7098051",
"0.7059062",
"0.7008015",
"0.694598",
"0.6942462",
"0.6907102",
"0.6893247",
"0.6888893",
"0.68782246",
"0.6860064",
"0.6833341",
"0.6831441",
"0.6825366",
"0.6788177",
"0.67860657",
"0.67409045",
"0.67364216",
"0.673089",... | 0.5911026 | 83 |
only show suggestions of friends who (1) Are not me (2) I have not already sent friends requests to (3) I am not already friends with (4) Have not sent me friend requests to me | def suggestions
@users = User.all.to_ary.select { |user| user != current_user &&
!current_user.to_fr_ids.include?(user.id) &&
!current_user.friends.include?(user) &&
!current_user.from_fr_ids.include?(user.id)
}
@requests = current_user.received_friend_requests
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggested_friends(page = 1, per_page = 15)\n calc_suggested_friends\n my_suggested_friends.where.not(id: rejected_friend_suggestions.pluck(:user_id) + [User.bot_id]).page(page).per(per_page)\n end",
"def friends_suggestion(friends_of_friends = false)\n\t\t#sql query for the requested and accepted fri... | [
"0.777259",
"0.7549769",
"0.7505452",
"0.70077306",
"0.6970852",
"0.6833681",
"0.68043673",
"0.6801827",
"0.66919184",
"0.66479844",
"0.66263455",
"0.6580975",
"0.65471125",
"0.6527248",
"0.6523972",
"0.6523972",
"0.65179205",
"0.6478295",
"0.6474806",
"0.6462955",
"0.6452549... | 0.77802724 | 0 |
kind of a 'create' method | def accept
@from = params[:from_id]
@to = current_user.id
@friend_request = FriendRequest.where(to_id: @to, from_id: @from)
Notification.where(user_id: @to, from_id: @from).destroy_all
@f = Friendship.new(user_id: @to, friend_id: @from)
if @f.save
User.find(@from).friends.push(User.find(@to))
@friend_request.destroy_all
flash[:notice] = "Friendship accepted"
redirect_to friends_find_path
else
flash[:alert] = "Couldnt accept friendship"
redirect_to friends_find_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n end",
"def create; end",
"def create; end",
"def create; end",
"def create; end",
"def create\n \t\n end",
"def create\n \n end",
"def create\r\n end",
"def create!\n end",
"def create\n end",
"def create\n end",
"def create\n end",
"def cre... | [
"0.8894404",
"0.87912536",
"0.87912536",
"0.87912536",
"0.87912536",
"0.8684313",
"0.85148054",
"0.8496605",
"0.84765834",
"0.8456744",
"0.84121317",
"0.84121317",
"0.84121317",
"0.8363522",
"0.8261579",
"0.82585484",
"0.82585484",
"0.82554317",
"0.8241999",
"0.81888473",
"0.... | 0.0 | -1 |
Apply coupons was one of the hardest methods I had to put together so far. The below code works to pass the tests, but I think I am not sure that it is worthy for a real application. The code below is also very very smelly. | def apply_coupons(cart, coupon_array)
# code here
##coupon count block to account for multiple coupons, and increment them
coupon_update_array = []
coupon_update_hash = {}
coupon_count = Hash.new(0)
coupon_array.each do |coupon_element|
coupon_element.each do |key, value|
if key == :item
coupon_count[value] += 1
end
end
end
coupon_array.each do |coupon_element|
coupon_element.each do |item, avocado|
coupon_count.each do |name, count|
if avocado == name
coupon_update_hash[coupon_element] = count
end
end
end
end
coupon_update_hash.each do |coupon_info, count|
coupon_info[:total_count] = 0
coupon_info.merge!(:count => count)
end
coupon_update_hash.each do |coupon_info, count|
coupon_info.each do |key, value|
if key == :num
coupon_info[:total_count] = count * value
end
end
end
#The code below takes care of multiple coupons for not having enough items to take advantage of the sale
# If this is the case, the coupon_update_hash information is adjusted to delete coupons that
# will not be eligible for use, since the client may not have enough items in their cart.
cart.each do |item, item_info|
coupon_update_hash.each do |coupon_info, count|
coupon_info.each do |coupon_key, coupon_value|
if coupon_key == :item && item == coupon_value
item_info.each do |item_key, item_value|
if item_key == :count
coupon_info.each do |coupon_key1, coupon_value1|
if coupon_key1 == :total_count && coupon_value1 > item_value
coupon_info.each do |coupon_key2, coupon_value2|
if coupon_key2 == :num
coupon_info[:total_count] = coupon_value1 - coupon_value2
end
if coupon_key2 == :count
coupon_info[:count] = coupon_value2 - 1
end
end
end
end
end
end
end
end
end
end
## Block below will return the cart in the event that no coupons are given,
#or no coupons apply
coupon_names = []
coupon_array.each do |coupons|
coupons.each do |food_key, food_data|
if food_key == :item
coupon_names.push(food_data)
end
end
end
coupons_that_apply_to_cart = []
cart.each do |food_name, food_data|
if coupon_names.include?(food_name)
coupons_that_apply_to_cart.push(food_name)
end
end
if coupons_that_apply_to_cart.length == 0
return cart
end
##This block will return the cart if they are not enough items in the cart
## for the coupon to apply. This method does not account for multiple coupons
## it looks at one coupon at a time. The method above accounts for the multiple coupons.
## This method counts the items in the cart
food_item_count = []
cart.each do |food_name, food_info|
coupons_that_apply_to_cart.each do |coupon_name|
if food_name == coupon_name
food_info.each do |key, value|
if key == :count
food_item_count.push({food_name => value})
end
end
end
end
end
# This method counts the items that you need to apply the coupon
food_coupon_count = []
coupon_update_hash.each do |coupon_data, count|
coupon_data.each do |key, value|
coupons_that_apply_to_cart.each do |coupon_name|
if key == :item && value == coupon_name
coupon_data.each do |key, value|
if key == :num
food_coupon_count.push({coupon_name => value})
end
end
end
end
end
end
#This method compares the items in the cart, with the items needed to apply the coupon
# If the item's count in the cart is greater than or equal to the required coupon count
# The item gets pushed to the qualifying_coupons_based_on_count array.
qualifying_coupons_based_on_count = []
food_coupon_count.each do |coupon_info|
food_item_count.each do |food_info|
coupon_info.each do |coupon_name, count_coupon|
food_info.each do |food_name, count_food|
if food_name == coupon_name && count_food >= count_coupon
qualifying_coupons_based_on_count.push({coupon_name => count_coupon})
end
end
end
end
end
#If the qualifying_coupons_based_on_count array's length is zero, we return the cart since
#although the customer may have items that are on sale, they have not bought the appropriate
# quantities to qualify for the special price
if qualifying_coupons_based_on_count.length == 0
return cart
end
## This block of code checks to see if there is any discrepancy between the qualifying_coupons_based_on_count
# and the coupons_that_apply_to_cart array. If there are any mismatches, we edit the
# coupons_that_apply_to_cart array, to make sure we do not include them in the final cart
qualifying_coupons_based_on_count.each do |qualifying_coupon|
qualifying_coupon.each do |coupon_name, count|
if !coupons_that_apply_to_cart.include?(coupon_name)
coupons_that_apply_to_cart.delete(coupon_name)
end
end
end
# This block adds the updated items with the correct format, and
# skeleton
coupon_item = ""
coupons_that_apply_to_cart.each do |coupon_name|
coupon_item = coupon_name + " W/COUPON"
cart[coupon_item] = {:price => 0, :clearance => 0, :count => 0}
end
coupon_array.each do |coupon_element|
coupon_element.each do |coupon_key, coupon_data|
coupons_that_apply_to_cart.each do |coupon_name|
if coupon_key == :item && coupon_data == coupon_name
coupon_element.each do |coupon_key, coupon_data|
if coupon_key == :cost
cart[coupon_name + " W/COUPON"][:price] = coupon_data
end
end
end
end
end
end
## This block will take care of the clearance
cart.each do |avocado, avocado_info|
avocado_info.each do |price, price_info|
coupons_that_apply_to_cart.each do |coupon_name|
if price == :clearance && avocado == coupon_name
cart[coupon_name + " W/COUPON"][:clearance] = price_info
end
end
end
end
## This block will take care of updating the counts for the couponed items
coupon_update_hash.each do |coupon_info, count|
coupon_info.each do |item, item_name|
coupons_that_apply_to_cart.each do |coupon_name|
if item == :item && item_name == coupon_name
coupon_info.each do |item1, item_name1|
if item1 == :count
cart[coupon_name + " W/COUPON"][:count] = item_name1
end
end
end
end
end
end
## update counts for remainder items that were left as a result of not fitting coupon_info
## parameters
cart.each do |food_name, food_info|
food_info.each do |food_key, food_value|
coupon_update_hash.each do |coupon_info, count|
coupon_info.each do |coupon_key, coupon_value|
if coupon_key == :item && coupon_value == food_name
coupon_info.each do |coupon_key, coupon_value|
if food_key == :count && coupon_key == :total_count
cart[food_name][:count] = food_value - coupon_value
end
end
end
end
end
end
end
return cart
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_coupons(cart, coupons)\n # Consult README for inputs and outputs\n #\n # REMEMBER: This method **should** update cart\nend",
"def apply_coupon\n if self.behavior == 'coupon'\n item = self.item\n \n # coitem is the OrderItem to which the coupon acts upon\n coitem = self.order.o... | [
"0.6711722",
"0.65336114",
"0.64883125",
"0.64358735",
"0.64039373",
"0.63943654",
"0.6312426",
"0.62917286",
"0.62565315",
"0.6237865",
"0.6096495",
"0.6075164",
"0.59763944",
"0.59592295",
"0.59417874",
"0.58999354",
"0.5867882",
"0.584894",
"0.58232665",
"0.57929236",
"0.5... | 0.56241685 | 23 |
Create a new Setster session. | def initialize(email, api_key)
url = "account/authenticate?email=#{email}&token=#{api_key}"
data = post(url)
@session_token = data['session_token']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @taster_session = TasterSession.new\n end",
"def create!(*args)\n session = new(*args)\n session.save!\n session\n end",
"def new\n @session = Session.new('')\n end",
"def create!(*args)\n session = new(*args)\n session.save!\n end"... | [
"0.698237",
"0.674164",
"0.66962284",
"0.6692959",
"0.6692959",
"0.6587983",
"0.6475659",
"0.63855",
"0.6383459",
"0.63735026",
"0.62717724",
"0.6210586",
"0.61639035",
"0.6126583",
"0.6125208",
"0.6082582",
"0.60528016",
"0.605051",
"0.60440165",
"0.59690356",
"0.5965097",
... | 0.0 | -1 |
Retrieve the location list. | def locations(query = {})
get('location', query)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n @locations = Location.find(:all, :order => \"name\")\n end",
"def get_locations\n response = execute_get(\"/reference/location\")\n Location.from_array(decode(response))\n end",
"def list_locations\n query = create_query(:Location, :all, by: default_sort_order)\n show_selected_locat... | [
"0.8088435",
"0.8063761",
"0.7894627",
"0.7883718",
"0.7860664",
"0.7834197",
"0.7834197",
"0.7814795",
"0.7709001",
"0.7469202",
"0.7445011",
"0.73352545",
"0.7281301",
"0.72498626",
"0.7240624",
"0.72277564",
"0.71814245",
"0.71805596",
"0.71449625",
"0.7128681",
"0.7117248... | 0.71308625 | 19 |
Retrieve a list of service options. | def services(query = {})
get('service', query)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(options = {})\n out = xml_run build_command('services', options.merge(:get => XML_COMMANDS_GET))\n convert_output(out.fetch(:stream, {}).fetch(:service_list, {}).fetch(:service, []), :service)\n end",
"def list_services\n @services\n end",
"def get_all(options = {})\n custom_p... | [
"0.70958865",
"0.6904981",
"0.68968123",
"0.6643289",
"0.6595358",
"0.65291005",
"0.65022993",
"0.6499549",
"0.64987874",
"0.64456844",
"0.64454806",
"0.6417207",
"0.63762146",
"0.63383496",
"0.6321498",
"0.63028353",
"0.6278468",
"0.62671185",
"0.6257707",
"0.61954904",
"0.6... | 0.61268693 | 26 |
GET /photos/1 GET /photos/1.json | def show
@photo = Photo.find(params[:id])
redirect_to @photo.collection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/photos/#{params[:id]}.json?token=#{ENV['API_KEY']}\"\n\t response = RestClient.get(url)\n\t @photo = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/photos.json?token=#{ENV['API_KEY']}\"\n response = RestClient.get(url)\n @ph... | [
"0.84863234",
"0.7777037",
"0.7566973",
"0.7507857",
"0.7482775",
"0.742858",
"0.73779064",
"0.73423064",
"0.73400605",
"0.73322564",
"0.73005956",
"0.7280408",
"0.725952",
"0.7259299",
"0.7214884",
"0.719664",
"0.719664",
"0.719664",
"0.719664",
"0.719664",
"0.719664",
"0.... | 0.0 | -1 |
GET /photos/new GET /photos/new.json | def new
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @photo = @allbum.photos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end",
"def new\n @photo = Photo.new\n\n render json: @photo\n end",
"def new\n @photo = Photo.new\n\n respond_to do |format|\n format... | [
"0.80598736",
"0.79233235",
"0.78761166",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.7876034",
"0.77998",
"0.77998",
"0.7632694",
"0.74142075",
"0.73975354",
"0.739603",
"... | 0.0 | -1 |
POST /photos POST /photos.json | def create
unless session[:codes].include?(SUPER_SECRET_CODE) || session[:codes].include?(@collection.code)
redirect_to root_path
else
@photo = Photo.new(params[:photo])
respond_to do |format|
if @photo.save
format.html { redirect_to @photo, notice: 'Photo was successfully created.' }
format.json { render json: @photo, status: :created, location: @photo }
else
format.html { render action: "new" }
format.json { render json: @photo.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @photos = Photo.new(photos_params)\n if @photos.save\n render json: { id: @photos.id, url: @photos.gallery.url,\n size: @photos.gallery_file_size }\n else\n render json: { id: nil }\n end\n end",
"def create\n @photo = Photo.new(photo_params)\n\n if @... | [
"0.7361035",
"0.7185209",
"0.6947464",
"0.6922178",
"0.6897456",
"0.6851186",
"0.66842484",
"0.6675465",
"0.66148436",
"0.66095084",
"0.6601552",
"0.65587986",
"0.6548897",
"0.6548897",
"0.6548897",
"0.6548897",
"0.6548897",
"0.6544014",
"0.64769965",
"0.6464411",
"0.6464411"... | 0.0 | -1 |
PUT /photos/1 PUT /photos/1.json | def update
@photo = Photo.find(params[:id])
redirect_to @photo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n puts y params['photo'].keys\n params['photo'].keys.each do |photo_id|\n photo = Photo.find(photo_id)\n photo.update_attributes(params['photo'][photo_id])\n end\n respond_to do |format|\n if true \n format.html { redirect_to photos_path, notice: 'Photos were successful... | [
"0.6875062",
"0.6766776",
"0.65346485",
"0.6527134",
"0.65198237",
"0.6435718",
"0.642703",
"0.64248544",
"0.64049363",
"0.64049363",
"0.64049363",
"0.64049363",
"0.63948375",
"0.63938975",
"0.6384001",
"0.63810134",
"0.6370729",
"0.6370729",
"0.6370729",
"0.6370729",
"0.6370... | 0.62175745 | 40 |
DELETE /photos/1 DELETE /photos/1.json | def destroy
unless session[:codes].include?(SUPER_SECRET_CODE) || session[:codes].include?(@collection.code)
redirect_to root_path
else
@photo = Photo.find(params[:id])
@photo.destroy
respond_to do |format|
format.html { redirect_to photos_url }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.ht... | [
"0.7743858",
"0.7743858",
"0.7743858",
"0.7743858",
"0.7743858",
"0.7743858",
"0.77150726",
"0.77150726",
"0.77150726",
"0.77150726",
"0.77150726",
"0.77036476",
"0.7683938",
"0.7666516",
"0.7664305",
"0.7664305",
"0.7651935",
"0.7651935",
"0.76373297",
"0.75912905",
"0.75888... | 0.0 | -1 |
gets a response in json from the api | def get_response(resource, query_string)
config = YAML.load(File.read("giantbomb.yaml"))
api_key = config['api_key']
api_base = config['api_base']
return HTTParty.get("#{api_base}/#{resource}/?api_key=#{api_key}&format=json&#{query_string}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_response response\n JSON.parse response.body\n end",
"def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end",
"def get_api_json\n response_string = RestClient.get('http://www.swapi.co/api/people/')\n JSON.parse(response_string)... | [
"0.7651301",
"0.7629855",
"0.7553191",
"0.75461495",
"0.7519141",
"0.74964505",
"0.73747593",
"0.7276129",
"0.7276129",
"0.72741646",
"0.72351605",
"0.72013855",
"0.72013855",
"0.72013855",
"0.72013855",
"0.71426094",
"0.7039237",
"0.70265603",
"0.70265603",
"0.70265603",
"0.... | 0.63908374 | 99 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.