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 |
|---|---|---|---|---|---|---|
PATCH/PUT /inputs/1 PATCH/PUT /inputs/1.json | def update
respond_to do |format|
if @input.update(input_params)
format.html { redirect_to @input, notice: 'Input was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @input.errors, status: :un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n raise to_yaml\n\n respond_to do |format|\n if @input.update(input_params)\n format.html { redirect_to @input, notice: 'Input was successfully updated.' }\n format.json { render :show, status: :ok, location: @input }\n else\n format.html { render :edit }\n fo... | [
"0.6625975",
"0.6494558",
"0.6494558",
"0.6494558",
"0.6494558",
"0.6494558",
"0.6494558",
"0.6494558",
"0.6423025",
"0.64133173",
"0.64133173",
"0.64133173",
"0.64133173",
"0.64133173",
"0.64133173",
"0.64133173",
"0.64133173",
"0.64133173",
"0.6405385",
"0.6385818",
"0.6283... | 0.64865154 | 8 |
DELETE /inputs/1 DELETE /inputs/1.json | def destroy
@input.destroy
respond_to do |format|
format.html { redirect_to inputs_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @input = Input.find(params[:id])\n @input.destroy\n\n respond_to do |format|\n format.html { redirect_to inputs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @input = Input.find(params[:id])\n @input.destroy\n\n respond_to do |format|\n format.ht... | [
"0.7373269",
"0.7045474",
"0.69982064",
"0.69982064",
"0.69982064",
"0.68879783",
"0.6537254",
"0.6522398",
"0.6506208",
"0.6461221",
"0.6440606",
"0.64076704",
"0.6401998",
"0.6374614",
"0.63727653",
"0.63696504",
"0.63326794",
"0.63042337",
"0.62839556",
"0.6283335",
"0.627... | 0.73094314 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_input
@input = Input.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def input_params
params.require(:input).permit(:key, :frameRate, :resolution, :aspectRatio, :interlaced, :container, :job_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981537",
"0.67835593",
"0.6748275",
"0.67436063",
"0.6736311",
"0.65937173",
"0.6503359",
"0.6498499",
"0.6482832",
"0.6478776",
"0.645703",
"0.6439998",
"0.63802195",
"0.6377008",
"0.6366287",
"0.632018",
"0.63016284",
"0.63011277",
"0.62932974",
"0.62919617",
"0.6290564... | 0.0 | -1 |
def create_unique_identifier self.id = SecureRandom.uuid create_unique_identifier if self.class.exists?(:id => self.id) end | def detect_carrier_add_info
ups = Regexp.new(/^(1Z?[0-9A-Z]{3}?[0-9A-Z]{3}?[0-9A-Z]{2}?[0-9A-Z]{4}?[0-9A-Z]{3}?[0-9A-Z]|[\dT]\d\d\d?\d\d\d\d?\d\d\d)$/i)
usps = Regexp.new(/(\b\d{30}\b)|(\b91\d+\b)|(\b\d{20}\b)/i)
usps2 = Regexp.new(/^(E\D{1}\d{9}\D{2}$|9\d{15,21})$/i)
usps3 = Regexp.new(/^91[0-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_identifier\n self.id ||= SecureRandom.uuid\n end",
"def create_uuid_for_id\n if self.id.nil?\n self.id = SecureRandom.uuid\n #self.id = SecureRandom.uuid.gsub('-','').upcase\n end\n end",
"def create_guid\n self.id ||= UUIDTools::UUID.random_create.to_s\n end",
"def identi... | [
"0.88206416",
"0.8664946",
"0.8613676",
"0.84424555",
"0.83321255",
"0.8260802",
"0.8228165",
"0.8225536",
"0.81548965",
"0.8125494",
"0.81214863",
"0.80941576",
"0.8077767",
"0.8049113",
"0.8032952",
"0.8001731",
"0.7998111",
"0.7955172",
"0.7881562",
"0.7876293",
"0.7860119... | 0.0 | -1 |
This method keeps executing the block called by yield until the block stops raising an error OR until x tries | def retry_before_failing
sleeping(NODE_QUERY_WAIT_TIME).seconds.between_tries.failing_after(MAX_NODE_QUERY_RETRIES).tries do
yield
end
yield
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yield\n wait\n case result\n when Exception\n raise result\n else\n result\n end\n end",
"def retry_until\n if @retry == 0\n job = yield\n else\n begin\n job = yield\n ... | [
"0.68544537",
"0.62551033",
"0.6200858",
"0.61955667",
"0.6190527",
"0.6157277",
"0.6101941",
"0.6101917",
"0.60656345",
"0.6043565",
"0.5938724",
"0.58524466",
"0.58451563",
"0.5836433",
"0.5821255",
"0.57782334",
"0.57695735",
"0.57585835",
"0.5751813",
"0.5751484",
"0.5745... | 0.58023244 | 15 |
===================== METHOD MISSING ===================== | def method_missing(name, *args, &block)
query_without_question_mark = /^has_(?<name>.+)_(?<type>#{ ELEMENT_TYPES })$/.match(name)
element_query = /^has_(?<name>.+)_(?<type>#{ ELEMENT_TYPES })\??$/.match(name)
element_find = /^(?<name>.+)_(?<type>#{ ELEMENT_TYPES })$/.match(name)
element_action = /^(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def implementation; end",
"def implementation; end",
"def schubert; end",
"def refutal()\n end",
"def custom; end",
"def custom; end",
"def private_method\n end",
"d... | [
"0.8158372",
"0.6998841",
"0.6998841",
"0.6998841",
"0.6998841",
"0.6942656",
"0.68572104",
"0.68572104",
"0.6855099",
"0.66887444",
"0.66706777",
"0.66706777",
"0.6620674",
"0.6608984",
"0.64553",
"0.644933",
"0.6438362",
"0.6405859",
"0.6332852",
"0.6294089",
"0.6294089",
... | 0.0 | -1 |
Retry block for node.find method above. | def retry_block(n = MAX_NODE_QUERY_RETRIES, &block)
begin
block.call
rescue Selenium::WebDriver::Error::StaleElementReferenceError, Capybara::TimeoutError, Capybara::ElementNotFound, Selenium::WebDriver::Error::UnknownError, Capybara::Driver::Webkit::NodeNotAttachedError
if (n -= 1) >= 0
sleep(30 / (n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retry_before_failing\n sleeping(NODE_QUERY_WAIT_TIME).seconds.between_tries.failing_after(MAX_NODE_QUERY_RETRIES).tries do\n yield\n end\n yield\n end",
"def try(&block)\n\n tries = REST_MAX_TRIES\n\n begin\n yield\n rescue\n tries -= 1\n ... | [
"0.669279",
"0.64966637",
"0.62885845",
"0.60105735",
"0.6005823",
"0.59410286",
"0.5929285",
"0.5856484",
"0.5844667",
"0.5785246",
"0.5763981",
"0.5679922",
"0.5641416",
"0.55891514",
"0.5549016",
"0.5540158",
"0.54744464",
"0.5470114",
"0.54663366",
"0.54635406",
"0.545497... | 0.65911436 | 1 |
Generate a "state" key that can be passed to the OAuth endpoints | def oauth_state
org = retrieve_organization
state = "#{org.name}:#{org.salt}:#{org.owner_email}"
Base64.urlsafe_encode64(Digest::SHA256.digest(state))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_personal_key\n self.personal_key = OaUtils.generate_random_key\n self.state = :active\n end",
"def get_key(state)\n state.sort.join('_')\n end",
"def create_auth_state\n\t auth_state = {:pathway => params[:gift_template][:pathway], \n :gift_template_id => params[:gift_template][:g... | [
"0.69740146",
"0.6727542",
"0.63871044",
"0.636521",
"0.6336195",
"0.6336195",
"0.6229482",
"0.61574787",
"0.61331517",
"0.61231816",
"0.6086252",
"0.60823876",
"0.6042761",
"0.6024395",
"0.6024395",
"0.60148674",
"0.59776145",
"0.5924675",
"0.5914351",
"0.59079206",
"0.58545... | 0.7164228 | 0 |
Normalize a Github URL into a Cyclid style source definition | def normalize(url)
uri = URI.parse(url)
source = {}
source['url'] = "#{uri.scheme}://#{uri.host}#{uri.path.gsub(/.git$/, '')}"
source['token'] = uri.user if uri.user
source['branch'] = uri.fragment if uri.fragment
source
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canonicalize_source(source)\n if source.is_a?(Hash) && source[:github]\n source = source.dup\n source[:git] = \"https://github.com/#{source[:github]}.git\"\n source.delete(:github)\n end\n source\n end",
"def parse_repo\n matches = @source_url.match @github_regexp\n ... | [
"0.6804975",
"0.62760067",
"0.6219566",
"0.6122229",
"0.6038586",
"0.6035815",
"0.6034577",
"0.60073704",
"0.5977274",
"0.59274054",
"0.58976954",
"0.588535",
"0.5858931",
"0.58440596",
"0.5813602",
"0.5800523",
"0.5791087",
"0.5764799",
"0.5749009",
"0.5714034",
"0.57110137"... | 0.67116916 | 1 |
Extract the "humanish" part from a Git repository URL | def humanish(uri)
uri.path.split('/').last.gsub('.git', '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repo_slug_from_url(url)\n url[%r{github.com[/:]([^/]*/(?:(?!\\.git)[^/])*)\\.*}, 1]\nend",
"def parse(url)\n matches = url.match(%r{[:/](?<user>[^/]+)/(?<repo>[^/]+)\\z})\n [matches[:user], matches[:repo].gsub(/\\.git\\z/, '')]\n rescue StandardError => e\n raise ParseError, 'Can not parse... | [
"0.75882846",
"0.687914",
"0.6862683",
"0.67006266",
"0.6687775",
"0.66173285",
"0.65410864",
"0.64908105",
"0.6456824",
"0.6399951",
"0.63889337",
"0.6376433",
"0.6371352",
"0.63341993",
"0.62853706",
"0.6277719",
"0.6247843",
"0.62295043",
"0.6168993",
"0.6160706",
"0.61432... | 0.7497892 | 1 |
Indicates whether its possible to capture the payment | def can_capture?(payment)
(payment.pending? || payment.checkout?) && !payment.response_code.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment.checkout?\n end",
"def can_capture?(payment)\n payment.pending? || payment... | [
"0.85729873",
"0.85729873",
"0.85729873",
"0.85729873",
"0.85729873",
"0.8420432",
"0.8406321",
"0.83981603",
"0.83726627",
"0.829914",
"0.829914",
"0.828406",
"0.82830316",
"0.8244026",
"0.76950306",
"0.7235041",
"0.713248",
"0.713248",
"0.71195644",
"0.71080416",
"0.7108041... | 0.83415586 | 10 |
Indicates whether its possible to void the payment. | def can_void?(payment)
!payment.void? && payment.pending? && !payment.response_code.blank?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state != 'void'\n end",
"def can_void?(payment)\n payment.state... | [
"0.8435381",
"0.8435381",
"0.8435381",
"0.8435381",
"0.8435381",
"0.8435381",
"0.8435381",
"0.8414637",
"0.8414637",
"0.83615565",
"0.83615565",
"0.8343824",
"0.83381695",
"0.83381695",
"0.8314558",
"0.7034634",
"0.67792964",
"0.6753569",
"0.66845626",
"0.6645172",
"0.655368"... | 0.82425183 | 16 |
Indicates whether its possible to credit the payment. Note that most gateways require that the payment be settled first which generally happens within 1224 hours of the transaction. | def can_credit?(payment)
return false unless payment.completed?
return false unless payment.order.payment_state == 'credit_owed'
payment.credit_allowed > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_credit?(payment)\n payment.completed? && payment.credit_allowed > 0\n end",
"def can_credit?(payment)\n payment.completed? && payment.credit_allowed > 0\n end",
"def can_credit?(payment)\n return false unless payment.state == 'completed'\n return false unless payment.order.pay... | [
"0.8107375",
"0.8107375",
"0.7975822",
"0.76718765",
"0.744201",
"0.7196401",
"0.71344215",
"0.6983333",
"0.6979606",
"0.6941891",
"0.6914664",
"0.6914664",
"0.6888789",
"0.68877214",
"0.6849643",
"0.67881995",
"0.67854303",
"0.6768373",
"0.6766829",
"0.6719905",
"0.6660727",... | 0.7957724 | 4 |
Returns a unique, deterministically reproducible index into an array We are hashing based on strings, let's use the ascii value of each string as a starting point. | def index(key, size)
key.sum % size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend",
"def generateKey(string)\r\n key = {}\r\n stringIterator = 0\r\n\r\n (string.length).times do\r\n charactersIterator = string[stringIterator] - 1\r\n divisorsIterator = 0\r\n divisors =... | [
"0.6383203",
"0.62403595",
"0.6144129",
"0.60989696",
"0.6059703",
"0.6045736",
"0.6044741",
"0.602797",
"0.59923834",
"0.59066594",
"0.5871428",
"0.58396715",
"0.58258843",
"0.5814923",
"0.5766527",
"0.57525396",
"0.57516277",
"0.5742264",
"0.5731274",
"0.5711685",
"0.570730... | 0.0 | -1 |
Simple method to return the number of items in the hash | def size
@items.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size\n return @hash.length\n end",
"def length\n hash.keys.length\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash.size\n end",
"def size\n @hash_array.length\n end",
"def size\n @hash_array.length\n end",
"def size\n ... | [
"0.828291",
"0.82106453",
"0.8109857",
"0.8109857",
"0.8109857",
"0.79691637",
"0.79691637",
"0.78121144",
"0.7748515",
"0.7684302",
"0.76763284",
"0.7656088",
"0.76353997",
"0.7629738",
"0.7615592",
"0.7615592",
"0.75738573",
"0.75696003",
"0.74785894",
"0.74441725",
"0.7398... | 0.0 | -1 |
=begin As a user, upon starting the CRM, I am presented with a prompt to add, modify, delete, display all, search by attribute, and exit. =end | def print_main_menu
puts "[1] Add a new contact"
puts "[2] Modify an existing contact"
puts "[3] Delete a contact"
puts "[4] Display all contacts"
puts "[5] Search by attribute"
puts "[6] delete_all"
puts "[7] exit"
puts "Enter a number: "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_by_attribute\n puts \"\\nPlease select a contact attribute to search by.\"\n print_search_by_attribute_options\n user_attribute = gets.chomp.downcase\n #Attepted to loop back through function after contacts displayed\n # if user_attribute == 5\n # display_all_contacts\n # search... | [
"0.59970486",
"0.5993395",
"0.58798575",
"0.58658797",
"0.58514714",
"0.5840038",
"0.58260834",
"0.5770405",
"0.5764896",
"0.5757198",
"0.5747621",
"0.5744629",
"0.572875",
"0.5710119",
"0.5688425",
"0.56677926",
"0.5645955",
"0.5633703",
"0.56207925",
"0.56119686",
"0.559239... | 0.5662488 | 16 |
=begin As a user, if I select add I am prompted to enter a 'first name', 'last name', 'email' and 'note'. =end | def add_new_contact
puts "\e[H\e[2J"
p "enter firstname"
first_name = gets.chomp
p "enter lastname"
last_name = gets.chomp
p "enter email address"
email = gets.chomp
p "enter note: optional"
note = gets.chomp
contact = Contact.create(
first_name: first_name,
last_na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_contact\nprint \"Contact first name:\"\nfirst_name = gets.chomp\n\nprint \"Contact last name:\"\nlast_name = gets.chomp\n\nprint \"Enter Contact's Email Address\"\nemail = gets.chomp\n\nprint \"Enter Note\"\nnote = gets.chomp\n\nContact.create(first_name, last_name, email, note)\n end",
"def add_pa... | [
"0.6682645",
"0.6556868",
"0.6545092",
"0.6487292",
"0.63802725",
"0.63300973",
"0.6308948",
"0.62953323",
"0.61733705",
"0.6155862",
"0.6113139",
"0.6099168",
"0.6095556",
"0.60854536",
"0.6066083",
"0.60628515",
"0.6060296",
"0.6023926",
"0.6006099",
"0.60005045",
"0.598974... | 0.6863274 | 0 |
Overrides the original Devise method | def reset_password_instructions(record, token, opts={})
I18n.locale = opts[:locale].to_sym if opts[:locale].present?
@receiver = record
# must call super at the end
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def devise_controller?; end",
"def current_user\n #super the main class of devise current_user\n super || guest_user\n end",
"def devise_scope(scope); end",
"def devise_parameter_sanitizer; end",
"def current_user\n # if a user is logged in we just use devise's implementation.\n super || guest... | [
"0.739315",
"0.6953081",
"0.68864566",
"0.6857896",
"0.6856911",
"0.6697071",
"0.6537552",
"0.6502013",
"0.64766014",
"0.64046663",
"0.6390906",
"0.6355852",
"0.63541466",
"0.6305523",
"0.6305523",
"0.6276121",
"0.6175761",
"0.6147142",
"0.61254966",
"0.612492",
"0.6090527",
... | 0.0 | -1 |
GET /rent_images GET /rent_images.json | def index
@rent_images = RentImage.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n return get_request(uri, @token)\n end",
"def images\n response = JSON.parse( self.class.get(\"#{BASE_URL}/contest/#{@api_key}/images\") )\n end",
"def getimagesinfo\n trek = Trek.find_by_id(params[:id]... | [
"0.747183",
"0.73400784",
"0.7327491",
"0.72308004",
"0.716566",
"0.7116451",
"0.7109326",
"0.7036103",
"0.70052963",
"0.7003318",
"0.6969881",
"0.6957036",
"0.6905841",
"0.6882117",
"0.68696594",
"0.685551",
"0.6818415",
"0.6799595",
"0.675445",
"0.6732359",
"0.6704539",
"... | 0.7560634 | 0 |
GET /rent_images/1 GET /rent_images/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @rent_images = RentImage.all\n end",
"def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \"application/json\", :disposition => \"inline\"})\n end",
"def images() \n uri = URI.parse(\"http://\" + @location.host +... | [
"0.7404441",
"0.72153795",
"0.70960164",
"0.70257413",
"0.70108265",
"0.70108265",
"0.69930077",
"0.69541675",
"0.6943511",
"0.6939472",
"0.6924728",
"0.6915424",
"0.6830568",
"0.6829322",
"0.6809298",
"0.6808921",
"0.67889327",
"0.6783966",
"0.6783966",
"0.6783966",
"0.67839... | 0.0 | -1 |
POST /rent_images POST /rent_images.json | def create
@rent_image = RentImage.new(rent_image_params)
respond_to do |format|
if @rent_image.save
format.html { redirect_to @rent_image, notice: 'Rent image was successfully created.' }
format.json { render :show, status: :created, location: @rent_image }
else
format.html... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @rent = Rent.new(rent_params)\n @rentpar = rent_params\n respond_to do |format|\n if @rent.save\n\n if params[:image]\n puts params[:image]\n params[:image].each { |image|\n @rent.rent_images.create(rent_id: @rent.id, image:image)\n }\n ... | [
"0.7920986",
"0.7389348",
"0.6688687",
"0.66749704",
"0.66384786",
"0.6632397",
"0.65949714",
"0.65824157",
"0.652193",
"0.6501194",
"0.6450269",
"0.6432711",
"0.63987696",
"0.6365365",
"0.6342925",
"0.63413274",
"0.63358325",
"0.6332496",
"0.6314013",
"0.6300564",
"0.6292124... | 0.7184774 | 2 |
PATCH/PUT /rent_images/1 PATCH/PUT /rent_images/1.json | def update
respond_to do |format|
if @rent_image.update(rent_image_params)
format.html { redirect_to @rent_image, notice: 'Rent image was successfully updated.' }
format.json { render :show, status: :ok, location: @rent_image }
else
format.html { render :edit }
format.jso... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @rent.update(rent_params)\n\n if params[:image]\n puts params[:image]\n params[:image].each { |image|\n @rent.rent_images.create(rent_id: @rent.id, image:image)\n }\n \n end\n \n format.html ... | [
"0.74965835",
"0.7282379",
"0.7064539",
"0.69201183",
"0.6819811",
"0.6818851",
"0.6658328",
"0.6658328",
"0.6658328",
"0.6658328",
"0.6639258",
"0.6572188",
"0.6571129",
"0.65608907",
"0.65608907",
"0.65608907",
"0.65608907",
"0.65608907",
"0.65608907",
"0.65608907",
"0.6540... | 0.7180967 | 2 |
DELETE /rent_images/1 DELETE /rent_images/1.json | def destroy
id = @rent_image.rent_id
@rent_image.destroy
respond_to do |format|
format.html { redirect_to "/rents/gallery/"+id.to_s, notice: 'Rent image was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @image = Image.find(params[:id])\n @image.destroy\n render json: {status: \"success\"}, status: :ok\n end",
"def destroy\n @image.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @image = Image.find(params[:id])\n \n... | [
"0.74352014",
"0.73909354",
"0.7364131",
"0.7344567",
"0.73016953",
"0.72948766",
"0.7286952",
"0.7286952",
"0.7286952",
"0.7286952",
"0.7286952",
"0.7286952",
"0.7282794",
"0.72614497",
"0.72614497",
"0.72614497",
"0.72614497",
"0.72614497",
"0.72614497",
"0.72614497",
"0.72... | 0.7583723 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_rent_image
@rent_image = RentImage.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def rent_image_params
params.fetch(:rent_image, {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /giveadvices GET /giveadvices.json | def index
#limits to show only current users adviceposts! - works - does it work if its null? -it should return a nil
@adviceposts = current_advisor.adviceposts
#limits to show only current users new messages! - works -
@messages = current_advisor.messages.page(params[:page]).order('created... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sevices = Sevice.all\n end",
"def show\n @advicepost = Advicepost.find(params[:id])\n\n @products = Product.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advicepost }\n end\n end",
"def show\n @getadvice = Getadvice.find(pa... | [
"0.6525906",
"0.6212388",
"0.6140065",
"0.6123995",
"0.60115737",
"0.59691435",
"0.5951241",
"0.59421253",
"0.59218425",
"0.583918",
"0.58373415",
"0.58373415",
"0.57983017",
"0.57941705",
"0.5781153",
"0.5761263",
"0.5748194",
"0.5745087",
"0.57441366",
"0.57438904",
"0.5741... | 0.0 | -1 |
step 1: reverse the integer step 2: compare the reversed integer to the given number Time Complexity: O(n) Space complexity: O(n) | def is_palindrome(number)
return false if number.class != Integer || number < 0
# create a varibale to store the result number
result = 0
prev_result = 0
copy_num = number
while copy_num != 0
current_digit = copy_num % 10
result = result * 10 + current_digit
# This is to handle overflow
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def palindromic_number?(int)\n arr = int.to_s\n if arr == arr.reverse\n p true\n else\n p false\n end\n\nend",
"def palindromic_number?(int)\r\n int.to_s == int.to_s.reverse\r\nend",
"def palindromic_number?(int)\n int.to_s == int.to_s.reverse\nend",
"def compare_number_after_swap(num)\n swap_... | [
"0.7056397",
"0.69901043",
"0.696128",
"0.69337785",
"0.692998",
"0.6928756",
"0.69241786",
"0.6918968",
"0.68833476",
"0.6875919",
"0.6831247",
"0.6831247",
"0.682575",
"0.68248963",
"0.6756652",
"0.6720304",
"0.67196804",
"0.6708567",
"0.6697651",
"0.66513556",
"0.66513556"... | 0.6062599 | 71 |
formats to a string | def format
"#{amount} #{currency}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s ; format ; end",
"def to_s\n format\n end",
"def format(text); end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format!; end",
"def to_s\n @source_string || ... | [
"0.80628",
"0.7460919",
"0.74485403",
"0.73777455",
"0.73777455",
"0.73777455",
"0.73777455",
"0.73777455",
"0.73777455",
"0.73777455",
"0.73777455",
"0.70901006",
"0.7045552",
"0.6943127",
"0.6922438",
"0.6922438",
"0.6857778",
"0.68269295",
"0.6792616",
"0.67666805",
"0.669... | 0.0 | -1 |
to get the currency object of money | def currency
money.currency
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def currency\n number_to_currency(self)\n end",
"def money(amount, name)\n Currency::Money.new(amount, name)\n end",
"def to_base_currency(money)\n bank.exchange_with(money, price_currency)\n end",
"def currency; end",
"def currency; end",
"def currency\n order.currency\n end",
"def... | [
"0.7613107",
"0.743933",
"0.7408067",
"0.7406263",
"0.7406263",
"0.7369911",
"0.73444813",
"0.7232111",
"0.7223922",
"0.7180694",
"0.7167575",
"0.7167575",
"0.7150755",
"0.7145329",
"0.71406937",
"0.71224636",
"0.70858604",
"0.7085225",
"0.7085225",
"0.70794135",
"0.70429695"... | 0.8082185 | 0 |
get the amount part of money | def amount
money.format(symbol: false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def money\n Money.from_amount(amount.to_f)\n end",
"def money\n to_d.money.to_s\n end",
"def money\n to_d.money.to_s\n end",
"def amount\n\n @amount_bigdecimal.to_f.round(2)\n\n end",
"def money(amount)\n number_to_currency amount.to_s, {:unit => 'R ', :delimiter => ',', :seperator => '.... | [
"0.7837267",
"0.75090575",
"0.75090575",
"0.7503321",
"0.7444543",
"0.7396598",
"0.73729944",
"0.73411286",
"0.7313585",
"0.7292622",
"0.72870016",
"0.72558576",
"0.7247728",
"0.7246833",
"0.7244398",
"0.72305894",
"0.7210818",
"0.71861583",
"0.7177771",
"0.7158744",
"0.71561... | 0.71273696 | 22 |
imperials is the imperials value | def metrics
standard.unit.convert_to_metric imperials
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_imperial_to_metric(measurement, conversion_factor)\n measurement * conversion_factor\nend",
"def imperial\n weight = get_weight(\"pounds\")\n height = get_height(\"inches\")\n\n bmi = \"#{(weight * 703) / (height * height) }\"\n puts \"Your BMI is: #{bmi}\"\n return bmi\nend",
"def ics( temps... | [
"0.6674475",
"0.5988048",
"0.58842003",
"0.57024825",
"0.5697752",
"0.5692208",
"0.5636939",
"0.5604348",
"0.56018656",
"0.56018054",
"0.55756456",
"0.5559663",
"0.55584055",
"0.550088",
"0.54956603",
"0.548406",
"0.5449152",
"0.5412982",
"0.5405265",
"0.5403666",
"0.5392998"... | 0.70229995 | 0 |
replaces a function with the arguments passed in command: the command to do the substitution in name: the name of the function args: the argument list expression: the expression of the function | def args_replace command, name, args, expression
initial_offset = offset = (command =~ /\b#{Regexp.escape name}\(/) + name.length + 1
bracket_count = 1
# find the last bracket
while offset < command.length
if command[offset] == ?(
bracket_count += 1
elsif command[offset] == ?)
bracket_count... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_sexp(sexp, predicate, function)\n Macro.new.replace(sexp, predicate, function)\nend",
"def expandify_element(element, *args)\n match = //\n to_process = nil\n args_index = 0\n\n # handle ${#} input replacement\n if (element =~ TOOL_EXECUTOR_ARGUMENT_REPLACEMENT_PATTERN)\n args_in... | [
"0.60614115",
"0.59935087",
"0.58503205",
"0.57638806",
"0.56547594",
"0.56185436",
"0.5611285",
"0.5553941",
"0.5503618",
"0.5503504",
"0.54755974",
"0.545029",
"0.54123527",
"0.5400505",
"0.5373905",
"0.5370587",
"0.53671026",
"0.53323203",
"0.5287228",
"0.5283144",
"0.5271... | 0.79910326 | 0 |
This method helps with building options_for_select for an object that has an association to a nested_set model returns options_for_select with the following rules: class_or_item must be a class (or object of a class) that uses acts_as_nested_set items listed in excluded_items array will not be included in the list (to ... | def nested_set_association_options_for_select(class_or_item, excluded_items=[], prompt="Please select..." )
throw ArgumentError.new "nested_set_association_options_for_select - class_or_item must use acts_as_nested_set" unless class_or_item.respond_to?(:roots)
def get_children(node, excluded... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nested_select(object, method, collection, options = {}, html_options = {})\n choices = nested_as_options(collection) { |record| [\"#{@indent} #{record.name}\", record.id] }\n select(object, method, choices, options, html_options)\n end",
"def items_for_select_menu(options = {}) \n # clean out... | [
"0.5853356",
"0.58169144",
"0.56734586",
"0.5573087",
"0.54456633",
"0.53816307",
"0.5375258",
"0.53659135",
"0.53654087",
"0.5328789",
"0.5318871",
"0.529789",
"0.5257301",
"0.5209802",
"0.52038795",
"0.5149186",
"0.5141086",
"0.5134187",
"0.5129201",
"0.51081806",
"0.507457... | 0.8240456 | 0 |
setter for adding songs to playlist | def song_tokens=(tokens)
self.song_ids = Song.ids_from_tokens(tokens)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_songs tracklist, playlist_object\n playlist_object.add_tracks!(tracklist)\n end",
"def add_song(song)\n @songs << song \n end",
"def add_song(song)\n songs << song\n end",
"def add_song(song)\n songs << song\n end",
"def add_song(song)\n @songs << song\n end",
"def add_s... | [
"0.7577467",
"0.7299398",
"0.7255439",
"0.72231287",
"0.7222883",
"0.7222883",
"0.7222883",
"0.7222883",
"0.7222883",
"0.7222883",
"0.7200994",
"0.7167695",
"0.7165535",
"0.716155",
"0.7127934",
"0.71273637",
"0.71273637",
"0.7107736",
"0.7107736",
"0.7107736",
"0.7107736",
... | 0.0 | -1 |
prepends the root section path to the path if the given pattern matches | def around_recognition(route, path, env, &block)
unless path =~ %r(^/admin) # TODO ... should be defined through the dsl in routes.rb
if match = path.match(@@pattern)
section = Site.find_by_host(env[:host_with_port]).sections.root
path.sub! /^#{match[0]}/, "#{match[1]}/#{section.ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_section\n $1 if @basename.to_s =~ /\\.(\\d\\w*)\\./\n end",
"def add_path_matcher(sections)\n match_path = ''\n sections.each do |section|\n if section[0] == '{' && section[-1] == '}'\n match_path = match_path + \"[^\\\\/]+\"\n else\n match_path = match_path + secti... | [
"0.5989368",
"0.5977211",
"0.5696764",
"0.56438255",
"0.5519941",
"0.54989153",
"0.54899365",
"0.5470857",
"0.5405657",
"0.5335277",
"0.5334511",
"0.53320706",
"0.53275424",
"0.52744454",
"0.52606744",
"0.5249739",
"0.5249739",
"0.52397794",
"0.5238244",
"0.5214252",
"0.52069... | 0.5597394 | 4 |
GET /card GET /card.json | def index
if Card.where(authorization_id: Authorization.current_id).count == 0 then
# Create default cards & tasks if empty for this authorization
tasks = Task.create([{name:"ContactList Example", done:true, authorization_id: Authorization.current_id},{name:"Kanban Example", done:false, authorizat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render json: @card\n end",
"def show\n render json: @card\n end",
"def show\n @card = PkCard.find(params[:id])\n render json: @card\n end",
"def show\n @card = Card.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json... | [
"0.8177671",
"0.8177671",
"0.81750333",
"0.80657166",
"0.80657166",
"0.80657166",
"0.80657166",
"0.80657166",
"0.805333",
"0.7898989",
"0.7884809",
"0.7831511",
"0.7773713",
"0.7414047",
"0.7391497",
"0.73547995",
"0.73455405",
"0.73202395",
"0.7317396",
"0.73155516",
"0.7266... | 0.0 | -1 |
GET /card/1 GET /card/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @card = PkCard.find(params[:id])\n render json: @card\n end",
"def show\n @card = Card.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @card }\n end\n end",
"def show\n @card = Card.find(params[:id])\n\n respond... | [
"0.7984984",
"0.79203784",
"0.79203784",
"0.79203784",
"0.79203784",
"0.79203784",
"0.7761157",
"0.7761157",
"0.77027035",
"0.76910007",
"0.76730764",
"0.76043975",
"0.7580899",
"0.7285507",
"0.72545516",
"0.72154176",
"0.7148023",
"0.712589",
"0.7112218",
"0.7091622",
"0.707... | 0.0 | -1 |
POST /card POST /card.json | def create
@card = Card.new(card_params)
@card[:authorization_id] = Authorization.current_id
respond_to do |format|
if @card.save
format.html { redirect_to @card, notice: 'Card was successfully created.' }
format.json { render :show, status: :created }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @card = Card.new(card_params)\n\n if @card.save\n render json: @card, status: :created, location: @card\n else\n render json: @card.errors, status: :unprocessable_entity\n end\n end",
"def create\n @card = Card.create(card_params)\n if @card.errors.any?\n render json:... | [
"0.8007552",
"0.785746",
"0.77633536",
"0.76443434",
"0.76374334",
"0.76257706",
"0.75999326",
"0.7595438",
"0.7566431",
"0.7566431",
"0.7566431",
"0.7566431",
"0.75103617",
"0.74918365",
"0.7449733",
"0.74182576",
"0.73416245",
"0.7326067",
"0.72852075",
"0.727796",
"0.72389... | 0.7441925 | 15 |
PATCH/PUT /card/1 PATCH/PUT /card/1.json | def update
respond_to do |format|
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
puts card_params
if @card.update(card_params)
format.html { redirect_to @card, notice: 'Card was successfully updated.' }
format.json { render :show, status: :ok, location: @card }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # @card = Card.find(params[:id])\n # @card.update(card_params)\n # render json: @card\n end",
"def update\n @card.update(card_params)\n if @card.errors.any?\n render json: @card.errors, status: :unprocessable_entity\n else\n render json: @card, status: 201\... | [
"0.7463383",
"0.7452306",
"0.7431029",
"0.74097556",
"0.73259944",
"0.7316192",
"0.7316192",
"0.7316192",
"0.7282309",
"0.7244808",
"0.7238653",
"0.7135418",
"0.7109382",
"0.7100514",
"0.7100514",
"0.7100514",
"0.7100514",
"0.7100514",
"0.7100514",
"0.7084221",
"0.7065368",
... | 0.7084596 | 19 |
DELETE /card/1 DELETE /card/1.json | def destroy
@card.destroy
respond_to do |format|
format.html { redirect_to card_url, notice: 'Card was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n # @card = Card.destroy(params[:id])\n # render json: 200\n end",
"def destroy\n @card.delete\n render json: {messsage: \"Movie/Series Card was successfully deleted.\"}, status: 204\n end",
"def destroy\n #@card = Card.find(params[:id])\n @card.destroy\n\n respond_... | [
"0.79048026",
"0.77135766",
"0.7698533",
"0.76649034",
"0.76649034",
"0.76649034",
"0.7621165",
"0.7590184",
"0.75511134",
"0.7539759",
"0.7500963",
"0.7495693",
"0.74601656",
"0.7455783",
"0.7440562",
"0.74256694",
"0.74256694",
"0.74256694",
"0.74256694",
"0.74256694",
"0.7... | 0.72505146 | 33 |
Use callbacks to share common setup or constraints between actions. | def set_card
@card = Card.where(authorization_id: Authorization.current_id).find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def card_params
params.require(:card).permit(:title, :description, :color, :status, :row_order_position)
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 |
minutes before appointment Notify our appointment attendee X minutes before the appointment time | def alert
# @twilio_number = ENV['TWILIO_NUMBER']
# @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']
# binding.pry
number_to_send_to = self.phone_number
twilio_sid = "ACca4bce79e5cdb95990cdf5a84b89c45b"
twilio_token = "5f5703217d9812afe53c1fceea9d0b3f"
tw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def appt_reminder_email_time\n if self.start_time.to_date > (self.created_at.to_date + 1)\n self.start_time - 12.hours\n end\n end",
"def update_remaining_appointments!(time_to_add)\n remaining_appointments_today.each do |appt|\n appt.update_attribute(:appointment_delayed_time,\n ... | [
"0.7341507",
"0.7205398",
"0.6692888",
"0.66680723",
"0.6648208",
"0.6289941",
"0.62241244",
"0.6103053",
"0.6059005",
"0.5996214",
"0.59829277",
"0.5951747",
"0.5945291",
"0.5890815",
"0.5878209",
"0.5867546",
"0.5843747",
"0.58108234",
"0.5771476",
"0.57576025",
"0.57400644... | 0.0 | -1 |
GET /batches GET /batches.json | def index
@batches = Batch.all
respond_to do |format|
format.html {}
format.json {
data = Hash.new
data["batches"] = @batches
return_success_response(data, "Request Successful", 200)
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @batches = Batch.page(params[:page]).per(15)\n @page = params[:page] || 1\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @batches }\n end\n end",
"def list_batches_with_http_info(opts = {})\n if @api_client.config.debugging\n ... | [
"0.75632226",
"0.7415398",
"0.73286897",
"0.711194",
"0.70886123",
"0.6862114",
"0.6839725",
"0.6813342",
"0.677585",
"0.65964687",
"0.64586616",
"0.63962585",
"0.63733006",
"0.6344917",
"0.6290671",
"0.6246177",
"0.62068826",
"0.61685944",
"0.61382574",
"0.61215985",
"0.6117... | 0.7686503 | 0 |
GET /batches/1 GET /batches/1.json | def show
respond_to do |format|
format.html {}
format.json {
data = Hash.new
data["batch"] = @batch
return_success_response(data, "Request Successful", 200)
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @batches = Batch.all\n respond_to do |format|\n format.html {}\n format.json {\n\n data = Hash.new\n data[\"batches\"] = @batches\n return_success_response(data, \"Request Successful\", 200)\n }\n end\n end",
"def index\n @batches = Batch.all\n end",
... | [
"0.73848814",
"0.71466523",
"0.711173",
"0.6936448",
"0.6916473",
"0.6729072",
"0.66923904",
"0.66800314",
"0.6679577",
"0.6555929",
"0.6404666",
"0.6400949",
"0.6339662",
"0.63126767",
"0.62823004",
"0.625739",
"0.6252372",
"0.61928767",
"0.6159479",
"0.614748",
"0.6057155",... | 0.5976446 | 23 |
POST /batches POST /batches.json | def create
@batch = Batch.new(batch_params)
team_member_ids = params[:team_member_ids]
respond_to do |format|
if @batch.save
format.html { redirect_to @batch, notice: 'Batch was successfully created.' }
format.json { render :show, status: :created, location: @batch }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @batches = Batch.all\n respond_to do |format|\n format.html {}\n format.json {\n\n data = Hash.new\n data[\"batches\"] = @batches\n return_success_response(data, \"Request Successful\", 200)\n }\n end\n end",
"def batch(request, request_options = {})\n ... | [
"0.6826564",
"0.6633915",
"0.6613268",
"0.65939456",
"0.6576259",
"0.657434",
"0.6560965",
"0.65256315",
"0.64826053",
"0.64776236",
"0.64512837",
"0.6449646",
"0.6444541",
"0.6424523",
"0.6405577",
"0.6363698",
"0.6327292",
"0.63068825",
"0.6279624",
"0.6279484",
"0.6255258"... | 0.6360841 | 16 |
PATCH/PUT /batches/1 PATCH/PUT /batches/1.json | def update
respond_to do |format|
if @batch.update(batch_params)
format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }
format.json { render :show, status: :ok, location: @batch }
else
format.html { render :edit }
format.json { render json: @batch.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @batch = Batch.find(params[:id])\n\n respond_to do |format|\n if @batch.update_attributes(params[:batch])\n format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }\n format.json { respond_with_bip(@batch) }\n else\n format.html { redirect_to @... | [
"0.70306814",
"0.6989383",
"0.6975556",
"0.684838",
"0.68064505",
"0.6696952",
"0.6689448",
"0.6689448",
"0.66380227",
"0.6565038",
"0.65494907",
"0.647014",
"0.6385986",
"0.6318869",
"0.6246466",
"0.6231996",
"0.6219665",
"0.61685556",
"0.6156123",
"0.6033362",
"0.6014959",
... | 0.6664314 | 10 |
DELETE /batches/1 DELETE /batches/1.json | def destroy
@batch.destroy
respond_to do |format|
format.html { redirect_to batches_url, notice: 'Batch was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @batch.destroy\n\n respond_to do |format|\n format.html { redirect_to batches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @batch = Batch.find(params[:id])\n @batch.destroy\n\n respond_to do |format|\n format.html { redirect_to batches_url ... | [
"0.7604413",
"0.7583041",
"0.75795025",
"0.75795025",
"0.7442352",
"0.74171066",
"0.7412871",
"0.7412871",
"0.73102266",
"0.73034376",
"0.7266451",
"0.7244553",
"0.7143779",
"0.7090966",
"0.6951617",
"0.6939564",
"0.6937238",
"0.6875119",
"0.6864587",
"0.67882687",
"0.6785654... | 0.7255194 | 13 |
Use callbacks to share common setup or constraints between actions. | def set_batch
begin
@batch = Batch.find(params[:id])
rescue Exception => e
return return_error_response(e.exception.to_s,404)
end
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 batch_params
params.require(:batch).permit(:course_id, :name, :price, :start_date, :schedule, :strength, :status ,:team_member_ids => [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Create the Note object | def initialize
@model = Evertils::Common::Query::Simple.new
@format = Formatting.new
@user = @model.user_info[:user]
@shard = @model.user_info[:shard]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @note = Note.new\n end",
"def create(params = {})\n note = build(params)\n note.save\n note\n end",
"def create_notes\n end",
"def create_note(contents, title = nil, description = nil)\n Dropio::Resource.client.create_note(self, contents, title, description)\n end",
"def new_no... | [
"0.7684043",
"0.76476824",
"0.7362498",
"0.7289316",
"0.72378147",
"0.719076",
"0.7185615",
"0.7063412",
"0.70445293",
"0.69815344",
"0.6976221",
"0.6890795",
"0.68620527",
"0.6837602",
"0.68306583",
"0.6799151",
"0.6760587",
"0.67371833",
"0.6716095",
"0.6699597",
"0.6683937... | 0.0 | -1 |
Wait for a note to exist | def wait_for_by_notebook(notebook, iterations = Evertils::Base::MAX_SEARCH_SIZE)
Notify.info("Waiting for #{notebook}...")
note = find_note_by_notebook(notebook)
begin
# didn't find it the first time? wait and try again
if note.entity.nil?
(1..iterations).each d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_or_create_note(opts)\n\t\treport_note(opts.merge({:wait => true}))\n\tend",
"def enter_note(test_data)\n hide_notifications_bar\n wait_for_element_and_type(note_text_area, test_data[UseOfCollections::NOTE.name])\n end",
"def wait\n\t\t\t\t@notification.wait\n\t\t\tend",
"def wait_for_by_title... | [
"0.6897465",
"0.64621437",
"0.6391215",
"0.62678283",
"0.608166",
"0.6063302",
"0.60514474",
"0.60508984",
"0.60508984",
"0.5917154",
"0.5888937",
"0.58729476",
"0.5825342",
"0.5736597",
"0.5735241",
"0.5720531",
"0.56681895",
"0.56428283",
"0.5633738",
"0.5621295",
"0.561010... | 0.57018757 | 16 |
Wait for a note to exist | def wait_for_by_title(title, notebook, iterations = Evertils::Base::MAX_SEARCH_SIZE)
Notify.info("Waiting for #{title}...")
note = find_note_by_title(title)
begin
# didn't find it the first time? wait and try again
if note.entity.nil?
(1..iterations).each do |it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_or_create_note(opts)\n\t\treport_note(opts.merge({:wait => true}))\n\tend",
"def enter_note(test_data)\n hide_notifications_bar\n wait_for_element_and_type(note_text_area, test_data[UseOfCollections::NOTE.name])\n end",
"def wait\n\t\t\t\t@notification.wait\n\t\t\tend",
"def test05_post_close... | [
"0.6897465",
"0.64621437",
"0.6391215",
"0.608166",
"0.6063302",
"0.60514474",
"0.60508984",
"0.60508984",
"0.5917154",
"0.5888937",
"0.58729476",
"0.5825342",
"0.5736597",
"0.5735241",
"0.5720531",
"0.57018757",
"0.56681895",
"0.56428283",
"0.5633738",
"0.5621295",
"0.561010... | 0.62678283 | 3 |
Find a note by note | def find_note_by_title(title, sleep = false)
sleep(5) if sleep
@model.find_note_contents(title)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_note(string)\n logger.info 'Searching for a string within a note'\n search string\n end",
"def find_note\n\t\t@note = Note.find(params[:id])\n\tend",
"def get_note(obj, id)\n obj['notes'].find {|n| n['persistent_id'] == id}\nend",
"def get_note(note_id)\n @notes[note_id]\n end",
"def... | [
"0.7608892",
"0.7047514",
"0.7018209",
"0.6873352",
"0.6873352",
"0.67006177",
"0.6597614",
"0.6212791",
"0.6199753",
"0.6164725",
"0.6124417",
"0.6100361",
"0.6023838",
"0.60042727",
"0.5918086",
"0.59029853",
"0.5881413",
"0.5865618",
"0.5856536",
"0.5852793",
"0.5776528",
... | 0.6114432 | 11 |
Find a note by notebook | def find_note_by_notebook(notebook, sleep = false)
sleep(5) if sleep
title = Formatting.date_templates[notebook]
@model.find_note_contents(title)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notebook\n @notebook ||= note_store.listNotebooks.select{|notebook| notebook.name == notebook_name}.first\n end",
"def notebook\n @note.notebookGuid\n end",
"def search_note(string)\n logger.info 'Searching for a string within a note'\n search string\n end",
"def find_notebook\... | [
"0.72482955",
"0.70199686",
"0.68029636",
"0.67772716",
"0.67260605",
"0.6438709",
"0.6371517",
"0.6353533",
"0.6353533",
"0.6298389",
"0.6230734",
"0.6211419",
"0.61774856",
"0.60875726",
"0.6066735",
"0.60615426",
"0.59805685",
"0.59652555",
"0.592485",
"0.59010124",
"0.587... | 0.8060751 | 0 |
draw a bar at given column with provided value (this command does not overwrite the screen) | def bar(column, value)
command "B#{column},#{value}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_values(total, cur)\n @value = (cur * 100 / total).round rescue 0\n width = ((@icon.width - 6) * @value / 100).round rescue 0\n\n # Draw bar\n @icon.clear\n @icon.draw_rect(0, 0, @icon.width - 1, @icon.height - 1, false)\n @icon.draw_rect(3, 3, width, @icon.height - 6, true) if(0 < width)... | [
"0.64666945",
"0.6215702",
"0.60802513",
"0.60577494",
"0.5940602",
"0.59248483",
"0.5922719",
"0.589253",
"0.5836636",
"0.58333576",
"0.5799103",
"0.579083",
"0.5780918",
"0.5755637",
"0.5750297",
"0.57136726",
"0.57136726",
"0.57136726",
"0.56806564",
"0.5675468",
"0.566160... | 0.7504416 | 0 |
do an action on a pixel at given column/row | def pixel(column, row, action)
command "P#{column},#{row},#{action.to_s.upcase}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pixel(row: 0, col: 0, color: \"W\")\n raise Useditor::Workspace::PixelLocationError.new(\"Row out of bounds\") if row < 0 || row > (@rows -1)\n raise Useditor::Workspace::PixelLocationError.new(\"Col out of bounds\") if col < 0 || col > (@cols -1)\n @image[row][col]\n end",
"def set_pix... | [
"0.64924747",
"0.6438124",
"0.6388152",
"0.63619256",
"0.6358999",
"0.63124216",
"0.63106084",
"0.62380743",
"0.6237493",
"0.6232126",
"0.6212054",
"0.6182094",
"0.6144389",
"0.61216664",
"0.6005289",
"0.5991073",
"0.59621125",
"0.5919221",
"0.59104174",
"0.5890347",
"0.58750... | 0.7726494 | 0 |
turn on/off all LEDs | def all(action)
command "ALL,#{action.to_s.upcase}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_on_leds\n @entry_led.on\n @exit_led.on \n end",
"def turnLightsOff\n @lightsOn = false\n end",
"def run\n led.on! # this does what you think it does\n sleep(1) # sleep for 1 second, kind of blunt, since it blocks everthing.\n led.off!\n sleep(1)\n end",
"def turn_on!\n @tur... | [
"0.8040124",
"0.72063804",
"0.7053904",
"0.69508684",
"0.6896147",
"0.68635553",
"0.6804198",
"0.67947173",
"0.67947173",
"0.6634929",
"0.65866333",
"0.6558669",
"0.6516391",
"0.64706",
"0.6415433",
"0.6318651",
"0.6242476",
"0.62194043",
"0.6210693",
"0.6201556",
"0.6179231"... | 0.0 | -1 |
scroll to left or right with given offset | def scroll(offset)
command "SCROLL#{offset}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scroll_left (x1,x2,y1,y2)\r\n #driver.swipe(start_x: 1000, end_x: 100, start_y: y, end_y: y, duration: 1000)\r\n #driver.swipe(start_x: x1, end_x: x2, start_y: y1, end_y: y2, duration: 1000)\r\n scroll_in_any_direction(x1,x2,y1,y2)\r\n end",
"def cursor_scroll_dn\n moveto(pos() + MSCROLL)\nend",
... | [
"0.7063579",
"0.644053",
"0.644053",
"0.63071156",
"0.63048923",
"0.6162941",
"0.6085208",
"0.6039461",
"0.6001291",
"0.5989853",
"0.59657437",
"0.59635425",
"0.5923462",
"0.5914706",
"0.5900576",
"0.5881104",
"0.5848924",
"0.58294195",
"0.58241266",
"0.5806432",
"0.5788537",... | 0.7441704 | 0 |
print a character at given column/row | def char(column, row, char)
command "T#{column},#{row},#{char}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char_at(column)\n line[column, 1]\n end",
"def print_char (i, j, s)\n if maze_mat[i][j] == 1\n print s\n else\n print \" \"\n end\n end",
"def move_to_column(x); puts \"\\e[#{x}F\" end",
"def display(line, column=0)\n result = \"\\e[s\"\n result << \"\\e[#{line.to_i}... | [
"0.7378273",
"0.7140198",
"0.70540226",
"0.6794265",
"0.67835265",
"0.6746956",
"0.6741829",
"0.6590594",
"0.65766704",
"0.657374",
"0.6566235",
"0.6552443",
"0.6552443",
"0.6552443",
"0.65387094",
"0.64899075",
"0.64899075",
"0.6478533",
"0.6432986",
"0.6426349",
"0.6421638"... | 0.7382112 | 0 |
print text (will be scrolled automatically) | def text(str)
@serial.write("#{str}\r")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_print(text)\n return text unless highline.page_at\n\n lines = text.lines.to_a\n while lines.size > highline.page_at\n highline.puts lines.slice!(0...highline.page_at).join\n highline.puts\n # Return last line if user wants to abort paging\n return \"...\\n#{lines... | [
"0.7307597",
"0.7247627",
"0.7181006",
"0.7138893",
"0.7073905",
"0.7011917",
"0.6984974",
"0.6972929",
"0.6921799",
"0.68991756",
"0.6870235",
"0.68508875",
"0.6838785",
"0.6807696",
"0.67343247",
"0.66999865",
"0.6693575",
"0.66796833",
"0.64863235",
"0.6458198",
"0.6434319... | 0.0 | -1 |
controller route actions GET /auth/assemblies | def index
@models = @model.get_many
respond_to do |format|
format.json do
render json: @models.to_json
end
format.html do
render :index
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @assemblies = Assembly.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assemblies }\n end\n end",
"def authorised_assets asset_class,projects=nil, action=\"view\"\n asset_class.all_authorized_for action, User.current_user, projects\n ... | [
"0.7329718",
"0.58147573",
"0.58066475",
"0.578521",
"0.57756835",
"0.5773556",
"0.5713083",
"0.57055205",
"0.57055205",
"0.5669257",
"0.56617886",
"0.5636892",
"0.5632952",
"0.5632952",
"0.56128055",
"0.5609874",
"0.5591478",
"0.55783176",
"0.5575782",
"0.55486387",
"0.55463... | 0.0 | -1 |
GET /customers GET /customers.json | def index
@customers = Stripe::Customer.all(:limit => 100)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @customers = @user.customers.all\n render json: @customers\n end",
"def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end",
"def index\n @user = current_user\n @customers = @user.custo... | [
"0.8047603",
"0.7958144",
"0.7873304",
"0.7785816",
"0.7759628",
"0.7743392",
"0.773739",
"0.7649949",
"0.7649949",
"0.76442534",
"0.76389146",
"0.75627637",
"0.74394524",
"0.74304146",
"0.74222744",
"0.7394979",
"0.72827095",
"0.7276728",
"0.7260948",
"0.7250168",
"0.7250168... | 0.0 | -1 |
before_action :student_validate, except: [:enter_exam, :check_status_exam, :question_student] | def layout_by_resource
if devise_controller?
"new_login"
else
"application"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_action \n end",
"def beforeValidation\n\n puts \"-----------beforeValidation------------\"\n\n #selfTest(self)\n\n puts \"-----------beforeValidation------------\"\n\n\n \n end",
"def pre_validation\n\n\n end",
"def determine_valid_action\n\n end",
"def... | [
"0.65966564",
"0.6199678",
"0.61837775",
"0.60897243",
"0.6086637",
"0.6003888",
"0.5980892",
"0.5968659",
"0.59161556",
"0.5897849",
"0.58839566",
"0.58488584",
"0.5848739",
"0.5838328",
"0.5820042",
"0.5820042",
"0.5799771",
"0.5796754",
"0.57797843",
"0.5775775",
"0.576954... | 0.0 | -1 |
very bad idea to go so deep | def index_joins
@rails.choice[:joins]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive => nil",
"def nesting() end",
"def depth; end",
"def traverse; end",
"def deep_each\n \n end",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n... | [
"0.6873934",
"0.6543271",
"0.64127475",
"0.6229251",
"0.6223764",
"0.5947107",
"0.59296095",
"0.59018165",
"0.579625",
"0.57234025",
"0.56508756",
"0.56508756",
"0.56508756",
"0.56508756",
"0.56508756",
"0.56508756",
"0.56508756",
"0.56508756",
"0.56508756",
"0.56508756",
"0.... | 0.0 | -1 |
which fields will be visible on the index page | def index_fields
if @rails.choice[:index_fields].blank?
@rails.resource.fields.keys
else
@rails.choice[:index_fields].collect{|field| field.split(':').first}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @fields = all_fields\n end",
"def index\n @fields = Field.all\n end",
"def document_show_fields\n Blacklight.config[:show_fields][:field_names]\n end",
"def index_fields\n self.class.fields.values.select { |field| field.index }\n end",
"def index_fields\n fields - %i[no... | [
"0.7662567",
"0.74445957",
"0.7378373",
"0.71553946",
"0.7101874",
"0.7101874",
"0.7100855",
"0.70655817",
"0.70632076",
"0.70022136",
"0.69699955",
"0.6936733",
"0.6891161",
"0.6891161",
"0.6891161",
"0.6887004",
"0.6841685",
"0.6835867",
"0.68349355",
"0.68349355",
"0.68273... | 0.75662607 | 1 |
convert company => company_id Used in the index action | def permitted_search_fields
fields = @rails.resource.fields
to_ids = []
expanded_fields = expand_association_to_ids fields
search_fields.each do |key|
next unless expanded_fields.keys.include?(key)
type = expanded_fields[key]
to_ids << (['references', 'be... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_id\n if @company.respond_to?(:to_hash)\n @company.fetch(:company_id) { @company }\n elsif @company.respond_to?(:company_id)\n @company.company_id\n else\n @company\n end\n end",
"def find_company\n Company.find(params[:company_id].to_i)\n end",
"d... | [
"0.7395401",
"0.69671273",
"0.69157135",
"0.6841032",
"0.6752074",
"0.67446",
"0.6722519",
"0.66124934",
"0.6605789",
"0.6588391",
"0.65137887",
"0.6483177",
"0.6477066",
"0.6464012",
"0.64526016",
"0.6399463",
"0.6376099",
"0.6356139",
"0.63144034",
"0.6314252",
"0.6314252",... | 0.0 | -1 |
if the field is belongs_to make so that fields contains the `field` and field_id | def expand_association_to_ids fields
expanded = {}
fields.each_pair do |name, type|
case type
when 'belongs_to'
expanded["#{name}_id"] = 'integer'
end
end
fields.merge(expanded)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_field?(field_name)\n direct_fields = self.fields\n foreigns.each do |f|\n foreign_dataset = self.class.dataset_from f\n if foreign_dataset\n direct_fields.concat foreign_dataset.fields\n end\n end\n direct_fields.include? field_name\n e... | [
"0.6311901",
"0.61518484",
"0.58919483",
"0.58468366",
"0.5833805",
"0.582897",
"0.57941765",
"0.5739344",
"0.57025427",
"0.56565154",
"0.562928",
"0.5626564",
"0.55656946",
"0.55642444",
"0.5564232",
"0.5548896",
"0.5538942",
"0.5531748",
"0.5525122",
"0.5484996",
"0.5447674... | 0.606811 | 2 |
convert company => company_id | def associations_to_ids hash
to_ids = {}
hash.each_pair do |key, type|
key_name = ['references', 'belongs_to'].include?(type.downcase) ? "#{key}_id" : key
to_ids[key_name] = type
end
to_ids
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_id\n if @company.respond_to?(:to_hash)\n @company.fetch(:company_id) { @company }\n elsif @company.respond_to?(:company_id)\n @company.company_id\n else\n @company\n end\n end",
"def add_company_id\n\t\tcompany = self.employee.company\n\t\tself.company_id =... | [
"0.7612697",
"0.69163626",
"0.6750859",
"0.67062044",
"0.66654855",
"0.6509545",
"0.63406587",
"0.62368554",
"0.6234156",
"0.62096906",
"0.6185554",
"0.6122597",
"0.6049482",
"0.6034934",
"0.60314256",
"0.60082114",
"0.5965468",
"0.59260285",
"0.5925552",
"0.5918353",
"0.5878... | 0.0 | -1 |
GET /authors/1 GET /authors/1.xml | def show
@author = Author.find(params[:id])
@all_articles = @author.articles.joins(:views, :content_source).where(["article_age = ? AND content_sources.code != ?", 30,"R"])
@non_inews = @all_articles.joins(:content_source).where(["content_sources.code = ? AND site_id != ?","I",1])
@inews = @all_articl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @author = Author.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @author }\n end\n end",
"def show\n @author_repository = AuthorRepository.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb... | [
"0.70273924",
"0.6813894",
"0.681174",
"0.6693451",
"0.6566892",
"0.6503373",
"0.6503373",
"0.6503373",
"0.6503373",
"0.64935154",
"0.64515775",
"0.63987124",
"0.63975984",
"0.6393685",
"0.6386732",
"0.6383627",
"0.6355221",
"0.63278633",
"0.6312841",
"0.6295561",
"0.6215661"... | 0.0 | -1 |
GET /authors/new GET /authors/new.xml | def new
@author = Author.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @author }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @author_repository = AuthorRepository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @author_repository }\n end\n end",
"def new\n @author = Author.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json {... | [
"0.7443775",
"0.70914954",
"0.68965006",
"0.6862118",
"0.6814787",
"0.6762321",
"0.66597104",
"0.66587365",
"0.66358787",
"0.66285527",
"0.66285527",
"0.66283363",
"0.6617511",
"0.6612877",
"0.6601246",
"0.6554841",
"0.6536575",
"0.65275043",
"0.65275043",
"0.65275043",
"0.65... | 0.7725193 | 0 |
POST /authors POST /authors.xml | def create
@author = Author.new(params[:author])
respond_to do |format|
if @author.save
format.html { redirect_to(@author, :notice => 'Author was successfully created.') }
format.xml { render :xml => @author, :status => :created, :location => @author }
else
format.html { re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_authors\n text = params[:text]\n puts \"str:#{text}\"\n request = Net::HTTP::Post.new(\"/personality-api/1/add_authors.json\")\n request.basic_auth BmnPersonalityApiSkeletonRor::Application.config.user_name, BmnPersonalityApiSkeletonRor::Application.config.password\n request.set_form_data({ ... | [
"0.648555",
"0.6042409",
"0.6015231",
"0.5988629",
"0.5929744",
"0.5927576",
"0.5909428",
"0.590168",
"0.58748627",
"0.58748627",
"0.58748627",
"0.58748627",
"0.5873977",
"0.58709115",
"0.58271414",
"0.58011883",
"0.57874465",
"0.5730848",
"0.5710593",
"0.5630088",
"0.5612164... | 0.6285127 | 2 |
PUT /authors/1 PUT /authors/1.xml | def update
@author = Author.find(params[:id])
respond_to do |format|
if @author.update_attributes(params[:author])
format.html { redirect_to(@author, :notice => 'Author was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @author = Author.find(params[:id])\n @author.update_attributes(params[:author])\n respond_with(@author)\n end",
"def update\n @book.authors = params[:book][:authors].delete_if { |x| x == '' }.map { |i| Author.find(i) } if params[:book][:authors].present?\n respond_to do |format|\n ... | [
"0.6331983",
"0.62035245",
"0.6054555",
"0.60039806",
"0.5974912",
"0.5966066",
"0.5953054",
"0.5952967",
"0.59294695",
"0.5922155",
"0.5914838",
"0.5844891",
"0.5838828",
"0.5788342",
"0.5779889",
"0.5770354",
"0.5770354",
"0.5770354",
"0.5770354",
"0.5770354",
"0.57546765",... | 0.63688856 | 1 |
DELETE /authors/1 DELETE /authors/1.xml | def destroy
@author = Author.find(params[:id])
@author.destroy
respond_to do |format|
format.html { redirect_to(authors_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n Author.destroy(params[:id])\n redirect_to '/authors'\n end",
"def destroy\n Author.delete(params[:id])\n redirect_to(authors_path)\n end",
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @author.destroy\n respond_... | [
"0.686459",
"0.68583137",
"0.6798691",
"0.6657785",
"0.6657785",
"0.6614151",
"0.6614151",
"0.65511936",
"0.65001845",
"0.6499806",
"0.6468818",
"0.64463925",
"0.64429945",
"0.64429945",
"0.64429945",
"0.64429945",
"0.64429945",
"0.64429945",
"0.6419601",
"0.6416993",
"0.6403... | 0.7327123 | 1 |
This method validates all the selected and is responsible for calling invalid/valid events | def valid?
result = true
selected.each do |view|
view.rmq_data.validations.each do |validation|
has_events = view.rmq_data.events
if validation.valid?(rmq(view).data)
if has_events && view.rmq_data.events.has_event?(:valid)
view.rmq_data.events[:valid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate \n#\tfirst check whether combo fields have been selected\n\t is_valid = true\n\t if is_valid\n\t\t is_valid = ModelHelper::Validations.validate_combos([{:vessel_code => self.vessel_code}],self)\n\tend\n\t#now check whether fk combos combine to form valid foreign keys\n\t if is_valid\n\t\t is_valid = s... | [
"0.7187285",
"0.715672",
"0.715672",
"0.7142176",
"0.68905145",
"0.684564",
"0.67118716",
"0.6701096",
"0.66997075",
"0.667705",
"0.6636022",
"0.6634045",
"0.6623421",
"0.66059524",
"0.65937626",
"0.65416104",
"0.6540964",
"0.6517969",
"0.65076065",
"0.64507526",
"0.6403189",... | 0.55726856 | 55 |
this method shortcuts specific validation rules. As such it should only be added to for universal validation needs. It must be kept as efficient as possible. | def universal_validation_checks (data, options={})
# shortcircuit if debugging
return true if RubyMotionQuery::RMQ.debugging?
# allow blank data if specified
return true if (options[:allow_blank] && (data.nil? || data.empty?))
# allow whitelist data if specified
return true if (optio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subclass_validations ; true ; end",
"def custom_validations\n self.validate_baseline && validate_baseline_date && \n self.validate_trial_days && self.validates_goal_name && self.validation_due_date\n end",
"def validation; end",
"def validation; end",
"def validations\n [:line_style... | [
"0.7086543",
"0.6851903",
"0.6830744",
"0.6830744",
"0.67079294",
"0.6637014",
"0.6568492",
"0.65260607",
"0.6472873",
"0.6460393",
"0.6460393",
"0.6460393",
"0.6450427",
"0.6450427",
"0.6450427",
"0.6450427",
"0.6443667",
"0.6435409",
"0.643194",
"0.64303666",
"0.64222115",
... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def skeleton_params
params.require(:skeleton).permit(
:name,
:slug,
settings_attributes: [:id, :_destroy, :type, :name, :value, :version_qualifier]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Get Instance Count Histogram | def ri_histogram(az, platform, size, options={})
options[:az] = az
options[:platform] = platform
options[:size] = size
request = get '/1/reporting/histogram', options
Hashie::Mash.new request
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def histo_counts\n @histo_counts ||= calculate_histo_counts\n end",
"def histograms\n metrics(Histogram)\n end",
"def calculate_histo_counts\n counts = []\n xx = x.dup\n histo_ranges.each do |i|\n counts << xx.size - xx.delete_if { |j| j > i[1] }.size\n ... | [
"0.75326955",
"0.685996",
"0.6805563",
"0.66530573",
"0.658357",
"0.65093786",
"0.64420104",
"0.6397016",
"0.6303631",
"0.6256727",
"0.62532616",
"0.6194095",
"0.615203",
"0.6061174",
"0.6059027",
"0.6003143",
"0.5987595",
"0.59839326",
"0.5978755",
"0.5972718",
"0.5971477",
... | 0.0 | -1 |
def [](pos) r, c = pos | def build_move_tree # Node[0,0]
@root_node = PolyTreeNode.new(@start_pos)
tree = [@root_node] #after first round tree = []
while !tree.empty?
#after line 39 => tree => [N(v(2,1)), N(v(1,2))]
res = tree.shift #tree = [] # res => TreeNode with the value of [2,1]
positions = new_move_position... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](pos)\n r, c = pos[0],pos[1]\n grid[r][c]\n end",
"def [](pos)\n row = pos.first\n col = pos.last\n @grid[row][col]\n end",
"def [](pos)\n @grid[pos[0]][pos[1]]\n # row,col = pos\n # @grid[row][col]\n end",
"def [](pos) #pos = [1,2]\n # x, y = pos\n ... | [
"0.75785005",
"0.73188806",
"0.7302657",
"0.729694",
"0.7238931",
"0.72283983",
"0.71659946",
"0.7148236",
"0.71439314",
"0.7132368",
"0.71185046",
"0.71185046",
"0.7088293",
"0.70881635",
"0.7042924",
"0.7040852",
"0.69896233",
"0.69882005",
"0.69846493",
"0.6978763",
"0.695... | 0.0 | -1 |
def build_move_tree p "asdfasdfasdlfj" sleep 1 self.root_node = PolyTreeNode.new(start_pos) build the tree out in breadthfirst fashion nodes = [root_node] until nodes.empty? current_node = nodes.shift current_pos = current_node.value new_move_positions(current_pos).each do |next_pos| next_node = PolyTreeNode.new(next_p... | def new_move_positions(pos)
candidates = KnightPathFinder.valid_moves(pos)
candidates = candidates.select { |e| !@considered_positions.include?(e) }
@considered_positions.concat(candidates)
return candidates
#@considered_positions = (@considered_positions.concat(candidates)).uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_move_tree #=> build the tree\n self.root_node = PolyTreeNode.new(start_pos) #=> root_node set to the start pos\n\n # build the tree out in breadth-first fashion\n nodes = [root_node]\n until nodes.empty?\n current_node = nodes.shift\n\n current_pos = current_node.value\n new_mo... | [
"0.9175775",
"0.9000952",
"0.8862723",
"0.8755282",
"0.8581117",
"0.85265106",
"0.8458384",
"0.84568965",
"0.8361926",
"0.7860596",
"0.7157782",
"0.714767",
"0.7035436",
"0.7018894",
"0.67968047",
"0.6691939",
"0.6674388",
"0.66083485",
"0.643518",
"0.6339106",
"0.6309171",
... | 0.0 | -1 |
Each subarray will have strings which are anagrams of each other Time Complexity: O(w n^2) ? THINKING.... Iterating through the string = O(n), summing each word = O(w); O(n w) checking for the word's sum in the hash and shovel onto array = O(1) returning the hash values = O(n) b/c if no words are anagrams, our hash wou... | def grouped_anagrams(strings)
return strings if strings.empty?
anagrams = {}
# for each word, if the sum is in the hash
strings.each do |word|
if anagrams[word.sum].nil?
anagrams[word.sum] = [word]
else
anagrams[word.sum] << word
end
end
return anagrams.values
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_anagrams(words)\r\n big_array = Array.new\r\n hash = Hash.new(0)\r\n words.each do |w| \r\n array = Array.new\r\n array = w.downcase.split(//)\r\n if hash.has_key?(array.sort) \r\n hash[array.sort]=hash[array.sort].push(w)\r\n else\r\n hash[array.sort]=Array.[](w)\r\n ... | [
"0.77875847",
"0.7774702",
"0.7766619",
"0.77547306",
"0.77300113",
"0.76665324",
"0.76329285",
"0.7569145",
"0.75421345",
"0.7539979",
"0.75197387",
"0.7513685",
"0.749747",
"0.748366",
"0.74831265",
"0.7472842",
"0.7444642",
"0.74369186",
"0.7414231",
"0.7414188",
"0.741229... | 0.74237925 | 18 |
This method will return the k most common elements in the case of a tie it will select the first occuring element. Time Complexity: O(n + k) Iterate through each element in order to count and add to hash O(n) Sort the hash: maybe O(log n) Put return first k elements = O(k) Space Complexity: O(n); worst case, hash is sa... | def top_k_frequent_elements(list, k)
return [] if list.empty?
element_count = {}
list.each do |element|
if element_count[element].nil?
element_count[element] = 1
else
element_count[element] += 1
end
end
sorted_elements = element_count.sort_by(&:first)
i = 0
max_nums = [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_k_frequent_elements(list, k)\n\n return [] if list.empty?\n \n # create a hash that has each element as key and number of occurrences as value: [1, 1, 1, 2, 2, 3] => {1=>3, 2=>2, 3=>1}\n hash = {}\n list.each do |element|\n if hash[element].nil?\n hash[element] = 1\n else \n hash[eleme... | [
"0.7957266",
"0.7929317",
"0.78502864",
"0.7811906",
"0.7798034",
"0.77936715",
"0.7775621",
"0.77672654",
"0.77605575",
"0.7752809",
"0.77316654",
"0.77315664",
"0.7683785",
"0.76756597",
"0.7651884",
"0.7635849",
"0.76263773",
"0.7612502",
"0.76046515",
"0.75953776",
"0.758... | 0.75547165 | 25 |
This method will return the true if the table is still a valid sudoku table. Each element can either be a ".", or a digit 19 The same digit cannot appear twice or more in the same row, column or 3x3 subgrid Time Complexity: ? Space Complexity: ? | def valid_sudoku(table)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_sudoku(table)\n table.each do |row|\n row_map = {}\n row.each do |elem|\n if elem != '.'\n if row_map[elem] \n return false\n else\n row_map[elem] = 1\n end\n end\n end\n end\n \n i = 0\n 9.times do\n column_map = {}\n table.each do |row|\n... | [
"0.8211502",
"0.81889945",
"0.8146699",
"0.8069601",
"0.80009776",
"0.79232717",
"0.7897237",
"0.76094997",
"0.75945985",
"0.73538876",
"0.734205",
"0.7302121",
"0.7013267",
"0.69960505",
"0.69183975",
"0.6854969",
"0.68095815",
"0.6777305",
"0.67575437",
"0.67113936",
"0.670... | 0.6978259 | 14 |
Book => xml: => :skip_instruct => true Category => :json => :dasherize => false Author => :all => :dasherize => false | def first_book
Book.find(:first)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @book = Book.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @book.to_xml(:include => { :keywords => {}, :sb_keywords => {}, :targetgroup => {}, :agegroup => {}, :signum => {}, :editions => { :include => { :descriptions => { :i... | [
"0.65045077",
"0.59051555",
"0.58521795",
"0.5815419",
"0.5782682",
"0.572954",
"0.57255226",
"0.5692258",
"0.56849456",
"0.5672873",
"0.56698275",
"0.5667937",
"0.56581014",
"0.56352717",
"0.559848",
"0.55929154",
"0.5581945",
"0.5569365",
"0.55536705",
"0.55375427",
"0.5533... | 0.0 | -1 |
Enumerate the PPP active connections. | def list
Enumerator.new do |y|
@cache.each_value do |re|
y << [re['address'], re['name']]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connections\n @mutex.synchronize do\n @connections.values.inject(0, &:+)\n end\n end",
"def get_connections\n @connected_to.keys\n end",
"def connections\n @connections.size\n end",
"def connections\n @connections.size\n end",
"def connections\n @connections... | [
"0.6588165",
"0.6537788",
"0.628825",
"0.628825",
"0.62706524",
"0.6180209",
"0.61736506",
"0.6163956",
"0.6145144",
"0.6120536",
"0.60523576",
"0.60159576",
"0.5992606",
"0.5988143",
"0.5985991",
"0.5972942",
"0.5968366",
"0.59525335",
"0.5898508",
"0.5885188",
"0.5857816",
... | 0.0 | -1 |
=index value of 15 i case insensitive | def come
p 'Welcome Home'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def az_index c\n c.upcase.ord - 'A'.ord\nend",
"def create_index2(word)\n word.each_char.map {|c| CHAR_MAP[c.downcase]}.reduce(:*)\n end",
"def char_at(index)\n self.to_array[index.to_i]\n #@word = TILE_VALUES[index]\n end",
"def index_of_small_letter(word)\n #word.gsub(/[[:lower:]]/)\nend",
... | [
"0.6508305",
"0.649827",
"0.6012254",
"0.59458476",
"0.5933818",
"0.58764404",
"0.5873269",
"0.5845312",
"0.57892764",
"0.5770418",
"0.5696458",
"0.5655363",
"0.56407475",
"0.56131804",
"0.5594958",
"0.5591342",
"0.5591342",
"0.5574778",
"0.5557818",
"0.5547689",
"0.55422676"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_donation_detail(id)
@donation_detail = DonationDetail.find(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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Before filters Confirms a loggedin user. | def logged_in_user
unless logged_in?
flash[:danger] = "Please log in."
redirect_to login_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signed_in_user_filter\n if signed_in?\n redirect_to root_path, notice: \"Already logged in\"\n end\n end",
"def appctrl_confirm_user\n redirect_to( signin_path() ) unless @current_user\n end",
"def confirm_logged_in\n unless session[:user_id]\n flash[:notice] = \"Please log in.\"\... | [
"0.6569166",
"0.6430658",
"0.6423167",
"0.64137745",
"0.63995165",
"0.62902534",
"0.6249426",
"0.6248803",
"0.6218758",
"0.6173909",
"0.612472",
"0.61157626",
"0.60806084",
"0.6062998",
"0.6040006",
"0.60308075",
"0.6022445",
"0.60193825",
"0.6015744",
"0.6000973",
"0.5993021... | 0.0 | -1 |
Confirms the correct user. | def correct_user
@user = User.find(params[:id])
redirect_to current_user unless current_user?(@user)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_user\n msg = \"You do not have permission to update another user's information\"\n require_correct_user(@user, msg)\n end",
"def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n... | [
"0.7474259",
"0.73411936",
"0.7317917",
"0.7183303",
"0.7174887",
"0.7049758",
"0.70130193",
"0.7012358",
"0.7006517",
"0.7006201",
"0.7003461",
"0.69663024",
"0.69136065",
"0.6911695",
"0.690295",
"0.6892608",
"0.68439376",
"0.6842948",
"0.68397075",
"0.683463",
"0.6826711",... | 0.0 | -1 |
Allert for non authorized action | def user_not_authorized
flash[:alert] = "You are not authorized to perform this action."
redirect_to(request.referrer || root_path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unauthorized\n end",
"def skip_authorization; end",
"def authorization; end",
"def user_action_on_resource_authorized\n end",
"def skip_authorization\n @_authorization_performed = true\n end",
"def authorise_action\n if !logged_in? or (@annotation.source != current_user)\n # TOD... | [
"0.73594624",
"0.7103822",
"0.6858122",
"0.6769781",
"0.67648417",
"0.6720445",
"0.6720445",
"0.6697826",
"0.6697826",
"0.6694636",
"0.66926926",
"0.6598255",
"0.6543917",
"0.6531534",
"0.6529454",
"0.65237707",
"0.65109235",
"0.6500639",
"0.6494309",
"0.6482946",
"0.6455142"... | 0.6265342 | 38 |
Method moves a card from game cards to specified hand | def deal_card(hand)
#hand is a string whose valid values are 'player_cards' and 'dealer_cards'
if !['player_cards','dealer_cards'].include?(hand)
raise "Unknown hand #{hand}"
end
#Check for an empty deck and reshuffle if necessary
if (session['game_cards'].length == 0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_card(guess)\n @board[guess].reveal\n @player.store_cards(guess, @board[guess].value)\n p @player.store\n end",
"def deal(card)\n\t\t@hand.push(card)\n\tend",
"def take_turn( player, hand )\n turn = nil\n case turn = player.take_turn(hand, @dealer.up_card)\n when :hit:\n han... | [
"0.72171724",
"0.7138571",
"0.7109097",
"0.7089356",
"0.706713",
"0.70414263",
"0.6991335",
"0.696174",
"0.6937465",
"0.69079477",
"0.6865887",
"0.68263716",
"0.6822201",
"0.68142325",
"0.67830056",
"0.6734797",
"0.6711113",
"0.6711113",
"0.6691604",
"0.6683179",
"0.66782117"... | 0.7269293 | 0 |
a method that checks if the specify hand busted | def bust?(hand)
return hand_total( hand ) > WIN_VALUE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def busted?(hand)\n if hand.busted?\n puts \"Busted!\"\n true\n else\n false\n end\n end",
"def busted?\n\t\treturn hand_busted?(@hand)\n\tend",
"def can_split_hand(hand)\n return nil\n end",
"def shouldHit\n # If 17 or above, lock the hand so it cannot receive any more cards\... | [
"0.82900345",
"0.81556726",
"0.7051722",
"0.7028727",
"0.69882107",
"0.69708616",
"0.6958255",
"0.69564843",
"0.6950832",
"0.6922749",
"0.68880975",
"0.6885143",
"0.68551177",
"0.6830759",
"0.68238235",
"0.6813831",
"0.6812661",
"0.6769677",
"0.6758388",
"0.6757798",
"0.67131... | 0.780418 | 2 |
Totals the points for a hand | def hand_total(hand)
#A flag to see if the hand contains an ace
have_ace = ! ( session[hand].select{|card| card['rank'] == "ace"}.empty? )
total = 0
#Look up the point value of each card in the hand
session[hand].each do |card|
total += RANK_TO_POINTS[ card['rank']]
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend",
"def points\n @puntos = 0\n students.each do |s| \n @puntos += s.points\n end\n @puntos += house_points\n end",
"def player_hand_total\n players_hand.inject(0) {|sum, card| sum + card.va... | [
"0.73431003",
"0.6987293",
"0.6947591",
"0.69389284",
"0.69366807",
"0.6907244",
"0.6902562",
"0.68712276",
"0.68426865",
"0.68361413",
"0.6812822",
"0.6750951",
"0.6711056",
"0.66690224",
"0.6664042",
"0.6629807",
"0.6557108",
"0.6540432",
"0.6540071",
"0.6514982",
"0.649941... | 0.75406694 | 0 |
Never trust parameters from the scary internet, only allow the white list through. | def validation_params
# params.require(:validation).permit(:id, :phone_num, :code)
params.permit(:id, :phone_num, :code)
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 |
def before_create self.on_base ||= "" self.outfielders ||= "" end | def redis_on_base
on_base
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_create()\n end",
"def before_create_save(record); end",
"def before_build\n\nend",
"def before_write\n end",
"def before_create_defaulter\n\t\tif self.order == nil\n\t\t\tself.order = \"\"\n\t\tend\n\n\t\tif self.show_others == nil\n\t\t\tself.show_others = false\n\t\tend\n\tend",
"d... | [
"0.7185991",
"0.6746148",
"0.66413254",
"0.6637903",
"0.6601145",
"0.6597145",
"0.64315075",
"0.637407",
"0.63470066",
"0.6310391",
"0.6273825",
"0.6266105",
"0.6258427",
"0.62444776",
"0.6213979",
"0.6174674",
"0.6160833",
"0.6131725",
"0.61163664",
"0.6060748",
"0.6051994",... | 0.0 | -1 |
Checks that arguments are rejected if they're wrong | def test_password
p1 = "mypassword123"
p2 = "mypassword1234"
s1 = Password.update(p1)
assert_equal(true, Password.check(p1,s1), "Password was not stored correctly")
assert_equal(false, Password.check(p2,s1), "Password check is broken")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missing_argument_invalid_argument\n\t\tc = Check.new\n\t\trefute c.check_arguments([1,1,'s'])\n\tend",
"def test_check_args_false\n c = Checker.new\n assert_equal false, c.check_args([1, 1, 1, 1])\n assert_equal false, c.check_args([1,1])\n assert_equal false, c.check_args(['something', 111]... | [
"0.7541694",
"0.7461994",
"0.74147946",
"0.73032457",
"0.7283505",
"0.72121847",
"0.71826154",
"0.71557444",
"0.71118116",
"0.7058357",
"0.70359516",
"0.70178556",
"0.69858646",
"0.6973148",
"0.6946238",
"0.6929936",
"0.6918174",
"0.68965983",
"0.6891664",
"0.6891247",
"0.688... | 0.0 | -1 |
we only support roundrobin placement for now | def monitor
loop do
sleep opts[:period]
group.engine.logger.info "#{group.banner}Monitoring group elasticity rule..."
# this is blocking because we don't want the rule to be triggered
# too many times.
if scale_up?
group.engine.logger.info "#{group.banner}Scaling ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def robin; end",
"def distributePrimaryRegions(priRegions)\n c = HBaseConfiguration.new()\n admin = HBaseAdmin.new(c)\n servers = Array.new()\n dServers = Array.new()\n dServers = admin.getClusterStatus.getDeadServerNames()\n serv = admin.getClusterStatus.getServers()\n serv.each do |s|\n if (!dServers... | [
"0.6329997",
"0.5912668",
"0.58263886",
"0.5501614",
"0.53285956",
"0.5323742",
"0.5299722",
"0.5284247",
"0.5208789",
"0.5192774",
"0.51694274",
"0.51518357",
"0.5129385",
"0.51264477",
"0.5107037",
"0.5098357",
"0.5088619",
"0.50847155",
"0.50799716",
"0.50762427",
"0.50710... | 0.0 | -1 |
GET /preparar_mates/1 GET /preparar_mates/1.json | def show
@empresa = Empresa.find(params[:empresa_id])
@producto = @empresa.productos.find(params[:producto_id])
@preparar_mate = @producto.preparar_mates.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mates(session, options={})\n json_request \"mates\", {:session => session}, options\n end",
"def show \n @inmate = Inmate.find(params[:id])\n render json: @inmate\n end",
"def show\n @mate = Mate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\... | [
"0.6900137",
"0.61212534",
"0.6053895",
"0.59736115",
"0.56997615",
"0.56443334",
"0.56409895",
"0.56301665",
"0.5618191",
"0.55862665",
"0.5568842",
"0.55616003",
"0.5523325",
"0.55153346",
"0.55008334",
"0.54803485",
"0.546482",
"0.5419408",
"0.5419333",
"0.54159236",
"0.54... | 0.5412004 | 21 |
POST /preparar_mates POST /preparar_mates.json | def create
@empresa = Empresa.find(params[:empresa_id])
@producto = @empresa.productos.find(params[:producto_id])
@preparar_mate = @producto.preparar_mates.build(preparar_mate_params)
respond_to do |format|
if @preparar_mate.save
format.html { redirect_to empresa_producto_preparar_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @mate = Mate.new(params[:mate])\n\n respond_to do |format|\n if @mate.save\n format.html { redirect_to @mate, notice: 'Mate was successfully created.' }\n format.json { render json: {mate: @mate}, status: :created, location: @mate }\n else\n format.html { render ac... | [
"0.55769044",
"0.53530544",
"0.5340133",
"0.5335051",
"0.52413374",
"0.5225603",
"0.5192981",
"0.5163182",
"0.51625496",
"0.5141869",
"0.51200545",
"0.5104154",
"0.51031977",
"0.5053567",
"0.50192183",
"0.49981737",
"0.49896193",
"0.4987082",
"0.49710417",
"0.49698752",
"0.49... | 0.6040503 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.