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
GET /gifts/1 GET /gifts/1.xml
def show @gift = Gift.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @gift } format.json { render :layout => false, :json => @gift.to_json } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @gifts = current_host.gifts\n end", "def show\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @indexed_gif }\n end\n end", "def show\n @tag = Tag.find(params[:id])\n @gifs = @tag.getGif...
[ "0.6863615", "0.6595635", "0.6563485", "0.6487047", "0.6266359", "0.6160782", "0.6160782", "0.6150649", "0.6147858", "0.61192554", "0.61192554", "0.61090267", "0.6100445", "0.6100445", "0.6100445", "0.6100445", "0.6100445", "0.60973257", "0.58278924", "0.5814098", "0.57243335...
0.0
-1
GET /gifts/new GET /gifts/new.xml
def new @gift = Gift.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @gift } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n # Add second slash to url that rails routing eats\n url = request.fullpath.gsub(/\\/http(s?)\\:/, 'http:/')\n\n gif = Gif.find_or_initialize_by(url: url){|g| g.remote_gif_url = url}\n\n if gif.new_record? && gif.save\n load_index_data\n flash.now[:success] = thumb_flash(gif, \"Creat...
[ "0.69246763", "0.6854227", "0.63873047", "0.63285905", "0.62631756", "0.6238503", "0.6180873", "0.6167866", "0.6145787", "0.6145787", "0.6131883", "0.61310136", "0.6106022", "0.60948694", "0.60822564", "0.6079595", "0.60792994", "0.6073825", "0.60673827", "0.6059845", "0.6058...
0.6123608
12
POST /gifts POST /gifts.xml
def create @user = current_user @gift = @user.gifts.create(params[:gift]) respond_to do |format| if @gift.save flash[:notice] = 'Gift idea was successfully added.' #format.html { redirect_to :action => :index } format.html { render :partial => 'gift', :locals => { :gift => @gift } } format.xml { render :xml => @gift, :status => :created, :location => @gift } format.json { render :json => @gift.to_json, :status => :created } else format.json { render :json => @gift.to_json } format.html { render :action => "new" } format.xml { render :xml => @gift.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @gif = Gif.new(gif_params)\n @gif.avatar_remote_url(@gif.url)\n @gif.approved = false\n @gif.deleted = false\n @gif.upvotes = 0\n @gif.downvotes = 0\n @gif.ratio = 0\n @gif.views = 0\n\n respond_to do |format|\n if @gif.save\n format.html { redirect_to @gif, noti...
[ "0.6623407", "0.64636165", "0.6253868", "0.62518555", "0.6072979", "0.6064172", "0.59968555", "0.5976434", "0.59526384", "0.5950958", "0.5943235", "0.5844419", "0.5771671", "0.5771671", "0.5771671", "0.5771671", "0.5771671", "0.5767186", "0.5713671", "0.56062675", "0.55512667...
0.510715
44
PUT /gifts/1 PUT /gifts/1.xml
def update @gift = Gift.find(params[:id]) respond_to do |format| if @gift.update_attributes(params[:gift]) flash[:notice] = 'Gift was successfully updated.' format.html { redirect_to(@gift) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @gift.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @indexed_gif = IndexedGif.find(params[:id])\n\n respond_to do |format|\n if @indexed_gif.update_attributes(params[:indexed_gif])\n format.html { redirect_to @indexed_gif, notice: 'Indexed gif was successfully updated.' }\n format.json { head :no_content }\n else\n ...
[ "0.65804076", "0.62795484", "0.61840004", "0.60494983", "0.60494983", "0.60494983", "0.60494983", "0.60494983", "0.6016912", "0.5980135", "0.5884269", "0.57653874", "0.57609326", "0.5712998", "0.5695316", "0.55285156", "0.55110425", "0.5485869", "0.5466479", "0.5464026", "0.5...
0.5362907
29
DELETE /gifts/1 DELETE /gifts/1.xml
def destroy @gift = Gift.find(params[:id]) @gift.destroy respond_to do |format| format.html { redirect_to(:action => :index) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @indexed_gif = IndexedGif.find(params[:id])\n @indexed_gif.destroy\n\n respond_to do |format|\n format.html { redirect_to indexed_gifs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gif.destroy\n respond_to do |format|\n format.html { redire...
[ "0.6930396", "0.68820477", "0.656696", "0.65352404", "0.6352554", "0.6331118", "0.6320864", "0.62355936", "0.62319374", "0.61706966", "0.6152128", "0.6144117", "0.6138728", "0.61348796", "0.6134773", "0.60982907", "0.6088722", "0.60817313", "0.6077572", "0.60680246", "0.60587...
0.5990248
35
Public: Adds a Line and returns it. Also sets the parent on the line and for simplicity adds the current_line number. Returns the line that was added.
def add_line(line) @lines << line line end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(context, line)\n\t\t\t@lines << @line.new(context, line)\n\t\tend", "def add_line\n @layout.add_widget(HLine.new)\n end", "def add_line(line)\n\t\t@lines << line\n\tend", "def append_line(line)\n @lines.push(line)\n @current = false\n @current_pos = 0\n end", "def line...
[ "0.6668727", "0.6592262", "0.6482159", "0.64409804", "0.6272245", "0.6220798", "0.620202", "0.61966985", "0.6170827", "0.6003752", "0.5966348", "0.592102", "0.59197515", "0.590428", "0.5867356", "0.5836515", "0.5802996", "0.5754109", "0.5743829", "0.57004714", "0.5695685", ...
0.67920893
0
Internal: Given an array of parsed blocks, converts the properties within the blocks into a single hash. Returns a hash.
def blocks_to_hash(blocks) blocks.each_with_object({}) do |block, hash| hash.merge!(block.to_hash) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_h(&block)\n if block_given?\n @properties.each_with_object({}) do |(key, val), acc|\n k, v = *block.(key, val)\n acc[k] = v\n end\n else\n DeepDup.deep_dup(@properties)\n end\n end", "def json_adjustments\n @blockss.each do |r...
[ "0.6046544", "0.55548185", "0.54865503", "0.5469761", "0.546405", "0.54541075", "0.5424585", "0.5415328", "0.5398357", "0.53873974", "0.53280497", "0.53262925", "0.52941555", "0.5293148", "0.52784747", "0.5266053", "0.5253693", "0.5234994", "0.5224278", "0.5202144", "0.520202...
0.73259133
0
FIXME: belongs to Blog engine
def full_permalink raise "can not create full_permalink for an article that belongs to a non-blog section" unless section.is_a? Blog # raise "can not create full_permalink for an unpublished article" unless published? date = [:year, :month, :day].map { |key| [key, (published? ? published_at : created_at).send(key)] }.flatten Hash[:permalink, permalink, *date] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blog\n object._blog\n end", "def blog(which_blog)\n blog_object\n end", "def posts; end", "def scraper\n blog.scraper\n end", "def index\n #binding.pry\n #@blogs = Blog.new_first\n @blogs = Blog.new_first.page(params[:page]).per(5)\n #byebug\n #@blogs = Blog.featured_blog...
[ "0.6993421", "0.6791575", "0.6632702", "0.6337447", "0.60823256", "0.6058488", "0.60539734", "0.60349554", "0.60349554", "0.5976926", "0.5976926", "0.5976534", "0.5976534", "0.5949663", "0.5939723", "0.59332806", "0.59308183", "0.59299666", "0.5924941", "0.5916103", "0.590197...
0.0
-1
Write encoded record to the handle
def write(record) @fh.puts(encode(record)) self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(record)\n @fh.write(MARC::Writer.encode(record))\n end", "def record_write bytes\n @reader.record_write bytes, @state\n end", "def write(record)\n @writer.write(MARC::XMLWriter.encode(record), @fh)\n @fh.write(\"\\n\")\n end", "def write(record)\n @writer.write(M...
[ "0.7382807", "0.7094003", "0.6921319", "0.6921319", "0.68935287", "0.67133904", "0.6448053", "0.63763046", "0.6352201", "0.63295764", "0.63295764", "0.63295764", "0.63295764", "0.62227345", "0.6185086", "0.6112052", "0.6030467", "0.6030467", "0.6028497", "0.6021128", "0.59768...
0.7957822
0
Esto es un atributo virtual.
def edad hoy = Date.today hoy.year - fecha_de_nacimiento.year - ((hoy.month > fecha_de_nacimiento.month || (hoy.month == fecha_de_nacimiento.month && hoy.day >= fecha_de_nacimiento.day)) ? 0 : 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr; end", "def override\n attributes.override\n end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def attribute; end", "def virtual; end", "def attributes(_record)\n raise 'Abstract method ...
[ "0.7080885", "0.70752454", "0.6895608", "0.6895608", "0.6895608", "0.6895608", "0.6895608", "0.6895608", "0.6895608", "0.68803865", "0.6640529", "0.6617597", "0.66158897", "0.66158897", "0.66158897", "0.66158897", "0.66158897", "0.66158897", "0.66158897", "0.66158897", "0.661...
0.0
-1
combine bishop and rook for queen moves
def bishop_moves(x, y, game) own_spaces = game[game[:turn]].keys opponent_spaces = game[@opp_turn[game[:turn]]].keys moves = [] # up right temp_x = x + 1 temp_y = y + 1 while temp_x < 5 && temp_y < 5 && !own_spaces.include?([temp_x, temp_y]) moves.push([temp_x, temp_y]) break if opponent_spaces.include?([temp_x, temp_y]) temp_x += 1 temp_y += 1 end # up left temp_x = x - 1 temp_y = y + 1 while temp_x > 0 && temp_y < 5 && !own_spaces.include?([temp_x, temp_y]) moves.push([temp_x, temp_y]) break if opponent_spaces.include?([temp_x, temp_y]) temp_x -= 1 temp_y += 1 end # down right temp_x = x + 1 temp_y = y - 1 while temp_x < 5 && temp_y > 0 && !own_spaces.include?([temp_x, temp_y]) moves.push([temp_x, temp_y]) break if opponent_spaces.include?([temp_x, temp_y]) temp_x += 1 temp_y -= 1 end # down left temp_x = x - 1 temp_y = y - 1 while temp_x > 0 && temp_y > 0 && !own_spaces.include?([temp_x, temp_y]) moves.push([temp_x, temp_y]) break if opponent_spaces.include?([temp_x, temp_y]) temp_x -= 1 temp_y -= 1 end moves end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def moves_queen(color, a, b)\n\t\t_moves = []\n\t\t(continue_left(color, a, b)).each{|move| _moves << move}\n\t\t(continue_right(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up(color, a, b)).each{|move| _moves << move}\n\t\t(continue_down(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up_left...
[ "0.6793946", "0.6759593", "0.66348326", "0.63150096", "0.6277755", "0.62528765", "0.62267834", "0.61691153", "0.615425", "0.6122588", "0.6058275", "0.60339695", "0.6012107", "0.6009247", "0.59959733", "0.59870994", "0.59814507", "0.5959321", "0.5917923", "0.5909152", "0.58929...
0.6824487
0
move will be in format of [type, start, end] e.g. ["N", [1,1], [2,3]]
def make_move(game, move, turn) new_game = game.clone # remove piece from the board new_game[turn].delete(move[1]) # add it to the board in new position new_game[turn][move[2]] = move[0] # remove opponent's piece new_game[@opp_turn[turn]].delete(move[2]) # a move has been made, decrement the limit, switch the turns new_game[:limit] -= 1 new_game[:turn] = @opp_turn[turn] # record the move made new_game[:moves].push([turn, move]) return new_game end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_move(move)\n #Is this enough of a repetition for me to iterate? It seemed more\n #tedious for me to iterate in this situation\n from = [(8-(move[0][1].to_i)), ((\"a\"..\"h\").to_a.index(move[0][0]))]\n to = [(8-(move[1][1].to_i)), ((\"a\"..\"h\").to_a.index(move[1][0]))]\n [from, to]\n en...
[ "0.6621405", "0.6583248", "0.6370971", "0.626844", "0.6234827", "0.6213427", "0.61882627", "0.6156398", "0.61142164", "0.60907453", "0.6069991", "0.6069991", "0.6053732", "0.6040931", "0.6036183", "0.6024046", "0.6011319", "0.6011319", "0.60095996", "0.60095996", "0.6006472",...
0.0
-1
pull value of letter from index
def score(word) point_values_hash = point_values point_values(word) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get index\n @letters[index]\n end", "def char_at(index)\n self.to_array[index.to_i]\n end", "def char_at(index)\n self.to_array[index.to_i]\n #@word = TILE_VALUES[index]\n end", "def char_at(index)\n\tself.to_array[index.to_i]\n end", "def index_to_letter(index)\n alphabet_a...
[ "0.7765185", "0.735024", "0.73303735", "0.71796054", "0.71541905", "0.7127811", "0.7054758", "0.69439024", "0.6931822", "0.69289386", "0.68637824", "0.6779648", "0.6716979", "0.66540015", "0.6607392", "0.6531172", "0.6512586", "0.6456748", "0.6415772", "0.641529", "0.6389533"...
0.0
-1
need to order through the hash according to the assigned key in the point_values method hash
def point_values { "A"=>1, "B"=>3, "C"=>3, "D"=>2, "E"=>1, "F"=>4, "G"=>2, "H"=>4, "I"=>1, "J"=>8, "K"=>5, "L"=>1, "M"=>3, "N"=>1, "O"=>1, "P"=>3, "Q"=>10, "R"=>1, "S"=>1, "T"=>1, "U"=>1, "V"=>4, "W"=>4, "X"=>8, "Y"=>4, "Z"=>10 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ordered_values; end", "def hash\n @points.inject(0) { |sum, point| sum += point.x + point.y }\n end", "def move_points(hash)\n\n\t\tpoints = Hash.new\n\n\t\tgc_hash = hash.select { |k,v| k.to_s.include?('gc') }\n\t\toc_hash = gc_hash.select { |k,v| v.include?('OC') }\n\n\t\t# Calculate OC count to ...
[ "0.6455059", "0.64427334", "0.63348913", "0.6192054", "0.6153559", "0.6088921", "0.59997576", "0.59171265", "0.58849764", "0.58649707", "0.58617437", "0.58029777", "0.57773423", "0.57769984", "0.57769984", "0.5754508", "0.57528013", "0.5749163", "0.57380855", "0.5702592", "0....
0.6493413
1
multiply that value by the corresponding multiplier value, do an enumerable to cycle through array applying multiplier to each in the array using map
def multiply_word_with_letter_multiplier(word,letter_multiplier) local_array = score(word) local_array.map do |number| number * letter_multiplier end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiply_by(num,arr)\n arr.map do |x|\n x * num\n end\nend", "def multiply_by(array)\n return array.map { |el| el * 3}\nend", "def multiply(array,mult)\n array.map{|num| num*mult}\nend", "def multiply_each (array, product=1)\n array.each do |x|\n product *= x\n end\n return product\nend", ...
[ "0.77951574", "0.76585543", "0.7645251", "0.7509173", "0.7409304", "0.7376546", "0.73750705", "0.7367438", "0.72560304", "0.71724063", "0.7166922", "0.71196467", "0.7073315", "0.7044117", "0.70420086", "0.70188105", "0.70101374", "0.69665265", "0.69500333", "0.6941966", "0.68...
0.0
-1
sum it up, set summed array to a plus equals of that array plus the next number in the array
def sum local_array = multiply_word_with_letter_multiplier local_array.inject(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def summing_method\n @summed_array = @single_digit_array.sum\n end", "def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return...
[ "0.7631964", "0.76146305", "0.7520379", "0.7515969", "0.74783814", "0.7439132", "0.7411004", "0.7403761", "0.7395291", "0.73907554", "0.7353599", "0.73473287", "0.73310477", "0.73274606", "0.7296245", "0.7295351", "0.727139", "0.7268158", "0.7264415", "0.72617936", "0.7259751...
0.0
-1
multiply that sum by the provided 3rd argument multiplier
def multiply_sum_by_3rd_argument end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiply(*all_args)\n all_args.inject(1) { |sum, value| sum *= value}\nend", "def mult(*args)\n\tprod = 1\n\targs.each do |arg|\n\t\tprod *= arg\n\tend\n\tprod\nend", "def multiply(nums)\r\n nums.reduce(:*)\r\nend", "def multiply\n inject(1) { |p,x| p * x }\n end", "def mul!(*args)\n ...
[ "0.7444188", "0.7357048", "0.71049494", "0.70804065", "0.7065773", "0.7042493", "0.7042044", "0.70210147", "0.7015285", "0.69790494", "0.6963095", "0.69568056", "0.6918573", "0.6889177", "0.6886552", "0.6886552", "0.6879731", "0.68562347", "0.68267405", "0.6789354", "0.678407...
0.78995043
0
Catches when the user presses the get started button
def get_started intro_and_request_permissions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start\n\t\tself.sender.start\n\tend", "def on_start\n end", "def starting?; event(:start).pending? end", "def started?; end", "def did_start_up\n end", "def start\n restart\n update\n Tk.mainloop\n end", "def start\n @actions << :start\n end", "def start\n end", "def star...
[ "0.707153", "0.70216453", "0.68119097", "0.6781285", "0.6635531", "0.6622585", "0.6546701", "0.6542525", "0.6542525", "0.6542525", "0.6542525", "0.6542525", "0.6542525", "0.6542525", "0.6542525", "0.65326494", "0.6480295", "0.6480295", "0.6480295", "0.6480295", "0.6452129", ...
0.0
-1
gets a list of users
def all(params = {}) begin parse get nil, params rescue Exception => e [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n get('users')['users']\n end", "def list_users\n http_get(:uri=>\"/users\", :fields=>x_cookie)\n end", "def list\n response = @client.get(\"/users\")\n response[\"users\"].map {|u| User.new(@client, u) }\n end", "def list_users\n self.class.get('/users')\n e...
[ "0.8715094", "0.8551452", "0.84233564", "0.83502555", "0.8327375", "0.83068377", "0.82944286", "0.8275011", "0.8265321", "0.8231169", "0.8195651", "0.81913435", "0.8181365", "0.8154818", "0.81418914", "0.8085132", "0.80827063", "0.80827063", "0.807182", "0.807182", "0.8067732...
0.0
-1
directories and files from /home/account_name/www/project_name folder (using ex. FileZilla) but it left some folders with symlinks, such as: www ` project_name | current > /home/account_name/www/project_name/releases/20131014083207 ` releases | 20131014081055 | | log > /home/account_name/www/project_name/shared/log | | public | | ` system > /home/account_name/www/project_name/shared/system | ` tmp | ` pids > /home/account_name/www/project_name/shared/pids ` 20131014083207 | log > /home/account_name/www/project_name/shared/log | public | ` system > /home/account_name/www/project_name/shared/system ` tmp ` pids > /home/account_name/www/project_name/shared/pids Before run change change project_name and account_name variables below. Than connect to your alwaysdata account with ssh, copy this file wherever you want and run: ruby r './ad_cleanup.rb' e 'cleanup'
def cleanup # ---------------------------------------------- account_name = 'your account name' # <-- change this! project_name = 'your project name' # <-- change this! # ---------------------------------------------- project_dir = "/home/#{account_name}/www" Dir.chdir(project_dir) Dir.entries(project_name).select do |entry1| dir1 = File.join(project_name,entry1) #dir2 = "#{project_name}/#{entry1}" if is_directory?(dir1) Dir.entries(dir1).select do |entry2| dir2 = File.join(dir1,entry2) #dir2 = "#{project_name}/#{entry1}/#{entry2}" if is_directory?(dir2) Dir.entries(dir2).select do |entry3| dir3 = File.join(dir2,entry3) #dir3 = "#{project_name}/#{entry1}/#{entry2}/#{entry3}" if is_directory?(dir3) Dir.entries(dir3).select do |entry4| delete_file(File.join(dir3,entry4)) end end delete_file(dir3) delete_dir(dir3) end end delete_file(dir2) delete_dir(dir2) end end delete_file(dir1) delete_dir(dir1) end delete_dir(project_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tidy_up\n return if DEBUG\n\n puts heading(\"Tidying up PWD\")\n\n FileUtils.remove(Dir[\"#{FileUtils.pwd}/bugsnag-*.tgz\"])\nend", "def remove_dead_symlinks\n base_paths.each do |path|\n command = \"find #{path} -xtype l -delete\"\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, c...
[ "0.61604303", "0.609182", "0.5838239", "0.572081", "0.56477356", "0.5638157", "0.56050116", "0.5603893", "0.55922616", "0.5583106", "0.5523004", "0.552116", "0.5510005", "0.5510005", "0.5507161", "0.5504293", "0.54923385", "0.54508877", "0.5426518", "0.54211396", "0.5417211",...
0.7290133
0
Create an erased flash.
def createflashimage flashdata = "\xff" * FLASHSIZE Flashimage.write(flashdata) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flash_keeper\n flash.keep\n end", "def discard_flash\n flash.discard\n end", "def flash_destroyed_message\n flash_message_builder(:destroy, flash_status_type, 'destroyed')\n end", "def keep_flash\n @keep_flash = true\n end", "def scaffold_flash\n {}\n end",...
[ "0.63379157", "0.6034925", "0.6015594", "0.5983541", "0.5918129", "0.59143656", "0.58458066", "0.57976186", "0.5707702", "0.56664616", "0.56011134", "0.5503426", "0.54939735", "0.54881525", "0.544252", "0.544252", "0.5435931", "0.5394532", "0.5394523", "0.5362896", "0.5348555...
0.62776345
1
Split flash image in partitions.
def splitflashimage flashdata = Flashimage.read size = flashdata.size puts("Flash image size: #{size / MiB} MiB = #{size} B.") raise('Flash size is unexpected.') if (size != FLASHSIZE) baseaddress = PARTITIONS['boot'][START] PARTITIONS.each { |label, partition| first = partition[START] - baseaddress last = first + partition[SIZE] filename = "#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}" Flashimage.write(flashdata[first ... last], filename) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mergepartitions\n\tflashdata = \"\\xff\" * FLASHSIZE\n\tbaseaddress = PARTITIONS['boot'][START]\n\tPARTITIONS.each { |label, partition|\n\t\tfirst = partition[START] - baseaddress\n\t\tlast = first + partition[SIZE]\n\t\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\t\tpartdata = Flashimage.r...
[ "0.690342", "0.59546083", "0.57812333", "0.57254237", "0.57205456", "0.5712888", "0.56876594", "0.5683673", "0.5644677", "0.56099576", "0.55600005", "0.54711246", "0.54664296", "0.54483944", "0.5411717", "0.5397295", "0.5254826", "0.5215175", "0.5200493", "0.5196441", "0.5172...
0.8141284
0
Make flash image from partitions.
def mergepartitions flashdata = "\xff" * FLASHSIZE baseaddress = PARTITIONS['boot'][START] PARTITIONS.each { |label, partition| first = partition[START] - baseaddress last = first + partition[SIZE] filename = "#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}" partdata = Flashimage.read(filename) size = partdata.size puts("Partition size: #{size / KiB} KiB = #{size} B (#{label}).") raise('Partition size is unexpected.') if (size != partition[SIZE]) flashdata[first ... last] = partdata } Flashimage.write(flashdata) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splitflashimage\n\tflashdata = Flashimage.read\n\tsize = flashdata.size\n\tputs(\"Flash image size: #{size / MiB} MiB = #{size} B.\")\n\traise('Flash size is unexpected.') if (size != FLASHSIZE)\n\tbaseaddress = PARTITIONS['boot'][START]\n\tPARTITIONS.each { |label, partition|\n\t\tfirst = partition[START] - b...
[ "0.68787396", "0.65255797", "0.641545", "0.62146753", "0.5831584", "0.57129085", "0.5710913", "0.5696141", "0.5632923", "0.5624845", "0.55377704", "0.5428235", "0.54141676", "0.5406065", "0.53421277", "0.5280142", "0.5260895", "0.52310866", "0.5201961", "0.5164563", "0.510017...
0.68463033
1
Change partition (configuration, web or code).
def changepartition(partition, filename) baseaddress = PARTITIONS['boot'][START] size = partition[SIZE] partdata = Flashimage.read(filename) length = partdata.size last = partition[SIZE] raise('Input file too large.') if length + 12 > last crc32 = Zlib.crc32(partdata) partdata[length ... last - 12] = "\xff" * (last - length - 12) partdata[last - 12 ... last] = [length, 0x12345678, crc32].pack('V3') filename = "#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}" Flashimage.write(partdata, filename) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_partition\n @partition = Partition.find(params[:id])\n end", "def setPartitionType(settings)\n settings = deep_copy(settings)\n tm = Storage.GetTargetMap\n settings = Builtins.maplist(settings) do |d|\n if Ops.get_symbol(d, \"type\", :x) == :CT_DISK\n mp = Ops.get_integ...
[ "0.68011206", "0.6676938", "0.618568", "0.60967946", "0.60418004", "0.5999213", "0.59895533", "0.58191353", "0.57497066", "0.56553215", "0.5624845", "0.55776787", "0.5513125", "0.5506415", "0.54891264", "0.5467075", "0.545486", "0.5430396", "0.5425995", "0.54255795", "0.53947...
0.6723628
1
Load partition file (code, web or configuration).
def loadpart(partname, filename) flashimage = Flashimage.new firmware = Flashimage.read(filename) size = firmware.size offset_signature = size - 10 signature = firmware[offset_signature .. -1] puts("signature: #{signature.inspect}") length, magic, crc32, offset = getblock(partname, firmware, offset_signature) partition = Partition.new(partname) partition.update(firmware[offset ... offset + length]) flashimage.update(partition) flashimage.write end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(file_path); end", "def load(file_path); end", "def load(path); end", "def load_path; end", "def set_partition\n @partition = Partition.find(params[:id])\n end", "def load_path=(load_path); end", "def load\n @yaml_parts, @ruby_parts = lookup_parts\n @data.clear\n self.y...
[ "0.56779397", "0.56779397", "0.56776893", "0.5607713", "0.552809", "0.5422654", "0.5393423", "0.53713644", "0.53360283", "0.53193", "0.53123003", "0.5309336", "0.5309114", "0.5309114", "0.52840716", "0.5271817", "0.5270335", "0.5269269", "0.52681625", "0.52555305", "0.5233593...
0.6331081
0
Load firmware file (code and web).
def loadfw(filename) flashimage = Flashimage.new firmware = Flashimage.read(filename) size = firmware.size offset_signature = size - 10 signature = firmware[offset_signature .. -1] puts("signature: #{signature.inspect}") length, magic, crc32, offset_code = getblock('code', firmware, offset_signature) code = Partition.new('code') code.update(firmware[offset_code ... offset_code + length]) puts code.size length, magic, crc32, offset_web = getblock('web', firmware, offset_code) web = Partition.new('web') puts web.size web.update(firmware[offset_web ... offset_web + length]) flashimage.update(code) flashimage.update(web) flashimage.write end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_firmware\n ensure_client && ensure_uri\n response = @client.rest_get(@data['uri'] + '/firmware')\n @client.response_handler(response)\n end", "def load_file(path)\n load_string(File.binread(path))\n end", "def loadpart(partname, filename)\n\tflashimage = Fl...
[ "0.63007134", "0.6011472", "0.5928067", "0.5909968", "0.5909968", "0.58938366", "0.5889059", "0.5864592", "0.5854285", "0.5824867", "0.5769541", "0.5741391", "0.57156634", "0.56640905", "0.56462", "0.5618558", "0.5609447", "0.56001127", "0.55932903", "0.55932903", "0.55531216...
0.72785926
0
GET /boots/1 GET /boots/1.json
def show @boot = Boot.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @boot } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boot }\n end\n end", "def index\n info = Aws.get_recipes_from_db\n render :json => info\n end", "def show\n @boot = Boot.find(params[:id])\n\n respond_to do |format|...
[ "0.66913277", "0.62402487", "0.61105716", "0.59769744", "0.591952", "0.5876535", "0.5660398", "0.5596117", "0.55550104", "0.55473495", "0.55455303", "0.5509982", "0.5491295", "0.5486162", "0.5483385", "0.54735804", "0.5445544", "0.5432645", "0.5427404", "0.54243594", "0.54105...
0.75800765
0
GET /boots/new GET /boots/new.json
def new @boot = Boot.new respond_to do |format| format.html # new.html.erb format.json { render json: @boot } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boot }\n end\n end", "def new\n @newapp = Newapp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newapp }\n end\n en...
[ "0.7068447", "0.6764454", "0.6749742", "0.6606039", "0.6537489", "0.64620835", "0.64563084", "0.64284384", "0.64284384", "0.64284384", "0.64284384", "0.64284384", "0.636379", "0.63579077", "0.63579077", "0.63579077", "0.63579077", "0.63535166", "0.63530594", "0.6350001", "0.6...
0.81628734
0
POST /boots POST /boots.json
def create @boot = Boot.new(params[:boot]) puts "=================================================================" puts params[:boot] p @boot.bootlargeimage_file_name puts "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" respond_to do |format| if @boot.save flash[:success] = "Boot was successfully created" format.html { redirect_to boots_path, notice: 'Boot was successfully created.' } format.json { render json: boots_path, status: :created, location: @boot } else format.html { render action: "new" } format.json { render json: @boot.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @testboot = Testboot.new(testboot_params)\n\n respond_to do |format|\n if @testboot.save\n format.html { redirect_to @testboot, notice: 'Testboot was successfully created.' }\n format.json { render :show, status: :created, location: @testboot }\n else\n format.html...
[ "0.6742345", "0.6466418", "0.6065044", "0.6004548", "0.5919822", "0.56240284", "0.56207764", "0.5488821", "0.5426072", "0.54159385", "0.5402109", "0.538391", "0.53199", "0.525922", "0.5255671", "0.52223134", "0.51395017", "0.5122044", "0.5095216", "0.50821424", "0.50764984", ...
0.6190524
2
PUT /boots/1 PUT /boots/1.json
def update @boot = Boot.find(params[:id]) respond_to do |format| if @boot.update_attributes(params[:boot]) flash[:success] = "Updated successfully " format.html { redirect_to boots_path, notice: 'Boot was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @boot.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @boot = Boot.find(params[:id])\n\n respond_to do |format|\n if @boot.update_attributes(params[:boot])\n flash[:notice] = 'Boot was successfully updated.'\n format.html { redirect_to(@boot) }\n format.xml { head :ok }\n else\n format.html { render :action =>...
[ "0.6424908", "0.61105126", "0.5636898", "0.56145096", "0.5521343", "0.5443643", "0.5434995", "0.5411755", "0.5400058", "0.53812206", "0.5359651", "0.5345468", "0.53138494", "0.52571774", "0.52571774", "0.52345127", "0.52269644", "0.5200251", "0.51425636", "0.51385486", "0.511...
0.6826857
0
DELETE /boots/1 DELETE /boots/1.json
def destroy @boot = Boot.find(params[:id]) @boot.destroy respond_to do |format| flash[:success] = "Deleted successfully " format.html { redirect_to boots_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n respond_to do |format|\n format.html { redirect_to(boots_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @testboot.destroy\n respond_to do |format|\n format.html { redirect_to testboots_url, notice: ...
[ "0.74450946", "0.69838065", "0.6720092", "0.65074015", "0.6457982", "0.64458597", "0.64412314", "0.64234084", "0.6423225", "0.6412931", "0.6346784", "0.6346784", "0.6346784", "0.6346784", "0.63379455", "0.6324339", "0.63220555", "0.630647", "0.630647", "0.62963164", "0.629607...
0.7643134
0
GET /daw_promos GET /daw_promos.json
def index @daw_promos = DawPromo.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @promocion }\n end\n end", "def index\n @daw_matricula_promos = DawMatriculaPromo.all\n end", "def show\n @pdevice = Pdevice.find(params[:id])...
[ "0.6421152", "0.62996143", "0.6150884", "0.6138804", "0.6123474", "0.6080514", "0.60380435", "0.59345794", "0.5912635", "0.5878894", "0.5827744", "0.5813213", "0.58032966", "0.5799405", "0.57931346", "0.57843083", "0.57540596", "0.57470965", "0.57324034", "0.57320577", "0.571...
0.67679787
0
GET /daw_promos/1 GET /daw_promos/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @promocion }\n end\n end", "def index\n @daw_promos = DawPromo.all\n end", "def show\n @pdevice = Pdevice.find(params[:id])\n\n respond_to ...
[ "0.6606121", "0.6514304", "0.640169", "0.6317443", "0.6274082", "0.61593235", "0.6122043", "0.6120167", "0.61056894", "0.609848", "0.6025202", "0.6003655", "0.59652865", "0.5956525", "0.5950266", "0.59340936", "0.5903782", "0.58972895", "0.58915377", "0.5888215", "0.58862895"...
0.0
-1
POST /daw_promos POST /daw_promos.json
def create @daw_promo = DawPromo.new(daw_promo_params) respond_to do |format| if @daw_promo.save format.html { redirect_to @daw_promo, notice: 'Daw promo was successfully created.' } format.json { render :show, status: :created, location: @daw_promo } else format.html { render :new } format.json { render json: @daw_promo.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n megam_rest.post_promos(to_hash) #WONT BE USED AS OF NOW\n end", "def create\n @daw_matricula_promo = DawMatriculaPromo.new(daw_matricula_promo_params)\n\n respond_to do |format|\n if @daw_matricula_promo.save\n format.html { redirect_to @daw_matricula_promo, notice: 'Daw ma...
[ "0.7214397", "0.6106348", "0.5992868", "0.5981123", "0.5788211", "0.57550657", "0.5698611", "0.5653004", "0.5481892", "0.5480644", "0.5477", "0.54521966", "0.54376364", "0.5414071", "0.5412733", "0.540968", "0.5398997", "0.53984874", "0.53982407", "0.53896254", "0.5343505", ...
0.6368797
1
PATCH/PUT /daw_promos/1 PATCH/PUT /daw_promos/1.json
def update respond_to do |format| if @daw_promo.update(daw_promo_params) format.html { redirect_to @daw_promo, notice: 'Daw promo was successfully updated.' } format.json { render :show, status: :ok, location: @daw_promo } else format.html { render :edit } format.json { render json: @daw_promo.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n if @promos.update_attributes(params[:promos])\n flash[:notice] = 'Promos was successfully updated.'\n format.html { redirect_to(@promos) }\n format.xml { head :ok }\n else\n format.html { rende...
[ "0.6426635", "0.6289894", "0.6176794", "0.6118892", "0.6061302", "0.60556245", "0.60500866", "0.6033528", "0.5984155", "0.59552926", "0.5940345", "0.5928201", "0.59210974", "0.59179556", "0.59135354", "0.5909171", "0.5852612", "0.5831549", "0.5829486", "0.5825716", "0.5823297...
0.58440816
17
DELETE /daw_promos/1 DELETE /daw_promos/1.json
def destroy @daw_promo.destroy respond_to do |format| format.html { redirect_to daw_promos_url, notice: 'Daw promo was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", ...
[ "0.68476886", "0.6831857", "0.6782474", "0.6763007", "0.6687799", "0.6687799", "0.6661607", "0.66362584", "0.6619438", "0.65782565", "0.6578152", "0.65766793", "0.65715885", "0.65598637", "0.6545403", "0.65070486", "0.6481814", "0.6478965", "0.6478949", "0.6478642", "0.647823...
0.66795
6
Use callbacks to share common setup or constraints between actions.
def set_daw_promo @daw_promo = DawPromo.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def daw_promo_params params.require(:daw_promo).permit(:pro_nombre, :pro_porcentaje, :pro_fechaini, :pro_fechafin, :pro_tipopromocion, :pro_estado, :daw_alianza_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.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
VIEW_ID = "222861936" initialize
def initialize() @view_id = VIEW_ID @analytics = Google::Apis::AnalyticsreportingV4 auth end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_view\n \t#puts \"#{controller_name}.define_view:begin view=#{@myparams[:view_id]}\"\n \t# views: liste des vues possibles est utilisee dans la view ruby show\n\t\t@views = View.all\n\t\t# view_id: id de la vue selectionnee est utilisee dans la view ruby show\n\t\t#@myparams[:view_id] = @views.first.id...
[ "0.6556202", "0.65433985", "0.6481879", "0.6463633", "0.6451928", "0.6407291", "0.6404822", "0.63247037", "0.625735", "0.6242812", "0.6194703", "0.59661794", "0.5916904", "0.5903193", "0.58999515", "0.5825491", "0.5814987", "0.58099526", "0.5806841", "0.5806045", "0.5806045",...
0.55849445
43
total data by selected period
def get_total_ga_info(startdate, enddate, hostname) puts 'totla data' set_total_by_date = Array.new formatted_startdate = DateTime.parse(startdate) formatted_enddate = DateTime.parse(enddate) # index 0 -> total data, index 1 -> data by date or hour current_arr = set_api_by_date(startdate, enddate, hostname) current_data = current_arr[0] current_linechart_data = current_arr[1] # get compare dates if startdate == enddate then compare_startdate = (formatted_startdate - 1.day).strftime("%Y-%m-%d") compare_enddate = (formatted_enddate - 1.day).strftime("%Y-%m-%d") else diff = (formatted_enddate - formatted_startdate).to_i + 1 compare_startdate = (formatted_startdate - diff.days).strftime("%Y-%m-%d") compare_enddate = (formatted_enddate - diff.days).strftime("%Y-%m-%d") end # index 0 -> total data, index 1 -> data by date or hour compare_arr = set_api_by_date(compare_startdate, compare_enddate, hostname) compare_data = compare_arr[0] compare_linechart_data = compare_arr[1] set_total_by_date.push(current_data) set_total_by_date.push(compare_data) set_total_by_date.push(current_linechart_data) set_total_by_date.push(compare_linechart_data) return set_total_by_date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_payments_data(period_data = 'this_month')\n res = payments.completed\n range, daily_report = period_data.to_s.report_period_to_range\n data = [[period_data.to_s.report_period_to_title, I18n.t('number.currency.format.unit')]]\n range.each{|d| data << [d.strftime(daily_report ? '%d' : '%Y-%m'),...
[ "0.71462023", "0.69259024", "0.6843798", "0.66862667", "0.66794366", "0.65194374", "0.65041906", "0.6476117", "0.6457001", "0.64241815", "0.6353831", "0.627408", "0.6240165", "0.6239664", "0.6222121", "0.6205127", "0.61658514", "0.6163508", "0.6150929", "0.61325055", "0.61213...
0.57223237
72
total data by dates
def set_api_by_date(startdate, enddate, hostname) # setup date range date_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate) # set metircs data. 10 metrices are allowed per one request metrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions', 'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions' ] # make new array and put metric type data in the array metric_type = Array.new metrics.each do |m| metric = @analytics::Metric.new metric.expression = m metric_type.push(metric) end # if startdate == enddate then # dimension = @analytics::Dimension.new(name: 'ga:hour') # order_by = @analytics::OrderBy.new(field_name: 'ga:hour', sort_order: 'ASCENDING') # else # dimension = @analytics::Dimension.new(name: 'ga:date') # order_by = @analytics::OrderBy.new(field_name: 'ga:date', sort_order: 'ASCENDING') # end # set dimensions, dimension_filters by hostname. if hostname is total, then set only hour or date in dimension if hostname == 'total' if startdate == enddate then dimensions = ['ga:hour'] else dimensions = ['ga:date'] end else if startdate == enddate then dimensions = ['ga:hour', 'ga:hostname'] else dimensions = ['ga:date', 'ga:hostname'] end dimension_filters = @analytics::DimensionFilterClause.new( filters: [ @analytics::DimensionFilter.new( dimension_name: 'ga:hostname', not: false, operator: "IN_LIST", expressions: [hostname] ) ] ) end dimension_type = Array.new dimensions.each do |d| dimension = @analytics::Dimension.new dimension.name = d dimension_type.push(dimension) end #set order_bys order_by = @analytics::OrderBy.new(field_name: dimensions[0], sort_order: 'ASCENDING') # setup request with the data i set up above to google analytics server request = @analytics::GetReportsRequest.new( report_requests: [@analytics::ReportRequest.new( view_id: @view_id, metrics: metric_type, dimensions: dimension_type, dimension_filter_clauses: [dimension_filters], date_ranges: [date_range], order_bys: [order_by] )] ) # send request and get the result in the response response = @client.batch_get_reports(request) # make new array for the total data. it will has datahash and dropdwnhash, datahash is for total data and # the other is for hourly/daily data. key would be time(00,01,02,...) or date(i.e. 5/20.5/21,...). set_total_array = Array.new # this data is mcv and it is from database total_clicks_count = set_total_article(startdate, enddate) # getting total data part start total_data = response.reports.first.data.totals key_array = metrics # get rid of 'ga:' key_array.each_with_index do |k, index| key_array[index] = k.gsub("ga:","") end total_data.each do |t| datahash = {} t.values.each_with_index do |v, index| datahash[key_array[index]] = v end datahash['mcv'] = total_clicks_count set_total_array.push(datahash) end # datahash sample -> { "pageviews": "11", "users": "22", "bounces": "33", ... , "mcv": 0 } # getting total data part end # getting daily or hourly data part start dropdwnhash = {} data_from_google = response.reports.first.data.rows data_from_google.each do |r| vhash = {} # key would be hour or date key = r.dimensions.first # vhash is the data such as pageview, users and so on for specific time or date r.metrics.first.values.each_with_index do |v, index| vhash[key_array[index]] = v end if startdate == enddate key = key + ":00" end dropdwnhash[key.to_sym] = vhash end # dropdwnhash sample (hour) -> "00:00": { "pageviews": "534", "users": "478", "bounces": "432", ... }, "01:00": { ... } # dropdwnhash sample (date) -> "20200608": { "pageviews": "534", "users": "478", "bounces": "432", ... }, "20200609": { ... } set_total_array.push(dropdwnhash) # getting daily or hourly data part end return set_total_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calorie_sum_by_day\n\n end", "def total_on(date)\n total = (items.sum :value, :conditions=>{:date=>date}) || 0\n total += value_unpaid_tasks_on(date)\n end", "def chart_data\n # date_from = (params[:q].nil? or params[:q][:issue_date_gteq].empty?) ? 30.days.ago.to_date : Date.parse(params[:q][:is...
[ "0.74724084", "0.71565723", "0.67710024", "0.6631749", "0.66201204", "0.6606829", "0.648559", "0.64828455", "0.6480033", "0.6460719", "0.64020985", "0.63573104", "0.63203496", "0.63151824", "0.62724555", "0.6268677", "0.625671", "0.6251783", "0.6188261", "0.6166282", "0.61639...
0.0
-1
get mcv date from database
def set_total_article(startdate, enddate) start_date = startdate.to_date.beginning_of_day end_date = enddate.to_date.end_of_day total_clicks_count = Click.where(:created_at => start_date..end_date).count return total_clicks_count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_date()\n @date\n end", "def get_date()\n @date\n end", "def date\n @date\n end", "def date\n @date\n end", "def date() self[:date]; end", "def date\n @date\n end", "def date\n @date\n end", "def get_date(sqlite_date)\n sqlite_date.nil? ? nil : sqlite_date[0....
[ "0.73385954", "0.73385954", "0.69346356", "0.69346356", "0.6906459", "0.6832835", "0.6832835", "0.6766766", "0.6744504", "0.6704357", "0.66079026", "0.66079026", "0.66079026", "0.66079026", "0.6513092", "0.65023994", "0.6499432", "0.6477608", "0.6473672", "0.6394089", "0.6385...
0.0
-1
each article data by selected period
def get_data(startdate, enddate) date_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate) order_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING') # metric = @analytics::Metric.new(expression: 'ga:sessions') # metric = @analytics::Metric.new(expression: ['ga:sessions', 'ga:uniquePageviews']) # metric = @analytics::Metric.new # metric.expression = ['ga:sessions', 'ga:uniquePageviews'] metrics = ['ga:pageviews', 'ga:users', 'ga:bounces', 'ga:sessions', 'ga:avgTimeOnPage', 'ga:newUsers', 'ga:goal1ConversionRate', 'ga:goal1Completions' ] # metrics = ['ga:totalEvents' # ] metric_type = Array.new metrics.each do |m| metric = @analytics::Metric.new metric.expression = m metric_type.push(metric) end dimensions = ['ga:pagePath', 'ga:pageTitle', 'ga:hostname' ] # dimensions = ['ga:pagePath', 'ga:eventCategory'] dimension_type = Array.new dimensions.each do |d| dimension = @analytics::Dimension.new dimension.name = d dimension_type.push(dimension) end # dimension = @analytics::Dimension.new(name: 'ga:pagePath') # dimension_filters = @analytics::DimensionFilterClause.new( # filters: [ # @analytics::DimensionFilter.new( # dimension_name: 'ga:pagePath', # operator: "IN_LIST", # expressions: ['/archives/69839', '/archives/54087', '/archives/68924', '/archives/58437', '/archives/65171', '/archives/64435', '/archives/61533', '/archives/68924', # '/archives/65086', '/archives/64736', '/archives/55244', '/archives/68211' # ] # ) # ] # ) request = @analytics::GetReportsRequest.new( report_requests: [@analytics::ReportRequest.new( view_id: @view_id, metrics: metric_type, dimensions: dimension_type, # dimension_filter_clauses: [dimension_filters], # dimensions: [dimension], date_ranges: [date_range], order_bys: [order_by], pageSize: 10000 )] ) response = @client.batch_get_reports(request) messageHash = {} # handling error if !response.reports.first.data.rows then key = "message" messageHash[key.to_sym] = "no data" return messageHash end data_from_google = response.reports.first.data.rows key_array = dimensions + metrics # get rid of 'ga:' key_array.each_with_index do |k, index| key_array[index] = k.gsub("ga:","") end key_array.push('id') key_array.push('clickCount') set_ga_data_array = Array.new data_from_google.each_with_index do |r, index| datahash = {} i = 0; # setup dimension part r.dimensions.each do |d| datahash[key_array[i]] = d i += 1 end # setup metrics part r.metrics.first.values.each do |m| datahash[key_array[i]] = m i += 1 end # get aticle data from db articleArr = set_article_data(datahash['hostname'], datahash['pagePath'], startdate, enddate) # setup id, mcv articleArr.each do |a| datahash[key_array[i]] = a i += 1 end set_ga_data_array.push(datahash) #datahash sample -> { "pagePath": "/archives/69839", ... , "goal1Completions": "23", "id": 4, "clickCount": 0 }, end return set_ga_data_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n # @search = Article.search do\n # fulltext params[:search]\n # # with(:published_at).less_than(Time.zone.now)\n # # facet(:publish_month)\n # # with(:publish_month, params[:month]) if params[:month].present?\n # end\n # @articles = @search.results\n\n @articles = Article.all \n @se...
[ "0.6340772", "0.6268592", "0.6192167", "0.6175236", "0.5997018", "0.59653", "0.5928373", "0.5853675", "0.58528817", "0.58490795", "0.58367676", "0.5802076", "0.5752877", "0.57439256", "0.57111377", "0.57017946", "0.5693628", "0.56608725", "0.5642664", "0.56386214", "0.5580434...
0.5453094
32
db data by url
def set_article_data(hostname, uri, startdate, enddate) url = 'https://' + hostname + uri article = Article.find_by(article_url: url) start_date = startdate.to_date.beginning_of_day end_date = enddate.to_date.end_of_day articleArr = Array.new if article id = article.id clickCount = article.clicks.where(:created_at => start_date..end_date).count else id = 0 clickCount = 0 end articleArr = [id, clickCount] return articleArr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def database! url\n parsed = parse url\n cr = Sova.new(parsed[:host])\n cr.database!(parsed[:database])\n end", "def database! url\n parsed = parse url\n cr = CouchRest.new(parsed[:host])\n cr.database!(parsed[:database])\n end", "def write_urls_db()\n end", "def getDBDat...
[ "0.7081181", "0.7055872", "0.6588096", "0.6471091", "0.63598365", "0.6351594", "0.6200471", "0.6073722", "0.60664654", "0.60117733", "0.595577", "0.59473366", "0.5875172", "0.5824699", "0.5812224", "0.57774645", "0.57739085", "0.57111925", "0.5696198", "0.56932586", "0.567389...
0.0
-1
method for cron job
def get_ga_data(yesterday, view_id, ga_key) date_range = @analytics::DateRange.new(start_date: yesterday, end_date: yesterday) order_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING') metrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:timeOnPage'] metric_type = Array.new metrics.each do |m| metric = @analytics::Metric.new metric.expression = m metric_type.push(metric) end dimensions = ['ga:dateHour', 'ga:pagePath'] dimension_type = Array.new dimensions.each do |d| dimension = @analytics::Dimension.new dimension.name = d dimension_type.push(dimension) end request = @analytics::GetReportsRequest.new( report_requests: [@analytics::ReportRequest.new( view_id: view_id, metrics: metric_type, dimensions: dimension_type, # dimension_filter_clauses: [dimension_filters], date_ranges: [date_range], order_bys: [order_by], page_size: 100_000 )] ) response = @client.batch_get_reports(request) # handling error if !response.reports.first.data.rows then return end data_from_google = response.reports.first.data.rows set_ga_data_array = Array.new data_from_google.each_with_index do |r, index| # dimensions = ['ga:dateHour', 'ga:pagePath'] # metrics = ['ga:pageviews', 'ga:users', 'ga:newUsers', 'ga:bounces', 'ga:sessions', 'ga:avgTimeOnPage'] datahash = {} urls_rm_params = r.dimensions[1].split(/\?/)[0] article = Article.select(:id).find_by(article_url: urls_rm_params) next if !article article_arr = set_ga_data_array.each_with_index.select{|a, index| a['article_id'] == article.id && a['date_hour'] == r.dimensions[0]} if !article_arr.empty? article_index = article_arr.first[1] set_ga_data_array[article_index] page_view = set_ga_data_array[article_index]['page_view'].to_i page_view_temp = r.metrics.first.values[0].to_i set_ga_data_array[article_index]['page_view'] = page_view + page_view_temp user = set_ga_data_array[article_index]['user'].to_i user_temp = r.metrics.first.values[1].to_i set_ga_data_array[article_index]['user'] = user + user_temp new_user = set_ga_data_array[article_index]['new_user'].to_i new_user_temp = r.metrics.first.values[2].to_i set_ga_data_array[article_index]['new_user'] = new_user + new_user_temp bounce = set_ga_data_array[article_index]['bounce'].to_i bounce_temp = r.metrics.first.values[3].to_i set_ga_data_array[article_index]['bounce'] = bounce + bounce_temp session = set_ga_data_array[article_index]['session'].to_i session_temp = r.metrics.first.values[4].to_i set_ga_data_array[article_index]['session'] = session + session_temp avg_time_on_page = set_ga_data_array[article_index]['avg_time_on_page'].to_i avg_time_on_page_temp = r.metrics.first.values[5].to_i set_ga_data_array[article_index]['avg_time_on_page'] = avg_time_on_page + avg_time_on_page_temp else datahash['article_id'] = article.id datahash['date_hour'] = r.dimensions[0] page_view = r.metrics.first.values[0] datahash['page_view'] = page_view user = r.metrics.first.values[1] datahash['user'] = user new_user = r.metrics.first.values[2] datahash['new_user'] = new_user bounce = r.metrics.first.values[3] datahash['bounce'] = bounce session = r.metrics.first.values[4] datahash['session'] = session avg_time_on_page = r.metrics.first.values[5] datahash['avg_time_on_page'] = avg_time_on_page datahash['created_at'] = Time.zone.now datahash['updated_at'] = Time.zone.now set_ga_data_array.push(datahash) end end # avg time on page setup (avt t.o.p in ga doesn't fit to our site so we need to calculate by ourselves) # avg.time on page = time on page / pageviews set_ga_data_array.each do |ga| time_on_page = ga['avg_time_on_page'].to_i pv = ga['page_view'].to_i if time_on_page != 0 && pv != 0 begin ga['avg_time_on_page'] = time_on_page/pv rescue StandardError => e puts e ga['avg_time_on_page'] = 0 end end end return set_ga_data_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cron_tasks\n end", "def cron_open\n # jo = File.open #still need to write crontab protocol\n end", "def cron(*args)\n @cron = args\n end", "def execute_tasks(starttime)\n now=Time.now\n starttime=Time.at(now.to_i-24*60*60) if starttime.nil? \n $stdin.each_line do |line|\n md= /^([^...
[ "0.8231804", "0.7285462", "0.72757626", "0.6817177", "0.67984563", "0.6728935", "0.66368926", "0.6531004", "0.6527388", "0.65028214", "0.64983344", "0.64424884", "0.6431277", "0.64071435", "0.63800585", "0.63647276", "0.6364586", "0.6350119", "0.6331258", "0.6323949", "0.6316...
0.0
-1
get article table data from ga
def get_article_data(yesterday, view_id, domain_id, article_key) date_range = @analytics::DateRange.new(start_date: yesterday, end_date: yesterday) order_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING') metric = @analytics::Metric.new(expression: 'ga:pageviews') dimensions = ['ga:pageTitle', 'ga:pagePath'] dimension_type = Array.new dimensions.each do |d| dimension = @analytics::Dimension.new dimension.name = d dimension_type.push(dimension) end request = @analytics::GetReportsRequest.new( report_requests: [@analytics::ReportRequest.new( view_id: view_id, dimensions: dimension_type, metrics: [metric], # dimension_filter_clauses: [dimension_filters], # dimensions: [dimension], date_ranges: [date_range], order_bys: [order_by], page_size: 100_000 )] ) response = @client.batch_get_reports(request) messageHash = {} # handling error if !response.reports.first.data.rows then return end data_from_google = response.reports.first.data.rows # max_position_array = get_max_position(yesterday, view_id) set_ga_data_array = Array.new data_from_google.each_with_index do |r, index| datahash = {} # domain_id datahash['domain_id'] = domain_id # dimensions = ['ga:pageTitle', 'ga:pagePath'] datahash['article_title'] = r.dimensions[0] urls_rm_params = r.dimensions[1].split(/\?/)[0] datahash['article_url'] = urls_rm_params # total_events = 0 # max_position = 1 # mobile_device_info = '' # if max_position_array != nil # max_arr = max_position_array.select{|max| max['article_url'] == r.dimensions[1]} # if !max_arr.empty? # max_arr.each do |a| # if a['total_events'] > total_events # total_events = a['total_events'] # mobile_device_info = a['mobileDeviceInfo'] # max_position = a['max_position'] # elsif a['total_events'] == total_events && a['mobileDeviceInfo'] == 'Apple iPhone' # if mobile_device_info == 'Apple iPhone' && a['max_position'] > max_position # max_position = a['max_position'] # elsif mobile_device_info != 'Apple iPhone' # mobile_device_info = a['mobileDeviceInfo'] # max_position = a['max_position'] # end # end # end # end # datahash[article_key[i]] = max_position # else # datahash[article_key[i]] = 25000 # end datahash['max_position'] = 0 set_ga_data_array.push(datahash) end return set_ga_data_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_all_article_info()\n return get_db_as_hash().execute(\"SELECT * FROM article JOIN tags ON article.tag_id=tags.tag_id\")\n end", "def index\n @ga_data = GaDatum.all\n end", "def get_data(startdate, enddate)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: startdate, end_dat...
[ "0.6470874", "0.6367738", "0.63142264", "0.6152746", "0.5951434", "0.56811464", "0.56811464", "0.5666134", "0.5623902", "0.5609545", "0.55517805", "0.5516633", "0.54986185", "0.54972523", "0.54873294", "0.5440363", "0.54317963", "0.54102975", "0.54008114", "0.5400532", "0.539...
0.6058423
4
customize rack app for testing, if block is given, reverts to default rack app after testing is done
def set_app!(options = {}) old_app = self.app self.app = Rack::Builder.app do use Rack::Session::Cookie, secret: 'ultra_strong_secret' use OmniAuth::Strategies::Zendesk, options run lambda{|env| [404, {'env' => env}, ["HELLO!"]]} end if block_given? yield self.app = old_app end self.app end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end", "def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end", "def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end", "def mock_app(base=Sinatra::Base, &...
[ "0.7283195", "0.7268397", "0.7268397", "0.7268397", "0.70114857", "0.70114857", "0.70114857", "0.70114857", "0.6834816", "0.6798196", "0.6750964", "0.66858554", "0.65658593", "0.6479456", "0.6439406", "0.6439406", "0.6385005", "0.6344517", "0.63343036", "0.623196", "0.6224924...
0.6906908
8
Check the home page after login has some links
def test_links_exist login_as_valid_user puts "****"+session[:login].to_s assert_tag :tag => "a", :parent => { :tag => "li"}, :descendant => { :child => /Project Management/ } logout end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_logged_in_home\n if current_user != nil\n redirect_to user_path(current_user)\n end\n end", "def home_check\n if logged_in? && @current_user.admin?\n puts @current_user\n redirect_to account_url(@current_user.id)\n return\n elsif logged_in?\n redirect_to cases_path...
[ "0.7586777", "0.73427194", "0.6974875", "0.6941298", "0.6922606", "0.691566", "0.6886396", "0.6836467", "0.68243676", "0.67823046", "0.67764926", "0.67730474", "0.6751303", "0.67338896", "0.672224", "0.66629237", "0.66353726", "0.6634183", "0.66152614", "0.6595828", "0.657011...
0.0
-1
MODIFIED: Sam Wolfe 4/10/2018 Added ability to hide/show profile elements based on request number
def band @posts_applied = Response.where(band_id: current_band.id).map{|response| response.post} @posts_applied = @posts_applied.first(3); @posts_not_applied = Post.find Post.all.map{|p| p.id} - @posts_applied.map{|post| post.id} @posts_not_applied = @posts_not_applied.first(3); @business_requests = BusinessRequest.where(band_id: current_band.id) @requests = @business_requests.count - @business_requests.count(:band_decision) if@requests > 0 @has_requests = true; else @has_requests = false; end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n \n @user = logged_in_user \n @questions = logged_in_user.user_attribute_details \n @change_list = ContentManager.calculate_change_list(@user) \n @campaigns_to_show = 5\n @owned_campaigns = logged_in_user.owned_campaigns.not_deleted\n @is_org_user = @user.has_role? \"Organiz...
[ "0.59980124", "0.58354694", "0.5797862", "0.57949615", "0.5775649", "0.570969", "0.56919116", "0.5663435", "0.5656469", "0.56062245", "0.55806166", "0.5534865", "0.5499659", "0.5442959", "0.54041946", "0.53907263", "0.538885", "0.5383257", "0.53717613", "0.5371131", "0.536779...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_item_data_property_ledger @item_data_property_ledger = ItemDataPropertyLedger.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 trusted parameter "white list" through.
def item_data_property_ledger_params params.require(:item_data_property_ledger).permit(:item_id, :data_property_id, :data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7120904", "0.70538116", "0.69469863", "0.6901261", "0.67348766", "0.6717708", "0.66874576", "0.6676195", "0.66601187", "0.65563625", "0.6525127", "0.64565873", "0.64494514", "0.644928", "0.64452374", "0.6433947", "0.6412815", "0.6412815", "0.6391939", "0.63792473", "0.6379...
0.0
-1
Work with Rails 4 strong parameters
def registration_params begin p = params.require(:user) rescue return false end p.permit(:username, :email, :password, :password_confirmation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "d...
[ "0.709536", "0.70448744", "0.70181274", "0.6857846", "0.68065673", "0.6789449", "0.67739236", "0.6763506", "0.67374355", "0.6731862", "0.6729607", "0.6702324", "0.66590965", "0.6643814", "0.66240853", "0.6606347", "0.6606347", "0.6601395", "0.66004115", "0.6598087", "0.659299...
0.0
-1
Work with Rails 4 strong parameters
def login_params begin p = params.require(:login) rescue return false end p.permit(:username, :password) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "d...
[ "0.70956105", "0.7045022", "0.7018351", "0.68581796", "0.68067217", "0.6789715", "0.67742157", "0.6763879", "0.67376703", "0.6732135", "0.67298895", "0.6702509", "0.66594124", "0.66441065", "0.662438", "0.6606626", "0.6606626", "0.660173", "0.6600566", "0.6598159", "0.6593380...
0.0
-1
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) current = 0 lowest = 0 lowest_key = nil name_hash.collect do |key, value| current = value if current < lowest || lowest == 0 lowest = current lowest_key = key end end lowest_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.82527804
49
Will include all attribute from API document
def searches wrapping!( search( root_uri, data_raw.to_s.gsub('=>', ':') ) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def include_attrs\n @include_attrs\n end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def attributes; end", "def...
[ "0.6565531", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.6327796", "0.63206816", "0.6318168", "0.6298896", "0.62770164", "0.61958444", "0.6189441", "0.61867046", "0.6173783", "0.6173783",...
0.0
-1
Post request raw datas
def field_ids @conditions['field_ids'] || cbobject.basis_fields end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_data; end", "def raw_post; end", "def post_data\n @request[\"postData\"]\n end", "def raw_post_request raw_params\n json_body = raw_params.to_json\n Rubix.logger.log(Logger::DEBUG, \"SEND: #{json_body}\") if Rubix.logger\n Net::HTTP::Post.new(uri.path).tap do |req|\n ...
[ "0.7524728", "0.7046655", "0.7007513", "0.7005208", "0.69985884", "0.6963396", "0.67141587", "0.66797686", "0.65774536", "0.65544075", "0.65361583", "0.65251786", "0.6415895", "0.6394937", "0.6367588", "0.6343628", "0.631943", "0.6306414", "0.62750965", "0.6268481", "0.624729...
0.0
-1
Set an attribute in the servlet context.
def []=(key, val) setAttribute(key.to_s, val) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_attribute(id, attr)\n\t\t\t@current_context.set_attribute(id, attr)\n\t\tend", "def set_attribute(name, value); end", "def set_attr(attr, value)\n ret = LibSeccomp.seccomp_attr_set(context, attr, value)\n raise SystemCallError.new(\"seccomp_attr_set(context, #{attr.inspect}, #{value}) failed\...
[ "0.7841657", "0.7423242", "0.71422565", "0.7134273", "0.69706947", "0.690911", "0.6894438", "0.6843054", "0.6803996", "0.6761267", "0.67404664", "0.67404664", "0.6673457", "0.6673457", "0.6627738", "0.6627738", "0.6580242", "0.657689", "0.65652084", "0.653342", "0.6531859", ...
0.6298588
36
Remove an attribute for the given key.
def delete(key) removeAttribute(key.to_s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_attribute(key); end", "def delete_attr!(key)\n copy_on_write if @attrs.shared\n key = key.intern \n old_attrs = @attrs\n @attrs = AttrArray.new\n @attrs_hash = {}\n old_attrs.each do |a|\n put_attr(a) if a.key_symbol != key\n end\n end", "def remove_attri...
[ "0.85295427", "0.8046233", "0.7494352", "0.7494352", "0.7494352", "0.7494352", "0.7170832", "0.7170832", "0.7168768", "0.71535647", "0.71510696", "0.708984", "0.70307964", "0.7027887", "0.6876078", "0.685754", "0.68046373", "0.6751213", "0.6698729", "0.6678779", "0.667554", ...
0.83570427
3
Retrieve all the attribute names (keys). like Hashkeys
def keys getAttributeNames.to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def keys\n attributes.ke...
[ "0.83720696", "0.83720696", "0.83720696", "0.83720696", "0.83421046", "0.83070236", "0.8240137", "0.82318974", "0.8211159", "0.81253296", "0.80687785", "0.8066238", "0.7990659", "0.79830986", "0.79690486", "0.79690486", "0.7962223", "0.79262525", "0.79241925", "0.7881712", "0...
0.8470216
0
Iterate over every attribute name/value pair from the context. like Hasheach
def each getAttributeNames.each { |name| yield(name, getAttribute(name)) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_attribute(&block)\n attributes.each(&block)\n end", "def each_attribute(&block)\n\t\t @@attributes.each &block\n\t\tend", "def each_attribute # :yields: key\n @attrs.each_key { |k| yield(k) }\n end", "def each_attribute(&block)\n attributes.each_attribute(&block)\n ...
[ "0.77277815", "0.7718536", "0.76774967", "0.75490063", "0.75388104", "0.750261", "0.7461197", "0.7363203", "0.7356307", "0.7356307", "0.72969013", "0.7191803", "0.71763533", "0.70837915", "0.6812762", "0.673729", "0.67111945", "0.668203", "0.661299", "0.65600127", "0.6490451"...
0.77591556
2
Set an attribute in the servlet request.
def []=(key, val) setAttribute(key.to_s, val) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_attribute(name, value); end", "def set_attribute(attribute, value)\n if MojeID.is_attribute_available?(attribute)\n fetch_request.set_values(attribute, value)\n bundle_to_request\n end\n end", "def setAttribute(attributeName)\n @attributeName = attributeName\n end", "def se...
[ "0.7239456", "0.68424404", "0.68416333", "0.6782506", "0.6678777", "0.6677796", "0.6625543", "0.66216785", "0.65993536", "0.65993536", "0.65319693", "0.65319693", "0.6499317", "0.6443476", "0.64036244", "0.63552034", "0.6302561", "0.627635", "0.62237495", "0.62061423", "0.619...
0.6058898
42
Remove an attribute for the given key.
def delete(key) removeAttribute(key.to_s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_attribute(key); end", "def delete_attr!(key)\n copy_on_write if @attrs.shared\n key = key.intern \n old_attrs = @attrs\n @attrs = AttrArray.new\n @attrs_hash = {}\n old_attrs.each do |a|\n put_attr(a) if a.key_symbol != key\n end\n end", "def remove_attri...
[ "0.85295427", "0.8046233", "0.7494352", "0.7494352", "0.7494352", "0.7494352", "0.7170832", "0.7170832", "0.7168768", "0.71535647", "0.71510696", "0.708984", "0.70307964", "0.7027887", "0.6876078", "0.685754", "0.68046373", "0.6751213", "0.6698729", "0.6678779", "0.667554", ...
0.83570427
1
Retrieve all the attribute names (keys) from the servlet request. like Hashkeys
def keys getAttributeNames.to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes\n @attrs.keys\n end", "def keys\n attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n ...
[ "0.7356165", "0.7324754", "0.72731984", "0.72731984", "0.72731984", "0.72731984", "0.7173571", "0.7165584", "0.71301204", "0.71086454", "0.7095123", "0.70937", "0.6940586", "0.69400525", "0.6928852", "0.68425727", "0.6841071", "0.6841071", "0.68225986", "0.6796084", "0.677672...
0.77442914
2
Iterate over every attribute name/value pair from the servlet request. like Hasheach
def each getAttributeNames.each { |name| yield(name, getAttribute(name)) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_attribute # :yields: key\n @attrs.each_key { |k| yield(k) }\n end", "def each_attribute(&block)\n\t\t @@attributes.each &block\n\t\tend", "def each # :yields: key, value\n @attrs.each { |k, v| yield(k, v) }\n end", "def each_attribute(&block)\n attributes.each(&block)\n ...
[ "0.6871169", "0.6616208", "0.6598819", "0.6588127", "0.64660853", "0.6449042", "0.6395681", "0.6395101", "0.6347066", "0.6317744", "0.6188348", "0.6186114", "0.61479557", "0.6146135", "0.6146135", "0.61373293", "0.61347294", "0.61000615", "0.6099919", "0.6072865", "0.6058385"...
0.69973594
0
Set an attribute in the session.
def []=(key, val) setAttribute(key.to_s, val) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set attribute, value\n attributes[attribute] = value\n end", "def set_attribute(name, value); end", "def set(attribute, value)\n @attributes[attribute.to_s] = value\n nil\n end", "def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end", "def set_attribu...
[ "0.7424007", "0.7346795", "0.72452635", "0.7098992", "0.70484173", "0.6964161", "0.69447935", "0.6932773", "0.6844347", "0.6842768", "0.6799717", "0.6799717", "0.6761823", "0.67564094", "0.67564094", "0.67532665", "0.6718862", "0.6680971", "0.66648626", "0.66628784", "0.66533...
0.63322526
52
Remove an attribute for the given key.
def delete(key) removeAttribute(key.to_s) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_attribute(key); end", "def delete_attr!(key)\n copy_on_write if @attrs.shared\n key = key.intern \n old_attrs = @attrs\n @attrs = AttrArray.new\n @attrs_hash = {}\n old_attrs.each do |a|\n put_attr(a) if a.key_symbol != key\n end\n end", "def remove_attri...
[ "0.85295427", "0.8046233", "0.7494352", "0.7494352", "0.7494352", "0.7494352", "0.7170832", "0.7170832", "0.7168768", "0.71535647", "0.71510696", "0.708984", "0.70307964", "0.7027887", "0.6876078", "0.685754", "0.68046373", "0.6751213", "0.6698729", "0.6678779", "0.667554", ...
0.83570427
2
Retrieve all the attribute names (keys) from the session. like Hashkeys
def keys getAttributeNames.to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keys\n attributes.keys\n end", "def keys\n @attributes.keys\n end", "def attributes\n @attrs.keys\n end", "def keys\n Keys[to_attr_list]\n end", "def attribute_keys\n return [] unless self[:attributes]\n self[:attributes].keys\n end", "def at...
[ "0.77650887", "0.7575111", "0.75099236", "0.74804366", "0.7431779", "0.74076426", "0.74076426", "0.74076426", "0.74076426", "0.7357327", "0.7351607", "0.71687037", "0.7148262", "0.7088859", "0.706278", "0.7058341", "0.7055983", "0.7030187", "0.7005255", "0.6972871", "0.693539...
0.8037139
1
Iterate over every attribute name/value pair from the session. like Hasheach
def each getAttributeNames.each { |name| yield(name, getAttribute(name)) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_attribute # :yields: key\n @attrs.each_key { |k| yield(k) }\n end", "def each # :yields: key, value\n @attrs.each { |k, v| yield(k, v) }\n end", "def attributes\n if iterator?\n @attr.each do |key, value|\n yield(value)\n end if @attr\n else\n...
[ "0.6623814", "0.6488496", "0.6451143", "0.640535", "0.6334656", "0.6282344", "0.62392306", "0.6152692", "0.6128836", "0.60732865", "0.60620636", "0.60481846", "0.6032993", "0.6032993", "0.60315186", "0.60060924", "0.5999632", "0.59871143", "0.59691674", "0.5969161", "0.596732...
0.67497075
1
Question3: Write at least one more function of your own design, and run it 10 different ways.
def sum_of(a,b) return a + b end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bad_smell_by_nfunctions\n end", "def three_to_twenty\n\nend", "def calls; end", "def calls; end", "def how_it_works\r\n end", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def problem_14\nend", "def perform\n multip...
[ "0.63595676", "0.62267905", "0.62042725", "0.62042725", "0.618429", "0.6077839", "0.6077839", "0.6077839", "0.6006674", "0.5958124", "0.59420806", "0.592435", "0.59094024", "0.5899994", "0.58799595", "0.58733886", "0.5867641", "0.5867641", "0.5867641", "0.5867641", "0.5867641...
0.0
-1
codewars kata: deodorant evaporator
def evaporator(content, evap_per_day, threshold) days = 0 threshold_amount = threshold.fdiv(100) * content until content < threshold_amount do content -= evap_per_day.fdiv(100) * content days += 1 end days end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def silly_adjective; end", "def celebration; end", "def anchored; end", "def villian; end", "def terpene; end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def demon; end", "def emotional_adjective; end", "def gounod; end", "def suivre; end", "def herald; end", "def...
[ "0.6394914", "0.63324815", "0.6163264", "0.6136077", "0.60891545", "0.60746104", "0.60338175", "0.6016724", "0.5994889", "0.59768456", "0.5797448", "0.5791851", "0.57638204", "0.5760907", "0.57375765", "0.5713643", "0.56810826", "0.56661266", "0.56586915", "0.5634365", "0.558...
0.0
-1
codewars kata: operations with sets
def process_2arrays(array_1, array_2) shared = array_1 & array_2 shared_count = shared.count array_1_unshared = array_1 - shared array_2_unshared = array_2 - shared count_1 = array_1_unshared.count count_2 = array_2_unshared.count unshared = array_1_unshared + array_2_unshared unshared_count = unshared.count [].push(shared_count, unshared_count, count_1, count_2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sets\n end", "def apply_harvesting_set_membership(sets)\n\t\t#We delete previous set memberships and move to new set\n old_sets = harvesting_set_membership.dup\n old_sets.each { |s| self.remove_relationship(:is_member_of_collection, s) }\n sets.delete_if { |s| s == \"\"}.each { |s| self.add_relatio...
[ "0.7116957", "0.6758597", "0.6758597", "0.6477536", "0.64008814", "0.6383874", "0.6361601", "0.63207406", "0.6299085", "0.62765026", "0.6194148", "0.6178563", "0.61028564", "0.60945547", "0.60883653", "0.60755897", "0.6050743", "0.5999694", "0.5980863", "0.59770066", "0.59396...
0.0
-1
codewars kata: next version
def nextVersion(version) return version.to_i.next.to_s if !version.include? '.' top, bottom = version.split('.', 2) bottom = bottom.split('.').join new_bottom = bottom.to_i.next.to_s if new_bottom.length > bottom.length top = top.to_i.next new_bottom = new_bottom.chars.drop(1).join end [top, new_bottom.chars.join('.')].join '.' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def king_richard_iii; end", "def jack_handey; end", "def solution4(input)\n end", "def anchored; end", "def koan_4\nend", "def p15\n\t\nend", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def villian; end", "def ...
[ "0.6714021", "0.6444321", "0.6353518", "0.62171453", "0.6216865", "0.6173083", "0.61607474", "0.61607474", "0.61607474", "0.61607474", "0.61607474", "0.61607474", "0.61607474", "0.61536807", "0.609242", "0.60637873", "0.6030874", "0.6030874", "0.6030874", "0.6030874", "0.6024...
0.0
-1
codewars kata: averages of numbers
def averages(array) return [] if !array.is_a? Array averages_array = [] array.each_index do |index| unless array[index + 1].nil? sum = (array[index] + array[index + 1]) sum % 2 == 0 ? averages_array << sum / 2 : averages_array << sum / 2.0 end end averages_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average numbers\n ave = numbers.reduce 0 do |total, number|\n sum = (total + number)\n end\n ave / numbers.length.to_f\nend", "def average(numbers)\n sum = numbers.reduce { |sum, number| sum + number }\n sum / numbers.count\nend", "def average(numbers)\n sum = numbers.reduce { |sum, number| sum + ...
[ "0.76195127", "0.75833255", "0.75833255", "0.75833255", "0.75833255", "0.75833255", "0.7582135", "0.7578446", "0.75643134", "0.75389767", "0.7529635", "0.75248945", "0.75080657", "0.7497693", "0.74847496", "0.7480164", "0.7474084", "0.74145824", "0.741104", "0.7360753", "0.73...
0.6961258
76
codewars kata: shortest word
def find_short(string) string.split.map(&:length).sort.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest(word1, word2)\n \n end", "def shortest_word(words)\n words.inject { |memo, word| memo.length < word.length ? memo : word}\nend", "def shortest_first(array_of_words)\n # TODO\nend", "def shortest_string(list_of_words)\n if list_of_words.empty? == true\n return nil\n end\n word...
[ "0.8314696", "0.80332565", "0.77733916", "0.76788294", "0.76128864", "0.7594599", "0.7564295", "0.7530207", "0.74949026", "0.74949026", "0.7450016", "0.7436052", "0.74038327", "0.73993284", "0.7394312", "0.73942447", "0.73930174", "0.73926634", "0.73741066", "0.7366519", "0.7...
0.0
-1
codewars kata: histogram h1
def histogram(results) array = [] results.each_with_index do |rolls, index| if rolls > 0 array.unshift("#{index + 1}|#{"#" * rolls} #{rolls}\n") else array.unshift("#{index + 1}|#{"#" * rolls}\n") end end array.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def histogram\n if @histogram.nil?\n @histogram = Hash[*BINS.map{ |elt| [elt, 0] }.flatten]\n authors.each do |name, num_commits|\n bottom = 0\n BINS.each do |top|\n if num_commits >= bottom and num_commits < top\n @histogram[bottom] += 1\n end\n bottom = top\n e...
[ "0.70034146", "0.6895342", "0.67857915", "0.66723007", "0.6634549", "0.66141874", "0.65223205", "0.63947433", "0.63616765", "0.63451564", "0.633878", "0.63285637", "0.6314085", "0.63092387", "0.62926716", "0.6250752", "0.61763084", "0.6159175", "0.6137487", "0.61359644", "0.6...
0.685367
2
codewars kata: number climber
def climb(n) array = [] until n < 1 array.push(n) n = n / 2 end array.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def break_chocolate(n, m)\n !/\\A\\d+\\z/.match(n.to_s) || !/\\A\\d+\\z/.match(m.to_s) || n == 0 || m == 0 ? 0 : n * m - 1\nend", "def break_chocolate(n, m)\n if n < 2\n 0\n else\n n * m - 1\n end\nend", "def crackle(number)\n\treturn \"Crackle\" if number % 3 == 0\nend", "def strong_num(n)\n arra...
[ "0.6796888", "0.6543511", "0.64249796", "0.6331908", "0.633165", "0.6309971", "0.628733", "0.6256616", "0.6237597", "0.62044233", "0.620167", "0.61951876", "0.6192066", "0.6169189", "0.6143555", "0.61297655", "0.6102379", "0.6102379", "0.60974514", "0.6091644", "0.6069785", ...
0.0
-1
codewars kata: powers of 2
def powers_of_two(n) (0..n).map{ |number| 2**number } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def powers_of_2\r\n\t\tunless $powers_of_2\r\n\t\t\t$powers_of_2 = [1]\r\n\t\t\t((BASE_BYTE << 3) - 1).times do |i|\r\n\t\t\t\t$powers_of_2[i + 1] = $powers_of_2[i] << 1\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\treturn $powers_of_2\r\n\tend", "def self_powers_2\n (1..1000).map {|i| i**i}.reduce(:+) % (10**10)\nend", ...
[ "0.81443995", "0.7788771", "0.7522795", "0.74974054", "0.7483794", "0.74133366", "0.73411417", "0.72870654", "0.7227142", "0.7213281", "0.7207004", "0.71964884", "0.71784556", "0.71650875", "0.7154648", "0.7154399", "0.7143813", "0.7033037", "0.7027812", "0.7021939", "0.70216...
0.7446869
5
codewars kata: colour association
def colour_association(array) array.map{|pair| Hash[pair.first, pair.last]} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def color(color); end", "def colors; end", "def colorize!; @colors = true; end", "def colorized?; end", "def scan_for_colors; end", "def generate_color_scheme\n if values_bits[Constants::V_Use_of_colors]<=2.5 #No colors \n if values_bits[Constants::V_Type_of_BG]<4.5 and @image_colors[0].get_li...
[ "0.6711947", "0.6350977", "0.6301483", "0.6254664", "0.62430394", "0.61862665", "0.61311495", "0.6082481", "0.60648423", "0.6030823", "0.60145295", "0.5983263", "0.59334964", "0.5930534", "0.5924699", "0.5924699", "0.5924699", "0.59190124", "0.5902911", "0.58814967", "0.58801...
0.6607406
1
codewars kata: rotate an array matrix
def rotate(matrix, direction) if direction == "clockwise" matrix.transpose.map{|i| i.reverse} else rotated = [] matrix.transpose.map{|i| i.reverse}.flatten.reverse.each_slice(matrix.size){ |a| rotated << a} rotated end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate_matrix(array)\n\n\nend", "def rotate_matrix(arr)\n\nend", "def rotate_matrix(arr)\n flipped_array = [] # initialize empty array\n transposed_arr = my_transpose(arr) # flip the rows with columns inside using a transpose method\n transposed_arr.each { |row| flipped_array << row.reverse } # on...
[ "0.8922084", "0.8662312", "0.7869226", "0.7834902", "0.7665643", "0.76367277", "0.7614206", "0.7582831", "0.7570841", "0.75581384", "0.74848557", "0.7463697", "0.7423924", "0.74125135", "0.7396256", "0.7371948", "0.73608685", "0.73164463", "0.7310452", "0.7274743", "0.7247427...
0.74875474
10
codewars kata: matrix addition
def matrixAddition(a, b) c = [] << a << b c.transpose.map{ |i| i.transpose }.map{ |s| s.map{ |p| p.reduce(&:+)}} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matrix_addition(m1, m2)\n rows = m1.length\n cols = m1[0].length\n result = Array.new(rows) { Array.new(cols, 0)}\n (0...rows).each do |row|\n (0...cols).each do |col|\n result[row][col] = m1[row][col] + m2[row][col]\n end\n end\n \n result\nend", "def matrix_add...
[ "0.7869705", "0.7850795", "0.7777493", "0.77681583", "0.76983064", "0.76678276", "0.7649536", "0.7621031", "0.7506059", "0.74922585", "0.7410893", "0.7402457", "0.73622286", "0.7308594", "0.7256614", "0.71787995", "0.7162077", "0.7141986", "0.71276253", "0.7099612", "0.706787...
0.8022373
0
codewars kata: josephus survivor this solution is built on this solution:
def josephus_survivor(n,k) # (1..n) people are put into the circle items = (1..n).to_a Array.new(n){items.rotate!(k-1).shift}.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend", "def josephus_survivor(n, k)\n survivors = (1..n).to_a\n loop do\n survivors.rotate!(k -1).shift\n return survivors[0] if survivors.length == 1\n end\nend", "de...
[ "0.74130183", "0.7368812", "0.7291861", "0.5909947", "0.57460254", "0.5739488", "0.5589394", "0.5555879", "0.55484784", "0.55193096", "0.55116236", "0.55075634", "0.54860073", "0.5452352", "0.5448089", "0.54232925", "0.54025215", "0.53847873", "0.53834206", "0.53795123", "0.5...
0.7168867
3
codewars kata: sudoku solution validator
def validSolution(board) array_of_boxes = Array.new box = Array.new i = 0 add_box_array = lambda do 3.times do 3.times do row = board[i] box.push(row[0]).push(row[1]).push(row[2]) i += 1 end array_of_boxes << box box = Array.new end end reset_and_rotate = lambda do i = 0 board.each{ |row| row.rotate!(3) } end add_reset_rotate = lambda do add_box_array.call reset_and_rotate.call end 2.times {add_reset_rotate.call} add_box_array.call all_possible_arrays = (1..9).to_a.permutation.to_a # each row & each column is a unique permutation of base_array board.all?{ |row| all_possible_arrays.include?(row) } && board.uniq.size == 9 && board.transpose.all?{ |column| all_possible_arrays.include?(column) } && board.transpose.uniq.size == 9 && array_of_boxes.all? { |box| all_possible_arrays.include?(box) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_sudoku(table)\n sudoku_box_hash = { [0, 0] => {}, [0, 1] => {}, [0, 2] => {},\n [1, 0] => {}, [1, 1] => {}, [1, 2] => {},\n [2, 0] => {}, [2, 1] => {}, [2, 2] => {}}\n\n sudoku_row_hash = { 1 => {}, 2 => {}, 3 => {},\n 4 => {}, 5 => {}, 6 =...
[ "0.7846883", "0.77814215", "0.77255124", "0.7709284", "0.7637136", "0.75797176", "0.7521248", "0.7473625", "0.74645483", "0.7441738", "0.74179155", "0.73958385", "0.7388276", "0.73526496", "0.7319035", "0.72637045", "0.72590715", "0.7211477", "0.72022873", "0.72022873", "0.72...
0.71205944
45
codewars kata: josephus permutation for best solutions, see
def josephus(items,k) new_array = [] while items.size > (k-1) new_array << items.delete_at(k-1) items.rotate!(k-1) end while items.size > 0 items.rotate!(k-1) new_array << items.delete_at(0) end new_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve\n perms = (1..9).to_a.permutation.map {|p| p.join}\n prods = []\n\n perms.each do |p|\n (1..2).each do |len|\n a, b, c = p[0, len].to_i, p[len..4].to_i, p[5, 4].to_i\n prods << c if a * b == c\n end\n end\n \n prods.uniq.reduce( :+ )\n end", "def pythagoreans ...
[ "0.7508187", "0.699553", "0.6897742", "0.6764146", "0.6730608", "0.67267084", "0.66697866", "0.65802777", "0.65519947", "0.6541124", "0.6524825", "0.6521009", "0.6516781", "0.6487009", "0.6468073", "0.6419668", "0.64172673", "0.64172673", "0.64172673", "0.64172673", "0.640475...
0.0
-1
codewars kata: format a string of names
def list(names) array = names.map{|n| n.values} if array.size > 2 array[0..-2].join(", ") + " & #{array[-1][0]}" else array.join(" & ") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_name(str)\n\tnames = str.split(\" \")\n\tformatted = \"\"\n\n\tnames.each do |name|\n\t\tformatted += name[0].upcase + name[1..-1].downcase + \" \"\n\tend\n\n\treturn formatted\n\n\t# name.each do |word|\n\t# \tword.each_char.with_index do |char, idx|\n\t# \t\tif idx == 0\n\t# \t\t\tupLetter = char.upca...
[ "0.752265", "0.7367414", "0.7313556", "0.7094018", "0.70486385", "0.70486385", "0.70415807", "0.70291847", "0.70199776", "0.69859535", "0.69590485", "0.69549334", "0.69225585", "0.69204056", "0.6917172", "0.6906009", "0.6902796", "0.6856452", "0.685421", "0.6841637", "0.68416...
0.0
-1
codewars kata: counting in the amazon
def count_arara(n) arara_array = [] (n/2).times{ |i| arara_array << "adak" } (n%2).times{ |i| arara_array << "anane" } arara_array.join(" ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customer_pet_count(number)\n return number[:pets].count\nend", "def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end", "def customer_pet_count(c...
[ "0.61818135", "0.6120547", "0.60995364", "0.6076927", "0.6065874", "0.6065874", "0.604398", "0.604398", "0.604398", "0.6012398", "0.59976244", "0.59915614", "0.59774286", "0.5966205", "0.5953364", "0.5953364", "0.59507114", "0.5947938", "0.5947938", "0.59430945", "0.59278554"...
0.0
-1
codewars kata: is a number prime?
def isPrime(num) # returns whether num is a prime number num > 1 && (2...num).none?{|n| num % n == 0} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_prime?(n)\n end", "def prime?(number)\n # binding.pry\n return false if number < 2\n (2..number - 1 ).each do|num|\n if (number % num) == 0\n return false\n end\n end\n true\nend", "def is_prime? (number)\n return false if number < 1\n 2.upto(Math.sqrt(number)) do |x|\n ret...
[ "0.8356683", "0.82777596", "0.82546204", "0.8216675", "0.8204239", "0.81969416", "0.8196109", "0.8195269", "0.8177309", "0.8171434", "0.81647146", "0.81625396", "0.81564415", "0.8153163", "0.81516963", "0.81494", "0.81445074", "0.8143539", "0.8141808", "0.81406075", "0.813376...
0.0
-1
codewars kata: vasya and stairs
def numberOfSteps(steps, m) ((steps/2 + steps%2)..steps).find{ |n| n%m==0 } || -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprovide_saily_kainsi(akamatsu_demoniacally)\n gibbergunyah_nutcrack(mollycot_copolymerization, capitulator_polyphylogeny, overjob)\n lid_polytonalism(pneumoenteritis_ribby)\n pricklefish(overdraft, phleboplasty_poleaxe)\n end", "def sittinae_hooey(scrawny_appulsion, termly)\n end", ...
[ "0.6092161", "0.5839368", "0.581617", "0.5801575", "0.5756847", "0.5713174", "0.56979847", "0.56849897", "0.56801516", "0.56405145", "0.56197953", "0.5580649", "0.55666673", "0.55611664", "0.5553605", "0.55462885", "0.55389935", "0.552456", "0.54853827", "0.54641163", "0.5451...
0.0
-1
codewars kata: sum of topleft to bottomright diagonals
def diagonalSum(matrix) (0...matrix.size).map { |i| matrix[i][i] }.reduce(&:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_of_diagonals\r\n\tresult = []\r\n\tresult.push 1\r\n\twidth = 3\r\n\twhile width <= 1001\r\n\t\tresult.push width**2, width**2 - (width-1), width**2 - (width-1)*2, width**2 - (width-1)*3\r\n\t\twidth += 2\r\n\tend\r\n\treturn result.reduce(:+)\r\nend", "def sum_diagonals(width)\r\n\t# Start on 1 so sum =...
[ "0.7635922", "0.75126874", "0.72006476", "0.6884646", "0.6704825", "0.6654649", "0.66140956", "0.6585282", "0.6578061", "0.6566153", "0.64192814", "0.64164245", "0.64109206", "0.640933", "0.6396608", "0.6395183", "0.63911545", "0.6368086", "0.6345855", "0.6331328", "0.6316184...
0.6602211
7
codewars kata: musical pitch classes
def pitch_class(note) array_with_sharps = [ 'B#', 'C#', 'D', 'D#', 'E', 'E#', 'F#', 'G', 'G#', 'A', 'A#', 'B'] array_with_flats = [ 'C','Db', 'D', 'Eb', 'Fb', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'Cb'] array_with_sharps.index(note) || array_with_flats.index(note) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kids_musical; end", "def get_pitch\n 12 * (@octave - 1) + @@letters[@letter] + @@accidentals[@accidental]\n end", "def codepoints\n Phonology.sounds.codepoints(features)\n end", "def musician; end", "def musician; end", "def strikes\r\n @pitches.select{|pitch| pitch.outcome == 'S'}\r\n...
[ "0.6830662", "0.66093254", "0.6191168", "0.6015732", "0.6015732", "0.5954493", "0.5947296", "0.5781961", "0.5736594", "0.5706084", "0.5689379", "0.5654669", "0.562302", "0.56144446", "0.56059366", "0.5603963", "0.5546832", "0.5532935", "0.55315226", "0.5530795", "0.5498791", ...
0.6328365
2
Implement a method that accepts 3 integer values a, b, c. The method should return true if a triangle can be built with the sides of given length and false in any other case. (In this case, all triangles must have surface greater than 0 to be accepted). Solution TIL the sum of any 2 sides of a triangle must be greater than the third side
def isTriangle(a,b,c) if (a > 0) || (b > 0) || (c > 0) if ((a + b) > c) && ((a + c) > b) && ((b + c) > a) return true else return false end else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_triangle?(a, b, c)\n if (a + b > c) && (a + c > b) && (b + c > a)\n true\n else\n false\n end\nend", "def valid_triangle?(a, b, c)\n a + b > c && a + c > b && b + c > a\nend", "def valid_triangle?(a, b, c)\n a + b > c && a + c > b && b + c > a\nend", "def valid_triangle?(a, b, c)\n a + ...
[ "0.84237313", "0.84212184", "0.84212184", "0.84212184", "0.8406885", "0.8390796", "0.8382921", "0.83159995", "0.82350993", "0.82110083", "0.8201444", "0.8188584", "0.8181286", "0.8174385", "0.8160924", "0.8151479", "0.81469566", "0.8139616", "0.8134575", "0.81237066", "0.8118...
0.8319327
7
Insert a row into the matrix of voices to search
def add_row( group_id, row, number_to_transpose = 0 ) @groups[group_id - 1] ||= [] @groups[group_id - 1] << MiltonsMachine::Core::ForteSet.new(row).transpose_mod12(number_to_transpose) @max_group_index = @groups.length - 1 @max_column_index = @groups[0][0].length - 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_row(pos)\n start = pos[:at].to_i\n count = pos[:count].to_i\n rows.each do |row|\n row.position += count if row.position >= start\n end\n count.times { rows.new(position: pos[:at]) }\n saved = rows.collect {|row| row.save }\n saved.all?\n end", "def insert_row(row, index=@rows....
[ "0.60751975", "0.58774453", "0.58319384", "0.58024424", "0.5738995", "0.57133186", "0.55922806", "0.55922806", "0.5532868", "0.5526674", "0.55206406", "0.5471927", "0.5442886", "0.54363483", "0.54328674", "0.5431411", "0.539794", "0.537761", "0.53758556", "0.5372628", "0.5345...
0.48094237
77
Insert a set into the search dictionary
def add_search_set( search_set, number_to_transpose = 0 ) @search_sets << Set.new( MiltonsMachine::Core::ForteSet.new(search_set).transpose_mod12(number_to_transpose) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(val)\n hash[val] = Set.new unless hash[val]\n hash[val].add(values.size)\n values.push(val)\n hash[val].size == 1\n end", "def __add_keys_to(set) # used by parser # [\n lim = @_st_tableSize\n lim = lim + lim\n kofs = 0\n while kofs < lim\n k = self.__at...
[ "0.6177171", "0.607688", "0.59745497", "0.5956627", "0.5948206", "0.59259856", "0.58951247", "0.58811456", "0.5874943", "0.58352625", "0.5789481", "0.5749088", "0.5687204", "0.56850153", "0.5616526", "0.56158483", "0.56066525", "0.5598883", "0.55987775", "0.55276084", "0.5527...
0.6488078
0
Run the rotation_analysis and print out the results
def run_rotation_analysis initialize_run rotate_group print_summary end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_rotation_count\n @rotation_count += 1\n print \"\\r\\e#{@rotation_count} of #{@maximum_rotations} processed...\"\n $stdout.flush\n end", "def main\n north_south = 0\n east_west = 0\n rotation = 0\n\n standard_rotations = {\n 0 => { north_south: 0, east_west: 1 },\n 9...
[ "0.6004163", "0.5732051", "0.5711006", "0.5667199", "0.55585", "0.5506489", "0.5484848", "0.53235203", "0.5312208", "0.52817506", "0.5261955", "0.52441883", "0.52290374", "0.5205131", "0.51918006", "0.51675093", "0.51662785", "0.51654243", "0.51544803", "0.5140026", "0.514002...
0.85818535
0
Initialize the environment before the analysis is run
def initialize_run @summary_totals.clear @rotation_count = 0 # Compute total number of rotation permutations for the run. # number_of_columns^(number_of_groups - 1) @maximum_rotations = @groups[0][0].length ** @max_group_index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_environment\n end", "def initialize_environment\n end", "def setup_environment; end", "def initialize env\n @env = env\n super()\n end", "def initialize env\n @env = env\n super()\n end", "def setup\n # noop\n end", ...
[ "0.81184566", "0.81184566", "0.7133543", "0.6778874", "0.6778874", "0.6455739", "0.63816494", "0.6365875", "0.6364734", "0.6351953", "0.6346537", "0.63257307", "0.6317991", "0.6317991", "0.63162154", "0.63154835", "0.63026214", "0.62400603", "0.6180285", "0.6179776", "0.61613...
0.0
-1
A recursive routine that rotates a group of voices in the horizontal matrix. If it is at depth, performs the final vertical analysis for the current rotations; otherwise, just calls itself to process the next group in the hierarchy.
def rotate_group( level = -1 ) level += 1 if level == 0 # First group always remains static rotate_group(level) # Recursive call to process next group of rows else # Rotate each pitch to the right for each row in this group. If its the last group then analyze the verticals # in each column across all groups; otherwise recursively call to process next group of rows. 0.upto(@max_column_index) do @groups[level].each { |row| row.rotate!(-1) } level == @max_group_index ? analyze_sonorities : rotate_group(level) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_rotation_analysis\n initialize_run\n rotate_group\n print_summary\n end", "def spiral_access(arrays, &block)\n # checks if arrays has no sub-arrays\n if arrays.empty?\n return\n end\n\n# top row\n first_set = arrays[0]\n first_set.each do |x|\n block.call x\n end\n ...
[ "0.58914447", "0.5213453", "0.5172878", "0.51578546", "0.5112639", "0.51018625", "0.4927041", "0.4922093", "0.48874027", "0.48260832", "0.47970814", "0.47718576", "0.475144", "0.46488744", "0.46468467", "0.46234345", "0.45963815", "0.4594693", "0.45883408", "0.4579273", "0.45...
0.73768514
0
Step through each column in the matrix of rotated rows (voices) and look for patterns of sets from a dictionary to create a score for each column (found) and for the entire matrix of rows (total found).
def analyze_sonorities sonority_to_test = Set.new # A work space for slicing result_counts = [] # Success counters of columns # Loop on columns in the matrix and extract out the sonority. Compare that to the dictionary of vertical sets to # compute a score for each column. @groups[0][0].each_index do |column_id| # Loop on number of number of columns result_counts[column_id] = 0 # Initialize counter for column sonority_to_test.clear # Slice through the voices of all groups and their rows to create a sonority to test. @groups.each_index do |group_id| @groups[group_id].each_index { |row_id| sonority_to_test.add( @groups[group_id][row_id][column_id] ) } end # Search the dictionary of vertical sets we are looking for and increment column counter if found. @search_sets.each { |set_to_search| result_counts[column_id] += 1 if set_to_search.subset?(sonority_to_test) } end # Accumulate a cross total of column result to create a final score for the current rotation snapshot. score = result_counts.inject(0) { |sum, col_result| sum += col_result } # If we meet the search criteria then add results to report totals and optionally print details. if @minimax_score.include?(score) accumulate_summary_totals(score) # Optionally print details of this rotation snapshot. print_details(result_counts, score) if @report_details end print_rotation_count unless @report_details # run progress meter if in summary mode end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_candidates(matrix)\n primary_line = row_index(matrix, @keys.first)\n\n list = []\n\n if column = matrix.column_with(content: primary, line: primary_line)\n list << {\n line: primary_line,\n column: column,\n value: primary\n }\n else\n matrix.row(primary_lin...
[ "0.6071914", "0.6060902", "0.5704503", "0.5675834", "0.5618278", "0.5469362", "0.5383137", "0.53829545", "0.5379066", "0.53445876", "0.5334156", "0.530029", "0.5285457", "0.5284604", "0.5281336", "0.52338374", "0.5212867", "0.5174232", "0.51719266", "0.5152324", "0.51519656",...
0.5937408
2
Accumulate current permutation search result counts into the reports summary totals. For example: if the total column score was 9 for the current rotation of the rows, summary_totals[9] would be incremented to reflect that a matrix solution was found with score = 9
def accumulate_summary_totals( score ) @summary_totals[score] ||= 0 @summary_totals[score] += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def summarize_results(results)\n sort_order = ['scenario', 'step', 'failed', 'flaky', 'undefined', 'skipped', 'pending', 'passed']\n\n ['scenario', 'step'].map do |group|\n group_results = results.grep(/^\\d+ #{group}/)\n next if group_results.empty?\n\n sums = su...
[ "0.60953057", "0.600039", "0.58985794", "0.58219343", "0.577207", "0.57419056", "0.5726415", "0.5687661", "0.56077826", "0.5471726", "0.54679525", "0.5459991", "0.54142916", "0.5409908", "0.5407839", "0.5400387", "0.5379317", "0.5376566", "0.5373155", "0.537284", "0.53650963"...
0.7095955
0
Print out the details of each analysis we are looking for
def print_details( result_counts, score ) puts ('=' * 10) << "\n" @groups.each_with_index { |group, index| group.each { |row| puts "#{row} Group " << (index + 1).to_s } } puts '-' * (@groups[0][0].length * 3) puts "#{result_counts} Score" puts "\nTotal Score: #{score}\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analyze\n format_results\n end", "def print_summary\n stats = [statistics[:total_code_loc], statistics[:total_spec_loc]]\n stats.push(stats[1].to_f / stats[0].to_f)\n \n puts \" Code LOC: %s Test LOC: %s Code to Test Ratio: 1:%1.1f\" % stats\n puts\n end",...
[ "0.6977242", "0.67322606", "0.6679173", "0.6597362", "0.65840834", "0.6583778", "0.65064", "0.65007865", "0.6453068", "0.6433837", "0.64218104", "0.6385697", "0.63795054", "0.6377932", "0.6339181", "0.633183", "0.63238513", "0.6282346", "0.6279356", "0.6272472", "0.626294", ...
0.635644
14
Print out a progress indicator of how many rotations / permutations have been processed and how many are remaining.
def print_rotation_count @rotation_count += 1 print "\r\e#{@rotation_count} of #{@maximum_rotations} processed..." $stdout.flush end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_progress\n\t\t\t# bar_size is between 0 and 30\n finish_size = (((@top_card-12).to_f / (@deck.length-11).to_f) * 30).to_i\n\t\t\tremain_size = 30 - finish_size\n\t\t\tprint \"\\nProgress: \"\n\t\t\tfinish_size.times {print '▓'}\n\t\t\tremain_size.times {print '░'}\n\t\t\tputs\n\t\t\tputs\n end", ...
[ "0.7286469", "0.6606537", "0.6606537", "0.6606537", "0.6606537", "0.6606537", "0.6561013", "0.65301615", "0.6503656", "0.64372945", "0.63917756", "0.63744324", "0.63731664", "0.63432467", "0.63100976", "0.6208046", "0.6141926", "0.6137373", "0.6123387", "0.6123387", "0.612338...
0.7456358
0
Prints a summary section for the entire report
def print_summary puts "\n\nScore : # Instances\n" << ("=" * 19) @summary_totals.each_with_index { |value, index| puts " %5d:%8d\n" % [index, value] unless value.nil? } puts "\n** End of Report" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def summary\n \n end", "def dump_summary( summary )\n\t\thtml = self.render_summary( summary )\n\t\t@output.puts( html )\n\t\t@output.flush\n\tend", "def summary\n end", "def summary\n end", "def summary\n # TODO\n end", "def summary; end", "def summary; end", "def summary; end", "def sum...
[ "0.72487986", "0.72418725", "0.7203269", "0.7203269", "0.7200281", "0.71919674", "0.71919674", "0.71919674", "0.71919674", "0.712414", "0.70546436", "0.70524293", "0.70318073", "0.7016436", "0.6937847", "0.6918684", "0.68868417", "0.6867476", "0.6850022", "0.68379134", "0.680...
0.77893555
0