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 |
|---|---|---|---|---|---|---|
Save serialized attribute to cache. If serializer method or serialization block is not given, Ultracache tries to serialize the object by serializeing hash returned by its `as_json` method. | def save_cache(obj)
value = if @serializer_method
serializer.serialize(obj.send(@serializer_method))
elsif @serializing_block
serializer.serialize(@serializing_block.call(obj))
else
serializer.serialize(obj.as_json)
end
storage.set(key(obj), value)
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_serialize(key, serializer: ActiveModel::ArraySerializer, json_opts: {}, &block)\n cache(key) { serialize(serializer: serializer, json_opts: json_opts, &block) }\n end",
"def write\n hash = attributes_hash\n write_value(serializer_class.dump(hash))\n @_cache = hash # set... | [
"0.72712463",
"0.7095984",
"0.69161844",
"0.5956073",
"0.5825795",
"0.5731434",
"0.56962436",
"0.56694424",
"0.55922",
"0.5510292",
"0.54900897",
"0.5483556",
"0.5483556",
"0.54575866",
"0.5448683",
"0.540787",
"0.54075634",
"0.5387215",
"0.5352197",
"0.5343216",
"0.53388435"... | 0.77806485 | 0 |
Read stored cache from storage. If the cache is not found, it tries to save corresponding cache to storage and return its value | def read_cache(obj, options = {})
k = key(obj)
ret = storage.get(k) || save_cache(obj)
if options[:deserialized]
serializer.deserialize(ret)
else
ret
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_from_cache\n result = if cache.is_a?(Proc)\n cache.call(nil)\n elsif File.exist?(cache.to_s)\n File.read(cache)\n end\n result if valid_rates?(result)\n end",
"def read_cache\n @cache_file = select_cache_file\n ... | [
"0.7634855",
"0.7406886",
"0.71576154",
"0.71402454",
"0.7024966",
"0.7009828",
"0.6981973",
"0.6981435",
"0.6957603",
"0.69345176",
"0.6887714",
"0.6865395",
"0.68627435",
"0.6789637",
"0.6789637",
"0.6789637",
"0.6789637",
"0.6789637",
"0.6789637",
"0.6789637",
"0.6789637",... | 0.72363186 | 2 |
Destroys cache from storage | def destroy_cache(obj)
storage.del(key(obj))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_clear\n @store.delete\n end",
"def destroy\n delete!(get, phase: :destroyed) if get && !cache.uploaded?(get)\n end",
"def cache_clear\n @store.clear\n end",
"def cache_clear\n @dataset.delete\n end",
"def cache_clear\n @dataset.delete\n ... | [
"0.77374905",
"0.7639924",
"0.7367089",
"0.7342189",
"0.7342189",
"0.7297336",
"0.7297336",
"0.72606885",
"0.72606885",
"0.7221525",
"0.7219844",
"0.7205838",
"0.7205838",
"0.72021604",
"0.719867",
"0.71892095",
"0.71892095",
"0.7174867",
"0.71665406",
"0.71665174",
"0.716614... | 0.82391334 | 0 |
Updates value of existing cache. Its behavior is same with that of `save_cache`. | def update_cache(obj)
save_cache(obj)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_cache\n # Does nothing...up to subclasses to implement.\n end",
"def set_cache(value); end",
"def set_cache(value); end",
"def set_cache\n cache_key = self.class.cache_key(self.key)\n Rails.cache.write(cache_key, self.actual_value)\n end",
"def update_cache(type, id, dat... | [
"0.7836948",
"0.75574094",
"0.75574094",
"0.7305472",
"0.7301359",
"0.7301359",
"0.7288954",
"0.7223188",
"0.71811163",
"0.717196",
"0.7152517",
"0.7129033",
"0.7072834",
"0.70043796",
"0.69305825",
"0.68115866",
"0.6740709",
"0.6729932",
"0.6726854",
"0.67143255",
"0.6713984... | 0.7672664 | 1 |
Adds a where condition that requires column to contain key Example: User.hstore_has_key(:properties, "favorite_color") | def hstore_has_key(column, key)
where("#{connection.quote_column_name(column)} ? :key", :key => key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hstore_has_any_keys(column, *keys)\n where(\"#{connection.quote_column_name(column)} ?| ARRAY[:keys]\", :keys => keys.flatten)\n end",
"def hstore_has_all_keys(column, *keys)\n where(\"#{connection.quote_column_name(column)} ?& ARRAY[:keys]\", :keys => keys.flatten)\n end",
"def se... | [
"0.7161256",
"0.7025353",
"0.63294756",
"0.62365425",
"0.617708",
"0.61253405",
"0.6086603",
"0.6018537",
"0.5920791",
"0.5895221",
"0.58656144",
"0.5843804",
"0.5765473",
"0.57418346",
"0.5711226",
"0.56885314",
"0.5677917",
"0.5673337",
"0.5644449",
"0.5629177",
"0.56104684... | 0.8315779 | 0 |
Adds a where condition that requires column to contain all keys. Example: User.hstore_has_all_keys(:properties, "favorite_color", "favorite_song") User.hstore_has_all_keys(:properties, ["favorite_color", "favorite_song"]) | def hstore_has_all_keys(column, *keys)
where("#{connection.quote_column_name(column)} ?& ARRAY[:keys]", :keys => keys.flatten)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hstore_has_any_keys(column, *keys)\n where(\"#{connection.quote_column_name(column)} ?| ARRAY[:keys]\", :keys => keys.flatten)\n end",
"def all?(*keys)\n keys.flatten!\n if keys.any?\n # Check only the specified keys\n valid = true\n keys.each do |key|\n un... | [
"0.7869474",
"0.6374922",
"0.63405627",
"0.6193158",
"0.5560081",
"0.55010927",
"0.5499895",
"0.5454974",
"0.54354656",
"0.54081637",
"0.533416",
"0.5332656",
"0.5309972",
"0.5287408",
"0.5281288",
"0.52629673",
"0.5260552",
"0.52523375",
"0.52488273",
"0.52488273",
"0.524520... | 0.85074276 | 0 |
Adds a where condition that requires column to contain any keys. Example: User.hstore_has_any_keys(:properties, "favorite_color", "favorite_song") User.hstore_has_any_keys(:properties, ["favorite_color", "favorite_song"]) | def hstore_has_any_keys(column, *keys)
where("#{connection.quote_column_name(column)} ?| ARRAY[:keys]", :keys => keys.flatten)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hstore_has_all_keys(column, *keys)\n where(\"#{connection.quote_column_name(column)} ?& ARRAY[:keys]\", :keys => keys.flatten)\n end",
"def hstore_has_key(column, key)\n where(\"#{connection.quote_column_name(column)} ? :key\", :key => key) \n end",
"def includes!(*keys)\n key... | [
"0.82035935",
"0.6901664",
"0.58999807",
"0.5833533",
"0.57246804",
"0.56622756",
"0.56490844",
"0.5628387",
"0.56015944",
"0.55385166",
"0.55337644",
"0.55140793",
"0.55062175",
"0.55020326",
"0.5426738",
"0.5420755",
"0.54157066",
"0.54004425",
"0.5396012",
"0.5326123",
"0.... | 0.8535087 | 0 |
=== class self === | def generate_trash_msg name_or_row
if name_or_row[:screen_name]
name = name_or_row[:screen_name]
r = name_or_row
else
name = name_or_row
r = screen_name_row(name)
end
if !r[:trashed_at]
r[:trash_msg] = nil
else
durs = Duration(Date(Date.now()), reltime.parse(r[:trashed_at], "48 hours"))
is_past = durs.days < 1 && durs.hour < 1 && durs.minute < 1
r[:trash_msg] = "Screen name, #{r[:screen_name]}"
if is_past
r[:trash_msg] += ", has been deleted. There is no undo."
else
r[:trash_msg] += ", has been put in trash."
r[:trash_msg] += " You have #{human_durs(durs)} from now to change your mind before it gets completely deleted."
end
end
r[:trash_msg]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def self\n @define_self = true",
"def +@\n self\n end",
"def +@\n self\n end",
"def initialize\n \n end",
"def itself\n self\n end",
"def initialize\n \n end",
"def class() end",
"def instance; end",
"def instance; end",
"def instance; end",
"def +@\n ... | [
"0.7404072",
"0.7157451",
"0.7157451",
"0.70814174",
"0.70460916",
"0.7020951",
"0.7002936",
"0.69723505",
"0.69723505",
"0.69723505",
"0.6971006",
"0.68950486",
"0.6827849",
"0.6827849",
"0.6827849",
"0.67618054",
"0.67618054",
"0.67489433",
"0.6727581",
"0.6727581",
"0.6686... | 0.0 | -1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.matrix_mailer.meta.subject | def meta matrix, level
@matrix = matrix
@user = matrix.user
@level = level
headers={:to => @user.email1, :subject => "#{CFG['domain']} - Matriz Nível #{level} Concluído"}
bccs=[]
bccs << @user.email2 if @user.email2.present?
bccs << CFG['email-contact']
headers[:bcc] = bccs
mail(headers)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subject\n self['subject'] || msg['subject']\n end",
"def message_subject=(value)\n @message_subject = value\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def subject (recipient)\n subject_variables = alert_v... | [
"0.74098873",
"0.7382836",
"0.7265705",
"0.717668",
"0.7164395",
"0.7128298",
"0.70913327",
"0.70273864",
"0.7011883",
"0.6997065",
"0.6899257",
"0.68102396",
"0.67520374",
"0.6746883",
"0.674433",
"0.66709965",
"0.66111887",
"0.6583207",
"0.6582169",
"0.6571861",
"0.6502308"... | 0.0 | -1 |
Handles 429 API exception | def method_missing(method_name, *args, &block)
if respond_to_missing?(method_name)
handle_known_exceptions do
@target.send(method_name, *args, &block)
end
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate_limit_check\n status = 200\n result = {}\n if rate_limit_on?\n if rate_limit_left > 0\n status = 429\n result[:error] = \"you need to wait #{rate_limit_left} ms before you can request anything again\"\n render status: status, json: result\n end\n end\n end",
"... | [
"0.6966554",
"0.6883952",
"0.6824011",
"0.6590152",
"0.6247385",
"0.62343496",
"0.6149302",
"0.5975909",
"0.5969418",
"0.59685695",
"0.59423184",
"0.5923473",
"0.59125584",
"0.5834165",
"0.5819871",
"0.575858",
"0.5747611",
"0.57061285",
"0.57009286",
"0.568927",
"0.56852686"... | 0.0 | -1 |
GET /step_types/1 GET /step_types/1.json | def show
@step_type = StepType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @step_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @step_type = StepType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @step_type }\n end\n end",
"def create\n @step_type = StepType.new(params[:step_type])\n\n respond_to do |format|\n if @step_type.save\n format.html { red... | [
"0.6964311",
"0.6590116",
"0.6362077",
"0.6362077",
"0.6362077",
"0.634966",
"0.6285838",
"0.6202415",
"0.61591583",
"0.61391413",
"0.61174864",
"0.597262",
"0.596985",
"0.58601964",
"0.5823646",
"0.58206195",
"0.5760642",
"0.57427734",
"0.57333934",
"0.57313234",
"0.5725373"... | 0.7449065 | 0 |
GET /step_types/new GET /step_types/new.json | def new
@step_type = StepType.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @step_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @step_type = StepType.new(params[:step_type])\n\n respond_to do |format|\n if @step_type.save\n format.html { redirect_to @step_type, notice: 'Step type was successfully created.' }\n format.json { render json: @step_type, status: :created, location: @step_type }\n else\n... | [
"0.76615024",
"0.7597696",
"0.74612314",
"0.7019332",
"0.70115805",
"0.69151366",
"0.68753594",
"0.6815718",
"0.6806939",
"0.6787319",
"0.6787308",
"0.67831624",
"0.6751571",
"0.66968924",
"0.66862106",
"0.6644399",
"0.66320115",
"0.6618037",
"0.6597929",
"0.6593064",
"0.6590... | 0.8258794 | 0 |
POST /step_types POST /step_types.json | def create
@step_type = StepType.new(params[:step_type])
respond_to do |format|
if @step_type.save
format.html { redirect_to @step_type, notice: 'Step type was successfully created.' }
format.json { render json: @step_type, status: :created, location: @step_type }
else
format.html { render action: "new" }
format.json { render json: @step_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @step_type = StepType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @step_type }\n end\n end",
"def create\n\n step_attributes = step_params\n fields_attributes = step_attributes.delete(\"fields\")\n\n @step = Step.new(step_attribu... | [
"0.6301478",
"0.6165463",
"0.61133933",
"0.60096407",
"0.59759814",
"0.5933946",
"0.5898706",
"0.582284",
"0.5800694",
"0.57337314",
"0.57299453",
"0.57114893",
"0.57070243",
"0.5701471",
"0.5695857",
"0.5693313",
"0.5657367",
"0.5655584",
"0.5653112",
"0.55918777",
"0.558468... | 0.72749895 | 0 |
PUT /step_types/1 PUT /step_types/1.json | def update
@step_type = StepType.find(params[:id])
respond_to do |format|
if @step_type.update_attributes(params[:step_type])
format.html { redirect_to @step_type, notice: 'Step type was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @step_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @step_type = StepType.new(params[:step_type])\n\n respond_to do |format|\n if @step_type.save\n format.html { redirect_to @step_type, notice: 'Step type was successfully created.' }\n format.json { render json: @step_type, status: :created, location: @step_type }\n else\n... | [
"0.6641828",
"0.64360684",
"0.6363463",
"0.63611674",
"0.63611674",
"0.63441116",
"0.6302788",
"0.62916106",
"0.6289646",
"0.62329584",
"0.6131726",
"0.61298335",
"0.6120811",
"0.6112716",
"0.6078138",
"0.6056743",
"0.60472655",
"0.6023685",
"0.5924834",
"0.5923892",
"0.59079... | 0.7451496 | 0 |
DELETE /step_types/1 DELETE /step_types/1.json | def destroy
@step_type = StepType.find(params[:id])
@step_type.destroy
respond_to do |format|
format.html { redirect_to step_types_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @step = Step.find(params[:id])\n @step.status = \"deleted\"\n @step.save!\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def destroy\n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html ... | [
"0.7551166",
"0.73224986",
"0.7266624",
"0.722744",
"0.70581967",
"0.70506763",
"0.70506763",
"0.70506763",
"0.70506763",
"0.6985755",
"0.69536024",
"0.6950195",
"0.69379926",
"0.6921468",
"0.69162726",
"0.68899816",
"0.6863857",
"0.6846205",
"0.68428344",
"0.6841495",
"0.683... | 0.81487787 | 0 |
added namespaces to make root element compliant with Intuit's expectation | def post_save xml, options={:mapping=>:_default}
# using REXML's element namespace method doesn't seem to set the namespace correctly...?
xml.root.add_attributes("xmlns"=>"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1")
xml.root.add_namespace "xsi", "http://www.w3.org/2001/XMLSchema-instance"
xml.root.add_namespace "xsd", "http://www.w3.org/2001/XMLSchema"
# for challengeResponses/response
xml.each_element("//response") do |x|
x.add_namespace "v11", "http://schema.intuit.com/platform/fdatafeed/challenge/v1"
x.name = "v11:response"
end
# for challengeResponses root
xml.each_element("//challengeResponses") do |x|
x.add_namespace "v1", "http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1"
x.name = "challengeResponses"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_save xml, options={:mapping=>:_default}\n # using REXML's element namespace method doesn't seem to set the namespace correctly...?\n xml.root.add_attributes(\"xmlns\"=>\"http://schema.intuit.com/platform/fdatafeed/institutionlogin/v1\")\n xml.root.add_namespace \"xsi\", \"http://www.w3.org/... | [
"0.5956942",
"0.58077854",
"0.57177633",
"0.55588984",
"0.5534406",
"0.55242664",
"0.55207837",
"0.55207837",
"0.551308",
"0.5478807",
"0.5478807",
"0.5478807",
"0.5478807",
"0.54777044",
"0.54416996",
"0.54332113",
"0.5431981",
"0.5431981",
"0.5431981",
"0.5431981",
"0.54319... | 0.6010139 | 0 |
Produces a random hipster word. | def words(number: 3, supplemental: false, spaces_allowed: false)
resolved_num = resolve(number)
word_list = (
translate('faker.hipster.words') +
(supplemental ? translate('faker.lorem.words') : [])
)
word_list *= ((resolved_num / word_list.length) + 1)
return shuffle(word_list)[0, resolved_num] if spaces_allowed
words = shuffle(word_list)[0, resolved_num]
words.each_with_index { |w, i| words[i] = word if w =~ /\s/ }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_word(lexicon)\n lexicon[rand(lexicon.length)] \n end",
"def meow()\n punctuations = '.!?'\n \"#{CAT_FACES[rand(CAT_FACES.length)]} Meow#{punctuations[rand(punctuations.length)]}\"\n end",
"def draw_word\n @words.sample(random: Ibsenphrase::Random.prng)\n end",
"def ge... | [
"0.7329372",
"0.719475",
"0.7166729",
"0.71409506",
"0.71236694",
"0.7115318",
"0.71099776",
"0.7083553",
"0.70009816",
"0.6991444",
"0.69467294",
"0.69446117",
"0.6934279",
"0.69256085",
"0.6901431",
"0.6901431",
"0.6901431",
"0.6901431",
"0.68891466",
"0.6854832",
"0.677814... | 0.0 | -1 |
Produces a random hipster sentence. | def sentence(word_count: 4, supplemental: false, random_words_to_add: 6, open_compounds_allowed: true)
"#{words(number: word_count + rand(random_words_to_add.to_i).to_i, supplemental: supplemental, spaces_allowed: open_compounds_allowed).join(' ').capitalize}."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def greeting\n\t\t# array of greetings and offers\n\t\tgreetings = [\"Hey!\", \"Hello!\", \"Good day!\", \"Greetings!\", \"Hi!\"]\n\t\toffer = [\"Can I help you?\", \"How can I help you?\", \"Do you need help?\", \"What can I help you with?\"]\n\t\t\n\t\t# construct random sentence\n\t\tg = greetings.sample\n\t\to... | [
"0.72986364",
"0.7148672",
"0.7054251",
"0.69198376",
"0.68773943",
"0.68484634",
"0.68423295",
"0.68243384",
"0.6807947",
"0.6800157",
"0.6774296",
"0.6761098",
"0.6758054",
"0.6754696",
"0.67369735",
"0.6720161",
"0.67163366",
"0.66603583",
"0.66225445",
"0.66163963",
"0.65... | 0.70724386 | 2 |
Produces random hipster sentences. | def sentences(number: 3, supplemental: false)
[].tap do |sentences|
1.upto(resolve(number)) do
sentences << sentence(word_count: 3, supplemental: supplemental)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)\n sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')\n end",
"def random_p\n \"<p>#{texter.random_paragraph}</p>\"\n end",
"def greeting\n\t\... | [
"0.71639436",
"0.70488733",
"0.7047451",
"0.67547226",
"0.67358375",
"0.6699973",
"0.6653218",
"0.6632277",
"0.66168106",
"0.65912986",
"0.6577314",
"0.65712744",
"0.6570623",
"0.65478563",
"0.65456074",
"0.6529778",
"0.649119",
"0.64764905",
"0.6475702",
"0.6467796",
"0.6457... | 0.0 | -1 |
Produces a random hipster paragraph. | def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)
sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_p\n \"<p>#{texter.random_paragraph}</p>\"\n end",
"def random_h( level = 1 )\n \"<h#{level}>#{texter.random_title}</h#{level}>\"\n end",
"def paragraph(\n word_count: rand(DEFAULT_WORD_COUNT_RANGE),\n sentence_count: rand(DEFAULT_SENTENCE_COUNT_RANGE),\n fillers: dictionnary.f... | [
"0.8400888",
"0.6910858",
"0.68437576",
"0.6598232",
"0.6574919",
"0.6535877",
"0.65357983",
"0.6521251",
"0.65000004",
"0.6478271",
"0.6383488",
"0.63128096",
"0.62859225",
"0.6263237",
"0.62630796",
"0.6235404",
"0.6212816",
"0.61507505",
"0.61499673",
"0.6144582",
"0.60971... | 0.73073816 | 1 |
Produces random hipster paragraphs. | def paragraphs(number: 3, supplemental: false)
[].tap do |paragraphs|
1.upto(resolve(number)) do
paragraphs << paragraph(sentence_count: 3, supplemental: supplemental)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_p\n \"<p>#{texter.random_paragraph}</p>\"\n end",
"def paragraph(sentence_count: 3, supplemental: false, random_sentences_to_add: 3)\n sentences(number: resolve(sentence_count) + rand(random_sentences_to_add.to_i).to_i, supplemental: supplemental).join(' ')\n end",
"def paragraphs(\n... | [
"0.81631213",
"0.7289829",
"0.70642257",
"0.68093425",
"0.67804617",
"0.6730128",
"0.6518558",
"0.64695597",
"0.645019",
"0.6369808",
"0.6351823",
"0.6300395",
"0.6265605",
"0.6253907",
"0.62310404",
"0.61243844",
"0.61080277",
"0.6100133",
"0.6075771",
"0.60674274",
"0.60540... | 0.6008029 | 22 |
Produces a random hipster paragraph by characters. | def paragraph_by_chars(characters: 256, supplemental: false)
paragraph = paragraph(sentence_count: 3, supplemental: supplemental)
paragraph += " #{paragraph(sentence_count: 3, supplemental: supplemental)}" while paragraph.length < characters
"#{paragraph[0...characters - 1]}."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_p\n \"<p>#{texter.random_paragraph}</p>\"\n end",
"def reproduce(p)\n copy = @chars.map do |c|\n if rand < p\n (c.ord + (rand <=> 0.5)).clamp(A, Z).chr\n else\n c\n end\n end\n self.class.new(copy)\n end",
"def rand_char\n @chars.sample\n end",
"d... | [
"0.7406626",
"0.6741285",
"0.66714346",
"0.6659473",
"0.65968525",
"0.6595556",
"0.65332294",
"0.65306276",
"0.6473004",
"0.646723",
"0.64242655",
"0.64209163",
"0.6366262",
"0.63505095",
"0.6313722",
"0.6274928",
"0.62504464",
"0.6241987",
"0.62392205",
"0.6238755",
"0.62331... | 0.7069037 | 1 |
DBD/Pg on some system Helpers to play with PostgreSQL sequences. | def currval(seq)
$new.select_one("SELECT CASE WHEN is_called THEN last_value ELSE last_value-increment_by END from #{seq}")[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uses_sequence\n select_value(\"SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';\")\n end",
"def pk_and_sequence_for(table)\n # try looking for a seq with a dependency on the table's primary key :\n result = select(<<-end_sql, 'PK and Serial Sequence')[0]\n ... | [
"0.64209497",
"0.63819104",
"0.6340135",
"0.62604934",
"0.6162698",
"0.61372364",
"0.6084514",
"0.59771466",
"0.5945088",
"0.58631194",
"0.5854936",
"0.5750588",
"0.57127696",
"0.57113534",
"0.56986827",
"0.5697025",
"0.56490433",
"0.5622328",
"0.5544973",
"0.5526736",
"0.551... | 0.0 | -1 |
validates :phone_number, phone: true | def full_name
self.first_name + ' ' + self.last_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_phone_number\n\t\tnumber = self.number.scan(/\\d/).join('')\n\t\tnumber[0] = '' if number[0] == \"1\"\n\n\t\tif number.length != 10\n\t\t\terrors.add(:phone, \"must be a valid 10 digit phone number\")\n\t\telse\n\t\t\tself.number = number\n\t\tend\n\tend",
"def parent_phone_is_valid\n errors.add(:pa... | [
"0.8267175",
"0.8099236",
"0.79389894",
"0.769612",
"0.76796526",
"0.76795036",
"0.7674642",
"0.7639494",
"0.7552082",
"0.7538909",
"0.74736667",
"0.7385529",
"0.7362493",
"0.72574764",
"0.7242357",
"0.6983831",
"0.6983831",
"0.6972526",
"0.69603044",
"0.6946785",
"0.69310415... | 0.0 | -1 |
POST /applicants POST /applicants.json | def create
@applicant = Applicant.new(applicant_params)
respond_to do |format|
if @applicant.save
format.html { redirect_to @application_case, notice: 'Applicant was successfully created.' }
format.json { render :show, status: :created, location: @applicant }
else
format.html { render :new }
format.json { render json: @applicant.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_user_for_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/users\", args)\nend",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def create\n @applicant = Applicant.new(params[:applicant])\n\n respond_to do |format|\n if @applicant.save\n f... | [
"0.63766336",
"0.63649476",
"0.6329159",
"0.6157046",
"0.60662836",
"0.5959357",
"0.5939169",
"0.58537537",
"0.58107126",
"0.5802765",
"0.5802765",
"0.57628757",
"0.57459277",
"0.57352346",
"0.56456345",
"0.5602937",
"0.55770916",
"0.5568196",
"0.55595535",
"0.5551981",
"0.55... | 0.56764364 | 14 |
PATCH/PUT /applicants/1 PATCH/PUT /applicants/1.json | def update
respond_to do |format|
if @applicant.update(applicant_params)
format.html { redirect_to @applicant, notice: 'Applicant was successfully updated.' }
format.json { render :show, status: :ok, location: @applicant }
else
format.html { render :edit }
format.json { render json: @applicant.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @applicant = Applicant.find(params[:id])\n\n respond_to do |format|\n if @applicant.update_attributes(params[:applicant])\n format.html { redirect_to admin_url(current_user.id), notice: 'Applicant was successfully updated.' }\n format.json { head :no_content }\n else\n ... | [
"0.6438407",
"0.6377001",
"0.63004726",
"0.62958455",
"0.6288469",
"0.62565386",
"0.6255666",
"0.62186205",
"0.60883737",
"0.60352004",
"0.60230803",
"0.60047716",
"0.60047716",
"0.60047716",
"0.6001481",
"0.6001481",
"0.59817284",
"0.59808546",
"0.5933867",
"0.5930248",
"0.5... | 0.61562353 | 9 |
DELETE /applicants/1 DELETE /applicants/1.json | def destroy
@application_case = @applicant.application_case
@user_applicant = @applicant
@user = @user_applicant.user
@agent = @user.client_agent.agent
ApplicationCaseMailer.notify_removed_agent(@agent, current_user, @application_case).deliver
ApplicationCaseMailer.notify_removed_applicant(@user_applicant.user, current_user, @application_case).deliver
@applicant.destroy
respond_to do |format|
format.html { redirect_to @application_case, notice: 'Applicant was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:id]... | [
"0.7216211",
"0.71124244",
"0.7110667",
"0.6986516",
"0.6986516",
"0.6846551",
"0.68246",
"0.6770803",
"0.66730756",
"0.6643646",
"0.6630965",
"0.6613308",
"0.66049236",
"0.66049236",
"0.66049236",
"0.66049236",
"0.66049236",
"0.6595776",
"0.6565704",
"0.6513114",
"0.6498793"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_applicant
@applicant = Applicant.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.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def applicant_params
params.require(:applicant).permit(:application_case_id, :user_id, :as_role)
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 |
Toggle the visibility of the element, hide it if it's shown, show it if it's hidden. | def toggle
if style![:display] == :none
show
else
hide
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toggle\n if visible?\n hide\n\n else\n show\n\n end\n end",
"def toggle\n style[:hidden] = !style[:hidden]\n update_visibility\n end",
"def link_to_visibility_toggle(options = {})\r\n options[:of] ||= '$(this.parentNode).next()'\r\n options[:... | [
"0.8281702",
"0.7527834",
"0.6910811",
"0.6806435",
"0.67665976",
"0.65891856",
"0.64851594",
"0.6400037",
"0.63962513",
"0.63899195",
"0.63899195",
"0.6312003",
"0.6310687",
"0.6251728",
"0.6216467",
"0.6182969",
"0.6141018",
"0.61338073",
"0.6065034",
"0.6044346",
"0.604434... | 0.75500757 | 1 |
Set the focus on the element. | def focus
`#@native.focus()`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def focus\n assert_exists\n driver.execute_script \"return arguments[0].focus()\", @element\n end",
"def focus\n assert_exists\n driver.execute_script \"return arguments[0].focus()\", @element\n end",
"def focus=(element)\n @focus.publish(:blur) if @focus && element && @focus != ... | [
"0.79769933",
"0.79769933",
"0.76388127",
"0.75656974",
"0.7477151",
"0.7346057",
"0.70663726",
"0.70535797",
"0.70535797",
"0.698406",
"0.68549675",
"0.6791009",
"0.67833686",
"0.6746829",
"0.6705154",
"0.6682076",
"0.6647243",
"0.6589346",
"0.6583605",
"0.65806955",
"0.6549... | 0.6611179 | 17 |
Blur the focus from the element. | def blur
`#@native.blur()`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def blur(locator)\n execute_script(\n 'var element = arguments[0]; element.blur();',\n find_element(locator)\n )\n end",
"def blur!\n self.update_attribute :focus, 0\n end",
"def blur(node)\n trigger(node, 'blur')\n\n Capybara.current_session.execute_script(\"document.body.click()\")... | [
"0.73862195",
"0.73538655",
"0.7001298",
"0.5909396",
"0.5713653",
"0.5680156",
"0.5680156",
"0.5527219",
"0.49778318",
"0.48970896",
"0.4865985",
"0.48241368",
"0.4745984",
"0.47098848",
"0.4642637",
"0.45500273",
"0.45393717",
"0.45031103",
"0.44316432",
"0.44047546",
"0.43... | 0.66816276 | 3 |
Check if the element is focused. | def focused?
`#@native.hasFocus`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def focused?\n @focus\n end",
"def focused?\n @focus\n end",
"def focus?\n (self.focus > 0) ? true : false\n end",
"def focused?\n UiaDll::is_focused(search_information)\n end",
"def focused?\n application.focused == self # TODO: application.focused?(self)\n end"... | [
"0.822994",
"0.822994",
"0.77647793",
"0.76823133",
"0.75927454",
"0.73038787",
"0.6812627",
"0.64203876",
"0.64198387",
"0.6292686",
"0.6292686",
"0.62880826",
"0.6261914",
"0.6245992",
"0.6245992",
"0.58594835",
"0.5815096",
"0.5726464",
"0.56532604",
"0.5603976",
"0.560396... | 0.7417785 | 5 |
Click the element. it fires the element's click event. | def click
`#@native.click()`
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def click(driver = $focus_driver)\r\n begin\r\n driver.find_element(self).click\r\n Log.info(\"Element clicked #{self.how} => #{self.what}\")\r\n rescue StandardError => e\r\n Log.fail(\"Element not clicked #{self.how} => #{self.what}\" + e.message)\r\n end\r\n end",
"def on_click(elem)\... | [
"0.7941502",
"0.7823945",
"0.7637481",
"0.760593",
"0.7421043",
"0.740068",
"0.73759776",
"0.73631793",
"0.7246927",
"0.7201121",
"0.7102807",
"0.70962864",
"0.7009745",
"0.70016927",
"0.69907963",
"0.69907963",
"0.69907963",
"0.69814605",
"0.6976918",
"0.6950351",
"0.6935895... | 0.67603886 | 35 |
Must have these methods defined in child classes graph.edge(i,j) graph.set_edge(i,j,value) graph.set_dir_edge(i,j,value) graph.reorder(permutation) graph.resize(i) | def edge?(i,j)
if(edge(i,j) != @no_edge_val)
return true
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_edge\n\t\t\traise NotImplementedError.new('#new_edge must be implemented')\n\t\tend",
"def initialize(edge, v1, v2)\n \t@edge = edge ##child (orignial Edge, it is first parameter)\n @v1 = v1\n @v2 = v2\n\n #each use increase degree, later it will help to find ofphans and junctions\n @v1.incr... | [
"0.64724076",
"0.62933224",
"0.6125629",
"0.60036695",
"0.590216",
"0.5891347",
"0.5845129",
"0.58077157",
"0.58077043",
"0.5782035",
"0.56905204",
"0.5683418",
"0.5658133",
"0.5655055",
"0.5650535",
"0.5634654",
"0.56316066",
"0.56226563",
"0.56210244",
"0.56096053",
"0.5599... | 0.0 | -1 |
returns the instances that match vendor_id (based on given prod id) | def vendor
FarMar::Vendor.all.find {|instance| instance.id == vendor_id}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def products\n FarMar::Product.all.select { |product| product.vendor_id == id }\n end",
"def products(ven_id)\n FarMar::Product.all.find_all { |product| product.vendor_id == ven_id }\n end",
"def products\n Product.find_by_vendor(@id)\n end",
"def products\n Product.find_all_by_vendor_id(... | [
"0.75932205",
"0.7452195",
"0.70700675",
"0.70386106",
"0.699669",
"0.6976406",
"0.6976406",
"0.6946011",
"0.6946011",
"0.69217175",
"0.68721664",
"0.68226916",
"0.6812798",
"0.6797201",
"0.67617446",
"0.66501224",
"0.6615321",
"0.6529921",
"0.6514067",
"0.6431453",
"0.642903... | 0.71530586 | 2 |
returns all of the sales that match the given prod id | def sales
FarMar::Sale.all.find_all {|instance| instance.product_id == id}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sales\n FarMar::Sale.all.find_all { |sale| sale.product_id == id }\n end",
"def sales\n FarMar::Sale.all.select { |sale| sale.product_info == product_id }\n end",
"def sales(assoc_product_id)\n assoc_sales = []\n FarMar::Sale.all.each do |sale|\n if sale.product_id.to_i == assoc_prod... | [
"0.81774527",
"0.80818695",
"0.7974159",
"0.79155743",
"0.7756965",
"0.7746877",
"0.763679",
"0.75372213",
"0.7447362",
"0.7313201",
"0.728974",
"0.71746176",
"0.715492",
"0.7005977",
"0.6799464",
"0.65683895",
"0.6558777",
"0.6558777",
"0.6541912",
"0.6534897",
"0.6332224",
... | 0.8307875 | 0 |
returns the num of times this product has been sold | def number_of_sales
sales.length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_sales #returns the number of times this product has been sold.\n\t\tsales\n\t\treturn sales.length\n\n\tend",
"def number_of_sales\n return sales.length\n # counter = 0\n # FarMar::Sale.all.each do |i|\n # if i.product_id == self.id\n # counter += 1\n # end\n # end\n ... | [
"0.8317405",
"0.7820133",
"0.76945615",
"0.76118433",
"0.76040465",
"0.75921386",
"0.75391406",
"0.75391406",
"0.74342734",
"0.74342734",
"0.74297756",
"0.7400201",
"0.7387079",
"0.72787774",
"0.7268433",
"0.7245668",
"0.72424877",
"0.7076527",
"0.7005647",
"0.69206655",
"0.6... | 0.7245441 | 17 |
Only allow a trusted parameter "white list" through. | def employee_params
params.require(:employee).permit(:name, :user_id, :position)
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 |
given a number n find out whether there are two numbers a,b present in an array so that a + b = n the problem asks for a two sum problem but there is actually a linear solution possible. just store the elements into a set. iterate over the array and check n element is part of the array. | def two_sum(arr, target)
a = arr.sort
low = 0
high = arr.length - 1
while(low < high)
sum = arr[low] + arr[high]
if sum == target
return true
elsif(sum < target)
low += 1
else
high -= 1
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_to_n? arr, n\n !!arr.uniq.combination(2).detect { |x, y| x + y == n }\nend",
"def sum_to_n?(int_array, n)\n return false unless int_array.respond_to?(:combination)\n \n int_array.uniq.combination(2).detect {|arr| sum(arr) == n }\nend",
"def sum_to_n?(array,n)\n if array.empty? || array.count =... | [
"0.7713251",
"0.77088434",
"0.7668214",
"0.76196426",
"0.7612828",
"0.7594801",
"0.7593281",
"0.7590625",
"0.7590257",
"0.75550324",
"0.7524307",
"0.74887174",
"0.7468222",
"0.74662125",
"0.74547887",
"0.7417118",
"0.7408233",
"0.7387673",
"0.73286563",
"0.7324249",
"0.731490... | 0.0 | -1 |
Return boolean value of the number. Return true if the number is greater than 0. | def of_number(val)
val > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def positive? number\n return number > 0 ? true : false\n end",
"def greater_than_zero?\n return false if nil?\n to_i.positive?\n end",
"def less_than_or_equal_to_zero(num)\n\treturn num <= 0 ? true : false\nend",
"def of_number(val)\n val > 0\n end",
"def negative? (numb... | [
"0.82104343",
"0.80496013",
"0.79177475",
"0.7828161",
"0.75500095",
"0.7545961",
"0.7412908",
"0.7400805",
"0.73893434",
"0.7357297",
"0.7357297",
"0.7314836",
"0.7293142",
"0.7236695",
"0.7232903",
"0.7210341",
"0.7146944",
"0.71455485",
"0.7144795",
"0.7144795",
"0.7136047... | 0.771585 | 4 |
GET /journals GET /journals.json | def index
if User.current.allowed_to?(:manage_roles)
@journals = Journal.order('id DESC').paginate(page: params[:page], per_page: 25)
else
@journals = Journal.where(assigned_to_id: User.current.id ).order('id DESC').paginate(page: params[:page], per_page: 25)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meals\n get(\"/user/#{@user_id}/meals.json\")\n end",
"def list\n @journals = Journal.all\n end",
"def index\n @journals = Journal.all\n respond_with(@user,@journals)\n end",
"def index\n @journals = Journal.all\n end",
"def index\n @journals = Journal.all\n end",
"def inde... | [
"0.74717534",
"0.72880185",
"0.7284204",
"0.705705",
"0.705705",
"0.705705",
"0.6902717",
"0.6870733",
"0.6844702",
"0.6813594",
"0.67545176",
"0.66743195",
"0.659527",
"0.6574649",
"0.65429664",
"0.6512185",
"0.64878213",
"0.6410139",
"0.63795763",
"0.6369896",
"0.6337413",
... | 0.58048606 | 81 |
GET /journals/1 GET /journals/1.json | def show
@answers = @journal.journal_answers
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @journal = @journals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @journal }\n end\n end",
"def meals\n get(\"/user/#{@user_id}/meals.json\")\n end",
"def index\n @journals = Journal.all\n respond_with(@user,@journals)\n e... | [
"0.7158706",
"0.6995361",
"0.6920045",
"0.6821866",
"0.67946637",
"0.67946637",
"0.67946637",
"0.670302",
"0.6599061",
"0.6578589",
"0.65454036",
"0.65318197",
"0.64096916",
"0.6369305",
"0.63512415",
"0.6330399",
"0.632792",
"0.6272398",
"0.62713885",
"0.6229385",
"0.622236"... | 0.0 | -1 |
POST /journals POST /journals.json | def create
@journal = Journal.new(journal_params)
respond_to do |format|
if @journal.save
format.html { redirect_to @journal, notice: 'Journal was successfully created.' }
format.json { render :show, status: :created, location: @journal }
else
format.html { render :new }
format.json { render json: @journal.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @journal = @journals.new(params[:journal])\n\n respond_to do |format|\n if @journal.save\n format.html { redirect_to [@user, @journal], notice: 'Journal was successfully created.' }\n format.json { render json: @journal, status: :created, location: @journal }\n else\n ... | [
"0.72485274",
"0.69155097",
"0.63383716",
"0.6259293",
"0.62000954",
"0.61539364",
"0.60876566",
"0.6057389",
"0.60325664",
"0.6006344",
"0.59995633",
"0.5952863",
"0.59456474",
"0.5921335",
"0.5921335",
"0.5893149",
"0.58816403",
"0.58816403",
"0.58816403",
"0.5869513",
"0.5... | 0.61778283 | 6 |
PATCH/PUT /journals/1 PATCH/PUT /journals/1.json | def update
respond_to do |format|
if @journal.update(journal_params)
format.html { redirect_to @journal, notice: 'Journal was successfully updated.' }
format.json { render :show, status: :ok, location: @journal }
else
format.html { render :edit }
format.json { render json: @journal.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @journal = @journals.find(params[:id])\n\n respond_to do |format|\n if @journal.update_attributes(params[:journal])\n format.html { redirect_to @journal, notice: 'Journal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ... | [
"0.7096663",
"0.65911806",
"0.65503",
"0.65026885",
"0.6410398",
"0.6401953",
"0.63927794",
"0.63869053",
"0.62689984",
"0.61922103",
"0.61696047",
"0.6126088",
"0.6080139",
"0.60492074",
"0.60459095",
"0.6019747",
"0.599662",
"0.5979517",
"0.5971456",
"0.59712565",
"0.596059... | 0.6099638 | 13 |
DELETE /journals/1 DELETE /journals/1.json | def destroy
@journal.destroy
respond_to do |format|
format.html { redirect_to journals_url, notice: 'Journal was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @journal = @journals.find(params[:id])\n @journal.destroy\n\n respond_to do |format|\n format.html { redirect_to journals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @journal.destroy\n respond_to do |format|\n format.html { redirect_to jou... | [
"0.78043866",
"0.7483773",
"0.71982855",
"0.7149167",
"0.7126249",
"0.6988012",
"0.69439566",
"0.6913544",
"0.6908471",
"0.68771756",
"0.68629533",
"0.685953",
"0.6836947",
"0.6828814",
"0.6825377",
"0.6825345",
"0.6768228",
"0.6760553",
"0.67595744",
"0.6753018",
"0.6747173"... | 0.71895957 | 4 |
Use callbacks to share common setup or constraints between actions. | def set_journal
@journal = Journal.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
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 journal_params
params.require(:journal).permit(Journal.safe_attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Init the status bar | def init_status_bar(menu)
status_bar = NSStatusBar.systemStatusBar
status_item = status_bar.statusItemWithLength(NSVariableStatusItemLength)
status_item.setMenu menu
status_item.setTitle "虾米同步状态"
@status_item = status_item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_status_bar\n status_bar.show_message(tr(\"Ready\"))\n end",
"def status=(status)\n @statusbar.configure(:text => status)\n end",
"def initStatusBar(menu)\n status_bar = NSStatusBar.systemStatusBar\n status_item = status_bar.statusItemWithLength(NSVariableStatusItemLength)\n ... | [
"0.76012444",
"0.7158105",
"0.70395267",
"0.67654264",
"0.65527374",
"0.65359634",
"0.6156544",
"0.60428095",
"0.6009266",
"0.59643936",
"0.59157556",
"0.5882142",
"0.58810174",
"0.5876234",
"0.5828364",
"0.5814335",
"0.5801912",
"0.57615966",
"0.574682",
"0.57330674",
"0.569... | 0.75574315 | 1 |
Cross product of two arrays of length 3 | def cross(b,c)
unless b.size == 3 and c.size == 3
raise "Vectors must be of length 3"
end
Vector[b[1]*c[2] - b[2]*c[1], b[2]*c[0] - b[0]*c[2], b[0]*c[1] - b[1]*c[0]]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross(array2)\n self.inject([]){ |array, first| array2.inject(array) {|array, second| array << [first, second]} } \n end",
"def cross(a, b)\n return a.map{|i| b.map{|j| \"#{i}#{j}\" }}.flatten\nend",
"def cross_product x\r\n Vector.Raise ErrDimensionMismatch if size != 3\r\n Vector.Raise ErrDim... | [
"0.7276372",
"0.7195979",
"0.7152805",
"0.7075533",
"0.6861736",
"0.6673852",
"0.6660438",
"0.66168576",
"0.65865666",
"0.65638363",
"0.65638363",
"0.65565205",
"0.64276206",
"0.6410609",
"0.63925946",
"0.6388039",
"0.6388039",
"0.6388039",
"0.6388039",
"0.6375185",
"0.637030... | 0.6768275 | 5 |
Auth flow original unauthenticated request > /login /login > POST /login (login_creds), captures username/station_id (both optional) /login_creds > GET /auth/samlva /auth/samlva > GET SAML IdP SAML IdP > POST /auth/saml_callback (create method below) /auth/saml_callback > original request GET form to allow user to assert a username/station_id | def login
return redirect_to "/" if current_user.present?
respond_to do |format|
format.html { render("login") }
format.text { render plain: "Text not supported" }
format.json { render json: { error: "JSON not supported" } }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_creds\n session_login[\"username\"] = params.permit(:username)[:username]&.strip if allow_assert_username?\n session_login[\"station_id\"] = params.permit(:station_id)[:station_id]&.strip\n\n redirect_to url_for_sso_host(\"/auth/samlva\")\n end",
"def consume\n # params[:SAMLResponse] can ... | [
"0.75115764",
"0.6528471",
"0.6423938",
"0.6398638",
"0.63190055",
"0.62628573",
"0.6237449",
"0.6200055",
"0.6184677",
"0.6162357",
"0.6155791",
"0.6155791",
"0.61241263",
"0.610195",
"0.6072814",
"0.6050492",
"0.60070056",
"0.5995164",
"0.5989293",
"0.59761214",
"0.5968342"... | 0.0 | -1 |
POST to set username/station_id and redirect to SAML login | def login_creds
session_login["username"] = params.permit(:username)[:username]&.strip if allow_assert_username?
session_login["station_id"] = params.permit(:station_id)[:station_id]&.strip
redirect_to url_for_sso_host("/auth/samlva")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n redirect_to user_saml_omniauth_authorize_path\n end",
"def saml_request\n session_token = authenticate\n uri = URI.parse(idp_login_url)\n req = Net::HTTP::Post.new(uri.request_uri)\n req.set_form_data({'onetimetoken' => session_token})\n req\n end",
"def lo... | [
"0.61834264",
"0.61506456",
"0.6061828",
"0.6061385",
"0.60161567",
"0.5889821",
"0.58387",
"0.5836966",
"0.58241606",
"0.579736",
"0.579406",
"0.5779315",
"0.57770455",
"0.57770455",
"0.57743305",
"0.5772102",
"0.57502043",
"0.5718001",
"0.57034796",
"0.56947595",
"0.5693255... | 0.7953103 | 0 |
omniauth endpoint for invalid saml tickets | def failure
flash[:error] = "There was a problem authenticating your PIV." # params.permit(:message)[:message] is not helpful UX
redirect_to url_for_sso_host("/login")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fail\n render :text => request.env[\"omniauth.auth\"].to_yaml\n end",
"def call_token_fail_api(ticket, reason)\n return call_api(\"/api/auth/token/fail\", {\n \"ticket\" => ticket,\n \"reason\" => reason\n })\nend",
"def handle_unverified_request\n redirect_to root_url, :notice => \"We dete... | [
"0.65320367",
"0.62100106",
"0.6195656",
"0.60620946",
"0.60118693",
"0.60118693",
"0.5989949",
"0.5961958",
"0.5910315",
"0.5892571",
"0.5857764",
"0.5844595",
"0.5844595",
"0.5816916",
"0.5815136",
"0.581105",
"0.57989836",
"0.57939845",
"0.5783121",
"0.5708238",
"0.5688541... | 0.55470943 | 43 |
Get child of composite | def get_child(name, options)
constant.constants.each do |constant_symbol|
constant = self.constant.const_get(constant_symbol)
# Check to see if constant is a child class of the public PageObject interface
next unless constant < get_page_object(options[:interface])
name = constant.name.split('::').last.to_underscore.to_sym
return create_composite(constant, options[:interface], name)
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def child\n children[0]\n end",
"def child(type=nil)\n c = children(type)[0]\n end",
"def get_child(name, options)\n child = hash[name].is_a?(Hash) ? hash[name] : {}\n child_location = location + \"[#{name}]\"\n\n create_composite(options, child, name, chi... | [
"0.7355132",
"0.6735822",
"0.66677415",
"0.6426834",
"0.64160436",
"0.63877565",
"0.6372313",
"0.63625634",
"0.63534725",
"0.6348437",
"0.6109812",
"0.60909355",
"0.6063566",
"0.6031922",
"0.6023781",
"0.6011808",
"0.600878",
"0.5998022",
"0.59971386",
"0.5978035",
"0.5974253... | 0.64483464 | 3 |
Get children of composite | def get_children(name, options)
new_children = {}
constant.constants.each do |constant_symbol|
constant = self.constant.const_get(constant_symbol)
# Check to see if constant is a child class of the public PageObject interface
next unless constant < get_page_object(options[:interface])
name = constant.name.split('::').last.to_underscore.to_sym
new_children[name] = create_composite(constant, options[:interface], name)
end
new_children
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_children\n return children\n end",
"def children\n _children\n end",
"def getChildren\n begin\n elementObject = waitForObject(@symbolicName, OBJECT_WAIT_TIMEOUT)\n children = Squish::Object.children(elementObject)\n return children\n rescue Exception => e\n\t ... | [
"0.74911445",
"0.7371243",
"0.7358285",
"0.735396",
"0.7258968",
"0.72306114",
"0.71981806",
"0.7146735",
"0.71276766",
"0.71075267",
"0.7097458",
"0.7097458",
"0.7091226",
"0.7077832",
"0.7077584",
"0.70741385",
"0.70741385",
"0.70741385",
"0.7054445",
"0.70249015",
"0.69995... | 0.63423145 | 99 |
Check if the result is true. If so, create a new pass result, Otherwise create a new fail result with the desc and fail msg. | def assert(assertion, desc = nil)
if assertion
pass
else
what =
if block_given?
yield
else
"Failed assert: assertion was "\
"`#{Assert::U.show(assertion, __assert_config__)}`."
end
fail(fail_message(desc, what))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_result\n TestResult.new\n end",
"def test_result_new_success?(test_result)\n run_result = test_result.run_result\n test = test_result.test\n changed = run_result.change_events.where(test_id: test, value: Automation::Test::Change::TestStartedPassing.value).first\n\n ... | [
"0.64786357",
"0.63493645",
"0.6288016",
"0.62639153",
"0.6253096",
"0.6245196",
"0.6157296",
"0.6149829",
"0.61336553",
"0.61088127",
"0.6090098",
"0.6070968",
"0.6062849",
"0.60229194",
"0.600662",
"0.59883046",
"0.5951742",
"0.5943407",
"0.590691",
"0.5904633",
"0.5889249"... | 0.0 | -1 |
The opposite of assert. Check if the result is false. If so, create a new pass result. Otherwise create a new fail result with the desc and fail msg. | def assert_not(assertion, fail_desc = nil)
assert(!assertion, fail_desc) do
"Failed assert_not: assertion was "\
"`#{Assert::U.show(assertion, __assert_config__)}`."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failed?\n @passed == false\n end",
"def flexmock_test_has_failed? # :nodoc:\n passed? == false\n end",
"def assert(expression, test_desc)\n if !expression\n puts \"Fail: \".red + test_desc\n else\n puts \"Success: \".green + test_desc\n end\nend",
"def assertFalseFailTest value\n... | [
"0.6669683",
"0.665331",
"0.6645053",
"0.6641277",
"0.6583464",
"0.6560926",
"0.6550201",
"0.65308756",
"0.65114176",
"0.6480775",
"0.6461099",
"0.6414421",
"0.6386038",
"0.63838327",
"0.6372341",
"0.63722515",
"0.6365622",
"0.6257349",
"0.6223451",
"0.62133247",
"0.620981",
... | 0.6443229 | 11 |
adds a Pass result to the end of the test's results does not break test execution | def pass(pass_msg = nil)
if @__assert_pending__ == 0
capture_result(Assert::Result::Pass, pass_msg)
else
capture_result(
Assert::Result::Fail,
"Pending pass (make it not pending)",
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_test_step(step,result)\n unless result.passed?\n # only the first non-passed step\n failed_step[:step] ||= step\n failed_step[:result] ||= result\n end\n end",
"def pass(_)\n @passed = true\n @done = true\n end",
"def print_results\n if !@failur... | [
"0.71719337",
"0.69219446",
"0.67639995",
"0.67180717",
"0.6659913",
"0.66203475",
"0.65977556",
"0.65932566",
"0.6584743",
"0.65658736",
"0.6532146",
"0.6522254",
"0.6509355",
"0.6468295",
"0.6409466",
"0.63936126",
"0.6366044",
"0.63604033",
"0.63604033",
"0.63604033",
"0.6... | 0.60262966 | 53 |
adds an Ignore result to the end of the test's results does not break test execution | def ignore(ignore_msg = nil)
capture_result(Assert::Result::Ignore, ignore_msg)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discard_results; end",
"def abandon_results!()\n #This is a stub, used for indexing\n end",
"def skipped; end",
"def skipped!; end",
"def ignore!\n @should_ignore = true\n end",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def ... | [
"0.73048675",
"0.6788711",
"0.6638515",
"0.6625198",
"0.65792257",
"0.64288765",
"0.64288765",
"0.64288765",
"0.64288765",
"0.63927984",
"0.6307533",
"0.6287846",
"0.6287838",
"0.62666816",
"0.62467897",
"0.62093705",
"0.61863816",
"0.61711097",
"0.61711097",
"0.61289644",
"0... | 0.67043525 | 2 |
adds a Fail result to the end of the test's results break test execution if assert is configured to halt on failures | def fail(message = nil)
if @__assert_pending__ == 0
if halt_on_fail?
raise Result::TestFailure, message || ""
else
capture_result(Assert::Result::Fail, message || "")
end
elsif halt_on_fail?
raise Result::TestSkipped, "Pending fail: #{message || ""}"
else
capture_result(Assert::Result::Skip, "Pending fail: #{message || ""}")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fail_now\n fail\n raise TestFail\n end",
"def fail\n @counts.fails += 1\n puts_failure_data(header: FAIL_HEADER)\n end",
"def after_test_step(step,result)\n unless result.passed?\n # only the first non-passed step\n failed_step[:step] ||= step\n failed_... | [
"0.69963783",
"0.69442284",
"0.6902007",
"0.6875813",
"0.6757238",
"0.6697945",
"0.65277433",
"0.65277433",
"0.6444955",
"0.6433373",
"0.6421928",
"0.64085823",
"0.638177",
"0.6295026",
"0.6295026",
"0.6295026",
"0.62933004",
"0.62406296",
"0.6222973",
"0.61858153",
"0.618336... | 0.68709457 | 4 |
adds a Skip result to the end of the test's results breaks test execution | def skip(skip_msg = nil, called_from = nil)
raise Result::TestSkipped, (skip_msg || ""), called_from
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip_now\n @skipped = true\n raise TestSkip\n end",
"def skip\n end",
"def skip\n end",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def skipped; end",
"def skipped!; end",
"def skipped!\n @skipped = true\n end",
"def sk... | [
"0.7332717",
"0.7318204",
"0.7318204",
"0.72731674",
"0.72731674",
"0.72731674",
"0.72731674",
"0.72460115",
"0.7202288",
"0.71801007",
"0.71323144",
"0.7056888",
"0.70323217",
"0.7019939",
"0.68792695",
"0.68422335",
"0.68415874",
"0.67699313",
"0.67262197",
"0.66200304",
"0... | 0.6954986 | 14 |
runs block and any fails are skips and any passes are fails | def pending(&block)
begin
@__assert_pending__ += 1
instance_eval(&block)
ensure
@__assert_pending__ -= 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def may_fail # block\n begin\n yield\n rescue\n end\nend",
"def on_fail( &block )\n @on_fail_blocks ||= []\n @on_fail_blocks << block\n end",
"def continue?; end",
"def failed?; failed_to_start? || (@success == false) end",
"def each_invalid_attempt(&block)\n invalid_attempts.... | [
"0.72039074",
"0.6441981",
"0.6436933",
"0.6390705",
"0.63790524",
"0.62657",
"0.62657",
"0.62657",
"0.62657",
"0.6243642",
"0.6243642",
"0.62141",
"0.61836493",
"0.6177631",
"0.61638975",
"0.6163593",
"0.61377513",
"0.6119222",
"0.611534",
"0.611534",
"0.6112046",
"0.60873... | 0.0 | -1 |
alter the backtraces of fail/skip results generated in the given block | def with_backtrace(bt, &block)
bt ||= []
begin
@__assert_with_bt__.push(bt.first)
instance_eval(&block)
rescue Result::TestSkipped, Result::TestFailure => ex
if ex.assert_with_bt.nil? && !@__assert_with_bt__.empty?
ex.assert_with_bt = @__assert_with_bt__.dup
end
raise(ex)
ensure
@__assert_with_bt__.pop
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_non_test_result_line(&block)\n raise ArgumentError.new('must provide a block') unless block_given?\n @on_non_test_result_line_block = block\n end",
"def on_fail( &block )\n @on_fail_blocks ||= []\n @on_fail_blocks << block\n end",
"def trace_execution_steps(&block)\... | [
"0.64063776",
"0.63223416",
"0.62171346",
"0.61347544",
"0.60919267",
"0.5813617",
"0.578718",
"0.578584",
"0.57349616",
"0.5734661",
"0.5734033",
"0.5642312",
"0.5640391",
"0.56376314",
"0.5637276",
"0.5626354",
"0.5622673",
"0.5615306",
"0.56123155",
"0.56123155",
"0.559742... | 0.5433169 | 49 |
Returns a Proc that will output a custom message along with the default fail message. | def fail_message(fail_desc = nil, what_failed_msg = nil)
[fail_desc, what_failed_msg].compact.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fail(message)\n growl \"Failure!\", message\n exit\nend",
"def failure_message_preface=(_arg0); end",
"def failure_message_continuation; end",
"def post_fail_message; end",
"def say_failed(message)\n say \"Failed!!\", message, :yellow\n end",
"def failure_message; end",
"def failure_messa... | [
"0.6215533",
"0.6176692",
"0.614217",
"0.6091478",
"0.6046225",
"0.6026733",
"0.6026733",
"0.6026733",
"0.6026733",
"0.6026733",
"0.6026733",
"0.6026733",
"0.60172784",
"0.59792924",
"0.5958564",
"0.5958564",
"0.5958564",
"0.5948204",
"0.59184283",
"0.5891365",
"0.5872824",
... | 0.5748308 | 42 |
Packages needed to manage the server remotely and install applications. | def install_management
# Needed to play with the configuration database.
package 'debconf'
package 'debconf-utils'
# Keys for Debian packages.
package 'debian-archive-keyring'
# Fetch files via HTTP.
package 'curl'
package 'wget'
package 'dpkg-dev' # Builds packages from source.
package 'openssh-server' # SSH into the box.
# For gems with native extensions.
package 'build-essential'
package 'g++'
# Pull code from version control.
package 'subversion'
package 'git-core'
package 'avahi-daemon' # mDNS, a.k.a. Bonjour
package 'ddclient' # dynamic DNS
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_packages\n return(interpreter.package_manager.install <<-HERE)\n # Core\n mysql-server\n mysql-client\n\n # Tools\n libcompress-zlib-perl\n mytop\n dbishell\n\n # Ruby drivers\n libmysql-ruby\n libdbd-mysql-ruby\n HERE\n end",
"def install_pack... | [
"0.6951988",
"0.68111384",
"0.66349185",
"0.654118",
"0.6489752",
"0.6479016",
"0.6442254",
"0.6332588",
"0.62906885",
"0.62463474",
"0.6232697",
"0.6225306",
"0.6220263",
"0.6220263",
"0.62169737",
"0.62168646",
"0.6214205",
"0.6179236",
"0.6166253",
"0.61521494",
"0.6141875... | 0.72432524 | 0 |
Packages needed by popular gems. | def install_tools
# For eventmachine.
package 'libssl-dev'
# For rmagick (image processing).
package 'libmagickwand-dev', /^libmagick\d*-dev$/
# For HTML/XML parsers (nokogiri, hpricot).
package 'libxml2-dev'
package 'libxslt1-dev'
# For HTTP fetchers (curb).
package 'libcurl-dev', 'libcurl-openssl-dev', /^libcurl\d*-dev$/,
/^libcurl\d*-openssl-dev$/
# needed for solr and other java-based services
package /^openjdk-\d+-jdk/
# useful to be able to work with compressed data
package 'zlib-dev', /^zlib[0-9a-z]*-dev$/
package 'bzip2'
package 'gzip'
package 'tar'
package 'zip'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gems; end",
"def gems; end",
"def gems; end",
"def require_gems; end",
"def gemspecs; end",
"def packages; end",
"def install_packages\n return(interpreter.package_manager.install <<-HERE)\n # Core\n mysql-server\n mysql-client\n\n # Tools\n libcompress-zlib-perl\n ... | [
"0.7410372",
"0.7410372",
"0.7410372",
"0.73640925",
"0.7323409",
"0.7054136",
"0.7026539",
"0.7017065",
"0.6992924",
"0.6960747",
"0.6923462",
"0.6909805",
"0.69033647",
"0.675927",
"0.675927",
"0.675927",
"0.675927",
"0.675927",
"0.675927",
"0.675927",
"0.675927",
"0.6751... | 0.731538 | 5 |
Packages for all the database servers we could need. | def install_databases
package 'sqlite3'
package 'libsqlite3-dev'
package 'mysql-client'
package 'mysql-server'
package 'libmysql-dev', 'libmysqlclient-dev', /^libmysqlclient\d*-dev$/
package 'postgresql-client'
package 'libpq-dev'
# TODO: NoSQL stores.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def databases\n get '_all_dbs'\n end",
"def getDefaultDatabases\n if !$remoteDatabasesLoaded\n info \"Loading remote databases...\"\n\n $remoteDatabases = []\n\n failures = false\n\n if !loadDatabase \"boostslair\",\n \"https://boostslair.com/rubysetupsystem/database.json... | [
"0.6284662",
"0.6213865",
"0.59914136",
"0.59774816",
"0.59756696",
"0.5966052",
"0.5951221",
"0.59317786",
"0.5915743",
"0.59096557",
"0.5894013",
"0.58845866",
"0.58566016",
"0.5824274",
"0.5820387",
"0.58146137",
"0.5798659",
"0.57856566",
"0.57759154",
"0.5773085",
"0.571... | 0.7171739 | 0 |
The ruby environment (ruby, irb, rubygems). | def install_ruby
# remove the bootstrap version of ruby to install the best available one.
remove_packages %w(ruby ruby1.8 ruby1.9.1 ruby2.0)
install_ruby_20 || install_ruby_19
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_environment\n ENV['RUBY_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'\n end",
"def rbenv_ruby\n `rbenv version`.split(' ').first\n end",
"def environment_info\n info = \"[Ruby: #{RUBY_VERSION}]\"\n info << \" [#{configuration.framework}]\" if configuration.fram... | [
"0.72205496",
"0.70407766",
"0.6850843",
"0.6671197",
"0.66489744",
"0.66169864",
"0.6610836",
"0.6511112",
"0.64925057",
"0.64757204",
"0.64351225",
"0.64348155",
"0.64265025",
"0.63705325",
"0.6362932",
"0.6349781",
"0.6321494",
"0.6319305",
"0.63153404",
"0.6310525",
"0.63... | 0.0 | -1 |
MRI19 (1.9.2 or above). | def install_ruby_19(retry_with_repos = true)
package = best_package_matching(['ruby1.9.1'])
if !package or package[:version] < '1.9.2'
return false unless retry_with_repos
# This distribution has an old ruby. Work around it.
deb_source = 'http://debian.mirrors.tds.net/debian/'
deb_repos = %w(testing main non-free contrib)
return_value = nil
with_package_source deb_source, deb_repos do
return_value = install_ruby_19 false
end
return return_value
end
package 'ruby1.9.1'
package 'ruby1.9.1-dev'
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_mri?; end",
"def sample_mri_rubies\n @sample_mri_rubies ||= %w[ ruby-3.2 ruby-2.7 ]\n end",
"def supported_mri_rubies\n @supported_mri_rubies ||= %w[\n ruby-3.2 ruby-3.1 ruby-3.0\n ruby-2.7 ruby-2.6 ruby-2.5\n ]\n end",
"def metro_code; end",
"def native_cri\n 4\n end",... | [
"0.61582536",
"0.56540954",
"0.5505444",
"0.5320108",
"0.5295054",
"0.51648843",
"0.5109289",
"0.50499284",
"0.5046846",
"0.50218016",
"0.5003168",
"0.49680203",
"0.49622387",
"0.49528617",
"0.49528617",
"0.49528617",
"0.49145424",
"0.48988822",
"0.48970655",
"0.4890224",
"0.... | 0.0 | -1 |
Package for frontend servers. | def install_frontends
package 'nginx'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clientserver\n end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server\n super\n end",
"def server\n super\n end",
"def backend; end",
"def configure_fronte... | [
"0.6990412",
"0.6971397",
"0.6971397",
"0.6971397",
"0.6971397",
"0.6971397",
"0.6971397",
"0.6971397",
"0.6971397",
"0.68638027",
"0.68638027",
"0.67168933",
"0.67058504",
"0.6532262",
"0.6532262",
"0.6522481",
"0.6451406",
"0.6451406",
"0.63921005",
"0.6344891",
"0.6213913"... | 0.59562415 | 35 |
Implementation of the supersimple package DSL. | def package(*patterns)
install_package_matching patterns
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def k_package!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n\n\n type = K_PACKAGE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 341:4: 'package'\n ... | [
"0.5377364",
"0.53752536",
"0.53318495",
"0.53318495",
"0.5307369",
"0.5147194",
"0.51312476",
"0.50860775",
"0.50487167",
"0.5040459",
"0.50331205",
"0.5031026",
"0.5013787",
"0.49887785",
"0.49719363",
"0.495826",
"0.49527267",
"0.49396613",
"0.49249852",
"0.49119574",
"0.4... | 0.0 | -1 |
two edge cases pawn can go two moves at first pawn can move diagonally to take another piece | def take(current_position)
if direction == 1
diagonals(current_position, 1)[0..1]
elsif direction == 2
diagonals(current_position, 1)[1...-1]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_pawn(p1)\n col = get_col_from_index(p1)\n valid = []\n\n # Piece color defines direction of travel. Enemy presence defines\n # the validity of diagonal movements\n if Move.color == :red\n valid << (p1 - 8) if unoccupied?(p1 - 8)\n valid << (p1 - 7) if piece_color(p1 ... | [
"0.745931",
"0.735287",
"0.73423564",
"0.7327035",
"0.7270857",
"0.7167028",
"0.7159574",
"0.71415347",
"0.7122272",
"0.7104862",
"0.70812416",
"0.70679915",
"0.7004447",
"0.6998566",
"0.699728",
"0.69614863",
"0.694933",
"0.6908358",
"0.68994117",
"0.68715847",
"0.68577504",... | 0.0 | -1 |
GET /iscrivitis or /iscrivitis.json | def index
@iscrivitis = Iscriviti.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n # Retrieve kpis templates from impac api.\n # TODO: improve request params to work for strong parameters\n attrs = params.slice('metadata', 'opts')\n auth = { username: MnoEnterprise.tenant_id, password: MnoEnterprise.tenant_key }\n\n response = begin\n MnoEnterprise::ImpacClient.se... | [
"0.61515707",
"0.6122329",
"0.60009104",
"0.5902783",
"0.5871682",
"0.58489805",
"0.5822327",
"0.57769346",
"0.57099545",
"0.57078904",
"0.5697192",
"0.56830317",
"0.5671696",
"0.5655413",
"0.5649607",
"0.56369156",
"0.5636174",
"0.56354713",
"0.5631355",
"0.56257206",
"0.557... | 0.6637823 | 0 |
GET /iscrivitis/1 or /iscrivitis/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sitio }\n end\n end",
"def index\n @iscrivitis = Iscriviti.all\n end",
"def show\n @institucional = Institucional.find(params[:id])\n\n respond_to do ... | [
"0.64324963",
"0.62872493",
"0.61910653",
"0.6137858",
"0.60527235",
"0.6029119",
"0.6026649",
"0.6003046",
"0.598621",
"0.59120965",
"0.5904004",
"0.58863866",
"0.58760405",
"0.5833617",
"0.58325446",
"0.58301675",
"0.5819982",
"0.5805419",
"0.58016104",
"0.5786974",
"0.5777... | 0.0 | -1 |
POST /iscrivitis or /iscrivitis.json | def create
@iscriviti = Iscriviti.new(iscriviti_params)
respond_to do |format|
if @iscriviti.save
format.html { redirect_to @iscriviti, notice: "Iscriviti was successfully created." }
format.json { render :show, status: :created, location: @iscriviti }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @iscriviti.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_iscriviti\n @iscriviti = Iscriviti.find(params[:id])\n end",
"def create\n @sitio = Sitio.new(params[:sitio])\n\n respond_to do |format|\n if @sitio.save\n format.html { redirect_to @sitio, notice: 'Sitio was successfully created.' }\n format.json { render json: @sitio, s... | [
"0.57280403",
"0.5706759",
"0.5686425",
"0.5535601",
"0.54374707",
"0.54359233",
"0.54340297",
"0.53830504",
"0.53777784",
"0.53757894",
"0.5375012",
"0.53551674",
"0.5333358",
"0.5301576",
"0.5300641",
"0.52725965",
"0.52421117",
"0.5219475",
"0.5218221",
"0.5211693",
"0.520... | 0.6242526 | 0 |
PATCH/PUT /iscrivitis/1 or /iscrivitis/1.json | def update
respond_to do |format|
if @iscriviti.update(iscriviti_params)
format.html { redirect_to @iscriviti, notice: "Iscriviti was successfully updated." }
format.json { render :show, status: :ok, location: @iscriviti }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @iscriviti.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @sitio = Sitio.find(params[:id])\n\n respond_to do |format|\n if @sitio.update_attributes(params[:sitio])\n format.html { redirect_to @sitio, notice: 'Sitio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit... | [
"0.6431485",
"0.6386374",
"0.63147074",
"0.62288374",
"0.6184213",
"0.6166263",
"0.6165514",
"0.6150753",
"0.6149236",
"0.61397356",
"0.6139202",
"0.61200666",
"0.6116254",
"0.6075206",
"0.6072485",
"0.6060625",
"0.60406625",
"0.60406625",
"0.6029343",
"0.6028532",
"0.6026345... | 0.6833927 | 0 |
DELETE /iscrivitis/1 or /iscrivitis/1.json | def destroy
@iscriviti.destroy
respond_to do |format|
format.html { redirect_to iscrivitis_url, notice: "Iscriviti was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end",
"def destroy\n @sitio = Sitio.find(params[:id])\n @sitio.destroy\n\n respond_to do |format|\n format.html { redirect_to sitios_url }\n format.json { head :no_content }\n ... | [
"0.68710345",
"0.6820844",
"0.6790766",
"0.67739004",
"0.6685559",
"0.6675904",
"0.66610116",
"0.6652753",
"0.66288584",
"0.66110116",
"0.6593122",
"0.6590212",
"0.6590212",
"0.6590212",
"0.6590212",
"0.6574984",
"0.6570485",
"0.65531176",
"0.6551056",
"0.6550214",
"0.6519221... | 0.6906022 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_iscriviti
@iscriviti = Iscriviti.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 iscriviti_params
params.require(:iscriviti).permit(:cognome, :nome, :email, :cellulare, :età, :richiesta)
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 |
Make a new MyObfuscate object. Pass in a configuration structure to define how the obfuscation should be performed. See the README.rdoc file for more information. | def initialize(configuration = {})
@config = configuration
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obfuscate(text); end",
"def apply(config)\n config.debug = debug?\n config.fde = fde? if config.fde?\n config.homedir = homedir if homedir\n config.logfile = logfile if logfile\n config.login = login if login\n config.token ... | [
"0.51187164",
"0.49184537",
"0.48273826",
"0.47683448",
"0.47652844",
"0.4762612",
"0.47481048",
"0.4733684",
"0.46965277",
"0.4678694",
"0.46349537",
"0.46163344",
"0.46088478",
"0.46075648",
"0.460755",
"0.4606585",
"0.4600054",
"0.45681134",
"0.45430997",
"0.45320535",
"0.... | 0.42936125 | 78 |
Read an input stream and dump out an obfuscated output stream. These streams could be StringIO objects, Files, or STDIN and STDOUT. | def obfuscate(input_io, output_io)
# We assume that every INSERT INTO line occupies one line in the file, with no internal linebreaks.
input_io.each do |line|
if table_data = database_helper.parse_insert_statement(line)
table_name = table_data[:table_name]
columns = table_data[:column_names]
if config[table_name]
output_io.puts obfuscate_bulk_insert_line(line, table_name, columns)
else
$stderr.puts "Deprecated: #{table_name} was not specified in the config. A future release will cause this to be an error. Please specify the table definition or set it to :keep."
output_io.write line
end
else
output_io.write line
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capture_with_inputs(stream, *args)\n begin\n # override STDOUT\n stream = stream.to_s\n eval \"$#{stream} = StringIO.new\"\n # override STDIN\n $stdin = StringIO.new\n $stdin.puts(args.shift) until args.empty?\n $stdin.rewind\n yield\n result = eval(\"$#{stream}\... | [
"0.6310717",
"0.6246652",
"0.5783478",
"0.57218575",
"0.5695093",
"0.56673974",
"0.5585368",
"0.5585368",
"0.5585368",
"0.5573825",
"0.5569667",
"0.5549787",
"0.5533815",
"0.551096",
"0.551096",
"0.5506669",
"0.54757",
"0.5431092",
"0.5405555",
"0.535864",
"0.535864",
"0.53... | 0.0 | -1 |
'password' is a virtual attribute | def password
@password
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def password\n \t\t return password_virtual_attr\n end",
"def password\n\t\tPassword.new( attribute_get(:password) )\n\tend",
"def password_field\n self.password\n end",
"def password\n @attributes[:password]\n end",
"def password\n @attributes[:password]\n end",
"def password\n ... | [
"0.8923515",
"0.82171404",
"0.81790924",
"0.81615293",
"0.81615293",
"0.8124509",
"0.8069165",
"0.8048135",
"0.8043672",
"0.80031204",
"0.7998858",
"0.7942966",
"0.7942966",
"0.7942966",
"0.7942966",
"0.7942966",
"0.7942966",
"0.79252744",
"0.79252744",
"0.79245543",
"0.79245... | 0.80647916 | 27 |
redefine your position_taken? method here, so that you can use it in the valid_move? method above. | def position_taken?(board, position)
if (board[position] == "X" || board[position] == "O")
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend",
"def position_taken?\nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v... | [
"0.8409544",
"0.81629395",
"0.80905885",
"0.8027683",
"0.8013985",
"0.7897459",
"0.7893988",
"0.788559",
"0.78440714",
"0.7842232",
"0.7832043",
"0.781508",
"0.78134483",
"0.7809711",
"0.7802032",
"0.78010035",
"0.7800593",
"0.77891666",
"0.77826595",
"0.77743876",
"0.7773536... | 0.0 | -1 |
Define display_board that accepts a board and prints out the current state. | def display_board(board)
divider = "-----------"
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts divider
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts divider
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def display_board(board)\n puts \" #{board[0]} | #{boar... | [
"0.82800204",
"0.82800204",
"0.8258375",
"0.8188966",
"0.81476265",
"0.81202936",
"0.8105247",
"0.8103876",
"0.8103876",
"0.8075896",
"0.8066689",
"0.8062806",
"0.8053156",
"0.8053156",
"0.8053156",
"0.8053156",
"0.8053156",
"0.8053156",
"0.8053156",
"0.8053156",
"0.8053156",... | 0.0 | -1 |
Write a method that takes a string as an argument and groups the number of time each character appears in the string as a hash sorted by the highest number of occurrences. | def get_char_count(string)
alphabet = 'abcdefghijklmnopqrstuvwxyz1234567890'
count = Hash.new(0)
valid_keys = []
string.each_char.with_index do |char, _i|
count[char.downcase] += 1
end
count.keys.each do |char|
valid_keys << char if alphabet.include?(char)
end
valid_keys.sort.group_by { |k| count[k] }.sort_by { |k, _v| k }.reverse.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ordered_count(str)\n counter_hsh = Hash.new(0)\n str.chars.each { |letter| counter_hsh[letter] += 1 }\n counter_hsh.sort_by { |x| [str.chars.index(x), str.chars.count(x)] }\nend",
"def string_frequency(string, hash)\n string.each_char do |char|\n hash[char]+=1\n end\n return hash\n ... | [
"0.7808186",
"0.7710988",
"0.770197",
"0.76872677",
"0.75952554",
"0.7540829",
"0.75379944",
"0.7534334",
"0.7520658",
"0.75083053",
"0.74930984",
"0.748371",
"0.7471014",
"0.7454163",
"0.7450043",
"0.7422173",
"0.74012494",
"0.73436",
"0.732835",
"0.7305477",
"0.7272525",
... | 0.75181013 | 9 |
Called directly on a keyed object, immediately dials and calls the keys specified as arguments. Returns the value found, or nil. A default cannot be specified. | def call(*lookup)
return KeyDialler.new(self, *lookup).call
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](key)\n\t\t\treturn dial!(key)\n\t\tend",
"def fetch(key, *default)\n result =\n if key?(key)\n self[key]\n elsif block_given?\n yield(self)\n end\n unless result\n raise KeyError, \"key not found \\\"#{key}\\\"\" if default.empty?\n result = d... | [
"0.6563564",
"0.6069963",
"0.60127074",
"0.5862249",
"0.5816683",
"0.5807284",
"0.5804853",
"0.58005685",
"0.57713604",
"0.57636106",
"0.5716827",
"0.56627834",
"0.56602174",
"0.5644939",
"0.564138",
"0.5632986",
"0.5627002",
"0.56203556",
"0.56124604",
"0.5580998",
"0.554427... | 0.6198736 | 1 |
Returns an Array of all the valid indices for this Array | def keys
if self.size > 0
return Array(0..(self.size - 1))
else
return []
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_a\n indices\n end",
"def indices\n @indices.to_a\n end",
"def all_indices\n @indices ||= []\n @indices.dup\n end",
"def indices\n return [\n columns.nil? ? nil : columns.begin,\n rows.nil? ? nil : rows.begin,\n columns.nil? ? nil : colum... | [
"0.7036332",
"0.6965362",
"0.68816745",
"0.6795691",
"0.66285723",
"0.65507954",
"0.64413583",
"0.60609657",
"0.6013238",
"0.594179",
"0.59402424",
"0.5853865",
"0.57353765",
"0.57237417",
"0.56907725",
"0.56466573",
"0.5641941",
"0.5641941",
"0.5638787",
"0.55664533",
"0.554... | 0.5132667 | 60 |
Structs are not empty by definition | def empty?; false; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_structure\n structure {}\n end",
"def empty?\n @structure.empty?\n end",
"def is_empty()\n \n end",
"def empty?; end",
"def empty?; end",
"def empty?; end",
"def empty?; end",
"def empty?; end",
"def empty?; end",
"def empty?; end",
"def empty?; end",
"def emp... | [
"0.70989215",
"0.69799596",
"0.65210134",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.644462",
"0.64139533",
"0.633003",
"0.6308909",
"0.6297629",
"0.6273337",
"0.62673295",
"0.623906... | 0.6284065 | 20 |
Use callbacks to share common setup or constraints between actions. | def set_article
@article = Article.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 article_params
params.permit(:name, :text, :article_type)
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 |
input: string output: array Logic iterate through string, feeding smaller and smaller substrings into method from previous exercise at each iteration, previous method will generate an array of strings add these to a new array, then flatten that array. Methods integerupto arrayflatten Code | def substrings_at_start(str)
new_arr = []
0.upto(str.size) do |i|
next if i == 0
new_arr << str.slice(0,i)
end
new_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def substrings(string)\r\n new_array = []\r\n string.size.times do |index|\r\n new_array << leading_substrings(string[index..string.size])\r\n end\r\n new_array.flatten\r\nend",
"def substrings(string)\n substring_array = []\n string.each do |letter|\n \n end\n substring_array\nend",
"def substri... | [
"0.7089269",
"0.6752686",
"0.6706309",
"0.66844463",
"0.66689646",
"0.6565682",
"0.65416485",
"0.6520616",
"0.6518869",
"0.65147406",
"0.65108436",
"0.646225",
"0.64598197",
"0.64364946",
"0.6396079",
"0.6369028",
"0.636115",
"0.635273",
"0.6337757",
"0.63012",
"0.63002753",
... | 0.0 | -1 |
Create a new assertion. | def initialize(s_name, user_id, authorized_subjects)
@system_name = s_name
@user_id = user_id
@subjects = authorized_subjects
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertion\n @assertion ||= Samlr::Assertion.new(document, options)\n end",
"def assertions; end",
"def assertions; end",
"def assert(assertion, text=nil)\n if assertion\n if !text.nil?\n @result.add_success(text)\n else\n @result.add_success \"#{caller.first}\"\n e... | [
"0.7138983",
"0.6642641",
"0.6642641",
"0.66213405",
"0.65986484",
"0.6472313",
"0.6412451",
"0.64051425",
"0.6285319",
"0.6285319",
"0.6275317",
"0.6135234",
"0.6097769",
"0.6060704",
"0.599299",
"0.5908655",
"0.58716774",
"0.5842196",
"0.57962525",
"0.5791215",
"0.57836485"... | 0.0 | -1 |
Encode the assertion into a request, including the signature. | def encode_and_sign_to_http_request(request, signing_secret)
authorization_info_b64 = Base64.strict_encode64(as_json)
request.headers[ASSERTION_HEADER_NAME] = authorization_info_b64
signature = OpenSSL::HMAC.digest("SHA256", signing_secret, authorization_info_b64)
request.headers[SIGNATURE_HEADER_NAME] = Base64.strict_encode64(signature)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n signed = (signed_at || Time.now).to_i.to_s\n\texpires = expires_at.to_i.to_s\n\tsignature = \"#{public_key}#{expires}#{signed}#{action}\"\n\ttoken = OpenSSL::HMAC.hexdigest DIGEST, secret, signature\n\tencoded_token = Base64.encode64(token)\n\tencoded_token.gsub! /\\n/, ''\n\tparams = [ encoded_t... | [
"0.6378693",
"0.6176774",
"0.6154882",
"0.61512655",
"0.6141733",
"0.60254514",
"0.5974324",
"0.5967479",
"0.5966809",
"0.58887297",
"0.58778286",
"0.58418393",
"0.5764388",
"0.57166386",
"0.57083136",
"0.57083136",
"0.57022184",
"0.5700408",
"0.5681346",
"0.5674436",
"0.5643... | 0.74113965 | 0 |
A > B a | ... ; B > A d | ... ==> A > A d a | ... ; | def remove_mutual_recursion
productions = @productions.map do |name, rules|
rules = rules.select do |rule|
rule.first.is_a?(Production) && rule.first.name != name
end.map! { |rule| rule.first.name }.tap(&:uniq!)
[name, rules]
end.to_h
# detect mutual recursions
productions.each { |name, prods| prods.select! { |p| productions[p].include?(name) } }
# make sure main production is preserved
productions[:main]&.each { |p| productions[p].delete(:main) }
# remove loops: a=>b & b=>a ==> a=>b
productions.each { |name, prods| prods.each { |p| productions[p].delete(name) } }
# remove productions that don't have recursion
productions.reject! { |_name, prods| prods.empty? }
return false if productions.empty?
p productions
productions.each do |name, prods|
prods.each do |prod|
buffer = []
@productions[name].each do |rule|
p, *rest = rule
if p.is_a?(Production) && p.name == prod
buffer.push(*@productions[prod].map { |r| remove_epsilons!(r + rest) })
else
buffer << rule
end
end.replace(buffer)
end
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_swap graph\n swap.gain = MIN\n A.each do |a|\n B.each do |b|\n d = a.d + b.d - 2*c(a,b)\n if d > swap.gain\n swap.gain = d\n swap = a,b\n end\n end\n end\n return swap\nend",
"def from_left; end",
"def from_left; end",
"def upc_a_with_composite_symbology; end",... | [
"0.51189905",
"0.50919056",
"0.50919056",
"0.5025286",
"0.49735418",
"0.49515605",
"0.49430007",
"0.49357888",
"0.49173012",
"0.48967704",
"0.48728043",
"0.48728043",
"0.4870021",
"0.48642772",
"0.48523083",
"0.4836339",
"0.48316592",
"0.4791636",
"0.47746688",
"0.47552803",
... | 0.0 | -1 |
A > Bd; B > cd | ae ==> A > cdd | aed | def remove_left_corners
found = false
@productions.each do |name, rules|
buffer = []
rules.each do |rule|
p, *rest = rule
# if p.is_a?(Production) && ![:main, name].include?(p.name)
if p.is_a?(Production) && name != p.name
found = true
buffer.push(*@productions[p.name].map { |r| remove_epsilons!(r + rest) })
else
buffer << rule
end
end.replace(buffer).uniq!
end
found
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_left; end",
"def from_left; end",
"def test_retuns_ordered_jobs_considering_all_dependecies\n sequence = Sequence.new()\n sequence.add(\"a =>\n b => c\n c => f\n d => a\n e => b\n f =>\")\n sequence.ordered.each do |job|\n ... | [
"0.53497916",
"0.53497916",
"0.53248847",
"0.5299707",
"0.5172676",
"0.5136457",
"0.51164836",
"0.50835663",
"0.5074249",
"0.5069894",
"0.50593245",
"0.5032968",
"0.50276464",
"0.5001344",
"0.5000253",
"0.49980363",
"0.49642047",
"0.49525693",
"0.4950845",
"0.49485755",
"0.49... | 0.0 | -1 |
A > bcD | bcC | bcB | Bd ==> A > bcA' | Bd A' > D | C | B | def remove_left_factors
prods = @productions.map do |name, rules|
next if rules.size == 1
t = Trie.new
rules.each { |rule| t.insert(rule) }
prefixes = t.group_by_prefixes
next if prefixes.size == rules.size
[name, t.group_by_prefixes]
end.compact!
return false if prods.empty?
prods.each do |name, prefixes|
rules = @productions[name] = []
prefixes.each do |prefix, suffixes|
if suffixes.size == 1 && suffixes.first.empty? # suffixes == [[]]
rules << prefix
else
suffix = suffixes.find(&:empty?)
suffix << EmptyProduction.instance if suffix
new_name = @productions.find { |_name, rs| rs == suffixes }&.first
unless new_name
new_name = gen_prod_name(name)
@productions[new_name] = suffixes
end
new_prod = Production.new(new_name)
rules << (prefix << new_prod)
end
end
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rev_comp(seq) # AAAGG-G => CCCTT-T\n # remove N start and last bases\n seq = seq.sub(/^N+/, '')\n seq.sub!(/N+$/, '')\n return nil if seq.include?(\"N\".freeze)\n seq.upcase!\n seq.reverse!\n seq.tr!('ATGC'.freeze, 'TACG'.freeze)\n return seq\n end",
"def phase_iii(... | [
"0.5841488",
"0.56494826",
"0.5647671",
"0.5610132",
"0.5509322",
"0.54918396",
"0.54779315",
"0.54493177",
"0.5422244",
"0.5375675",
"0.5350358",
"0.53134054",
"0.53096735",
"0.52852803",
"0.5248732",
"0.523137",
"0.5221138",
"0.51923364",
"0.51661676",
"0.51471674",
"0.5144... | 0.0 | -1 |
se ingresa nota, para poder agregar notas o visualizar notas de cada alumno. | def initialize(name)
@name = name
@nota
#declaracion v instancia
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notacion(columna, fila)\n ambiguedades = @tablero.movibles_a(columna, fila).select do |pieza|\n (@columna != pieza.columna or @fila != pieza.fila) and @color == pieza.color and self.class == pieza.class\n end\n\n notacion = inicial\n if ambiguedades.any? { |pieza| @fila == pieza.fila... | [
"0.6700982",
"0.5979742",
"0.5969126",
"0.59501946",
"0.5523544",
"0.5503018",
"0.5443353",
"0.5440858",
"0.54291546",
"0.5428226",
"0.53658336",
"0.53647757",
"0.5350744",
"0.5312101",
"0.52898514",
"0.5283403",
"0.527619",
"0.527619",
"0.527532",
"0.5271295",
"0.5269651",
... | 0.0 | -1 |
creando getter y setter para x e y | def initialize( position_x, position_y )
@x = position_x
@y = position_y
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def x=(value)\n end",
"def x #getter method\n\t\t@x\n\tend",
"def getX() \n @x \n end",
"def get_x; \t\t@x \t\t\tend",
"def getX\n @x\n end",
"def x=(x)\n end",
"def set(x, y)\n @x, @y = x, y\n end",
"def set(x, y)\n @x = x\n @y = y\n self\n end",
"def y=(val... | [
"0.67302454",
"0.66621244",
"0.6636133",
"0.65863734",
"0.6480267",
"0.6456387",
"0.6456264",
"0.6440891",
"0.63995874",
"0.63093054",
"0.6299624",
"0.62274045",
"0.6174075",
"0.61602247",
"0.6138953",
"0.6045652",
"0.6040855",
"0.60077816",
"0.60077816",
"0.60077816",
"0.599... | 0.0 | -1 |
for Ruby 1.8.6 support | def shellescape(str)
# An empty argument will be skipped, so return empty quotes.
return "''" if str.empty?
str = str.dup
# Process as a single byte sequence because not all shell
# implementations are multibyte aware.
str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
# A LF cannot be escaped with a backslash because a backslash + LF
# combo is regarded as line continuation and simply ignored.
str.gsub!(/\n/, "'\n'")
return str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ruby_version; '2.6.3' end",
"def private; end",
"def ext; end",
"def ext; end",
"def verdi; end",
"def berlioz; end",
"def kex_byte_requirement; end",
"def terpene; end",
"def probers; end",
"def target_ruby; end",
"def ruby_version\n RUBY_VERSION.gsub(/[^0-9]/,'').to_i\nend",
"def user_... | [
"0.6202769",
"0.61185557",
"0.6071659",
"0.6071659",
"0.57001626",
"0.56970984",
"0.5599947",
"0.5582617",
"0.5559545",
"0.5537444",
"0.5509361",
"0.5505944",
"0.5461351",
"0.5455352",
"0.5438943",
"0.54357547",
"0.54319966",
"0.542248",
"0.542248",
"0.542248",
"0.542248",
... | 0.0 | -1 |
tests the urlinfo method | def test_urlinfo
puts 'testing url info'
urlinfo = Topsy::Base.urlinfo("http://www.aycron.com")
assert urlinfo.class == Topsy::UrlInfo, "Class of urlinfo method doesn't return UrlInfo"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_match_info\n return @url_match_info\n end",
"def url_info(url)\n response = handle_response(self.class.get(\"/urlinfo.json\", :query => {:url => url}))\n Topsy::UrlInfo.new(response)\n end",
"def get_url_info\n # test this url, it it is valid SReality url\n ... | [
"0.66013134",
"0.65040106",
"0.6437108",
"0.6315921",
"0.6281823",
"0.61463976",
"0.6061934",
"0.60583526",
"0.5996423",
"0.5996423",
"0.59619117",
"0.5923301",
"0.5910185",
"0.5900284",
"0.5900284",
"0.58526355",
"0.58487105",
"0.5830209",
"0.5827681",
"0.5817748",
"0.581765... | 0.7669538 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.