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 |
|---|---|---|---|---|---|---|
URL slug creation logic The steps are roughly as follows 1. If the record hasn't passed its validations, exit immediately 2. If the source_column is empty, exit immediately (no error is thrown this should be checked with your own validation) 3. If the slug is already set we have nothing to do, otherwise a. Strip out punctuation b. Replace unusable characters with dashes c. Clean up any doubled up dashes d. Check if the slug is unique and, if not, append a number until it is e. Save the URL slug | def create_slug
return if self.errors.size > 0
return if self[source_column].blank?
if self[slug_column].to_s.empty?
proposed_slug = self[source_column].to_slug
suffix = ""
existing = true
acts_as_slugable_class.transaction do
while existing != nil
# look for records with the same url slug and increment a counter until we find a unique slug
existing = acts_as_slugable_class.
where(slug_column => proposed_slug + suffix).
where(slug_scope_condition).first
if existing
suffix = suffix.empty? ? "-0" : suffix.succ
end
end
end # end of transaction
self[slug_column] = proposed_slug + suffix
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_slug\n source = self[model.slug_options[:gen_from]] || \"\"\n slug = ActiveSupport::Inflector.transliterate(source) # remove accents\n .gsub(/&/,'and') # switch out &\n .gsub(/@/,'at') # switch out @\n .parameterize('-') # cleanup remain... | [
"0.7065004",
"0.6764861",
"0.66352636",
"0.65899235",
"0.65244013",
"0.65244013",
"0.6512822",
"0.6461349",
"0.63912755",
"0.6388084",
"0.6388084",
"0.6371469",
"0.6365984",
"0.6351019",
"0.63445914",
"0.6339431",
"0.6322686",
"0.63140494",
"0.62559336",
"0.62559336",
"0.6248... | 0.86341465 | 0 |
TODO Add account number validation. | def identifier
num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_account_number\n @acct_num\n end",
"def account_number\n return @account_number\n end",
"def generate_account_number\n return if account_number.present?\n self.account_number = generate_account_number_token\n end",
"def account_number\n @account_number ? @account_number.to_s... | [
"0.73531663",
"0.73414975",
"0.7076806",
"0.7033394",
"0.67323345",
"0.6714883",
"0.6531907",
"0.6504244",
"0.64889216",
"0.64050996",
"0.6332469",
"0.6317587",
"0.6310256",
"0.62917554",
"0.62917554",
"0.6289948",
"0.6265814",
"0.6264364",
"0.6264364",
"0.6264338",
"0.624460... | 0.0 | -1 |
This is the constructor for the Paper class. All dimension parameters to this method are in twips. ==== Parameters name:: The name for the paper object. width:: The width of the paper in portrait mode. height:: The height of the paper in portrait mode. | def initialize(name, width, height)
@name = name
@width = width
@height = height
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @paper = Paper::A4\n @left_margin = DEFAULT_LEFT_MARGIN\n @right_margin = DEFAULT_RIGHT_MARGIN\n @top_margin = DEFAULT_TOP_MARGIN\n @bottom_margin = DEFAULT_BOTTOM_MARGIN\n @gutter = nil\n @orientation = PORTRAIT\n ... | [
"0.6314327",
"0.6223362",
"0.61128145",
"0.6091368",
"0.6081066",
"0.600612",
"0.600612",
"0.5984649",
"0.5946034",
"0.5912513",
"0.5911243",
"0.59032494",
"0.5886491",
"0.58456147",
"0.58222026",
"0.57983303",
"0.56411725",
"0.5640577",
"0.56243366",
"0.562127",
"0.560729",
... | 0.7407958 | 0 |
Convenience method for zooming the screen. Places two fingers at the edges of the screen and brings them together. | def zoom(percentage = 200, auto_perform = true, driver = $driver)
::Appium::Core::MultiTouch.zoom percentage: percentage, auto_perform: auto_perform, driver: driver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zoom(percentage = 200, auto_perform = true)\n fail ArgumentError(\"Can't zoom to smaller then screen size.\") if percentage < 100\n\n p = 100 / Float(percentage)\n i = 1 - p\n\n top = TouchAction.new\n top.swipe start_x: i, start_y: i, end_x: 1, end_y: 1, duration: 1\n\n ... | [
"0.60257125",
"0.59447056",
"0.59120256",
"0.58333623",
"0.57661",
"0.5733687",
"0.5733687",
"0.5653727",
"0.564632",
"0.5472498",
"0.54480577",
"0.54408664",
"0.5410994",
"0.5393193",
"0.5371043",
"0.5365548",
"0.5279539",
"0.52739227",
"0.52502626",
"0.5191827",
"0.5104939"... | 0.5557064 | 9 |
def create if params[:password] == Rails.application.secrets.secret_password find_by(password_digest: params[:password]) session[:valid_user] = true redirect_to '/secret' else | def show
@user = User.find_by(id: session[:user_id])
@outfit = @user.outfits
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_password\n if params[:password] != params[:verify_pw]\n session[:message] = \"Passwords don't match. Please try again.\"\n redirect \"/register\"\n end\nend",
"def verify_password\n # dev_puts current_user.login\n # dev_puts params[:login]\n if current_user && current_user.login.eql?(... | [
"0.730715",
"0.70501834",
"0.70470154",
"0.6925958",
"0.6919008",
"0.68930167",
"0.6882618",
"0.6860816",
"0.6858191",
"0.68566334",
"0.6837599",
"0.6823904",
"0.6815354",
"0.6805224",
"0.67698723",
"0.67693883",
"0.67681164",
"0.67454183",
"0.67284405",
"0.67134815",
"0.6699... | 0.0 | -1 |
assert("RustRegexpcasefold?", '15.2.15.7.6') do assert_false RustRegexp.new("(https?://[^/]+)[azAZ09./]+", RustRegexp::MULTILINE).casefold? assert_true RustRegexp.new("(https?://[^/]+)[azAZ09./]+", RustRegexp::IGNORECASE | RustRegexp::EXTENDED).casefold? assert_true RustRegexp.new("(https?://[^/]+)[azAZ09./]+", RustRegexp::MULTILINE | RustRegexp::IGNORECASE).casefold? assert_false RustRegexp.new("(https?://[^/]+)[azAZ09./]+").casefold? assert_true RustRegexp.new("(https?://[^/]+)[azAZ09./]+", true).casefold? end | def test_match
reg = RustRegexp.new("(https?://[^/]+)[-a-zA-Z0-9./]+")
assert_false reg.match("http://masamitsu-murase.12345/hoge.html").nil?
assert_nil reg.match("http:///masamitsu-murase.12345/hoge.html")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_match_case_sensitive_binary_no_match\r\n\t\t#content with exact match\r\n\t\tcontent = \"first line.\\nthis string doesnt contains a match on: My\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.unescaped_string = \"M|79|Mat|63 68|123\" #equals MyMatch123\r\n\t\tsnort_rule_cont... | [
"0.6137553",
"0.60912406",
"0.60233766",
"0.6018899",
"0.5960956",
"0.58500963",
"0.5798894",
"0.57920045",
"0.5780985",
"0.57408726",
"0.5732851",
"0.5724394",
"0.5691623",
"0.5656116",
"0.56359",
"0.557114",
"0.5563196",
"0.55368555",
"0.5534483",
"0.54810584",
"0.5474184",... | 0.6180982 | 0 |
if RustRegexp.const_defined? :ASCII_RANGE assert('RustRegexpoptions (no options)') do assert_equal RustRegexp::ASCII_RANGE | RustRegexp::POSIX_BRACKET_ALL_RANGE | RustRegexp::WORD_BOUND_ALL_RANGE, OnigRegexp.new(".").options end assert('RustRegexpoptions (multiline)') do assert_equal RustRegexp::MULTILINE | RustRegexp::ASCII_RANGE | RustRegexp::POSIX_BRACKET_ALL_RANGE | OnigRegexp::WORD_BOUND_ALL_RANGE, OnigRegexp.new(".", OnigRegexp::MULTILINE).options end end | def test_extended_patterns_no_flags
[
[ ".*", "abcd\nefg", "abcd" ],
[ "^a.", "abcd\naefg", "ab" ],
[ "^a.", "bacd\naefg", "ae" ],
[ ".$", "bacd\naefg", "d" ]
].each do |reg, str, result|
m = RustRegexp.new(reg).match(str)
puts m.inspect
unless m.nil?
assert_equal result, m[0]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_regexp\n# (find-node \"(emacs-ja)Regexps\")\n \n conv = lambda{|from,to| assert_equal(to, el4r_conv_regexp(from)) }\n conv[ //, '' ]\n conv[ /a/, 'a' ]\n conv[ /a./, 'a.' ]\n conv[ /a*/, 'a*' ]\n conv[ /a+/, 'a+' ]\n conv[ /a?/, 'a?' ]\n conv[ /[ab]/, '[ab]' ]\n conv[ /[^ab]... | [
"0.5964451",
"0.5913886",
"0.5913886",
"0.5864126",
"0.58640945",
"0.5765381",
"0.57223755",
"0.57221174",
"0.558431",
"0.5540713",
"0.5537782",
"0.5499215",
"0.5493492",
"0.5485469",
"0.5476689",
"0.5476689",
"0.5476689",
"0.54644084",
"0.541113",
"0.54087114",
"0.5389694",
... | 0.60338444 | 0 |
global variables assert('$~') do | def test_dolla_squiggle
m = match_data_example
assert_equal m[0], $~[0]
mismatch_data_example
assert_nil $~
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __\n raise \"__ should be replaced with a value or expression to make the test pass.\"\nend",
"def checkTypo(arg,regex)\r\n return !(arg=~regex)\r\nend",
"def verify_iss=(_arg0); end",
"def verify_iss=(_arg0); end",
"def =~(p0) end",
"def =~(p0) end",
"def =~(p0) end",
"def verify_not_before=(_... | [
"0.58193773",
"0.5751243",
"0.57143074",
"0.57143074",
"0.566705",
"0.566705",
"0.566705",
"0.5551559",
"0.5551559",
"0.5546082",
"0.55127764",
"0.5485446",
"0.5458042",
"0.54202974",
"0.5415629",
"0.53506213",
"0.5317055",
"0.5305252",
"0.52981436",
"0.5257",
"0.52562773",
... | 0.0 | -1 |
GET /requests GET /requests.json | def index
@requests = Request.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @requests }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @requests = Request.all\n\n render json: @requests\n end",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.json { render :json => @requests}\n end\n end",
"def index\n @requests = ::Request.all\n\n respond_to do |format|\n format.html # in... | [
"0.71195513",
"0.6854284",
"0.6853197",
"0.67639446",
"0.67531043",
"0.6720251",
"0.6658772",
"0.6585643",
"0.6530313",
"0.64756197",
"0.6440112",
"0.64036715",
"0.6360889",
"0.63438714",
"0.6333824",
"0.6333824",
"0.6333824",
"0.6333824",
"0.6333824",
"0.6333824",
"0.6333824... | 0.6835143 | 4 |
GET /requests/1 GET /requests/1.json | def show
respond_to do |format|
format.html # show.html.erb
format.json { render json: @request }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @requests = Request.all\n\n render json: @requests\n end",
"def show\n @request = Request.find(params[:id])\n\n render json: @request\n end",
"def index\n @requests = Request.all\n\n respond_to do |format|\n format.json { render :json => @requests}\n end\n end",
"de... | [
"0.6923948",
"0.6775905",
"0.6691131",
"0.6687603",
"0.6687603",
"0.6601547",
"0.6509265",
"0.64060545",
"0.64060545",
"0.64060545",
"0.64060545",
"0.6389414",
"0.6377212",
"0.62783706",
"0.6275274",
"0.6275274",
"0.6275274",
"0.6275274",
"0.6275274",
"0.6275274",
"0.6275274"... | 0.5719245 | 71 |
DELETE /requests/1 DELETE /requests/1.json | def destroy
@request.destroy
respond_to do |format|
format.html { redirect_to requests_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @request = Request.find(params[:id])\n @request.destroy\n\n respond_to do |format|\n format.html { redirect_to requests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @request.destroy\n respond_to do |format|\n format.html { redirect_to requests_url ... | [
"0.7699295",
"0.76810163",
"0.76810163",
"0.76810163",
"0.7671836",
"0.7671836",
"0.7671836",
"0.7671836",
"0.7671836",
"0.7671836",
"0.7389192",
"0.73615795",
"0.7333734",
"0.7329198",
"0.7329198",
"0.7329198",
"0.7329198",
"0.7329198",
"0.7329198",
"0.7329198",
"0.7329198",... | 0.7705958 | 0 |
DELETE /crops/1 DELETE /crops/1.json | def destroy
Image.find(params[:id]).destroy
redirect_to :action => 'index'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @crop.destroy\n respond_to do |format|\n format.html { redirect_to crops_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", ar... | [
"0.6835698",
"0.67774457",
"0.66544914",
"0.6623697",
"0.65907073",
"0.6563973",
"0.6503464",
"0.64857924",
"0.64815444",
"0.64815444",
"0.6477888",
"0.6457768",
"0.645574",
"0.64427245",
"0.64319974",
"0.6416719",
"0.6390896",
"0.6388758",
"0.6388758",
"0.6388758",
"0.638618... | 0.0 | -1 |
Return current user instance, used for authorization. This method can be redefined in ApplicationController if you want to use application's auth system. ex: class ApplicationController < ActionController::Base def current_puffer_user current_user end end In this case returner user model instance should respond to has_role? method, or you should properly redefine +has_puffer_access?+ See +has_puffer_access?+ source and docs. | def current_puffer_user
@current_puffer_user ||= begin
super
rescue NoMethodError
::Admin::SessionsController.model.to_adapter.get(session[:puffer_user_id])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n \treturn @current_user if defined? @current_user\n \t@current_user = User.first\n end",
"def current_user\n if @current_user.nil?\n if ( ! session[ApplicationController::KEY_CURRENT_USER_ID].blank? )\n user_class = session[ApplicationController::KEY_CURRENT_... | [
"0.7571162",
"0.7537186",
"0.75358003",
"0.7500328",
"0.749589",
"0.74914634",
"0.74897945",
"0.7485818",
"0.74837977",
"0.7482105",
"0.74799097",
"0.7463718",
"0.7463391",
"0.745315",
"0.74430585",
"0.74367815",
"0.74355406",
"0.74205005",
"0.74205005",
"0.74155694",
"0.7414... | 0.7935158 | 0 |
Used in before_filter to prevent unauthorized access | def require_puffer_user
unless has_puffer_access?(puffer_namespace)
redirect_to puffer.new_admin_session_url(:return_to => request.fullpath)
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def skip_authorization; end",
"def access_denied\n end",
"def unauthorized\n end",
"def access_denied\n\n end",
"def restrict_access\t\n\t\tif current_user.owner == false\n\t\t\tredirect_to user_path(current_use... | [
"0.8207742",
"0.7865589",
"0.76097804",
"0.7578242",
"0.75616854",
"0.75197655",
"0.7509085",
"0.7509085",
"0.7482987",
"0.7467636",
"0.74079233",
"0.73983616",
"0.73949957",
"0.73886526",
"0.7366004",
"0.7363671",
"0.73410517",
"0.7332605",
"0.7325293",
"0.7313738",
"0.73089... | 0.0 | -1 |
create method for iterating through consonants | def consonant(letter)
alphabet = "bcdfghjklmnpqrstvwxyz"
alphabet2 = alphabet.chars.rotate.join('')
each_id = alphabet.index(letter.downcase)
next_consonant = alphabet2[each_id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initial_consonants\n \n @@sentence.map { |word|\n if word.start_with?('a','e','i','o','u','A','E','I','O','U') \n \"\" \n else \n consonant_blend = word.split /([aeiou].*)/\n consonant_blend[0]\n\n end\n ... | [
"0.69036484",
"0.6854533",
"0.6818968",
"0.6733501",
"0.6683276",
"0.66182685",
"0.6504335",
"0.6504113",
"0.64830077",
"0.64376146",
"0.6421656",
"0.64196306",
"0.64174145",
"0.640674",
"0.6406254",
"0.6393598",
"0.63852936",
"0.6383894",
"0.6364434",
"0.636204",
"0.6352603"... | 0.6229567 | 35 |
define method that implements previous methods define alphabet and vowels set new_string to value of empty string | def aliass(full_name)
alphabet = "bcdfghjklmnpqrstvwxyz"
vowels = "aeiou"
new_string = ""
#break input word into array and iterate through each letter
#if the letter is a vowel, take it and change it to next_vowel
#if the letter is a consonant, take it and change it to consonant
#else just add with no modification
full_name.split('').each do |letter|
if vowels.include?(letter)
new_string += vowel(letter)
elsif alphabet.include?(letter)
new_string += consonant(letter)
else
new_string += letter
end
end
#transform this new string into an array
new_word = new_string.split(' ')
#swap first and second word in array
new_word.reverse!
#turn new word into string
new_word.map {|names| names.capitalize!}
new_string = new_word.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vowel_change(current_v)\n if current_v == \"u\"\n current_v = \"a\"\n elsif current_v == \"U\"\n current_v = \"A\" \n else \n v_location = $vowels.index(current_v)\n current_v = $vowels[v_location+2]\n end\n current_v\nend",
"def vowel string\n # string = string.split(\"\")\n # strin... | [
"0.66397953",
"0.653145",
"0.6477933",
"0.64709556",
"0.64006555",
"0.63861024",
"0.6377128",
"0.63668257",
"0.6337688",
"0.63353044",
"0.6332802",
"0.62827474",
"0.6281222",
"0.6233197",
"0.62321454",
"0.62200516",
"0.62124026",
"0.62085694",
"0.61926854",
"0.6182257",
"0.61... | 0.60119313 | 37 |
This method is used for retrive the original password. WTF?! def password_clean crypted_password.decrypt(password_salt) end | def active?
active
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password_clean\n crypted_password.decrypt(salt)\n end",
"def password_clean\n crypted_password.decrypt(salt)\n end",
"def password\n raw_password = read_attribute(:password)\n raw_password.blank? ? nil : crypt.decrypt(raw_password)\n end",
"def decrpyt_password(encrypt_pass)\n ... | [
"0.9375924",
"0.93410146",
"0.72074896",
"0.6896532",
"0.6842127",
"0.67906916",
"0.67060715",
"0.6704768",
"0.6683602",
"0.66495824",
"0.66283005",
"0.6597421",
"0.6597421",
"0.6597421",
"0.65815824",
"0.6580408",
"0.6564844",
"0.6506535",
"0.649459",
"0.649048",
"0.6487642"... | 0.0 | -1 |
Calcula el porcentaje de carbohidratos del plato Devuelve:: Porcentaje de carbohidratos | def calc_perc_carbohydrates
alimentos = @food.collect { |x| x.carbohydrates }
gramos = @quantities.collect { |x| x/100.0 }
result = 0.0
for i in 0...alimentos.size
result += (gramos[i] * alimentos[i]) * 4
end
result /= @vct
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def por_carbo\n\t\t\t(@carbohidratos/suma_gramos)*100\n\t\tend",
"def valorpolialcoholesp\n\t\tvag=(polialcoholes * 70) / 100\n vag.round(2)\n\tend",
"def porc_grasa\n\t\t(1.2 * self.indice_masa_corporal + 0.23 * edad - 10.8 * sexo - 5.4).round(1)\n\tend",
"def porcentaje_carbohidratos\n ... | [
"0.71335584",
"0.70614773",
"0.69884187",
"0.69729626",
"0.6963495",
"0.69417924",
"0.69015986",
"0.68918085",
"0.6874473",
"0.6755125",
"0.67229366",
"0.67117506",
"0.67044514",
"0.6671719",
"0.6671009",
"0.6664855",
"0.6602347",
"0.6581777",
"0.6575524",
"0.6566262",
"0.654... | 0.0 | -1 |
storage :fog Override the directory where uploaded files will be stored. This is a sensible default for uploaders that are meant to be mounted: | def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_dir\n 'file_uploads'\n end",
"def store_dir\n \"uploads\"\n end",
"def store_dir\n 'uploads'\n end",
"def store_dir\n # \"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}\"\n # This works for the file storage as well as Amazon S3 and Rackspace Cloud Files.\n # D... | [
"0.7506321",
"0.736592",
"0.7332265",
"0.73319936",
"0.73027855",
"0.72984564",
"0.72778606",
"0.72778606",
"0.72778606",
"0.7269079",
"0.7244876",
"0.7229235",
"0.7225781",
"0.7201635",
"0.71862006",
"0.71782804",
"0.7164274",
"0.7149744",
"0.7149744",
"0.7149744",
"0.714974... | 0.7110686 | 30 |
Creates a new JobScheduler | def initialize(classes, result_aggregator, options, job_type: Job)
@classes = classes
@result_aggregator = result_aggregator
@options = options
@job_type = job_type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @job_scheduler = JobScheduler.new(job_scheduler_params)\n\n respond_to do |format|\n if @job_scheduler.save\n flash[:success] = \"Success! JobScheduler created.\"\n format.html { redirect_to job_scheduler_url(@job_scheduler) }\n format.json { render :show, status: :crea... | [
"0.6695572",
"0.6507251",
"0.6492816",
"0.64896166",
"0.6323488",
"0.6312585",
"0.6305333",
"0.6295468",
"0.62597036",
"0.5966181",
"0.594305",
"0.58616054",
"0.58603346",
"0.5834377",
"0.5832244",
"0.5832244",
"0.5832244",
"0.57532024",
"0.57215494",
"0.5717579",
"0.5679437"... | 0.0 | -1 |
def send_blowio(message, number) blowerio = RestClient::Resource.new(ENV['BLOWERIO_URL']) blowerio['/messages'].post :to => number, :message => message end | def send_sms(number, subject, carrier, message)
SMSMailer.sms_mailer(number, subject, carrier, message).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message\n response = RestClient::Request.new(\n :method => :post,\n :url => \"https://api.twilio.com/2010-04-01/Accounts/#{ENV['TWILIO_ACCOUNT_SID']}/Messages.json\",\n :user => ENV['TWILIO_ACCOUNT_SID'],\n :password => ENV['TWILIO_AUTH_TOKEN'],\n :payload => { :Body => body,\n... | [
"0.6427578",
"0.6205235",
"0.60775065",
"0.6053971",
"0.6053971",
"0.6041905",
"0.59912735",
"0.59523493",
"0.59356374",
"0.5928938",
"0.5898737",
"0.5895211",
"0.5883637",
"0.5870907",
"0.58634293",
"0.58594537",
"0.58574057",
"0.5851537",
"0.58486885",
"0.58300245",
"0.5797... | 0.0 | -1 |
Creates a new Kele client authorized with a username and password Params: username = string, password = string | def initialize(email, password)
# Bloc's API URL
# Params: endpoint = string
def api_url(endpoint)
"https://www.bloc.io/api/v1/#{endpoint}"
end
# Use the httparty class method .post to send a post request to the sessions endpoint of Bloc’s API with the email and password in the body of the request.
response = self.class.post(api_url("sessions"), body: {"email": email, "password": password})
# The @auth_token instance variable holds the authorization token provided by Bloc's API upon verifying successful username and password.
@auth_token = response["auth_token"]
# If the username and password are invalid, Bloc's API will not return an authorization token.
puts "There was a problem authorizing those credentials. Please try again." if @auth_token.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n payload = {\n name: name,\n validator: validator,\n # this field is ignored in API V1, but left for backwards-compat,\n # can remove after OSC 11 support is finished?\n admin: admin,\n }\n begin\n # try API V1\n raise Chef::Exceptions::In... | [
"0.7007443",
"0.6801419",
"0.6776164",
"0.66389316",
"0.6634256",
"0.6557456",
"0.6525087",
"0.6369942",
"0.6344741",
"0.63208896",
"0.6277257",
"0.6273922",
"0.6256848",
"0.62306714",
"0.6223341",
"0.6159044",
"0.615755",
"0.6140426",
"0.61233187",
"0.60774624",
"0.59818006"... | 0.0 | -1 |
Retrieve's the current user as a JSON blob by passing auth_token to the request to property authenticate against the Bloc API. Params: auth_token = string Use the httparty class method .get to pass the auth_token to Bloc's API with httparty's header option. | def get_me
response = self.class.get(api_url("users/me"),
headers: { "authorization" => @auth_token })
# Parse the JSON document returned in the response into a Ruby hash
JSON.parse(response.body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticated_user_with_token\n ApiKey.find_user_with_token(decoded_token)\n end",
"def get_user_by_auth_token\n user = UserSession.find_by_auth_token!(params[:auth_token]).user\n\n json_response 200,\n success: true,\n message_id: 'ok',\n message: I18n.t('success.ok'),\n da... | [
"0.68131524",
"0.6732153",
"0.66908926",
"0.665829",
"0.6595166",
"0.642096",
"0.64065033",
"0.6395047",
"0.6388248",
"0.6317604",
"0.6307986",
"0.6293515",
"0.6263402",
"0.625402",
"0.6223923",
"0.62147665",
"0.6209079",
"0.6191752",
"0.6190895",
"0.6187938",
"0.6167497",
... | 0.0 | -1 |
Don't ask the user for record quantity, just randomly create 10 Customers, Sales Orders and Invoices | def randomize_records
puts "Due to the API throughput limitations, this may take some time...\n"
execute_customer_record_create(10)
execute_sales_order_create(25)
execute_invoice_create(25)
# 25.times do |t|
# execute_payment_create(25)
# end
puts "\nFinished creating bulk records!"
exit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_customer_record_create(qty)\n puts \"Starting to create Customer records... Please give the API time to respond...\\n\"\n qty.times do |t|\n body = FakeCustomer.new.generate\n # puts JSON.pretty_generate(JSON.parse(body.to_json))\n FakeRestActions.new(endpoint: \"Customers\", body... | [
"0.70539945",
"0.6952793",
"0.6700388",
"0.66585565",
"0.6645221",
"0.6553587",
"0.6525742",
"0.6455582",
"0.64101386",
"0.63748324",
"0.6339594",
"0.63063043",
"0.6258709",
"0.6230114",
"0.61926",
"0.61608404",
"0.6147892",
"0.61292994",
"0.6126526",
"0.61087227",
"0.6108722... | 0.6756391 | 2 |
We ask the user to tell us how many records they want with these methods | def ready_customer_records
execute_customer_record_create(check_quantity)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_count\n\t\t# TODO\n\tend",
"def num_records\n num_urls + num_docs\n end",
"def num_records\n num_urls + num_docs\n end",
"def retrieved_records\n results.count\n end",
"def records_per_page\n\t\t@params[:records_per_page] || 25\n\tend",
"def total_records\n ... | [
"0.68464315",
"0.63600236",
"0.63600236",
"0.63318706",
"0.632335",
"0.63220537",
"0.6243119",
"0.6214137",
"0.62105274",
"0.6207605",
"0.6207605",
"0.61525023",
"0.6150881",
"0.6007105",
"0.5986569",
"0.5986569",
"0.5946007",
"0.59169185",
"0.59169185",
"0.59169185",
"0.5912... | 0.0 | -1 |
Execute record creation based in quantity input | def execute_customer_record_create(qty)
puts "Starting to create Customer records... Please give the API time to respond...\n"
qty.times do |t|
body = FakeCustomer.new.generate
# puts JSON.pretty_generate(JSON.parse(body.to_json))
FakeRestActions.new(endpoint: "Customers", body: body, access_token: @access_token).post_request
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(_obj, args, _ctx)\n create_table = Table.new(\n name: args[:name],\n quantity: args[:quantity],\n )\n return create_table if create_table.save\n GraphQL::ExecutionError.new(\"invalid data\")\n end",
"def add_units(qty)\n qty.to_i.times do\n #create item\n ... | [
"0.67013735",
"0.65957385",
"0.63124126",
"0.6233941",
"0.6219562",
"0.61756307",
"0.61744106",
"0.6164429",
"0.60861033",
"0.6059458",
"0.6053218",
"0.601747",
"0.5993268",
"0.5993268",
"0.59552157",
"0.5915156",
"0.5906974",
"0.5903815",
"0.5892649",
"0.58911955",
"0.587275... | 0.6794722 | 0 |
GET /bookings GET /bookings.json | def index
@bookings = Booking.all
respond_to do |format|
format.html
format.json { render :json => @bookings }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |f... | [
"0.8231102",
"0.80220497",
"0.80220497",
"0.80220497",
"0.7619097",
"0.7607287",
"0.7501954",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7473071",
"0.7437335",
... | 0.80365145 | 1 |
GET /bookings/1 GET /bookings/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |f... | [
"0.7793375",
"0.76496434",
"0.76496434",
"0.76496434",
"0.76409495",
"0.76042414",
"0.75729305",
"0.73645985",
"0.73645985",
"0.73645985",
"0.73645985",
"0.7241474",
"0.7206953",
"0.7206953",
"0.7206953",
"0.7206953",
"0.7206953",
"0.7206953",
"0.7206953",
"0.7206953",
"0.720... | 0.0 | -1 |
POST /bookings POST /bookings.json | def create
@booking = Booking.new(booking_params)
@current_room_bookings = Booking.where('room_id=?', @booking.room_id);
overlap = false;
@current_room_bookings.each do |old_booking|
endTime = old_booking.booking_start_time + 2*60*60;
currentEndTime = @booking.booking_start_time + 2*60*60;
if(@booking.booking_start_time...currentEndTime).overlaps?(old_booking.booking_start_time...endTime)
respond_to do |format|
format.html { redirect_to new_booking_path, notice: "Booking for that time slot already exists!" }
format.json { render json: @booking.errors, status: :unprocessable_entity }
end
overlap = true;
break;
end
end
if(!overlap)
respond_to do |format|
if @booking.save
format.html { redirect_to home_path, notice: 'Booking was successfully created.' }
format.json { render :show, status: :created, location: @booking}
UserMailer.welcome_email(@booking).deliver!
else
format.html { render :new }
format.json { render json: @booking.errors, status: :unprocessable_entity }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n booking = Booking.create(booking_params)\n render json: booking\n end",
"def create\n\t\tbooking = Booking.new(booking_params)\n\n\t if booking.save\n\t \tPeekBooker.use_a_boat(booking.size, booking.timeslot_id)\n\t \tPeekBooker.delete_overlap_assignments(booking.timeslot_i... | [
"0.7353111",
"0.7228384",
"0.68615675",
"0.6782987",
"0.6782987",
"0.67671645",
"0.6642527",
"0.66402507",
"0.6624695",
"0.65151906",
"0.6509862",
"0.6509862",
"0.6509862",
"0.64893967",
"0.6432859",
"0.6378296",
"0.634707",
"0.63245595",
"0.6297444",
"0.62888706",
"0.6278033... | 0.0 | -1 |
PATCH/PUT /bookings/1 PATCH/PUT /bookings/1.json | def update
respond_to do |format|
if @booking.update(booking_params)
format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }
format.json { render :show, status: :ok, location: @booking }
else
format.html { render :edit }
format.json { render json: @booking.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @booking = Booking.find(params[:id])\n\n if @booking.update(booking_params)\n head :no_content\n else\n render json: @booking.errors, status: :unprocessable_entity\n end\n end",
"def update\n @booking = Booking.find(params[:id])\n @booking.update_attributes(params[:booki... | [
"0.70660025",
"0.7035505",
"0.6951961",
"0.69296867",
"0.69296867",
"0.69296867",
"0.6925516",
"0.68727815",
"0.67891777",
"0.6737531",
"0.67097384",
"0.66938263",
"0.66938263",
"0.66938263",
"0.66782904",
"0.66559863",
"0.66393423",
"0.66337067",
"0.6626812",
"0.6624749",
"0... | 0.66082895 | 33 |
DELETE /bookings/1 DELETE /bookings/1.json | def destroy
@booking.destroy
respond_to do |format|
format.html { redirect_to home_path, notice: 'Booking was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |fo... | [
"0.7660707",
"0.7660707",
"0.7660707",
"0.7660707",
"0.7657568",
"0.7565737",
"0.75498253",
"0.75498253",
"0.739592",
"0.7359668",
"0.7359668",
"0.729106",
"0.72711414",
"0.724865",
"0.724865",
"0.724865",
"0.724865",
"0.724865",
"0.724865",
"0.724865",
"0.724865",
"0.72486... | 0.70330614 | 83 |
Use callbacks to share common setup or constraints between actions. | def set_booking
@booking = Booking.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 booking_params
params.require(:booking).permit(:user_id, :room_id, :booking_start_time, :email)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
GET /clients or /clients.json | def index
@clients = Client.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @clients = current_user.clients\n render json: @clients\n end",
"def index\n @clients = Client.all\n render json: @clients\n end",
"def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cli... | [
"0.75374585",
"0.7330886",
"0.7307635",
"0.72432935",
"0.7184106",
"0.7164839",
"0.71297824",
"0.71297824",
"0.71297824",
"0.71297824",
"0.71297824",
"0.71297824",
"0.71297824",
"0.7128865",
"0.71083707",
"0.7085555",
"0.705713",
"0.7012124",
"0.7004734",
"0.6977244",
"0.6952... | 0.67724645 | 38 |
GET /clients/1 or /clients/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def client(client, options = {})\n get(\"clients/#{client}\", options).pop\n end",
"def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end",
"def show\n\t\t@client =... | [
"0.7229171",
"0.7203965",
"0.7196992",
"0.71656483",
"0.71620274",
"0.71615666",
"0.71365654",
"0.71365654",
"0.71365654",
"0.71365654",
"0.71365654",
"0.71365654",
"0.71365654",
"0.7127474",
"0.7113834",
"0.7081925",
"0.70799977",
"0.7051576",
"0.6945427",
"0.69094324",
"0.6... | 0.0 | -1 |
POST /clients or /clients.json | def create
@client = Client.new(client_params)
respond_to do |format|
if @client.save
format.html { redirect_to @client, notice: "Client was successfully created." }
format.json { render :show, status: :created, location: @client }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_url, notice: 'El cliente se creó correctamente' }\n format.json { render :index, status: :created, location: @client }\n else\n format.html { render... | [
"0.70459324",
"0.70041037",
"0.6982345",
"0.69419277",
"0.691603",
"0.6902005",
"0.6902005",
"0.6902005",
"0.6884694",
"0.68596154",
"0.68228376",
"0.68214285",
"0.6814508",
"0.68108",
"0.68108",
"0.68108",
"0.6749863",
"0.673373",
"0.6733688",
"0.67275417",
"0.6692932",
"0... | 0.6796346 | 16 |
PATCH/PUT /clients/1 or /clients/1.json | def update
respond_to do |format|
if @client.update(client_params)
format.html { redirect_to @client, notice: "Client was successfully updated." }
format.json { render :show, status: :ok, location: @client }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @client.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @client.update(client_params)\n render json: @client\n end",
"def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n ... | [
"0.72847515",
"0.71870065",
"0.71870065",
"0.7159641",
"0.70983404",
"0.70771176",
"0.70771176",
"0.7063752",
"0.70605636",
"0.7038159",
"0.7032087",
"0.70251894",
"0.7000975",
"0.69954747",
"0.696068",
"0.6934566",
"0.69332933",
"0.6922324",
"0.69015485",
"0.69005156",
"0.68... | 0.682296 | 31 |
DELETE /clients/1 or /clients/1.json | def destroy
@client.destroy
respond_to do |format|
format.html { redirect_to clients_url, notice: "Client was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destro... | [
"0.766094",
"0.76533216",
"0.7626295",
"0.7626295",
"0.7622084",
"0.7621878",
"0.7621878",
"0.7621878",
"0.7621878",
"0.7621878",
"0.7621878",
"0.7621878",
"0.7621878",
"0.7621878",
"0.7577433",
"0.75709546",
"0.7490678",
"0.7484262",
"0.7465928",
"0.74481285",
"0.74197084",
... | 0.7371586 | 35 |
Use callbacks to share common setup or constraints between actions. | def set_client
@client = Client.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def client_params
params.require(:client).permit(:name, :last_billed_at, :billing_day, :client_payment_method)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Run our predictions that are further defined in the methods below | def virus_effects
# predicted_deaths(@population_density, @population, @state)
# speed_of_spread(@population_density, @state)
predicted_deaths
speed_of_spread
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_test\n for i in 0..@count-1\n @predictions << Prediction.new(@test_set[i].user_id,@test_set[i].movie_id, @test_set[i].rating,@database.predict(@test_set[i].user_id, @test_set[i].movie_id))\n end\n end",
"def predictions\n @predictions ||= Prediction.predict_for(self)\n end",
"def pr... | [
"0.73955566",
"0.7159063",
"0.6958304",
"0.6767968",
"0.6767968",
"0.673815",
"0.66892606",
"0.6639657",
"0.66204596",
"0.65931046",
"0.65644634",
"0.6562667",
"0.6496972",
"0.6481561",
"0.64305604",
"0.6427423",
"0.62992793",
"0.62512964",
"0.62239105",
"0.62217987",
"0.6188... | 0.0 | -1 |
Based on the density and population for a state, we're determining the number of deaths then printing out the prediction | def predicted_deaths
# predicted deaths is solely based on population density
# Use case/when for determining number of deaths
case @population_density
when @population_density >= 200; number_of_deaths = (@population * 0.4).floor
when @population_density >= 150; number_of_deaths = (@population * 0.3).floor
when @population_density >= 100; number_of_deaths = (@population * 0.2).floor
when @population_density >= 50; number_of_deaths = (@population * 0.1).floor
else number_of_deaths = (@population * 0.05).floor
end
print "#{@state} will lose #{number_of_deaths} people in this outbreak"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted_deaths # this is going to print out the deaths for each state on the outbreak which is going to be based on population and population density\n \n death_percent = 0.1 if @population_density >= 50\n death_percent = 0.2 if @population_density >= 100\n death_percent = 0.3 if ... | [
"0.8503434",
"0.84995985",
"0.8488351",
"0.8488351",
"0.8488351",
"0.8488351",
"0.8488351",
"0.8488351",
"0.8466374",
"0.84660757",
"0.84493667",
"0.84493446",
"0.84487724",
"0.84477603",
"0.841132",
"0.84048444",
"0.8403927",
"0.839711",
"0.8389722",
"0.8377348",
"0.83712006... | 0.0 | -1 |
Based on the population density, this predicts the number of months in which the disease will spread across the state | def speed_of_spread #in months
# We are still perfecting our formula here. The speed is also affected
# by additional factors we haven't added into this functionality.
speed = 0.0
case
when @population_density >= 200; speed += 0.5
when @population_density >= 150; speed += 1
when @population_density >= 100; speed += 1.5
when @population_density >= 50; speed += 2
else speed += 2.5 end
puts " and will spread across the state in #{speed} months.\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted_deaths\n # predicted deaths is solely based on population density\n STATE_FORMULA.each do |state_size, calculation|\n if @population_density >= calculation[:pop_density]\n return number_of_deaths = (@population * calculation[:deaths]).floor\n end\n end\n number_of_deaths ... | [
"0.7408022",
"0.7192387",
"0.71716064",
"0.7138437",
"0.70976317",
"0.7083109",
"0.70770305",
"0.7064478",
"0.7050245",
"0.704741",
"0.7028265",
"0.70282125",
"0.7002906",
"0.6991173",
"0.6980168",
"0.6973679",
"0.6972927",
"0.6954767",
"0.6954621",
"0.6951002",
"0.6947833",
... | 0.0 | -1 |
make variable/method Service.find_by(name: self.service_name).traffic | def bad_service?
Service.find_by(name: self.service_name).traffic != "GOOD SERVICE"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_train_status\n\t\tService.find_by(name: self.service_name).traffic\n\tend",
"def obtain_description\n\t\t#it's only pulling traffic train status for now, but we will get it to pull out the description instead.\n\t\tService.find_by(name: self.service_name).traffic\n\tend",
"def obtain_description\n\... | [
"0.65359384",
"0.65186495",
"0.651654",
"0.6070373",
"0.5983686",
"0.59749585",
"0.57798755",
"0.5657848",
"0.5430913",
"0.53892076",
"0.5368636",
"0.5344797",
"0.5316005",
"0.53084785",
"0.5297777",
"0.5239648",
"0.52305055",
"0.52204096",
"0.5198573",
"0.51972246",
"0.51689... | 0.49125263 | 52 |
checks if alert object is selected within critical timeframe of recipient | def relevant_time?
self.start < Time.now && self.end >Time.now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_alert? \n check_in = self.query[\"check_in\"].to_datetime if self.query[\"check_in\"]\n check_out = self.query[\"check_out\"].to_datetime if self.query[\"check_out\"]\n if (check_in && (check_in < Time.now)) or (check_out && (check_out < Time.now))\n Authorization::Maintenance::without_a... | [
"0.6003306",
"0.5897826",
"0.5823105",
"0.5713491",
"0.5645782",
"0.5639726",
"0.5616117",
"0.5594783",
"0.5553861",
"0.5548916",
"0.55438477",
"0.55414087",
"0.5497674",
"0.5495964",
"0.5448917",
"0.54387844",
"0.5426253",
"0.54149675",
"0.54113847",
"0.5410548",
"0.5396336"... | 0.5545619 | 10 |
Relates to creating text to voice calls. | def obtain_description
#it's only pulling traffic train status for now, but we will get it to pull out the description instead.
Service.find_by(name: self.service_name).traffic
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def speech; end",
"def incoming_text\n # Looks up the incoming phone number in our database and\n # retrieves the lead if found:\n begin\n standard_phone = Phoner::Phone.parse(params['From'], country_code: '1').to_s\n @lead = Lead.find_by(standard_phone: standard_phone) if standard_phone\n ... | [
"0.6667594",
"0.6629084",
"0.6580173",
"0.6555955",
"0.65346307",
"0.6510406",
"0.6409636",
"0.64002955",
"0.636529",
"0.63589513",
"0.63281953",
"0.63158625",
"0.6287795",
"0.62788105",
"0.62788105",
"0.62788105",
"0.62649494",
"0.6263339",
"0.62570095",
"0.62348783",
"0.623... | 0.0 | -1 |
We are following this url example below to to format the url for a call: | def call
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_url(request)\n \"#{@api_prefix}#{request}\"\n end",
"def request_url\n base_url = \"http://#{api_host}#{PATH}?\"\n base_url << \"appid=#{app_id}\"\n base_url << \"&callname=#{call_name}\"\n base_url << \"&siteid=#{site_id}\"\n base_url << \"&version=#{API_VERSION}\"\n ... | [
"0.68915445",
"0.68886673",
"0.6685401",
"0.66527754",
"0.6510911",
"0.64814883",
"0.6468134",
"0.6452945",
"0.63216484",
"0.6302338",
"0.6196032",
"0.6175477",
"0.6157846",
"0.61501914",
"0.6138132",
"0.61146605",
"0.60992926",
"0.60152376",
"0.5979382",
"0.5978775",
"0.5958... | 0.0 | -1 |
TODO: set default_tee set password???? | def config_user
atts = {}
u = @device.user
unless params[:name].blank?
return render json: {:status=>11, :message=>'用户名已经设置,不能修改'} if u.name
return render json: {:status=>12, :message=>'用户名已存在'} if User.find_by_name params[:name]
atts[:name] = params[:name]
end
unless params[:email].blank?
unless u.email.eql?(params[:email])
return render json: {:status=>13, :message=>'邮箱已经注册过'} if User.find_by_email params[:email]
end
atts[:email] = params[:email]
end
unless params[:pass].blank?
return render json: {:status=>14, :message=>'密码已经设置'} if u.password
atts[:password] = params[:pass]
end
atts[:score_mode] = params[:score_mode] unless params[:score_mode].blank?
atts[:tee] = params[:default_tee] unless params[:default_tee].blank?
u.update_attributes(atts)
ret = {:status=>0}
unless params[:password].blank?
@device.update_token
ret[:token] = @device.token
end
render json: ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setpwent\n ::Etc.setpwent\n end",
"def session_passwd\n super\n end",
"def session_passwd\n super\n end",
"def passwd=(p0) end",
"def passwd=(p0) end",
"def passwd\r\n @password = \"12345\"\r\n end",
"def password=(_arg0); end",
"def password=(_arg0); end",
"def passwo... | [
"0.6496828",
"0.63807863",
"0.63807863",
"0.63689125",
"0.63689125",
"0.6309606",
"0.625712",
"0.625712",
"0.625712",
"0.625712",
"0.6195145",
"0.61910325",
"0.61910325",
"0.608439",
"0.608439",
"0.608439",
"0.608439",
"0.608439",
"0.608439",
"0.5996619",
"0.5990703",
"0.59... | 0.0 | -1 |
GET /student_app_cat_regnos GET /student_app_cat_regnos.json | def index
@student_app_cat_regnos = StudentAppCatRegno.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @all_registration = AllRegistration.new\n @all_registration.reg_no=number_retrive(\"REG\")\n @college_master = CollegeMaster.last\n @years = which_category.years.find(:all)\n # @year1.map!(&:year)\n @semesters = \"B-Tech\".include?(@college_master.category) ? @category.semesters : \"\... | [
"0.6189821",
"0.60448205",
"0.5916937",
"0.5742928",
"0.5697935",
"0.55680597",
"0.5528712",
"0.5516869",
"0.5514594",
"0.55056554",
"0.5497031",
"0.54948574",
"0.5491098",
"0.5450131",
"0.5445969",
"0.54315805",
"0.5430632",
"0.5398704",
"0.5384641",
"0.5384532",
"0.5376649"... | 0.7220545 | 0 |
GET /student_app_cat_regnos/1 GET /student_app_cat_regnos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @student_app_cat_regnos = StudentAppCatRegno.all\n end",
"def new\n @all_registration = AllRegistration.new\n @all_registration.reg_no=number_retrive(\"REG\")\n @college_master = CollegeMaster.last\n @years = which_category.years.find(:all)\n # @year1.map!(&:year)\n @semesters ... | [
"0.7038048",
"0.6241537",
"0.6068811",
"0.5967954",
"0.5823859",
"0.55989313",
"0.55699086",
"0.5553694",
"0.5542902",
"0.5526952",
"0.54778993",
"0.547211",
"0.5433817",
"0.5428422",
"0.5421693",
"0.5419726",
"0.5409812",
"0.5390164",
"0.538287",
"0.53789496",
"0.5365086",
... | 0.0 | -1 |
POST /student_app_cat_regnos POST /student_app_cat_regnos.json | def create
@student_app_cat_regno = StudentAppCatRegno.new(student_app_cat_regno_params)
respond_to do |format|
if @student_app_cat_regno.save
format.html { redirect_to @student_app_cat_regno, notice: 'Student app cat regno was successfully created.' }
format.json { render :show, status: :created, location: @student_app_cat_regno }
else
format.html { render :new }
format.json { render json: @student_app_cat_regno.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @student_app_cat_regnos = StudentAppCatRegno.all\n end",
"def set_student_app_cat_regno\n @student_app_cat_regno = StudentAppCatRegno.find(params[:id])\n end",
"def new\n @all_registration = AllRegistration.new\n @all_registration.reg_no=number_retrive(\"REG\")\n @college_maste... | [
"0.645226",
"0.59649545",
"0.5849053",
"0.5651538",
"0.5577191",
"0.54617",
"0.5451802",
"0.542166",
"0.54051125",
"0.533416",
"0.5330176",
"0.5326658",
"0.52769065",
"0.52295613",
"0.5201422",
"0.5188359",
"0.5160425",
"0.51532394",
"0.51500064",
"0.5131479",
"0.5130406",
... | 0.7248284 | 0 |
PATCH/PUT /student_app_cat_regnos/1 PATCH/PUT /student_app_cat_regnos/1.json | def update
respond_to do |format|
if @student_app_cat_regno.update(student_app_cat_regno_params)
format.html { redirect_to @student_app_cat_regno, notice: 'Student app cat regno was successfully updated.' }
format.json { render :show, status: :ok, location: @student_app_cat_regno }
else
format.html { render :edit }
format.json { render json: @student_app_cat_regno.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_student_app_cat_regno\n @student_app_cat_regno = StudentAppCatRegno.find(params[:id])\n end",
"def update\n json_update(category,category_params, Category)\n end",
"def update\n # @student_category = StudentCategory.find(params[:id])\n\n respond_to do |format|\n if @student_catego... | [
"0.61135834",
"0.58597535",
"0.5834623",
"0.57942486",
"0.5766092",
"0.5749243",
"0.572301",
"0.57015866",
"0.5649218",
"0.56271374",
"0.56202483",
"0.5569394",
"0.5530903",
"0.55274683",
"0.55272967",
"0.55177826",
"0.5516618",
"0.5513322",
"0.5502429",
"0.5458423",
"0.54519... | 0.69879645 | 0 |
DELETE /student_app_cat_regnos/1 DELETE /student_app_cat_regnos/1.json | def destroy
@student_app_cat_regno.destroy
respond_to do |format|
format.html { redirect_to student_app_cat_regnos_url, notice: 'Student app cat regno was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end",
"def destroy\n # @student_category = StudentCategory.find(params[:id])\n @student_category.destroy\n\n respond_to do |format|\n format.html { redirect_to student_categories_url }\n format.json { head :ok }\n ... | [
"0.6481493",
"0.64647764",
"0.6455211",
"0.64507127",
"0.6437519",
"0.640994",
"0.64044076",
"0.63618094",
"0.6357828",
"0.6351566",
"0.6349962",
"0.6335993",
"0.6334742",
"0.6328334",
"0.6326384",
"0.63259524",
"0.631205",
"0.63094646",
"0.6304676",
"0.6303961",
"0.63002515"... | 0.73455197 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_student_app_cat_regno
@student_app_cat_regno = StudentAppCatRegno.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 student_app_cat_regno_params
params.require(:student_app_cat_regno).permit(:registrationnumber, :firstname, :lastname)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /promulher_forms GET /promulher_forms.json | def index
@promulher_forms = PromulherForm.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_forms\n @course = Course.find(params[:course_id])\n @forms = @course.professor_forms\n render json: @forms\n end",
"def show\n\t\t@form = @client.forms.find(params[:id])\n @procedures = @form.procedures.order('step_num ASC')\n\n \trespond_to do |format|\n \t\tformat.html # show.html.... | [
"0.7620798",
"0.7235807",
"0.71815485",
"0.7090954",
"0.6815023",
"0.67670554",
"0.6584934",
"0.6520534",
"0.65044993",
"0.64778745",
"0.64277625",
"0.64209366",
"0.63731885",
"0.635059",
"0.63230646",
"0.63163817",
"0.6273654",
"0.6267967",
"0.6258361",
"0.62518436",
"0.6251... | 0.72768515 | 1 |
GET /promulher_forms/1 GET /promulher_forms/1.json | def show; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_forms\n @course = Course.find(params[:course_id])\n @forms = @course.professor_forms\n render json: @forms\n end",
"def show\n\t\t@form = @client.forms.find(params[:id])\n @procedures = @form.procedures.order('step_num ASC')\n\n \trespond_to do |format|\n \t\tformat.html # show.html.... | [
"0.75220186",
"0.7489939",
"0.7340279",
"0.7143869",
"0.7011556",
"0.681693",
"0.6814621",
"0.680867",
"0.6616181",
"0.6593455",
"0.65731007",
"0.64824426",
"0.646599",
"0.64471567",
"0.6445544",
"0.643093",
"0.641826",
"0.6399494",
"0.6353839",
"0.6349988",
"0.6323702",
"0... | 0.0 | -1 |
POST /promulher_forms POST /promulher_forms.json | def create
@promulher_form = PromulherForm.new(promulher_form_params)
respond_to do |format|
if @promulher_form.save
format.html { redirect_to @promulher_form, notice: 'Promulher form was successfully created.' }
format.json { render :show, status: :created, location: @promulher_form }
else
format.html { render :new }
format.json { render json: @promulher_form.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n\t\t@form = @client.forms.new\n\n \n 3.times do\n procedure = @form.procedures.build\n end\n 3.times do\n authemp = @form.authemps.build\n end\n\n\t\trespond_to do |format|\n \t\tformat.html # show.html.erb\n \t\tformat.json { render json: @form }\n \t\tend\n\tend",
... | [
"0.6913027",
"0.66726047",
"0.6592258",
"0.6552269",
"0.64742494",
"0.6252745",
"0.62478137",
"0.6233747",
"0.6229439",
"0.6166977",
"0.6159434",
"0.61400044",
"0.612566",
"0.60932463",
"0.6082558",
"0.6077474",
"0.6069096",
"0.6062797",
"0.6053153",
"0.60170335",
"0.6016596"... | 0.69148487 | 0 |
PATCH/PUT /promulher_forms/1 PATCH/PUT /promulher_forms/1.json | def update
respond_to do |format|
if @promulher_form.update(promulher_form_params)
format.html { redirect_to @promulher_form, notice: 'Promulher form was successfully updated.' }
format.json { render :show, status: :ok, location: @promulher_form }
else
format.html { render :edit }
format.json { render json: @promulher_form.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @pec_form = PecForm.find(params[:id])\n\n respond_to do |format|\n if @pec_form.update_attributes(params[:pec_form])\n format.html { redirect_to @pec_form, notice: I18n.t('pec_form.notice.update') }\n format.json { head :ok }\n else\n\t\t\t\tgon.edit_pec_form = true\n\t\t... | [
"0.65179825",
"0.6510923",
"0.64998424",
"0.6494558",
"0.6481626",
"0.64682937",
"0.64682937",
"0.6396021",
"0.6302415",
"0.6280932",
"0.62748474",
"0.62587726",
"0.62528056",
"0.6247302",
"0.6236622",
"0.6225212",
"0.6219872",
"0.62041736",
"0.62023014",
"0.6200375",
"0.6198... | 0.6852862 | 0 |
DELETE /promulher_forms/1 DELETE /promulher_forms/1.json | def destroy
@promulher_form.destroy
respond_to do |format|
format.html { redirect_to promulher_forms_url, notice: 'Promulher form was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @form1.destroy\n respond_to do |format|\n format.html { redirect_to form1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @formulario = Formulario.find(params[:id])\n @formulario.destroy\n\n respond_to do |format|\n format.html { redirect_to ... | [
"0.72760016",
"0.720834",
"0.7181126",
"0.71731514",
"0.7154185",
"0.7150297",
"0.7143509",
"0.71341413",
"0.7090525",
"0.70640826",
"0.7054177",
"0.70404845",
"0.7016824",
"0.7015252",
"0.7006958",
"0.6993865",
"0.69792414",
"0.6978846",
"0.6977704",
"0.69638497",
"0.6953685... | 0.7256895 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_promulher_form
@promulher_form = PromulherForm.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def promulher_form_params
params.require(:promulher_form).permit(:family_size, :f_children, :m_children, :works)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
serialize the hash into json and save in a cookie add to the responses cookies | def store_flash(res)
serialized_flash = @later.to_json
res.cookies << WEBrick::Cookie.new("_rails_lite_flash" , serialized_flash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cookie_hash\n\t\t\t{ 'Cookie' => @cookies.to_s }\n\t\tend",
"def store_session(res)\n res.cookies << WEBrick::Cookie.new('_rails_lite_app', @hash.to_json)\n end",
"def serialize_into_cookie(record); end",
"def encode_to_cookie h, cookie\n cookie[@name] = encode h\n end",
"def serialize_... | [
"0.7232483",
"0.7079436",
"0.70458454",
"0.69088364",
"0.67860115",
"0.6538753",
"0.6516383",
"0.64779174",
"0.6469998",
"0.643302",
"0.6402495",
"0.6361502",
"0.636",
"0.63407034",
"0.6339202",
"0.63323885",
"0.6327872",
"0.63275915",
"0.629749",
"0.62952596",
"0.6291643",
... | 0.60611534 | 36 |
Use callbacks to share common setup or constraints between actions. | def set_post_tag
@post_tag = PostTag.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def post_tag_params
params.fetch(:post_tag, {})
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 |
GET /minuts GET /minuts.json | def index
@minuts = Minut.joins(:users).where("users.id = ?", current_user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ministerio }\n end\n end",
"def show\n @minicurso = Minicurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.6410871",
"0.6312887",
"0.62972283",
"0.6230961",
"0.60910964",
"0.6053777",
"0.5992761",
"0.5978026",
"0.59486645",
"0.59478074",
"0.5918123",
"0.5911583",
"0.5909336",
"0.58867455",
"0.5876364",
"0.5864731",
"0.58595914",
"0.58544225",
"0.5841103",
"0.58241785",
"0.58108... | 0.57781523 | 26 |
GET /minuts/1 GET /minuts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ministerio }\n end\n end",
"def show\n @minicurso = Minicurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.668309",
"0.64907336",
"0.6230573",
"0.61786985",
"0.61763036",
"0.6167411",
"0.6089131",
"0.6071402",
"0.6068066",
"0.6031913",
"0.60002184",
"0.5993631",
"0.59558696",
"0.5953275",
"0.59485024",
"0.5946205",
"0.5945761",
"0.5934396",
"0.5930904",
"0.5915597",
"0.59039146... | 0.0 | -1 |
POST /minuts POST /minuts.json | def create
@minut = Minut.new(minut_params)
@minut = Minut.new(minut_params)
user_id = params[:minut][:id]
if user_id
user = User.find(user_id) # 権限情報追加(本人)
@minut.users << user
end
user = User.find(current_user) # 権限情報追加(選択分)
@minut.users << user
@users = User.where.not("id = ?", current_user)
respond_to do |format|
if @minut.save
format.html { redirect_to @minut, notice: 'Minut was successfully created.' }
format.json { render :show, status: :created, location: @minut }
else
format.html { render :new }
format.json { render json: @minut.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @minicurso = Minicurso.new(params[:minicurso])\n\n respond_to do |format|\n if @minicurso.save\n format.html { redirect_to @minicurso, notice: 'Minicurso was successfully created.' }\n format.json { render json: @minicurso, status: :created, location: @minicurso }\n else\... | [
"0.5968583",
"0.5932527",
"0.58873105",
"0.58409667",
"0.57937044",
"0.57039076",
"0.5684435",
"0.5669336",
"0.56550986",
"0.56373256",
"0.56323504",
"0.56201684",
"0.5618863",
"0.5610063",
"0.56022364",
"0.559634",
"0.5589939",
"0.5565027",
"0.5557354",
"0.55550426",
"0.5552... | 0.5320203 | 48 |
PATCH/PUT /minuts/1 PATCH/PUT /minuts/1.json | def update
@minut = Minut.new(minut_params)
minutdel = Minut.find(params[:id])
minutdel.delete
user_id = params[:minut][:id]
if user_id
user = User.find(user_id) # 権限情報追加(選択分)
@minut.users << user
end
user = User.find(current_user) # 権限情報追加(本人分)
@minut.users << user
@users = User.where.not("id = ?", current_user)
respond_to do |format|
if @minut.save
format.html { redirect_to @minut, notice: 'Minut was successfully updated.' }
format.json { render :show, status: :ok, location: @minut }
else
format.html { render :edit }
format.json { render json: @minut.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @ministerio = Ministerio.find(params[:id])\n\n respond_to do |format|\n if @ministerio.update_attributes(params[:ministerio])\n format.html { redirect_to @ministerio, notice: 'Ministerio was successfully updated.' }\n format.json { head :no_content }\n else\n forma... | [
"0.63166493",
"0.6293164",
"0.62190956",
"0.62032664",
"0.6133953",
"0.6111854",
"0.60540307",
"0.603813",
"0.6036243",
"0.6034789",
"0.602788",
"0.60248744",
"0.6014388",
"0.6011896",
"0.5987442",
"0.59751886",
"0.59518075",
"0.59506756",
"0.5945692",
"0.59401137",
"0.593182... | 0.0 | -1 |
DELETE /minuts/1 DELETE /minuts/1.json | def destroy
@minut.destroy
respond_to do |format|
format.html { redirect_to minuts_url, notice: 'Minut was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @ministerio = Ministerio.find(params[:id])\n @ministerio.destroy\n\n respond_to do |format|\n format.html { redirect_to ministerios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @minicurso = Minicurso.find(params[:id])\n @minicurso.destroy\n\n ... | [
"0.7088651",
"0.6969055",
"0.69264215",
"0.69081724",
"0.68713397",
"0.687088",
"0.6791006",
"0.6781413",
"0.67722327",
"0.6757899",
"0.67391723",
"0.6722646",
"0.67088556",
"0.6705816",
"0.6703608",
"0.6692136",
"0.66843086",
"0.6656975",
"0.6639853",
"0.6637083",
"0.6636861... | 0.7147959 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_minut
@minut = Minut.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 minut_params
params.require(:minut).permit(:title, :body, authors_attributes: [:minut_id, :user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Make sure password and confirm_password are the same on update | def validate_on_update
unless plain_password.blank?
unless plain_password == password_confirmation
errors.add_to_base("Passwords don't match")
end
# Validate password criteria
unless plain_password.length >= 6
errors.add_to_base("Password must be at least 6 characters long.")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_on_update\n unless plain_password.blank?\n unless plain_password == password_confirmation\n errors.add_to_base(\"Passwords don't match\")\n end\n # Validate password criteria\n unless plain_password.length >= 6\n errors.add_to_base(\"Password must be at least 6 cha... | [
"0.7755978",
"0.76147574",
"0.7551223",
"0.75487745",
"0.74905527",
"0.7482487",
"0.7462891",
"0.744798",
"0.7446331",
"0.7367924",
"0.7308071",
"0.7282038",
"0.7268492",
"0.72589314",
"0.7253914",
"0.72497183",
"0.72287405",
"0.71731997",
"0.7166696",
"0.7149652",
"0.7146407... | 0.76982796 | 1 |
Encrypts the password with the user salt | def encrypt(plain_password)
self.class.encrypt(plain_password)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n self.salt = make_salt unless has_password?(password)\n self.encrypted_password = encrypt(password)\n end",
"def encrypt_password\n ... | [
"0.8456656",
"0.83809954",
"0.837295",
"0.83666867",
"0.8361271",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83577955",
"0.83539045",
"0.8353123",
"0.83147633",
"0.8314556",
"0.83011955",
"0.82853645",
"0.8279242",
"0.8253498",
"0.82321554",
"0.8... | 0.0 | -1 |
Remember token remembers users between browser closures | def remember_token?
remember_token_expires_at && Time.now.utc < remember_token_expires_at
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remember_token; end",
"def remember(user)\n#goes to remember method in user.rb and returns user.remember_token, and saves hashed one\n user.remember\n# saves users id\n cookies.permanent.signed[:user_id]=user.id\n# saves users cookies token\n cookies.permanent[:remember_token]=user.remember_token\n ... | [
"0.8017096",
"0.75709236",
"0.7546626",
"0.7537563",
"0.7514134",
"0.75125575",
"0.74719423",
"0.74566025",
"0.74316955",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
"0.74314374",
... | 0.0 | -1 |
These create and unset the fields required for remembering users between browser closes | def remember_me
remember_me_for 2.weeks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forgets\n update_attribute(:remember_digest, nil)\n end",
"def after_save\n cookies['global_properties_for_user'] = nil\n end",
"def forget\n \tupdate_attribute(:remember_digest, nil)\n end",
"def forget\n \tupdate_attribute(:remember_digest, nil)\n end",
"def forget\n update_attribute(:... | [
"0.655833",
"0.64576274",
"0.6433039",
"0.6433039",
"0.63186485",
"0.6318346",
"0.62982345",
"0.62982345",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
"0.6266504",
... | 0.0 | -1 |
We are going to connect this user object with a facebook id. But only ever one account. | def link_fb_connect(fb_user_id)
unless fb_user_id.nil?
#check for existing account
existing_fb_user = ::User.find_by_fb_user_id(fb_user_id)
#merge the existing account
unless existing_fb_user.nil?
merge_with(existing_fb_user)
end
#link the new one
self.fb_user_id = fb_user_id
save(false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_fb_connect(fb_user_id)\n unless fb_user_id.nil?\n #check for existing account\n # UPDATE:\n # allow multiple accounts to use the same facebook id I guess - \n # makes debugging a lot easier too\n existing_fb_user = User.find_by_facebook_uid(fb_user_id)\n \n #unlink th... | [
"0.7504093",
"0.7490277",
"0.7399922",
"0.7399922",
"0.7399922",
"0.7399922",
"0.73369694",
"0.7231991",
"0.72258043",
"0.70384943",
"0.6854877",
"0.67980784",
"0.67314434",
"0.6724964",
"0.6720284",
"0.6681034",
"0.66633296",
"0.6646808",
"0.664005",
"0.6634973",
"0.6614998"... | 0.7533046 | 0 |
The Facebook registers user method is going to send the users email hash and our account id to Facebook We need this so Facebook can find friends on our local application even if they have not connect through connect We then use the email hash in the database to later identify a user from Facebook with a local user | def register_user_to_fb(force = false)
if force || changed.include?('username') || changed.include?('facebook_username')
email = facebook_username.present? ? facebook_username : username
users = {:email => email, :account_id => id}
::Facebooker::User.register([users]) unless Rails.env.test?
self.facebook_hash = ::Facebooker::User.hash_email(email)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_user_to_fb\n\t #users = {:email => email, :account_id => id}\n\t #Facebooker::User.register([users])\n\t #self.email_hash = Facebooker::User.hash_email(email)\n\t #save(false)\n\tend",
"def register_user_to_fb\n users = {:email => email, :account_id => id}\n Facebooker::Use... | [
"0.86883646",
"0.85537905",
"0.85171074",
"0.85083807",
"0.84802294",
"0.84802294",
"0.80198365",
"0.7796362",
"0.73765904",
"0.73027676",
"0.68901366",
"0.68469244",
"0.6791724",
"0.67764485",
"0.67577904",
"0.6695931",
"0.6695524",
"0.66334695",
"0.66173434",
"0.65594894",
... | 0.81115323 | 6 |
Encrypts some data with the salt. | def encrypt(plain_password)
md5_password = Digest::MD5.digest(plain_password)
base64_password = Base64.encode64(md5_password).chomp
base64_password
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt(data)\n self.class.encrypt(data + salt.to_s)\n end",
"def encrypt(data)\n Digest::SHA1.hexdigest(data + @salt)\n end",
"def encrypt(password)\n self.class.encrypt(password) #, salt)\n end",
"def encrypt(data, password = nil)\n salt = random_bytes(@salt_len)\n iv = ra... | [
"0.8596541",
"0.8273116",
"0.74384254",
"0.7435833",
"0.7434742",
"0.7434742",
"0.7434742",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
"0.7423544",
... | 0.0 | -1 |
find the user in the database, first by the facebook user id and if that fails through the email hash | def find_by_fb_user(fb_user)
u = ::User.find(:first, :conditions => {_(:fb_user_id, :user) => fb_user.uid}) || ::User.find(:first, :conditions => {_(:facebook_hash, :user) => fb_user.email_hashes})
# make sure we have a person
if u && !u.person
u.create_person_from_fb(fb_user)
end
u.update_attribute(:fb_user_id, fb_user.uid) if u && !u.fb_user_id
u
rescue ::Facebooker::Session::SessionExpired
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_using_oauth_email(oauth_data, oauth_user_id)\r\n user = nil\r\n oauth_email = oauth_data.info.email\r\n if oauth_email.present?\r\n user = self.find_by(email: oauth_email)\r\n if user.present? && user.oauth_user_id.blank?\r\n ... | [
"0.6920768",
"0.67485434",
"0.672814",
"0.67200446",
"0.67033076",
"0.66947705",
"0.66855234",
"0.66835487",
"0.66795",
"0.66595215",
"0.66486245",
"0.6629216",
"0.6628796",
"0.65961623",
"0.65886146",
"0.65642726",
"0.65103817",
"0.65065646",
"0.64859295",
"0.6476302",
"0.64... | 0.7600064 | 0 |
Take the data returned from facebook and create a new user from it. We don't get the email from Facebook and because a facebooker can only login through Connect we just generate a unique login name for them. If you were using username to display to people you might want to get them to select one after registering through Facebook Connect | def create_from_fb_connect(fb_user, username)
u = ::User.find(:first, :conditions => {_(:username) => username} )
if u
u.facebook_hash = fb_user.email_hashes.first
u.fb_user_id = fb_user.uid
else
u = ::User.create(_(:username) => username || fb_user.email_hashes.first, _(:last_login) => Time.now.utc, _(:fb_user_id) => fb_user.uid, _(:facebook_hash) => fb_user.email_hashes.first)
end
u.create_person_from_fb(fb_user) unless u.person
u.save(false)
u
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def facebook_create\n @new_user = User.find_or_create_by(uid: auth['uid']) do |u|\n u.name = auth['info']['name']\n u.email = auth['info']['email']\n u.image = auth['info']['image']\n u.password = User.generic_password\n end\n @new_user.save\n ... | [
"0.78181374",
"0.7777557",
"0.7627231",
"0.7423836",
"0.7354835",
"0.734686",
"0.73203176",
"0.72324646",
"0.7228638",
"0.72273344",
"0.72220707",
"0.7187338",
"0.70985585",
"0.7051838",
"0.70495343",
"0.70490974",
"0.7039318",
"0.7028881",
"0.70116824",
"0.7010756",
"0.70054... | 0.771394 | 2 |
not sure why but cas sometimes sends the extra attributes as underscored | def att_from_receipt(atts, key)
atts[key] || atts[key.underscore]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cas_extra_attributes=(extra_attributes)\n extra_attributes.each do |name, value|\n puts \"DEBUG: cas_extra_attributes CALLED\"\n puts \"extra_attributes:\"+ name.to_s+\" => \"+ value.to_s\n case name.to_sym\n when :fullname\n self.fullname = value\n when :email\n ... | [
"0.5777301",
"0.5684195",
"0.55034155",
"0.5490005",
"0.5461186",
"0.53680336",
"0.534602",
"0.52959126",
"0.529258",
"0.52419686",
"0.5228576",
"0.52164567",
"0.52164567",
"0.52164567",
"0.52106774",
"0.51925284",
"0.51921195",
"0.5185141",
"0.517589",
"0.51559234",
"0.51543... | 0.0 | -1 |
Build a multipart/formdata body as per RFC 2388. | def build_stream
# Form input field name for the file path must be set to file.
# Any other field name will not be picked up by the upload server.
name = 'file'
content_length = File.size(@data_path)
content_type = mime_type_for(@data_path)
@stream = Tempfile.new("BitsOnTheRun.Upload.")
@stream.binmode
write_stream_head(name, content_type, content_length)
write_stream_body
write_stream_tail
@stream.seek(0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_multipart_content(params)\n\tparts, boundary = [], \"#{rand(1000000)}-we-are-all-doomed-#{rand(1000000)}\"\n\t\n\tparams.each do |name, value|\n\t\tdata = []\n\t\tif value.is_a?(Pathname) then\n\t\t\tdata << \"Content-Disposition: form-data; name=\\\"#{urlencode(name.to_s)}\\\"; filename=\\\"#{value.base... | [
"0.76564777",
"0.75952953",
"0.7582058",
"0.73681915",
"0.73681915",
"0.73681915",
"0.73681915",
"0.73525167",
"0.73045135",
"0.7284556",
"0.72065836",
"0.7174001",
"0.71551114",
"0.7081993",
"0.70066154",
"0.70038176",
"0.6973473",
"0.69263816",
"0.6857866",
"0.68310946",
"0... | 0.0 | -1 |
Adding an index concurrently must not happen inside a transaction (the default) | def change
add_index :handcuffs_primary_tests, :test_field, algorithm: :concurrently
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_add_index(*args, **options); end",
"def create_or_update_index\n # check if index is created\n if index_exists?\n IndexJob.perform_later(self.class.name, 'update', id)\n else\n IndexJob.perform_later(self.class.name, 'index', id)\n end\n end",
"def add_index(table_name, column_n... | [
"0.7123435",
"0.6822825",
"0.6721672",
"0.6665731",
"0.6581441",
"0.64493763",
"0.6313256",
"0.6201618",
"0.6175409",
"0.6165769",
"0.615396",
"0.6152387",
"0.606203",
"0.6056703",
"0.6028219",
"0.6023471",
"0.6015267",
"0.6015267",
"0.6008429",
"0.6001351",
"0.6001351",
"0... | 0.54555327 | 100 |
any dlv file under this size should be recomputed, b/c it's probably just comments if this guesses badly, it is just inefficient, not incorrect | def initialize(table='traces')
@table=table
raise "#{Basedir} does not exists " unless Kernel::test(?d,Basedir)
#ip2db=Ips2TTLdistance2db.new
## create a database handle with constants stored in Ips2TTLdistance2db
#@dbh=DBI.connect("DBI:Pg:dbname=#{ip2db.databasename};host=#{ip2db.databasehost}",
# ip2db.databaseuser, ip2db.databasepasswd)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recalculate_filesize\n @filesize = @collection.reduce(0) {|sum,asset| sum + asset.size}\n end",
"def size; file_log.size(file_rev); end",
"def file_size\n 1000 # temporarily disable file size calculation\n # TODO: fix this in production env (perhaps zencoder is not replacing target file?)... | [
"0.66798526",
"0.65998375",
"0.6590753",
"0.65602523",
"0.64207715",
"0.63986605",
"0.6382927",
"0.6381316",
"0.63580567",
"0.6309444",
"0.630816",
"0.6279705",
"0.6273612",
"0.6273612",
"0.62481326",
"0.62187374",
"0.6187421",
"0.6159184",
"0.6142946",
"0.61356705",
"0.60522... | 0.0 | -1 |
delete the default shipment and create split shipments out of it | def split_shipment!
self.shipments.destroy_all
units = self.inventory_units.includes(:variant=>:product)
units.group_by{|u| u.variant.product.brand_id}.each do |brand_id,units|
s = Spree::Shipment.create!({ :order => self, :shipping_method => shipping_method, :address => self.ship_address,
:inventory_units => units}, :without_protection => true)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_shippment(items)\n fill_boxes(items)\n shippment_object\n make_json_object\n end",
"def shipped\n \n end",
"def create_shipment!\n shipping_method(true)\n\n if shipment.present?\n shipment.update_attributes!(:shipping_method => shipping_method)\n else\n self.shipmen... | [
"0.61928374",
"0.59945863",
"0.59641236",
"0.58702356",
"0.5850442",
"0.576921",
"0.5718929",
"0.57001406",
"0.56667674",
"0.5660817",
"0.56591797",
"0.56439507",
"0.56239814",
"0.5610756",
"0.55948067",
"0.55864877",
"0.5574602",
"0.5569819",
"0.5567483",
"0.5567483",
"0.555... | 0.6811934 | 0 |
private update adjustment for shipment without passing order | def update_adjustments
self.adjustments.reload.each do |adjustment|
if adjustment.originator.class == Spree::Shipment
adjustment.update!
else
adjustment.update!(self)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_order\n # If there is no adjustment for the current gift package, just create one here unless there already is one for the gift package\n if self.gift_package_id && self.gift_package_id > 0 && self.adjustments.gift_packaging.where(:originator_id => self.gift_package_id).count == 0\n self.gift... | [
"0.75130665",
"0.7189034",
"0.70065576",
"0.6834643",
"0.67360175",
"0.6710495",
"0.6707694",
"0.67011046",
"0.6621398",
"0.6618038",
"0.65752834",
"0.65631765",
"0.6539716",
"0.6537501",
"0.6527779",
"0.6524986",
"0.64819205",
"0.6447702",
"0.64275545",
"0.642652",
"0.639881... | 0.67873484 | 4 |
Check wallets by currency | def process
info = []
Currency.all.each do |currency|
if currency.coin
group_id = StratumWalletGroup.get_id(1, 'cointrade')
# Check locally
if currency[:stratum_wallet_id].nil? or currency[:stratum_wallet_id] == 0
# Load from api, or create
wallet_eid = StratumWallet.get_id(currency.id, group_id, currency)
if wallet_eid.nil?
@logger.error "Failed loading/creating wallet #{currency.code}"
else
# Update Redis
currency.update_stratum_wallet_id(wallet_eid)
end
end
#Update currencies memory list
info << "#{currency.code} group #{group_id} stratum_wallet_id = #{currency.stratum_wallet_id}"
end
end
@logger.info "Define Stratum wallets: #{JSON.pretty_generate(info)} "
rescue
SystemMailer.wallet_mapping_error({}, $!.message, $!.backtrace.join("\n"))
@logger.error "Failed to map: #{$!}"
@logger.error $!.backtrace.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same_currencies?\n debit_account.currency?(amount.currency) &&\n credit_account.currency?(amount.currency)\n end",
"def fetch_wallet(funds_type, currency_iso_code)\n MangoPay.request(:get, url() + \"/wallets/#{funds_type}/#{currency_iso_code}\")\n end",
"def same_currency?(curren... | [
"0.64214355",
"0.62708616",
"0.6194144",
"0.60878205",
"0.60166323",
"0.5950085",
"0.59104717",
"0.59040016",
"0.5895025",
"0.5836461",
"0.57885647",
"0.5752347",
"0.56782264",
"0.56674993",
"0.56410336",
"0.56410336",
"0.56410336",
"0.56051457",
"0.56041694",
"0.56038266",
"... | 0.0 | -1 |
Method combines First name, Last name and returns Full Name of Contact | def name
name = ''
name = first_name if first_name
name = name + ' ' + last_name if last_name
name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name\n return Contact.generate_full_name self.first_name, self.middel_name, self.last_name\n end",
"def full_name\n return first_name + \" \" + last_name\n end",
"def full_name\n return first_name + \" \" + last_name\n end",
"def full_name\n [first_name, last_name].join(\"... | [
"0.8470216",
"0.8177915",
"0.8177915",
"0.8141312",
"0.8141312",
"0.8141312",
"0.8141312",
"0.8141312",
"0.8141312",
"0.8137999",
"0.8135187",
"0.8135187",
"0.8135187",
"0.8135187",
"0.8135187",
"0.8103105",
"0.8102288",
"0.81004745",
"0.80938405",
"0.8081592",
"0.80691826",
... | 0.0 | -1 |
Method combines First name, Middle name & Last name and returns Full Name of Contact | def full_name
return Contact.generate_full_name self.first_name, self.middel_name, self.last_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_name\n \"#{first_name} #{middle_name} #{last_name}\".split.join(' ')\n end",
"def full_name\n name = first_name.strip # required\n name << \" #{middle_name.strip}\" if !middle_name.nil?\n name << \" #{last_name.strip}\" # required\n name << \" #{mother_last_name.s... | [
"0.82870626",
"0.8255562",
"0.821288",
"0.81470543",
"0.8136675",
"0.81085455",
"0.8104215",
"0.8104215",
"0.80901086",
"0.80901086",
"0.80901086",
"0.80901086",
"0.80901086",
"0.8088031",
"0.8088031",
"0.8088031",
"0.8088031",
"0.8088031",
"0.8088031",
"0.80834216",
"0.80793... | 0.83620644 | 0 |
Method returns Primary Email of a contact if any or blank otherwise | def email
return Contact.get_default_email self.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_email\n primary_email_object = emails.find_by(is_primary: true)\n return if primary_email_object.blank?\n\n primary_email_object.address\n end",
"def primary_email\n primary_contacts(emails, :email_rank_code, &:first)\n end",
"def primary_email\n if self[\"gd$email\"]\n _e... | [
"0.83127165",
"0.82457817",
"0.8234795",
"0.7814641",
"0.7607048",
"0.74769187",
"0.74534076",
"0.73707074",
"0.7350632",
"0.7205736",
"0.7195834",
"0.71909875",
"0.70083004",
"0.69953036",
"0.69882786",
"0.69879574",
"0.6984345",
"0.6971407",
"0.6968407",
"0.68911135",
"0.68... | 0.7551905 | 5 |
Method returns the top connector status of Contact | def is_top_connector?
TopConnector.exists? :contact_id => self.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n @connections.status\n end",
"def connection_status\n \t@current_connection = ConnectionInfo.where(\"disconnected_at is null\").first\n end",
"def connector_type\n cable.connector_types[self.end - 1]\n end",
"def getConnectorStart()\n\t\tif @roomConnectors.length() > 0\n\t\t\treturn @ro... | [
"0.6166162",
"0.5930187",
"0.571587",
"0.565967",
"0.5516205",
"0.5496794",
"0.541558",
"0.5384492",
"0.5379278",
"0.5327636",
"0.5326426",
"0.5294457",
"0.52766067",
"0.52710396",
"0.52410865",
"0.5230667",
"0.5228206",
"0.5219499",
"0.52187765",
"0.52187765",
"0.52187765",
... | 0.7028141 | 0 |
Method validates a Contact for Manual Entry | def validate?
valid = true
if first_name.blank? && last_name.blank?
errors.add_to_base("Must enter contact name")
valid = false
end
ex_email = Contact.find(:first, :include => [:emails], :conditions => ["emails.email_text = ? AND contacts.user_id = ? AND merged_to_form_contact_id = 0", self.email, self.user_id])
if ex_email
errors.add_to_base("Contact already in network")
valid = false
end
valid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n validates_contact\n end",
"def validate_that_at_least_one_set_of_contact_info_is_present\n return if veteran_contact_info.present? || claimant_contact_info.present?\n\n errors.add :form_data, I18n.t('appeals_api.errors.contact_info_presence')\n end",
"def verify_contact_address\... | [
"0.7018682",
"0.6405677",
"0.63949496",
"0.6386284",
"0.63279635",
"0.63274956",
"0.6300706",
"0.60699385",
"0.59637433",
"0.58243674",
"0.58243674",
"0.58243674",
"0.5777996",
"0.5763454",
"0.57205427",
"0.57137734",
"0.57137734",
"0.57137734",
"0.57137734",
"0.5706434",
"0.... | 0.60282665 | 8 |
Method validates a Contact for Manual Update | def validated_for_update?(c)
valid = true
if first_name.blank? && last_name.blank?
c.errors.add_to_base("Must enter contact name")
valid = false
end
ex_email = Contact.find(:first, :include => [:emails], :conditions => ["emails.email_text = ? AND contacts.user_id = ? AND contacts.id != ? AND merged_to_form_contact_id = 0", email, user_id, c.id])
if ex_email
c.errors.add_to_base("Contact already in network")
valid = false
end
valid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate\n validates_contact\n end",
"def validate\n if !new_record? && current?\n errors.add('contact_name', 'Please provide a contact name for your enquiry') unless contact_name.present?\n errors.add('contact_phone', 'Please provide a phone number where we may contact you at about your enq... | [
"0.70229536",
"0.63903046",
"0.6388088",
"0.6354135",
"0.6290593",
"0.62462604",
"0.6065871",
"0.60438716",
"0.60438716",
"0.60438716",
"0.6012076",
"0.5992357",
"0.5966696",
"0.5943815",
"0.59399045",
"0.5924662",
"0.5907218",
"0.59043497",
"0.58974147",
"0.5894543",
"0.5870... | 0.7387179 | 0 |
Method Returns Collection of Contacts that are suspected as duplicates in the Merge but not Merged. THis scenario does not occur now. | def duplicates
Contact.find(:all, :conditions => ["id != ? AND merge_id = ?", id, merge_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(contacts_with_dupes)\n group_by_email(contacts_with_dupes).flat_map do |_, contacts|\n contacts.sort_by! { |c| c[:date_added] }\n\n contacts.first.tap do |merged|\n contacts[1..-1].each do |newer|\n merged.keys.each do |key|\n merged[key] = newer[key] unless newer[... | [
"0.642129",
"0.63884264",
"0.6226378",
"0.62016684",
"0.6129265",
"0.6113292",
"0.59946615",
"0.5966752",
"0.59532094",
"0.5919953",
"0.5893186",
"0.580054",
"0.57838774",
"0.57540345",
"0.5693528",
"0.5678384",
"0.5638158",
"0.56254077",
"0.56212527",
"0.56030095",
"0.558354... | 0.7821992 | 0 |
Method Returns Collection of Contacts that were Merged to form the calling Contact | def parents
Contact.find(:all, :conditions => ["merged_to_form_contact_id = ?", self.id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contacts\n first_set = self.initiated_contacts\n second_set = self.received_contacts\n return first_set + second_set\n end",
"def contacts\n collection = CapsuleCRM::ContactCollection.new(self,CapsuleCRM::Contact, [])\n collection.concat emails\n collection.concat phone_numbers\n collec... | [
"0.7499693",
"0.70603544",
"0.6941987",
"0.6640651",
"0.664044",
"0.6612947",
"0.65297437",
"0.6513908",
"0.65033674",
"0.6486956",
"0.64663416",
"0.6463961",
"0.6399552",
"0.63609123",
"0.63422996",
"0.63251644",
"0.6323237",
"0.6290057",
"0.62756443",
"0.6255044",
"0.622678... | 0.6291385 | 17 |
Method To Unmerge Contact | def un_merge
Contact.transaction do
self.parents.each do |contact|
contact.update_attribute('merged_to_form_contact_id', 0)
if contact.contact_type == Constants::CONTACT_TYPE::PROSPECT
ContactProspect.update_all("prospect_old_id = NULL, prospect_id = #{contact.id}", "prospect_old_id = #{contact.id}")
else
ContactProspect.update_all("contact_old_id = NULL, contact_id = #{contact.id}", "contact_old_id = #{contact.id}")
end
end
self.emails.clear
self.sources.clear
self.contact_metas.clear
self.destroy_shares
self.destroy
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_tag_from_contact\n\t\t\t\t# unlike the remove method in account, this only removes the tag from one contact\n\t\t\t\t\n\t\t\tend",
"def unlink_contact(_contact)\n _rc = false\n if self.contacts.detect { |c| c._id ==_contact._id }\n _facility = self.facilities.any_in(consumer_ids: [_contact.... | [
"0.6606985",
"0.65824574",
"0.63902843",
"0.63557243",
"0.6297876",
"0.6173803",
"0.6135985",
"0.61075574",
"0.6054319",
"0.6038812",
"0.6034099",
"0.6012317",
"0.60014975",
"0.5994348",
"0.5992247",
"0.5987092",
"0.5949446",
"0.5891389",
"0.5891389",
"0.5889042",
"0.58774173... | 0.78927857 | 0 |
def set_company(company_name) if self.valid? unless company_name.nil? company_name = company_name.strip unless company_name.blank? company = Company.find_or_create_by_name company_name self.company_id = company.id self.company_name = company.name end end end end | def update_company company_name
if self.valid?
unless company_name.nil?
company_name = company_name.strip
if company_name.blank?
self.company_id = 0
self.company_name = ''
else
company = Company.find_or_create_by_name company_name
unless company.id == self.company_id
self.company_id = company.id
self.company_name = company.name
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_company_name\n @company_name = CompanyName.find(params[:id])\n end",
"def company=(company)\n super(Company.find_or_create_by_name(company))\n end",
"def company_name=(company_name)\n if !company_name.nil? && company_name.to_s.length < 0\n fail ArgumentError, 'invalid value for ... | [
"0.8134257",
"0.80279374",
"0.7890128",
"0.77635014",
"0.7657602",
"0.762966",
"0.7577724",
"0.75354016",
"0.751264",
"0.751264",
"0.7444966",
"0.735183",
"0.735183",
"0.735183",
"0.735183",
"0.735183",
"0.735183",
"0.735183",
"0.735183",
"0.735183",
"0.735183",
"0.735183",... | 0.87759185 | 0 |
Save titles for contact | def save_contact_titles(positions)
title_str= ''
positions.each_with_index do |position, index|
if position.is_current == 'true'
company = Company.find_or_create_by_name(position.company.name)
title = self.titles.build(:position => position.title, :company_id => company.id)
title_str += ', ' unless index == 0
title_str += "#{title.position} at #{company.name}"
end
end
self.update_attribute(:title, title_str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_titles\n # Title was submitted\n if self.title.blank?\n self.title = get_title_from_chartup(chartup) || 'Untitled'\n else\n set_chartup_title(self.title)\n end\n end",
"def set_saved_title\n @saved_title = SavedTitle.find(params[:id])\n end",
"def contact\n @title = \... | [
"0.6404645",
"0.6220932",
"0.61893195",
"0.6028167",
"0.59328157",
"0.59262687",
"0.5821474",
"0.5804921",
"0.5788068",
"0.57827574",
"0.5780047",
"0.57742757",
"0.5755893",
"0.57304657",
"0.5717839",
"0.57167625",
"0.57158715",
"0.5715551",
"0.57153976",
"0.57029545",
"0.569... | 0.75141835 | 0 |
The two methods 'default_chain' and 'default_tire_size' offers a way to provide specializations > line 31 and 49. | def initialize(**opts)
@size = opts[:size]
@chain = opts[:chain] || default_chain
@tire_size = opts[:tire_size] || default_tire_size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_tire_size\n raise NotImplementedError, \"This #{self.class} cannot respond to:\"\n end",
"def default_tire_size\n '23'\n end",
"def default_tire_size\n '2.1'\n end",
"def default_tire_size\n raise NotImplementedError, \n \"This #{self.class.to_s} can not respond_to :: #{__me... | [
"0.6421778",
"0.6192532",
"0.6043917",
"0.6030757",
"0.6030757",
"0.56372744",
"0.56372744",
"0.5530686",
"0.54070413",
"0.5393867",
"0.5338277",
"0.5338277",
"0.51637363",
"0.51445943",
"0.5060263",
"0.5060263",
"0.5060263",
"0.49945265",
"0.49917507",
"0.49617237",
"0.49232... | 0.6125143 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.