query_id
stringlengths
32
32
query
stringlengths
7
6.75k
positive_passages
listlengths
1
1
negative_passages
listlengths
88
101
3bae11812ed3bebd6c32eba5c4af67b2
Set lens by key.
[ { "docid": "1093db85d2f8d90dcf8e28191faedf04", "score": "0.0", "text": "def []=(key, entry)\n key = key_for(key) unless valid_key?(key)\n @hash[key] = entry if key\n end", "title": "" } ]
[ { "docid": "3b960333288a07238aa4e2952113c42a", "score": "0.67129654", "text": "def lset(key, index, value); end", "title": "" }, { "docid": "3b960333288a07238aa4e2952113c42a", "score": "0.67129654", "text": "def lset(key, index, value); end", "title": "" }, { "docid": "66...
e6335f94984527304cf99e8a934812a2
A simple method to fetch the item at the index. If index > size, then it 'wraps' around and looks again E.g. [0, 1, 2].wrap_fetch(4) returns 1 Operation is effectively fetch(index % size)
[ { "docid": "c13e64fc74c9bb895086ddc5d486f078", "score": "0.8689641", "text": "def wrap_fetch(index)\n return nil if empty?\n fetch(index % size)\n end", "title": "" } ]
[ { "docid": "2376334cc0ec1841bdaebb65625475f5", "score": "0.6554438", "text": "def get\n @buffer << fetch_one if @position == index_limit\n\n result = @buffer[rev_count]\n @position += 1\n result\n end", "title": "" }, { "docid": "e159ffd19c19edc5e477bb13e559476a", "score": "...
76965c0e76c7d360cc2a9a94266d4057
I worked on this challenge [by myself]. Your Solution Below
[ { "docid": "f52c5cb3c5be9500df08d44dc772f684", "score": "0.0", "text": "def array_concat(array_1, array_2)\n new_array = []\n new_index = 0\n index = 0\n\n while index < array_1.length\n \tnew_array[new_index] = array_1[index]\n \tindex += 1\n \tnew_index += 1\n end\n\n index = 0\n\n while ind...
[ { "docid": "b9960478999684c2b536f76e22f6fc63", "score": "0.6521408", "text": "def solution4(input)\n end", "title": "" }, { "docid": "f712d49ec6c615538b2e2aa846391fda", "score": "0.6286658", "text": "def challenge; end", "title": "" }, { "docid": "bca12d2414c241325b8beea...
ab100ee81b4e557ec1cf24e663cfa87c
GET /invoices/1 GET /invoices/1.json
[ { "docid": "a81945373733e4951b987de6ea99f9a1", "score": "0.0", "text": "def show\n end", "title": "" } ]
[ { "docid": "70c3a08e741dcc63a67a6e8a8ac10a85", "score": "0.7969666", "text": "def url\n '/api/invoices'\n end", "title": "" }, { "docid": "cfee3b2bec5c691b6dbe0961b07c847e", "score": "0.77583605", "text": "def index\n @invoices = @user.invoices.all\n ...
a1a5ac64eb5586dd80a617a18717fc2d
Returns the score you get when the search string matches the `text`.
[ { "docid": "f3a1b2070dd83dd0ed1bb23e3c493998", "score": "0.0", "text": "def maximum_score\n max_score_from_individual_letters = individual_letter_scores.reduce(:+)\n max_score_from_contiguous_letters = text.length - 1\n max_score_from_individual_letters + max_score_from_contiguous_letters\n en...
[ { "docid": "29371d9bad822caf6fa1480a05a387bd", "score": "0.720412", "text": "def score(text)\n count = count(text)[0].values\n expectedCount = count(text)[1].values\n #actually gets chi squared score (math stuff)\n sum = 0 \n count.each_index{|i| sum += (count[i] - expectedCount[i])**2 / expectedCo...
884679ffc5ff6b91978c9b054d26929c
Binds a provisioned service to an application on the target cloud.
[ { "docid": "f5229a3c8d849037fde929ab9fc9aa0f", "score": "0.70393556", "text": "def bind_service(name, appname)\n require_login\n raise CloudFoundry::Client::Exception::BadParams, \"Service Name cannot be blank\" if name.nil? || name.empty?\n raise CloudFoundry::Client::Exception::Ba...
[ { "docid": "3cbb806c29bbbb0c87699225d90469b3", "score": "0.7328457", "text": "def bind_app_services(app, service_instance_guid)\n service_instance = @client.service_instance(service_instance_guid)\n service_binding = @client.service_binding\n service_binding.app = app\n service_binding.servi...
e6942366c8f539dcd46ef3798818f2f4
This defines form columns. You can overwrite this method at each model if it is different from columns. Default is calling columns(). === SEE ALSO columns:: define default columns list_columns:: define list columns search_form_columns:: define search form columns
[ { "docid": "f88b06d30ad200043b2b10e12aeed72f", "score": "0.78690976", "text": "def form_columns\n columns\n end", "title": "" } ]
[ { "docid": "3933ed4d871861ee4a1881b56501658d", "score": "0.72753495", "text": "def search_form_columns\n columns\n end", "title": "" }, { "docid": "e6a76de4585cd238aadbc63c3d7dd70f", "score": "0.68062824", "text": "def predefined_columns\n helper_module = \"Netzke::H...
066675d4dedb4f6f6bebce652b9d552f
Execute the Choreo using the specified InputSet as parameters, wait for the Choreo to complete and return a ResultSet containing the execution results.
[ { "docid": "cfbde49ad46dd04a167b901f3c1f97ce", "score": "0.0", "text": "def execute(input_set = nil)\n resp = super(input_set)\n results = GetEncodersCountResultSet.new(resp)\n return results\n end", "title": "" } ]
[ { "docid": "c4ca32683e8ce75eb6a187d63df8fa77", "score": "0.76658994", "text": "def execute(input_set = nil)\n resp = super(input_set)\n results = DoneResultSet.new(resp)\n return results\n end", "title": "" }, { "docid": "6f7a7d9be674ad4cf17d6743eb1f7836", "scor...
f86a760cc2fd83300b1402b5d36227c5
Get a list of all the lifters that have a membership to a specific gym
[ { "docid": "ec9589cd6673e3fc9e57f4a3e12e763a", "score": "0.6145504", "text": "def lifters\n memberships.map {|m| m.lifter}\n end", "title": "" } ]
[ { "docid": "0a86882b98f2ae45bd4e43b17afa6ee6", "score": "0.80454403", "text": "def lifters_at_this_gym\n memberships_here = Membership.all.select {|membership| membership.gym == self}\n memberships_here.map {|membership| membership.member}\n end", "title": "" }, { "docid": "0e18fe8e82...
af54c2601bfca14c7f34a7a197087f34
POST /card_types POST /card_types.xml
[ { "docid": "b5a4b3f93f5038a586bcfcf711aac9bb", "score": "0.5292562", "text": "def create\n @card_type = CardType.new(params[:card_type])\n\n what_custom = WhatCustom.new\n what_custom.subfctr_name = 'RECHARGE_'+params[:card_type][:price_model]\n what_custom.description = params[:card_type][:...
[ { "docid": "6990ad8e01791be83fcb8effc9a622ce", "score": "0.6575279", "text": "def create\n @card_type = CardType.new(card_type_params)\n respond_to do |format|\n if @card_type.save\n format.html { redirect_to card_types_path, notice: (I18n.t 'activerecord.messages.card_type.created') }...
50b1ab16ae984d6b5d1ac79e0f48de58
POST /internal_informations POST /internal_informations.json
[ { "docid": "7664ad28c4d094267267fe6cd39d05a0", "score": "0.71466357", "text": "def create\n @internal_information = InternalInformation.new(internal_information_params)\n\n respond_to do |format|\n if @internal_information.save\n format.html { redirect_to @internal_information, notice:...
[ { "docid": "5be5b62b11cc675588f98d55d0d45365", "score": "0.6898038", "text": "def create\n @internal = Internal.new(internal_params)\n\n respond_to do |format|\n if @internal.save\n format.html { redirect_to @internal, notice: 'Internal was successfully created.' }\n format.json...
ad113f802526955c64b0a9194eab15c7
GET /group_lessons/1 GET /group_lessons/1.json
[ { "docid": "a81945373733e4951b987de6ea99f9a1", "score": "0.0", "text": "def show\n end", "title": "" } ]
[ { "docid": "2908e037b99a7d07aa43d340d5bc83e9", "score": "0.7588434", "text": "def index\n @group_lessons = GroupLesson.all\n @group_lessons.fetch_lessons\n end", "title": "" }, { "docid": "3a752db9509ebbb608a5fb51e7e5582a", "score": "0.7002161", "text": "def index\n #@lesso...
90e447b7b7644f91109fb174b8c40ee2
Updates a device type information Updates a device type information
[ { "docid": "805bfd9f6e1bc4564ce0abfb25f9ae56", "score": "0.6462555", "text": "def update_device_types_info_with_http_info(dtid, device_type_info, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DevicesManagementApi.update_device_types_info ...\"\...
[ { "docid": "da28347586ac3ba6302efe7b189bab70", "score": "0.7563436", "text": "def update_types\n\t\t[Device]\n\tend", "title": "" }, { "docid": "da28347586ac3ba6302efe7b189bab70", "score": "0.7563436", "text": "def update_types\n\t\t[Device]\n\tend", "title": "" }, { "doc...
a3a5b9bbe6f1ab8947430567293b879e
A wrapper method for the ipmitool's 'bmc guid' command that can be used to obtain the 'bmc guid' information for the node with a specified IP address (as a Hash map).
[ { "docid": "750594fea96ae65d6c8cd73aea8657d8", "score": "0.73069656", "text": "def bmc_guid(host_ip, username, passwd)\n command_failed, bmc_output = run_ipmi_command(host_ip, username, passwd, 'bmc', 'guid')\n if command_failed\n return [false, {}]\n end\n bmc_hash ...
[ { "docid": "97e03032ebeb3bbd4959765d73b4b99a", "score": "0.5797575", "text": "def get_bmc_by_uuid\n @command = :get_bmc_by_uuid\n includes_uuid = false\n # load the appropriate option items for the subcommand we are handling\n option_items = load_option_items(:command => :get...
ee407121436f584346ca5e82de76aef6
Registers the Pokemon or species as seen.
[ { "docid": "768ede979ca0ad4dd4a4e58c8394722e", "score": "0.72428334", "text": "def register_seen(species, form = nil)\n validate species => [Symbol, Integer, Species, Pokemon], form => [Integer, NilClass]\n if species.is_a?(Pokemon)\n pokemon = species\n species = pokemon.species...
[ { "docid": "f8f716baff3bc2a36c6689e553e65a34", "score": "0.78523165", "text": "def register_seen(species, form = nil)\n @pokedex.register_seen(species, form)\n end", "title": "" }, { "docid": "13883cb85c9af3ea246a5643db4f363c", "score": "0.6636602", "text": "def register_owned(sp...
2d46ca0a2f5bb2ded7b52b36737b3abb
GET /parte_laboratorios/1 GET /parte_laboratorios/1.json
[ { "docid": "ea4dc17883d02e747cc30c067ea288b9", "score": "0.0", "text": "def show\n if params[:name] == nil\n @pacientes = Paciente.paginate(:page => params[:page], :per_page => 5)\n else\n @pacientes = Paciente.or(nombre: /.*#{params[:name].downcase}.*/i)\n .or(...
[ { "docid": "e0febd08b1e28cea415972a00a7eac3c", "score": "0.689917", "text": "def set_parte_laboratorio\n @parte_laboratorio = ParteLaboratorio.find(params[:id])\n end", "title": "" }, { "docid": "abd77e4bab939c84775f605f36869a29", "score": "0.6866798", "text": "def index\n @la...
745f03af2f3560f2056f4e05423c421d
try dynamically finding a provider based on querying the providers to see what they support
[ { "docid": "f0ed3ba98b63e3b260342d5f5a0d1a16", "score": "0.656213", "text": "def maybe_dynamic_provider_resolution(resource, action)\n # log this so we know what providers will work for the generic resource on the node (early cut)\n Chef::Log.debug \"providers for generic #{resource.resource_n...
[ { "docid": "f61c92d612379a4d7eb6863458ea557d", "score": "0.7427442", "text": "def fetch_provider\n # provider is the explictly defined provider\n # otherwise look at the type to find the default provider, e.g. \"aws\"\n environment&.find_provider(provider || _type.split(\"_\").first)\n end", ...
08969e19c163f2314dc6cb75211e90b1
This makes the game being character selection mode.
[ { "docid": "9c8ad86136f0de07214dd4ec1a8b5bd3", "score": "0.6706209", "text": "def begin_character_selection combined_arguments\n player_list, @my_character_locations = combined_arguments\n\n @players = player_list\n $LOGGER.debug \"Game is moving into character selection phase. Othe...
[ { "docid": "1abb97d9ff1c16392497ca1e6e99e5c3", "score": "0.69804454", "text": "def game_mode\n return $prompt.select(\"Select game mode\",\n [\"Manual\", \"Simulate\"])\n \nend", "title": "" }, { "docid": "6b322a888b551eee85a279f41fd62759", "score": "0.68626827", "text":...
5beb2d118b69aa19103760b80cf3d85f
def current_assignment self.current_shift.assignment end
[ { "docid": "21cf72878adb45368aeca016a7c6552c", "score": "0.0", "text": "def has_assignment?\n if self.assignments.any?\n true\n else\n false\n end\n end", "title": "" } ]
[ { "docid": "d57ee944981f0df417c3b92d0ae75ae7", "score": "0.7338461", "text": "def current_assignment\n @a=Assignment.current.for_employee(self)\n @result = @a[0]\n end", "title": "" }, { "docid": "a60d731b087817385c2acd34f387a33e", "score": "0.717168", "text": "def c...
a08b9a2ff3f1570e9fe6af4636c152b6
lexer rule input! (INPUT) (in FoodLOOP.g)
[ { "docid": "99ac55b8c42727df2e59240fdb8d5ce0", "score": "0.65110254", "text": "def input!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 21 )\n\n\n\n type = INPUT\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -...
[ { "docid": "165aafb8572f0861ce62065be7f2cffd", "score": "0.6549322", "text": "def lex(input)\n loop do\n token, value, rest = lex_comment(input)\n if :comment == token\n raise \"infinite loop on input: #{input}\" if input == rest\n input = rest\n else\n return toke...
130f6d2b819d96ebf3ab81919ff5c5c3
delete schedule and delete status
[ { "docid": "e8ed899957a1a8f9bc2e733f48f4bdba", "score": "0.79294103", "text": "def deleteschedule(scid)\r\n scrbslog(\"======Begin to delete a schedule======\")\r\n @schedule = Schedule.find(scid)\r\n @user = User.find(@schedule.user_id)\r\n scrbslog(\"Author:\" + @user.name)\r\n @status ...
[ { "docid": "27d4840072bd91b91c2688cbdb16675d", "score": "0.7443488", "text": "def destroy\n @schedule.destroy\n end", "title": "" }, { "docid": "7923a4f609415a130493b086c3d70ab8", "score": "0.70769304", "text": "def destroy\n @schedule = Schedule.find(params[:id])\n\n @sche...
7f9ac71a25fca0c74c27a6bcd9d027e4
Run calendar token generator if not set
[ { "docid": "5170c7e9fa78ebd961c78980778c6a5e", "score": "0.6973342", "text": "def clean_calendar_token\n self.calendar_token = generate_calendar_token if calendar_token.blank?\n end", "title": "" } ]
[ { "docid": "7a1eff2a400044cced1a38bd5abbae60", "score": "0.6974363", "text": "def generate_calendar_token\n SecureRandom.urlsafe_base64(nil, false)\n end", "title": "" }, { "docid": "0a6048a18739b108877196d7f3aa7904", "score": "0.6314911", "text": "def generate_token\n begin\n...
d4c645c27464185e56db92eae691e97c
TODO: should probably do away with using instance_eval to set values like this. The interface for CourseInfo should probably become more uniformly hashlike as well, instead of using some hash access, and objectlike access for the properties that "always exist".
[ { "docid": "7aadd54b62021373b07258c3d7d9765b", "score": "0.0", "text": "def parse_heading(h1_node)\n\t\t\t@context.instance_eval do\n\t\t\t\t@title = h1_node.inner_text.strip # <h1>\n\t\t\t\t\n\t\t\t\t@title = @title.split(' - ').last\n\t\t\tend\n\t\tend", "title": "" } ]
[ { "docid": "b6bd53905b52cb3aaf649e86f5688f4f", "score": "0.6345677", "text": "def set_course_fields(_course)\n @course.name = params[:course][:name]\n @course.institutions_id = params[:course][:institutions_id]\n @course.directory_path = params[:course][:directory_path]\n @course.info = para...
e561e11bcf379ef5dc139c210017366b
Only allow a list of trusted parameters through.
[ { "docid": "bcf37e76edf02cd62047b514ee9684ce", "score": "0.0", "text": "def swap_params\n params.require(:swap).permit(:module_code, :slot_type, :current_slot, :completed, :startTime, :endTime, :venue, :day, :desired_slots => [])\n end", "title": "" } ]
[ { "docid": "3663f9efd3f3bbf73f4830949ab0522b", "score": "0.74768823", "text": "def whitelisted_params\n super\n end", "title": "" }, { "docid": "36956168ba2889cff7bf17d9f1db41b8", "score": "0.71700543", "text": "def set_param_whitelist(*param_list)\n self.param_whitelist...
a916f6af80e1e35d70ffcd4e4421ecbd
check if user is at least 13 years old
[ { "docid": "a2fc91c386ed23e4fe1c1852fcfeb1f6", "score": "0.76064783", "text": "def check_minimum_age\n errors.add(:birthdate, 'You must be 13 years or older to use our service') if birthdate && birthdate_changed? && birthdate.year > (Date.today - 13.years).year\n end", "title": "" } ]
[ { "docid": "9de98b181b28224260acf9e5dc0c5e89", "score": "0.736344", "text": "def verify_age(age, year_ob)\r\n #Example, if a person is born on July 2006, and the current date is Jan. 2016\r\n #the person is 9 years old, not 10. We need to account for this small error.\r\n if (Time.now.year - year_ob)...
28727f7818cc0a39549803833f714b9e
Whether we can remove this node from the reactor graph.
[ { "docid": "8890434761a0a65eaaad4c36c5de8352", "score": "0.0", "text": "def finished?; end", "title": "" } ]
[ { "docid": "ea7575a29ea91dffa40ad971fe5584dc", "score": "0.69821095", "text": "def remove?(node); end", "title": "" }, { "docid": "ea7575a29ea91dffa40ad971fe5584dc", "score": "0.69821095", "text": "def remove?(node); end", "title": "" }, { "docid": "8297892ab94331054d3205...
aef533cf83d431a192a0cc382480da78
PATCH/PUT /departamento1s/1 PATCH/PUT /departamento1s/1.json
[ { "docid": "40455576951f9193e9c72796f51d9d8c", "score": "0.70743257", "text": "def update\n respond_to do |format|\n if @departamento1.update(departamento1_params)\n format.html { redirect_to @departamento1, notice: 'Departamento1 was successfully updated.' }\n format.json { render...
[ { "docid": "0f8872308cd71e90aed963baf02fd23e", "score": "0.71670735", "text": "def update\n request = RestClient.put File.join(API_SERVER,\"rest-api/departments\"), { \n 'id' => params['id'], \n 'name' => params['department']['name'], \n 'description' => params['department']['des...
6abb4b4a515b1ba048c298f79eae3066
move backwards from an annotations' target until the last (or first) targeted anno, then return this one's canvas
[ { "docid": "2e96cab186f818d539bbbea64209d641", "score": "0.5429656", "text": "def getTargetingAnnosCanvas inputAnno\n return if inputAnno.nil?\n return(inputAnno.canvas) if (inputAnno.canvas.to_s.include?('/canvas/'))\n targetAnnotation = Annotation.where(\"annotation_id like ? \", \"%#{inputAn...
[ { "docid": "f9bacc3b27d0924e15435d1a01acf4ae", "score": "0.5819298", "text": "def getTargetingAnnosCanvas inputAnno\n return if inputAnno.nil?\n p \"in getTargetingAnnosCanvas: current anno_id: #{inputAnno.annotation_id} and current canvas: #{inputAnno.canvas}\"\n return(inputAnno.canvas) if (i...
50f9f185a7e0a4b735aeced6110bd841
Calculates hash code according to all attributes.
[ { "docid": "f2f0895ea917814b0063672093269aad", "score": "0.0", "text": "def hash\n [access_token_strategy, allowed_cors_origins, audience, authorization_code_grant_access_token_lifespan, authorization_code_grant_id_token_lifespan, authorization_code_grant_refresh_token_lifespan, backchannel_logout_...
[ { "docid": "d63333ed15c27e3f7526f0c6f8099546", "score": "0.7120726", "text": "def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end", "title": "" }, { "docid": "23cdf6a080837fbe407633be0799ea0e", "score": "0.7038658", "text": "def hash() end", "title": "...
46a2186ddbc142bbfe8e78e6bdd9553c
this is just a test array that you can use in IRB to evaluate your method: board = ["X", " ", " ", " ", " ", "O", " ", " ", " "] turn_count iterates over board, and adds 1 to count for each index that is not empty. note that we have used the `return` keyword at the end of the method so that the method returns the curre...
[ { "docid": "d606b9c3449a135b6f973aa72da22b14", "score": "0.0", "text": "def turn_count(board)\n count = 0\n board.each do |character|\n if character != \" \" && character != \"\"\n count += 1\n end\n end\n return count\nend", "title": "" } ]
[ { "docid": "5351d09f4f87f80de3ae579332dfdcab", "score": "0.81254005", "text": "def turn_count\n # use each to iterate over the elements of the board\n # to check if that element is an X or O and increment counter by 1\n # return value of each is the original array\n counter = 0\n @cells.e...
d75c3e153ed11e80ed99a054132876df
sync_with_facebook helper takes Facebooker::Location object
[ { "docid": "476938c3296ee13debc3eb2e4899ffbf", "score": "0.7100602", "text": "def sync_with_facebook_location(location, fb_location)\n # Always create - ignore errors if already exists\n attrs = {:location_type => location, :city => fb_location.city, :postal_code => fb_location.zip.to_s}\n begi...
[ { "docid": "ed370eb4d8b5d8c753f1baca9eed5887", "score": "0.6647137", "text": "def facebook_location\n api_user.location\n end", "title": "" }, { "docid": "3d7f3210f93acf0cb6881b645f2f1d02", "score": "0.60352397", "text": "def post_to_facebook\n restaurant = Restaurant.find...
3e6974765412d3cbf9bb7a93216a3799
Get list of all sources
[ { "docid": "7979823eddb5f7c3dd1e22d62e88187a", "score": "0.75100994", "text": "def sources\n \turl = URI.parse(\"#{@base_url}#{@api_version}/sources\")\n \t request = Net::HTTP::Get.new(url.request_uri)\n\n \t @headers.each {|k, v| request[k] = v }\n\n \t response = Net::HTTP.start(url.hostname...
[ { "docid": "f4e0e42e4719657b54d506c2ddda2f22", "score": "0.88284504", "text": "def list_sources\n log_message( \"Listing sources...\" ) unless @logging == false\n source_list = @connection.get( \"source\" )\n return source_list\n end", "title": "" }, { "docid": "e6c5e305c482a56dcd2...
98d3cbce65085e5e9c4f4dcba989c57f
Halve growth for closest fit This will lead to some shrinking in other direction when aspect ratio is reestablished
[ { "docid": "f6d2103459908226a02a7b739e6ddaa8", "score": "0.6153944", "text": "def halve_growth(growth)\n growth.each do |direction, value|\n growth[direction] = value.to_f / 2\n end\n\n growth\n end", "title": "" } ]
[ { "docid": "575ca3bf25ceca487ebae7ab5f5695b6", "score": "0.604677", "text": "def update_change_height\n return unless @mode == :take\n return unless open?\n optimal_h = fitting_height(1)\n return if self.height == optimal_h\n if self.height < optimal_h\n self.height = optimal_h\n ...
5ecaee2e5ca6b1f48f3ca987ea432743
won method" accepts board and returns the token "X" or "O" indicating the winner
[ { "docid": "f6d51f1aaef133f8b7fdf6326e9ff1a0", "score": "0.0", "text": "def winner(board)\n if won?(board)\n return board[won?(board)[0]]\n else\n return nil\n end\nend", "title": "" } ]
[ { "docid": "de0d454de7a1937004211f0e93144194", "score": "0.89160734", "text": "def winner\n if winner = won? == false\n return nil\n else\n win_token = @board[won?[0]]\n end\n if win_token == \"X\"\n return \"X\"\n elsif win_token == \"O\"\n return \"O\"\n end\n e...
eb01c16e86736f4799afe1dab1eeefc3
class PalindromicSubstrings < Test::Unit::TestCase def test_palindromes assert_equal(palindromes('abcd'), []) assert_equal(palindromes('madam'), ['madam', 'ada']) assert_equal(palindromes('hellomadamdidmadamgoodbye'), [ 'll', 'madam', 'madamdidmadam', 'madam', 'madamdidmadam', 'ada', 'adamdidmada', 'damdidmad', 'amdidm...
[ { "docid": "4b8764d4e5b63ab38fceab83c324ea89", "score": "0.78859746", "text": "def palindromes(str)\n palindromic_substrings = []\n\n substrings = substrings(str)\n puts substrings\n\n substrings.each do |substr|\n palindromic_substrings << str if str == str.reverse\n end\n\n puts palindromic_s...
[ { "docid": "a370195f66bb70dd5a701f5ff9e58b7b", "score": "0.8449807", "text": "def palindrome_substrings(string)\n\nend", "title": "" }, { "docid": "6314480826f9a12d3d760f94c4844f27", "score": "0.80484444", "text": "def palindrome_substrings(str)\r\n result = []\r\n substrings_arr =...
f74c29bdfc4a183e1ec1b91334cd5be2
Use callbacks to share common setup or constraints between actions.
[ { "docid": "6ae501e393652f3a4a4ef5a28fbf90e9", "score": "0.0", "text": "def set_subscription\n @subscription = Subscription.find(params[:id])\n end", "title": "" } ]
[ { "docid": "631f4c5b12b423b76503e18a9a606ec3", "score": "0.60339177", "text": "def process_action(...)\n run_callbacks(:process_action) do\n super\n end\n end", "title": "" }, { "docid": "7b068b9055c4e7643d4910e8e694ecdc", "score": "0.60135007", "text": "d...
2fb64570e6fe63706e15d75f8c80f4f1
Q561: Array Partition I
[ { "docid": "bc05c5a67bd9e54b913b5201743d9b9b", "score": "0.0", "text": "def array_pair_sum(nums)\n sorted = nums.sort\n i = 0\n sum = 0\n while i < sorted.length\n sum += [sorted[i], sorted[i+1]].min\n i += 2\n end\n sum\nend", "title": "" } ]
[ { "docid": "8f831a5a9c76a09c8d99cf08b8a7bae5", "score": "0.75378555", "text": "def partition(&block); end", "title": "" }, { "docid": "2c3342c52ebdbeb6ef881c49441a1027", "score": "0.72941285", "text": "def partition(array,left,right,pivotIndex)\n\tpivotValue = array[pivotIndex]\n\tfo...
b82a4aa07f2c625d69b0177b1e57f855
DELETE /hanks/1 DELETE /hanks/1.json
[ { "docid": "021932f274d6ccad1eb562045fc5878b", "score": "0.7437597", "text": "def destroy\n @hank.destroy\n respond_to do |format|\n format.html { redirect_to hanks_url, notice: 'Hank was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "title": "" } ...
[ { "docid": "442ebeb596a7ab6eabe6e143366e5cb3", "score": "0.72112274", "text": "def destroy\n @tank = Tank.find(params[:id])\n @tank.destroy\n\n respond_to do |format|\n format.html { redirect_to tanks_url }\n format.json { head :no_content }\n end\n end", "title": "" }, { ...
21648b2f877f4214e415524a6efa0eb0
This creates an user account with Just Giving
[ { "docid": "fad3a74110cfb3d22c55347ed2db467d", "score": "0.0", "text": "def create(params)\n put('v1/account', params)\n end", "title": "" } ]
[ { "docid": "7cbde0684f86edf4b235c7fe9a8168be", "score": "0.74724716", "text": "def account_creation\n\n username = prompt.ask(\"Choose a username!\\n\")\n while User.find_by(username: username) || username == \"\"\n puts \"Username taken - please try another\\n\"\n us...
d76ba2d3fda105a279f895f5240686f7
2. Form submit and redirect
[ { "docid": "82a63d4d30169024d21b28b037d1ddcb", "score": "0.0", "text": "def create\n\n # Artist.create(\n # name: params[:artist][:name],\n # dob: params[:artist][:dob]\n # ) ...SO LONG SUCKER!\n\n # Use the security-filtered version of the form params ('strong params')\n Artist.c...
[ { "docid": "32dc6497a8d295cc18328a234f7d943b", "score": "0.7242624", "text": "def redirect_submit\n # for amendments, provide the amendment reason and check if they want to request a repayment\n if @lbtt_return.amendment?\n redirect_to returns_lbtt_amendment_reason_path\n elsif @lb...
fcc9473d0db57dd8f404329ee3ec13f5
Hook called when module is included, extends a descendant with class and instance methods.
[ { "docid": "54219329d244ca789b41679341a331f6", "score": "0.7698925", "text": "def included(descendant)\n super\n descendant.extend ClassMethods\n end", "title": "" } ]
[ { "docid": "5a0e803d853eef02f6b1d309f0b92366", "score": "0.7826716", "text": "def included(descendant)\n super\n descendant.extend ClassMethods\n end", "title": "" }, { "docid": "5a0e803d853eef02f6b1d309f0b92366", "score": "0.7826716", "text": "def included(d...
7fb1aebadaa7cd2a4437914c08ece1cd
The base path provided for the route
[ { "docid": "6611468c53be4fde4a592fdf33ae4de9", "score": "0.8646196", "text": "def base_path\n @path\n end", "title": "" } ]
[ { "docid": "ca17248c3f0ae4869c6e9364561c6803", "score": "0.83886665", "text": "def base_path\n request.path =~ %r{\\/.*\\/} ? request.path.match(\"\\/.*\\/\")[0] : '/'\n end", "title": "" }, { "docid": "fb3e4abeda326b42aea5e5b53f2ca729", "score": "0.838352", "text": "def ...
f74c29bdfc4a183e1ec1b91334cd5be2
Use callbacks to share common setup or constraints between actions.
[ { "docid": "785fec7ad7bcfc4930706bda504130dc", "score": "0.0", "text": "def set_goal\n @goal = Goal.find(params[:id])\n end", "title": "" } ]
[ { "docid": "bd89022716e537628dd314fd23858181", "score": "0.6163163", "text": "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "title": "" }, { "docid": "3db61e749c16d53a52f73ba0492108e9", "score": "0.6045976", "text": "def action_hook;...
4105107f31aabf67e01ae900435c2e84
GET /sync_operations GET /sync_operations.json
[ { "docid": "ebb84cdc4ef18c3a2a03f91775af2a12", "score": "0.78120434", "text": "def index\n @sync_operations = SyncOperation.all\n end", "title": "" } ]
[ { "docid": "526a4ec5f0631cd7315a3b2d2552208c", "score": "0.6554324", "text": "def operations\n @client.operations\n end", "title": "" }, { "docid": "526a4ec5f0631cd7315a3b2d2552208c", "score": "0.6554324", "text": "def operations\n @client.operations\n end", "title": "" ...
f098086830144373ab25496d6600fedb
Destroy the given resource
[ { "docid": "408d1bfc1dc226ebe7ba5a7fa5cb94e2", "score": "0.7782404", "text": "def destroy(_resource, _params, _authorizer)\n raise NotImplemented\n end", "title": "" } ]
[ { "docid": "b380582a1d3611a57d0a980f9e075a9a", "score": "0.86408716", "text": "def destroy\n destroyer = ensure_destroyer\n destroyer.destroy(@resource)[:result]\n end", "title": "" }, { "docid": "689d65ec7ee37514a8f91246adcf0374", "score": "0.85689616", "text": "def destroy\n...
066cc7dade79e091fa1c3d2b4040caf2
Returns the payload hash as a flat array.
[ { "docid": "0d8651c29efab9e9b2470eaacb147fa2", "score": "0.7281857", "text": "def flat_payload\n self.payload.to_a.flatten\n end", "title": "" } ]
[ { "docid": "d1274e4e11be61fe3f1e187c4a236010", "score": "0.67466164", "text": "def to_array\n @array ||= begin\n array = to_hash.kind_of?(Array) ? to_hash : [to_hash]\n array.compact\n end\n end", "title": "" }, { "docid": "8fda64c56afdac4b77349a048592284...
420d33336b4030e02ffdf3d9663a9d4c
PUT /organisation_types/1 PUT /organisation_types/1.json
[ { "docid": "a5153d7648aee31b8fcdeaf5353d0658", "score": "0.7636972", "text": "def update\n @organisation_type = OrganisationType.find(params[:id])\n\n respond_to do |format|\n if @organisation_type.update_attributes(params[:organisation_type])\n format.html { redirect_to @organisation_...
[ { "docid": "aaf1bf10f855cf90573b1758aec0f65b", "score": "0.6782748", "text": "def update\n @organization_type = OrganizationType.find(params[:id])\n \n respond_to do |format|\n if @organization_type.update_attributes(params[:organization_type])\n flash[:notice] = 'OrganizationType wa...
22eae89bfd81a5fe6e7389646acc1e86
Public: Checks if self is a descendant of node node The node which might be a direct or indirect ancestor Returns true if self is a descendant, false otherwise
[ { "docid": "fceb39a9a728483f13258244f618866b", "score": "0.8753974", "text": "def descendant_of?(node)\n self.class.descendants_of(node).include?(self)\n end", "title": "" } ]
[ { "docid": "cf4091e92f3df330c7b165969850a12d", "score": "0.8536276", "text": "def descendant_of?(nd)\n (self == nd) ? true : is_ancestor?(nd)\n end", "title": "" }, { "docid": "c1d64fcf99e940eb05300af23b2ed56a", "score": "0.8442784", "text": "def descendant_of?(node)\n s...
536da9ef2fa826f3b7938272ebd440b4
DELETE /imes/d309hs/1 DELETE /imes/d309hs/1.json
[ { "docid": "43c30f9d4f9ca5a0b1256a15b5b26462", "score": "0.70297426", "text": "def destroy\n @imes_d309h.destroy\n respond_to do |format|\n format.html { redirect_to imes_d309hs_url, notice: 'D309h was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "t...
[ { "docid": "b1a17c1ee1af05c79fe156622df44818", "score": "0.74401855", "text": "def delete(path)\n begin\n response = client[path].delete :accept => 'application/json'\n rescue Exception => e\n puts e.inspect\n end\n end", "title": "" }, { "docid": ...
22181ecfb51b489985ba57c222ce5ce5
Public: Returns the value given by the user as an answer to the question, translated to English when appropriate.
[ { "docid": "460c7ed000e08a9ba3cad4f07f875e0e", "score": "0.7376336", "text": "def localized_answer_for(question)\n raw_value = answer_for(question)\n\n return raw_value unless question.is_a?(MultipleChoiceQuestion)\n return raw_value if raw_value.blank?\n\n I18n.t(\n \"survey.questions....
[ { "docid": "b3da5b860243f123fad65101d1eab78f", "score": "0.7046623", "text": "def question(...)\n print Colours.yellow(I18n.translate(...))\n end", "title": "" }, { "docid": "22bb48f148936cbec1349cc2d500ad1b", "score": "0.7041308", "text": "def questionAnswerText(question, us...
ef01fa2fac711b110680f4077134d264
GET /men_shoe_categories/1 GET /men_shoe_categories/1.json
[ { "docid": "a81945373733e4951b987de6ea99f9a1", "score": "0.0", "text": "def show\n end", "title": "" } ]
[ { "docid": "48b8eaac89bfd2785b01b151d00e5a4d", "score": "0.74254715", "text": "def index\n @men_shoe_categories = MenShoeCategory.all\n end", "title": "" }, { "docid": "3cba43678b445865af5afd71d9719de9", "score": "0.7004102", "text": "def get_categories()\n response = RestClie...
f62664211a55937f089babd4f93fe8c5
=begin :type key: Integer :type value: Integer :rtype: Void =end
[ { "docid": "b1750d6887bfe4e2344889e9d19ed263", "score": "0.0", "text": "def put(key, value)\n has_key = get(key)\n\n if has_key != -1\n @store[key].val = value\n elsif has_key == -1 && length < capacity\n n = @store[key] = LNode.new(value, key)\n append_to_tail(...
[ { "docid": "7f4da9e3fae663df19bd67f1a3a92f9c", "score": "0.72691745", "text": "def key=(value); end", "title": "" }, { "docid": "048ddd5b1ae95db52c41c26dd8300824", "score": "0.68428147", "text": "def put(key, value)\n return if @cap <= 0\n fav = @c[key]\n if fav\n ...
000700ac2a45342c16df8f08031f2d7b
Checks if this account is taxable (has a tax code associated with it).
[ { "docid": "e0e8de37a390099d69747a1317ac85cf", "score": "0.77304304", "text": "def taxable?\n !tax_code.blank?\n end", "title": "" } ]
[ { "docid": "3579e965b2bc14144473bd64ae51e469", "score": "0.8134562", "text": "def taxable?\n return false if taxable.nil? || taxable == false\n true\n end", "title": "" }, { "docid": "1c3d3912a7d6841a09959846a26be68b", "score": "0.79860955", "text": "def taxable?\n ...
96087638702da43be34e499061ccbd8b
Works as "apphelp_protected_links_to", but writes links in the style of buttons (assuming supporting CSS). You will usually want to wrap the output in a container DIV of class "buttons"; this is not done automatically in case you want to add other things inside the same container (such as a 'real' form submission butto...
[ { "docid": "c1468a72e49c23fc0ddd880e84942dd1", "score": "0.8176337", "text": "def apphelp_protected_buttons_to( *button_data )\n buttons = ''\n\n button_data.each do | data |\n next if ( data.nil? )\n\n action = data[ 0 ] # NB: This is the action the button will represent, not ...
[ { "docid": "7a4798092b8d78ec7decf977851a78c8", "score": "0.8053194", "text": "def apphelp_protected_button_to( action, options_for_link, options_for_url = nil )\n apphelp_protected_buttons_to(\n [ action, options_for_link, options_for_url ]\n )\n end", "title": "" }, { "docid": "...
f74c29bdfc4a183e1ec1b91334cd5be2
Use callbacks to share common setup or constraints between actions.
[ { "docid": "0d90c91987bd41141e6ebd6bcd12a785", "score": "0.0", "text": "def set_admin_album\n @admin_album = Admin::Album.find(params[:id])\n end", "title": "" } ]
[ { "docid": "631f4c5b12b423b76503e18a9a606ec3", "score": "0.60339844", "text": "def process_action(...)\n run_callbacks(:process_action) do\n super\n end\n end", "title": "" }, { "docid": "7b068b9055c4e7643d4910e8e694ecdc", "score": "0.6014297", "text": "de...
c5a67838fda3a9ec07ef0fd6f5693b60
Determine Cursor Location: Confirmation
[ { "docid": "832c7d36a71c56c68462b9030d9934e1", "score": "0.0", "text": "def is_ok?\n @index == 89\n end", "title": "" } ]
[ { "docid": "bed6b4c99cc6374702b187b5f2a55d30", "score": "0.6747471", "text": "def cursor_position()\n vars = all_variables()\n x = vars[\"cursor_x\"].to_i\n y = vars[\"cursor_y\"].to_i\n shown = vars[\"cursor_flag\"] != \"0\"\n [x, y, shown]\n end", "title": "" }, { "docid": ...
d5f87413cd32a19b1e3e900cb77cecc5
Return amount of mutations
[ { "docid": "8cdb0c840ff2687f66efd40e52ea644c", "score": "0.8822122", "text": "def amount_mutations\n mutations.length\n end", "title": "" } ]
[ { "docid": "63dbcd01dadd3c6e3a58b2fc4b9f28bd", "score": "0.7322674", "text": "def amount_kills\n mutations.select(&:success?).length\n end", "title": "" }, { "docid": "0a8754292e440ac8ffd7f689f3031fcb", "score": "0.63729054", "text": "def modifications_amount_by_commit\n ...
c6951859fed8ad5e399867486a35a485
All of the active conditions (conditions that have been set)
[ { "docid": "b1e5ed24d4f0266ca1b6cf57438abbcb", "score": "0.67321926", "text": "def conditions\n return @conditions if @conditions\n \n conditions_hash = {}\n \n association_objects.each do |association_object|\n relationship_conditions = association_object.con...
[ { "docid": "b8d21b1926881656141b8a77575a753f", "score": "0.79560024", "text": "def conditions\n @conditions_set.conditions\n end", "title": "" }, { "docid": "a1ac7385e899fbc016b0519c48811fdb", "score": "0.77657056", "text": "def conditions\n return nil unless active_elem...
8552d46f5d7925b28a725c0d7d9b0388
GET /karteikartes GET /karteikartes.json
[ { "docid": "70aea47830cce05b504366f8aa103c01", "score": "0.6806793", "text": "def index\n @karteikartes = Karteikarte.all\n end", "title": "" } ]
[ { "docid": "e06b50b6bd3b61d1af1c30fafd121d39", "score": "0.6682321", "text": "def index\n @artikels = Artikel.all\n\n render json: @artikels\n end", "title": "" }, { "docid": "3111028d50fbb5b5b07018f21f6b44ca", "score": "0.656657", "text": "def index\n @kites = current_user...
c8914ad029ccb032544ab79817f6a149
before_filter :check_owner, :except => [:mypapers, :citations_graph, :show]
[ { "docid": "7f1633eabddfa6fe167fbdb2158d2edc", "score": "0.0", "text": "def mypapers\n @sort = params[:sort]\n @order = 'title ASC'\n if @sort\n if @sort == \"alpha\"\n @order = 'title ASC'\n end\n if @sort == \"alpha2\"\n @order = 'title DESC'\n end\n if ...
[ { "docid": "48d9e78f1a71196cc459af22a8c44b76", "score": "0.69155717", "text": "def show\n redirect_to \"/boroughs\" unless is_owner?\n end", "title": "" }, { "docid": "f0c8ac564bd793c6ba6219a20414b367", "score": "0.67978835", "text": "def show\n # see before action filter\n e...
e544eda00417c05ff747bbbda8352bf5
Raises `ConditionNotMet` with specified error message if block does not return a truthy value. Intended for use with `audit`
[ { "docid": "c21258fce55024fa9e6a4bbcbdaf4393", "score": "0.64791316", "text": "def valid_if(error_key, message: nil)\n raise_condition!(error_key, message: message) unless yield\n end", "title": "" } ]
[ { "docid": "62af24e9a773f923673e8a6f28a513fc", "score": "0.67887", "text": "def valid_unless(error_key, message: nil)\n raise_condition!(error_key, message: message) if yield\n end", "title": "" }, { "docid": "20ca34e7dcfcc8647abdb03829a913ef", "score": "0.67401916", "tex...
9672b35bf6282a480b6b2a988054f298
Abandon the current record.
[ { "docid": "49a0b167ce822c91c59fd45bfdd607ef", "score": "0.674983", "text": "def abandon\n return unless current_user.can_abandon_record(@death_record)\n @death_record.abandoned = true\n @death_record.save\n render js: \"window.location.href='#{death_records_path}'\"\n return\n end", ...
[ { "docid": "bd76d842398550252ba82e0812318514", "score": "0.6893989", "text": "def abandon\n send \"<abandon/>\"\n end", "title": "" }, { "docid": "bd76d842398550252ba82e0812318514", "score": "0.6893989", "text": "def abandon\n send \"<abandon/>\"\n end", "title": ...
c657de4b70d266e9a3a784b999ea9e60
Never trust parameters from the scary internet, only allow the white list through.
[ { "docid": "f718ce5097611cadf156773810fe5b01", "score": "0.0", "text": "def payment_params\n params.require(:payment).permit(:stripe_customer_token, :user_id, :email, :plan)\n end", "title": "" } ]
[ { "docid": "e164094e79744552ae1c53246ce8a56c", "score": "0.69792545", "text": "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "title": "" }, { "docid": "e662f0574b56baff056c6fc4d8aa1f47", "score": "0.6781151", "text": "def strong_params\n params.requ...
68195da18369df45daa38b4bedcf4479
=> ["i", "o", "d", "t"] Reflection Part 3: Now write a method that takes a column number and returns all the elements in the column. Pseudocode still use global variable boggle_board create get_col method that takes col as an argument and return the column of boggle_board array. Initial Solution
[ { "docid": "5b1669b73f59d2fdef8f250a729009f6", "score": "0.7842367", "text": "def get_col(col)\n $boggle_board.transpose[col]\nend", "title": "" } ]
[ { "docid": "e59b9e5e2c095e748287a7f4149df86d", "score": "0.87485206", "text": "def get_col(col)\n boggle_board = [[\"b\", \"r\", \"a\", \"e\"],\n [\"i\", \"o\", \"d\", \"t\"],\n [\"e\", \"c\", \"l\", \"r\"],\n [\"t\", \"a\", \"k\", \"e\"]]\n column =[]\n ...
a4abfb270fca710cf31ae9e1ce1200fc
GET /reservationcs/1 or /reservationcs/1.json
[ { "docid": "a81945373733e4951b987de6ea99f9a1", "score": "0.0", "text": "def show\n end", "title": "" } ]
[ { "docid": "adff03f59c8c17487695797b6b12b2cc", "score": "0.6769146", "text": "def show\n @reservation = Reservation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reservation }\n end\n end", "title": "" }, { "docid...
d8800c76da08568ca0e2233cd6dcb2ef
player chooses to follow x_spot to the pond
[ { "docid": "8e4884527be9ec6f9fef03a8e2af87a0", "score": "0.0", "text": "def pond\n puts \"Nothing but sunken boats in the pond.\"\n puts \"Try the [B]each or the [C]ave next?\"\n x_spot_two = gets.chomp.downcase\n if x_spot_two == \"b\"\n beach\n elsif x_spot_two == \"c\"\n cave\n else pond...
[ { "docid": "ffdbcc44d47ea4bcbf54e0f909e00744", "score": "0.69493866", "text": "def move_to_next_spot\n face = @toy.face\n point_x = @point.x\n point_y = @point.y\n\n case face\n when \"north\"\n point_y += 1\n when \"south\"\n point_y -= 1\n when \"east\"...
9a86b4aecd6d989fe04d8efe8b747015
depends_on 'cmake' => :build
[ { "docid": "add18a78ae1928da85a1af1d62d6c721", "score": "0.0", "text": "def install\n # system \"./configure\", \"--disable-debug\", \"--disable-dependency-tracking\",\n \"--prefix=#{prefix}\"\n # system \"cmake . #{std_cmake_parameters}\"\n # system \"make install\" # ...
[ { "docid": "fd08643c30d054610ac53c5126caee0a", "score": "0.69059354", "text": "def package_depends_on\n depends_on\n end", "title": "" }, { "docid": "71faeb7b64e137f4f41251bf50a86201", "score": "0.675044", "text": "def install\n# Dependency tracking only, uncomment this sect...
51c63a345195a170727ba49ebcbafa69
The default dir_path is the same name as the component file but with '.yml' stripped
[ { "docid": "635d16702a73e21ea1240bad8aaef321", "score": "0.0", "text": "def dir_path\n @dir_path ||= (owner.respond_to?(:dir_path) ? owner.dir_path : \"#{parent.parent.dir_path}/#{node_name}\")\n end", "title": "" } ]
[ { "docid": "175eda5f272b861a5e4045f54cf44bcc", "score": "0.6913946", "text": "def yaml_dir\n 'config/'\n end", "title": "" }, { "docid": "fcba61b9922e3129ba0e20cb227781d7", "score": "0.67538506", "text": "def load_dir_path\n component_path = Pathname.new(dir_path)\...
2bd477e98c15f7fa7c969e758092c319
========= Installation ================= Install the plugin
[ { "docid": "8dfe884bb6f9d58a5f51cb29479af5a1", "score": "0.0", "text": "def install(context={})\n \n SystemConfiguration::Variable.first_or_create({:name => 'attachment.default_storage'}, \n {:value => '', :description => 'Default st...
[ { "docid": "f65a79d1e1c92a80e420c29a0110b978", "score": "0.7900202", "text": "def install\n end", "title": "" }, { "docid": "e09f07e4ab4aaeeaad771471cbf78864", "score": "0.7893614", "text": "def install; end", "title": "" }, { "docid": "e09f07e4ab4aaeeaad771471cbf78864",...
cec9e390190def822e3492baafa79f27
Returns the current view context, or builds one if none is saved.
[ { "docid": "f87542ee6f4f347f94a5273f975aed75", "score": "0.0", "text": "def current; end", "title": "" } ]
[ { "docid": "d01b6061400e1309df944ebd28245341", "score": "0.6551144", "text": "def oprah_view_context\n @oprah_view_context || view_context\n end", "title": "" }, { "docid": "fca6b161b76cac484c204c6336de4778", "score": "0.65444875", "text": "def view_context\n @view_context...
97d490e7ecab497c892b2995a7d645fb
Bonus homework: Make this faster but still recursive: Option a: memoisation Option b: iterative recursion I think I used both here
[ { "docid": "f7d20c29c2b707d8e622bd83b36a71c6", "score": "0.0", "text": "def fibonacci_bonus(index, a = 1, b = 1, total = 1)\n if index <= 2\n return total\n end\n total = a + b\n a = b\n b = total\n index -= 1\n fibonacci_bonus(index, a, b, total)\nend", "title": "" } ]
[ { "docid": "47cbac36dc5f96496558341a4b14878a", "score": "0.6959611", "text": "def fib_memoized(n)\r\n # If we don't already know the answer, we have to find it.\r\n if not @memo[n]\r\n if n<2\r\n @memo[n] = 1\r\n else\r\n @memo[n] = fib_memoized(n-2) + fib_memoized(n-1)\r\n end\r\n ...
5d9c2de575e6885bd6bfa806f4149e9d
Adds check for cached time attributes which have been type cast already and value can be used from cache. This prevents the raw time value from being type cast using default Rails type casting when writing values to the database.
[ { "docid": "f5850bb4705eb6c117b910fdfce82966", "score": "0.0", "text": "def read_attribute(attr_name)\n attr_name = attr_name.to_s\n if !(value = @attributes[attr_name]).nil?\n if column = column_for_attribute(attr_name)\n if unserializable_attribute?(attr_name, column)\n ...
[ { "docid": "e5cac046fce10386a938fbf5cfc6cc7e", "score": "0.62498486", "text": "def has_times(*attrs)\n options = attrs.extract_options!\n attrs.each do |attr|\n attr_reader attr\n define_reader_with_options(attr,options)\n define_method(\"#{attr.to_s}=\") do |val...
d070834b8e70ebb69f32b3d83bd4c0d5
Called internally when the event becomes unreachable
[ { "docid": "3de5ac57a66cd2dd938b42fe2c6aba74", "score": "0.62058026", "text": "def unreachable!(reason = nil, plan = self.plan)\n if !plan || !plan.engine\n unreachable_without_propagation(reason)\n elsif engine.gathering?\n unreachable_without_propaga...
[ { "docid": "f64975f2478e76fc86025a940b809bde", "score": "0.78141224", "text": "def unreachable_event(event)\n delayed_events.delete_if { |_, _, _, signalled, _| signalled == event }\n end", "title": "" }, { "docid": "02ed4bdaf4f8cdbda8e94ec3257837b2", "score": "0.654683...
632704bc9d3b79a6b55d2d3e91b1ad95
FIXME: Deprecated: remove for 4.1
[ { "docid": "c7e8875d6463fe8c7c3eef01744e96d2", "score": "0.0", "text": "def backup_path\n ActiveSupport::Deprecation.warn(\"Settings.backup_path is deprecated and will be removed from GitLab 4.1\", caller)\n backup.path\n rescue Settingslogic::MissingSetting\n File.expand_path(app['bac...
[ { "docid": "b6b2bcc0062aeb115edab7b10cbe6930", "score": "0.6373862", "text": "def desired; end", "title": "" }, { "docid": "9dcc74dd11eb115d21bf9af45b3ec4e3", "score": "0.63666016", "text": "def bodystmt; end", "title": "" }, { "docid": "9dcc74dd11eb115d21bf9af45b3ec4e3",...
2233e212a6a32ecb38bbd574d921a1f2
PATCH/PUT /otus/1 PATCH/PUT /otus/1.json
[ { "docid": "4e37d59628bd8ec302b5d6b8813d1509", "score": "0.65332854", "text": "def update\n respond_to do |format|\n if @otu.update(otu_params)\n format.html { redirect_to @otu, notice: 'Otu was successfully updated.' }\n format.json { render :show, location: @otu }\n else\n ...
[ { "docid": "7f635c1899cb622c531ea1e0638c056d", "score": "0.6716462", "text": "def update\n @ot = Ot.find(params[:id])\n\n respond_to do |format|\n if @ot.update_attributes(params[:ot])\n format.html { redirect_to @ot, notice: 'Ot was successfully updated.' }\n format.json { head...
3531ac9ac648436b365f3c0caa509a15
Get statistics about files, grouped by date API Key Scope: statistics / by_date
[ { "docid": "96b144273bd7078ca47e01c3e8e9951d", "score": "0.6922066", "text": "def statistics_by_date_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: StatisticsApi.statistics_by_date ...'\n end\n allowable_values = [\"file_...
[ { "docid": "cc22085f509271bddd477d6b10e56fd2", "score": "0.69033873", "text": "def file_stats\n @stats = @ff.get_stats\n end", "title": "" }, { "docid": "a92572b0281790e74146118ff87d2e76", "score": "0.68009156", "text": "def statistics_by_file_extension_with_http_info(opts = ...
2073d28f1b01f4c6c75e1e809f1ee3f7
Return true if browser is modern (Webkit (Safari 4.1+, Chrome 3.0+), Firefox 17+, IE9+, Opera 12+).
[ { "docid": "2b287c8fd37819489d616985c346d6aa", "score": "0.6099319", "text": "def modern?\n self.class.modern_rules.any? {|rule| rule === self }\n end", "title": "" } ]
[ { "docid": "c6a9e443da7624ba8f93f8bf1655711c", "score": "0.79674685", "text": "def cdo_modern?\n ver = version.to_i\n\n # IE 9+\n return false if ie? && ver < 9\n\n # Firefox 10+\n return false if firefox? && ver < 10\n\n # Opera 12+\n return false if opera? && ver < 12\n\n # Saf...
1bd9a9885be5e9834c8222791a986f94
Check if the synchronizer is enabled.
[ { "docid": "456a7436fdb3ca7bacff1799d82b9c73", "score": "0.0", "text": "def enabled?\n (super ||\n (!@remote_url.nil? && @remote_url.to_s.start_with?(\"#{@name}:\")) ||\n local_valid_repo?)\n end", "title": "" } ]
[ { "docid": "318ce2856047c65e92c22abeab9dbfab", "score": "0.79443806", "text": "def sync_enabled?\n defined?(@@sync_activated) && !!@@sync_activated\n end", "title": "" }, { "docid": "475010b4cb0de1c9b824572510bc0fc4", "score": "0.74304837", "text": "def enabled?\n synchroniz...
c0b801e4f54c8a23d06e0fa4322123f7
Sets input stream and resets variables
[ { "docid": "480fdde7fdeaacdc74de959a4c8a3a91", "score": "0.71442246", "text": "def input=(io)\n @input = io\n reset\n end", "title": "" } ]
[ { "docid": "7610e0065427a4897e77ef5750000857", "score": "0.6943854", "text": "def setio(input, output)\n @@input = input\n @@output = output\n end", "title": "" }, { "docid": "52aa0f939d9a5f9f34f1b3109278fc39", "score": "0.69344854", "text": "def set_input_stream_done\n @...
c5774b1a2ef1e0bf0bad69a7ce59af6e
GET /Colecciones/1 GET /Colecciones/1.xml
[ { "docid": "7fc20cc36588ff2c07a0be10583feb40", "score": "0.6987044", "text": "def show\n @coleccion = Coleccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @coleccion }\n end\n end", "title": "" } ]
[ { "docid": "45265ba73f1c7e43f0fccbe7576a80f0", "score": "0.6824058", "text": "def index\n cadena = getactividades(params[:id].to_i)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => cadena }\n end\n end", "title": "" }, { "docid"...
bf3a7957e0a96cf55e0464d096159f48
DELETE /post_replies/1 DELETE /post_replies/1.json
[ { "docid": "34bdd21adabebb6e9f44ce1341e2b1e2", "score": "0.0", "text": "def destroy\n if (current_user.id == @post_reply.user_id) or (current_user.is_admin)\n @post_reply.flag_delete = true\n @post_reply.save\n if @post_reply.save\n flash[:notice] = \"Reply was succefully delete...
[ { "docid": "27a4f9e2f99a1c0a360e27a0f5d084e2", "score": "0.7897856", "text": "def destroy\n @reply = Reply.find(params[:id])\n @reply.destroy\n @post = @reply.post\n\n respond_to do |format|\n format.html { redirect_to @post }\n format.json { head :ok }\n end\n end", "title...
32aa09e5f74c62f070a86d27d22ea628
Checks if the 2 guesses match
[ { "docid": "55cc1a01103eb076664493d76e10de39", "score": "0.7103082", "text": "def match?(guessed)\n g1r, g1c = guessed[0]\n g2r, g2c = guessed[1]\n\n if !(@newGrid[g1r][g1c] == @newGrid[g2r][g2c])\n @newGrid[g1r][g1c] = :-\n @newGrid[g2r][g2c] = :-\n ...
[ { "docid": "6d424df3706924fdc9fdf2e55e956ff7", "score": "0.73705107", "text": "def guessed_correctly?(guesses)\n @hash_boxes[guesses[0]] == @hash_boxes[guesses[1]] ? true : false\nend", "title": "" }, { "docid": "916d01d1255ce1aed62d2c7d7dd58acb", "score": "0.7368349", "text": "def ...
7c0bb8448066d03f3cbf948836a3334e
Returns true if the user is logged in, false otherwise.
[ { "docid": "4152a874a58c8cafc3b48bdead00d17e", "score": "0.0", "text": "def logged_in?\n !current_staff.nil?\n end", "title": "" } ]
[ { "docid": "31fb4132def094f5ed9925db932d58eb", "score": "0.89972186", "text": "def user_is_logged_in\n if session[:current_user] != nil\n return true\n else\n return false\n end\n end", "title": "" }, { "docid": "5e8797ab67adadcb571fb446716121fe", "score": "0.8901693"...
07a93a3248a02f6bb19ce6294f2ed745
Has the user submitted a news story in the last `NewsSubmissionBreak` seconds?
[ { "docid": "8d7d7bab6e58c8049ecd7c9530e69c41", "score": "0.6728817", "text": "def submitted_recently\n allowed_to_post_in_seconds > 0\nend", "title": "" } ]
[ { "docid": "874d17eee14de3b8b3e7eba5f3a4a174", "score": "0.67351604", "text": "def submitted_recently\n allowed_to_post_in_seconds > 0\n end", "title": "" }, { "docid": "5f9332de7ef14884e7144d61b3fc4d05", "score": "0.63165635", "text": "def is_scheduled_post?\n scheduled...
a2099a77c85e91272ae2f9e35b937953
Only allow a trusted parameter "white list" through.
[ { "docid": "bdca3748ff61118c8b2a1571c1b8ac79", "score": "0.0", "text": "def detalle_params \n params.permit(:nofra, :codigoprd, :cantidad, :impuesto, :precio)\n end", "title": "" } ]
[ { "docid": "c1f317213d917a1e3cfa584197f82e6c", "score": "0.7121987", "text": "def allowed_params\n ALLOWED_PARAMS\n end", "title": "" }, { "docid": "b32229655ba2c32ebe754084ef912a1a", "score": "0.70541996", "text": "def expected_permitted_parameter_names; end", "title": "...
99064e222c8839605c7ab9ebddd9358f
Whether or not the client is authorized
[ { "docid": "c47597da1a02cc1ac9939dc1f2b680c4", "score": "0.7434044", "text": "def is_authorized?\n !!token && !token.expired?\n end", "title": "" } ]
[ { "docid": "534a07400fe52f845349074a6d6d8ce1", "score": "0.8898652", "text": "def authorized?\n true\n end", "title": "" }, { "docid": "0b474081ffe6e52cf8c25a174d7298f0", "score": "0.8672039", "text": "def authorized?\n true\n end", "title": "" }, { "docid": "...
218b95c25101e8577410a4afaf6ef620
Look up the names mentioned by a page and return their details as LOD
[ { "docid": "b8b834efd956c896cd642fdadb73e172", "score": "0.0", "text": "def mentions_as_lod\n names = names_from_references\n mentions = []\n names.each do |name|\n record = get_record(@data, name)\n graph_maker = GraphMa...
[ { "docid": "baba53ac51ee5e2cb3b0e053f799740f", "score": "0.6888677", "text": "def scrape_name(page)\n page.css('div.lister-item').css('h3.lister-item-header').css('a').text.split(\"\\n\").map { |name| name[1..-1]}\nend", "title": "" }, { "docid": "07116f4794de620e43152b1be570e1e5", "s...
5ce6fb92b4d5eac8f6c45f358073f78b
Overridable method so a fake implementation can be used in tests
[ { "docid": "3f190cb9db0896e1c3f038277e9fa085", "score": "0.0", "text": "def _listen_class\n _listen_module::Listener\n end", "title": "" } ]
[ { "docid": "6513ed80c07083afaa67e08a17d5b972", "score": "0.7186872", "text": "def stubbed?; end", "title": "" }, { "docid": "3660c5f35373aec34a5a7b0869a4a8bd", "score": "0.6952349", "text": "def implementation; end", "title": "" }, { "docid": "3660c5f35373aec34a5a7b0869a4...
3a732de5f0c9d8a5f5247ffee4a2a778
GET /formularios GET /formularios.json
[ { "docid": "780f64b49a694a898c2b87620ee1e2ea", "score": "0.6695841", "text": "def index\n @formularios = Formulario.all\n end", "title": "" } ]
[ { "docid": "1a97d914aeed54fca51fdaa971af3233", "score": "0.7254745", "text": "def show\n @formulario = Formulario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @formulario }\n end\n end", "title": "" }, { "docid": ...
f06e33b4b0067ad15e02a84840cd40c4
sets the token X
[ { "docid": "78f8e460a16813cfffe9cea827b10668", "score": "0.0", "text": "def setplayer2\r\n\t\t@player2 = \"X\"\r\n\tend", "title": "" } ]
[ { "docid": "fbc7f3ad5f8eb51f40ffb198dc31e88d", "score": "0.7220695", "text": "def set_token(token)\n @token = token\n end", "title": "" }, { "docid": "a5bd862d7712f9bdf20603006edad8e8", "score": "0.70772594", "text": "def set_Token(value)\n set_input(\"Token\", value)\n ...
17a20f973add88c191ae991e2bffd80f
=> false Write a method, adult_in_group?(people), that accepts an array containing people. The method should return true if there is at least 1 person with an age of 18 or greater. The method should return false otherwise.
[ { "docid": "4383fb07adc1114d971f39aba75b0cb2", "score": "0.79168427", "text": "def adult_in_group?(people)\n people.any? {|people| people[:age] >= 18}\nend", "title": "" } ]
[ { "docid": "b0ddcbf2f2bf745eaff97550856c6e10", "score": "0.8501938", "text": "def adult_in_group?(people)\n adulting = true\n \n # Get the hash values from the people array, map the hash values into\n # a single dimensional array for easy manipulation.\n persons = people.each { |k, v| v }...
c657de4b70d266e9a3a784b999ea9e60
Never trust parameters from the scary internet, only allow the white list through.
[ { "docid": "95b6dde93e43b087031e92af548816d7", "score": "0.0", "text": "def book_params\n params.require(:book).permit(:id, :isbn, :title, :volume, :edition, :user_account_id, \n post_attributes: [:id, :price, :description, :book_id],\n authors_attributes: [:id, :au_fname, :au_lname, ...
[ { "docid": "3663f9efd3f3bbf73f4830949ab0522b", "score": "0.7495027", "text": "def whitelisted_params\n super\n end", "title": "" }, { "docid": "13a61145b00345517e33319a34f7d385", "score": "0.69566035", "text": "def strong_params\n params.require(:request).permit(param_whit...
f74c29bdfc4a183e1ec1b91334cd5be2
Use callbacks to share common setup or constraints between actions.
[ { "docid": "503490b9ae1cb5fd68ab0cd1b3445124", "score": "0.0", "text": "def set_rh\n @rh = Rh.find(params[:id])\n end", "title": "" } ]
[ { "docid": "bd89022716e537628dd314fd23858181", "score": "0.6163163", "text": "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "title": "" }, { "docid": "3db61e749c16d53a52f73ba0492108e9", "score": "0.6045976", "text": "def action_hook;...
900badac88bd1bf0338f4055a5351042
Comparator to sort strings such that letters (alphabetic characters) come before numbers and other characters
[ { "docid": "af66abe2b7242c339001bcba786d0de5", "score": "0.6975927", "text": "def alphasort(other)\n 0.upto((self.length < other.length ? self.length : other.length) - 1) do |i|\n next if self[i] == other[i] # Characters the same, skip to next character.\n if self[i] =~ /[a-zA-Z]/ && !(othe...
[ { "docid": "89900488c7498652f9057aaeaffc813f", "score": "0.7302941", "text": "def alphabetize!\n sort! { |a, b| grouped_compare(a, b) }\n end", "title": "" }, { "docid": "f93e1c8f3a492b75c9b601ee41cc53de", "score": "0.7293764", "text": "def alphabetized(string)\n string.delete('...
1eb554430be791fe1d58c1e44dc62565
returns true if the given user is the current user
[ { "docid": "6855b85993c6e9a61d6399a477ce5541", "score": "0.0", "text": "def current_doctor?(doctor)\n doctor == current_doctor\n end", "title": "" } ]
[ { "docid": "8106eeb79f4b0e4a3e2c09cca28d597f", "score": "0.90768164", "text": "def current_user?(user)\n\t\t\tuser == current_user\n\t\tend", "title": "" }, { "docid": "8106eeb79f4b0e4a3e2c09cca28d597f", "score": "0.90768164", "text": "def current_user?(user)\n\t\t\tuser == current_u...
acae820a3526b07594d5ef37ea07aa8b
GET /sellerreviews/1 GET /sellerreviews/1.json
[ { "docid": "a81945373733e4951b987de6ea99f9a1", "score": "0.0", "text": "def show\n end", "title": "" } ]
[ { "docid": "4c53a23719cec17d6a83a3da03fe2db7", "score": "0.74980044", "text": "def index\n @reviews = reviewable.reviews\n\n respond_to do |format|\n format.html\n format.json { render json: @reviews }\n end\n end", "title": "" }, { "docid": "aa0b50fdad74bc8b5f92b9938f011...
dff0b905785855c4e892de818e54f2fd
quick report of basic info, should break this out into individual method calls
[ { "docid": "4d05ef1464ef4da87253a4d50674c813", "score": "0.0", "text": "def report\n sensors = get_readings(:temperature, :oi_mode, :charging_source, :battery_charge, :battery_capacity, :current)\n sensors[:temperature][:text] = sensors[:temperature][:formatted].to_s + \" Celsius\"\n sensors[:b...
[ { "docid": "ac48c0bf237ebe517111acbf7365ed73", "score": "0.794964", "text": "def info; end", "title": "" }, { "docid": "ac48c0bf237ebe517111acbf7365ed73", "score": "0.794964", "text": "def info; end", "title": "" }, { "docid": "ac48c0bf237ebe517111acbf7365ed73", "scor...
63748d6b1c6dfbc5db07c2fa9d696ccd
I used the more easily typed method name "eat_from" rather than "take_fish_from" as listed in the inscructions file. I wanted to call it "eat" but the fact that it takes as a parameter the river, not the fish itself (as I imagine the bear eats the first fish it finds, or the "last", as suggested by the reference to .po...
[ { "docid": "94209f1c84fc8ed15bf70ca31d8eb13e", "score": "0.68494046", "text": "def eat_from(river)\n @belly.push(river.fish_eaten.name)\n end", "title": "" } ]
[ { "docid": "ca634a31ffb25722d3cb35ae9551d1ca", "score": "0.7875206", "text": "def eat_fish_from_river(river)\n add_to_stomach(river.fish.last)\n river.take_one_fish\n end", "title": "" }, { "docid": "32753ee8aed481c23c24305cc9b0ebf8", "score": "0.7680386", "text": "def take_fi...
13caaacbef50568bed5fb863fe6a42ef
Creates destination view from a Destination object instance Calls tertiary view (hotel)
[ { "docid": "c7473c1409b1f042605cfc01751e0afc", "score": "0.0", "text": "def dest_view(dest)\n waiting=true\n while waiting\n system \"clear\" or system \"cls\"\n puts \"Showing Hotels for '#{dest.name}' \"\n self.hline\n num_items=dest.hotels.length\n sorted = dest.hotels....
[ { "docid": "7959acaa6a0d4c2fffb5424f091fab1a", "score": "0.6499353", "text": "def create\n @destination = @agent.destinations.build(destination_params)\n if @destination.save\n # Render info I need\n # comments show view\n render \"destinations/details\", :layout => false\n else\...
38053e2247401c81f0de799d3f51a551
PATCH/PUT /artists/1 PATCH/PUT /artists/1.json
[ { "docid": "1f6f20730b95fb20ae355eb12e6a872a", "score": "0.70747226", "text": "def update\n respond_to do |format|\n if @artist.update(artist_params)\n format.html { redirect_to @artist, notice: 'Artist was successfully updated.' }\n format.json { render :show, status: :ok, locatio...
[ { "docid": "5e333dbfcf8116f07f50ebd51247b373", "score": "0.777175", "text": "def update\n artist = Artist.find(params[:id])\n artist.update_attributes(artist_params)\n render json: artist\n end", "title": "" }, { "docid": "926097139b98f0bde10050baa01e504b", "score": "0.772899",...