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
Run a standard profile query for a specific player
def run_command(bot, type, query, options) query.gsub! /#/, "-" query.gsub! /[^A-Za-z0-9\-]/, "" options["tag"] = query if type == "profile" user = get_username(query) if user == nil return "Unknown user #{user}" end %{#{user[:message]} #{get_user_details user[:long]}} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_player_profile\n @player_profile = PlayerProfile.where(user_id: params[:user_id])[0]\n end", "def select_player_profile\n push_game_state(ProfileSelect)\n end", "def player_profile(\n player_id,\n season,\n graph_start_season,\n graph_end_season,\n graph_s...
[ "0.6570387", "0.6315511", "0.62811023", "0.62009", "0.61190265", "0.59987974", "0.5949724", "0.5906917", "0.59018725", "0.5868668", "0.5860656", "0.5825967", "0.57407176", "0.5697209", "0.56826574", "0.56825686", "0.56540924", "0.56026345", "0.5595355", "0.55901897", "0.55753...
0.5856817
11
send a message out to the appropriate channels
def dispatch_message(bot, pns) message = bot.paginate_response(pns, takeoff=16) @config[:channel_for_announce].each do |channel| channels = bot.find_channel(channel) puts "CHANNELS: #{channels}" channels.each do |channel| if config[:announce_tags].length > 0 channel.send_message config[:announce_tags].join(" ") end message.map { |m| channel.send_message "```Markdown\n#{m}```" } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_channel_msg( msg)\n @descriptors.each do |sock|\n if sock != @serverSocket\n user = @user_info[@descriptors.index(sock)-1] \n if user[:role] == \"client\" and user[:mode] == \"push\"\n str = \"Advice from channel #{msg[:channel]} : #{msg[:ad]}\\n\"\n sock.write(str...
[ "0.73161024", "0.7313379", "0.69117796", "0.66111356", "0.6486624", "0.64085686", "0.63602644", "0.6319078", "0.62892354", "0.62892354", "0.627646", "0.6265836", "0.6265584", "0.62641734", "0.6253432", "0.6210911", "0.62052035", "0.6197792", "0.6193296", "0.6193296", "0.61877...
0.0
-1
set a bit to 1
def set(position) # duplicated code to avoid a method call @field[position / ELEMENT_WIDTH] |= 1 << (position % ELEMENT_WIDTH) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set(bit, value = true)\n if value\n @bits = union convert_bit(bit)\n @set_indexes << bit unless @set_indexes.include?(bit)\n elsif set?(bit)\n @bits = xor convert_bit(bit)\n @set_indexes.delete(bit)\n end\n\n @bits\n end", "def bit(y)\n bit?(y) ? ONE : ...
[ "0.72141165", "0.7178396", "0.71600384", "0.71600384", "0.6933555", "0.69261837", "0.67317045", "0.6703773", "0.66939026", "0.65755546", "0.6550913", "0.6543002", "0.64151216", "0.63881695", "0.63568014", "0.63316816", "0.631783", "0.62053806", "0.6199442", "0.6182848", "0.61...
0.0
-1
set a bit to 0
def unset(position) # duplicated code to avoid a method call @field[position / ELEMENT_WIDTH] &= ~(1 << (position % ELEMENT_WIDTH)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear(bit)\n set(bit, false)\n end", "def set_zero_flag_from(actual_value)\n\t\t@flags.set_bit_at(ZERO_FLAG, (actual_value.zero? ? 1 : 0))\n\tend", "def set(bit, value = true)\n if value\n @bits = union convert_bit(bit)\n @set_indexes << bit unless @set_indexes.include?(bit)\n ...
[ "0.7264407", "0.7049321", "0.6877007", "0.6711308", "0.6711308", "0.66727185", "0.6659421", "0.65888023", "0.6542075", "0.646377", "0.6420886", "0.63936836", "0.6345617", "0.62497246", "0.62263083", "0.62019545", "0.6201048", "0.6190154", "0.6173893", "0.61636615", "0.612317"...
0.0
-1
check if bit is set
def include?(position) @field[position / ELEMENT_WIDTH] & 1 << (position % ELEMENT_WIDTH) > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set?(bit)\n bit = convert_bit(bit)\n intersect(bit) == bit\n end", "def set?(flag)\n (@status_register & flag == 0) ? false : true\n end", "def is_valid?\n bit_set?(VALID_FLAG_BIT)\n end", "def checkBitSet( i, bitfield )\n bitfield & (1<<i)\n end", "def set?(num, ma...
[ "0.8200939", "0.7401231", "0.7036542", "0.692363", "0.6870035", "0.67379725", "0.67364216", "0.65892154", "0.64471257", "0.63815945", "0.63623756", "0.63316876", "0.6288815", "0.6261348", "0.62603116", "0.6183481", "0.61574936", "0.61547905", "0.6118871", "0.60667914", "0.606...
0.0
-1
check if bit is not set
def zero?(position) # duplicated code to avoid a method call @field[position / ELEMENT_WIDTH] & 1 << (position % ELEMENT_WIDTH) == 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set?(bit)\n bit = convert_bit(bit)\n intersect(bit) == bit\n end", "def empty?\n bitmask.zero?\n end", "def not\n ~@bits\n end", "def empty_bits?(_options = {})\n empty_bits.size > 0\n end", "def is_valid?\n bit_set?(VALID_FLAG_BIT)\n end", "def unique...
[ "0.7041558", "0.7014351", "0.69234836", "0.6834223", "0.65042186", "0.64841497", "0.6447419", "0.63980186", "0.6341475", "0.6301505", "0.6298788", "0.62809825", "0.62763095", "0.62578785", "0.62578785", "0.6217787", "0.61977434", "0.6188017", "0.61809397", "0.61607766", "0.61...
0.0
-1
iterate over each bit
def each(&block) @size.times { |position| yield self[position] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n bits.each(&block)\n end", "def each_byte(&blk)\n # No block given? Return an enumerator.\n return to_enum(:each_byte) unless block_given?\n \n # Block given? Apply it on each bit.\n @vbits.each_byte(&blk)\n end", "def bits...
[ "0.7857885", "0.6796281", "0.6715447", "0.6628589", "0.65724105", "0.6447172", "0.63436407", "0.6307854", "0.626422", "0.624921", "0.62025565", "0.61182714", "0.6051606", "0.60229033", "0.6021521", "0.60176194", "0.60173804", "0.6011429", "0.6008914", "0.5982818", "0.5965102"...
0.0
-1
returns the field as a string like "0101010100111100," etc.
def to_s inject("") { |a, b| a + b.to_s } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n @field.unpack('b*').first\n end", "def to_s\n bits=\"\"\n @fields.each {|f| \n if f.kind_of? Fields::Field\n bits << f.bitstring\n else\n bits << f.to_bitstring\n end\n }\n [bits].pack('B*')\n end", ...
[ "0.7630524", "0.7360662", "0.65509164", "0.6348841", "0.63420266", "0.63344747", "0.6320698", "0.6320097", "0.6245026", "0.62322605", "0.61734414", "0.61650527", "0.61273384", "0.6102714", "0.6101424", "0.60838306", "0.6075802", "0.6075707", "0.6043951", "0.6042723", "0.60327...
0.0
-1
returns the total number of bits that are set (the technique used here is about 6 times faster than using each or inject direct on the bitfield)
def total_set @field.inject(0) { |a, byte| a += byte & 1 and byte >>= 1 until byte == 0; a } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def countSetBits(x)\n\tcount = 0\n\n\twhile(x != 0)\n\t\tx = x & (x - 1)\n\t\tcount += 1\n\tend\n\treturn count\nend", "def bit_set_size\n @bit_set.size\n end", "def total_set\n @field.each_byte.inject(0) { |a, byte| (a += 1; byte &= byte - 1) while byte > 0 ; a }\n end", "def total_set\n @field.i...
[ "0.81293327", "0.79675764", "0.75831735", "0.75443316", "0.75443316", "0.747867", "0.7250146", "0.7238437", "0.70984393", "0.7089188", "0.7089188", "0.7085563", "0.70387733", "0.70144105", "0.69572455", "0.6900928", "0.6885847", "0.6775824", "0.67731905", "0.6756439", "0.6729...
0.7483263
6
Returns the next proxy or a tail sentinel.
def next @next ||= if next_uri node_cache.fetch(next_uri) do node = self.class.new(node_cache, next_uri, adapter, graph) node.prev = self node end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get!\n index = proxies.find_index(&:connectable?)\n return if index.nil?\n\n proxy = proxies.delete_at(index)\n tail = proxies[index..-1]\n\n @proxies = tail << proxy\n\n proxy\n end", "def get!\n index = proxies.find_index(&:connectable?)\n return if index.nil?\n\n...
[ "0.6481719", "0.6481719", "0.60736585", "0.60736585", "0.60260916", "0.59760445", "0.59760445", "0.59745824", "0.59189147", "0.5868273", "0.58570725", "0.58371925", "0.5824143", "0.5764316", "0.5759766", "0.57580054", "0.5692301", "0.5651094", "0.5631295", "0.5631295", "0.562...
0.5244995
81
Returns the previous proxy or a head sentinel.
def prev @prev ||= node_cache.fetch(prev_uri) if prev_uri end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prev\n prev? ? @current - 1 : nil\n end", "def get_prev()\n return @prev_node\n end", "def previous\n\t first? ? nil : locate - 1\n\tend", "def previous\n first? ? nil : @collection[index - 1]\n end", "def previous_sibling\n return @links[:previous_sibling]\n end", "def get_p...
[ "0.6964384", "0.673149", "0.67148054", "0.6679511", "0.6671421", "0.6588562", "0.6586074", "0.65328246", "0.6505349", "0.64929175", "0.6453486", "0.643297", "0.6422634", "0.6416476", "0.63785225", "0.63660455", "0.6361419", "0.6317082", "0.63158166", "0.6307675", "0.6284356",...
0.65647256
7
Graph representation of node.
def to_graph return RDF::Graph.new if target_id.blank? g = Resource.new(rdf_subject) g.proxy_for = target g.proxy_in = proxy_in.try(:uri) g.next = self.next.try(:rdf_subject) g.prev = prev.try(:rdf_subject) g.graph end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def graph_to_s\n string = \"\"\n @nodes.each do |name, node|\n string +=\"#{name}:\\n\\t(#{node.name}, #{node.country}, #{node.continent} #{node.timezone}, #{node.coords}, #{node.pop}, #{node.region}) => #{@edges[name]} \\n\"\n end\n string\n end", "def to_s\n @node...
[ "0.7046038", "0.6967149", "0.6884637", "0.6771866", "0.6683932", "0.66171753", "0.6561019", "0.65581596", "0.6532377", "0.6532377", "0.64345556", "0.64195704", "0.64019084", "0.63810647", "0.63556397", "0.635271", "0.6339811", "0.6325886", "0.63254493", "0.63181293", "0.63181...
0.0
-1
Populates attributes for the LinkedNode
def populate(instance) instance.proxy_for = resource.proxy_for instance.proxy_in = resource.proxy_in instance.next_uri = resource.next instance.prev_uri = resource.prev end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transfer_node_attributes(nodes, attributes); end", "def transfer_node_attributes(nodes, attributes)\n nodes.each do |child|\n # update all attributes\n merge_attributes(child, attributes)\n\n # set attributes specific to list items\n if @definition\n chil...
[ "0.71143246", "0.6941304", "0.6568938", "0.6293124", "0.6126974", "0.60959095", "0.60477895", "0.5967191", "0.5956017", "0.5897612", "0.5886323", "0.5886323", "0.5879867", "0.58052343", "0.57828236", "0.5701745", "0.5680954", "0.5672642", "0.5661207", "0.5657288", "0.56464344...
0.0
-1
Constructs a set of triples using ActiveTriples as objects
def resource @resource ||= Resource.new(uri, graph: graph) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def triples_for_class_definition\n declare_namespaces\n g = Graph.new\n b = BNode.new(self.name)\n g << Triple.new(b, URIRef.new('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), URIRef.new('http://www.w3.org/2002/07/owl#Class'))\n return g\n end", "def initi...
[ "0.6056422", "0.60386145", "0.587347", "0.5808522", "0.571177", "0.56227523", "0.56219935", "0.5567973", "0.55074215", "0.547889", "0.5476486", "0.5464657", "0.54468805", "0.53807265", "0.5371706", "0.5345029", "0.5322439", "0.53183144", "0.5302632", "0.5301507", "0.5300333",...
0.0
-1
PHASE I: O(n^3) def sub_sum(list) results = [] list.each_index do |j| list[0..j].each_index do |i| results max end max end PHASE II: O(n)
def sub_sum(list) sums = [] low = -1 high_subsum = nil lowest = nil list.each_index do |j| sums << (sums.empty? || j == low + 1 ? list[j] : sums.last + list[j] ) if sums.last < 0 low = j end lowest = j if lowest.nil? || sums[lowest] > sums[low] high_subsum = j if high_subsum.nil? || sums.last > sums[high_subsum] end list[lowest + 1..high_subsum].reduce(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sub_sum(list)\n array = []\n (0...list.length).each do |idx1|\n (idx1...list.length).each do |idx2|\n array << list[idx1..idx2] #O(n)\n end\n end \n array.map {|sub| sub.length > 1 ? sub.sum : sub.first}.max\nend", "def sub_sum(list)\n subs = []\n\n list.each_with_index...
[ "0.93181413", "0.9094144", "0.908011", "0.90670574", "0.9048249", "0.8932781", "0.8713485", "0.87077844", "0.86943835", "0.86902106", "0.8677072", "0.8663656", "0.86573505", "0.8652443", "0.86190265", "0.8601082", "0.85748106", "0.85522026", "0.8546105", "0.8521786", "0.85037...
0.8569448
17
return user's own feeds for profile
def profile_feeds(is_current_user = false) res = @user.contents.includes(:hash_tags, :owner, :user).ignore_daily_devotions unless is_current_user @user.user_anonymities.pluck(:start_time, :end_time).each do |range| res = res.where.not(created_at: range.first..(range.last || Time.current)) end end res.order(created_at: :desc).page(@page).per(@per_page) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feed\n FeedItem.from_users_followed_by(self)\n end", "def index\n people_in_feed = current_user.feed_list\n @posts = Post.where(user: people_in_feed)\n end", "def feeds\n @user = current_user\n @subscribed_ids = @user.subscriptions.pluck(:feed_uid)\n end", "def feed\n Post.from_users...
[ "0.7159712", "0.7015746", "0.70052236", "0.6999898", "0.6999898", "0.69806415", "0.68978363", "0.687664", "0.68647873", "0.6847692", "0.6809461", "0.6806109", "0.6806109", "0.6806109", "0.6806109", "0.6806109", "0.6806109", "0.6806109", "0.6806109", "0.67907697", "0.6763212",...
0.73798025
0
return the past popular contents in a period (last logout until last login) show this for 5 mins show feeds older than 2 days
def past_popular if @page == 1 && @user.last_sign_out_at.present? && @user.last_sign_out_at <= 2.days.ago && @user.current_sign_in_at >= 1.minutes.ago popular_in(@user.last_sign_out_at, @user.last_sign_in_at).limit(6).includes(:hash_tags, :user, :owner).to_a else [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recent_feed_items(limit = 100)\n feed_items.order('created_at DESC').limit(limit)\n end", "def profile_feeds(is_current_user = false)\n res = @user.contents.includes(:hash_tags, :owner, :user).ignore_daily_devotions\n unless is_current_user\n @user.user_anonymities.pluck(:start_time, :end_time...
[ "0.6626408", "0.6389905", "0.6349433", "0.6326535", "0.62500566", "0.6240445", "0.6235057", "0.61758035", "0.6158916", "0.6110723", "0.6091789", "0.60670924", "0.60657144", "0.6029253", "0.59938765", "0.59336793", "0.5930667", "0.5920468", "0.589976", "0.58955723", "0.5895572...
0.74290466
0
return the popular contents in a period
def popular_in(from, to) popular_content.where(last_activity_time: from..to) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_popular(*date)\n find_popular_in_structure(@content.dig(*date))\n end", "def stats_from_period(period)\n return self.stats.where(:period => period).count\n end", "def popular\n act = self.listings.map {|l| l.activity_id}\n activities = act.map {|a| Activity.find(a)}\n coun...
[ "0.65190464", "0.63274807", "0.6203076", "0.61007583", "0.606174", "0.5990856", "0.59374595", "0.5913491", "0.58438236", "0.5833228", "0.58003515", "0.5758116", "0.5758012", "0.5704866", "0.57021695", "0.56447846", "0.56367916", "0.5635713", "0.5631064", "0.5609499", "0.56066...
0.6472667
1
order by recent created at tag_id: filter content for a specific tag
def recent_content(tag_id = nil) query = [@user.following_shared_contents.to_sql, @user.following_contents.to_sql, @user.contents.to_sql].map{|v| " (#{v}) " }.join(' UNION ') res = Content.from("(#{query}) as contents") .order('contents.created_at DESC') .newsfeed_for(@user.id) res = res.joins(:contents_hash_tags).where('contents_hash_tags.hash_tag_id = ?', tag_id) if tag_id res = res.page(@page).per(@per_page).includes(:user) # res.instance_variable_set(:@total_count, Rails.cache.fetch("cache-total-recent-content-#{@user.id}", expires_in: 1.hours){ res.except(:select, :limit, :offset, :order).count }) #TODO verify hash error res end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sorted_tags\n tags.order('id ASC')\n end", "def tweets_by_tag\n @tag = Tag.find(params[:id])\n @tweets = @tag.tweets.order(created_at: :desc) # order the tweets according to when they were created, with the most recent tweet at the top.\n end", "def show\n @tagname = params[:id].to_s\n @t...
[ "0.6160298", "0.5942049", "0.59141886", "0.58783025", "0.5841075", "0.5811637", "0.5808768", "0.577848", "0.5774392", "0.5696184", "0.5686206", "0.56682163", "0.5666951", "0.5625646", "0.5611365", "0.55982244", "0.55968434", "0.5596261", "0.55810255", "0.55505073", "0.5513944...
0.64833534
0
The trending card has to show the most popular content on the site at that particular moment. It should be same for all the users and irrespective of whether content is made by friend of user or not. You should make this real time by ranking the newest content on the site. Amongst the ranked newest content at that particular time, anonymous posts; posts with more reactions, comments, shares, gets ranked higher on the list.
def public_popular_in(time_range) Content.public_content.popular.where(content_actions: {created_at: time_range}).page(@page).per(@per_page).includes(:hash_tags, :user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_most_popular\n @card_sets = CardSet.order(\"impressions_count DESC\")[0..19]\n end", "def feeds_with_top_tweets\n\n end", "def index\n # start_day = DateTime.now.prev_month\n # populars = Like.where(\"created_at > ?\", start_day).group(:feed_id).order(\"count_feed_id desc\").count(:feed_id)...
[ "0.62438357", "0.62145114", "0.61803305", "0.61167955", "0.5964634", "0.5908032", "0.59076166", "0.58841527", "0.58676225", "0.5837729", "0.58376235", "0.5808934", "0.5734143", "0.5693051", "0.5677139", "0.5666641", "0.56516", "0.5632654", "0.56225896", "0.56164056", "0.56061...
0.53523713
67
return the score calculator select
def score_select_sql '(contents.last_activity_time::timestamp::date) as score_date, (contents.cached_votes_score + contents.shares_count + contents.comments_count - contents.reports_counter) as score_priority' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def score\n calculator.score\n end", "def score_calculator\n OrderedResultCalculator.new(@competition, false)\n end", "def score\n # an answer has a reference to a score. we simply can return\n # the score of that choice (which is defined by the teacher)\n choice.score\n end", "def scor...
[ "0.7449996", "0.6843684", "0.683826", "0.6555083", "0.6551839", "0.6546789", "0.65351063", "0.649656", "0.649656", "0.6477641", "0.64392495", "0.6432761", "0.63912845", "0.6369566", "0.63642085", "0.6352478", "0.634572", "0.63312614", "0.63306904", "0.6319919", "0.6267821", ...
0.0
-1
METHODS FOR BOUGHT ODDS (that the user has bet on)
def calculate_winnings result = 0 self.bookings.each do |booking| if booking.match.status == "FINISHED" if booking.won result += booking.stake * booking.odd.odds else booking.stake ? result -= booking.stake : result end end end return result.round(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def online_special_ballot\n end", "def company_bought(company, buyer); end", "def check_bingo\n\t\t\n\tend", "def award; end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def gounod; end", "def bizet; end", "def bought_by(new_owner)\r\n self.owner = new_owner\r\n ...
[ "0.5896408", "0.585284", "0.58192277", "0.57995814", "0.57507527", "0.5750046", "0.5697624", "0.5652417", "0.5648728", "0.56458974", "0.56325835", "0.56325835", "0.56325835", "0.5615902", "0.55706775", "0.5545176", "0.55250776", "0.55229205", "0.55177295", "0.5432563", "0.542...
0.0
-1
METHODS FOR CREATED ODDS (that the user has created)
def calculate_created_odds_won counter = 0 counter += self.odds.joins(:match).where(matches: {status: 'FINISHED'}).where(odds: {outcome: 'Away'}).where("matches.goals_home_team < matches.goals_away_team").count counter += self.odds.joins(:match).where(matches: {status: 'FINISHED'}).where(odds: {outcome: 'Home'}).where("matches.goals_home_team > matches.goals_away_team").count counter += self.odds.joins(:match).where(matches: {status: 'FINISHED'}).where(odds: {outcome: 'Draw'}).where("matches.goals_home_team = matches.goals_away_team").count return counter end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create; end", "def create; end", "def create; end", "def create; end", "def create\n \n end", "def create\r\n end", "def create\r\n\r\n\r\n end", "def create\n \t\n end", "def create\n \n end", "def create_user\n # provide the interface asking for name, destination and dura...
[ "0.7304219", "0.7304219", "0.7304219", "0.7304219", "0.7158937", "0.7098668", "0.7081323", "0.7062805", "0.7025147", "0.69980055", "0.699789", "0.6952472", "0.6952472", "0.6952472", "0.6906203", "0.6906203", "0.68438673", "0.68438673", "0.68438673", "0.68438673", "0.68438673"...
0.0
-1
GET /api/v1/graphs GET /api/v1/graphs.json
def index @api_v1_graphs = Api::V1::Graph.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_graphs_data\n service_response = DashboardManagement::GetGraphsData.new(params).perform\n\n if service_response.success?\n render :json => service_response.data\n elsif\n service_response.http_code = 404\n render_api_response(service_response)\n end\n end", "def index\n @gr...
[ "0.7725691", "0.7653633", "0.7399759", "0.73251146", "0.69971234", "0.6990866", "0.69184864", "0.66235274", "0.66197103", "0.66169757", "0.65473115", "0.6466313", "0.6465362", "0.6442774", "0.6440801", "0.6385612", "0.63670546", "0.63272965", "0.6316742", "0.6244747", "0.6192...
0.807319
0
GET /api/v1/graphs/1 GET /api/v1/graphs/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @api_v1_graphs = Api::V1::Graph.all\n end", "def index\n @graphs = Graph.all\n end", "def get_graphs_data\n service_response = DashboardManagement::GetGraphsData.new(params).perform\n\n if service_response.success?\n render :json => service_response.data\n elsif\n service...
[ "0.8017534", "0.7332328", "0.7323125", "0.7199046", "0.7095376", "0.67637765", "0.6666292", "0.6648659", "0.66473055", "0.66353106", "0.6527443", "0.644544", "0.6401183", "0.62639636", "0.6236526", "0.62171185", "0.61735624", "0.6165963", "0.6156656", "0.61091524", "0.6101903...
0.0
-1
POST /api/v1/graphs POST /api/v1/graphs.json
def create @api_v1_graph = Api::V1::Graph.new(api_v1_graph_params) respond_to do |format| if @api_v1_graph.save format.html { redirect_to @api_v1_graph, notice: 'Graph was successfully created.' } format.json { render :show, status: :created, location: @api_v1_graph } else format.html { render :new } format.json { render json: @api_v1_graph.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @graph = Graph.new(graph_params)\n\n respond_to do |format|\n if @graph.save\n format.html { redirect_to @graph, notice: 'Graph was successfully created.' }\n format.json { render action: 'show', status: :created, location: @graph }\n else\n format.html { render ac...
[ "0.67985654", "0.66915673", "0.6688425", "0.65477103", "0.647379", "0.64457285", "0.6404164", "0.6401438", "0.63896036", "0.63079774", "0.6295759", "0.625981", "0.6167605", "0.6076818", "0.6039997", "0.6008446", "0.6007045", "0.59372455", "0.5891869", "0.58862734", "0.5878463...
0.6743665
1
PATCH/PUT /api/v1/graphs/1 PATCH/PUT /api/v1/graphs/1.json
def update respond_to do |format| if @api_v1_graph.update(api_v1_graph_params) format.html { redirect_to @api_v1_graph, notice: 'Graph was successfully updated.' } format.json { render :show, status: :ok, location: @api_v1_graph } else format.html { render :edit } format.json { render json: @api_v1_graph.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @graph.update_attributes_from_request(update_params)\n head :no_content\n end", "def update\n respond_to do |format|\n if @graph.update(graph_params)\n format.html { redirect_to @graph, notice: 'Graph was successfully updated.' }\n format.json { head :no_content }\n ...
[ "0.70027006", "0.66642237", "0.65367174", "0.63618875", "0.63520855", "0.63027775", "0.6169927", "0.61608464", "0.6157715", "0.61464256", "0.61087024", "0.6080535", "0.60788774", "0.6063443", "0.59740096", "0.5950415", "0.59375876", "0.58936626", "0.5881226", "0.58564943", "0...
0.7097672
0
DELETE /api/v1/graphs/1 DELETE /api/v1/graphs/1.json
def destroy @api_v1_graph.destroy respond_to do |format| format.html { redirect_to api_v1_graphs_url, notice: 'Graph was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @graph.destroy\n\n respond_to do |format|\n format.html { redirect_to graphs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @graph.destroy\n respond_to do |format|\n format.html { redirect_to graphs_url }\n format.json { head :no_content }\...
[ "0.7720642", "0.7696479", "0.75280964", "0.7278515", "0.7264083", "0.71896666", "0.7185668", "0.7183429", "0.71443653", "0.70227313", "0.6989473", "0.6829833", "0.6791626", "0.6758628", "0.674047", "0.6714944", "0.6688358", "0.66641724", "0.66641724", "0.66641724", "0.6664172...
0.80842793
0
Use callbacks to share common setup or constraints between actions.
def set_api_v1_graph @api_v1_graph = Api::V1::Graph.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.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def api_v1_graph_params params.fetch(:api_v1_graph, {}) 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.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.629117...
0.0
-1
Adds the passed employee to the company employee list
def hire_employee(employee) @employees << employee end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def \n # Adds the passed employee to the company employee list\n def hire_employee(employee)\n self.employees\n @employees\n end", "def add_as_employee\n \tputs \"Called for new employee\"\n end", "def add_a_company_from_the_list(company_name)\n self.companies << Company.find_by(name: company_nam...
[ "0.8339331", "0.6958814", "0.69253546", "0.66866696", "0.6654511", "0.65498346", "0.63898826", "0.6178842", "0.6141167", "0.60884887", "0.60786813", "0.60774946", "0.602282", "0.5998668", "0.5975492", "0.58867174", "0.5867605", "0.5859508", "0.58593744", "0.5773638", "0.57686...
0.7927917
1
Removes the passed employee from the company employee list
def fire_employee(employee) @employees.reject! {|employ| employ.employee_id == employee.employee_id} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_staff(employee)\n employee = Employee.find(employee.id)\n employee.delete!\n end", "def destroy\n @company = Company.find(params[:company_id]) \n @employee = @company.employees.find(params[:id])\n \n @employee.destroy\n respond_to do |format|\n format.html { redirect_to co...
[ "0.737837", "0.6771567", "0.66117066", "0.6452416", "0.6293485", "0.6255084", "0.6151475", "0.61221737", "0.60958266", "0.60911804", "0.6074265", "0.60177386", "0.5989681", "0.5978626", "0.5975921", "0.5970905", "0.5969001", "0.59599185", "0.59538823", "0.59092134", "0.589513...
0.7073252
1
GET /leads GET /leads.json
def index @leads = Lead.upcoming .includes(:updates, :agents, :agent) .order(created_at: :desc) .page(params[:page]) .per(50) respond_to do |format| format.html # index.html.erb format.json { render json: @leads } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_leads(opts = {})\n data, status_code, headers = get_leads_with_http_info(opts)\n return data\n end", "def index\n @leads = Lead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leads }\n end\n end", "def get_leads_with_http_inf...
[ "0.7782497", "0.76061714", "0.7103633", "0.7063612", "0.7063612", "0.7009838", "0.70090014", "0.6882662", "0.67997116", "0.67951083", "0.6782454", "0.6772152", "0.6726303", "0.67129517", "0.6608653", "0.6442716", "0.62777555", "0.6243289", "0.62082773", "0.6153388", "0.610647...
0.7363691
2
GET /leads/1 GET /leads/1.json
def show @agents = Agent.employees.order('created_at ASC') respond_to do |format| format.html # show.html.erb format.json { render json: @lead } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @leads = Lead.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leads }\n end\n end", "def index\n @leads = Lead.upcoming\n .includes(:updates, :agents, :agent)\n .order(created_at: :desc)\n ...
[ "0.7621", "0.71967936", "0.709088", "0.69814336", "0.69814336", "0.6980588", "0.6943444", "0.69328177", "0.6924294", "0.6831734", "0.67984235", "0.6785623", "0.6537891", "0.65375596", "0.65359616", "0.6486458", "0.64575225", "0.64314413", "0.63917404", "0.6342103", "0.6340278...
0.63092875
22
GET /leads/new GET /leads/new.json
def new respond_to do |format| format.html # new.html.erb format.json { render json: @lead } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_lead\n @lead = Lead.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lead }\n end\n end", "def new\n @lead = Lead.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lead }\n end\n end",...
[ "0.80469465", "0.80036056", "0.7612746", "0.76119363", "0.74693483", "0.74184495", "0.7277592", "0.72705835", "0.72517794", "0.7219594", "0.7210759", "0.71703994", "0.71595466", "0.71595466", "0.7134896", "0.71134186", "0.71134186", "0.7053873", "0.70510554", "0.7042961", "0....
0.76859534
2
POST /leads POST /leads.json
def create if @lead.save respond_to do |format| format.html do if can? :read, Lead redirect_to @lead, notice: 'Lead Created!' else redirect_to contact_path, notice: 'An agent will follow up with you soon.' end end format.json { render json: @lead, status: :created, location: @lead } end else respond_to do |format| format.html { render action: "new" } format.json { render json: @lead.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(lead)\n validate_type!(lead)\n\n attributes = sanitize(lead)\n _, _, root = @client.post(\"/leads\", attributes)\n\n Lead.new(root[:data])\n end", "def create\n @lead = current_user.leads.build(params[:lead])\n\n respond_to do |format|\n if @lead.save\n format....
[ "0.70162195", "0.6988889", "0.69738215", "0.6810859", "0.6682621", "0.66040474", "0.65756524", "0.649473", "0.6423695", "0.63496786", "0.6343331", "0.6336863", "0.63212484", "0.62086904", "0.6135985", "0.6135985", "0.6124143", "0.6081969", "0.60774946", "0.60716045", "0.60512...
0.62829643
13
PUT /leads/1 PUT /leads/1.json
def update respond_to do |format| if @lead.update_attributes(lead_params) format.html { redirect_to @lead, notice: 'Lead was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @lead.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @lead = current_user.leads.find(params[:id])\n\n respond_to do |format|\n if @lead.update_attributes(params[:lead])\n format.html { redirect_to @lead, :notice => 'Lead was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :ac...
[ "0.67734313", "0.67483133", "0.66518134", "0.6645375", "0.653518", "0.6462796", "0.6375053", "0.62968063", "0.62707996", "0.6241587", "0.62352675", "0.6214622", "0.61351895", "0.6128944", "0.61150837", "0.6108898", "0.6095091", "0.6095091", "0.6095091", "0.60325646", "0.60131...
0.64391816
6
DELETE /leads/1 DELETE /leads/1.json
def destroy @lead.destroy respond_to do |format| format.html { redirect_to leads_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @lead = Lead.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to leads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead = Lead.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.h...
[ "0.73097557", "0.73097557", "0.7196059", "0.71081406", "0.7048643", "0.6896236", "0.6896236", "0.6896236", "0.6896236", "0.6872066", "0.68553", "0.6840958", "0.6826918", "0.6818553", "0.678036", "0.67576575", "0.67369866", "0.67098886", "0.67066383", "0.67032105", "0.669834",...
0.7155419
3
Read lines (list/array of string) and add them to the table, setting row names and row fields. The first row is assumed to be the header and ignored if the header has been set (the case with merge/concat tables).
def read_lines lines, options = {} table_apply = TableApply.new(options) header = table_apply.parse_header(lines[0], options) Validator::valid_header?(header, @header) # compare against older header when merging column_index,header = table_apply.column_index(header) # we may rewrite the header @header = header if not @header newheader = @header[1..-1] # parse the rest prev_line = newheader (lines[1..-1]).each_with_index do | line, line_num | rowname, data_fields = table_apply.parse_row(line_num, line, newheader, column_index, prev_line, options) if data_fields @rownames << rowname if not options[:with_rownames] # otherwise doubles rownames @rows << data_fields if data_fields end prev_line = data_fields end return @rownames,@rows end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_row_data(headers, row)\n # Hash of field values\n fields = {}\n\n # List of alternate spellings found in current row\n alt_spellings = []\n\n # Related words for current row\n see_also = []\n\n # List of hashes of source data for current row\n sources = []\n\n ...
[ "0.62547827", "0.5952414", "0.5909689", "0.58332336", "0.5827793", "0.57584494", "0.5697398", "0.5669024", "0.56660134", "0.56534654", "0.5653198", "0.5651283", "0.5649592", "0.56240034", "0.5584674", "0.5566309", "0.5563567", "0.5551987", "0.5546737", "0.55300754", "0.552411...
0.7848728
0
Find a record by rowname and return the fields. Empty fields are nils.
def find_fields rowname row = row_by_name(rowname) fields = (row ? row.fields : []) # fill fields with nil to match header length # say header=5 fields=2 fill=2 (skip rowname) fields.fill(nil,fields.size,header.size-1-fields.size) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_rows(field_name, record_id) \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_name} WHERE #{field_name} = #{record_id}\")\n \n return self.results_as_objects(results) \n end", "def search_rows(field_name, input) \n results = CONNECTION.execute(\"SELECT * FROM #{self.table_na...
[ "0.7456607", "0.6485828", "0.60588884", "0.60141444", "0.58458763", "0.58333576", "0.5814258", "0.5807388", "0.5791286", "0.5770369", "0.5761502", "0.5672182", "0.56644034", "0.56513304", "0.56345457", "0.5624395", "0.559037", "0.5585519", "0.5583838", "0.5572891", "0.5550982...
0.7392044
1
Returns UUIDs of existing analyses. Returns UUIDs of existing analyses.
def get_enclaves(opts = {}) data, _status_code, _headers = get_enclaves_with_http_info(opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analysis_list_for_comparison(selected_analysis_ids)\n analyses = []\n Analysis.all.each do |analysis|\n unless selected_analysis_ids.index(analysis.id.to_s)\n analyses << analysis\n end\n end\n return analyses\n end", "def get_analysis_outputs(analysis_name, visualization_name=n...
[ "0.53981704", "0.5386689", "0.52579975", "0.52346635", "0.51474774", "0.5063719", "0.49321067", "0.49101204", "0.4903911", "0.4893182", "0.48903605", "0.4855237", "0.4836862", "0.48333636", "0.4831092", "0.4831092", "0.4776956", "0.47475573", "0.4692231", "0.4692231", "0.4649...
0.0
-1
Returns UUIDs of existing analyses. Returns UUIDs of existing analyses.
def get_enclaves_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EnclaveServiceApi.get_enclaves ...' end # resource path local_var_path = '/enclaves' # query parameters query_params = opts[:query_params] || {} query_params[:'created'] = opts[:'created'] if !opts[:'created'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil? query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'Authorization'] = opts[:'authorization'] if !opts[:'authorization'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:body] # return_type return_type = opts[:return_type] || 'File' # auth_names auth_names = opts[:auth_names] || [] new_options = opts.merge( :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: EnclaveServiceApi#get_enclaves\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analysis_list_for_comparison(selected_analysis_ids)\n analyses = []\n Analysis.all.each do |analysis|\n unless selected_analysis_ids.index(analysis.id.to_s)\n analyses << analysis\n end\n end\n return analyses\n end", "def get_analysis_outputs(analysis_name, visualization_name=n...
[ "0.53999895", "0.5388654", "0.5258045", "0.5235734", "0.5148866", "0.50634253", "0.49323067", "0.49110147", "0.4903252", "0.48940668", "0.48913836", "0.48559904", "0.4836585", "0.48334405", "0.48316672", "0.48316672", "0.47780722", "0.4749975", "0.46915066", "0.46915066", "0....
0.0
-1
Denglu api host, default to
def host @host ||= 'http://open.denglu.cc' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def host\n conf['api']['host']\n end", "def host\n \"http://api.lvh.me:3000\"\n end", "def host\n @host || \"https://api.digitalriver.com/\"\n end", "def api_host #:nodoc:\n API_URI\n end", "def host\n @host || Sapience.config.host\n end", "def host; end", "def host; en...
[ "0.7863586", "0.7628773", "0.75186956", "0.7461454", "0.742789", "0.7192306", "0.7192306", "0.7192306", "0.7192306", "0.7192306", "0.7192306", "0.7192306", "0.7192306", "0.7192306", "0.711119", "0.7106801", "0.7099089", "0.7044356", "0.7012463", "0.69600606", "0.69502777", ...
0.7813256
1
Denglu api version, no used now
def version @version ||= '1.0' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def version; end", "def ver...
[ "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "0.7294671", "...
0.0
-1
Denglu api rquest sign method, only support md5
def sign_type @sign_type ||= :md5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign(req, ts)\n md5_salt = \"ifxy8jvzf1q0f9uz\"\n body = \"#{CGI.escape(req)}#{ts}#{md5_salt}\"\n # md5.update body.upcase\n sign = Digest::MD5.hexdigest body\n sign.upcase\nend", "def sign_key; end", "def sign(message); end", "def signature\n # Remove 'sha_sign' key from request params and con...
[ "0.74845874", "0.7372473", "0.71271366", "0.70815223", "0.70594686", "0.70594686", "0.7058359", "0.70272374", "0.70204586", "0.7018726", "0.7005727", "0.6984091", "0.69178987", "0.69106704", "0.6791169", "0.67847025", "0.6774681", "0.6728385", "0.6712281", "0.6668443", "0.662...
0.65331465
33
Inorder traversal without allowance of duplicate numbers.
def insert(data) current_node = @root if @root while current_node != nil if data < current_node.data && current_node.left == nil current_node.left = TreeNode.new(data) elsif data > current_node.data && current_node.right == nil current_node.right = TreeNode.new(data) elsif data < current_node.data current_node = current_node.left elsif data >= current_node.data current_node = current_node.right else return end end else @root = TreeNode.new(data) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inorder\n inorder_traversal(@root, [])\n end", "def inorder\n return inorder_recursion(current = @root, tree = [])\n end", "def inorder\n array = []\n return [] if @root.nil?\n current = @root\n\n return inorder_recursive(current, array)\n end", "def inorder\n return [] if @root =...
[ "0.7199349", "0.7024316", "0.69626594", "0.6930271", "0.6916963", "0.6872379", "0.6802421", "0.67921895", "0.67873156", "0.675436", "0.6670824", "0.66661865", "0.6622766", "0.6622766", "0.6622766", "0.6622766", "0.6622766", "0.6622766", "0.6622766", "0.6595145", "0.65946114",...
0.0
-1
Generates list of tag names matching parameter term. Used by jqueryui/autocomplete.
def autocomplete_name @tags = Tag.where(["name ILIKE ?", "*#{params[:term]}*".to_escaped_for_sql_like]).order('LENGTH(name)', :name).limit(20).pluck(:name) respond_to do |format| format.json { render :json => @tags } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tags\n klass = Object.const_get(\"Concepts\").const_get(params[:tag_class])\n results = klass.search_for_label_starting_with(params[:term]).map(&:label)\n render :json => results.uniq.sort\n end", "def suggest\n unless request.post?\n render :nothing=>true\n return\n end\n tags =...
[ "0.696582", "0.6893298", "0.64016736", "0.6355518", "0.62735856", "0.62722635", "0.62722635", "0.62694097", "0.6263004", "0.6263004", "0.6263004", "0.6253126", "0.6251969", "0.62506187", "0.6241277", "0.6227749", "0.6209689", "0.6201785", "0.6150374", "0.61028856", "0.6060025...
0.6634328
2
Add methods to be used by unit tests here
def make_account(email: 'jdoe@emmoco.com', password: 'aba456', admin: false, first: 'John', last: 'Doe') # system admin, not lock admin # account is a devise model, must set properties at instance level and not in constructor Account.create!(:first_name => first, :last_name => last, :email => email, :password => password, :password_confirmation => password, :admin => admin, :confirmed_at => DateTime.now.utc.iso8601(9), :confirmation_sent_at => DateTime.now.utc.iso8601(9) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_tests\n end", "def tests; end", "def tests; end", "def testing\n # ...\n end", "def test_method\n end", "def test_case; end", "def test_added_methods\r\n assert_respond_to @default_user, :roles\r\n assert_respond_to @default_user, :has_role?\r\n \r\n assert_resp...
[ "0.74740875", "0.74509597", "0.74509597", "0.7287391", "0.7213313", "0.70211905", "0.69240856", "0.68980217", "0.68980217", "0.68951887", "0.67803216", "0.6682979", "0.6682979", "0.6680286", "0.66583264", "0.6652276", "0.66501504", "0.66501504", "0.66473943", "0.6642925", "0....
0.0
-1
XXX replace with this everywhere! This isn't quite our reply format, but it parses, can be compared to db, and tests enough resolution.
def comparable_payload_date_now DateTime.now.utc.iso8601(3) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_response_packet(data_received)\n begin\n answers_received = Array.new\n transaction_ID, flags, questions, answers, authority_rrs, additional_rrs, lookup_host, query_type, query_class = data_received.unpack(\"S>S>S>S>S>S>Z*S>S>\")\n \n offset = (2 * 6) + (lookup_host.length + 1) + (2 * 2)\n ...
[ "0.6480944", "0.5903921", "0.5749201", "0.57132095", "0.57061553", "0.5660886", "0.56454694", "0.56447446", "0.56385064", "0.5632017", "0.56051266", "0.5601346", "0.5596882", "0.5570422", "0.55677944", "0.5562987", "0.5560064", "0.55482554", "0.55390996", "0.5535185", "0.5533...
0.0
-1
user must be owner/admin
def make_guest_key(lock, guest_email, user) key = Key.create_new_key(lock.id, guest_email, user) # permission error return key if (key.class == Hash) start = 60*60 tc = TimeConstraint.create!(:key_id => key.id, :start_offset=> start.to_s, :end_offset => (start*2).to_s, :monday => true, :tuesday => true, :wednesday => true, :thursday => true, :friday => false, :saturday => true) # update seq_no key.reload return key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_is_owner_or_admin?\n record.reading.user == user || user.try(:admin?)\n end", "def owner_only\n unless current_user == @organism.owner\n flash[:alert] = \"Vous ne pouvez executer cette action car vous n'êtes pas le propriétaire de la base\"\n redirect_to admin_organisms_url\n end\n\n...
[ "0.7479658", "0.74450374", "0.7436773", "0.74187815", "0.7392298", "0.73575556", "0.73540586", "0.7335592", "0.7272078", "0.7272078", "0.72628516", "0.72593427", "0.72109", "0.7205841", "0.7193228", "0.7179591", "0.715416", "0.71513206", "0.71506566", "0.71358436", "0.7132151...
0.0
-1
Make a key for owner/admin
def make_key(lock, user) # sharer_user_id faked key = make_guest_key(lock, user.account.email, user) return key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_key\n self.key = Digest::MD5.hexdigest(self.official_id.to_s + self.sent_to_email)\n end", "def generate_key; end", "def create_key(arg = nil)\n set_or_return(\n :create_key,\n arg,\n kind_of: [ TrueClass, FalseClass ]\n )\n end", "def owner_key_name\n ...
[ "0.66664803", "0.66499746", "0.6577757", "0.6445111", "0.64109486", "0.63829887", "0.6367881", "0.63670015", "0.6305508", "0.62922543", "0.62316364", "0.62170774", "0.6209117", "0.6208473", "0.61997443", "0.61927915", "0.61927915", "0.6179158", "0.6152233", "0.6140616", "0.61...
0.69425344
0
XXX remove ua_token here
def make_user_device(user, device, ua_token = '64ce3cbfb716c0eb61adc2d6da1f2781e8b74d39b49c1e521108db9109b1be35') @@user_device_start_count += 1 UserDevice.create!(user_id: user.id, device_id: device.id, name: "Test Device", ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_agent; end", "def user_agent; end", "def user_agent; end", "def user_agent=(user_agent); end", "def user_agent(vendor: T.unsafe(nil)); end", "def ua\n @ua ||= begin\n request.env['HTTP_USER_AGENT'].downcase\n rescue\n ''\n end\n end", "def bot_user_agent(vendor: T.unsafe(ni...
[ "0.6631617", "0.6631617", "0.6631617", "0.6398644", "0.62567353", "0.61779976", "0.6041781", "0.5976474", "0.59256065", "0.58829296", "0.58829296", "0.5876162", "0.5858558", "0.58558714", "0.58280915", "0.58065057", "0.5762385", "0.5761491", "0.57579017", "0.57577926", "0.573...
0.0
-1
Extra was thought to be required on any event that sends email. Found another way this time...
def add_extra_data(data) =begin data[:extra] = { password: 'mypass', host: 'myhost', port: 'myport', } =end return data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skip_email_changed_notification!; end", "def missed\n EventMailer.missed\n end", "def inbound_email; end", "def inbound_email; end", "def reserved_mail\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end", "def send_welcome_email\n #if Rails.env.production?\n if email.presen...
[ "0.6834109", "0.6686461", "0.6501137", "0.6501137", "0.6419938", "0.64082956", "0.63711274", "0.6359058", "0.6348391", "0.6337836", "0.6329679", "0.62794626", "0.62624663", "0.62434435", "0.6241681", "0.622194", "0.62172574", "0.6212257", "0.6203063", "0.6203063", "0.6203063"...
0.0
-1
Event submission order not specified.
def put_event_last(last_type) evs = Event.all.order('created_at ASC') @@ev_first = evs[evs.length-2] @@ev_second= evs[evs.length-1] if (@@ev_first.event_type == last_type) ev = @@ev_first @@ev_first = @@ev_second @@ev_second = ev return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def event_requirement; end", "def interprete_submission event\n case event.utd\n when \"Ci\"\n interprete_submission_control_input event\n when \"Co\"\n interprete_submission_control_output event\n when \"Bi\"\n interprete_submission_bulk_input event\n when \"Bo\"\n ...
[ "0.6393541", "0.59873784", "0.5905741", "0.5812615", "0.5812615", "0.57550824", "0.57523715", "0.561019", "0.5498859", "0.54958785", "0.545236", "0.5450552", "0.5412113", "0.53945774", "0.5394409", "0.53931963", "0.53931963", "0.53931963", "0.53751355", "0.535871", "0.5349173...
0.0
-1
XXX add expected_msg to all check_response(errorcode) calls! Once that's done, expected_msg default can be :SUCCESS.
def check_response(code = :success, expected_msg = nil, line = nil) line = line ? " [*_test:" + line.to_s + "]" : "" assert_response code, "expected " + code.to_s + ", server response: " + response.body.to_s + line if (code.class == Symbol) # Not sure why this list isn't the right one: (has :ok instead). Should fix once... Rack::Utils::SYMBOL_TO_STATUS_CODE[:success] = 200 Rack::Utils::SYMBOL_TO_STATUS_CODE[:redirect] = 302 code = Rack::Utils::SYMBOL_TO_STATUS_CODE[code] end return if (code == 302) # redirect, html body body = JSON.parse(response.body) #Success payloads should contain one of these. assert (body[0] && body[0]["server_time"]) || body["status"] == code || body["status"] == "destroyed" || body["server_time"] || body["device_id"] || body["key_data"] || body["authtoken"], "success payload not one of the usual patterns" + line return if ! expected_msg if expected_msg.class == Symbol expected_msg = ApplicationController.MESSAGES[expected_msg] assert expected_msg != nil, "oops, your check_response passed a non-existant expected message symbol!" + line end if (code == 200) return assert body["message"] = expected_msg, "wrong message" + line end # Simple generic check against message template to see that we got # the right one - there will be at least 12 chars without a # substitution at either start or end in all our MESSAGES strings. # Or a whole string without formatting anywhere (when array of validation errors is stringified). len = 12 ret_msg = body["error"] # Handle short expected strings (INVALID_PARAM) assert ret_msg.start_with?(expected_msg.first(len)) || ret_msg.end_with?(expected_msg.last(len)) || ret_msg.include?(expected_msg), "reply error message doesn't match:\"" + ret_msg + "\"!=\""+ expected_msg + "\"" + line end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status(response, expected_status_code, failure_message)\n if response.status == expected_status_code\n true\n else\n fail(\"#{failure_message}. Response: #{response.status} #{response.reason_phrase} #{response.body}\")\n end\n end", "def status(response, expected_s...
[ "0.7065888", "0.70651686", "0.6792315", "0.66696703", "0.65302384", "0.6525615", "0.64335215", "0.6397393", "0.6380532", "0.6358957", "0.6317961", "0.6306827", "0.6301938", "0.6299585", "0.6262045", "0.6201875", "0.6183555", "0.61627895", "0.61594754", "0.61509717", "0.613373...
0.7594521
0
Checks that correct devices are sent notifications, and correct device endpoints via notification.push_result if present (i.e. called from model test, not controller)
def check_notification_devices(notification, user, num_devices, from_model = false) # Assume we don't have tests with endpoint_disabled_at or missing endpoint_arn, confirm that expected count is correct. destinations = user.active_devices.count assert_equal num_devices, destinations, "expected " + num_devices.to_s + " devices to be notified, only " + destinations.to_s + " active devices exist" assert_equal num_devices, notification.devices_tried, "expected " + num_devices.to_s + " devices to be notified, only " + notification.devices_tried.to_s + " were attempted (AWS endpoint_disabled/arn missing)" assert_equal num_devices, notification.devices_sent, "expected " + num_devices.to_s + " devices to be notified, only " + notification.devices_sent.to_s + " were notified" attempts = notification.push_result if !attempts assert !from_model, "model notification test did not find push_result" return end assert_equal num_devices, attempts.length, "expected " + num_devices.to_s + " devices to be notified, only " + attempts.length.to_s + " were reported" # Since we're re-creating the device often, it's being enabled each time # If that changes, this is an alternative assert # assert_equal "EndpointDisabled", attempts.first.flatten[1] # Failure, but not our fault and shows we tried attempts.each do |notice| # Show that we got some sort of response back for AWS assert notice.keys.first.start_with?("arn:aws:sns"), "not a valid ARN detected" # XXX what else to check? Get device list from user, and check: # assert_equal notice.keys.first, (some) device.endpoint_arn # Then remove extra check in notification_test.rb end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_status(result, devicelist)\t\n \t\tif result[\"success\"] == 1\n\t\t\tstatusmsg = \"Push notification SUCCESSFUL\"\n\t\t\tif result[\"results\"][0].count > 1\n\t\t\t\t# send_email_to_master?: Notification processed but with warning on fcm_id\n\t\t\t\tstatusmsg = \"Push notification SUCCESSFUL, but Regist...
[ "0.6918698", "0.63289815", "0.6166253", "0.6154866", "0.6012139", "0.6011295", "0.5970822", "0.5891662", "0.58732855", "0.5841871", "0.58186024", "0.57381624", "0.5687575", "0.56712115", "0.55881894", "0.55844015", "0.55818504", "0.55770606", "0.5575946", "0.55744576", "0.552...
0.7725414
0
Check that lock_data is now in the db
def check_lock_db_by_id(lock_id, lock_data) lock = Lock.where(:id => lock_id) assert_equal 1, lock.count, "check_lock_db_by_id: wrong lock count" check_data(lock.first, lock_data) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def acquire_lock\n\t\t@@logger.info { \"Acquiring a lock in the database.\" } if have_logger?\n\t\tTournament.dataset.filter(:id => self.id, :locked => false).update(:locked => true) != 0\n\tend", "def return_lock\n\t\t@@logger.info { \"Returning the lock to the database.\" } if have_logger?\n\t\tTournament.data...
[ "0.6986449", "0.67807335", "0.6645532", "0.64968604", "0.64473575", "0.6432631", "0.63897717", "0.6381794", "0.6379547", "0.6319864", "0.6314433", "0.63089794", "0.62979865", "0.6289556", "0.6266611", "0.62590396", "0.62465215", "0.62203634", "0.62104046", "0.61889875", "0.61...
0.71256036
0
Compare DB results against the POST/PUT request data. If PUT, caller has not refreshed model since putting. (Some wasted overhead in POST case) pre_record is set to nil, in case no previous record existed (:create) and to not break other tests outside of lock calling check_data Dates are iso8601(3) until we monkey patch datetime.to_json. TBD: make this report all errors like check_reply TBD: pass test description
def check_data(model, # not-yet-reloaded db model ref, # symbol-value hash of reference data ignore = nil, # array of symbol field names to ignore (even if in ref param) approx_time = false, # fuzzy .now time compare disallow = nil, # array of symbol field names that must not be present (must be nil in model/db) Arbitrarily overrides ref fields. line = nil) pre_record = model.dup model.reload untouched_fields = model.class.accessible_attributes.to_a - ref.stringify_keys.keys line = line ? " [*_test:" + line.to_s + "]" : "" check_valid_field = lambda do |ref| field = ref[0] # wierd - db fields can be accessed as model[field], # attr_accessor fields can't. So must distinguish. # But note this only works when checking the model used to create, # since attr_accessor fields are not persisted. # There might be a less hacky way... dbfield = model.instance_variables.include?(("@" + field.to_s).to_sym) ? model.send(field) : model[field] if (disallow && disallow.include?(field)) if (@@trace) print "check_data checking field is nil: " + model.class.to_s + "." + field.to_s + ": " + dbfield.to_s + line + "\n" end return dbfield == nil ? nil : { expected: nil, actual: dbfield } end if (!ignore || !ignore.include?(field)) ref_val = ref[1] if (@@trace) print "check_data checking: " + model.class.to_s + "." + field.to_s + ": " + dbfield.to_s + "=" + ref_val.to_s + line + "\n" end return ((dbfield.class == ActiveSupport::TimeWithZone) ? # Not checking format here, just value. (approx_time ? # XXX Tighten this back to 1, by passing request time into check_key_event fuzzy_compare_datetime(DateTime.parse(ref_val), dbfield, 6) : equal_normalize_iso8601(ref_val, dbfield.utc.iso8601(3))) : (ref_val.to_s == dbfield.to_s)) ? nil : { expected: ref_val, actual: dbfield } end nil end assert_each_log_results(ref, true, "have wrong values in database" + line, &check_valid_field) #makes sure that other database fields are untouched if pre_record untouched_fields.each do |field| =begin # Turn this on to see what fields might never be checked for being touchable across all tests. # Need a way to filter out dont-care/obsolete fields. if (@@trace) print "check_data checking field was untouched: " + model.class.to_s + "." + field + "\n" end =end assert_equal pre_record.read_attribute(field), model.read_attribute(field), ("*** " + field + line + ":") end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_key_data(record, ref_data, resp_data,\n exclude = nil, # exclude from db check.\n allow = nil, augment = true, # extra GET /keys items\n disallow = nil, line = nil)\n # XXX validate internally-generated db fields.\n must_exclude = [:time_...
[ "0.5812346", "0.56281394", "0.54641837", "0.54635286", "0.5421807", "0.5413907", "0.52973574", "0.5163757", "0.51561177", "0.515374", "0.51394576", "0.5101692", "0.50815177", "0.5056348", "0.504603", "0.5042999", "0.5042186", "0.50151736", "0.49933058", "0.49924344", "0.49917...
0.6480884
0
Check both db and json reply Note that GET /keys payload has extra dummy fields. ref_data nil when checking GET /keys.
def check_key_data(record, ref_data, resp_data, exclude = nil, # exclude from db check. allow = nil, augment = true, # extra GET /keys items disallow = nil, line = nil) # XXX validate internally-generated db fields. must_exclude = [:time_constraints, :admin] exclude = exclude ? exclude + must_exclude : must_exclude # Allow skipping check_data. if (record && ref_data) check_data(record, ref_data, exclude, nil, disallow, line) end # Allow skipping reply check. if !resp_data return end non_db = [ "bluetooth_address", "first_name", "last_name", "email", "user_display_name", "time_constraints", "lock_time_zone" ] server_time = augment ? [:server_time] : [] # reply splits into two sub-hashes. key_data = resp_data["key_data"] key_info = resp_data["key_info"] assert_not_nil key_data, "key_data present" assert_not_nil key_info, "key_info present" check_reply(json: key_data, model: record, elsewhere: non_db, allow: @@key_data_fields, exclude: ["seq_no"], augment: nil) # id present due to global rule in key_info, but not required check_reply(json: key_info, model: record, elsewhere: non_db, exclude: @@key_data_fields, augment: server_time) assert_equal record.lock.bluetooth_address, key_info["bluetooth_address"], "bluetooth_address" assert_equal record.lock.name, key_info["name"], "name" assert date_match(record.last_access, key_info["last_access"]), "last_access" assert_equal record.user.account.first_name, key_info["first_name"], "first_name" assert_equal record.user.account.last_name, key_info["last_name"], "last_name" assert_equal record.user.account.email, key_info["email"], "email" assert_equal record.user.display_name, key_info["user_display_name"], "user_display_name" assert_equal record.lock.time_zone, key_info["lock_time_zone"], "time_zone" # XXX admin check_key_time_constraints(record, key_data, key_info) #/locks doesn't include the same fields as /keys, so ignore these checks for GET /locks if (!ref_data && augment) # get /keys has extra fields admin = key_info['admin'] auto_generated = key_info['auto_generated'] lock_owner_key = key_info['lock_owner_key'] assert_boolean_equal admin || lock_owner_key, auto_generated, "auto_generated equals admin || lock_owner_key" assert_boolean_equal record.lock.user_id == record.user_id, lock_owner_key, "lock_owner_key equals record.lock.user_id == record.user_id" lu = LocksUser.where(:lock_id => record.lock.id, :user_id => record.user_id) assert_boolean_equal (lu.count > 0) && lu.first.admin, admin, "admin matches LocksUser" # XXX lock_owner_display_name, sharer_display_name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_payload(json, model,\n exclude = nil, # fields that should not be present\n allow = nil, # fields to check, overriding model accessible_attributes. Note: silently ignored if not an accessabie field - use augment!\n augment = [:server_time]) # n...
[ "0.5614489", "0.55604726", "0.554261", "0.551467", "0.54984576", "0.54513955", "0.5385335", "0.53414315", "0.53021795", "0.5284166", "0.52521044", "0.52485174", "0.5227316", "0.52241814", "0.51784825", "0.51757485", "0.51425743", "0.51400083", "0.51150113", "0.5114529", "0.51...
0.68892664
0
Returns true if date string is valid payload string and is "close" to now ("close" is ultimately a security check, within lock/server time accuracy) unused
def check_new_date(date, field_name) dt = parse_datetime_string(date) if dt == nil return false end check_now_date(dt, field_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_date?(date_string)\n if date_string.match(/\\d{4}-\\d{2}-\\d{2}/)\n begin\n Date.parse(date_string)\n return true\n rescue ArgumentError\n return false\n end\n else\n begin\n SycTimeleap::TimeLeap.new.send(date_string)\n return true\n resc...
[ "0.6857888", "0.66395366", "0.6582829", "0.65122426", "0.65047514", "0.6421318", "0.6384514", "0.63562286", "0.6334127", "0.6312026", "0.6292565", "0.6242036", "0.6232396", "0.62002903", "0.61661786", "0.6157691", "0.6142606", "0.6136764", "0.6098116", "0.6085142", "0.6066516...
0.6199042
14
Ditto, from date object
def check_now_date(dt, field_name = "date", now = DateTime.now) now = now.utc assert fuzzy_compare_datetime(dt, now, 1), # 1 for testing, not real-world. field_name + " and now are not equal: " + normalize_date(dt) + ", " + normalize_date(now) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_date()\n #This is a stub, used for indexing\n end", "def to_date\n find\n end", "def to_date(dt)\n Date.new(dt.year, dt.month, dt.day)\n end", "def to_date\n ::Date.new(year, month, day)\n end", "def to_date\n @from_date ||= begin\n Date....
[ "0.73726135", "0.70265055", "0.687814", "0.68705773", "0.684838", "0.68167585", "0.6813324", "0.6790094", "0.6781406", "0.67805475", "0.6776669", "0.6776047", "0.6771513", "0.6753767", "0.6746767", "0.6737227", "0.6691597", "0.6674612", "0.66658115", "0.660132", "0.6561077", ...
0.0
-1
validate time_constraints reply against db
def check_time_constraints_payload(record, resp_data) # We never return time_constraints = null assert_equal record.time_constraints.count, resp_data["time_constraints"].count for i in 0..record.time_constraints.count-1 do #puts record.time_constraints[i].to_json #puts resp_data["time_constraints"][i] check_payload(resp_data["time_constraints"][i], record.time_constraints[i], [:key_id, :start_time, :end_time, :start_offset, :end_offset], nil, nil) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_validations_for_time\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time\") if value && (! value.kind_of?(Time))\n end\n end", "def time_collision_validation\n\t\tappointments = Appointment.all\n\n\t\t#if duration...
[ "0.7029831", "0.6711255", "0.6674615", "0.6671239", "0.66067874", "0.6569625", "0.6500645", "0.6485276", "0.64559066", "0.6454577", "0.64332443", "0.63851225", "0.6376364", "0.635773", "0.6343979", "0.63172174", "0.629406", "0.62855357", "0.62593746", "0.6244238", "0.62348974...
0.76533043
0
Check the reply payload against the database. Note that by default this only checks payload fields that come from accessable model atrribute fields, plus server_time. All override arguments are arrays with symbol indices. json is string indices. Old signature, replace with named args check_reply(). TBD: pass test description
def check_payload(json, model, exclude = nil, # fields that should not be present allow = nil, # fields to check, overriding model accessible_attributes. Note: silently ignored if not an accessabie field - use augment! augment = [:server_time]) # non-DB fields to check for existence and format return check_reply(json: json, model: model, exclude: exclude, allow: allow, augment: augment) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_key_data(record, ref_data, resp_data,\n exclude = nil, # exclude from db check.\n allow = nil, augment = true, # extra GET /keys items\n disallow = nil, line = nil)\n # XXX validate internally-generated db fields.\n must_exclude = [:time_...
[ "0.59408534", "0.5215165", "0.5130718", "0.5071094", "0.50513035", "0.49761605", "0.49279323", "0.49270067", "0.49247766", "0.49216127", "0.48596847", "0.48377764", "0.48371542", "0.4828303", "0.48250428", "0.48182714", "0.4808157", "0.47992134", "0.47754818", "0.47660962", "...
0.70843494
0
Check fields like above, but log actual and expected values. Use with check_valid_db_field as the test lambda.
def assert_each_log_results(enumerable, e_is_hash, msg = nil, &test) if !enumerable return nil end failed_elements = Array.new failed_expected = Array.new failed_actual = Array.new enumerable.each do |e| results = test.call(e) if (results != nil) failed_elements << (e_is_hash ? e[0] : e) failed_expected << results[:expected] failed_actual << results[:actual] end end msg = "invalid: #{failed_elements} #{msg}:\nexpected: #{failed_expected}\n actual: #{failed_actual}" raise( MiniTest::Assertion, msg ) unless failed_elements.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_valid(field, *values)\n __model_check__\n values.each do |value|\n o = __setup_model__(field, value)\n if o.valid?\n assert_block { true }\n else\n messages = [o.errors[field]].flatten\n assert_block(\"unexpected invalid field <#{o.class}##{field}>, value: <#{va...
[ "0.6610176", "0.6592786", "0.6394038", "0.60852164", "0.6073407", "0.6069321", "0.6068769", "0.6029218", "0.60098016", "0.60085094", "0.5992325", "0.59732175", "0.58674103", "0.5848211", "0.5847895", "0.57482743", "0.57295996", "0.57236415", "0.570539", "0.56890506", "0.56858...
0.0
-1
Two booleans are effectively equal if one is false and one is nil
def assert_boolean_equal(a, b, msg = nil) assert_equal !a, !b, msg end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def falsy_or_equal? first, second\n (!first && !second) || first == second\n end", "def ==(other)\n other.nil?\n end", "def xor?(bool1, bool2)\n !!bool1 != !!bool2\nend", "def xor?(boolean_one, boolean_two)\n if boolean_one && boolean_two\n false\n elsif boolean_one == false && boolean_two ...
[ "0.74820274", "0.7040151", "0.68291575", "0.6795823", "0.67505723", "0.67234063", "0.66434336", "0.6607449", "0.6605088", "0.6574376", "0.65281427", "0.65078807", "0.64804214", "0.64743644", "0.64743644", "0.64576256", "0.6453094", "0.642227", "0.63753915", "0.6357478", "0.63...
0.6940953
2
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. a = 17.to_s(2) meathod for getting binary value val should be a string
def isPalindromic(val) ln = val.length middle = ln / 2.0 arr = val.split('') 0.upto(middle) do |x| if(arr[x] != arr[ln - x - 1]) then return false end end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base2to10(binary)\n bin_array = binary.chars.reverse\n i = 0\n sum = 0\n while i < bin_array.length\n sum += bin_array[i].to_i*(2**i)\n i+=1\n end\n sum\nend", "def base2to10(binary)\n #split to single digits\n digits = binary.split('').map{|str| str.to_i}.reverse\n #loop through multiply by 2...
[ "0.73721695", "0.7053233", "0.70114464", "0.68919015", "0.67682695", "0.6759019", "0.6677593", "0.66053146", "0.6596396", "0.65664184", "0.65291196", "0.65195626", "0.65107965", "0.6493945", "0.6463598", "0.64528805", "0.64523786", "0.6429031", "0.64070284", "0.6381502", "0.6...
0.0
-1
Copy data in string to a local char array
def initialize(input) initialize__antlrstring_stream() @data = input.to_char_array @n = input.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_chardata( str )\n @dest.characters( str )\n end", "def strcpy(str_src, str_dst)\n (0..(str_src.length - 1)).each do |cpt|\n str_dst[cpt] = str_src[cpt].ord\n end\n end", "def on_chardata(str)\n characters(str)\n end", "def copy(data, ts, te)\n data[ts...te].p...
[ "0.6699414", "0.6145968", "0.61320513", "0.60138637", "0.60138637", "0.6005323", "0.5819964", "0.5525691", "0.54595906", "0.5428591", "0.5357195", "0.5337338", "0.5265475", "0.523339", "0.52123255", "0.52123255", "0.52032214", "0.51803267", "0.5144464", "0.51380986", "0.51147...
0.0
-1
This is the preferred constructor as no data is copied
def initialize(data, number_of_actual_chars_in_array) initialize__antlrstring_stream() @data = data @n = number_of_actual_chars_in_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def constructor; end", "def new(*args) dup.initialize(*args) end", "def initialize(data)\r\n @data = data.dup\r\n end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize(*) end", "def initialize(data=nil)\n super(data)...
[ "0.7837625", "0.75226563", "0.7371936", "0.7360704", "0.7360704", "0.7360704", "0.7360704", "0.7360704", "0.71990854", "0.7159012", "0.71117026", "0.71117026", "0.71117026", "0.71117026", "0.71117026", "0.71117026", "0.71117026", "0.71117026", "0.71117026", "0.71117026", "0.7...
0.0
-1
Reset the stream so that it's in the same state it was when the object was created except the data array is not touched.
def reset @p = 0 @line = 1 @char_position_in_line = 0 @mark_depth = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n @data = nil\n end", "def reset!\n @buffer = buffer.reset!\n end", "def reset\n @buffer.string = @buffer.read; nil\n end", "def reset\n @io = StringIO.new(String.new) # A StringIO with ASCII-8BIT encoding\n\n self\n end", "def rewind\n r = @strea...
[ "0.7335008", "0.7289417", "0.7157586", "0.71102375", "0.7085769", "0.7013993", "0.7010649", "0.6969296", "0.6922089", "0.68911386", "0.67669564", "0.67480785", "0.6743509", "0.671749", "0.6701437", "0.6690454", "0.66567856", "0.66474915", "0.6546687", "0.654247", "0.65187407"...
0.0
-1
Return the current input symbol index 0..n where n indicates the last symbol has been read. The index is the index of char to be returned from LA(1).
def index return @p end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input_to_index(input)\n index = input.to_i - 1\n end", "def input_to_index(input)\n index = input.to_i - 1\n end", "def input_to_index(input)\n index = input.to_i - 1\n end", "def symbol_at(n)\n @symbols ||= LazyArray.new(num_symbols, &method(:create_symbol))\n @symbols[n]&.tap ...
[ "0.63829786", "0.63829786", "0.63829786", "0.6366744", "0.6361213", "0.62964886", "0.62961936", "0.6283901", "0.62632215", "0.6240923", "0.62260044", "0.6221627", "0.62085295", "0.62085295", "0.62067026", "0.619711", "0.61892104", "0.6171784", "0.6142264", "0.6130304", "0.611...
0.0
-1
consume() ahead until p==index; can't just set p=index as we must update line and charPositionInLine.
def seek(index) if (index <= @p) @p = index # just jump; don't update stream state (line, ...) return end # seek forward, consume until p hits index while (@p < index) consume end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reconsume\n @pos -= 1 if @pos > 0\n end", "def consume_seek(pos)\n orig = consume_pos\n if pos < 0\n pos = consume_pos + pos\n pos = 0 if pos < 0\n end\n @consume_pos = pos\n orig\n end", "def consume\n @current = @tokens[@pos]\n @pos += 1 if @current\n @cur...
[ "0.6558713", "0.6441859", "0.6400765", "0.63929045", "0.62788886", "0.61726075", "0.6081983", "0.59819955", "0.5888392", "0.58780134", "0.5840802", "0.5819478", "0.58149654", "0.5768579", "0.57501805", "0.57332927", "0.57199526", "0.5700264", "0.56755614", "0.5669725", "0.566...
0.7371428
0
Hit the CollegiateLink API directly, for when using the app that is deployed on the stugov server. :nocov:
def hit_api_direct # CollegiateLink API needs some data to be hashed and sent for auth purposes time = (Time.now.to_f * 1000).to_i.to_s ipaddress = ENV['cl_ipaddress'] apikey = ENV['cl_apikey'] privatekey = ENV['cl_privatekey'] random = SecureRandom.hex hash = Digest::SHA256.hexdigest(apikey + ipaddress + time + random + privatekey) url = ENV['cl_apiurl'] + @resource + "?time=" + time + "&apikey=" + apikey + "&random=" + random + "&hash=" + hash + @url_options return send_request(url, nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_link\n authenticated_client.link test_link_full_name\nend", "def url_api\n Guidebox\n end", "def call_api\n @client.build_url\n @client.get\n assign_data\n end", "def call\n \n # create URI::HTTPS object using the url of the API \n url = URI(\"https://api.covid19api.com/s...
[ "0.5981596", "0.5927176", "0.57892096", "0.57103014", "0.5632172", "0.56240344", "0.5462497", "0.5448014", "0.5444466", "0.54260135", "0.5387464", "0.5382508", "0.5373295", "0.5339043", "0.5316908", "0.52996576", "0.52938086", "0.52938086", "0.5285804", "0.5272961", "0.526238...
0.7466838
0
:nocov: Hit the CollegiateLink API by using a script located at stugov_api_base_url, for when using the app from localhost. :nocov:
def hit_api_local # Authentication info pass = ENV['stugov_api_user'] priv = ENV['stugov_api_pass'] # Our base URL hosted on stugov's server base_url = ENV['stugov_api_base_url'] # We make a sha256 hash of this in binary format, then base64 encode that digest = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new("sha256"), priv, pass)).chomp url = base_url + "?resource=" + @resource + @url_options return send_request(url, digest) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hit_api_direct\n # CollegiateLink API needs some data to be hashed and sent for auth purposes\n time = (Time.now.to_f * 1000).to_i.to_s\n ipaddress = ENV['cl_ipaddress']\n apikey = ENV['cl_apikey']\n privatekey = ENV['cl_privatekey']\n random = SecureRandom.hex\n hash = Digest::SHA256.hexd...
[ "0.680646", "0.61558855", "0.6136825", "0.6110455", "0.58596414", "0.58202535", "0.580722", "0.57972", "0.57713294", "0.57523054", "0.57415086", "0.57216847", "0.5704975", "0.57041746", "0.567133", "0.56438255", "0.56316847", "0.56079304", "0.5573442", "0.5556985", "0.5550353...
0.6984046
0
:nocov: Send a request to the request url.
def send_request(requrl, digest) url = URI.parse(requrl) # Create our request object and set the Authentication header with our encrypted data https = Net::HTTP.new(url.host, url.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE # Make our request object with Auth field req = Net::HTTP::Get.new(url.to_s) req.add_field("Authentication", digest) if digest # Send the request, put response into res # FIRXME handle errors res = https.request(req) # Return an empty string if res.body is blank return "" if res.body.blank? # Output successful result return JSON.parse(res.body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_request(method, url, body, headers); end", "def send_request(method, url)\n @response = client.run_request(method, url, @body, headers) do |req|\n req.params = params\n end\n end", "def send_request; end", "def run_request(method, url, body, headers)\n original_run_request(method, ur...
[ "0.7443406", "0.74407446", "0.7290787", "0.7173253", "0.7029576", "0.70056754", "0.6999796", "0.6954042", "0.6923328", "0.68692356", "0.68379754", "0.6821078", "0.681813", "0.67935103", "0.6787613", "0.67646044", "0.6755306", "0.6731393", "0.66022134", "0.65907425", "0.655874...
0.6147391
78
List reviews on a pull request
def pull_reviews(repo, pull_number, options = {}) paginate "#{Repository.path repo}/pulls/#{pull_number}/reviews", options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pull_request_reviews(repo, pull_request_number, options = {})\n accept = {\n accept: CUSTOM_ACCEPT_HEADER\n }\n paginate \"#{Repository.path repo}/pulls/#{pull_request_number}/reviews\", options.merge(accept)\n end", "def reviews(params = {})\n data = request(\"/review/list\", p...
[ "0.7483134", "0.68478465", "0.67313915", "0.6731044", "0.67005795", "0.6611429", "0.65004694", "0.64741486", "0.6453519", "0.6384777", "0.63749844", "0.63617235", "0.63543564", "0.6277397", "0.62767804", "0.6269487", "0.6263371", "0.61769724", "0.6165491", "0.61638325", "0.61...
0.69913536
1
Create a pull request review
def create_pull_review(repo, pull_number, options = {}) post "#{Repository.path repo}/pulls/#{pull_number}/reviews", options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_pull_request_review(repo, pull_request_number, event, body = nil, options = {})\n review = {\n event: event,\n accept: CUSTOM_ACCEPT_HEADER\n }\n review[:body] = body unless body.nil?\n post \"#{Repository.path repo}/pulls/#{pull_request_number}/reviews\", options.merge...
[ "0.7690211", "0.7578934", "0.711053", "0.6963013", "0.6919701", "0.6865636", "0.68362796", "0.67761296", "0.6682887", "0.6564113", "0.6540966", "0.6519871", "0.6487514", "0.64476216", "0.6427748", "0.63832057", "0.6360633", "0.6332194", "0.6280849", "0.6271118", "0.6261362", ...
0.74455553
2
Update a pull request review
def update_pull_review(repo, pull_number, review_id, body, options = {}) opts = options.dup opts[:body] = body put "#{Repository.path repo}/pulls/#{pull_number}/reviews/#{review_id}", opts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @pullRequest = PullRequest.find(params[:id])\n\t\t@git = Git.init()\n\t\tDir.chdir(@pullRequest.source_repo.path)\n\t\trequestor_path = \"#{@pullRequest.repository.path}\"\n\t\t@git.pull(requestor_path, \"master\") # fetch and a merge\n\t\t@pullRequest.status = \"ACCEPTED\"\n if @pullRequest.sav...
[ "0.71378064", "0.70203656", "0.68627334", "0.6531957", "0.6512212", "0.6478034", "0.6473329", "0.6452587", "0.6426484", "0.63866985", "0.63829947", "0.636542", "0.6337701", "0.6331433", "0.6305585", "0.62957555", "0.6291038", "0.62900805", "0.62805575", "0.6246751", "0.624675...
0.74029684
0
Delete a pending review
def delete_pending_review(repo, pull_number, review_id, options = {}) delete "#{Repository.path repo}/pulls/#{pull_number}/reviews/#{review_id}", options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @review.destroy\n end", "def destroy\n @review.destroy\n\n head :no_content\n end", "def destroy\n @review.destroy\n\n head :no_content\n end", "def destroy\n @review.destroy\n\n head :no_content\n end", "def destroy\n @review = Review.find(params[:id])\n @revie...
[ "0.762986", "0.7479662", "0.7479662", "0.7479662", "0.7374576", "0.7257119", "0.7254589", "0.7237458", "0.7208224", "0.71945477", "0.7166525", "0.7150386", "0.71219933", "0.71122795", "0.7093618", "0.70535886", "0.7052535", "0.70297825", "0.7027775", "0.70230097", "0.7021921"...
0.80866915
0
Get comments for a single review
def pull_review_comments(repo, pull_number, review_id, options = {}) paginate "#{Repository.path repo}/pulls/#{pull_number}/reviews/#{review_id}/comments", options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_reviews\n @comment_reviews = CommentReview.where('comment_id = ?', params[:comment_id])\n end", "def comments(user)\n self.design_review_comments.to_ary.find_all { |comment| comment.user == user }\n end", "def comments\n client.get(\"/#{id}/comments\")\n end", "def index\r\n if...
[ "0.7831954", "0.7184588", "0.7173683", "0.69745255", "0.69627583", "0.6875403", "0.68352276", "0.68352276", "0.68208903", "0.6701501", "0.66712064", "0.6631541", "0.6604589", "0.6584814", "0.65768605", "0.6527079", "0.65252066", "0.65141594", "0.6509699", "0.65013164", "0.650...
0.7027936
3
Submit a pull request review
def submit_pull_review(repo, pull_number, review_id, event, options = {}) opts = options.dup opts[:event] = event.to_s.downcase post "#{Repository.path repo}/pulls/#{pull_number}/reviews/#{review_id}/events", opts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def submit_pull_request_review(repo, pull_request_number, review_id, event, body = nil, options = {})\n review = {\n event: event,\n accept: CUSTOM_ACCEPT_HEADER\n }\n review[:body] = body unless body.nil?\n post \"#{Repository.path repo}/pulls/#{pull_request_number}/reviews/#{rev...
[ "0.7473314", "0.71686697", "0.70066434", "0.6703671", "0.6587605", "0.6554552", "0.6532003", "0.65314436", "0.64809394", "0.64288765", "0.63518995", "0.6339383", "0.633823", "0.63189584", "0.6298319", "0.62978536", "0.62891036", "0.6279987", "0.6254046", "0.62419516", "0.6217...
0.70999724
2
Dismiss a pull request review
def dismiss_pull_review(repo, pull_number, review_id, message, options = {}) opts = options.dup opts[:message] = message put "#{Repository.path repo}/pulls/#{pull_number}/reviews/#{review_id}/dismissals", opts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unapprove\n if self.build.pull_request_number != '-1'\n # Clear sha and pull request number\n self.new_image.clear_preapproval_information(false)\n else\n self.new_image.approved = false\n end\n\n # Clear fields that mark diff that an action has been taken, so it is listed in the \"D...
[ "0.6699187", "0.6618998", "0.6568663", "0.60219586", "0.6003063", "0.5849465", "0.5802847", "0.5744155", "0.5743743", "0.5736826", "0.5693942", "0.5672551", "0.5672551", "0.5672551", "0.5661644", "0.5652809", "0.56416", "0.562842", "0.56234676", "0.5615655", "0.5611419", "0...
0.7431354
0
Add more helper methods to be used by all tests here...
def login_with(provider) post "/auth/#{provider}/callback", params: OmniAuth.config.mock_auth[provider.to_sym] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end", "def helpers; end", "def...
[ "0.7330966", "0.701972", "0.701972", "0.701972", "0.6772961", "0.6679903", "0.6679903", "0.6583205", "0.65507036", "0.6377433", "0.63762784", "0.632961", "0.6280821", "0.6280821", "0.6249786", "0.6142927", "0.6137607", "0.6121912", "0.6108209", "0.60972595", "0.60949636", "...
0.0
-1
process Thor instance and save the task name and parameters
def save_history(instance,args) invocation = instance.instance_variable_get("@_invocations").to_a[0] classes = invocation[0].to_s name = invocation[1].first classes.gsub!(/Thor::Sandbox::/,"") classes.gsub!(/::/,":") classes.downcase! options = [args,instance.options] history = Bio::Ngs::Record.new(Bio::Ngs::HISTORY_FILE) history.save(classes+":"+name,options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task\n end", "def thor_task(klass, task_name, &block)\n if program.nil?\n warn \"WARNING:thor_task: no program is associated with #{class_name.upcase} task, does not make sense to create a thor task.\" if Bio::Ngs::Utils.verbose?\n return nil\n end \n if ...
[ "0.6594773", "0.6333987", "0.61970997", "0.619649", "0.61283123", "0.6127869", "0.60794157", "0.60758924", "0.60415673", "0.6022716", "0.5997201", "0.59499615", "0.5893367", "0.58528084", "0.5835467", "0.58218104", "0.5818631", "0.57643217", "0.57117", "0.5684532", "0.5676909...
0.0
-1
create a Response object from a string of XML markup.
def initialize(xml) @doc = Nokogiri::XML(xml) parse_response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_string(xml_string)\n doc = Handsoap::XmlQueryFront.parse_string(xml_string, :nokogiri)\n on_response_document(doc)\n doc\n end", "def load_xml(str)\r\n @xml = REXML::Document.new(str.to_s)\r\n xml_to_instance\r\n self\r\n end", "def parse(response)\n Hpricot.XML(respo...
[ "0.66791296", "0.6570238", "0.6483129", "0.64370483", "0.63398963", "0.5944897", "0.59307647", "0.5930296", "0.5929129", "0.58560663", "0.5748317", "0.5677534", "0.5660816", "0.564391", "0.5627375", "0.5594382", "0.5591135", "0.5589291", "0.55401", "0.552319", "0.55169773", ...
0.576525
11
Ideally this would just be a sequence, but Sqlite and MySQL don't support sequences in the way we need to use them ie. determining what the next number will be before we create the record, because Webmachine wants to set the URL of the resource that is about to be created before we actually create it.
def next_number Sequence.next_val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_sequence_id\n last_sequence_id + 1\n end", "def next_val_sequence(name)\n if self.class.to_s =~ /ActiveRecord::ConnectionAdapters::Mysql/\n self.insert_sql(\"INSERT INTO %s_sequence VALUES(NULL)\" % name)\n else\n # the default insert_sql is nonsense, but jdbc...
[ "0.73848796", "0.68666846", "0.680819", "0.6645219", "0.6638979", "0.65884614", "0.65621877", "0.653829", "0.653659", "0.65037596", "0.64738595", "0.64720064", "0.6460654", "0.6447457", "0.6434641", "0.63836527", "0.62950486", "0.627115", "0.62591416", "0.62539685", "0.625396...
0.6423679
15
policy should be applied in resource
def find consumer_name, provider_name, pact_version_sha, verification_number unscoped(PactBroker::Domain::Verification) .select_all_qualified .join(:all_pact_publications, pact_version_id: :pact_version_id) .consumer(consumer_name) .provider(provider_name) .pact_version_sha(pact_version_sha) .verification_number(verification_number).single_record end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def policy; end", "def policy\n @policy ||= init_policy\n end", "def policies; end", "def policy(resource)\n if authorization_enabled?\n super(resource)\n else\n Authorization::Policy.new(nil, nil, default: true)\n end\n end", "def permissions_policy(...
[ "0.7860656", "0.7391965", "0.73655355", "0.7085996", "0.70082986", "0.6817591", "0.673376", "0.6732114", "0.6661314", "0.66250634", "0.6623107", "0.6611521", "0.66004133", "0.659947", "0.65653604", "0.65600616", "0.6496333", "0.64664024", "0.64491343", "0.63913167", "0.638408...
0.0
-1
The most recent verification for the latest revision of the pact belonging to the version with the largest consumer_version_order.
def find_latest_verification_for consumer_name, provider_name, consumer_version_tag = nil consumer = pacticipant_repository.find_by_name!(consumer_name) provider = pacticipant_repository.find_by_name!(provider_name) join_cols = { Sequel[:lp][:pact_version_id] => Sequel[:verifications][:pact_version_id], Sequel[:lp][:consumer_id] => consumer.id, Sequel[:lp][:provider_id] => provider.id } query = scope_for(PactBroker::Domain::Verification) .select_all_qualified .join(:latest_verification_ids_for_pact_versions, { Sequel[:verifications][:id] => Sequel[:lv][:latest_verification_id] }, { table_alias: :lv }) .join(:latest_pact_publication_ids_for_consumer_versions, join_cols, { table_alias: :lp }) .join(:versions, { Sequel[:cv][:id] => Sequel[:lp][:consumer_version_id] }, { table_alias: :cv }) if consumer_version_tag == :untagged query = query.left_outer_join(:tags, { Sequel[:cv][:id] => Sequel[:tags][:version_id] }) .where(Sequel[:tags][:name] => nil) elsif consumer_version_tag query = query.join(:tags, { Sequel[:cv][:id] => Sequel[:tags][:version_id], Sequel[:tags][:name] => consumer_version_tag }) end query.reverse_order( Sequel[:cv][:order], Sequel[:verifications][:number] ).limit(1).single_record end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latest_version\n\t\treturn versions.order(\"number DESC\").last\n\tend", "def most_recent_version\n card_versions.detect { |card_version| card_version.version == latest_version }\n end", "def latest_version\n self.versions.order(\"revision_date DESC\").first\n end", "def latest_version\n self....
[ "0.72005063", "0.7194936", "0.69726247", "0.6933484", "0.6914127", "0.6894144", "0.6894127", "0.6785639", "0.6754412", "0.67265606", "0.65859646", "0.6585945", "0.6542431", "0.64670616", "0.6457054", "0.6414893", "0.64076906", "0.63957787", "0.6385406", "0.6306635", "0.628181...
0.6935989
3
Return the directory where all the theme assets are stored in the filesystem.
def root_dir File.join(self.runner.path, 'public') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def themes_path\n File.join(RAILS_ROOT, 'themes')\n end", "def public_path\n \"themes/#{self.dir}\"\n end", "def theme_path\n File.join(themes_path, theme)\n end", "def themes_path\n \"#{Rails.root}/app/themes\"\n end", "def theme_path\n Rails.root.join('themes', account_...
[ "0.79184246", "0.75729924", "0.73922354", "0.7222381", "0.7067332", "0.70265937", "0.70168304", "0.697791", "0.6916561", "0.69120365", "0.6846867", "0.68247837", "0.67936677", "0.6781905", "0.6728958", "0.66944206", "0.66815007", "0.6677874", "0.6676094", "0.66345334", "0.659...
0.6166495
60
Tell if the file has to be excluded from the array of theme assets. It does not have to be a folder or be in the samples folder or owns a name starting with the underscore character.
def exclude?(file) File.directory?(file) || file.starts_with?(File.join(self.root_dir, 'samples')) || File.basename(file).starts_with?('_') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid_asset?(filepath)\n return false if FileTest.directory?(filepath)\n @ruhoh.db.config(\"theme\")[\"exclude\"].each {|regex| return false if filepath =~ regex }\n true\n end", "def ignore_assets\n ret = []\n ret << [\"assets/styles/atoms/flex\", \"assets/styles/atoms/fle...
[ "0.7225027", "0.6791632", "0.66634434", "0.644439", "0.64368874", "0.64095634", "0.62974983", "0.6272059", "0.6262853", "0.62419313", "0.6178901", "0.6116001", "0.5973595", "0.59604657", "0.59577715", "0.5923467", "0.5916432", "0.58954465", "0.58936983", "0.5851869", "0.58427...
0.69061583
1
This class acts a proxy of an array
def method_missing(name, *args, &block) self.list.send(name.to_sym, *args, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __array__; self; end", "def proxied_visible_array(proxy)\n new_array = visible_array(proxy)\n proxy.target = new_array\n return proxy\n end", "def array\n raise \"Not implemented\"\n end", "def &(arr)\n raise 'Not Implemented'\n end", "def Array(p0) end", "def method...
[ "0.73314035", "0.7205926", "0.70076954", "0.6938592", "0.69200784", "0.68948233", "0.6890189", "0.6761369", "0.67279106", "0.6637297", "0.66249067", "0.65722615", "0.6517969", "0.6421559", "0.6356981", "0.62894464", "0.62882936", "0.62437296", "0.624197", "0.62370765", "0.620...
0.0
-1
Insert your range by specifying the lower bound. RangeMap generates the upper value based on what's already in the map. While not ideal, it makes it a lot easier to keep the set continuous.
def insert range_first, value @values[range_first] = value lowers = @values.keys.sort uppers = @values.keys.sort lowers.pop uppers.shift @ranges = [] for i in 0...lowers.size do @ranges << (lowers[i]...uppers[i]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_range!(range, ranges)\n # Make sure the arguments are correct\n return nil if range.nil? || ranges.nil?\n\n # Ignore the range if there is an existing one which is bigger\n return nil unless ranges[range.startLine].nil? || ranges[range.startLine].endLine < range.endLine\n ...
[ "0.68139243", "0.68055266", "0.6695958", "0.6695958", "0.6298246", "0.62112653", "0.60588735", "0.60549575", "0.6048147", "0.6045404", "0.6026577", "0.60160005", "0.60104054", "0.59501374", "0.5939584", "0.5932181", "0.5878951", "0.5878951", "0.5878951", "0.5878951", "0.58789...
0.711145
0
DEPRECATED the audio_to_video processor requires :poster_img
def process_poster_img_first return unless Array.wrap(@attachments_for_processing).include? :poster_img @attachments_for_processing.delete(:poster_img) && @attachments_for_processing.unshift(:poster_img) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url_to_video(source, options = T.unsafe(nil)); end", "def create\n @video = Video.new(event_id: params[:event_id], has_youtube: params[:has_youtube], video: params[:video], youtube: params[:youtube], default: params[:default])\n\n if params[:has_youtube] == 'false'\n image = StringIO.new(Base64.de...
[ "0.59640527", "0.58651", "0.56925726", "0.56710154", "0.56485385", "0.5568697", "0.55607253", "0.55441666", "0.5522475", "0.5522475", "0.5430362", "0.54236037", "0.53931606", "0.5392778", "0.53901356", "0.5355758", "0.535307", "0.53115577", "0.52822506", "0.52763414", "0.5223...
0.5157481
27
this file path is the default
def expand_path(path) File.expand_path("../#{path.to_s}", __FILE__) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_path\n PATH_USER_DEFAULTS\n end", "def file_path; end", "def default_file_name\n ''\n end", "def default_files; end", "def file_path\n end", "def root_file_path; end", "def default\n path\n end", "def default_path; end", "def default_location(path)\n @...
[ "0.7990323", "0.79700315", "0.77296007", "0.7705189", "0.75851333", "0.7582162", "0.7541148", "0.7417093", "0.73330104", "0.7220596", "0.7220596", "0.71863294", "0.7172769", "0.7167392", "0.7167392", "0.7167392", "0.71460986", "0.7139503", "0.7072904", "0.70563513", "0.705635...
0.0
-1
Test value for membership.
def test? value actual_response = begin message.send_to value, publicly: publicly rescue # Methods that raise can't pass any test return false end response.test? actual_response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def member_of?(key, value)\n val = get(key)\n val and val.include?(value)\n end", "def has_value?(value); end", "def value?(value) true end", "def has_value?(value)\n field(with: value)\n end", "def value?(value); end", "def value?(value); end", "def has_value? value; val...
[ "0.68899876", "0.6780675", "0.6688708", "0.6525609", "0.64526975", "0.64526975", "0.6401513", "0.63658786", "0.63658786", "0.63658786", "0.6299634", "0.62726164", "0.6239315", "0.62265176", "0.618934", "0.6187125", "0.6187125", "0.6171145", "0.6153809", "0.61517084", "0.61339...
0.0
-1
Algorithm by Paul Bourke, ported to Ruby by David Michael Not sure the best way to deal with the return values here. I have left them in until something is figured out.
def find_intersection_point_with(segment) denominator = ((segment.p2.y - segment.p1.y)*(p2.x - p1.x)) - ((segment.p2.x - segment.p1.x)*(p2.y - p1.y)) numerator_a = ((segment.p2.x - segment.p1.x)*(p1.y - segment.p1.y)) - ((segment.p2.y - segment.p1.y)*(p1.x - segment.p1.x)) numerator_b = ((p2.x - p1.x)*(p1.y - segment.p1.y)) - ((p2.y - p1.y)*(p1.x - segment.p1.x)) if denominator == 0.0 if numerator_a == 0.0 && numerator_b == 0.0 # 'COINCIDENT' return nil end # 'PARALLEL' return nil end ua = numerator_a/denominator ub = numerator_b/denominator # An intersection point exists, given the following conditions if ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0 x = point1.x + ua*(p2.x - p1.x) y = point1.y + ua*(p2.y - p1.y) return Point.new(x, y) end # 'NOT_INTERESECTING' return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }...
[ "0.6204431", "0.607982", "0.6042307", "0.60044867", "0.5953729", "0.59434915", "0.59410363", "0.59334326", "0.59075284", "0.58150274", "0.5801679", "0.5795958", "0.57890904", "0.57890713", "0.57751304", "0.57697016", "0.5765989", "0.5764292", "0.57627213", "0.5753981", "0.574...
0.0
-1
UPDATE BUDGET_AVAILABLE FUNCTIONS currently called when CASTINGS are SAVED might be mixing too much functionality here, remove it by deleting update_film_budget_available() from save()
def calc_budget_deduction # calc deduction sql = "SELECT castings.fee FROM castings INNER JOIN moviestars ON castings.moviestar_id = moviestars.id WHERE castings.movie_id = $1" values = [@movie_id] result = SqlRunner.run(sql, values) fee_array = result.map{|movie| movie['fee'].to_i} deduction = if fee_array.length > 0 fee_array.sum else 0 end return deduction end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_funding\n logger.debug \"Updating percent funded\"\n @total_copies = total_copies\n @downloads_reserved = project_subscriptions.collect { |s| s.amount }.sum #- self.pmf_fund_investment_share_amount_incl_outstanding\n self.downloads_reserved = @downloads_reserved\n self.downloads_available...
[ "0.5716932", "0.56702775", "0.56653494", "0.56620884", "0.5634273", "0.5588675", "0.5563788", "0.5548188", "0.5522167", "0.5520951", "0.5510975", "0.54816705", "0.5432512", "0.5398188", "0.53852326", "0.5375539", "0.5362887", "0.5341276", "0.5316205", "0.5309376", "0.5285603"...
0.0
-1
Query Darksky.net for each of the historical dates specified, plus the forecast, in order to compute the risk of landslides
def update_from_darksky(historical_dates=[Date.today-1], forecast=true) darksky_secret = ApiKey.where(:service => 'Darksky').first.key hydra = Typhoeus::Hydra.new requests = Hash.new forecast_request = nil logger.debug("Updating Station #{name} for dates: #{historical_dates}") # Construct the HTTP requests to Darksky: one for each of the past days we care about, and one for today to get the forecast historical_dates.each do |d| endpoint = "https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude},#{d.to_time.to_i}" request = Typhoeus::Request.new(endpoint) hydra.queue(request) requests[d] = request end forecast_request = Typhoeus::Request.new("https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude}") hydra.queue(forecast_request) if forecast # Run the whole lot of them! hydra.run # Parse out the observed precipitation from the historical queries reports = [] requests.each_pair do |d, request| if request.response.timed_out? logger.error "Request to Darksky timed out: #{request}" next end if request.response.nil? logger.error "No response from Darksky for request #{request}" next end if request.response.code != 200 logger.error "Unable to fetch weather data from #{request.base_url}: #{request.response.code} #{request.response.status_message}" next end # With error trapping done, let's parse the body and update the db with the report data. data = JSON.load(request.response.body) data['daily']['data'].each do |report| logger.debug(report) d = Time.at(report['time']).to_date datestamp = "#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}" logger.debug("Using timestamp #{datestamp}") # We want to update an existing row in place if we've previously computed one r = weather_reports.find_or_create_by( :latitude => self.latitude, :longitude => self.longitude, :date => datestamp, ) # TODO: multiply by the actual number of hours in the time period. precip = report['precipIntensity'] # This is in inches per hour logger.debug("Extracted precipitation report: #{precip} from report #{report}") r.precip = precip * 24.0 logger.debug("Constructed WeatherReport: #{r}") logger.debug("Coordinates: #{r.latitude},#{r.longitude}") logger.debug("Datestamp: #{r.date}") logger.debug("Recorded Precip: #{r.precip}") r.save reports.push(r) end end # Add the forecast data as well forecasts = [] if forecast logger.info("Parsing forecasts for station #{self}") logger.debug("Got response: #{forecast_request.response}") if forecast_request.response.timed_out? logger.error "Request to Darksky timed out: #{forecast_request}" return end if forecast_request.response.nil? logger.error "No response from Darksky for request #{forecast_request}" return end if forecast_request.response.code != 200 logger.error "Unable to fetch weather data from #{forecast_request.base_url}: #{forecast_request.response.code} #{forecast_request.response.message}" return end logger.debug("Successful response from Darksky") data = JSON.load(forecast_request.response.body) data['daily']['data'].each do |report| logger.debug(report) d = Time.at(report['time']).to_date datestamp = "#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}" r = weather_reports.find_or_create_by( :latitude => self.latitude, :longitude => self.longitude, :date => datestamp, ) r.precip = report['precipIntensity'] * 24.0 # The Darksky report gives us inches per hour logger.debug("Created forecast object: #{r}") r.save forecasts.push(r) end end # TODO: add a column that we can record when this update was last run, for display on the webpage. {:reports => reports, :forecasts => forecasts} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @day_forecasts = DayForecast.where(\"forecast_datetime >= ?\", Time.current.beginning_of_day)\n @half_forecasts = HalfForecast.where(point_date: Config.last.half_forecast_point_date)\n end", "def forecast(loc)\n\n url = \"#{@base_url}/#{FORECAST_QUERY}/q/#{loc[0]},#{loc[1]}.json\" \n\n r...
[ "0.66614354", "0.60668576", "0.6066592", "0.5974969", "0.59240896", "0.5865374", "0.5747944", "0.5740663", "0.5709514", "0.5698288", "0.56412435", "0.56311035", "0.5538237", "0.553533", "0.55173546", "0.5509265", "0.55082506", "0.5467259", "0.54360956", "0.5413047", "0.541287...
0.680085
0
Fetch the 18 days previous to the specified date, and use those records to compute the risk of landslides for this station.
def alert(today = Date.today) # Pull the previous 18 days' reports # These should all be loaded after running update_from_darksky # Recent reports are the previous three days recent_precip = 0.0 logger.info("Computing Recent Precip for Station #{self} on #{today}") recent_weather_reports(today).each do |report| recent_precip += report.precip_inches end logger.debug("Got #{recent_precip} inches of precipitation in the three prior days.") # Old reports are the 15 days prior to the 3 days' "recent reports". So, days d - 4 through d - 18 old_precip = 0.0 old_weather_reports(today).each do |report| old_precip += report.precip_inches end logger.debug("Got #{old_precip} inches of precipitation in the 15 days before that.") threshold_level = 3.5 - 0.67 * old_precip alert_level = recent_precip - threshold_level WeatherStationAlert.new( :latitude => self.latitude, :longitude => self.longitude, :alert_for => today, :level => alert_level, :old_sum => old_precip, :recent_sum => recent_precip, ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def previous_180_days_visits\n user.visits.find_by_date((entry_date - 180.days), exit_date).select { |v| v.id != self.id && v.schengen? && v.entry_date <= entry_date }\n end", "def article_previous\n blog_data.articles.find { |a| a.date < date }\n end", "def previous_forecast\n self.class.ge...
[ "0.58718663", "0.5803914", "0.5663553", "0.5638601", "0.56007826", "0.5463594", "0.5410098", "0.54063886", "0.5396055", "0.5388472", "0.53714174", "0.5361695", "0.52970153", "0.5288534", "0.52846056", "0.51544106", "0.5137231", "0.50970745", "0.50722224", "0.50635016", "0.502...
0.4669689
70
Pull the weather reports for yesterday through today 3, relative to the given date.
def recent_weather_reports(today = Date.today) recent_days = (1..3).collect {|i| today - i}.collect {|d| "#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}"} weather_reports.where(:date => recent_days) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def old_weather_reports(today = Date.today)\n old_days = (4..18).collect {|i| today - i}.collect {|d| \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"}\n weather_reports.where(:date => old_days)\n end", "def alert(today = Date.today)\n # Pull the previous 18 days' reports\n # Thes...
[ "0.76588184", "0.6507561", "0.64307475", "0.6360588", "0.61364245", "0.61216724", "0.61152965", "0.6101046", "0.60029805", "0.59832585", "0.59827876", "0.59446365", "0.594318", "0.5929036", "0.5760742", "0.57355076", "0.57162905", "0.56970924", "0.5678437", "0.56615275", "0.5...
0.80460894
0
Pull the weather reports for today 4 through today 18, relative to the given date.
def old_weather_reports(today = Date.today) old_days = (4..18).collect {|i| today - i}.collect {|d| "#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}"} weather_reports.where(:date => old_days) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recent_weather_reports(today = Date.today)\n recent_days = (1..3).collect {|i| today - i}.collect {|d| \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"}\n weather_reports.where(:date => recent_days)\n end", "def current_weather_data\r\n response = self.get_data\r\n\r\n # n...
[ "0.7563557", "0.6514366", "0.6486014", "0.64308333", "0.62580734", "0.6228936", "0.61959726", "0.61880416", "0.6083938", "0.60269463", "0.6022878", "0.59817", "0.59484744", "0.59270394", "0.58390236", "0.58254266", "0.581904", "0.58145887", "0.58121926", "0.5775087", "0.57703...
0.7817178
0