query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Encode to callseq: Kconv.tojis(str) > string Convert str to ISO2022JP Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('jxm0', str).
def tojis(str) ::NKF::nkf('-jm', str) end
[ "def tojis; Kconv.tojis(self) end", "def utf2sjis(str)\n return str\n #return str.encode(\"Shift_JIS\",\"UTF-8\",:undef => :replace, :invalid => :replace,:replace => \"*\")\nend", "def toutf8(str)\n ::NKF::nkf('-wm', str)\n end", "def sjis_safe(str)\n [\n [\"301C\", \"FF5E\"], # wave-dash\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: Kconv.toutf8(str) > string Convert str to UTF8 Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('wxm0', str).
def toutf8(str) ::NKF::nkf('-wm', str) end
[ "def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end", "def unicode_normalize_kc(input); end", "def convert_to_utf_8(string)\n string = string.to_s\n return if string.encoding == Encoding::UTF_8\n encoder = Encoding::Converter.new(string.encoding, Encoding::UTF_8, undef: :replace)\n encode...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: Kconv.toutf16(str) > string Convert str to UTF16 Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('w16xm0', str).
def toutf16(str) ::NKF::nkf('-w16m', str) end
[ "def to_utf16(str)\n if str.respond_to?(:encode)\n str.encode('UTF-16BE')\n else\n Iconv.conv('UTF-16BE', 'UTF-8', str)\n end\n end", "def utf8_to_utf16(string)\n JSON::UTF8toUTF16.iconv(string).unpack('H*')[0]\n end", "def encode_utf16le(str); end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
guess callseq: Kconv.guess(str) > integer Guess input encoding by NKF.guess2
def guess(str) ::NKF::guess(str) end
[ "def guess_old(str)\n ::NKF::guess1(str)\n end", "def score_string(guess)\n results = Array.new()\n guess.split('').each_with_index do |char, index|\n if char == @code[index]\n results[index] = :h\n elsif @code.include? char\n results[index] = :n\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: Kconv.guess_old(str) > integer Guess input encoding by NKF.guess1
def guess_old(str) ::NKF::guess1(str) end
[ "def guess(str)\n ::NKF::guess(str)\n end", "def score_string(guess)\n results = Array.new()\n guess.split('').each_with_index do |char, index|\n if char == @code[index]\n results[index] = :h\n elsif @code.include? char\n results[index] = :n\n else\n r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: Kconv.issjis(str) > obj or nil Returns whether input encoding is Shift_JIS or not. Note don't expect this return value is MatchData.
def issjis(str) RegexpShiftjis.match( str ) end
[ "def issjis;\tKconv.issjis(self) end", "def utf2sjis(str)\n return str\n #return str.encode(\"Shift_JIS\",\"UTF-8\",:undef => :replace, :invalid => :replace,:replace => \"*\")\nend", "def tojis(str)\n ::NKF::nkf('-jm', str)\n end", "def to_jis\n raise 'Undefined charset.' if self.charset.nil?\n ca...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: Kconv.isutf8(str) > obj or nil Returns whether input encoding is UTF8 or not. Note don't expect this return value is MatchData.
def isutf8(str) RegexpUtf8.match( str ) end
[ "def is_utf8?(string); end", "def isutf8;\tKconv.isutf8(self) end", "def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).valid_encoding?\n else\n false\n end\n end", "def vali...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
to Encoding callseq: Stringtojis > string Convert self to ISO2022JP Note This method decode MIME encoded string and convert halfwidth katakana to fullwidth katakana. If you don't want it, use NKF.nkf('jxm0', str).
def tojis; Kconv.tojis(self) end
[ "def tojis(str)\n ::NKF::nkf('-jm', str)\n end", "def utf2sjis(str)\n return str\n #return str.encode(\"Shift_JIS\",\"UTF-8\",:undef => :replace, :invalid => :replace,:replace => \"*\")\nend", "def to_katakana\n NKF.nkf('-w --katakana', self)\n end", "def to_katakana(src)\n src\n .gsub(\"わ゙\",\"γƒ·\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: Stringissjis > obj or nil Returns whether self's encoding is Shift_JIS or not. Note don't expect this return value is MatchData.
def issjis; Kconv.issjis(self) end
[ "def issjis(str)\n RegexpShiftjis.match( str )\n end", "def utf2sjis(str)\n return str\n #return str.encode(\"Shift_JIS\",\"UTF-8\",:undef => :replace, :invalid => :replace,:replace => \"*\")\nend", "def to_jis\n raise 'Undefined charset.' if self.charset.nil?\n case self.charset\n when 'ASCII';\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
callseq: Stringisutf8 > obj or nil Returns whether self's encoding is UTF8 or not. Note don't expect this return value is MatchData.
def isutf8; Kconv.isutf8(self) end
[ "def is_utf8?(string); end", "def utf8?\n return true if encoding.nil?\n encoding == \"UTF-8\"\n end", "def is_utf8?\n case encoding\n when Encoding::UTF_8, Encoding::US_ASCII\n valid_encoding?\n when Encoding::ASCII_8BIT\n dup.force_encoding(Encoding::UTF_8).va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Whether the poll should be displayed.
def opinion_show_poll? begin !opinion_user.nil? rescue NoMethodError false end end
[ "def shown?\n return !!shown\n end", "def visible?\n @visible\n end", "def visible?\n @visible\n end", "def display?\n @document_self and not @ignored and\n (documented? or not @suppressed)\n end", "def call_to_show?\n self.dig_for_boolean(\"listingSummary\", \"isCall...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create new favorite for current customer
def create fav_params = params.require(:favorite).permit(:content_id, :content_type) @favorite = Favorite.new(fav_params) @favorite.customer_id = current_person.user.id @favorite.save redirect_to request.referer end
[ "def favorite\n\t\t\tcustomer = Customer.find(params[:customer_id])\n\t\t\tclient = Client.find(params[:favorite][:client_id])\n\t\t\tfavorite = Favorite.create()\t#PARAMS\n\t\t\tfavorite.client = cleient\n\t\t\tcustomer.favorites << favorite\n\t\tend", "def create\n favourite = Favourite.new\n fav...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reduce the land mass images generated from the Google Map tiles into tiles comprising of the square 2x2 of the parent tile. For example, 4 tiles from zoom level 2 will be used to create one tile at zoom level 1 This script assumes that all tiles at the maximum zoom level exist Option hash :limit_to => allows maximum nu...
def start(*options) limit_to = options[0][:limit_to].to_s if ( (options.length > 0) && (options[0].instance_of?(Hash)) ) overwrite = options[0].keys.include?(:overwrite) if ( (options.length > 0) && (options[0].instance_of?(Hash)) ) update_log_every = 100 tiles_processed = 0 tiles_limit ...
[ "def build_reduced_land_mass_image(x, y, zoom, accuracy_pixels, overwrite = false)\n land_mass_tile_path = LandMassTile.tile_path(x, y, zoom, accuracy_pixels)\n \n # exit if file already exists\n return false if (!overwrite && File.exists?(land_mass_tile_path))\n \n begin\n # build up square ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build land mass image from Google Map image Returns true if image created
def build_reduced_land_mass_image(x, y, zoom, accuracy_pixels, overwrite = false) land_mass_tile_path = LandMassTile.tile_path(x, y, zoom, accuracy_pixels) # exit if file already exists return false if (!overwrite && File.exists?(land_mass_tile_path)) begin # build up square of 4 childre...
[ "def build_land_mass_image(x, y, zoom, overwrite = false)\n land_mass_tile_path = LandMassTile.tile_path(x, y, zoom, @accuracy_pixels)\n \n # exit if file already exists\n return false if (!overwrite && File.exists?(land_mass_tile_path))\n \n begin\n # load the tile image\n tile = Magick...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get x,y tiles for all tiles at maximum zoom level 1 down to zoom level 0 (1 tile)
def get_tiles tiles = [] accuracy_pixels_config = AppConfig.gmap_accuracy (0...AppConfig.gmap_max_zoom).reverse_each do |zoom| tiles_across = 2**zoom # the accuracy will go down by half at each zoom level with a floor of 1 i.e. 8 => 4, 7 => 2, 6 => 1, 5 => 1, 4 => 1 accuracy_pixels = (accu...
[ "def google_tile (tx, ty, zoom)\n [tx, (2**zoom - 1) - ty]\n end", "def quadtree_tiles(_zoom, quadx, quady)\n # When zoom == 20\n address_int = (dimensions[:x] * quady) + quadx\n address_bin = HumanComputer::Processor.eight_bitify address_int\n [Address.find_by(pid: @pid, address: address_bin)]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns all previously fetched entries; can be used to reprocess the events for, say, various historical analyses
def all_fetched_entries @entry_cache.all_entries end
[ "def fetch_entries\n entries.inject([]){ |all, entry| all << entry << addendas[entry] }.flatten.compact\n end", "def get_all_events_cached\n @events = Event.all_cached\n end", "def entries\n return @feed_entries if @feed_entries\n fetch if @atom_feed.nil?\n @feed_entries = @atom_feed....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send points in batches of a hundred. I'm not sure exactly how much the API can cope with in a single call, so this might change.
def _send_point(body) body.each_slice(100) do |p| conn.post('/?f=wavefront', p.join("\n"), 'application/octet-stream') end end
[ "def write_chunks(points)\n points.each_with_index do |point_group, index|\n check_progress(index, points.length, @init_time)\n @client.write_points(point_group)\n end\n end", "def send_batch msgs\n @socket.send_batch msgs\n end", "def batched_send(send_params_array)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the primary file spec for self. This is used for reporting where we want a single file spec only. Uses the one with key :primary if present, otherwise a random one.
def primary_file_spec @file_specs[:primary] || @file_specs[@file_specs.keys.first] end
[ "def primary\n result = @files[:primary].select do |file|\n if !file.static?\n true\n elsif file.ip_address.nil?\n false\n else\n ipaddr = IPAddr.new(file.ip_address)\n Reserved_IP_Ranges.none? { |range| range.include?(ipaddr) }\n end\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read browsers requirements from application config
def browsers(app) file = app.root.join('config/autoprefixer.yml') config = file.exist? ? YAML.load_file(file) : { 'browsers' => nil } config['browsers'] end
[ "def browsers\n all_browser_caps = ENV['SAUCE_ONDEMAND_BROWSERS'] && JSON.parse(ENV['SAUCE_ONDEMAND_BROWSERS'])\n if all_browser_caps && all_browser_caps.size > 0\n all_browser_caps\n else\n [single_browser_caps]\n end\n end", "def browsers\n [:android, :saf...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if this block is valid, and appears after prev block
def after?(prev_block) (index - prev_block.index) == 1 && prev_block.time <= time && prev_block.hash == prev_hash end
[ "def valid_block?(prev_block)\n prev_block_hash(prev_block) == last_block.hash\n end", "def block_valid?(args = {})\n block = Block.find_by(id: args[:block_id])\n previous_block = block.previous_block\n neighbor_blocks_valid?(block, previous_block)\n end", "def validate_block\r\n\t\tvalid_flag...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The ID of the parent object
def parent_id object["parent_id"] end
[ "def parent_id\n @parent_id || @parent.id\n end", "def id\r\n @id.start_with?('.') && @parent ? @parent.id + @id : @id\r\n end", "def parent\n in_objects.first\n end", "def parent_id\n\n h.parent_id ?\n Ruote::FlowExpressionId.new(h.parent_id) :\n nil\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A value that indicates whether this object can be embedded
def is_embeddable? object["is_embeddable"] end
[ "def embedded?\n @embedded\n end", "def embedded?\n @embedded == true\n end", "def embed?\n inheritable_documents.any?\n end", "def allowed?\n allowed\n end", "def embedded?\n @embedded ||= (cyclic ? _parent.present? : self.class.embedded?)\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /dialogs POST /dialogs.json
def create @dialog = Dialog.new(dialog_params) respond_to do |format| if @dialog.save format.html { redirect_to @dialog, notice: 'Dialog was successfully created.' } format.json { render action: 'show', status: :created, location: @dialog } else format.html { render action: ...
[ "def create\n @dialog = Dialog.new(dialog_params)\n\n respond_to do |format|\n if @dialog.save\n format.html { redirect_to @dialog, notice: 'Dialog was successfully created.' }\n format.json { render :show, status: :created, location: @dialog }\n else\n format.html { render :new...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /dialogs/1 PATCH/PUT /dialogs/1.json
def update respond_to do |format| if @dialog.update(dialog_params) format.html { redirect_to @dialog, notice: 'Dialog was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @dialog.errors, status...
[ "def update\n respond_to do |format|\n if @dialog.update(dialog_params)\n format.html { redirect_to @dialog, notice: 'Dialog was successfully updated.' }\n format.json { render :show, status: :ok, location: @dialog }\n else\n format.html { render :edit }\n format.json { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /dialogs/1 DELETE /dialogs/1.json
def destroy @dialog.destroy respond_to do |format| format.html { redirect_to dialogs_url } format.json { head :no_content } end end
[ "def destroy\n @gui_dialog = Gui::Dialog.find(params[:id])\n @gui_dialog.destroy\n\n respond_to do |format|\n format.html { redirect_to gui_dialogs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dialog = @story.dialogs.find(params[:id])\n @dialog.destroy\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Class is selected if listing type is currently selected
def get_new_listing_tab_class(listing_type) "new_listing_form_tab_#{@listing.listing_type.eql?(listing_type) ? 'selected' : 'unselected'}" end
[ "def selected_class\n selected? ? SimpleNavigation.config.selected_class : nil\n end", "def selected_class(sort_type, sorted_by)\n selected?(sort_type, sorted_by) ? 'selected' : ''\n end", "def get_type_select_icon_class(category)\n \"listing_type_select_icon_#{@listing.category.eql?(category) ? ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Class is selected if category is currently selected
def get_type_select_icon_class(category) "listing_type_select_icon_#{@listing.category.eql?(category) ? 'selected' : 'unselected'}_#{category}" end
[ "def selected_class\n if selected?\n container.selected_class || config.selected_class\n end\n end", "def selected_class\n selected? ? SimpleNavigation.config.selected_class : nil\n end", "def category_selected\n return unless logged_in? t(\"quotations.login_missing\")\n\n cate...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The classes the checkbox gets depend on to which categories its' share type belongs to.
def get_share_type_checkbox_classes(share_type) classes = "" Listing::VALID_CATEGORIES.each do |category| if Listing::VALID_SHARE_TYPES[@listing.listing_type][category] && Listing::VALID_SHARE_TYPES[@listing.listing_type][category].include?(share_type) classes += "#{category} " end ...
[ "def get_type_select_icon_class(category)\n \"listing_type_select_icon_#{@listing.category.eql?(category) ? 'selected' : 'unselected'}_#{category}\"\n end", "def share_types\n unique_categorizations(:share_type)\n end", "def classes\n kwattr_values(\"class\")\n end", "def classes=(value)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
expects category_string to be "item", "favor", "rideshare" or "housing"
def localized_category_label(category_string) return nil if category_string.nil? category_string += "s" if ["item", "favor"].include?(category_string) return t("listings.index.#{category_string}") end
[ "def check(string, category)\n @categories.key?(category) &&\n @categories[category].check(string)\n end", "def categorize(str)\n raise ArgumentError, 'str param must be a String' unless str.is_a?(String)\n\n outcomes = j_instance.categorize(str)\n j_instance.getBestCategory(outcomes)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns an array of numbers each word corresponds to a code.
def generate_code(str) word_arr = str.split(" ") word_arr_simple = str.downcase.split(" ").each {|x| x.gsub!(/\W+/, '')} word_hash = {} counter = 1 word_arr_simple.each do |word| if word_hash[word] != nil else word_hash[word] = counter counter += 1 end end $new_array = [] word_...
[ "def codewords\n codewords = []\n data = binary_data\n data, codewords[9] = data.divmod 636\n 8.downto(0) do |i|\n data, codewords[i] = data.divmod 1365\n end\n codewords\n end", "def split_code(codes)\n arr = []\n num = codes.scan(/\\d/).join('')\n str = codes.scan(/[a-...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /attachments/1 DELETE /attachments/1.json
def destroy @attachment = Attachment.find_by_name(params[:id]) @attachment.destroy respond_to do |format| format.html { redirect_to attachments_url } format.json { head :ok } end end
[ "def destroy\n @attachment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @attachment = Attachment.find(params[:id])\n @attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to attachments_url }\n format.json { he...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method that calculates an attack against us by another set of attributes Returns true if we die, false otherwise
def attacked(attacker) attack = rand(2+attacker.agility)-rand(@agility) if attack>0 @health -= rand(attacker.strength) @game.message(self.name + " suffers " + attack.to_s + " damage!") end if self.health <= 0 return true else return false end end
[ "def battle(attacker, defender)\n if accuracy_check(attacker.accuracy) \n defender.hull - attacker.firepower\n else\n return false\n end\nend", "def under_attack \n return true if warrior.health < @health\n return false\n end", "def check_attacked ai\n\t\tai.my_ants.each do |ant|\n\t\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds an age unit to the creature. When it's too young or old, it should not be a very good fighter. During it's postpuberty, it may try to reproduce. If it grows too old, it will die. Returns false if it dies, true otherwise
def take_age @age += 1 @infertility -= 1 if @infertility > 0 @hunger += 1 if @age > @max_age return false end return true end
[ "def isCharDead?\n if @age <= 50\n return false\n else\n return true\n end\n end", "def legal?\n @age >= LEGAL_AGE\n end", "def over_the_hill?\n return false if @age < 40\n true\n end", "def is_of_age?\n Time.now.years_ago(passenger_birthday.year).year > 18\n end", "def is...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We consider the creature to be hungry when its hunger is superior to its max HP divided by two
def hungry? return (@hunger > @max_health/2) end
[ "def poison_effect\n return max_hp/8\n end", "def damaged_hp_rate\n total_mob_max_hp = 0\n total_mob_current_hp = 0\n\n mobs.each do |mob|\n total_mob_max_hp += mob.max_hp\n total_mob_current_hp += mob.hp\n end\n\n total_mob_max_hp / total_mob_current_hp\n end", "def unit_hp\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The creature shall enter an infertility period
def enter_infertility @infertility = @p_o_i end
[ "def dead\r\n @energy < 0\r\n @gameover = true\r\n @timeout = true\r\n @time == 0\r\nend", "def encounter#instance method\n\n if !survive_attack?\n \"You died.\"\n elsif !outrun_zombie?\n \"You have been chased down.\"\n new_zombie_object = Zombie.new(30, 40)\n @@horde << new_zombie_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /request_templates GET /request_templates.json
def index @request_templates = RequestTemplate.all end
[ "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def list\n @client.make_request :get, templates_path\n end", "def get_templates(limit = 100, offset = 0)\n params = { limit: limit, offset: offset }\n\n request :get,\n '/v3/...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /request_templates POST /request_templates.json
def create @request_template = RequestTemplate.new(request_template_params) respond_to do |format| if @request_template.save respond format, 'Request template was successfully created.' else format.html { render :new } format.json { render json: @request_template.errors, sta...
[ "def index\n @request_templates = RequestTemplate.all\n end", "def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end", "def add_report_template(args = {}) \n post(\"/reports.json/template\", args)\nend", "def search_email_templates(request)\n sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /request_templates/1 PATCH/PUT /request_templates/1.json
def update respond_to do |format| if @request_template.update(request_template_params) respond format, 'Request template was successfully updated.' else format.html { render :edit } format.json { render json: @request_template.errors, status: :unprocessable_entity } end ...
[ "def patch_email_template(email_template_id, request)\n start.uri('/api/email/template')\n .url_segment(email_template_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .patch()\n .go()\n end", "def update_email_template(email_template_id, request)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a single translation status for the given project
def translation_status(project_id, status_id) c_r Lokalise::Resources::CustomTranslationStatus, :find, [project_id, status_id] end
[ "def project_status(project)\n h project.human_readable_status\n end", "def translation(project_id, translation_id, params = {})\n c_r Lokalise::Resources::Translation, :find, [project_id, translation_id], params\n end", "def project_status\n\t\t@project = Project.find(params[:id])\n\n\t\tre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates translation status inside the given project
def create_translation_status(project_id, params) c_r Lokalise::Resources::CustomTranslationStatus, :create, project_id, params end
[ "def create_custom_translation_status(project_id, req_params)\n params = { query: project_id, req: req_params }\n\n data = endpoint(name: 'CustomTranslationStatuses', params: params).do_post\n\n resource 'CustomTranslationStatus', data\n end", "def create_in_project(client, project: requ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates the given translation status inside the given project
def update_translation_status(project_id, status_id, params) c_r Lokalise::Resources::CustomTranslationStatus, :update, [project_id, status_id], params end
[ "def update_custom_translation_status(project_id, status_id, req_params = {})\n params = { query: [project_id, status_id], req: req_params }\n\n data = endpoint(name: 'CustomTranslationStatuses', params: params).do_put\n\n resource 'CustomTranslationStatus', data\n end", "def translation...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes translation status inside the given project
def destroy_translation_status(project_id, status_id) c_r Lokalise::Resources::CustomTranslationStatus, :destroy, [project_id, status_id] end
[ "def destroy_custom_translation_status(project_id, status_id)\n params = { query: [project_id, status_id] }\n\n data = endpoint(name: 'CustomTranslationStatuses', params: params).do_delete\n\n RubyLokaliseApi::Generics::DeletedResource.new data.content\n end", "def delete_translations\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array of available colors that can be assigned to custom translation statuses
def translation_status_colors(project_id) c_r Lokalise::Resources::CustomTranslationStatus, :colors, [project_id, 'colors'] end
[ "def colors\n localized[:colors]\n end", "def custom_translation_status_colors(project_id)\n params = { query: [project_id, :colors] }\n\n data = endpoint(name: 'CustomTranslationStatuses', params: params).do_get\n\n RubyLokaliseApi::Generics::CustomStatusAvailableColors.new data.content\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
makes a blast database from the query and the target
def makedb # check if the query is a nucleotide sequence query_file = Bio::FastaFormat.open(@query) query_file.each do |entry| raise "Query sequence looks like it's not nucleotide" if !entry.isNucl? end # check if the target is a nucl or prot seq target_file = Bio::FastaFormat.open(@targe...
[ "def makedb\n # only scan the first few hundred entries\n n = 100\n # check if the query is a nucl or prot seq\n query_file = Bio::FastaFormat.open(@query)\n count_p=0\n count=0\n query_file.take(n).each do |entry|\n count_p += 1 if entry.isProt?\n count += 1\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if a charname exists for a given User
def exists?(user, charname) #TODO: Figure out why querying for user fails not Character.first(:user_id => user._id, :name => charname).nil? end
[ "def char_taken?(char)\n check_char = Character.find_by_name(char.name)\n if check_char == nil \n \"no_entry\"\n else\n if check_char.user_id == 0\n \"unassigned\"\n else\n check_char.user.name\n end\n end\n end", "def user_exists?(name)\n Etc.getpwnam(name).nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if a character name is a reserved word
def reserved? charname ['create', 'list'].include? charname end
[ "def valid_name_char?(chr)\n VALID_LETTERS.include?(chr) ||\n VALID_DIGITS.include?(chr) ||\n chr == DASH ||\n chr == UNDESCORE\n end", "def valid_c_name?(name)\n return false if name.empty?\n name =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/\n end", "def reserved_name?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines how to display the invitation, depending on the invitation type. Options: :link_to_invitation will link to the invitee show page (for internal invitations) :expose_external_invitation_email will expose the external invitee's email (should only be exposed to sponsor)
def format_invitation(invitation, options = {}) expose_external_invitation_email = options.delete(:expose_external_invitation_email) || false link_to_invitation = options.delete(:link_to_invitation) || false if invitation.is_a? SurveyInvitation || NetworkInvitation then if link_to_invitation the...
[ "def set_view_for_invitation\n end", "def invitation_url(type, employee)\n if type == :invite\n new_account_organization_invitation_path(current_account, current_organization, invitation: { employee_id: employee.id })\n else\n edit_account_organization_invitation_path(current_account, current_org...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Auto links with links opening in a new window.
def auto_link_new_window(text) auto_link(text, :html => {:target => '_blank'}) end
[ "def gen_open_link_in_new_tab link_name\n\tnew_tab = window_opened_by do\n\t\tlink_to_open = page.find_link(link_name).native\n\t\tpage.driver.browser.action.key_down(:shift).click(link_to_open).key_up(:shift).perform() \n\tend\n\treturn new_tab\nend", "def autolink\n convert do |current|\n Rinku.auto...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines the subdomain that should be used when creating a CS link for the organization Checks to see if the email address passed belongs to an uninitialized association member
def subdomain_for(params) organization = params[:organization] email = params[:email] organization = Organization.find_by_email(email) if email if organization && organization.association then organization.association.subdomain else '' end end
[ "def email_domain\n if !self[:email].blank?\n split_host = URI.parse(\"#{self[:email]}\").path.split('@')\n \"#{split_host.last}\" if 2 == split_host.size\n else\n self.organization.site_domain if self.organization\n end\n rescue URI::InvalidURIError\n nil\n end", "def subdomain(sub)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
determines how to display the association contact information based on what fields are available
def association_contact_information contact = "<a href='mailto: #{current_association.contact_email}'>#{current_association.contact_name.blank? ? current_association.name : current_association.contact_name}</a>" contact += " at #{current_association.formatted_contact_phone}" unless current_associatio...
[ "def display_contacts\n Contact.each do |contacts|\n print \"First name: #{contacts.first_name}, Last name: #{contacts.last_name}, Email address: #{contacts.email}, Notes: #{contacts.note}\"\n end\n\n # HINT: Make use of this method in the display_all_contacts and search_by_attribute methods to keep y...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /artists/:artist_id/subscription/:id DELETE /users/:user_id/subscription/:id
def destroy @subscription.destroy respond_to do |format| format.html { redirect_to artist_subscription_path } format.json { head :ok } end end
[ "def destroy \n Instagram.delete_subscription({:id => params[:id]})\n local_subscription = Subscription.find_by_original_id params[:id]\n local_subscription.destroy if local_subscription\n redirect_to :admin_subscriptions\n end", "def destroy\n @user_artist.destroy\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get associated subscription (two paths)
def lookup_subscription @subscription = if params.has_key?(:id) UserSubscription.find(params[:id]) else current_user.user_subscriptions.where(artist: @user).first end end
[ "def subscription\n device = APN::Device.where(:subscriptions => {'$elemMatch' => { :_id => self.subscription_id }}).first\n device.subscriptions.where(:_id => self.subscription_id).first\n end", "def get_subscriber(subscription_id, subscriber_id)\r\n Subscription.new(subscription_id).getSub...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Replaces existing query definition or registers new if not exists in the system with given queryName
def replace_query_definition(query_name, body, opts = {}) data, _status_code, _headers = replace_query_definition_with_http_info(query_name, body, opts) return data end
[ "def addQueryName(theName)\n @metadata.addQueryName(theName)\n end", "def update_saved_query(name, query)\n url = @base_url + METHODS[:query_saved] + name\n saved_query_wrapper(url, query, update=true)\n end", "def register_percolator_query(query_name, options = {})\n server.request(:put, percol...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Queries using query definition identified by queryName. Maps the result to concrete objects based on provided mapper.
def run_query(query_name, mapper, opts = {}) data, _status_code, _headers = run_query_with_http_info(query_name, mapper, opts) return data end
[ "def run_query_with_http_info(query_name, mapper, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: CustomQueriesBPMApi.run_query ...\"\n end\n # verify the required parameter 'query_name' is set\n if @api_client.config.client_side_validation &&...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Queries using query definition identified by queryName. Maps the result to concrete objects based on provided mapper.
def run_query_with_http_info(query_name, mapper, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomQueriesBPMApi.run_query ..." end # verify the required parameter 'query_name' is set if @api_client.config.client_side_validation && query_name....
[ "def run_query(query_name, mapper, opts = {})\n data, _status_code, _headers = run_query_with_http_info(query_name, mapper, opts)\n return data\n end", "def run_query_filtered(query_name, mapper, opts = {})\n data, _status_code, _headers = run_query_filtered_with_http_info(query_name, mapper, op...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Queries using query definition identified by queryName. Maps the result to concrete objects based on provided mapper. Query is additional altered by the filter spec and/or builder
def run_query_filtered(query_name, mapper, opts = {}) data, _status_code, _headers = run_query_filtered_with_http_info(query_name, mapper, opts) return data end
[ "def run_query(query_name, mapper, opts = {})\n data, _status_code, _headers = run_query_with_http_info(query_name, mapper, opts)\n return data\n end", "def run_query_with_http_info(query_name, mapper, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Callin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a link to the current account management option create or show
def account_link return link_to I18n.t('user.show'), user_path(current_user) if current_user? link_to I18n.t('navigation.sign_up'), new_user_path end
[ "def switch_account_button(account, **options)\n # if Jumpstart::Multitenancy.domain? && account.domain?\n # link_to options.fetch(:label, account.name), account.domain, options\n if Jumpstart::Multitenancy.subdomain? && account.subdomain?\n link_to options.fetch(:label, account.name), root_url(subd...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Pass many strings that will be include in the load path and require all ruby files in the specified dir
def load_paths=(dirs) dirs.each do |dir| directory = File.expand_path(dir) $LOAD_PATH.unshift(directory) unless $LOAD_PATH.include?(directory) Dir["#{directory}/*.rb"].each { |file| require file } end end
[ "def require_all dir\n `ls #{dir}`.each_line do |file|\n require \"#{dir}/#{file.strip}\"\n end\nend", "def run_loadpath(paths)\n\n end", "def load_files(path)\n Dir[path].each {|file| require file}\nend", "def load_custom_ruby_files\n self[:require].each { |f| require f }\n end", "def requ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform all cascading deletes, destroys, or nullifies. Will delegate to the appropriate strategy to perform the operation.
def cascade! cascades.each do |name| if !metadata || !metadata.versioned? meta = relations[name] strategy = meta.cascade_strategy strategy.new(self, meta).cascade end end end
[ "def apply_destroy_dependencies!\n self.class._all_dependents.each do |association|\n if dependent = association.try(:dependent)\n send(\"_dependent_#{dependent}!\", association)\n end\n end\n end", "def doAllDeleteOperations(dryRun)\n #N Without this, the dele...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
set locale for interface translating from current admin user
def set_locale I18n.locale = access_control.user.locale end
[ "def set_locale\n admin = send(\"current_\" + ReleafDeviseHelper.devise_admin_model_name)\n I18n.locale = admin.locale\n end", "def set_locale\n I18n.locale = session[:admin_locale] = 'fr'\n end", "def set_locale\n I18n.locale = current_user.try(:locale) || locale_from_header\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Notify the user of the backup operation results. `status` indicates one of the following: `:success` : The backup completed successfully. : Notification will be sent if `on_success` was set to `true` `:warning` : The backup completed successfully, but warnings were logged : Notification will be sent, including a copy o...
def notify!(status) name = case status when :success then 'Success' when :warning then 'Warning' when :failure then 'Failure' end message = '[Backup::%s]' % name send_message(message) end
[ "def notify!(status)\n name, color = case status\n when :success then ['Success', success_color]\n when :warning then ['Warning', warning_color]\n when :failure then ['Failure', failure_color]\n end\n message = \"[Back...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get a class for each controller. This will be inserted as a class in the body tag.
def bodytag_class a = controller.class.to_s.underscore.gsub(/_controller$/, '').gsub(/\//, '-') "#{a}".gsub(/_/, '-') end
[ "def body_class\n qualified_controller_name = controller.controller_path.gsub('/','-')\n basic_body_class = \"#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}\"\n\n if @body_classes\n \"#{basic_body_class} #{@body_classes}\"\n else\n basic_body_class\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Selects messages from mailboxes then marking them with +flags+. If a block is given it is run after message marking. Unless :Noop was set, then it just prints out what it would do. Automatically called by IMAPClient::run
def run(message, flags) log message message_count = 0 mailboxes = find_mailboxes mailboxes.each do |mailbox| @mailbox = mailbox @imap.select @mailbox log "Selected #{@mailbox}" messages = find_messages next if messages.empty? message_count += messages.length ...
[ "def mark(messages, flags)\n messages.each_slice(500) do |chunk|\n @imap.store chunk, '+FLAGS.SILENT', flags\n end\n log \"Marked messages with flags\"\n end", "def run\n log \"Flagging tasty messages\"\n\n message_count = 0\n mailboxes = find_mailboxes\n\n mailboxes.each do |mailbox|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Connects to IMAP server +host+ at +port+ using ssl if +ssl+ is true then logs in as +username+ with +password+. IMAPClient will really only work with PLAIN auth on SSL sockets, sorry.
def connect(host, port, ssl, username, password, auth = nil) @imap = Net::IMAP.new host, port, ssl, nil, false log "Connected to #{host}:#{port}" if auth.nil? then auth_caps = @imap.capability.select { |c| c =~ /^AUTH/ } raise "Couldn't find a supported auth type" if auth_caps.empty? auth...
[ "def connect(host = @options[:Host],\n port = @options[:Port],\n ssl = @options[:SSL],\n username = @options[:Username],\n password = @options[:Password],\n auth = @options[:Auth]) # :yields: Connection\n imap = Net::IMAP.new host, port, ssl, nil, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds mailboxes with messages that were selected by the :Boxes option.
def find_mailboxes mailboxes = @imap.list(@root, "*") if mailboxes.nil? then log "Found no mailboxes under #{@root.inspect}, you may have an incorrect root" return [] end mailboxes.reject! { |mailbox| mailbox.attr.include? :Noselect } mailboxes.map! { |mailbox| mailbox.name } @box...
[ "def find_messages\n @box = @boxes.find { |box| @mailbox =~ /#{box}/ } # TODO: needs more work\n raise unless @box\n @email = @flag[@box]\n raise unless @email\n return [answered_in_curr, wrote_in_curr, responses_in_curr].flatten\n end", "def find_messages\n mailbox = @boxes.find { |box| @mailb...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Searches for messages matching +query+ in the selected mailbox (see Net::IMAPselect). Logs 'Scanning for +message+' before searching.
def search(query, message) log " Scanning for #{message}" messages = @imap.search query log " Found #{messages.length} messages" return messages end
[ "def search_messages query\n if query == \"All Mail\"\n 1.upto(@metaindex.size).map {|i| @metaindex.load_messageinfo(i)}.compact\n else\n query = Heliotrope::Query.new \"body\", query.gsub(/All Mail/,\"\").strip\n @metaindex.set_query query\n @metaindex.get_some_results @metain...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Marks +messages+ in the currently selected mailbox with +flags+ (see Net::IMAPstore).
def mark(messages, flags) messages.each_slice(500) do |chunk| @imap.store chunk, '+FLAGS.SILENT', flags end log "Marked messages with flags" end
[ "def run(message, flags)\n log message\n\n message_count = 0\n mailboxes = find_mailboxes\n\n mailboxes.each do |mailbox|\n @mailbox = mailbox\n @imap.select @mailbox\n log \"Selected #{@mailbox}\"\n\n messages = find_messages\n\n next if messages.empty?\n\n message_count +...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Reset the tracking of job executions.
def reset! executions.reset end
[ "def reset_counter\n @run_count = 0\n end", "def reset\n @log = []\n reset_failure_count\n end", "def reset\n @before_run = @persisted = @after_run = false\n end", "def reset\n # reset all the steps (stati and execution times)\n @steps.each(&:reset)\n # reset the st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Lookup storage class for a given options key
def lookup_storage(key) { memory: Storage::Memory, redis: Storage::Redis }[key] end
[ "def object_from_option_name option_name\n assoc.klass.find option_name.to_i\n end", "def get_storage_object(key)\n obj = singleton_class.retrieve_storage_key(key)\n Rails.logger.debug(\" #{self.class.name}.#{__method__}(#{obj.class.name}) retrieved existing with key:#{key}\")\n obj\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the system needs a reboot or is expected to reboot Note that we will silently miss any other platformspecific reboot notices besides Windows+Ubuntu.
def reboot_pending? # don't break when used as a mixin in contexts without #node (e.g. specs). if respond_to?(:node, true) && node.run_context.reboot_requested? true elsif platform?("windows") # PendingFileRenameOperations contains pairs (REG_MULTI_SZ) of filenames that canno...
[ "def reboot?\n !!@reboot\n end", "def is_rebooting?()\n reboot_detect_script = VagrantWindows.load_script('reboot_detect.ps1')\n @machine.communicate.execute(reboot_detect_script, :error_check => false) != 0\n end", "def requires_reboot\n return @requires_reboot\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /passwords/new GET /passwords/new.xml
def new @password = Password.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @password } end end
[ "def new\n @pwd_tracker = PwdTracker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pwd_tracker }\n end\n end", "def new\n @password = password.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :j...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /passwords POST /passwords.xml
def create @password = Password.new(params[:password]) respond_to do |format| if @password.save flash[:notice] = 'Password was successfully created.' format.html { redirect_to(passwords_path) } format.xml { render :xml => @password, :status => :created, :location => @password } ...
[ "def generate_new_password_for_guest(args = {}) \n post(\"/guestaccess.json/#{args[:guestId]}/newpassword\", args)\nend", "def create\n @password = application.passwords.new(password_params)\n\n respond_to do |format|\n if @password.save\n format.html { redirect_to [application, @password], noti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /passwords/1 DELETE /passwords/1.xml
def destroy @password = Password.find(params[:id]) @password.destroy respond_to do |format| format.html { redirect_to(passwords_url) } format.xml { head :ok } end end
[ "def destroy\n @password = password.find(params[:id])\n \n @password.destroy\n\n respond_to do |format|\n format.html { redirect_to passwords_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @password.destroy\n respond_to do |format|\n format.html { redire...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Just word difference between the first and second half of a word Not really anagram
def word_diff return -1 unless (@word.size % 2 == 0) # initialize a hash with 26 lowercase alphabet character and set count for 0 word_hash = ('a'..'z').inject({}) {|h,c| h[c] = 0; h} # Increment count for first word len = @word.size / 2 @word[0..len-1].split("").each {|c...
[ "def word_unscrambler(str, words)\n anagram = [] \n letters = str.split(\"\").sort #ex: 'cat'\n other_words = words.split(\"\") #ex 'tac', tic, toc == tac\n \n other_words.each do |o_word|\n # letters_of_other_words = other_words[x].split(\"\")\n letters_of_other_words = o_word.split(\"\").sort\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Register the known input types for such a processor.
def _RegisterInputTypes @knownInputClasses.push(Rokuby::ProjectDescription) @knownInputClasses.push(Rokuby::ProjectConfiguration) @knownInputClasses.push(Rokuby::ProjectInstance) @knownInputClasses.push(Rokuby::VsProjectDescription) @knownInputClasses.push(Rokuby::VsProjectConfiguration) ...
[ "def _RegisterInputTypes\n @knownInputClasses.push(Rokuby::ProjectDescription)\n @knownInputClasses.push(Rokuby::ProjectConfiguration)\n @knownInputClasses.push(Rokuby::ProjectInstance)\n @knownInputClasses.push(Rokuby::GppProjectDescription)\n @knownInputClasses.push(Rokuby::GppProjectConf...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Time in years between BeginContract and Period.end
def years_of_service(period=nil) # TODO: need a real general purpose date diff by year # function since this is likely needed in multiple places. return 0 if contract_start.nil? period = Period.current if period.nil? if (period.finish > contract_start) tmp_date = period.finish count = 0...
[ "def years_count\n ((@end_date - @start_date).to_f / 365).to_f.round(1)\n end", "def span_years; end", "def end_year\n Time.now.year - 90\n end", "def financial_year_range\n start_date..end_date\n end", "def get_begin_date\n get_end_date.prev_year\n end", "def years\n year_delta = @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find out average number of hours per month based on the number of hours expected to work per day
def hours_per_month ((hours_day * days_week_to_i()) * WEEKS_IN_YEAR ).fdiv(MONTHS_IN_YEAR) end
[ "def hour_averages(minutes)\n hours = {}\n minutes.chunk { |minute|\n minute.formatted_hour\n }.each { |hour, array|\n hours[hour] = array.collect(&:seats).average\n }\n hours\nend", "def hours_per_day(entries)\n hours_per_day = Hash.new(0.0)\n entries.each do |entry|\n hours_per_day[entry[:start]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write the given ast to a string and returns it
def to_s(ast) @file = '' process(ast) @file end
[ "def to_s\n @ast.to_s\n end", "def to_ast\n @ast\n end", "def astdump(ast)\n ast = transform(ast) unless ast.kind_of?(Puppet::Parser::AST)\n Puppet::Pops::Model::AstTreeDumper.new.dump(ast)\n end", "def dump_ast\n print_ast(@top_node, \"\")\n puts \"\"\n end", "def to_rubocop_a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /district_students POST /district_students.xml
def create @student = current_district.students.build(params[:student]) respond_to do |format| if @student.save flash[:notice] = "#{edit_obj_link(@student)} was successfully created.".html_safe format.html { redirect_to(index_url_with_page) } else format.html { render :actio...
[ "def create\n # @student_district = StudentDistrict.new(params[:student_district])\n\n respond_to do |format|\n if @student_district.save\n format.html { redirect_to @student_district, notice: 'Student district was successfully created.' }\n format.json { render json: @student_district, stat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /district_students/1 PUT /district_students/1.xml
def update @student = current_district.students.find(params[:id]) respond_to do |format| if @student.update_attributes(params[:student]) flash[:notice] = "#{edit_obj_link(@student)} was successfully updated.".html_safe format.html { redirect_to(index_url_with_page) } else fo...
[ "def update\n # @student_district = StudentDistrict.find(params[:id])\n\n respond_to do |format|\n if @student_district.update_attributes(params[:student_district])\n format.html { redirect_to @student_district, notice: 'Student district was successfully updated.' }\n format.json { head :ok ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /district_students/1 DELETE /district_students/1.xml
def destroy @student = current_district.students.find(params[:id]) @student.remove_from_district respond_to do |format| format.html { redirect_to(index_url_with_page) } end end
[ "def destroy\n @district = District.find(params[:id])\n @district.destroy\n\n respond_to do |format|\n format.html { redirect_to(district_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @district = District.find(params[:id])\n @district.destroy\n\n respond_to do |for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /evactivities/1 GET /evactivities/1.xml
def show @evactivity = Evactivity.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @evactivity } end end
[ "def recent_activities\n get(\"/user/#{@user_id}/activities/recent.json\")\n end", "def recent_activities()\n get(\"/user/#{@user_id}/activities/recent.json\")\n end", "def show\n @activity = get_user.activities.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.er...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /evactivities/new GET /evactivities/new.xml
def new @evactivity = Evactivity.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @evactivity } end end
[ "def new\n @activity = get_user.activities.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @activity }\n end\n end", "def new\n @today_activity = TodayActivity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml {...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /evactivities POST /evactivities.xml
def create @evactivity = Evactivity.new(params[:evactivity]) respond_to do |format| if @evactivity.save flash[:notice] = 'Evactivity was successfully created.' format.html { redirect_to(@evactivity) } format.xml { render :xml => @evactivity, :status => :created, :location => @eva...
[ "def create\n raise Request::NoRequiredFields unless params[:activities]\n Request.add( params[:org_id], current_user, \"activity\", \"add\", { :new_record => params[:activities][0..4] } )\n respond_success \"Бпасибо, Π’Π°Ρˆ запрос ΠΎΡ‚ΠΏΡ€Π°Π²Π»Π΅Π½\", requests_path\n rescue ActiveRecord::RecordInvalid, ActiveRecord...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /evactivities/1 PUT /evactivities/1.xml
def update @evactivity = Evactivity.find(params[:id]) respond_to do |format| if @evactivity.update_attributes(params[:evactivity]) flash[:notice] = 'Evactivity was successfully updated.' format.html { redirect_to(@evactivity) } format.xml { head :ok } else format.ht...
[ "def update\n @activity = Activity.find(params[:id])\n \n respond_to do |format|\n if @activity.update_attributes(params[:activity])\n format.html { redirect_to activities_path }\n format.xml { render :nothing => true }\n else\n format.html { render :action => \"edit\" }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /evactivities/1 DELETE /evactivities/1.xml
def destroy @evactivity = Evactivity.find(params[:id]) @evactivity.destroy respond_to do |format| format.html { redirect_to(evactivities_url) } format.xml { head :ok } end end
[ "def destroy\n @activity = get_user.activities.find(params[:id])\n @activity.destroy\n\n respond_to do |format|\n format.html { redirect_to(activities_url()) }\n format.xml { head :ok }\n end\n end", "def destroy\n @today_activity = TodayActivity.find(params[:id])\n @today_activity.d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /line_destinations GET /line_destinations.json
def index @line_destinations = LineDestination.all end
[ "def prep_destinations\n # grab addresses from request params\n @delivery_route_addresses = params[:route][:addresses_attributes]\n # map delivery addresses into [x,y]\n @destinations = @delivery_route_addresses.map.with_index(1) { |address, idx|\n # concat address vales into continuous string\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /line_destinations POST /line_destinations.json
def create destination = Destination.find(params[:destination_id]) @line_destination = @plan.add_destination(destination.id) respond_to do |format| if @line_destination.save format.html { redirect_to @line_destination.plan, notice: 'Line destination was successfully created.' } format...
[ "def index\n @line_destinations = LineDestination.all\n end", "def create\n @destination = Destination.new(destination_params)\n @destination.save\n set_destinations\n end", "def prep_destinations\n # grab addresses from request params\n @delivery_route_addresses = params[:route][:addresses_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /line_destinations/1 PATCH/PUT /line_destinations/1.json
def update respond_to do |format| if @line_destination.update(line_destination_params) format.html { redirect_to @line_destination, notice: 'Line destination was successfully updated.' } format.json { render :show, status: :ok, location: @line_destination } else format.html { ren...
[ "def update\n @shipping_line = ShippingLine.find(params[:id])\n\n respond_to do |format|\n if @shipping_line.update_attributes(params[:shipping_line])\n format.html { redirect_to @shipping_line, :notice => 'Shipping line was successfully updated.' }\n format.json { head :no_content }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /line_destinations/1 DELETE /line_destinations/1.json
def destroy @line_destination.destroy respond_to do |format| format.html { redirect_to line_destinations_url, notice: 'Line destination was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to lines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @route = Line.find_by_slug(params[:line_id]).routes.find(params[:id])\n @route.destroy\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks if a particular block has been defined within the current block scope. Options: [+name+] The name of the block to check
def defined?(name) !blocks[name].nil? end
[ "def defined?(name)\n !blocks[name.to_sym].nil?\n end", "def has_block(name)\n @blocks.key?(name.to_s)\n end", "def check_block name\n raise \"No such block: #{name}\" unless @source.key? name\n end", "def block_exist?( name )\n return @blocks.include?( name )\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Define a block, unless a block by the same name is already defined. "1", :parameter2 => "2" do |options| %> and Options: [+name+] The name of the block being defined (either a string or a symbol or a Proc) [+options+] The default options for the block definition. Any or all of these options may be overridden by whomeve...
def define(name, options={}, &block) collection = options.delete(:collection) if collection collection.each do |object| define(call_with_params(name, object, options), options, &block) end else self.define_block_container(name, options, &block) end nil ...
[ "def define(name, options={}, &block)\n # Check if a block by this name is already defined.\n if blocks[name.to_sym].nil?\n # Store the attributes of the defined block in a container for later use\n block_container = BuildingBlocks::Container.new\n block_container.name = name\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Skip the rendering of a particular block when blocks.render is called for the a particular block name My output Options: [+name+] The name of the block to skip rendering for
def skip(name) blocks[name] = nil skipped_blocks[name] = true self.define_block_container(name) do end nil end
[ "def strip_block(block_name)\n print \"Stripping block {block:#{block_name}}...\"\n if self.gsub!(ThemeSnippet.block_regex_pattern_for(block_name), '')\n puts \"removed!\"\n else\n puts \"no match found!\"\n end\n end", "def skip_filter(*names, &blk)\n skip_before_render_filter(*name...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a block to render before another block. This before block will be put into an array so that multiple before blocks may be queued. They will render in the order in which they are declared when the "blocksrender" method is called. Any options specified to the before block will override any options specified in the bl...
def before(name, options={}, &block) self.add_block_container_to_list("before_#{name.to_s}", options, &block) nil end
[ "def render_before_blocks(name_or_container, *args)\n render_before_or_after_blocks(name_or_container, \"before\", *args)\n end", "def before(&blk)\n self.before_block = blk\n end", "def before(&block)\n opts[:before_hook] = if b = opts[:before_hook]\n proc do\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a block to render after another block. This after block will be put into an array so that multiple after blocks may be queued. They will render in the order in which they are declared when the "blocksrender" method is called. Any options specified to the after block will override any options specified in the block ...
def after(name, options={}, &block) self.add_block_container_to_list("after_#{name.to_s}", options, &block) nil end
[ "def render_after_blocks(name_or_container, *args)\n render_before_or_after_blocks(name_or_container, \"after\", *args)\n end", "def after_configure(&block)\n @after_configure_blocks ||= []\n @after_configure_blocks << block\n end", "def append_after(scope = :each, &block)\n after_pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a block to render around another block. This around block will be put into an array so that multiple around blocks may be queued. They will render in the order in which they are declared when the "blocksrender" method is called, with the last declared around block being rendered as the outermost code, and the first...
def around(name, options={}, &block) self.add_block_container_to_list("around_#{name.to_s}", options, &block) nil end
[ "def render_before_or_after_blocks(name_or_container, before_or_after, *args)\n options = args.extract_options!\n\n block_options = {}\n if (name_or_container.is_a?(BuildingBlocks::Container))\n name = name_or_container.name.to_sym\n block_options = name_or_container.options\n else...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a unique name for an anonymously defined block (i.e. a block that has not been given a name)
def anonymous_block_name self.anonymous_block_number += 1 "block_#{anonymous_block_number}" end
[ "def next_block_name\n @next_block_id ||= 0\n \"block#{@next_block_id += 1}\".to_sym\n end", "def name_code\n \t \n \tself.block_name = self.block_name.upcase\n \t\n \tself.code = self.block_name[0..2]\n end", "def block_name \n :CodeBlock \n end", "def set_block_na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Render all the before blocks for a partial block
def render_before_blocks(name_or_container, *args) render_before_or_after_blocks(name_or_container, "before", *args) end
[ "def before_render(&block)\n state.before_render_callbacks << block\n end", "def before_render\n @blocks.each do |(path, block)|\n if _within?(path)\n @stasis.action.class.class_eval(&block)\n end\n end\n end", "def render_left_blocks\n result = ''\n Block.l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Render all the after blocks for a partial block
def render_after_blocks(name_or_container, *args) render_before_or_after_blocks(name_or_container, "after", *args) end
[ "def after_render(&block)\n @after_render_block = block\n end", "def after_bundle(&block)\n @after_bundle_blocks ||= []\n @after_bundle_blocks.append(block)\nend", "def render_before_or_after_blocks(name_or_container, before_or_after, *args)\n options = args.extract_options!\n\n block_options = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Utility method to render either the before or after blocks for a partial block
def render_before_or_after_blocks(name_or_container, before_or_after, *args) options = args.extract_options! block_options = {} if (name_or_container.is_a?(Blocks::Container)) name = name_or_container.name.to_sym block_options = name_or_container.options else name = name...
[ "def render_before_or_after_blocks(name_or_container, before_or_after, *args)\n options = args.extract_options!\n\n block_options = {}\n if (name_or_container.is_a?(BuildingBlocks::Container))\n name = name_or_container.name.to_sym\n block_options = name_or_container.options\n else...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }