query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
A hash that maps from the original card id to the duplicated card id
def duplicated_cards Cache.hash_get_all("#{@batch_id}_duplicated_cards").presence || {} end
[ "def register_duplicated_card(original_card_id:, to_card_id:)\n Cache.hash_set(\"#{@batch_id}_duplicated_cards\", original_card_id, to_card_id)\n\n remapper = CardDuplicatorMapper::RemapLinkedCards.new(\n batch_id: @batch_id,\n )\n # remap the card that was just duplicated\n remapper...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
converts hand from array of card to array of sorted scores of said cards
def cards_by_score scores = {} @cards.each do |card| scores[card] = card.score end Hash[scores.sort_by { |card, score| -score }] end
[ "def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end", "def sort_by_suit\n \tnew_hand = []\n while @cards.size > 0\n \tpos = 0 # position of minimal card\n \tc = @cards[0] # minimal card\n \t@cards.each_with_index do |card, index|\n \t\tc1 = card\n # puts \"c: #{c....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
check if only 5 cards in hand already
def hand? @cards_by_score.length == 5 end
[ "def high_card?\n cards.uniq(&:value).size == 5 && !flush? && !straight?\n end", "def flush()\n suits = []\n self.hand.each {|card| suits << card.suit }\n \n return suits.any? { |ele| suits.count(ele) == 5}\n end", "def complete?\n @cards.length == 5\n end", "def six_cards?(player_che...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns an array of card with given number of multiples
def get_multiples(number) cards = [] @cards_by_score.each_key do |card| if @card_scores.count(card.score) == number cards << card end end cards end
[ "def get_cards\n a = Array.new\n (0..31).each do |i|\n a << Card.new(@cards.slice(i*2,2))\n end\n a\n end", "def initialize_cards\n cards = []\n 4.times { cards += (2..14).to_a }\n cards.sample(52)\n end", "def repetitions(n)\n @hand.group_by{ |card| card.point }.select { |k, v| v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Used in development mode for onthefly generation of public/netzke/ext.[js|css]
def ext respond_to do |format| format.js { render :text => Netzke::Core::DynamicAssets.ext_js } format.css { render :text => Netzke::Core::DynamicAssets.ext_css } end end
[ "def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Ext.ns('Netzke.core');}\n res << %{Netzke.RelativeUrlRoot =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Used in development mode for onthefly generation of public/netzke/touch.[js|css]
def touch respond_to do |format| format.js { render :text => Netzke::Core::DynamicAssets.touch_js } format.css { render :text => Netzke::Core::DynamicAssets.touch_css } end end
[ "def build_dev\n timer_block(\n 'Start [development] build for *.js files',\n 'JS time: ') do\n all_js_into_one_file\n end\n end", "def request_debug_assets?; end", "def js\n puts 'Compressing JS files...'\n `java -jar ./_scripts/yuicompressor-2.4.2.ja...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Main dispatcher of oldstyle (Sencha Touch) HTTP requests. The URL contains the name of the component, as well as the method of this component to be called, according to the double underscore notation. E.g.: some_grid__post_grid_data.
def endpoint_dispatch(endpoint_path) component_name, *sub_components = endpoint_path.split('__') component_instance = Netzke::Base.instance_by_config(Netzke::Core.session[:netzke_components][component_name.to_sym]) # We render text/plain, so that the browser never modifies our response response...
[ "def render_component(url_options, general_options)\n filtered_params = [\"action\", \"controller\", \"content_item_url\"] \n params.each_pair do |k, v|\n if k.match(\"(.+)_#{url_options[:id]}_(.+)\")\n url_options[$2] = v\n elsif k.match(\"(.+[a-zA-Z]+)\")\n url_optio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /imagems/1 GET /imagems/1.xml
def show @imagem = @evento.imagems.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @imagem } end end
[ "def index\n @imagems = Imagem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @imagems }\n end\n end", "def get_image(image_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parse...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public interface BlockCommand.new ||Arguments:|| `name` The String name of the command. `args` The NodeList of arguments given to the command. `raw_tokens` A TokenList that represents the entire BlockCommand, generated by the Tokenizer. You must override this method in your subclass of BlockCommand.
def initialize(*args) if self.class == BlockCommand raise TypeError, 'BlockCommand.new should not be called directly' end super end
[ "def initialize(*args)\n raise TypeError, 'BlockCommand.new should not be called directly' if self.class == BlockCommand\n super\n end", "def define(*args, &block)\n @commands << new(*args, &block)\n end", "def initialize *args, &block\n @pipes = {}\n @command = EM::SystemComm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
BlockCommandactive_block Since BlockCommands have the ability to contain multiple blocks, this method returns (at least in theory) the block within this BlockCommand that the Parser is currently looking as it is iterating over it. You must override this method in your subclass of BlockCommand. It must return a NodeList...
def active_block raise NotImplementedError, 'BlockCommand#active_block should be overridden by a subclass' end
[ "def active_block\n @nodes\n end", "def get_blocks\n @blocks\n end", "def block_node; end", "def process_block(node)\n node\n end", "def block\n (@blocks ||= Array.new) << Block.new\n @in_block = @blocks.last\n yield\n @in_block = nil\n end", "def nodelis...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writes an object to the stream. Calls the object's write() method, if available. Uses to_s otherwise.
def write( object ) if object.responds_to?(:write_to) then object.write_to(@stream) else @stream << object.to_s end end
[ "def _write(obj)\n obj.Write()\n end", "def _write(obj)\n obj.Write()\n end", "def puts( obj )\n return unless writeable?\n\n data = Marshal.dump(obj)\n @socket.write([data.size].pack('I')) + @socket.write(data)\n rescue SystemCallError\n return nil\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writes a string directly to the stream, without any filtering.
def write!( string ) @stream << string end
[ "def write(string)\n @output_stream.write(string)\n end", "def write(str)\n writing { write0 str }\n end", "def write(str); end", "def write(string)\n @buffer << string\n self\n end", "def write(str)\n str = str.to_s\n IOUtil.write(str, out_stream)\n str.bytes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
USE ONLY if &f is assocoative, AT YOUR OWN RISK. s is used only for the last reduce.
def reduce (s, &f) self.parallelize{|slice| slice.reduce(&f)}.reduce(s, &f) end
[ "def reduce\n \n end", "def _reduce_236(val, _values, result)\n result = nil\n \n result\nend", "def reduce_function\n 'function (key, values) { return reduce(key, values);};'\n end", "def _reduce_239(val, _values, result)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
i^n mod p, where p is prime and i is a primitive root of p With this formula, generate a series through progressive squaring, from zero to (p1). Collect the residue, mod p and perform an xswap with each object's index number. The result will be the corresponding MOF series.
def mof(i, p) arr = [] x_swap = [] (0..(p-2)).each do |x| arr.push((i**x) % p) end (1..(p-1)).each do |n| x_swap.push((arr.index {|item| n == item }) % 12 ) end return x_swap end
[ "def mod_sqr(p0) end", "def runterholen(p,q,dividend)\r\n\tp[q.deg-1] = dividend[q.deg-1]\r\n\tp[0..-2].mod\r\nend", "def permutation_equation p\n index_hash = {}\n y = []\n p.each_with_index do |x, i|\n index_hash[x] = i\n end\n (1..p.size).each do |n|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Card Test cards belonging in the card class
def test_card_members card = Card.new("A", "Hearts") assert_equal(card.value, 1) assert_equal(card.face, "A") assert_equal(card.is_ace, true) end
[ "def initialize cards\n @deck = cards\n end", "def cards\n @cards\n end", "def build_deck\n 0.upto(51).map{ |i| Card.new(i)}\n end", "def test_user_start_plays_the_game\n card_1 = Card.new(:club, 'Two', 2)\n card_2 = Card.new(:club, 'Three', 3)\n card_3 = Card.new(:club, 'Four', 4)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks to see whether anything currently exists at the given location.
def exists?(location_uri) r = client[connection.api.object_url(location_uri_to_fedora3_pid(location_uri), format: 'xml')].head # without disabling redirection, we should not get 3xx here (200..299).cover? r.code rescue RestClient::ExceptionWithResponse => e return false i...
[ "def contains?(loc)\n false\n end", "def has_locations?\n !@locations.empty?\n end", "def location_exists\n if self.location_changed?\n if GeneticBank.exists?(self.location)\n errors.add(:location, \"already exists\")\n end\n end\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Closes the shared memory area end frees its content.
def close Shared::try("dhmdt") {Shared::shmdt(@mem)} Shared::try("shmctl") {Shared::shmctl(@id, Shared::IPC_RMID, nil)} end
[ "def close\n @mmap.close\n @mmap = nil\n end", "def dispose\n call Memory.deAlloc(self)\n end", "def close() end", "def finalize\n if @handle\n @handle.release_interface(0)\n @handle.close\n end\n end", "def sync_close(*) end", "def close\n store.close\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writes a string len bytes.
def write(str, len=nil) raise ArgumentError, "str must respond to :to_s" unless str.respond_to? :to_s @mem.write_string(str.to_s, len) end
[ "def write_string_length(str, len)\n Rubinius.primitive :pointer_write_string\n raise PrimitiveFailure, \"Unable to write string\"\n end", "def write(str)\n raise(IOError, \"not opened for writing\") unless @writable\n raise(IOError, \"not modifiable string\") if @string.frozen?\n\n str = st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
As a user, if 'modify' is selected, I am prompted to enter an id for the contact to be modified. As a user, when an id is entered, I am prompted to type 'yes' or 'no' to confirm my selection. As a user, if 'yes' is typed, I am prompted to change 'firstname', 'lastname', 'email' or 'notes' by number. You shouldn't be ab...
def modify_contact puts "Please enter the id of the contact to modify: " id = gets.chomp.to_i puts "Please confirm 'yes' or 'no' to modify this contact: " puts @rolodex.display_contact(id) answer = gets.chomp.downcase if answer == 'yes' puts "Please enter the number of the attribute you would ...
[ "def modify_option(number)\n\t\t# if number == 1\n\t\t# \tputs \"Please enter new first name\"\n\t # \t\tfname = gets.chomp\n\t # \t\tputs @fname\n\t # \t\tconfirm_modify\n\n\t # \t\t@fname=fname\n\n\t # \telsif number == 2\n\t # \t\tputs \"Please enter new last name\"\n\t # \t\tlname = gets.chomp\n\t # \t\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the type of this comment. Inline comments correspond to `:inline`: whatever Block comments correspond to `:document`: =begin hi i am a document =end
def type case text when /^#/ :inline when /^=begin/ :document end end
[ "def type\n if text.start_with?(\"#\".freeze)\n :inline\n elsif text.start_with?(\"=begin\".freeze)\n :document\n end\n end", "def nodeType\n COMMENT_NODE\n end", "def commentable_type\n read_attribute(:commentable_type) == 'Topic' ? Topic.find(commenta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Compares comments. Two comments are identical if they correspond to the same source range.
def ==(other) other.is_a?(Source::Comment) && @location == other.location end
[ "def compareCommentNodes(n1, n2, opts, differences, status = EQUIVALENT)\n return true if opts[:ignore_comments]\n t1 = n1.content\n t2 = n2.content\n if opts[:collapse_whitespace]\n t1 = collapse(t1)\n t2 = collapse(t2)\n end\n unless t1 == t2\n status = UNEQUAL_C...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
HTTParty raises an errors after time limit defined by ::default_timeout if it cannot connect to server, then it raises Net::OpenTimeout if it cannot read response from server, then it raises Net::ReadTimeout
def handle_timeouts yield rescue Net::OpenTimeout, Net::ReadTimeout {} end
[ "def http_read_timeout\n @http_read_timeout ||= 5\n end", "def http_open_timeout\n @http_open_timeout ||= 2\n end", "def check_for_timeouts!\n return if (!@timeout_at or Time.now < @timeout_at or @timed_out)\n\n @timed_out = true\n @timeout_at = nil\n\n if (@connected and @active_mes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A singleuse login link for Express accounts to access their Stripe dashboard
def login_link(**options) ::Stripe::Account.create_login_link(processor_id) rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end
[ "def stripe_dashboard\n dashboard_link = Stripe::Account.create_login_link(@current_user.stripe_user_id)\n redirect_to dashboard_link.url\n end", "def dashboard\n account = Stripe::Account.retrieve(current_user.stripe_user_id)\n login_links = account.login_links.create\n redirect_to login_links.ur...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
converts 0terminated ASCII string to ruby string
def asciiz_to_str(asciiz) zero_byte_idx = asciiz.index("\x00") if zero_byte_idx != nil return asciiz[0, zero_byte_idx] else return asciiz end end
[ "def cstring(off=0)\n self[ off, (self.index(\"\\x00\") || self.size) ]\n end", "def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end", "def read_string io\n buf = ''\n while (c = io.read(1)) != \"\\0\"\n buf += c\n end\n buf\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
parses a number param and returns the value raises an exception if the param cannot be converted to a number examples: nil => 0 3 => 3 "MB_OK" => 0 "SOME_CONSTANT | OTHER_CONSTANT" => 17 "tuna" => !!!!!!!!!!Exception Parameter "consts_mgr" is a ConstantManager
def param_to_number(v, consts_mgr = @consts_mgr) if v.class == NilClass then return 0 elsif v.kind_of? Integer then return v # ok, it's already a number elsif v.kind_of? String then dw = consts_mgr.parse(v) # might raise an exception if dw != nil return dw else ...
[ "def getinteger(arg)\n arg.strip!\n if arg.match(/^\\d+$/)\n arg.to_i\n else\n $stderr.puts \"ERROR: Not a number : #{arg}\"\n exit STATE_UNKNOWN\n end\nend", "def parse_numeric_constant\n if peek?(:LIT_INT)\n ExprInt.new(expect(:LIT_INT))\n else\n ExprFloat.new(expect(:LIT_FLOAT))\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
RESEARCHERS don't have a profile, but they shouldn't have a U.Va. computing id.
def virginia_borrower? # @profile !~ /^[a-z]{2,3}([0-9][a-z]{1,2})?$/i profile.match?(/Virginia Borrower|Other VA Faculty|Alum/i) || profile.blank? end
[ "def lib_profile?\n return false if uid.blank?\n\n Rails.cache.fetch(\"people/drupal/#{org_code}/#{uid}\", expires_in: 24.hours) do\n benchmark \"People Page (#{uid})\" do\n response = profile_client.head uid\n\n response.success?\n end\n end\n end", "def find_profile (profile_na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Indicate whether the user can request item scanning.
def can_request_scanning? true # TODO: Should this be !virginia_borrower? ? end
[ "def can_user_start?\n item.can_user_start?(user)\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def control_scanning?\n control_scanning\n end", "def check_if_user_can_perform_action_on_resources\n if @item.is_a?(Typus.user_class)\n check_if...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /skydata/1 GET /skydata/1.json
def show @skydatum = Skydatum.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @skydatum } end end
[ "def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end", "def retrieve_jon_snow_data\n # Fetching data from the API\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /skydata/new GET /skydata/new.json
def new @skydatum = Skydatum.new respond_to do |format| format.html # new.html.erb format.json { render json: @skydatum } end end
[ "def new\n @earth = Earth.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @earth }\n end\n end", "def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cloud }\n end\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /skydata POST /skydata.json
def create @skydatum = Skydatum.new(params[:skydatum]) respond_to do |format| if @skydatum.save format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' } format.json { render json: @skydatum, status: :created, location: @skydatum } else format.html ...
[ "def create\n @meteo_datum = MeteoDatum.new(meteodatum_params)\n @meteo_datum.weather_station_id = params[:weather_station_id]\n\n if @meteo_datum.save\n render json: @meteo_datum, status: :created\n else\n render json: @meteo_datum.errors, status: :unprocessable_entity\n end\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /skydata/1 PUT /skydata/1.json
def update @skydatum = Skydatum.find(params[:id]) respond_to do |format| if @skydatum.update_attributes(params[:skydatum]) format.html { redirect_to @skydatum, notice: 'Skydatum was successfully updated.' } format.json { head :no_content } else format.html { render action: "...
[ "def update\n respond_to do |format|\n if @sky_track.set(sky_track_params)\n format.html { redirect_to @sky_track, notice: 'Sky track was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /skydata/1 DELETE /skydata/1.json
def destroy @skydatum = Skydatum.find(params[:id]) @skydatum.destroy respond_to do |format| format.html { redirect_to skydata_url } format.json { head :no_content } end end
[ "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @json_datum.destroy\n respond_to do |format|\n format.html { redirect...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the disable_xpn_host REST call
def disable_xpn_host request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_disable_xpn_host_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def disable_xpn_host request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_disable_xpn_host_request request_pb\n query_string_params = if query_string_params.an...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the disable_xpn_resource REST call
def disable_xpn_resource request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_disable_xpn_resource_request request_pb response = @client_stub.make_post_request( uri: ...
[ "def disable_xpn_resource request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_disable_xpn_resource_request request_pb\n query_string_params = if query_string_p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the enable_xpn_host REST call
def enable_xpn_host request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_enable_xpn_host_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def enable_xpn_host request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_enable_xpn_host_request request_pb\n query_string_params = if query_string_params.any?...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the enable_xpn_resource REST call
def enable_xpn_resource request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_enable_xpn_resource_request request_pb response = @client_stub.make_post_request( uri: ...
[ "def enable_xpn_resource request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_enable_xpn_resource_request request_pb\n query_string_params = if query_string_par...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the get_xpn_host REST call
def get_xpn_host request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, _query_string_params = transcode_get_xpn_host_request request_pb response = @client_stub.make_get_request( uri: uri, ...
[ "def get_xpn_host request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_xpn_host_request request_pb\n query_string_params = if query_string_params.any?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the get_xpn_resources REST call
def get_xpn_resources request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_get_xpn_resources_request request_pb response = @client_stub.make_get_request( uri: uri,...
[ "def get_xpn_resources request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_xpn_resources_request request_pb\n query_string_params = if query_string_params....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the list_xpn_hosts REST call
def list_xpn_hosts request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_list_xpn_hosts_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def list_xpn_hosts request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_xpn_hosts_request request_pb\n query_string_params = if query_string_params.any?\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the move_disk REST call
def move_disk request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_move_disk_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def move_disk request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_move_disk_request request_pb\n query_string_params = if query_string_params.any?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the move_instance REST call
def move_instance request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_move_instance_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def move_instance request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_move_instance_request request_pb\n query_string_params = if query_string_params.any?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the set_common_instance_metadata REST call
def set_common_instance_metadata request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_set_common_instance_metadata_request request_pb response = @client_stub.make_post_request( ...
[ "def set_common_instance_metadata request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/setCommonInstanceMetadata\"\n body = request_pb.metadata_resource.to_json\n\n response = @client_stub.make_post_request(\n uri: uri,\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the set_default_network_tier REST call
def set_default_network_tier request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_set_default_network_tier_request request_pb response = @client_stub.make_post_request( ...
[ "def set_default_network_tier request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_set_default_network_tier_request request_pb\n query_string_params = if query_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the set_usage_export_bucket REST call
def set_usage_export_bucket request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_set_usage_export_bucket_request request_pb response = @client_stub.make_post_request( u...
[ "def set_usage_export_bucket request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_set_usage_export_bucket_request request_pb\n query_string_params = if query_st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
rename local variable rrlv
def rename_local_variable # Start on either 'asdf', and do viw<leader>rrlv asdf = 10 p asdf # TODO: make this work without 'v' end
[ "def rename_var(var_name, opts={})\n return var_name if BUILTIN_VARS.include?(var_name)\n\n generate = opts.fetch(:generate, true)\n unresolved = opts.fetch(:unresolved, [])\n renamed = @renames[var_name]\n\n if renamed.nil? and parent\n renamed = parent.rename_var(var_name, :generate => false)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create a dns record
def create_record(fqdn, type, ipdata) unless @dnss.is_valid? Puppet.crit dns.cstatus end priority = {} # TODO: research how to implement priority for puppet # priority = priority[0] # if priority.nil? # priority = {} # else # priority = { :prior...
[ "def create_dns_record(params)\n if RECORD_MAPPING[:dns].include?(params[:record_type])\n if params[:record_type].eql?('A')\n record = Infoblox::Arecord.new(connection: connection, name: params[:name], ipv4addr: params[:ipv4addr])\n elsif params[:record_type].eql?('AAAA')\n reco...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get a dns record object
def get_record(fqdn, type) matches = find_match(@dnss.records, fqdn, true) if matches != nil record = nil matches.each do |record| Puppet.debug "inspecting #{record.hash_type} == #{type}" if record.hash_type.to_s == type.to_s Puppet.notice "found...
[ "def makeARecord(machine, ttl: Config::TTL_A_RECORD)\n return DnsRecord.new(name: machine.dns_record(),\n type: \"A\",\n content: machine.static_ip(),\n ttl: ttl)\nend", "def get_record(zone_id, record_id)\n request(\n :expects...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create a dns zone
def create_zone(zone, email, ttl) @dnsh.name = zone @dnsh.email = email @dnsh.ttl = ttl if @dnsh.save == true Puppet.notice "Created dns zone #{zone} with id #{@dnsh.id}" else Puppet.err @dnsh.cstatus raise @dnsh.cstatus end end
[ "def create_zone zone_name, zone_dns, description: nil,\n name_server_set: nil\n ensure_service!\n gapi = service.create_zone zone_name, zone_dns,\n description: description,\n name_server_set: name_serv...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get a dns zone
def get_zone(zone) return find_match(@dns.domains, zone) end
[ "def fetch_zone\n route53 = Fog::DNS.new(connection_params)\n @zone = route53.zones.get(@current_resource.zone_id)\nend", "def get_hosted_zone()\n\t\tresp = @r53.get_hosted_zone(:id => @zone)\n\t\tresp[:hosted_zone]\n\tend", "def get_zone(zone=nil) \n zone ||= @zone\n get(\"Zone/#{zone}\")\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the unsigned m/z value
def mz _mz_signed = mz_signed _mz_signed >= 0 ? _mz_signed : -_mz_signed end
[ "def max_z\n @max_z\n end", "def z\n return @z\n end", "def z_value\n @z_value ||= self.class.z_value\n end", "def min_z\n @min_z\n end", "def unit \n\t\t\tunitq = self.dup\n\t\t\tmagnitude = self.abs\n\t\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /supplies_providers_loans/1 GET /supplies_providers_loans/1.json
def show @supplies_providers_loan = SuppliesProvidersLoan.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @supplies_providers_loan } end end
[ "def show\n @supplies_loan = SuppliesLoan.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @supplies_loan }\n end\n end", "def new\n @supplies_providers_loan = SuppliesProvidersLoan.new\n\n respond_to do |format|\n format.html #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /supplies_providers_loans/new GET /supplies_providers_loans/new.json
def new @supplies_providers_loan = SuppliesProvidersLoan.new respond_to do |format| format.html # new.html.erb format.json { render json: @supplies_providers_loan } end end
[ "def new\n @supplies_loan = SuppliesLoan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplies_loan }\n end\n end", "def new\n @title = t('view.providers.new_title')\n @provider = Provider.new\n\n respond_to do |format|\n format.html #...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /supplies_providers_loans/1 PUT /supplies_providers_loans/1.json
def update @supplies_providers_loan = SuppliesProvidersLoan.find(params[:id]) respond_to do |format| if @supplies_providers_loan.update_attributes(params[:supplies_providers_loan]) format.html { redirect_to @supplies_providers_loan, notice: 'Supplies providers loan was successfully updated.' } ...
[ "def update\n @supplies_loan = SuppliesLoan.find(params[:id])\n\n respond_to do |format|\n if @supplies_loan.update_attributes(params[:supplies_loan])\n format.html { redirect_to @supplies_loan, notice: 'Supplies loan was successfully updated.' }\n format.json { head :no_content }\n el...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /supplies_providers_loans/1 DELETE /supplies_providers_loans/1.json
def destroy @supplies_providers_loan = SuppliesProvidersLoan.find(params[:id]) @supplies_providers_loan.destroy respond_to do |format| format.html { redirect_to supplies_providers_loans_url } format.json { head :no_content } end end
[ "def destroy\n @supplies_loan = SuppliesLoan.find(params[:id])\n @supplies_loan.destroy\n\n respond_to do |format|\n format.html { redirect_to supplies_loans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @provider = Provider.find(params[:id])\n @provider.destro...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns a copy of the point
def get_point_clone return @point.clone end
[ "def get_point_clone\n return @point.clone\n end", "def copy()\n Point.new(@x,@y)\n end", "def to_point\n if length == 2\n p = Point.new(*self)\n elsif length == 1\n p = self[0].clone\n end\n return p\n end", "def add_to_point point\n add_to_point! point.dup\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
checks whether the function is converging
def converging? # check the convergence in a given direction comparing the previous and current values def point_converged?(previous, current) pre = previous.value curr = current.value diff = (pre - curr).abs size = [pre.abs, curr.abs].max...
[ "def converge_complete; end", "def converged?\n @iterations.last.converged?\n end", "def converge_complete\n end", "def converge\n transition_to(:converge)\n end", "def converge_failed(exception); end", "def is_training_finished(points)\n res = true\n points.each do | point|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build an initial simplex == Parameters: start_point: starting point of the minimization search
def build_simplex(start_point) n = start_point.length raise "dimension mismatch" if n != @start_configuration.length # set first vertex @simplex = Array.new(n+1) @simplex[0] = PointValuePair.new(start_point, Float::NAN) # set remaining vertices 0.upto(n - 1) do |...
[ "def build_simplex(start_point)\n n = start_point.length\n raise \"dimension mismatch\" if n != @start_configuration.length\n # set first vertex\n @simplex = Array.new(n+1)\n @simplex[0] = PointValuePair.new(move_into_bounds(start_point), Float::NAN)\n\n # set remaining vertices\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Evaluate all the nonevaluated points of the simplex
def evaluate_simplex # evaluate the objective function at all non-evaluated simplex points 0.upto(@simplex.length - 1) do |i| vertex = @simplex[i] point = vertex.point if vertex.value.nan? @simplex[i] = PointValuePair.new(point, f(point)) end ...
[ "def evaluate_simplex\n # evaluate the objective function at all non-evaluated simplex points\n @simplex.each_with_index do |v,i|\n @simplex[i].value = f(v.point) if v.value.nan?\n end\n # sort the simplex from best to worst\n @simplex.sort!{ |x1, x2| x1.value <=> x2.value }\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replace the worst point of the simplex by a new point == Parameters: point_value_pair: point to insert
def replace_worst_point(point_value_pair) n = @simplex.length - 1 0.upto(n - 1) do |i| if (compare(@simplex[i], point_value_pair) > 0) point_value_pair, @simplex[i] = @simplex[i], point_value_pair end end @simplex[n] = point_value_pair end
[ "def replace_worst_point(point_value_pair)\n n = @simplex.length - 1\n 0.upto(n - 1) do |i|\n if (compare(@simplex[i], point_value_pair) > 0)\n point_value_pair, @simplex[i] = @simplex[i], point_value_pair\n end\n end\n @simplex[n] = point_value_pair\n end", "def add_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
loads structure file csv, returns structure as array
def loadStructure(file) csv_text = File.read(file) return CSV.parse(csv_text, :headers => true) end
[ "def load_csv\n csv = CSV.read(@csv_file)\n @schema = csv.shift[3..-1]\n return csv\n end", "def convert_csv_file_to_object\n begin\n CSV.foreach(@file_name) do |row|\n @csv_object.push(row)\n end \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Records the original rvm environment and sets up a new gemset.
def setup_rvm @@rvm_original_env ||= RVM.current.expanded_name @@env = RVM::Environment.current @@env.gemset_create(app_name) @@env.gemset_use!(app_name) end
[ "def reset_rvm\n @@env.use!(@@rvm_original_env)\n end", "def update_installed_gemsets(rubie)\n env = RVM::Environment.new\n env.use rubie\n\n @installed_gemsets ||= {}\n @installed_gemsets[rubie] = env.gemset_list\n @installed_gemsets[rubie]\nend", "def update_installed_gemsets(rubie)\n orig...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reverts to the original rvm environment
def reset_rvm @@env.use!(@@rvm_original_env) end
[ "def reset_current!\n Environment.reset_current!\n end", "def restore_env(env)\n @src, @tree, @block_ial, @stack, @text_type = *env\n end", "def restore\n @backend.restore\n setup_container_name\n setup_family\n end", "def reset(mode='soft')\n command = 'res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the rbenv ruby version
def rbenv_ruby `rbenv version`.split(' ').first end
[ "def ruby_version\n ENV[\"RUBY_VERSION\"]\n end", "def ruby_version\n if ruby = ENV['RUBY']\n File.basename(ruby)\n else\n RUBY_VERSION\n end\n end", "def determine_rbenv_ruby_version_if_not_given\n if node[:rbenv_passenger][:rbenv_ruby].nil?\n ruby_version = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the RVM ruby version
def rvm_ruby @@env.expanded_name.match(/([\w\-\.]+)/)[1] end
[ "def ruby_version\n default = %x{ rvm current}.strip\n items = %x{ rvm ls strings }.split.compact\n\n ruby = menu_with_default \"RVM Ruby version to use for deployment:\", items,default\n ruby = ask \"Enter alternative RVM Ruby string: \" if ruby =~ /Other/\n ruby\n end", "def current_ruby_version...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if rbenv is installed.
def rbenv_installed? @rbenv_installed ||= `which rbenv`.present? end
[ "def rbenv_installed?\n !which('rbenv').nil?\n end", "def has_virtualenv_installed(python)\n `#{python} -m virtualenv --help 2>&1`\n if (0 != $?.to_i)\n false\n else\n true\n end\n end", "def ruby_installed?\n !which('ruby').nil?\n end", "def ruby?\n exist? 'Gemfile...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if RVM is installed.
def rvm_installed? @rvm_installed ||= `which rvm`.present? end
[ "def rvm_installed?\n cmd_test %{-s \"/usr/local/lib/rvm\"}\nend", "def rvm?\n\t\t\tFile.exists?(RvmPow::RVM_BINARY)\n\t\tend", "def installed?\n if File.exists?(dm_cmd)\n return true\n else\n message.warn \"LVM Tools are not installed\"\n return false\n end\n end", "def ruby_install...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /chase_vehicles GET /chase_vehicles.json
def index @chase_vehicles = ChaseVehicle.all end
[ "def index\n @vehicles = Vehicle.all\n\n render json: @vehicles\n end", "def vehicles\n vehiclesUrl = URI.parse('https://owner-api.teslamotors.com/api/1/vehicles')\n\n response = Net::HTTP.start(vehiclesUrl.host, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|\n http.get(vehicle...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /chase_vehicles/1 DELETE /chase_vehicles/1.json
def destroy @chase_vehicle.destroy respond_to do |format| format.html { redirect_to :back } format.json { head :no_content } end end
[ "def destroy\n @vehicle.destroy\n render json: { status: true }\n end", "def destroy\n @vehicle = Vehicle.find(params[:id])\n @vehicle.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @vehi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a tag with the given key and data value to all collections matching the query condition. If append is true, this method will append the value to any existing data (if not already present), rather than overwriting it. The optional block gets passed Arrayuniq to determine whether a piece of data is already present in...
def add_tag(key, value, condition, token, append=false, only_granules=true, &block) query = tag_condition_to_query(condition) # https://bugs.earthdata.nasa.gov/browse/CMR-2855 will fix the need for some of this logic # https://bugs.earthdata.nasa.gov/browse/CMR-2609 as well if value.present? || ...
[ "def append(key, value); end", "def append(value, hash, array)\n key = array[1]\n hash[value[:key]] = { flags: value[:flags], exptime: value[:exptime], value: hash[key][:value] + value[:value], cas_unique: value[:cas_unique] }\n value[:reply] != 'false' ? (self.result = \"\\r\\nSTORED\") : (self.result =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The number of citizen not engaged in color pass in args
def citizens_ready_in(color) citizens.where(:color => color, :engaged => false).count end
[ "def amount_of_color(color)\n colorizr_vector.amount_of_color(color)\n end", "def diversity\n color_count.keys\n end", "def nc\n Ncurses::COLOR_PAIR(@id)\n end", "def assign_game_color count\n case count\n when 0\n return \"transparent\"\n when 6\n return $app_red\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the IP associated with this record if it can be deduced from the record name
def ip ip = nil unless valid? return nil end begin case name when /\.in-addr\.arpa$/ name_without_suffix = name.sub(/\.in-addr\.arpa$/, '') quads = name_without_suffix.split('.') if quads.size == 4 quads.reverse! ip = quads.join('.') ...
[ "def info_detected_address\n self.class.info(name)[:ip]\n end", "def ipaddress\n block = /\\d{,2}|1\\d{2}|2[0-4]\\d|25[0-5]/\n re = /\\A#{block}\\.#{block}\\.#{block}\\.#{block}\\z/\n if info[1]['host'] && re =~ info[1]['host']\n info[1]['host']\n else\n address(i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /result_statistic_sections/1 PATCH/PUT /result_statistic_sections/1.json
def update respond_to do |format| if @result_statistic_section.update(result_statistic_section_params) format.html { redirect_to edit_result_statistic_section_path(@result_statistic_section), notice: t('success') } format.json { render :show, status: :ok, location: @resul...
[ "def update\n respond_to do |format|\n if @result_statistic_section.update(result_statistic_section_params)\n format.html do |_format|\n if params[:result_statistic_section].has_key? :extraction_ids\n redirect_to consolidate_result_statistic_section_path(@result_statistic_section,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /bugreports POST /bugreports.json
def create @bugreport = Bugreport.new(bugreport_params) @bugreport.reporter = current_user respond_to do |format| if @bugreport.save format.html { redirect_to root_url, notice: 'Bugreport was successfully created.' } format.json { render action: 'show', status: :created, location: @bu...
[ "def create\n @bugreport = Bugreport.new(bugreport_params)\n\n respond_to do |format|\n if @bugreport.save\n format.html { redirect_to @bugreport, notice: 'Bugreport was successfully created.' }\n format.json { render :show, status: :created, location: @bugreport }\n else\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /bugreports/1 PATCH/PUT /bugreports/1.json
def update respond_to do |format| if @bugreport.update(bugreport_params) format.html { redirect_to @bugreport, notice: 'Bugreport was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @bugreport...
[ "def update\n @bugreport = Bugreport.find(params[:id])\n\n respond_to do |format|\n if @bugreport.update_attributes(params[:bugreport])\n format.html { redirect_to @bugreport, notice: 'Bugreport was successfully updated.' }\n format.json { head :no_content }\n else\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /bugreports/1 DELETE /bugreports/1.json
def destroy @bugreport.destroy respond_to do |format| format.html { redirect_to bugreports_url } format.json { head :no_content } end end
[ "def destroy\n @bugreport = Bugreport.find(params[:id])\n @bugreport.destroy\n\n respond_to do |format|\n format.html { redirect_to bugreports_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bug_report = BugReport.find(params[:id])\n @bug_report.destroy\n\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
2. Metoda display_details() afiseaza numele si prenumele
def display_details() puts "Numele persoanei: #@nume" puts "Prenumele persoanei: #@prenume" end
[ "def inspect_details\n\t\t\treturn ''\n\t\tend", "def display_details()\r\n\t\tprintf(\"\\n**************************************************\")\r\n\t\tprintf(\"\\n***** MONTHLY PAY SLIP DETAILS *****\")\r\n\t\tprintf(\"\\n**************************************************\")\r\n\t\tprintf(\"\\nEmpl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a host to and initializes `task` attribute as an empty array.
def initialize(host=nil) @host = host @tasks = [] end
[ "def initialize # Initialize method that is similar to a Constructor in Java\n @all_tasks = [] # Method includes an array that stores all tasks\n end", "def initialize\n @task_list = []\n end", "def tasksOnHost(filter, host)\n java_import 'java.net.URL'\n java_import 'java.net.SocketException'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method will be called by the Logging framework when it first initializes. Here we require the redis appender code.
def initialize_redis require File.expand_path('../appenders/redis', __dir__) end
[ "def setup\n self.logger.reopen(File.open(File.join(Lokii::Config.root, Lokii::Config.log), \"a\")) if daemon? && self.logger\n self.logger ||= ::Logger.new(File.join(Lokii::Config.root, Lokii::Config.log))\n end", "def setup_redis_log\n as :root do\n create_file! '/etc/rsyslog.d/99...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
helper method for self.highest_pledge to abstract away the process to get highest pledge amount
def highest_pledge_amount pledges.reduce(0) do |highest_pledge_amount, pledge| highest_pledge_amount = pledge.amount > highest_pledge_amount ? pledge.amount : highest_pledge_amount end end
[ "def highest_pledge()\n self.pledges().max_by() { | pledge | pledge.amount() }\n end", "def user_highest_pledge\n self.pledges.empty? ? 0 : self.pledges.map {|pledge| pledge.amount}.max \n end", "def biggest_investment\n max = 0\n funding_rounds.each do |round| \n if...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build an instance of BrandedCallInstance
def get_instance(payload) BrandedCallInstance.new(@version, payload, ) end
[ "def new_api_call_builder\n @api_call.new_builder\n end", "def get_instance(payload)\n return CallInstance.new(\n @version,\n payload,\n )\n end", "def get_instance(payload)\n PhoneCallInstance.new(@version, payload, )\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
check if the left child of is greater than parent
def left_child_greater?(array, index) array[left_child(index)] && (left_child(index) > array[index]) end
[ "def check_left\n\t\tunless @left_child.nil?\n\t\t\treturn @left_child.value\n\t\tend\n\tend", "def is_left_child?\n return false if is_root?\n self == parent.left_child\n end", "def is_parent_greater_than_child(index, parent)\n @tree[parent].rating > @tree[index].rating\n end", "def isLeftC...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Below Sets params for admin library id from inherited AdminLibraries class.
def set_library @library = AdminLibrary.friendly.find(params[:admin_library_id]) end
[ "def init_params(params)\n super\n end", "def create_admin_library \n library = AdminLibrary.new(name: \"#{self.name} Archive\", admin_id: self.id)\n library.save\n end", "def model_attributes(_form_params)\n super.tap do |params|\n params[:admin_set_id] = admin_set_id if params[:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Below Provides params for new library upload record.
def upload_params params.require(:library_upload).permit(:title, :description, :tags, :image, :file) end
[ "def upload_params\n {\n extension: params.require(:extension),\n tarball: params.require(:tarball)\n }\n end", "def create_file_params(ios)\n # multi-doc uploading capabilities, each doc needs to be it's own param\n file_params = {}\n ios.each_with_index do |io,index|\n fil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Counts the number of quote characters in a line, excluding escaped quotes.
def count_quote_chars(line, quote_char) return 0 if line.nil? || quote_char.nil? count = 0 previous_char = '' line.each_char do |char| count += 1 if char == quote_char && previous_char != '\\' previous_char = char end count end
[ "def quotes_word_count\n @quotes.reduce(0) { | quote, num| quote + num.word_count }\n end", "def count_lines string\n string.to_s.scan(/$/).length\n end", "def count_occurances_delimiter(line)\n delimiter_count.keys.each do |key|\n #Count the occurances of delimiter in a line\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ruby equivalent of the Cextension for parse_line parses a single line: either a CSV header and body line quoting rules compared to RFC4180 are somewhat relaxed we are not assuming that quotes inside a fields need to be doubled we are not assuming that all fields need to be quoted (0 is even) works with multichar col_se...
def parse_csv_line_ruby(line, options, header_size = nil) return [] if line.nil? line_size = line.size col_sep = options[:col_sep] col_sep_size = col_sep.size quote = options[:quote_char] quote_count = 0 elements = [] start = 0 i = 0 previous_char = '' ...
[ "def line_parse(validated_line)\n return unless validated_line\n row = validated_line.split(',')\n return unless row.any?\n if @headers.empty?\n @headers = row\n else\n @data_hash.merge!(row_to_hsh(row))\n @valid_rows << @data_hash\n end\n end", "def parse_csv...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If file has headers, then guesses column separator from headers. Otherwise guesses column separator from contents. Raises exception if none is found.
def guess_column_separator(filehandle, options) skip_lines(filehandle, options) delimiters = [',', "\t", ';', ':', '|'] line = nil has_header = options[:headers_in_file] candidates = Hash.new(0) count = has_header ? 1 : 5 count.times do line = readline_with_counts(fil...
[ "def detect_col_sep\n available_col_seps.each do |col_sep|\n begin\n SmarterCSV.process filename, chunk_size: 1, headers_in_file: false, user_provided_headers: [:timestamp, :value], col_sep: col_sep do |chunk|\n data = chunk.first\n break if data[:timestamp].to_s.include?(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /litigantes GET /litigantes.json
def index @litigantes = Litigante.all end
[ "def show\n @litra = Litra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @litra }\n end\n end", "def index\n @lesuurs = Lesuur.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /litigantes POST /litigantes.json
def create @litigante = Litigante.new(litigante_params) respond_to do |format| if @litigante.save format.html { redirect_to @litigante, notice: 'Litigante was successfully created.' } format.json { render :show, status: :created, location: @litigante } else format.html { ren...
[ "def create\n @status = [[\"Nouveau\"], [\"en cours de traitement\"], [\"traité\"]]\n @litige_params = user_litige_params\n if admin_signed_in?\n @litige_params = litige_params\n end\n @litige_params = {identifiant: Litige.idenfifiant_generator( 2, 3)}.merge(@litige_params)\n @litige = Litige...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /litigantes/1 PATCH/PUT /litigantes/1.json
def update respond_to do |format| if @litigante.update(litigante_params) format.html { redirect_to @litigante, notice: 'Litigante was successfully updated.' } format.json { render :show, status: :ok, location: @litigante } else format.html { render :edit } format.json { r...
[ "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end", "def patch *args\n make_request :patch, *args\n end", "def update\n @leito = Leito.find(params[:id])\n\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Destroys the like tied to this user on this likeable model
def unliked_by(user) self.send(self.class.like_label.tableize.to_sym).find_by_user_id(user.id).destroy rescue false end
[ "def destroy\n @user_like = UserLike.find(params[:id])\n @user_like.destroy\n\n respond_to do |format|\n format.html { redirect_to(scaffold_user_likes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_like = UserLike.find(params[:id])\n @user_like.destroy\n\n res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
matches `[PERCENTAGE] of [NUM]` and `[PERCENTAGE] (off|on) [NUM]`
def parse_percentage_expression regex = /(?<percentage>-?[\d.]+)% (?<operator>(off?|on)) (?<expr>.*$)/ match = @expression.match(regex) if match operator = match.named_captures["operator"] percentage = match.named_captures["percentage"] expr = match.named_captures["expr"] percentag...
[ "def percent? = unit == 'percent'", "def percent!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 17)\n\n type = PERCENT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 359:10: '\\\\%'\n match(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
reformat any mathmatical functions from lowercase to upper e.g. avg(1,2) > AVG(1,2)
def reformat_math_functions funcs = %w(min max sum avg count round rounddown roundup sin cos tan) regex = /\b(?<func>#{funcs}.join('|'))\((?<expr>[^()]+)\)/ match = @expression.match(regex) if match func = match.named_captures["func"] expr = match.named_captures["expr"] @expression = ...
[ "def tolower\n set_function_and_argument(:tolower, nil)\n end", "def zebulansNightmare(functionName)\n new_name = functionName.split(\"_\").map!(&:capitalize).join(\"\")\n if new_name[0]\n new_name[0] = new_name[0].downcase\n end\n new_name\nend", "def alphabetize\n\nend", "def upcase!(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
comments resemble cstyle, singleline statements `//[...]` when commented out, the processed expression will be blank
def detect_comments if @input =~ %r{^\s*[/]{2}} @mode = :comment @expression = '' end end
[ "def comment (comment)\n return \"/** #{comment} */\\n\" \nend", "def single_line_comment\n # //\n if @codes[@pos] == 0x2f and @codes[@pos + 1] == 0x2f\n @pos += 2\n pos0 = @pos\n while (code = @codes[@pos]) and !line_terminator?(code)\n @pos += 1\n end\n ret...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
if input matches `[VAR] = [EXPRESSION]` extract variable name and expression
def process_variable_assignment regex = %r{(?<name>\w+)( = )(?<expression>.*$)} match = @input.match(regex) if match @name = match.named_captures["name"] @expression = match.named_captures["expression"] end end
[ "def extractVariable( *args )\r\n rval = scanVariable( *args ) or return nil\r\n return rval[:match]\r\n end", "def parse_variable_value\n variable = gets.chomp\n return variable.to_i, false if variable.is_number?\n\n is_an_expression = variable.split(' ').length > 1\n if is_an_expres...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
currently variables are only expanded when surrounded by whitespace or ends of line
def expand_variables # self.tokens = self # var_regex = /^[\w]+$/ # var_regex = /([\s\b])[\w]+([\s\b])/ # expanded = [] # self.tokens.each do |token| # expanded << expand_token(token) # end # @expression = expanded.join(' ') @expression = self.tokens.map do |token| expand_...
[ "def local_variables() end", "def capture_variables(line)\n noncomment, _ = line.split(\"#\", 2)\n noncomment.scan(/ENV(?:\\[|\\.fetch\\()['\"]([^'\"]+)['\"]/).flatten\n end", "def compile_expand!\n instance_eval \"def expand(vars); \\\"#{expand_code_fragment}\\\"; end\", __FILE__, __LINE__\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
remove leading and trailing whitespace from expression
def trim_whitespace @expression.strip! end
[ "def rstrip\r\n match = rewrite(/\\s+\\z/)\r\n match ? match[0] : ''\r\n end", "def trim_whitespace!\n replace(trim_whitespace)\n end", "def strip_whitespace!\n replace(self.strip_whitespace)\n end", "def trim_trailing_whitespace; end", "def trim_whitespace; end", "def strip_extra_w...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
if nonblank expression is invalid then mark mode as :invalid
def validate # @expression && !@expression.blank? if !@expression || @expression.blank? return elsif !Calculator.valid?(@expression) @expression = nil @mode = :invalid end end
[ "def invalid!\n @invalid = true\n add_class(:invalid)\n end", "def valid_regex; end", "def allowBlank; end", "def match_regex\n if !self.value.blank? && self.regex\n errors.add(:value, 'is a invalid value') unless self.value =~ Regexp.new(self.regex)\n end\n end", "def setInvalid()\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines if the uploaded file should be committed to the blockchain and if so, commits it.
def commit_file if @upload.public? && @upload.file_type.public? && @upload.address.blank? && (@upload.creating? || @upload.failed?) BlockchainCommitJob.perform_later(@upload.id) end end
[ "def commit\n logger.info(\"Begin commit transaction, id: #{id}\")\n\n parts = sync_get_all_parts.map{ |p|\n Part.new(:number => p[:number], :etag => p[:etag])\n }\n @protocol.complete_multipart_upload(\n bucket, object, id, parts, @options[:callback])\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines if the uploaded file can be retrieved from the blockchain and if so, retrieves it.
def retrieve_file if @upload.public? && @upload.file_type.public? && @upload.address.present? && @upload.success? BlockchainRetrieveJob.perform_later(@upload.id) end end
[ "def retrieve_file(file)\n begin\n @ftp.getbinaryfile(file)\n return true\n rescue Exception => e\n error_message(e)\n return false\n end\n end", "def raw_file_okay?\n File.exists? uploaded_file_path\n end", "def retrieve_file(file)\n begin\n @ftp.getbinaryfile(file...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /markets/1 PATCH/PUT /markets/1.json
def update respond_to do |format| if @market.update(market_params) format.html { redirect_to @market, notice: 'Market was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @market.errors, status...
[ "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end", "def update\n @market = Market.find(params[:id])\n if @market.update_attr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }