query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Yield each bookmark to the block that requires synchronization. The :since option may be specified to indicate the time of the most recently updated bookmark. Only bookmarks whose time is more recent than the time specified are yielded.
def synchronize(options={}) if since = options[:since] since.utc return false unless updated_since?(since) else since = Time.at(0) since.utc end open.elements.each('posts/post') do |el| attributes = el.attributes time = Time.iso8601(attributes['tim...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bookmark_query(q,&blk)\n response = query(q)\n bookmark = response[\"bookmark\"]\n docs = response[\"docs\"]\n\n until !docs || docs.empty?\n yield docs\n q[\"bookmark\"] = bookmark\n response = query(q)\n bookmark = response[\"bookmark\"]\n ...
[ "0.5677542", "0.5362584", "0.5287357", "0.5209643", "0.5123315", "0.50758433", "0.49724126", "0.49338025", "0.49207413", "0.48885435", "0.4852993", "0.47811237", "0.47484133", "0.4718143", "0.4698666", "0.46631137", "0.46602684", "0.46602684", "0.46602684", "0.46580476", "0.4...
0.5633354
1
A Time object representing when the most recent bookmark was created or updated.
def remote_last_updated_at require 'rexml/document' doc = REXML::Document.new(request('update')) Time.iso8601(doc.root.attributes['time']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bookmark_time\n @ole.BookmarkTime\n end", "def latest_restorable_time\n data[:latest_restorable_time]\n end", "def latest_restorable_time\n data[:latest_restorable_time]\n end", "def last_edited_time\n begin\n $redis.hget 'last_edit:instrument', self.id\n rescue\n ...
[ "0.7708772", "0.69254977", "0.69254977", "0.6861092", "0.678406", "0.678406", "0.678406", "0.6771644", "0.6768277", "0.67533755", "0.6752988", "0.6735972", "0.6689751", "0.6683843", "0.66806775", "0.66806775", "0.66806775", "0.66806775", "0.6680535", "0.6646449", "0.6646449",...
0.636663
36
Initializes all keys to `UNSET_VALUE`
def initialize super keys.each do |key| set(key, self.class::UNSET_VALUE) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear\n keys.each do |k|\n Jeapie.instance_variable_set(\"@#{k}\", nil)\n end\n end", "def reset_initial_values\n @initial_values.clear if @initial_values\n @missing_initial_values.clear if @missing_initial_values\n end", "def reset!\n @significant_keys = nil\n @orders = ...
[ "0.69660556", "0.6755322", "0.67488617", "0.6719314", "0.66499686", "0.66154104", "0.6439547", "0.64275587", "0.64091766", "0.63930345", "0.6391282", "0.6360693", "0.6350334", "0.63373464", "0.6332697", "0.6281231", "0.6239432", "0.6217614", "0.6217614", "0.621136", "0.619826...
0.8348679
0
Overrides values from specified environment variables, and sets them to default values if no configuration was found
def finalize! super keys.each { |key| set(key, resolve_value(key)) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_environment_defaults\n @format = env(:format, @format) if @format.nil?\n @autopath = env(:autopath, @autopath) if @autopath.nil?\n @files = env(:files, @files) if @files.empty?\n @match = env(:match, @match) if @match.empty?\n @tags = env(:tags, @t...
[ "0.73390996", "0.7317774", "0.72905385", "0.72395974", "0.71362275", "0.6962681", "0.6847984", "0.68433154", "0.68208647", "0.681351", "0.6758425", "0.6666344", "0.6579933", "0.6579933", "0.6533237", "0.65212125", "0.6495378", "0.643742", "0.6423049", "0.6419716", "0.63936406...
0.0
-1
Returns a configuration line/stanza for the specified key and value. The returned line should include linefeed `\\n` if not empty. The default implementations returns "=\\n".
def config_for(key, value) "#{key}=#{value && value}\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_line(value)\n config_value = AppConfig.config[value]\n if config_value.kind_of? Mash\n config_value = config_value.to_hash\n end\n str = [config_value.inspect].flatten.first.split(\"\\n\").first\n if str.length > VALUE_LENGTH\n str = str[0..(VALUE_LENGTH - 4)] + '...'\n end\n ...
[ "0.6334932", "0.595716", "0.55967873", "0.5538644", "0.5380671", "0.5348368", "0.5344652", "0.5301884", "0.52344185", "0.5225823", "0.51633716", "0.513886", "0.5133486", "0.512706", "0.5108123", "0.5065678", "0.50303304", "0.50193423", "0.50114393", "0.49856082", "0.49671972"...
0.6606757
0
Returns a new instance of this class where all nil keys are replaced from the specified default config
def merge_defaults(defaults) result = dup keys.each do |key| if !set?(key) && defaults.key?(key) result.set(key, defaults.get(key)) end end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default!(defaults = {})\n replace(defaults.merge(self))\n end", "def initialize\n @config = DEFAULT_CONFIG.deep_dup\n end", "def default_config\n {}\n end", "def merge_default(defaults)\n if defaults && !defaults.empty?\n defaults.each do |key, value|\n self[key] = va...
[ "0.6929436", "0.6734182", "0.6635432", "0.65440416", "0.65005666", "0.6454535", "0.64253783", "0.64216715", "0.6393175", "0.6335105", "0.63335717", "0.6316129", "0.63160366", "0.63126355", "0.6299907", "0.62725574", "0.6265084", "0.6259665", "0.62550896", "0.6246645", "0.6233...
0.0
-1
GET /categories GET /categories.json
def index get_paginated_categories respond_to do |format| format.html format.js format.xls if(params[:a] == "a") format.csv { send_data Category.all.to_csv2 } else format.csv { send_data Category.all.to_csv } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def categories\n\t\tbegin\n\t\t\t@categories = Category.select(:id, :name)\n\t\t\trender json: @categories\n\t\trescue Exception => e\n\t\t\terror_handling_bad_request(e)\n\t\tend\n\tend", "def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter:...
[ "0.83901125", "0.83281714", "0.8320568", "0.7809046", "0.7742267", "0.756787", "0.75121796", "0.74144626", "0.73855793", "0.7370643", "0.73698753", "0.73698753", "0.7368008", "0.73468053", "0.7331163", "0.73165005", "0.7285874", "0.7265682", "0.72289234", "0.72212476", "0.721...
0.0
-1
POST /categories POST /categories.json
def create init = params[:category][:name][0] division = Division.find_by_name(params[:division_id].upcase) category_number = Category.create_number(params) @category = Category.new(category_params.merge(:code => (('%03d' % ((Category.last.code.to_i rescue 0)+1)))).merge(:division_id => division.id)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n json_create(category_params, Category)\n end", "def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATE...
[ "0.77381927", "0.74330735", "0.7234303", "0.71620107", "0.7123316", "0.70633465", "0.7054235", "0.6957395", "0.6956477", "0.6904152", "0.68380356", "0.682139", "0.68183225", "0.6807698", "0.67846733", "0.6612181", "0.65656227", "0.6565445", "0.65561736", "0.6522468", "0.65185...
0.0
-1
PUT /categories/1 PUT /categories/1.json
def update @category = Category.find(params[:id]) if @category.update_attributes(category_params) flash[:notice] = 'Category was successfully updated.' redirect_to categories_path else flash[:error] = @category.errors.full_messages # format.js render "edit" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end", "def update_categories(categories, options = {} )\n options.merge!(:docid => self.docid, :categories => categories)\n resp = @conn.put do |req|\n ...
[ "0.7724567", "0.74909496", "0.7319212", "0.70157593", "0.6877518", "0.6792349", "0.66833127", "0.66648275", "0.6634337", "0.6618428", "0.6588373", "0.6572942", "0.6507015", "0.65063256", "0.64743674", "0.64715", "0.6443928", "0.6425827", "0.6413952", "0.6379", "0.6352537", ...
0.0
-1
DELETE /categories/1 DELETE /categories/1.json
def destroy @category = Category.find(params[:id]) @category.destroy get_paginated_categories respond_to do |format| format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @category.destroy\n render json: @category, status: :ok\n end", "def destroy\n @category = Category.find(params[:id])\n @category.destroy\n\n respond_to do |f...
[ "0.78272814", "0.77353686", "0.76392984", "0.7488916", "0.74731207", "0.74233276", "0.7399541", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7385346", "0.7378597", "0.7378597"...
0.0
-1
execute a block with a different format (ex: an html partial while in an ajax request)
def with_format(format, &block) old_formats = formats self.formats = [format] block.call self.formats = old_formats nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_partial(context, options, &block); end", "def body_content\n call_block\n end", "def parse_block_html; end", "def content\n call_block\n end", "def render\n if @block\n instance_eval(&@block)\n end\n end", "def partial_html_sections\n # Tell our application_h...
[ "0.6462519", "0.64606804", "0.6451388", "0.64014333", "0.6225472", "0.6206344", "0.61626506", "0.60735977", "0.6058124", "0.60069346", "0.5984732", "0.59455407", "0.59347486", "0.59331524", "0.5906178", "0.5905666", "0.5882819", "0.5882819", "0.58650273", "0.58508176", "0.584...
0.0
-1
A method that takes an attribute name and its class. This creates a getter and setter for the instance variable of the same name, but the setter checks the type of value being assigned. If the type differs from that specified by the second parameter, an exception is thrown. If the type matches, then the value is assign...
def strong_attr_accessor(source_class, *name) names.each do |name| var_name = "@#{name}".to_sym define_method(name) { instance_variable_get(var_name) } define_method("#{name}=".to_sym) do |value| raise 'Classes do not match' unless value.instance_of?(source_class) inst...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_accessor_typesafe(*classes_args)\n classes_args.each_with_index do |attr_name, i|\n next if i%2 == 0\n\n class_name = classes_args[i-1].name\n attr_name = attr_name.to_s\n\n #getter\n self.class_eval %Q{\n def #{attr_name}\n fail \"variable <#{attr_name}> ac...
[ "0.7088052", "0.6800977", "0.6744544", "0.6447708", "0.6442046", "0.6409927", "0.6365219", "0.6295124", "0.62298024", "0.6219169", "0.61600345", "0.61524636", "0.6144862", "0.6132096", "0.61246794", "0.61132425", "0.6050269", "0.60252124", "0.60041666", "0.59901935", "0.59756...
0.5752653
34
7kyu I made a program that filters a list of strings and returns a list with only friends name in it. If a name has exactly 4 letters in it, you can be sure that it has to be a friend of yours! Otherwise, you can be sure he's not...
def friend(friends) x = [] friends.each { |i| puts i.length if i.length == 4 x.push(i) end } x end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def friend(friends)\n \n return [] if friends.empty? \n friends=friends.split(\",\") if (friends.is_a? String)\n friends.select{|friend| friend.length==4 && (friend.is_a? String)}\nend", "def friend(friends)\r\n friends_name = []\r\n friends.each {|friend| friends_name.push(friend) if friend.length == 4}\r\n ...
[ "0.76541257", "0.72479296", "0.71305364", "0.7041879", "0.66225225", "0.65617454", "0.6332171", "0.6316158", "0.61874115", "0.6154084", "0.60753995", "0.603734", "0.5877262", "0.5824719", "0.5815174", "0.576773", "0.57626194", "0.5721331", "0.57092106", "0.56818986", "0.56811...
0.6000399
12
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) min_key=nil min_value=0 counter=0 name_hash.collect do |key, value| if value < min_value || counter==0 min_key = key min_value = value end counter+=1 end min_key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n...
[ "0.8821222", "0.8777674", "0.87769854", "0.8745862", "0.8689437", "0.86553806", "0.865241", "0.86165065", "0.8587693", "0.8572328", "0.85674095", "0.8550907", "0.8529734", "0.8529734", "0.85182345", "0.84936565", "0.8475531", "0.8475531", "0.8466132", "0.8449126", "0.84490585...
0.0
-1
client > proxyserver > MongoDB > proxyserver ( ABAC ) > client
def callbacks(conn) conn.server(:srv, { :host => @config[:server_host], :port => @config[:server_port]}) conn.on_data do |data| # parse the raw binary message @flag = false # nil raw_msg, msg = WireMongo.receive(data) @recent = msg # nil # nil # nil...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect_through_proxy; end", "def using_proxy?; end", "def connect_using_proxy(socket); end", "def proxy (port)\n $CACHE = Cache.new()\n\n # open the server connection so that we can listen\n # in on the given port\n server = TCPServer.open(\"localhost\", port)\n\n # start listening for requests\n ...
[ "0.6663332", "0.6392823", "0.63490814", "0.63107526", "0.6228371", "0.6129923", "0.6128783", "0.6126886", "0.5989413", "0.5989413", "0.5989413", "0.59859174", "0.5967109", "0.5920627", "0.59042215", "0.58757436", "0.58522743", "0.58055454", "0.5796844", "0.5793429", "0.575287...
0.54683876
47
should this take a list of 'red' etc and look up the colours?
def set colours colours.each_with_index do |colour, i| fixed_colour = colour.map { |c| GAMMA[c] } rings[i] = PixelPi::Color *fixed_colour end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def colors() = @colors ||= %i[blue green purple magenta cyan yellow red]", "def getColor(c)\n if c == \"r\" then return :red\n elsif c == \"b\" then return :blue\n elsif c == \"g\" then return :green\n elsif c == \"y\" then return :yellow\n elsif c == \"c\" then return :cyan\n elsif c == \"m\" then return ...
[ "0.73149836", "0.70366913", "0.70128655", "0.69800335", "0.6907872", "0.68729234", "0.68729234", "0.6813431", "0.6812007", "0.67940795", "0.6714879", "0.66767114", "0.66204363", "0.6592053", "0.65894055", "0.6570208", "0.6536134", "0.6531635", "0.65295815", "0.65161973", "0.6...
0.0
-1
This gets a game cliche from a list of cliches in a text file
def get_game_cliche #initialize variable chosen_line = nil #Get the cliche File.foreach("game_cliches.txt").each_with_index do |line, number| chosen_line = line if rand < 1.0/(number+1) end return chosen_line.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_file(file)\n file_lines_array = File.readlines(file)\n file_characters_array = []\n file_lines_array.each do |line|\n file_characters_array << line\n end\n file_characters_array.map! do |character|\n character = @dictionary[character]\n end\n morse_code = file_characters_arr...
[ "0.60776716", "0.58314663", "0.5727392", "0.5727392", "0.56803805", "0.55513674", "0.5522171", "0.55120814", "0.53398526", "0.5279201", "0.52735335", "0.52666813", "0.52592844", "0.52514553", "0.52434874", "0.51947075", "0.516467", "0.5110767", "0.5105512", "0.50975233", "0.5...
0.7069886
0
This gets a business model from a list in a text file
def get_business_model #initialize variable chosen_line = nil #Get the cliche File.foreach("business_models.txt").each_with_index do |line, number| chosen_line = line if rand < 1.0/(number+1) end return chosen_line.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_from_file(filename = \"listsave\")\n\t\tIO.readlines(filename).each do |line|\n\t\t\tadd_task(Task.new(line.chomp))\n\t\tend\n\tend", "def read_models\n File.readlines(\"car-models.txt\").each do |line|\n @modles_hash[line[0,1]] = line.partition('=').last.chomp\n end\n # puts \"@modles_has...
[ "0.5695746", "0.5681048", "0.5620122", "0.5601672", "0.55808204", "0.55757797", "0.5550483", "0.5545499", "0.5530213", "0.54000396", "0.53902805", "0.53765845", "0.5367506", "0.53501093", "0.5347121", "0.53337157", "0.53337157", "0.5333076", "0.5310881", "0.5310881", "0.52765...
0.6435022
0
This gets a game genre from a list in a text file
def get_game_genre #initialize variable chosen_line = nil #Get the cliche File.foreach("game_genres.txt").each_with_index do |line, number| chosen_line = line if rand < 1.0/(number+1) end return chosen_line.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_genre_list()\n File.open('./genre_list')\nend", "def load_genre(file_name)\n\t\tindata = []\n\t\tCSV.foreach(\"#{file_name}\", col_sep: \"|\") do |row|\n\t\t\tgenre_for_movie = [row[5].to_i,row[6].to_i,row[7].to_i,row[8].to_i,row[9].to_i,row[10].to_i,row[11].to_i,row[12].to_i,row[13].to_i,row[14].to_i,...
[ "0.692953", "0.67731315", "0.6715894", "0.6458827", "0.6436415", "0.6399445", "0.63710093", "0.62383497", "0.6196342", "0.6195388", "0.61871946", "0.6115621", "0.6111598", "0.60685605", "0.6032322", "0.60173255", "0.5997231", "0.5992747", "0.59678346", "0.5966975", "0.587621"...
0.7423634
0
The top left of checkerboard should always be filled with [r] You should assume the size input is always an integer You should not assume the size input is always positive number Input size of <= 0 will return an empty string
def checkerboard(size) for i in 1..size do i % 2 == 0 ? checker=0 : checker=1 for j in 1..size do if checker == 1 print "[r]" checker = 0 else print "[b]" checker = 1 end end puts "\n" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkerboard(size)\n return \"\" if size <= 0\n completed_board = \"\"\n\n first_line = size.times do |n|\n if n.odd?\n completed_board << \"[r]\"\n else\n completed_board << \"[b]\"\n end\n end\n\n # binding.pry\nend", "def board(empty_square_char = '.')\n board_str = \" ABCDEFGH...
[ "0.7710083", "0.67398125", "0.66570306", "0.64006877", "0.63859284", "0.63433677", "0.6326673", "0.63063467", "0.6300146", "0.62883115", "0.62721723", "0.6269958", "0.62586683", "0.6236139", "0.6236139", "0.62247515", "0.62210417", "0.6220166", "0.6217392", "0.6162387", "0.61...
0.7139748
1
ActiveRecord::Base.establish_connection :adapter => :nulldb
def check_limit_offset(params) %i(limit offset).each do |p| unless params[p].nil? begin params[p] = Integer(params[p]) rescue ArgumentError raise Exception.new("#{p.to_s} is not an integer") end end end return params end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_connection\n settings = {\n adapter: 'sqlite3',\n database: temp_file(\"\")\n }\n ActiveRecord::Base.establish_connection(settings)\n ActiveRecord::Base.connection\nend", "def connection\n ActiveRecord::Base.connection\n end", "def connection\n ActiveRecord::Base.connection\n end", ...
[ "0.7385665", "0.71668893", "0.71668893", "0.71224797", "0.70422375", "0.7028706", "0.7013474", "0.69961834", "0.68992656", "0.6873064", "0.68022835", "0.67683685", "0.6680943", "0.66615087", "0.6655488", "0.6602563", "0.6589965", "0.6566522", "0.64215326", "0.6418039", "0.635...
0.0
-1
Create Fitness base on `access_token` and `authentication_token`
def create_fitness(options={}) options = { access_token: options[:access_token], fitness: { timestamp: options[:timestamp], primary_type: options[:primary_type], intensity: options[:intensity], start_time: options[:start_time], total_distance: opti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n puts \"MESSAGE 14 IN CREATE\"\n @auth = request.env['omniauth.auth']['credentials']\n # The following statement saves the tokens to the database\n Token.create(\n access_token: @auth['token'],\n refresh_token: @auth['refresh_token'],\n expir...
[ "0.62985295", "0.6046622", "0.60394263", "0.60279596", "0.59811884", "0.5951267", "0.5911963", "0.58370155", "0.58201367", "0.57845044", "0.576786", "0.57342196", "0.56925106", "0.5683174", "0.5676897", "0.5646178", "0.56432146", "0.56332815", "0.56057465", "0.5588948", "0.55...
0.59690934
6
The redraw() function makes draw() execute once. In this example, draw() is executed once every time the mouse is clicked.
def setup size 200, 200 @y = 100 stroke 255 no_loop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_draw( event )\n dirty_rects = draw( event.screen )\n event.screen.update_rects(dirty_rects)\n end", "def draw\n end", "def draw\n end", "def draw\n end", "def draw\n end", "def reload\n draws = @draws.dup\n clear\n draws.each { |block| draw(&block) }\n ...
[ "0.7007123", "0.6685596", "0.6685596", "0.6685596", "0.6623632", "0.6572368", "0.6517742", "0.65167433", "0.64859945", "0.6477629", "0.6477629", "0.6477629", "0.6477629", "0.6462083", "0.6462083", "0.63677293", "0.6347879", "0.63139594", "0.6202709", "0.61418515", "0.6117978"...
0.0
-1
The number of alarms. Returns an Integer.
def count @alarms.objects.find { |o| o.name == "count" }.val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count\n @monkeys.count\n end", "def aps_notification_count_for_application(application_name)\n redis.llen(aps_application_queue_key(application_name)).to_i\n end", "def num_missed_calls\n missed_contacts.count\n end", "def get_at_words_count\n @redis.llen(\"store:ats\").to_...
[ "0.6462344", "0.628732", "0.5995112", "0.5980965", "0.5917086", "0.5846684", "0.5811305", "0.5753843", "0.5741786", "0.5738726", "0.5713813", "0.5709746", "0.56947064", "0.56912374", "0.56524205", "0.5648412", "0.56226647", "0.5620281", "0.5602073", "0.5579684", "0.55703425",...
0.7122949
0
Query alarms. options A Hash of options: :start A DateTime instance describing the earliest time to query history for. :end A DateTime instance describing the latest time to query history for.
def query options from = options.fetch :start to = options.fetch :end query = @alarms.objects.find { |o| o.name == "query" } filter = OBIX::Builder.new do obj do abstime name: "start", val: from.iso8601 abstime name: "end", val: to.iso8601 end end.ob...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query options\n from = options.fetch :start\n to = options.fetch :end\n\n query = @history.objects.find { |o| o.name == \"query\" }\n\n filter = OBIX::Builder.new do\n obj do\n abstime name: \"start\", val: from.iso8601\n abstime name: \"end\", val: to.iso8601\n ...
[ "0.7354929", "0.5985333", "0.58743316", "0.58070326", "0.5764716", "0.5755746", "0.5753159", "0.5711461", "0.56931704", "0.5642877", "0.5606174", "0.5584435", "0.54797727", "0.54386693", "0.54228055", "0.54051065", "0.53797007", "0.53651226", "0.5352223", "0.534723", "0.53454...
0.8652422
0
url the link/site body string words array of the body histogram
def initialize(url) #pass in the url...cnn @url = url #saving the url in n instance variable #this is how you create a default value for a hash @histogram = Hash.new(0) #taking histogram and creating a hash but setting default values at 0. we're going to be couting words so default should be zero pars...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_url\n map = map_words_on_page\n map.each do |word, count|\n wc = WordCount.new(:word=>word, :count=>count, :page_id => object_id)\n push wc # todo pull the push/stack functionality out of Page to minimize db calls\n end\n end", "def score_for_body_links\n link_count = self.mess...
[ "0.58963275", "0.5879348", "0.57970613", "0.5660673", "0.55442375", "0.54835504", "0.54835504", "0.54834515", "0.5471452", "0.54589516", "0.5456753", "0.5455539", "0.54499", "0.5448315", "0.5444331", "0.543729", "0.5435514", "0.5431505", "0.5427271", "0.5427271", "0.54243207"...
0.54556453
11
responds to json or html requests through inheritance from BaseController:
def index #respond_with if current_user_from_api_access respond_to do |format| format.json { render json: current_user_from_api_access.measurements.all.to_json } format.html { render text: current_user_from_api_access.measurements.all.to_json } end else respond_to do |f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(*)\n respond_to do |format|\n format.jsonapi { super }\n format.json { super }\n end\n end", "def responder\r\n self.class.respond_to :html, :json\r\n end", "def interface\n respond_to do |format|\n format.json {}\n end\n end", "def show\n respond_to d...
[ "0.722741", "0.71344936", "0.6774035", "0.65800697", "0.65792745", "0.65206504", "0.65200824", "0.6509677", "0.64965665", "0.64454347", "0.63354063", "0.6302215", "0.6283222", "0.6251773", "0.62393016", "0.6180863", "0.6180863", "0.6180863", "0.6180863", "0.6180863", "0.61808...
0.59665954
67
returns the measure record associated with the device
def measure_for_device(device_id, measure_id) device = Device.where(:name => device_id) # use first on device to get record from association, then # use first again on measures to get measure record device.first.measures.where(:name => measure_id).first if device.any? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def measure\n Measure.new(1, self)\n end", "def get_cell_measures(cell)\n query_cell_info '/cell/getMeasures', cell\n end", "def get_patient_result(patient_id)\n qm = QualityMeasure.new(@measure_id, @sub_id)\n measure = Builder.new(get_db, qm.definition, @parameter_values)\n ...
[ "0.6254628", "0.62511176", "0.6113168", "0.6065451", "0.6030521", "0.6027722", "0.5988547", "0.5962184", "0.5931976", "0.59317654", "0.59277445", "0.5884901", "0.5878865", "0.58713424", "0.5865355", "0.586038", "0.5829321", "0.58077085", "0.5791861", "0.57839763", "0.5758343"...
0.77113473
0
POST /users POST /users.json
def create @user = User.new(user_params) respond_to do |format| if @user.save format.html { redirect_to groups_path, notice: 'User was successfully created.' } format.json { render :show, status: :created, location: @user } session[:user_id] = @user.id else format.ht...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post b...
[ "0.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def user_params params.require(:user).permit(:user_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.6949516", "0.68133247", "0.6803944", "0.6795208", "0.6745487", "0.67407674", "0.65270406", "0.6520888", "0.6491314", "0.6430685", "0.6430685", "0.6430685", "0.6398393", "0.6355302", "0.63544565", "0.6347063", "0.6343035", "0.63376737", "0.6326283", "0.6326283", "0.6326283"...
0.0
-1
write a function to search target in nums. If target exists, then return its index, otherwise return 1. Template 1 is the most basic and elementary form of Binary Search. It is the standard Binary Search Template that most high schools or universities use when they first teach students computer science. Template 1 is u...
def search(nums, target) left = 0 right = nums.length - 1 while left <= right pivot = left + (right - left) / 2 return pivot if nums[pivot] == target if target < nums[pivot] right = pivot - 1 else left = pivot + 1 end end -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_target(nums, target)\n return -1 if nums.empty? || !target\n start_ind = 0\n last_ind = nums.size - 1\n mid = (start_ind + last_ind) / 2\n\n #having condition as start_ind + 1 < last_ind will be helpful in find first/last position in function\n #also avoid infinite loop when the array ...
[ "0.86517495", "0.8379405", "0.81462884", "0.8144708", "0.794463", "0.78020096", "0.7797183", "0.77851063", "0.7719615", "0.77196014", "0.7711477", "0.7692617", "0.7687563", "0.76829803", "0.7676202", "0.76682353", "0.7660379", "0.7660379", "0.7649494", "0.76413953", "0.762154...
0.86788327
0
Approach 2: Time complexity: O(n) implementation This approach traverses the entire array until it finds the target value.
def search(nums, target) nums.each_with_index do |num, index| return index if num == target end -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_target(nums, target)\n return -1 if nums.empty? || !target\n start_ind = 0\n last_ind = nums.size - 1\n mid = (start_ind + last_ind) / 2\n\n #having condition as start_ind + 1 < last_ind will be helpful in find first/last position in function\n #also avoid infinite loop when the array ...
[ "0.70447177", "0.70421404", "0.7010863", "0.6975586", "0.69155717", "0.6900799", "0.68797463", "0.6874444", "0.6800295", "0.6797924", "0.67750895", "0.67574704", "0.67372996", "0.67370737", "0.67188925", "0.67035687", "0.669355", "0.6691955", "0.6690252", "0.66829795", "0.667...
0.0
-1
GET /properties GET /properties.json
def toggle_fav @property = Property.find(params[:id]) current_usertemp.favorited?(@property) ? current_usertemp.unfavorite(@property) : current_usertemp.favorite(@property) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end", "def get_properties\n xm...
[ "0.75018007", "0.7475009", "0.746873", "0.7455118", "0.7341186", "0.73298395", "0.728888", "0.728888", "0.7288875", "0.71567196", "0.7149775", "0.71148396", "0.7105831", "0.7083838", "0.7083838", "0.7083838", "0.7083838", "0.70709115", "0.70466745", "0.70451057", "0.70230925"...
0.0
-1
GET /properties/1 GET /properties/1.json
def show @agent = @property.account @count = Property.where(zona: @property.zona).where.not(id: @property).count @neighbourhood = Property.where(zona: @property.zona).where.not(id: @property).limit(3) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @property = Property.find(params[:id])\n\n render json: @property\n end", "def show\n property = Property.find params[:id]\n respond_to do |format|\n format.html {}\n format.json { render :json => property}\n end\n end", "def show\n @property = Property.find(params[:i...
[ "0.74967957", "0.73476976", "0.7304607", "0.72556674", "0.72336495", "0.72336495", "0.72336495", "0.72336495", "0.7188035", "0.7172849", "0.7145906", "0.71286345", "0.70898354", "0.70896214", "0.70896214", "0.7055902", "0.70408046", "0.69893426", "0.6987266", "0.6970528", "0....
0.0
-1
POST /properties POST /properties.json
def create @property = Property.new(property_params) # params[:property][:cover_picture].each do |image| mini_image = MiniMagick::Image.new(params[:property][:cover_picture].tempfile.path) mini_image.resize '1200x1200' # end # params[:property][:pictures].each do |image| # mini_image =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @property = Property.new(property_params)\n\n if @property.save\n render json: @property, status: :created, location: @property\n else\n render json: @property.errors, status: :unprocessable_entity\n end\n end", "def property_params\n params.require(:property).permit!\n ...
[ "0.72530675", "0.7060616", "0.7046808", "0.70337754", "0.70122105", "0.6942112", "0.69248956", "0.6900617", "0.6889012", "0.68744063", "0.68609405", "0.68319124", "0.68319124", "0.68319124", "0.68319124", "0.68319124", "0.68319124", "0.68319124", "0.68010026", "0.6796665", "0...
0.0
-1
PATCH/PUT /properties/1 PATCH/PUT /properties/1.json
def update respond_to do |format| if @property.update(property_params) format.html { redirect_to @property, notice: 'Property was successfully updated.' } format.json { render :show, status: :ok, location: @property } else format.html { render :edit } format.json { render...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "d...
[ "0.7230165", "0.6859053", "0.6859053", "0.6859053", "0.6859053", "0.6859053", "0.66675586", "0.66257334", "0.6604779", "0.6590328", "0.65412945", "0.6528812", "0.6528812", "0.65230703", "0.6513928", "0.65127814", "0.6489119", "0.6483777", "0.6479823", "0.64533067", "0.6453306...
0.63508874
31
DELETE /properties/1 DELETE /properties/1.json
def destroy @property.destroy respond_to do |format| format.html { redirect_to properties_url, notice: 'Property was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n #@property = Property.find(params[:id])\n @property.destroy\n\n respond_to do |format|\n format.html { redirect_to properties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @property = Property.find(params[:id])\n @property.destroy\n\n respond_...
[ "0.7364613", "0.73575217", "0.73575217", "0.73561615", "0.73561615", "0.73491865", "0.73491865", "0.7317726", "0.7288179", "0.727353", "0.7259411", "0.7255245", "0.72499126", "0.7248999", "0.72075725", "0.7179407", "0.71657205", "0.7145741", "0.71061295", "0.7086546", "0.7081...
0.711052
27
Use callbacks to share common setup or constraints between actions.
def set_property @property = Property.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6165094", "0.60450804", "0.5944413", "0.5915806", "0.58885634", "0.5835225", "0.5775847", "0.5700531", "0.5700531", "0.56543404", "0.56209993", "0.54238355", "0.5410386", "0.5410386", "0.5410386", "0.5394892", "0.5377769", "0.53559244", "0.5339896", "0.53388095", "0.533008...
0.0
-1
Only allow a list of trusted parameters through.
def property_params params.require(:property).permit(:id,:account_id,:featured,:comision,:duenos_id,:descripcion,:tipoOp,:tipoProp, :zona, :colonia, :precio, :mConst, :mTerreno, :banos,:ac,:alarm,:lift,:balcony,:furnished,:bbq,:heating,:fireplace,:backyard,:pool,:terrace,:security,:comision, :recamaras,:cover_pic...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69485277", "0.6813547", "0.6799911", "0.6796169", "0.6745757", "0.6741778", "0.6527065", "0.65204644", "0.64925444", "0.64314413", "0.64314413", "0.64314413", "0.6398711", "0.6355623", "0.6355327", "0.6345812", "0.6343951", "0.6338371", "0.6327366", "0.6327366", "0.6327366...
0.0
-1
1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirtyone, Saving February alone, Which has twentyeight, rain or shine. And on leap years, twentynine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. How many Sunday...
def add_day(day) day += 24*60*60 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def countSundaysYear(year, startDay)\n\tsundays = 0\n\tday = startDay % 7\n\tif(isLeapYear(year))\n\t\tyear = $MonthsLeap\n\telse\n\t\tyear = $Months\n\tend\n\t\n\tyear.each do |x|\n\t\tif(day == 0)\n\t\t\tsundays += 1\n\t\tend\n\t\tday = ((day + x) % 7)\n\t\t\n\tend\n\t\n\treturn sundays\nend", "def total_sunda...
[ "0.7489364", "0.72933215", "0.7270485", "0.72318393", "0.7160231", "0.7018686", "0.70099545", "0.6989564", "0.6955054", "0.6954173", "0.69245076", "0.68479466", "0.68394285", "0.68319017", "0.67667097", "0.67360306", "0.66971827", "0.6672687", "0.66698015", "0.6659785", "0.66...
0.0
-1
check if two arrays contain the same contents
def same_set?(a, b) ((a - b) + (b - a)).blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arrays_equivalent(array1, array2)\n return true if array1 == array2\n return false unless array1 && array2 # either one is nil\n\n array1.count == array2.count && (array1 - array2).empty? && (array2 - array1).empty?\n end", "def array_equals(array1, array2)\n #raise NotImplementedError\n#Check for...
[ "0.8304899", "0.8097667", "0.8039322", "0.8020542", "0.79603225", "0.7939865", "0.7915729", "0.7911575", "0.79086286", "0.79078823", "0.790613", "0.78635913", "0.7845817", "0.7820372", "0.7796", "0.7794774", "0.77891284", "0.7780091", "0.7764603", "0.7763603", "0.77446127", ...
0.6895629
74
Adds a handler to the reactor. A handler is a callable taking a single argument, the message.
def add_handler(handler) @handlers << handler end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_message_handler(&block)\n @message_handlers << block\n end", "def add_handler(name, handler)\n subscribe(name)\n subscriptions[name].handlers << handler\n end", "def handler\n @handlers.push(proc do |msg|\n yield msg\n end)\n end", "def add_handler(new_handler)\n ...
[ "0.7231306", "0.70802605", "0.6918257", "0.67517906", "0.6619087", "0.6497206", "0.6444436", "0.64262986", "0.63075036", "0.6248153", "0.621285", "0.6183933", "0.617584", "0.61286837", "0.5891722", "0.5729914", "0.5725149", "0.5690471", "0.56413794", "0.5638347", "0.5552255",...
0.7232581
0
GET /recovery_passwords GET /recovery_passwords.json
def index @recovery_passwords = RecoveryPassword.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @passwords = current_user.passwords\n end", "def password\n respond_to do |format|\n format.html\n format.json { render json: { :password => get_password } }\n end\n end", "def forgot_password\n user = validate_user(params['forgot_username'])\n\n devices = get_mfa_devices...
[ "0.6642948", "0.65952843", "0.6493781", "0.62614274", "0.62520427", "0.62235296", "0.6222507", "0.6112147", "0.605353", "0.6041732", "0.6038329", "0.60291475", "0.59056455", "0.59056455", "0.58997273", "0.5888444", "0.58786786", "0.58556145", "0.5850409", "0.5814593", "0.5804...
0.70308644
0
GET /recovery_passwords/1 GET /recovery_passwords/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @recovery_passwords = RecoveryPassword.all\n end", "def password\n respond_to do |format|\n format.html\n format.json { render json: { :password => get_password } }\n end\n end", "def forgot_password\n user = validate_user(params['forgot_username'])\n\n devices = get_mfa_...
[ "0.6763542", "0.67008877", "0.64790297", "0.644061", "0.6385905", "0.6188214", "0.60768247", "0.60183734", "0.6007298", "0.59789145", "0.59695286", "0.59339875", "0.5930383", "0.59030926", "0.58430356", "0.5828433", "0.5757152", "0.5748743", "0.5744994", "0.5744994", "0.57158...
0.0
-1
POST /recovery_passwords POST /recovery_passwords.json
def create @recovery_password = RecoveryPassword.new(recovery_password_params) respond_to do |format| if @recovery_password.save format.html { redirect_to @recovery_password, notice: 'Recovery password ha sido creado.' } format.json { render :show, status: :created, location: @recovery_pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n puts 'Recovery password!!!!!!!!!!!!!!!!!!!!!!'\n self.resource = resource_class.send_reset_password_instructions(resource_params)\n\n if successfully_sent?(resource)\n render status: 200, json: nil\n else\n render status: 400, json: { message: 'Invalid email!' }\n # binding....
[ "0.6374773", "0.62566763", "0.62361735", "0.62082964", "0.61124355", "0.6088549", "0.6035341", "0.60332566", "0.60098505", "0.5997153", "0.59957033", "0.59919095", "0.5968382", "0.59658456", "0.59611714", "0.59586763", "0.59586763", "0.5920181", "0.59013224", "0.5885759", "0....
0.66673905
0
PATCH/PUT /recovery_passwords/1 PATCH/PUT /recovery_passwords/1.json
def update respond_to do |format| if @recovery_password.update(recovery_password_params) format.html { redirect_to @recovery_password, notice: 'Recovery password ha sido actualizado.' } format.json { render :show, status: :ok, location: @recovery_password } else format.html { ren...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#...
[ "0.7038705", "0.6849744", "0.6849744", "0.6739247", "0.6659965", "0.6589009", "0.65321237", "0.65321237", "0.64814776", "0.6469921", "0.6428219", "0.64126647", "0.64113885", "0.64082414", "0.63714933", "0.6342289", "0.6268501", "0.6267053", "0.626467", "0.62633336", "0.625635...
0.6532131
6
DELETE /recovery_passwords/1 DELETE /recovery_passwords/1.json
def destroy @recovery_password.destroy respond_to do |format| format.html { redirect_to recovery_passwords_url, notice: 'Recovery password ha sido eliminado.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @password.destroy\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 @xmt_mgr_password.destroy\n respond_to do |format|\n format.html { redirect_to xmt_mgr_passwords_url, notice: 'Passwo...
[ "0.69135994", "0.65709585", "0.6546936", "0.6473401", "0.63672", "0.6350938", "0.63128436", "0.6280077", "0.6279821", "0.62780744", "0.6257426", "0.62523204", "0.6236595", "0.6233573", "0.61981446", "0.6159638", "0.61543375", "0.61443245", "0.6133967", "0.6116662", "0.6086743...
0.69258785
0
Use callbacks to share common setup or constraints between actions.
def set_recovery_password @recovery_password = RecoveryPassword.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163821", "0.6045432", "0.5945441", "0.5916224", "0.58894575", "0.5834073", "0.57764685", "0.5702474", "0.5702474", "0.5653258", "0.56211996", "0.54235053", "0.5410683", "0.5410683", "0.5410683", "0.53948104", "0.5378064", "0.5356684", "0.53400385", "0.53399503", "0.533122...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def recovery_password_params params.require(:recovery_password).permit(:recovery_password_id, :state, :user_id, :token, :progress) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Reads keypresses from the user including 2 and 3 escape character sequences.
def read_char STDIN.echo = false STDIN.raw! input = STDIN.getc.chr if input == "\e" then input << STDIN.read_nonblock(3) rescue nil input << STDIN.read_nonblock(2) rescue nil end ensure STDIN.echo = true STDIN.cooked! return input end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_pressed\n if STDIN.ready?\n input = STDIN.read_nonblock(1) rescue nil\n if input == \"\\e\" \n input << STDIN.read_nonblock(3) rescue nil\n input << STDIN.read_nonblock(2) rescue nil\n end\n end\n # STDIN.cooked!\n input\n\nend", "def pressKey\n STDIN.echo = false\n STDIN.raw!\n ...
[ "0.7172551", "0.7169227", "0.70784056", "0.7075981", "0.7036095", "0.6970929", "0.6938356", "0.68953437", "0.6784526", "0.6697007", "0.6683167", "0.6661258", "0.6653919", "0.65723825", "0.65356755", "0.64906526", "0.64837956", "0.6473542", "0.64629143", "0.6436959", "0.643314...
0.6393362
23
== Constraints Chef libraries are evaluated before the recipe that places the chef_gem that it needs is put into place. This places two constraints on this library: 1) A 'require' must be done in a method 2) This class cannot use 'Subclass < Superclass' As Net::LDAP is a class it cannot be included as a module
def initialize require 'rubygems' require 'net-ldap' require 'cicphash' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conscientious_require; end", "def load_cloudflare_cookbook_gems\n return if defined? @@cloudflare_cookbook_gems_loaded\n chef_gem 'cloudflare' do\n action :install\n version '2.0.1'\n end\n require 'resolv'\n require 'cloudflare'\n @@cloudflare_cookbook_gems_loaded = true\nend...
[ "0.6480207", "0.64590555", "0.62435687", "0.6108768", "0.6097916", "0.6090847", "0.6049699", "0.6030041", "0.60176545", "0.6016308", "0.5910933", "0.5820359", "0.57835615", "0.57699853", "0.5769488", "0.5702365", "0.5679358", "0.56678206", "0.56448567", "0.5639703", "0.558224...
0.66525275
0
== Bind This method should not be used directly. It is used to bind to the directory server. The databag_name is the name of the databag that is used for looking up connection credentials. It returns a connected ruby Net::LDAP object
def bind( host, port, credentials, databag_name, use_tls ) # :yields: host, port, credentials, databag_name, use_tls credentials = credentials.kind_of?(Hash) ? credentials.to_hash : credentials.to_s unless databag_name.kind_of?(String) or databag_name.kind_of?(Symbol) raise "Invalid databag_name: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bind\n conn = Net::LDAP.new :host => @config[:server],\n :port => @config[:port],\n :base => @config[:base]\n if @config[:encryption]\n conn.encryption @config[:encryption]\n end\n \n ...
[ "0.6913362", "0.63650143", "0.6115088", "0.6058074", "0.6005063", "0.6000602", "0.5991074", "0.59695226", "0.5956265", "0.5793615", "0.5700936", "0.5565955", "0.5537644", "0.5522277", "0.5521801", "0.5499361", "0.5465693", "0.5459872", "0.53915536", "0.5391111", "0.53690284",...
0.7768266
0
== Search This method is used to search the directory server. It accepts the connection resource object described above along with the basedn to be searched. Optionally it also accepts an LDAP filter and scope. The default filter is objectClass= and the default scope is 'base' It returns a list of entries.
def search( c, basedn, *constraints ) # :yields: connection_info, basedn, filter, scope self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap raise "Must specify base dn for search" unless basedn ( filter, scope, attributes ) = constraints filter = filter.nil? ? N...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_ldap(session_handle, base, scope, filter, fields)\n vprint_status(\"Searching LDAP directory\")\n search = wldap32.ldap_search_sA(session_handle, base, scope, filter, nil, 0, 4)\n vprint_status(\"search: #{search}\")\n\n if search['return'] == LDAP_SIZELIMIT_EXCEEDED\n print_error(\"LDAP...
[ "0.70574045", "0.6846109", "0.6770961", "0.65752316", "0.6574974", "0.645856", "0.6366931", "0.62826765", "0.6233852", "0.6118379", "0.60482985", "0.6020928", "0.5801382", "0.56704265", "0.5670218", "0.56624055", "0.5576212", "0.5559215", "0.5526331", "0.55008805", "0.5485458...
0.830434
0
== Get Entry This method accepts a connection resource object. It is intended to be used with Chef::Resource::LdapEntry objects that will also have a .dn method indicating Distinguished Name to be retrieved. It returns a single entry.
def get_entry( c, dn ) # :yields: connection_info, distinguished_name self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap entry = @ldap.search( base: dn, filter: Net::LDAP::Filter.eq( 'objectClass', '*' ), scope: Net::L...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookup_entry\n\t\tself.log.debug \"Looking up entry for %s\" % [ self.dn ]\n\t\tentry = nil\n\n\t\tif self.include_operational_attrs?\n\t\t\tself.log.debug \" including operational attributes.\"\n\t\t\tentry = self.directory.get_extended_entry( self )\n\t\telse\n\t\t\tself.log.debug \" not including operatio...
[ "0.69192225", "0.6838741", "0.6255633", "0.62506276", "0.6213904", "0.61219466", "0.6081091", "0.6077004", "0.6066452", "0.60608196", "0.594333", "0.5859642", "0.58492595", "0.58359665", "0.5781691", "0.5781691", "0.5737232", "0.5667582", "0.566263", "0.56159306", "0.5518761"...
0.78271013
0
== Add Entry This method accepts a connection resource object, a distinguished name, and the attributes for the entry to be added.
def add_entry( c, dn, attrs ) # :yields: connection_info, distinguished_name, attributes self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap # Ensure no duplicates by casting as a case insensitive, case preserving hash attrs = CICPHash.new.merge(attrs) # Ensu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_entry entry\n @data << entry\n end", "def add_subscription_entry(name, entry)\n\t\tend", "def add(entry)\n @entries[entry.tag] = entry\n end", "def add(dn, attributes)\n attributes = normalize_attributes(attributes)\n log_dispatch(:add, dn, attributes)\n adapter.add...
[ "0.61634195", "0.6126714", "0.6046693", "0.60178816", "0.58524925", "0.568015", "0.56614065", "0.5592205", "0.5586353", "0.5576164", "0.55708426", "0.55561775", "0.5537293", "0.5488622", "0.5487179", "0.54644245", "0.54437673", "0.5431659", "0.54093915", "0.54081136", "0.5394...
0.76255393
0
== Modify Entry Accepts a connection resource object as the first argument, followed by an Array of ldap operations. It is intended to be used with Chef::Resource::LdapEntry objects that will also have a .dn method that returns the DN of the entry to be modified. Each ldap operation in the ldap operations list is an Ar...
def modify_entry( c, dn, ops ) # :yields: connection_info, distinguished_name, operations entry = self.get_entry( c, dn ) @ldap.modify dn: dn, operations: ops raise "Unable to modify record: #{@ldap.get_operation_result.message}" unless @ldap.get_operation_result.message =~ /(Success|Attribute or ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_entry(entry, ldap_attrs, user_attrs, ldap_key, user_key)\n if user_attrs.has_key?(user_key)\n if ldap_attrs.has_key?(ldap_key)\n if user_attrs[user_key] != ldap_attrs[ldap_key].first\n entry << LDAP.mod(LDAP::LDAP_MOD_REPLACE, ldap_key, user_attrs[user_key].is_a?(String) ...
[ "0.6744574", "0.6497927", "0.60004467", "0.595042", "0.59479856", "0.59115237", "0.57591045", "0.5537294", "0.5492222", "0.5431266", "0.5388358", "0.5270078", "0.5257175", "0.5213396", "0.5180569", "0.51710707", "0.5163162", "0.515719", "0.50943655", "0.50943655", "0.50694454...
0.79542965
0
== Delete Entry Expects a connection resource object, along with a .dn method that returns the Distinguished Name of the entry to be deleted.
def delete_entry( c, dn ) # :yields: connection_info, distinguished_name self.bind( c.host, c.port, c.credentials, c.databag_name, c.use_tls ) unless @ldap @ldap.delete dn: dn raise "Unable to remove record: #{@ldap.get_operation_result.message}" unless @ldap.get_operation_result.message =~ /(Succe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(dn)\n @conn.delete :dn => dn\n end", "def delete(dn)\n log_dispatch(:delete, dn)\n adapter.delete(dn)\n end", "def delete_entry(entry)\n @address_book.entries.delete(entry)\n puts \"#{entry.name} has been deleted\"\n end", "def destroy\n begin\n self.clas...
[ "0.7283597", "0.68367934", "0.68008673", "0.67022884", "0.6545504", "0.6452004", "0.63261557", "0.6283859", "0.5983127", "0.59383315", "0.5937805", "0.59077823", "0.5865994", "0.58384407", "0.5783325", "0.5737294", "0.5722508", "0.5717711", "0.570386", "0.56989276", "0.566451...
0.79056066
0
Dump data into a JSON formatted string
def dump(obj, max_bytes: 2**12, max_depth: 3) bytesize = 0 hash = obj.each_with_object({}) do |(k, v), acc| str = (k.to_json + v.to_json) items = acc.keys.size - 1 if bytesize + str.bytesize + items + ELLIPSIS.bytesize > max_bytes acc[k] = ELLIPSIS...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end", "def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n data.to_json + \"\\n\"\n end", "def json_out(data)\n content_type 'application/json', :charset => 'utf-8'\n ...
[ "0.7622262", "0.7622262", "0.7622262", "0.75341743", "0.74195427", "0.7172281", "0.70908517", "0.6977205", "0.6977205", "0.69614565", "0.69446486", "0.69425774", "0.68894756", "0.6823157", "0.67997605", "0.67718923", "0.6771829", "0.67412823", "0.6737895", "0.6725289", "0.669...
0.0
-1
You can add fixtures and/or initialization code here to make experimenting with your gem easier. You can also use a different console, if you like.
def client @client ||= Gamewisp::Client.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_console\n console\n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def main\n\n # test\n\n # Console.new\n console_start\n end", "de...
[ "0.6623186", "0.65358907", "0.65358907", "0.65358907", "0.65358907", "0.65358907", "0.65358907", "0.65358907", "0.65258735", "0.6423783", "0.6410113", "0.6410113", "0.6410113", "0.6410113", "0.6410113", "0.6410113", "0.6400091", "0.6400091", "0.6400091", "0.6400091", "0.64000...
0.0
-1
12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 385 = 2640. Find the difference between the sum of the squares of the first one hund...
def sum_of_square(range) range.inject(0) { |sum, i| sum + i**2 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_square_difference(num)\n 1.upto(num).sum**2 - 1.upto(num).reduce(0) { |total, n| total + n**2 }\nend", "def sum_square_difference(num)\n square_of_sum = ((1..num).sum)**2\n sum_of_squares = (1..num).map { |n| n**2}.sum\n square_of_sum - sum_of_squares\nend", "def sum_square_difference(num)\n squar...
[ "0.7811906", "0.7668373", "0.7664246", "0.7661506", "0.76431787", "0.7641731", "0.7632839", "0.7598747", "0.75828016", "0.7568321", "0.7551572", "0.75468403", "0.7542266", "0.7505301", "0.75040656", "0.743689", "0.7434244", "0.74255884", "0.7422579", "0.74223477", "0.7414717"...
0.0
-1
Set sendgrid category to email subject
def welcome_provider(user) @user = user @profile = user.profile sendgrid_category :stripe_connect_welcome_provider @show_logo = true subject = "You're all set to accept online payments on Kinstantly" mail to: user.email, subject: subject end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sendgrid_category category\n @sg_category = category\n end", "def set_SubjectCategory(value)\n set_input(\"SubjectCategory\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailSubject\", value)\n end", "def set_EmailSubject(value)\n set_input(\"EmailS...
[ "0.72636276", "0.65522796", "0.6377444", "0.6376773", "0.63184136", "0.6290704", "0.6259525", "0.625898", "0.6226775", "0.6215164", "0.61077064", "0.6078173", "0.5974807", "0.5974807", "0.5974807", "0.5974807", "0.5974807", "0.5974807", "0.5974807", "0.5974807", "0.59291524",...
0.0
-1
before_action :set_user, only: [:update] ,only:[:profile]
def profile p @user.as_json render json: @user.as_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_profile_edit\n\n\n end", "def edit_profile\n end", "def edit_profile\n \t@user = current_user\n end", "def update\n # @profile = Profile.find(profile_params[:id])\n @user = current_user\n @profile = @user.profile\n # @user.profile = @profile\n # redirect_to(profile_path)...
[ "0.789721", "0.76940334", "0.7626223", "0.75246626", "0.73746663", "0.7359051", "0.73206717", "0.73023605", "0.7262557", "0.72412753", "0.72296643", "0.72288847", "0.7222599", "0.72112167", "0.7207946", "0.72045183", "0.7193295", "0.7191214", "0.71895313", "0.713199", "0.7122...
0.0
-1
ensure that there are no votes referencing this post
def destroy_votes Vote.where(post_id: self.id).destroy_all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unvote!(post)\n votes.find_by(post_id: post.id).destroy\n end", "def has_votes?\n vote_count > 0\n end", "def clear_vote!(voteable)\n clear_vote(voteable)\n return true\n rescue\n return false\n end", "def ensure_not_referenced_by_any_expense\n raise \"Cannot delete ...
[ "0.64432395", "0.6361458", "0.63155955", "0.6271475", "0.62529933", "0.6182774", "0.61332995", "0.6085801", "0.6076617", "0.6062003", "0.59006333", "0.5894566", "0.5848834", "0.584272", "0.57691884", "0.575261", "0.5739186", "0.57267904", "0.571363", "0.5663623", "0.5659946",...
0.59981024
10
Procs vs. methods You can't pass methods to other methods, but you can pass procs to methods Methods can't return other methods, but they can return procs. Procs are objects, methods aren't
def do_self_importantly(some_proc) puts "Everybody just HOLD ON! I have something to do..." some_proc.call puts "Ok everyone, I'm done. Go on with what you were doing." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_Method_InstanceMethods_to_proc\n\t\tpass\n\tend", "def go\n a = Proc.new do \n puts 'Proc'\n\n return\n end\n\n methods(&a)\n\n puts 'end go'\nend", "def test\r\n puts \"Enter in methods\"\r\n p = Proc.new { p \"Entering proc\"; break }\r\n p.call\r\n p \"Existing methods\"\r\nen...
[ "0.6747757", "0.64880836", "0.6454937", "0.6437338", "0.63884526", "0.63388664", "0.63382596", "0.63094056", "0.62636656", "0.62457436", "0.6241719", "0.62269", "0.614704", "0.614704", "0.61166704", "0.6105994", "0.6104038", "0.6096777", "0.6072324", "0.607074", "0.6029219", ...
0.0
-1
add a student to the school by calling the add_student method and giving it an argument of the student's name and their grade You can't push an item into an array that is the value of a key that doesn't exist yet...
def add_student(student_name, grade) # roster[grade] = [] # ...first: create the new key and point it to an empty array roster[grade] ||= [] # add multiple students to a grade & add students to different grades using ||= roster[grade] << student_name # ...then: push the new value into that array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_student(school, new_student_name, new_student_grade, new_student_semester)\n school[:students].push(:name => new_student_name, \n :grade => new_student_grade, :semester => new_student_semester)\nend", "def add_student(student_name, student_grade)\n\t\tSCHOOL[:students] << {:name => student_name, :gr...
[ "0.88618064", "0.87271804", "0.8682114", "0.86343634", "0.8576702", "0.8544164", "0.85305893", "0.8526905", "0.8506872", "0.8501374", "0.8501222", "0.8491915", "0.84350276", "0.8427564", "0.84203774", "0.8417378", "0.84017414", "0.8355033", "0.8343341", "0.83103615", "0.82933...
0.85037917
9
sort the students in each grade alphabetically by name
def sort sorted_roster = {} # start with an empty hash roster.each do |grade, students| # for each key (grade) / value (students array) pair in roster hash sorted_roster[grade] = students.sort # arrange the students alphabetically within their array end return sorted_roster # return hash: sorte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort\n @roster.each do |grade, studen_name|\n studen_name.sort!\n end\n end", "def sort\n self.roster.each do |grade, students|\n students.sort!\n end\n self.roster\n end", "def alphabetical_list(students)\n sorted_array = students.sort_by {|person| person[:last_name].downcase}\n...
[ "0.7992486", "0.7468632", "0.74620163", "0.7276964", "0.7257774", "0.7257774", "0.7154111", "0.71498907", "0.71150535", "0.70866776", "0.7061759", "0.68353426", "0.68326634", "0.6828903", "0.680314", "0.65420014", "0.6515555", "0.6487491", "0.64787716", "0.6372604", "0.633022...
0.68986255
11
Just an idea, instead of localeStorage, saving the current project in Redis in a hash. Not implemented.
def cache(user) "#{user.id}_project" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_locale\n Thread.current[:\"localite:locale\"] || base\n end", "def translations_hash; end", "def current\n locale = I18n.locale\n @current ||=\n Rails.cache.fetch(\"languages/current/#{locale}\") do\n l = Language.find_by_group(locale)\n l ||= Language.english...
[ "0.5913796", "0.58742917", "0.57955784", "0.5696557", "0.56920224", "0.56034577", "0.5578434", "0.5498196", "0.54722613", "0.54700357", "0.5460152", "0.5426229", "0.53552544", "0.5337919", "0.5317755", "0.5310304", "0.5302839", "0.5284406", "0.5281995", "0.5275137", "0.526450...
0.5911733
1
record a page that contains this link
def add_page_from(page) @pages_from << page unless @pages_from.include?(page) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_page(page)\n\t\t\t\turl = page.uri.to_s\n\t\t\t\trecord(url, content: page.content)\n\t\t\tend", "def associate_page(page); end", "def store_page\n @stored_page = @crwlr.pages.create(:address => @url, :title => @page_title[0..200], :number_of_links => @links.size)\n if @parent_page\n @par...
[ "0.765677", "0.7186724", "0.66615486", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.6535963", "0.65091664", "0.65091664", "0.6499726", "0.6353338", "0.63053006", "0.6240896", ...
0.0
-1
follow redirects to get to the final uri as necessary
def actual_uri redirects_to or uri end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follow_redirections\n self.url = self.add_scheme(decoded_uri(self.url.strip))\n attempts = 0\n code = '301'\n path = []\n\n while attempts < 5 && %w(301 302).include?(code) && !path.include?(self.url)\n attempts += 1\n path << self.url\n response = self.request_media_url\n co...
[ "0.81358474", "0.81077385", "0.79131883", "0.78438246", "0.76555467", "0.75273144", "0.7353265", "0.7346001", "0.7236638", "0.7225533", "0.6997556", "0.6992243", "0.6979397", "0.6966184", "0.6862678", "0.68504125", "0.6730477", "0.667231", "0.6621946", "0.65637475", "0.647566...
0.6837485
16
record a page that contains this link
def add_page_from(page) pages_from << page unless pages_from.include?(page) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def record_page(page)\n\t\t\t\turl = page.uri.to_s\n\t\t\t\trecord(url, content: page.content)\n\t\t\tend", "def associate_page(page); end", "def store_page\n @stored_page = @crwlr.pages.create(:address => @url, :title => @page_title[0..200], :number_of_links => @links.size)\n if @parent_page\n @par...
[ "0.76575977", "0.71869576", "0.6662686", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.65359455", "0.651008", "0.651008", "0.65002435", "0.6353063", "0.63040876", "0...
0.0
-1
get the proxy that applies to this particular link on windows this requires dll interaction as it has richer proxy support and the proxy can be different for different links on unix this is always a common proxy for all links that is provided via an environment variable
def proxy return @proxy if @proxy return if not Utility.is_windows? handle = WinProxy.open(@@HTTP_header['User-Agent'], 1, nil, nil, 0) return @proxy if handle.null? options = WinProxy::Options.new options[:flags] = 1 options[:auto_detect_flags] = 2 options[:auto_logon]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_defined_proxy\n prime_proxy = ENV.select { |k,v| v if k =~ /http_proxy/i }.first\n if prime_proxy.nil?\n prime_proxy = ENV.select { |k,v| v if k =~ /all_proxy/i }.first\n end\n return nil if prime_proxy.nil?\n\n URI.parse(prime_proxy[1])\n end", "def find_http_proxy\n ...
[ "0.7688793", "0.757827", "0.75567734", "0.731487", "0.7279257", "0.6937296", "0.69084275", "0.6826845", "0.68028396", "0.6633162", "0.66265565", "0.65869397", "0.6566076", "0.6541223", "0.6510802", "0.6497136", "0.64904135", "0.6483316", "0.6384128", "0.6336637", "0.6336637",...
0.7373571
3
validates self and searches for new pages to validate
def validate(hydra, &on_complete) raise 'link has no queue to use' if not @queue puts "querying #{uri}" if @opts[:verbose] tries = 0 begin # request = Typhoeus::Request.new(uri.to_s, method: (@opts[:duplicate] ? :get : :method), auth_method: :auto, proxy_auth_method: :auto) opts =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_page_existence\n if page.blank?\n errors.add(:page_id, :invalid)\n return false\n end\n self.name = page['name']\n true\n end", "def scan_site!\n add_pages_for_scan!\n while @pages_for_scan.size > 0\n page = convert_to_valid @pages_for_scan.pop\n next u...
[ "0.65158445", "0.61410904", "0.6084954", "0.5912128", "0.5824427", "0.57929707", "0.5708629", "0.56867766", "0.5680132", "0.5664891", "0.56567043", "0.5653245", "0.56360173", "0.561327", "0.55930126", "0.55798876", "0.5569805", "0.5551614", "0.5549726", "0.5540649", "0.552429...
0.0
-1
handle the response from the link request
def process_response(response) content = response.body content_type = response.content_type if not content.empty? and content_type['html'] content.force_encoding('iso-8859-1') # all bytes are valid in iso-859-1, so this ensures the next line never throws an encoding exception, yet still allows...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_response(response); end", "def handle_response(response); end", "def handle_links(json) end", "def handle_response(response)\n case response\n when Net::HTTPRedirection\n options[:limit] -= 1\n self.path = response['location']\n @redirect = true\n ...
[ "0.6972669", "0.6972669", "0.66860217", "0.63975567", "0.6363958", "0.62960523", "0.6275297", "0.6185953", "0.61779183", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373", "0.6164373",...
0.6372328
4
XXX causes a huge spike in memory use. very dodgy and wrong anyway
def parse_javascript(content) i = 0 while m = content.match(/(['"])(.*?[^\\])\1/, i) str = $2 # TODO unescape this string, eg. \\ -> \, \" -> " new_uri = nil begin if str.start_with?('http:') or str.start_with?('https:') new_uri = URI.parse(str) elsif ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def memos; end", "def memos; end", "def big_bad; end", "def pausable; end", "def mem(*) end", "def memsize\n end", "def used?; end", "def garbage_collect\n end", "def garbage_collect\n end", "def private; end", "def nakayoshi_gc\n 4.times { GC.start(full_mark: false) }\n GC.compact\nend", ...
[ "0.68657255", "0.68657255", "0.6808195", "0.6198888", "0.6138034", "0.6066464", "0.60321605", "0.5994822", "0.5994822", "0.59879124", "0.5928295", "0.58783036", "0.58734006", "0.5852445", "0.58475345", "0.5808522", "0.5776025", "0.5776025", "0.5754171", "0.57425886", "0.57425...
0.0
-1
save the content of the link, attempting to replace the links in the content to local references
def duplicate(content_type, content) # TODO process CSS as well if content_type['html'] Nokogiri.parse(content).search('@src', '@href').each {|attr| new_uri = parse_uri(attr.content.strip, base, uri) attr.content = uri_to_filename(new_uri.route_from(uri)).gsub(' ', '%20') if Link...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_references_html\r\n fixup_page\r\n html = display_content\r\n includes = find_includes(html)\r\n page_names = find_referenced_names(html)\r\n save_references(page_names, includes)\r\n end", "def save_file path, content\n\t\t\t\tif @fix\n\t\t\t\t\tcontent = content.gsub \"url('/\", \"ur...
[ "0.6567425", "0.65585786", "0.6447391", "0.62871224", "0.6237766", "0.6236621", "0.6172117", "0.6146743", "0.6080767", "0.5930058", "0.58878714", "0.5820214", "0.57773566", "0.57765585", "0.57738966", "0.5754886", "0.57368857", "0.57165253", "0.5712843", "0.5709101", "0.57053...
0.0
-1
XXX this hasn't been tested thoroughly. most likely does the wrong thing for at least some inputs TODO should maintain a table of uri > path mappings for anything that gets changed or truncated so that we can choose unique paths when there is a collision. then all uris will be mapped uniquely and correctly
def uri_to_filename(uri, abspath = false) filename = File.join($aliases[0], (uri.path[-1] == '/' ? uri.path + 'index.html' : uri.path).gsub(/[:*?"<>|]/, '_')) filename = File.join(Dir.pwd, filename) if abspath filename = File.join(filename, 'index.html') if File.directory?(filename) filename += ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_uri(*strs)\n new_str = strs * '/'\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\n new_str\n end", "def update_duplicate_uri\n # Checking if multiple content are present with the same uri the updating the uri\n duplicate_entries = Content.where(:uri=>self.uri...
[ "0.6556938", "0.63961816", "0.63835734", "0.62619084", "0.6094695", "0.6094695", "0.6003296", "0.5844179", "0.5820089", "0.57403195", "0.56830937", "0.5653757", "0.56386137", "0.5622774", "0.5588163", "0.5544093", "0.5544093", "0.54867285", "0.54861665", "0.54801816", "0.5473...
0.0
-1
get or prompt for a given proxy's username and password
def proxy_userpass(proxies = [proxy[0]]) proxies = [proxies] if proxies.class != Array proxies.map! {|p| p.downcase } userpass = (@@proxy_userpass[proxies[0]] || LinkToLoad.ask_for_userpass('proxy')) proxies.each {|p| @@proxy_userpass[p] = userpass } userpass end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_password(username)\n password = ask(\"password for #{username}:\") { |q| q.echo = false }\n password\nend", "def get_password host,username\n print \"Password for \"+username+\"@\"+host+\": \"\n system \"stty -echo\"\n pw = gets.delete(\"\\n\")\n system \"stty echo\"\n puts\n ...
[ "0.67717135", "0.65416163", "0.6259683", "0.6256776", "0.6227258", "0.6202245", "0.6157576", "0.6105552", "0.6069566", "0.60599804", "0.604003", "0.6004663", "0.5964904", "0.594268", "0.5939773", "0.5936331", "0.5922371", "0.59126276", "0.58866394", "0.5868141", "0.5863001", ...
0.6311824
2
pisspoor matching but the alternative is complex and this is good enough for error pages
def match_javascript_refresh(line) line =~ /window.location\s*=\s*(["'].*)$/i ? "#{$1.sub(/\/\/.*$/, "").sub(/\s*-->.*$/, "").sub(/\s*<\/script>.*$/, "")} [javascript]" : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_match() end", "def match(p0) end", "def match(p0) end", "def match(pattern); end", "def test_match \n begin\n md = @regexp =~ @s\n puts \"\\n#{regexp} =~ #{@s} yields #{@regexp =~ @s} and $~=#{$~.inspect}\"\n\n rescue => e\n $stderr.print e.message \n $stderr.print e....
[ "0.7090835", "0.689698", "0.689698", "0.6860065", "0.6725951", "0.667814", "0.65287334", "0.65287334", "0.6453381", "0.6416772", "0.6385208", "0.6317937", "0.6317707", "0.6317707", "0.61786884", "0.6158108", "0.60969377", "0.60914445", "0.60631156", "0.60631156", "0.59785265"...
0.0
-1
turn a href into an absolute path
def make_path(base, href) return href if href[0] == '/' base + href end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expand_path(href)\n return href if href.match(/^https*:\\/\\//) # if starts with protocol complete link\n return @request_href unless href.match(/[a-zA-Z0-9]+/) # rejects href=\"#\" and allows non-unique exception handling.\n return @request_href if href.match(/#[a-zA-Z0-9]*$/)\n\n if href[0, 1] !=...
[ "0.74313325", "0.7259466", "0.7234768", "0.7195484", "0.71680987", "0.71527714", "0.7023498", "0.6959961", "0.6959891", "0.6949252", "0.69085574", "0.6827566", "0.6731841", "0.67244583", "0.671601", "0.6713233", "0.67031634", "0.66990775", "0.66528964", "0.6634661", "0.662463...
0.7278829
1
reduce any '../', './', and '//' in a path or uri
def reduce_path(path) if path =~ /^(https?:\/\/.+)(\/.*)/ prefix = $1 path = $2 relative = false else prefix = nil relative = path[0] != '/' end while path.sub!(/\/*[^\/]+\/+\.\./, ''); end while path.sub!(/\/+\.\/+/, '/'); end path = path[2.....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uri(path)\n s = File::expand_path(path).gsub(DIR, \"\").gsub(File::SEPARATOR, '/')\n return s == '' ? '/' : s\n end", "def normalize_path(url); end", "def normalize_path(url); end", "def normalize_uri(*strs)\n new_str = strs * \"/\"\n\n new_str = new_str.gsub!(\"//\", \"/\") while new_str.in...
[ "0.7050252", "0.6911172", "0.6911172", "0.68011254", "0.677133", "0.67306715", "0.6601699", "0.65985906", "0.65985906", "0.6590226", "0.6532023", "0.6532023", "0.6453584", "0.64493656", "0.6447845", "0.6432042", "0.64209706", "0.63909125", "0.6367975", "0.6360824", "0.6354751...
0.7364567
0
add a link to be processed
def add_uri(new_link, from = nil, recurse = true) return if not new_link uri = (new_link.class == LinkToLoad ? new_link.uri : new_link) link = to_validate[uri] || queued[uri] || validated[uri] || invalid[uri] if not link puts 'queueing ' + uri.to_s if @opts[:verbose] link = (ne...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_link(link)\n links << link\n end", "def add_link\n @bib.link.each do |l|\n case l.type&.downcase\n when \"doi\" then @item.doi = l.content\n when \"file\" then @item.file2 = l.content\n when \"src\" then @item.url = l.content\n end\n end\...
[ "0.7483394", "0.7205235", "0.70008266", "0.6883265", "0.68251795", "0.67953926", "0.67953926", "0.67707944", "0.67035586", "0.6687012", "0.66641146", "0.664809", "0.66434485", "0.66281384", "0.6623783", "0.6621798", "0.66100514", "0.6582565", "0.65666807", "0.6542367", "0.654...
0.6007093
78
grab the next link off the list
def queue_next begin link = to_validate.shift return if not link queued[link[0]] = link[1] link[1].validate(@hydra) { |error: nil| queued.delete(link[0]) if error then invalidate(link[1], error[:type], error[:msg]) else validated[link[0]] = link[1] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next\n perform_get(links.next, self.class)\n end", "def next_item\n return nil if @link == nil\n link.kernel.select {|item| item.rule == @rule}.first\n end", "def next_address\n list_entry[:next]\n end", "def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(ur...
[ "0.76924497", "0.7587537", "0.7422341", "0.7188903", "0.7188903", "0.71803594", "0.71423864", "0.71423864", "0.71327865", "0.71327865", "0.71327865", "0.71327865", "0.7115808", "0.7076858", "0.7075121", "0.7075121", "0.7075121", "0.7065827", "0.7035438", "0.69852316", "0.6985...
0.0
-1
move the given link off the main queue and onto the invalid queue
def invalidate(link, *args) queued.delete(link.uri) if not link.suspect inv = InvalidURI.new(link, *args) invalid[inv.uri] = inv elsif @opts[:verbose] puts 'questionable link invalidated: ' + link.uri.to_s end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def queue_next\n begin\n link = to_validate.shift\n return if not link\n\n queued[link[0]] = link[1]\n\n link[1].validate(@hydra) { |error: nil|\n queued.delete(link[0])\n\n if error then invalidate(link[1], error[:type], error[:msg])\n else validated[lin...
[ "0.6881409", "0.6479159", "0.6250727", "0.6175462", "0.6158869", "0.6153209", "0.60790294", "0.5987659", "0.597337", "0.59211755", "0.584882", "0.5823436", "0.57847935", "0.57847935", "0.5767391", "0.57355714", "0.57271713", "0.56752914", "0.5672765", "0.5657361", "0.5654901"...
0.524979
61
put a link back onto the queue
def unshift(link) if link validated.delete(link[0]) to_validate[link[0]] = link[1] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(link)\n @queue.add link\n end", "def shift()\n # If our ttl is zero, skip\n if @queue.length < 1\n return nil\n end\n # Get next from queue\n this = @queue.shift\n puts \"QUEUE ->: %3d %s\" % [this['ttl'], this['url']]\n # Do we already have this page?\n if ! @sto...
[ "0.73733264", "0.6955292", "0.6735756", "0.67130184", "0.66893166", "0.6653917", "0.6616847", "0.6616847", "0.6570856", "0.6567809", "0.6546701", "0.6546701", "0.6535376", "0.6522527", "0.65144753", "0.64977074", "0.6428081", "0.6401439", "0.63853294", "0.6369037", "0.6333765...
0.0
-1
indique le nombre de point de vie
def show_state puts "#{@name} a #{@life_points} de PV" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def points; end", "def points\n 1\n end", "def points\n -1\n end", "def position=(point); end", "def pos() end", "def pos() end", "def pos() end", "def pos() end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos\n end", ...
[ "0.7319244", "0.6943422", "0.6928855", "0.6703674", "0.6554638", "0.6554638", "0.6554638", "0.6554638", "0.6466883", "0.6466883", "0.6466883", "0.6466883", "0.6466883", "0.6466883", "0.6367322", "0.6367322", "0.6367322", "0.6361447", "0.6324097", "0.6324097", "0.6324097", "...
0.0
-1
Create an empty page with necessary assets for project +p+
def create_empty_page(p) cli.say 'Creating project page' FileUtils.mkdir_p(browse_file(p, '.')) %w[favicon-32.png style.css].each do |i| FileUtils.cp(template_file(i), browse_file(p, i)) end write_file(p, 'about.html') do build_from_template('about.html', citation: MiGA::MiGA.CITATION) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_project_page(p)\n # Redirect page\n write_file(p, '../index.html') { build_from_template('redirect.html') }\n\n # Summaries\n summaries = Dir[\"#{p.path}/*.tsv\"].map do |i|\n b = File.basename(i, '.tsv')\n generate_summary_page(i, p)\n \"<li><a href='s-#{b}.html'>#{format_n...
[ "0.702871", "0.67735654", "0.6353886", "0.6273523", "0.6258971", "0.6180119", "0.613617", "0.6118454", "0.6103431", "0.6102516", "0.6098231", "0.6093809", "0.6092664", "0.60811114", "0.60627323", "0.6057448", "0.6052244", "0.60504496", "0.6045839", "0.6034876", "0.59940636", ...
0.8454481
0
Create landing page for project +p+
def generate_project_page(p) # Redirect page write_file(p, '../index.html') { build_from_template('redirect.html') } # Summaries summaries = Dir["#{p.path}/*.tsv"].map do |i| b = File.basename(i, '.tsv') generate_summary_page(i, p) "<li><a href='s-#{b}.html'>#{format_name(b)}</a></li>...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_empty_page(p)\n cli.say 'Creating project page'\n FileUtils.mkdir_p(browse_file(p, '.'))\n %w[favicon-32.png style.css].each do |i|\n FileUtils.cp(template_file(i), browse_file(p, i))\n end\n write_file(p, 'about.html') do\n build_from_template('about.html', citation: MiGA::MiGA...
[ "0.7371354", "0.6664608", "0.6611665", "0.6508865", "0.6410716", "0.63955003", "0.6310804", "0.6294235", "0.6290953", "0.6285155", "0.6269014", "0.6267971", "0.62649435", "0.6193769", "0.6182318", "0.6173127", "0.6159468", "0.61482817", "0.61232287", "0.61231667", "0.6119241"...
0.77630687
0
Create page for the summary +path+ in project +p+
def generate_summary_page(path, p) b = File.basename(path, '.tsv') table = '<table class="table table-hover table-responsive">' File.open(path, 'r') do |fh| fh.each do |ln| r = ln.chomp.split("\t") if $. == 1 table += '<thead><tr>' + r.map { |i| "<th scope=col>#{f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_project_page(p)\n # Redirect page\n write_file(p, '../index.html') { build_from_template('redirect.html') }\n\n # Summaries\n summaries = Dir[\"#{p.path}/*.tsv\"].map do |i|\n b = File.basename(i, '.tsv')\n generate_summary_page(i, p)\n \"<li><a href='s-#{b}.html'>#{format_n...
[ "0.7484316", "0.6507673", "0.6498785", "0.63521224", "0.60548556", "0.59551257", "0.584933", "0.5718473", "0.5688941", "0.5640451", "0.5592488", "0.5543848", "0.5512932", "0.55012167", "0.5489683", "0.5489683", "0.5489683", "0.5489683", "0.5489683", "0.5489683", "0.5489683", ...
0.7636214
0
Create page for dataset +d+ within project +p+
def generate_dataset_page(p, d) data = { unmiga_name: d.name.unmiga_name, information: format_metadata(d), results: format_results(d) } write_file(p, "d_#{d.name}.html") do build_from_template('dataset.html', data) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_datasets_index(p)\n cli.say 'Creating index pages'\n data = format_dataset_index(p)\n data.each do |k, v|\n write_file(p, \"#{k}_datasets.html\") do\n v[:list] = 'None' if v[:list] == ''\n build_from_template(\n 'datasets.html',\n v.merge(:\"#{k}_datasets_...
[ "0.68037844", "0.64201796", "0.6405191", "0.6208129", "0.5913871", "0.5708373", "0.56997925", "0.5664465", "0.56394017", "0.5603932", "0.554942", "0.55379516", "0.55356014", "0.553241", "0.54918236", "0.5452057", "0.54436624", "0.54004836", "0.5386109", "0.5359547", "0.535954...
0.86693054
0
Create pages for reference and query dataset indexes
def generate_datasets_index(p) cli.say 'Creating index pages' data = format_dataset_index(p) data.each do |k, v| write_file(p, "#{k}_datasets.html") do v[:list] = 'None' if v[:list] == '' build_from_template( 'datasets.html', v.merge(:"#{k}_datasets_active" => 'acti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_indexes\n @first_page = first_page\n generate_index('index')\n generate_index('indexes')\n end", "def index_pages\n debug_msg \" generating pages search index\"\n\n pages = @files.select do |file|\n file.text?\n end\n\n pages.each do |page|\n debug_msg \" #{page.p...
[ "0.7581115", "0.7085274", "0.69342494", "0.66503674", "0.6550457", "0.6513609", "0.6435873", "0.63384014", "0.63214314", "0.628524", "0.6247826", "0.62302375", "0.6215779", "0.6195686", "0.6191556", "0.61650985", "0.6163107", "0.6147718", "0.61047316", "0.60825545", "0.607092...
0.73654836
1
Format +obj+ metadata as a table
def format_metadata(obj) '<table class="table table-sm table-responsive">' + obj.metadata.data.map do |k, v| case k when /^run_/, :plugins, :user next when :web_assembly_gz v = "<a href='#{v}'>#{v[0..50]}...</a>" when :datasets v = v.size e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def table_row(obj, out_mode, depth)\n row = []\n variables = out_mode == :full ? obj.class::FIELDS_FULL : obj.class::FIELDS_SUMMARY\n variables.each do |var|\n val = obj.instance_variable_get(\"@#{var}\")\n val = val[0..32] if out_mode == :summary # Shorten data for summary -...
[ "0.63745046", "0.6241079", "0.62046194", "0.5997506", "0.5989809", "0.59521073", "0.5918139", "0.58749056", "0.58509296", "0.5800575", "0.578684", "0.578684", "0.5783817", "0.5769742", "0.57531536", "0.574793", "0.57232594", "0.5713948", "0.5704228", "0.56967455", "0.5633141"...
0.7606932
0
Format +obj+ results as cards
def format_results(obj) o = '' obj.each_result do |key, res| links = format_result_links(res) stats = format_result_stats(res) next unless links || stats name = format_name(key) url_doc = 'http://manual.microbial-genomes.org/part5/workflow#' + key.to_s.tr('_', '-') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_result(obj)\n formatted_str = \"\\n\\nSearch Results: \\n\\n\"\n obj.each do |key, value|\n unless key == \"_id\"\n\t key_str = key.capitalize\n\t if value.kind_of?(Array)\n\t\t \tformatted_str << key_str << \": \"\n\t\t \tvalue.each do |var|\n\t\t \t\tformatted_str << var.to_s << ((v...
[ "0.64820445", "0.6226193", "0.5886291", "0.5849091", "0.58358157", "0.5789512", "0.5777686", "0.5776829", "0.5770966", "0.5745876", "0.5724106", "0.57017106", "0.56891537", "0.56819046", "0.5678904", "0.56606877", "0.56455904", "0.5630276", "0.56124246", "0.56106174", "0.5596...
0.77843404
0
Write +file+ within the browse folder of project +p+ using the passed block output as content
def write_file(p, file) File.open(browse_file(p, file), 'w') { |fh| fh.print yield } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(block)\n @filemgr.write(block, @contents)\n end", "def output(file, &block)\n @outfile = File.expand_path(file)\n @block = block\n self\n end", "def write_to(file_name, &block)\n file = File.new(file_name, \"w\")\n file.write \"---\\n\"\n yield(file) if block_given?\n file...
[ "0.66409993", "0.6551999", "0.6197935", "0.61722183", "0.61622196", "0.6113944", "0.6112693", "0.6066088", "0.60583067", "0.59728247", "0.5966772", "0.59273505", "0.59130883", "0.59073776", "0.58719283", "0.5867446", "0.58516586", "0.58434427", "0.5830314", "0.58273727", "0.5...
0.7643977
0
Use a +template+ file to generate content with a hash of +data+ over the layout page if +layout+ is true
def build_from_template(template, data = {}, layout = true) cont = File.read(template_file(template)).miga_variables(data) return cont unless layout build_from_template( 'layout.html', data.merge(content: cont, project_name: cli.load_project.name), false ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mustache(template, args={}, layout=true)\n args = args.update(:site => site, :site_tags => tags, :current_user => current_user)\n layout_class = UserApp::Views::Layout\n layout_class.template = design.layout\n view_class = UserApp::Views.const_get(template.to_s.classify)\n vi...
[ "0.6997361", "0.67198944", "0.67088735", "0.6704546", "0.66211927", "0.6575901", "0.647485", "0.639517", "0.6370739", "0.6320471", "0.629727", "0.62776285", "0.62680995", "0.623344", "0.62254375", "0.62193334", "0.6199515", "0.6190676", "0.6162726", "0.61603975", "0.61348367"...
0.73471045
0
Path to the template browse file
def template_file(file) File.join( MiGA::MiGA.root_path, 'lib', 'miga', 'cli', 'action', 'browse', file ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_path\n File.expand_path('../templates', __FILE__)\n end", "def template_path\n File.expand_path(File.join(File.dirname(__FILE__), \"template.rb\"))\n end", "def full_path\n \"templates/#{filename}\"\n end", "def template_path\n \"#{template_dir}/#{template_name}\...
[ "0.7515096", "0.7345798", "0.72823894", "0.7268778", "0.72396916", "0.7000569", "0.6968479", "0.6914573", "0.69109267", "0.6904416", "0.6890691", "0.68772614", "0.6826309", "0.6808136", "0.6794476", "0.67501146", "0.6747688", "0.6718692", "0.66853267", "0.6671208", "0.6648840...
0.7424156
1
Path to the browse file in the project
def browse_file(p, file) File.join(p.path, 'browse', file) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path\n project\n end", "def code_browse path\n dr = ruby_renderer\n view(path, :close_key => 'q', :title => $0) do |t|\n t.renderer dr\n t.bind_key([?\\\\,?\\\\,?o],'choose file') { \n str = choose_file \"**/*\"\n if str and str != \"\"\n t.add_conten...
[ "0.66099113", "0.63447005", "0.6344689", "0.63362616", "0.63069445", "0.62917894", "0.6266471", "0.62566894", "0.62329155", "0.62251616", "0.62099624", "0.6183693", "0.6176807", "0.61586636", "0.6128603", "0.6115792", "0.6110082", "0.61082464", "0.6090519", "0.60740787", "0.6...
0.7663598
0
control para before_destroy :control_sin_items_comprobantes
def control_sin_items_comprobantes if [detalles].any? {|detalle| detalle.any? } self.errors[:base] = "error que queres hacer?" return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @itemtipo.destroy\n\n head :no_content\n end", "def before_destroy\n items.each(&:destroy)\n permissions.each(&:destroy)\n comments.each(&:destroy)\n super\n end", "def destroy\n @item_acompanhamento.destroy\n respond_to do |format|\n format.html { redirect_to item_...
[ "0.7043247", "0.7038581", "0.6695523", "0.666312", "0.66605735", "0.66199595", "0.6593814", "0.65882796", "0.65862525", "0.6535487", "0.6525096", "0.65166366", "0.6495914", "0.6483524", "0.6465499", "0.6451895", "0.6445081", "0.6436919", "0.64357185", "0.6414452", "0.64034337...
0.0
-1
display add full set link
def add_full_set_link(form_builder) link_to_function 'Extra Full Set' do |page| form_builder.fields_for :equipment, Equipment.new, :child_index => 'NEW_RECORD' do |f| html = render(:partial => 'laptop', :locals => { :form => f }) page << "$('#equipment_list').append('#{escape_javascript(html)}...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def links; end", "def links; end", "def precinctsShowLink\n \"#{firstname} #{lastname}, #{office.name}\"\n end", "def fileset_link_markup(file_name, descr = nil)\n descr = \"View resource.\" if descr == nil\n\n link_markup = \"\"\n fileset = fileset(file_name)\n noid = fileset[\"noid\...
[ "0.6243538", "0.6243538", "0.6152521", "0.5977365", "0.5868611", "0.586806", "0.5857904", "0.5857329", "0.5838049", "0.57813776", "0.5776984", "0.57643837", "0.57371944", "0.57341295", "0.5717242", "0.56426245", "0.5606865", "0.559819", "0.557542", "0.557542", "0.5569722", ...
0.58607054
6
determine the future value of an investment of present_value with given interest rate over time periods number of periods (years) that the interest is cumulated rate the annual rate of return present_value the value at the start of the period compound_frequency number of compounds / period(year)
def future_value(rate,periods,present_value,compound_frequency = 1) compound_frequency = resolve_compound_frequency!(compound_frequency) if compound_frequency == :continuous return continuous_compound_fv(rate,periods,present_value) end future_value = present_value * (1+rate/compound_freq...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end", "def compound_return(periods,present_value,future_value)\n pv = present_value.to_d\n fv = future_value.to_d\n n = periods.to_d\n rate = ((fv / pv)**(1/n))-1\n end", "def future...
[ "0.7779788", "0.75517434", "0.7306679", "0.6672953", "0.65825135", "0.63988066", "0.6284648", "0.6245956", "0.6159949", "0.61575097", "0.60779995", "0.60768104", "0.6067823", "0.6065797", "0.60527045", "0.59514064", "0.5936478", "0.5902118", "0.5874436", "0.58550656", "0.5800...
0.80783045
0