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
Enable SQL logging. You can call this method within a block where SQL logging was disabled to renable it.
def enable_sql_logging(&block) sql_logging(enabled: true, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_sql\n @opts[:log_sql]\n end", "def log_sql(log_sql = true)\n if log_sql\n Sierra::DB.db.loggers << Sierra::Logging.logger\n else\n Sierra::DB.db.loggers.delete(Sierra::Logging.logger)\n end\n end", "def disable_sql_logging(&block)\n sql_logging(enabled: ...
[ "0.73297447", "0.7178721", "0.6995771", "0.6811558", "0.6701986", "0.6605298", "0.65847754", "0.6432213", "0.6359256", "0.6253259", "0.6249488", "0.6209547", "0.61505383", "0.6128812", "0.61093336", "0.60587066", "0.60376793", "0.5924147", "0.5919858", "0.5833025", "0.5833025...
0.88641167
0
Use a different database connection for the block. You can use this if your application has multiple databases to swap connections for the migration. You can pass in either a database connection or an ActiveRecord::Base class to use the connection used by that class. The label argument will be added to the logged SQL as a comment.
def using_connection(connection_or_class, label: nil, &block) if connection_or_class.is_a?(Class) && connection_or_class < ActiveRecord::Base label ||= connection_or_class.name connection_or_class.connection_pool.with_connection do |connection| switch_connection_in_block(connection, label: label, &block) end else switch_connection_in_block(connection_or_class, label: label, &block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def use(name)\n with(database: name)\n end", "def use(name)\n with(database: name)\n end", "def current_database_name\n ActiveRecord::Base.connection_pool.spec.config[:name] || 'default'\n end", "def log_connection_yield(sql, conn, args=nil)\n if !@loggers.empty? && (external...
[ "0.58952796", "0.58952796", "0.5864107", "0.58073604", "0.5803836", "0.56988025", "0.5618647", "0.556568", "0.55474716", "0.5438245", "0.541401", "0.5365838", "0.5349817", "0.5346079", "0.5331299", "0.53275156", "0.52839667", "0.52775586", "0.5259137", "0.5258833", "0.5252176...
0.6936789
0
returns true if an update occurred
def git_fetch path Open3.popen2e *%W(git fetch origin), chdir: path do |stdin, stdout, _wait| not stdout.read.chomp.empty? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update?\n @update\n end", "def updated?\n command.success?\n end", "def updated?() updated.present?; end", "def update?\n true\n end", "def updated?\n false\n end", "def update?\n state == STATE_UPDATE\n end", "def update\n true\n end", ...
[ "0.8384876", "0.82848316", "0.818492", "0.8106037", "0.8061133", "0.8057604", "0.79850566", "0.79443085", "0.79440373", "0.79325265", "0.7848952", "0.7796269", "0.777988", "0.7770933", "0.77215767", "0.77215767", "0.7694314", "0.7693199", "0.76871115", "0.76871115", "0.767150...
0.0
-1
Returns a resized image for display.
def display_image image.variant(resize_to_limit: [500, 500]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_resized_image\n create_image do |xfrm|\n if size\n MiniMagick::Tool::Convert.new do |cmd|\n cmd << xfrm.path # input\n cmd.flatten\n cmd.resize(size)\n cmd << xfrm.path # output\n end\n end\n end\n ...
[ "0.74281555", "0.7337605", "0.7276508", "0.72498614", "0.71668667", "0.6908238", "0.6732925", "0.67188084", "0.66568625", "0.66387683", "0.65469444", "0.6546263", "0.65405697", "0.6535587", "0.6528795", "0.6500281", "0.6499397", "0.6488022", "0.6481025", "0.6469561", "0.64159...
0.7291966
6
=> 14.0 A more elegant approach
def elegant_calc(expr) expr.split.each_with_object([]) { |e, a| if e.match(/\d+/) a << e.to_f else y, x = a.pop, a.pop a << x.send(e, y) end }.last || 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verdi; end", "def vat_number; end", "def __numval_optkeys\n super() + ['closeenough']\n end", "def _reduce_479(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def default_v_score ; raise 'not implemented'; end", "def _red...
[ "0.5340474", "0.52942824", "0.52820003", "0.5267194", "0.52660584", "0.5245146", "0.5239247", "0.51868105", "0.51832074", "0.5180995", "0.5165528", "0.5160624", "0.51514214", "0.5136787", "0.51276714", "0.512177", "0.512177", "0.512177", "0.51167417", "0.5091326", "0.5088698"...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_place_permission @place_permission = PlacePermission.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.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.532...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def place_permission_params params.fetch(:place_permission, {}).permit(:user_id, :role).merge(:place => @place) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
def about render 'about' => if the only logic in an action can be done implicitly, the whole action can be implied end GET /pets
def index @pets = Pet.all # render 'index' => where render is a method call and 'index' is an argument # rails will implicitly try to render a view template with the same name as the action end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def about; render; end", "def about\n respond_to do |format|\n format.html { render :about }\n end\n end", "def about\n\t\tabout_post = Post.of_type(Post::POST_TYPE_ABOUT)\n\t\tif about_post.present?\n\t\t\tgon.post = about_post.as_json\n\t\t\trender :show\n\t\telse\n\t\t\tredirect_to :root\n\t\tend\n\...
[ "0.7644059", "0.6880763", "0.6832566", "0.6722207", "0.6722207", "0.6699893", "0.66456723", "0.66456723", "0.66456723", "0.6621492", "0.6586283", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", ...
0.6040009
43
strong params that take advantage of Rails security features to prevent e.g. SQL injection attacks
def pet_params params.require(:pet).permit(:name, :species, :year_of_birth, :good_with_kids) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def user_strong_params\n html_safe(params[:user]).strip\n end", "def quote_params\n params.permit!\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",...
[ "0.726364", "0.72509843", "0.7165954", "0.7023828", "0.68842524", "0.68697464", "0.68058985", "0.6786618", "0.6765251", "0.6735566", "0.6719693", "0.66753376", "0.66280156", "0.66228265", "0.6579734", "0.6567968", "0.6559923", "0.6532757", "0.6505881", "0.6501059", "0.6465924...
0.0
-1
look up how to do this without copy/pasting other method
def average_credit_rating if average_credit_score > 760 "excellent" elsif average_credit_score > 725 "great" elsif average_credit_score > 660 "good" elsif average_credit_score > 560 "mediocre" else "bad" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def anchored; end", "def schubert; end", "def suivre; end", "def offences_by; end", "def formation; end", "def stderrs; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def terpene; end", "def who_we_are\r\n end", ...
[ "0.6463675", "0.6371908", "0.62604", "0.6120137", "0.6048225", "0.5922335", "0.59012616", "0.5839975", "0.58262706", "0.58262706", "0.58262706", "0.58262706", "0.57962567", "0.5721782", "0.5714384", "0.56867284", "0.56867284", "0.5673827", "0.5632865", "0.5619114", "0.5619114...
0.0
-1
Extract the connection string for the rabbitmq service from the service information provided by Cloud Foundry in an environment variable.
def amqp_url if not ENV['VCAP_SERVICES'] return { :host => "172.16.32.11", :port => 5672, :username => "guest", :password => "guest", :vhost => "/", } end services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true) url = services.values.map do |srvs| srvs.map do |srv| if srv[:label] =~ /^rabbitmq-/ srv[:credentials] else [] end end end.flatten!.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def amqp_url\n if not ENV['VCAP_SERVICES']\n return {\n :host => \"localhost\",\n :port => 5672,\n :username => \"guest\",\n :password => \"guest\",\n :vhost => \"/\",\n }\n end\n\n services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true)\n url = services.values.map ...
[ "0.7228656", "0.64117", "0.60329986", "0.5871954", "0.58560705", "0.57894254", "0.57065386", "0.5627882", "0.55615014", "0.5546482", "0.5546482", "0.55334806", "0.55314684", "0.55079055", "0.5474078", "0.54584104", "0.544193", "0.54413456", "0.542486", "0.542486", "0.54162025...
0.744864
0
Opens a client connection to the RabbitMQ service, if one isn't already open. This is a class method because a new instance of the controller class will be created upon each request. But AMQP connections can be longlived, so we would like to reuse the connection across many requests.
def client unless $client u = amqp_url puts u c = Bunny.new(u) c.start $client = c # We only want to accept one un-acked message $client.qos :prefetch_count => 1 end $client end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def client\n unless $client\n u = amqp_url\n conn = Bunny.new(u)\n conn.start\n $client = conn.create_channel\n\n # We only want to accept one un-acked message\n $client.prefetch(1)\n end\n $client\nend", "def client\n set_connection unless @client\n @client\n end", "def connect\n ...
[ "0.66360945", "0.6550528", "0.64999807", "0.6062877", "0.5976772", "0.5913682", "0.5913102", "0.591306", "0.58838266", "0.58361375", "0.5823498", "0.5796797", "0.5780779", "0.5761988", "0.57447934", "0.57340795", "0.5719682", "0.5711008", "0.57009107", "0.565251", "0.5641438"...
0.64861387
3
Register a card that has been duplicated so it can be remapped
def register_duplicated_card(original_card_id:, to_card_id:) Cache.hash_set("#{@batch_id}_duplicated_cards", original_card_id, to_card_id) remapper = CardDuplicatorMapper::RemapLinkedCards.new( batch_id: @batch_id, ) # remap the card that was just duplicated remapper.remap_cards(original_card_id, to_card_id) # if all have completed, then we run through them all, basically a last pass # to ensure we match any links that were created later than the duplicates, etc. # TODO: How to ensure all cards were mapped or if duplication failed? return unless all_cards_mapped? remapper.call end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addCard(givenCard)\n \tcards_users.create(card_id: givenCard.id, is_shared: false)\n end", "def add_card card\n card.deck = self\n @cards[card.id] = card\n end", "def add_card(card)\n \t@cards << card\n end", "def addSharedCard(givenCard)\n \tcards_users.create(card_id: givenCard.id, is...
[ "0.67919964", "0.67069805", "0.66378534", "0.66062117", "0.65801567", "0.65801567", "0.6567602", "0.65265167", "0.6503379", "0.64770275", "0.63998014", "0.63998014", "0.63998014", "0.63933533", "0.63773215", "0.63613427", "0.63472915", "0.6335032", "0.6329207", "0.6318804", "...
0.7502256
0
A hash of all cards that have been marked that they may need to be updated after duplication is complete
def linked_cards Cache.hash_get_all("#{@batch_id}_linked_cards").presence || {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def duplicated_cards\n Cache.hash_get_all(\"#{@batch_id}_duplicated_cards\").presence || {}\n end", "def hash\n super() ^ @hidden_cards.hash\n end", "def hash\n # Memoizing such a simple hash value seems silly, however the\n # profiler showed the Card#hash method as having 22% of the runtime....
[ "0.7276199", "0.68572944", "0.62788683", "0.6125981", "0.61204976", "0.6001791", "0.5956916", "0.5943199", "0.58915186", "0.5858628", "0.5857005", "0.5826576", "0.5824386", "0.58186543", "0.580839", "0.57961667", "0.5751639", "0.57414544", "0.57371646", "0.5718707", "0.569993...
0.60833347
5
A hash that maps from the original card id to the duplicated card id
def duplicated_cards Cache.hash_get_all("#{@batch_id}_duplicated_cards").presence || {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_duplicated_card(original_card_id:, to_card_id:)\n Cache.hash_set(\"#{@batch_id}_duplicated_cards\", original_card_id, to_card_id)\n\n remapper = CardDuplicatorMapper::RemapLinkedCards.new(\n batch_id: @batch_id,\n )\n # remap the card that was just duplicated\n remapper...
[ "0.6899874", "0.66217256", "0.6553424", "0.6336948", "0.6322116", "0.6262354", "0.6208293", "0.6151167", "0.6149363", "0.6100726", "0.6077612", "0.60733", "0.60646814", "0.6054649", "0.6023997", "0.5946687", "0.59424937", "0.591993", "0.5900293", "0.5875312", "0.5863407", "...
0.7027408
0
converts hand from array of card to array of sorted scores of said cards
def cards_by_score scores = {} @cards.each do |card| scores[card] = card.score end Hash[scores.sort_by { |card, score| -score }] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end", "def sort_by_suit\n \tnew_hand = []\n while @cards.size > 0\n \tpos = 0 # position of minimal card\n \tc = @cards[0] # minimal card\n \t@cards.each_with_index do |card, index|\n \t\tc1 = card\n # puts \"c: #{c....
[ "0.7948034", "0.7014165", "0.7000303", "0.6928356", "0.68609774", "0.6820641", "0.6737521", "0.6714905", "0.66206586", "0.6574508", "0.6560887", "0.6517915", "0.6503766", "0.6470747", "0.6426299", "0.6387371", "0.636609", "0.635723", "0.63561314", "0.6342808", "0.63078564", ...
0.7296949
1
check if only 5 cards in hand already
def hand? @cards_by_score.length == 5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_house?\n return unless size >= 5\n\n the_cards = cards_by_rank.values\n the_cards[0].count >= 3 && the_cards[1].count >= 2\n end", "def complete?\n @cards.length == 5\n end", "def six_cards?(player_check)\n if (player_check.hand.length == 6) && (player_check.hand_total < 21)\n ...
[ "0.77190894", "0.7696931", "0.7544853", "0.7426773", "0.7379774", "0.71706223", "0.7072673", "0.7059381", "0.6965509", "0.69097555", "0.68847656", "0.6856932", "0.68359697", "0.68305546", "0.68256474", "0.6815574", "0.6785656", "0.67349523", "0.67292315", "0.67136276", "0.670...
0.80713946
0
determines what exists in hands
def pair? @card_scores.uniq.length == (@card_scores.length - 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_multiple_hands\n return 1 if @hands.length > 1\n return nil\n end", "def has_a_hand\n return 1 if @hands.length > 0\n return nil\n end", "def hand\n hands.first\n end", "def has_hands\n return @hands.select{|hands| hands.status == HandStatus::PLAY} != []\n end", "def hands\n ...
[ "0.72336465", "0.7123592", "0.7041259", "0.70120835", "0.6972605", "0.6804357", "0.677349", "0.6752963", "0.6719292", "0.6710728", "0.659526", "0.6583047", "0.65560097", "0.64660335", "0.6446914", "0.636851", "0.63634807", "0.63504654", "0.6314673", "0.6272187", "0.6265082", ...
0.0
-1
gets best hand with given type
def get_high_cards(cards) @cards_by_score.each_key do |card| if cards.length < 5 && !cards.include?(card) cards << card end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def best_hand\n case\n when hand?\n return @cards\n when pair? && !hand?\n get_pairs\n when two_pair? && !hand?\n get_pairs\n when three_of_a_kind? && !full_house? && !hand?\n get_three_of_a_kind\n when straight? && !straight_flush? && !hand?\n get_straight\n when flus...
[ "0.7461818", "0.66510767", "0.6424252", "0.6400516", "0.63111544", "0.6275096", "0.61452454", "0.6110654", "0.6074439", "0.6067524", "0.5941566", "0.5932318", "0.5813837", "0.5805027", "0.57864434", "0.5785165", "0.57525396", "0.5747556", "0.5745277", "0.5691408", "0.5685435"...
0.0
-1
returns an array of card with given number of multiples
def get_multiples(number) cards = [] @cards_by_score.each_key do |card| if @card_scores.count(card.score) == number cards << card end end cards end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_multiples(number)\n \n numbers = Array.new(number - 1, 0)\n count = 0\n while count < numbers.length \n numbers[count] = count + 1\n count += 1\n end\n\n numbers.select do |element|\n element % 3 == 0 || element % 5 == 0\n end\n\nend", "def collect_multiples(limit)\n array = []\n (1...
[ "0.7295955", "0.7234427", "0.71736974", "0.71499264", "0.71370065", "0.7105511", "0.7092792", "0.7009756", "0.6929065", "0.6902126", "0.6857695", "0.68308", "0.682126", "0.6779479", "0.6763631", "0.6746046", "0.6718843", "0.66709906", "0.66703296", "0.66694295", "0.6638205", ...
0.7604125
0
with array of cards and determines the best 5 card hand
def best_hand case when hand? return @cards when pair? && !hand? get_pairs when two_pair? && !hand? get_pairs when three_of_a_kind? && !full_house? && !hand? get_three_of_a_kind when straight? && !straight_flush? && !hand? get_straight when flush? && !straight_flush? && !hand? get_flush when full_house? && !hand? get_full_house when four_of_a_kind? && !hand? get_four_of_a_kind when straight_flush? && !hand? get_straight_flush else get_high_card end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_high_cards(cards)\n @cards_by_score.each_key do |card|\n if cards.length < 5 && !cards.include?(card)\n cards << card\n end\n end\n end", "def tie_breaker_cards\n matched = self.matched_cards\n sorted = @cards.sort.reverse\n # sorted so the card with highest value ...
[ "0.7607686", "0.7482673", "0.7390467", "0.73692095", "0.73263884", "0.7233955", "0.706368", "0.70279825", "0.7026328", "0.692564", "0.6915625", "0.6875506", "0.6858767", "0.68203574", "0.68152577", "0.6812981", "0.68022346", "0.6781045", "0.6765555", "0.6751201", "0.66803753"...
0.70128715
9
TODO: check that this works correctly when creating a member's first photo_album from photos/new
def set_name_as_untitled if name.blank? untitled_count = attachable ? attachable.photo_albums.untitled.size : self.class.without_attachable.untitled.size self.name = "#{UNTITLED_NAME} #{untitled_count + 1}" end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n \n @album = @user.albums.new(params[:album])\n \n if @album.save\n flash[:notice] = 'User was successfully created.'\n if params[:album][:avatar].blank?\n redirect_to @album\n else\n \n render :action => 'cropping'\n end\n else\n ...
[ "0.6716489", "0.6584746", "0.65331537", "0.6481912", "0.6475554", "0.643558", "0.6428309", "0.64254946", "0.6385693", "0.6383643", "0.63700205", "0.63440716", "0.6309707", "0.6305727", "0.62739587", "0.6256663", "0.6256292", "0.62509334", "0.62458843", "0.6242875", "0.6226155...
0.0
-1
TODO how to test this
def get_users_current_votes(user) applicable_ideas = Idea.all.published.where.not(user: user) applicable_versions = Version.where(idea: applicable_ideas) votes = Upvote.where(user: user, version: applicable_versions.ids) return votes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def probers; end", "def schubert; end", "def refutal()\n end", "def weber; end", "def implementation; end", "def implementation; end", "def formation; end", "def identify; end", "def custom;...
[ "0.7699575", "0.6550803", "0.6550803", "0.6550803", "0.6550803", "0.65251195", "0.64689064", "0.62361383", "0.6185826", "0.61640114", "0.61640114", "0.6056613", "0.6033879", "0.5993173", "0.5993173", "0.5976", "0.59221303", "0.5884436", "0.5884436", "0.5884436", "0.5884436", ...
0.0
-1
Action used by nonExt.Direct (Touch) components
def dispatcher endpoint_dispatch(params[:address]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform\n $driver.multi_touch @actions\n end", "def click_action\n raise NotImplementedError \"Subclasses must implement this method\"\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def action_hook; end", "def action(event...
[ "0.6418835", "0.6414012", "0.63618726", "0.63618726", "0.63618726", "0.63618726", "0.63618726", "0.630119", "0.6270856", "0.61801755", "0.61144507", "0.60913104", "0.60820156", "0.6079153", "0.6072843", "0.6066831", "0.60415614", "0.6028799", "0.60075706", "0.59906316", "0.59...
0.0
-1
Used in development mode for onthefly generation of public/netzke/ext.[js|css]
def ext respond_to do |format| format.js { render :text => Netzke::Core::DynamicAssets.ext_js } format.css { render :text => Netzke::Core::DynamicAssets.ext_css } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def netzke_init(params = {})\n theme = params[:ext_theme] || :default\n [netzke_css_include(theme), netzke_js_include, netzke_js].join(\"\\n\")\n end", "def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token...
[ "0.6672198", "0.63841134", "0.62464255", "0.62149256", "0.6169453", "0.61687607", "0.6008034", "0.59936416", "0.59929276", "0.59929276", "0.59812254", "0.59486586", "0.59182674", "0.59182674", "0.5897309", "0.58845794", "0.5853264", "0.5851368", "0.58097774", "0.57962453", "0...
0.6852749
0
Used in development mode for onthefly generation of public/netzke/touch.[js|css]
def touch respond_to do |format| format.js { render :text => Netzke::Core::DynamicAssets.touch_js } format.css { render :text => Netzke::Core::DynamicAssets.touch_css } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_dev\n timer_block(\n 'Start [development] build for *.js files',\n 'JS time: ') do\n all_js_into_one_file\n end\n end", "def precompile_assets; end", "def request_debug_assets?; end", "def request_debug_assets?; end", "def js\n puts 'Comp...
[ "0.66531837", "0.62821525", "0.6220736", "0.6220736", "0.6187166", "0.6154933", "0.6081586", "0.6038984", "0.5971961", "0.59503865", "0.5941376", "0.59234643", "0.5895388", "0.5889352", "0.5878378", "0.58676356", "0.58346045", "0.5809598", "0.5796627", "0.57818174", "0.578051...
0.65088785
1
Main dispatcher of oldstyle (Sencha Touch) HTTP requests. The URL contains the name of the component, as well as the method of this component to be called, according to the double underscore notation. E.g.: some_grid__post_grid_data.
def endpoint_dispatch(endpoint_path) component_name, *sub_components = endpoint_path.split('__') component_instance = Netzke::Base.instance_by_config(Netzke::Core.session[:netzke_components][component_name.to_sym]) # We render text/plain, so that the browser never modifies our response response.headers["Content-Type"] = "text/plain; charset=utf-8" render :text => component_instance.invoke_endpoint(sub_components.join("__"), params), :layout => false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dispatcher\n endpoint_dispatch(params[:address])\n end", "def method_missing(method_name, params = {})\n component, *action = method_name.to_s.split('__')\n component = component.to_sym\n action = !action.empty? && action.join(\"__\").to_sym\n\n if action\n if compone...
[ "0.59711206", "0.57147175", "0.5545272", "0.5320577", "0.5257479", "0.5120687", "0.510155", "0.5065449", "0.50552744", "0.50552744", "0.50552744", "0.5034021", "0.50314534", "0.5030001", "0.49982038", "0.49866804", "0.49825743", "0.4977301", "0.49751395", "0.49751395", "0.497...
0.58597404
1
=> "I don't care about arguments" Procs and lambdas handle return differently: A lambda will return normally like a method, while A proc will return from the method enclosing the proc.
def proc_return my_proc = Proc.new { return } my_proc.call puts "This will not be printed" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proc_return_demo\n some_proc = Proc.new { return \"proc returns\"}\n some_proc.call\n \"method returns\"\nend", "def lambda_vs_proc\n my_lam = lambda { return puts \"Hi, I'm your lambda!\" }\n my_lam.call\n puts 'Returned from lambda!'\n my_proc = Proc.new { return puts 'Hello from proc!' }\n my_proc...
[ "0.75660604", "0.75587374", "0.74647546", "0.7360698", "0.7320859", "0.731422", "0.72660494", "0.72437483", "0.7212939", "0.7205226", "0.71961004", "0.7113144", "0.7056424", "0.6909016", "0.6905708", "0.6899517", "0.6844433", "0.684056", "0.68395615", "0.6819871", "0.6753244"...
0.7487214
2
GET /imagems/1 GET /imagems/1.xml
def show @imagem = @evento.imagems.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @imagem } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image(image_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Compute::Slicehost::GetImage.new,\n :path => \"images/#{image_id}.xml\"\n )\n end", "def show\n @imagem = Imagem.find(params[:id])\...
[ "0.69916815", "0.69894046", "0.6804412", "0.65871704", "0.6567679", "0.65181506", "0.64555717", "0.64343226", "0.64343226", "0.64343226", "0.64182395", "0.6405345", "0.64015716", "0.63921446", "0.63728523", "0.6349735", "0.63433266", "0.63350546", "0.6333711", "0.6321536", "0...
0.71077454
0
Public interface BlockCommand.new ||Arguments:|| `name` The String name of the command. `args` The NodeList of arguments given to the command. `raw_tokens` A TokenList that represents the entire BlockCommand, generated by the Tokenizer. You must override this method in your subclass of BlockCommand.
def initialize(*args) if self.class == BlockCommand raise TypeError, 'BlockCommand.new should not be called directly' end super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command *args, &block\n @commands ||= []\n @args ||= []\n @commands << block\n @args << args\n end", "def new_block_el(*args); end", "def initialize\n @block_args = []\n end", "def command_raw(args)\n\n end", "def initialize( name, *args, &block )\n\t\t\t@name\t\t ...
[ "0.6585519", "0.6168184", "0.6128972", "0.60842866", "0.6081653", "0.60322154", "0.59502864", "0.5863933", "0.5813367", "0.5808431", "0.5790726", "0.5786573", "0.5776735", "0.57718474", "0.57465255", "0.57334", "0.5682308", "0.5667897", "0.56664985", "0.56640947", "0.56623715...
0.73147696
0
BlockCommandactive_block Since BlockCommands have the ability to contain multiple blocks, this method returns (at least in theory) the block within this BlockCommand that the Parser is currently looking as it is iterating over it. You must override this method in your subclass of BlockCommand. It must return a NodeList. TODO: At the moment, this method is not used
def active_block raise NotImplementedError, 'BlockCommand#active_block should be overridden by a subclass' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_blocks\n @blocks\n end", "def block_node; end", "def block_node; end", "def block\n blockable.blocks.detect{|b| b.identifier == self.identifier.to_s} || \n blockable.blocks.build(:identifier => self.identifier.to_s)\n end", "def blocks\n @blocks ||= []\n end", "de...
[ "0.6610187", "0.64303994", "0.64303994", "0.6326704", "0.6225922", "0.62140965", "0.6201415", "0.61609197", "0.6132075", "0.61044264", "0.6054984", "0.60532784", "0.6030627", "0.6024402", "0.593743", "0.59208715", "0.5899928", "0.5820576", "0.5778507", "0.57395554", "0.573908...
0.74524754
0
BlockCommandto_s A convenience method. Returns a String.
def to_s "[ #{@name} ]" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n return command\n end", "def to_s\n #N Without this we won't see the command as a command and a list of arguments\n return command.join(\" \")\n end", "def to_s\n msg = ''\n msg += \"Command: #{name}\\n\"\n options.each { |o| msg += \" \" + o.inspect + \"\\n\"...
[ "0.7274692", "0.67441344", "0.66691697", "0.6443314", "0.6411545", "0.6346718", "0.6346718", "0.6260042", "0.624778", "0.618448", "0.60809064", "0.60204303", "0.6009049", "0.5927742", "0.59268844", "0.5913619", "0.58910495", "0.5888042", "0.58464164", "0.5816891", "0.5816891"...
0.0
-1
Writes an object to the stream. Calls the object's write() method, if available. Uses to_s otherwise.
def write( object ) if object.responds_to?(:write_to) then object.write_to(@stream) else @stream << object.to_s end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def puts( obj )\n return unless writeable?\n\n data = Marshal.dump(obj)\n @socket.write([data.size].pack('I')) + @socket.write(data)\n rescue SystemCallError\n return nil\n end", "def write_object(object)\n object\n end", "def write_object(object)\n @encoder.encode(object, @sock)...
[ "0.71540254", "0.6904508", "0.6904365", "0.67931956", "0.67856747", "0.62626743", "0.6194346", "0.6134303", "0.61313057", "0.60799366", "0.59159815", "0.59101236", "0.58574235", "0.58574235", "0.58492833", "0.5848072", "0.58037907", "0.5790163", "0.5717786", "0.5700183", "0.5...
0.8353593
0
Runs your block as a DSL against this renderer.
def capture(&block) instance_eval(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dsl_eval(block)\n @dsl ||= DSL.new(self)\n @dsl.instance_eval(&block)\n self\n end", "def render\n if @block\n instance_eval(&@block)\n end\n end", "def execute(&block)\n DSLHelper.new(Class => [:&, :|, :not]) do\n Kernel.load(File.join(File...
[ "0.7001058", "0.6772839", "0.6755337", "0.66568166", "0.65246576", "0.64727616", "0.64645255", "0.6356884", "0.6356884", "0.6287815", "0.62836623", "0.627724", "0.62623775", "0.6246424", "0.62230605", "0.6209218", "0.62003386", "0.61987364", "0.61869085", "0.6159928", "0.6104...
0.0
-1
Writes a string directly to the stream, without any filtering.
def write!( string ) @stream << string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(str)\n writing { write0 str }\n end", "def write(string)\n @handle.write(string)\n end", "def write(string)\n @buffer << string\n self\n end", "def write string\n end", "def write_(s)\n s = s.encode(@conf['encoding'], s.encoding)\n @sock.puts s\n log...
[ "0.75466233", "0.73717535", "0.7187002", "0.71484816", "0.6922733", "0.688927", "0.68741834", "0.67630714", "0.67505395", "0.6742431", "0.67225593", "0.65913945", "0.65913945", "0.65718716", "0.655634", "0.6544536", "0.6539199", "0.6489562", "0.64566904", "0.6446546", "0.6432...
0.82116294
0
USE ONLY if &f is assocoative, AT YOUR OWN RISK. s is used only for the last reduce.
def reduce (s, &f) self.parallelize{|slice| slice.reduce(&f)}.reduce(s, &f) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce\n _reduce = ->(acc, f, xs){\n xs == [] ? acc : _reduce.(f.(acc, xs[0]), f, xs[1..-1])\n }\n\n curry.(->(f, xs) {\n _reduce.(xs[0], f, xs[1..-1])\n })\n end", "def _reduce_1(val, _values, result)\n return \"\" \n result\nend", "def _reduce_667(val, _values, result); end", ...
[ "0.6401935", "0.6053761", "0.59972626", "0.5986387", "0.5986387", "0.59557736", "0.5932066", "0.5931145", "0.59285116", "0.5910238", "0.5904617", "0.5901731", "0.5901554", "0.58995897", "0.5892134", "0.5891917", "0.5890365", "0.5881632", "0.58763105", "0.5861768", "0.58616257...
0.721914
0
quantity quantity of the food unit gram/unit/kilo
def food Food.find(self.food_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quantity\n quantity_initial - quantity_consumed\n end", "def total_sugars\n food.sugars * quantity\n end", "def quantity\n 1\n end", "def total_cholesterol\n food.cholesterol * quantity\n end", "def qty()\n 1\n end", "def quantity\n read_integer('qua...
[ "0.7335919", "0.73286116", "0.7263488", "0.72568536", "0.7207919", "0.7204568", "0.7200629", "0.7200623", "0.71804833", "0.716172", "0.712698", "0.7123181", "0.7068726", "0.7064936", "0.7064936", "0.7049627", "0.7028739", "0.6983993", "0.69572914", "0.69571143", "0.69462746",...
0.0
-1
i^n mod p, where p is prime and i is a primitive root of p With this formula, generate a series through progressive squaring, from zero to (p1). Collect the residue, mod p and perform an xswap with each object's index number. The result will be the corresponding MOF series.
def mof(i, p) arr = [] x_swap = [] (0..(p-2)).each do |x| arr.push((i**x) % p) end (1..(p-1)).each do |n| x_swap.push((arr.index {|item| n == item }) % 12 ) end return x_swap end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mod_mult (p, n)\n q = p\n r = Point.new Float::INFINITY, Float::INFINITY\n\n while n > 0\n if n % 2 == 1\n r = self.mod_add r, q\n end\n\n q = self.mod_add q, q\n n = (n / 2).floor\n end\n r\n end", "def squared_primes(array)\n\n a=[]\n array...
[ "0.61392176", "0.588643", "0.57472026", "0.57002056", "0.5683183", "0.5673275", "0.5672151", "0.56346744", "0.56346744", "0.55487424", "0.5485087", "0.5465638", "0.5440824", "0.5367206", "0.53502285", "0.53487235", "0.5338467", "0.5331518", "0.5331102", "0.5328647", "0.528274...
0.7118193
0
create a random order of N (nonunique) items handy for testing and monte carlo method
def random_item items.to_a.sample end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_multiset_simple n\n @set.permutation(n).to_a.sort_by { rand }\n end", "def randn(n)\n (1..MAX_PK).to_a.shuffle!.take(n)\n end", "def pick!(n = nil)\n if n\n if n > self.size\n r = self.dup\n self.replace([])\n r\n else\n r = []\n ...
[ "0.6721891", "0.6655618", "0.6648356", "0.6602962", "0.6413543", "0.6404212", "0.63592046", "0.6325159", "0.63228416", "0.63053834", "0.62699354", "0.62311935", "0.62185025", "0.62082523", "0.6189463", "0.6155809", "0.61550593", "0.61501", "0.61398077", "0.6123339", "0.611919...
0.6156917
15
A callback initiated after successfully authenticating. This can be used to insert your own logic that is only run after the user successfully authenticates. Example: def after_ip_authentication(remote_ip) self.update_attribute(:invite_code, nil) end
def after_ip_authentication(_remote_ip); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_custom_authentication; end", "def after_ip_authentication\n end", "def after_custom_authentication\n\n end", "def callback\n rpx_auth\n after_auth(params[:on_complete_url])\n end", "def after_hash_token_authentication\n end", "def after_crowd_authentication\n end", "d...
[ "0.6595618", "0.65379465", "0.6419615", "0.60326874", "0.59665775", "0.5953205", "0.5950166", "0.5950166", "0.59467286", "0.5876996", "0.5848361", "0.58358914", "0.5788606", "0.5708852", "0.5708394", "0.5685545", "0.56622446", "0.56618494", "0.56517303", "0.56498915", "0.5636...
0.5928965
9
Card Test cards belonging in the card class
def test_card_members card = Card.new("A", "Hearts") assert_equal(card.value, 1) assert_equal(card.face, "A") assert_equal(card.is_ace, true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cards\n @cards\n end", "def initialize(cards)\n @cards = cards\n end", "def initialize(cards)\n @cards = cards\n end", "def initialize(cards)\n @cards = cards\n end", "def cards\n\t\t@cards.each do |card|\n\t\t\tputs card.card\n\t\tend\n\tend", "def initialize\n @cards = []\n ...
[ "0.707315", "0.70665234", "0.70665234", "0.70665234", "0.7052203", "0.7004935", "0.69747305", "0.69489425", "0.69261783", "0.6864857", "0.684946", "0.68325603", "0.68214726", "0.6771567", "0.6768702", "0.6721055", "0.66996026", "0.6685493", "0.66793084", "0.6665216", "0.66616...
0.7157642
0
Generates a new persistence identifier, ensuring that no object exists for the new URI.
def generate_new_location_uri candidate = nil loop do candidate = uri_prefix + pid_generator.next_pid break unless exists?(candidate) end candidate end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _new_id\n @lock.synchronize do\n begin\n # Generate a random number. It's recommended to not store more than\n # 2**62 objects in the same store.\n id = rand(2**64)\n # Ensure that we don't have already another object with this ID.\n end while @in_memory_o...
[ "0.6663946", "0.65618205", "0.64491725", "0.6353967", "0.6203314", "0.62010306", "0.6195559", "0.6176102", "0.615472", "0.61157405", "0.61072636", "0.60505223", "0.6030096", "0.60107934", "0.5985302", "0.5984192", "0.597313", "0.597313", "0.5971608", "0.5967458", "0.5962256",...
0.6074885
11
Checks to see whether anything currently exists at the given location.
def exists?(location_uri) r = client[connection.api.object_url(location_uri_to_fedora3_pid(location_uri), format: 'xml')].head # without disabling redirection, we should not get 3xx here (200..299).cover? r.code rescue RestClient::ExceptionWithResponse => e return false if e.response.code.eql? 404 raise e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists?(location_uri)\n raise NotImplementedError\n end", "def is_here?(element)\n element.exists?\n rescue\n false\n end", "def exists?\n !@not_found\n end", "def here?\n @locations.any?(&:here)\n end", "def exists?\n folder_location.present?\n e...
[ "0.7274327", "0.6738706", "0.6724346", "0.6704184", "0.6701831", "0.63999087", "0.63611555", "0.63513106", "0.63443905", "0.63250864", "0.6246865", "0.6222583", "0.6213896", "0.6213896", "0.6213896", "0.62010026", "0.61985993", "0.61985993", "0.6178999", "0.6174857", "0.61539...
0.6895828
1
GET /organizations GET /organizations.json
def index return unless params[:type] == 'building' @organizations = @organizations.only_categories(%w[Fraternity Sorority Independent Blitz Concessions]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = or...
[ "0.80765116", "0.80071", "0.78597564", "0.78338337", "0.78312206", "0.7745588", "0.7691283", "0.7672265", "0.76290935", "0.7590858", "0.7536119", "0.7533662", "0.7521284", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.750...
0.0
-1
GET /organizations/1 GET /organizations/1.json
def show @booth_chairs = @organization.booth_chairs @tools = Tool.checked_out_by_organization(@organization).just_tools @shifts = @organization.shifts @participants = @organization.participants @charges = @organization.charges end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end", "def show\n organization = current_user.organizations.find(params[:id])\n if organization\n render json: organization, status: 200\n else\n head 404\n end\n end", "def index\n ...
[ "0.7965355", "0.7789723", "0.7624976", "0.76014984", "0.75791377", "0.75791377", "0.75518954", "0.7519814", "0.74602246", "0.74229765", "0.7412952", "0.7383728", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559...
0.0
-1
GET /organizations/new GET /organizations/new.json
def new; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { ren...
[ "0.80002916", "0.80002916", "0.79110706", "0.7769764", "0.74969125", "0.7459801", "0.7459801", "0.7459801", "0.7459801", "0.7459801", "0.74499846", "0.7448206", "0.7431489", "0.7401061", "0.7384301", "0.73354286", "0.73137957", "0.7312422", "0.7312422", "0.7299635", "0.729592...
0.0
-1
POST /organizations POST /organizations.json
def create @organization.save respond_with(@organization) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CreateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n format.html { redire...
[ "0.7546241", "0.71868527", "0.703545", "0.70268863", "0.7016771", "0.6988308", "0.6930564", "0.69226116", "0.69226116", "0.69226116", "0.69226116", "0.6916983", "0.6892586", "0.68546283", "0.67094165", "0.670208", "0.6676121", "0.6673902", "0.6667356", "0.661678", "0.6606358"...
0.685141
14
PUT /organizations/1 PUT /organizations/1.json
def update @organization.update(organization_params) respond_with(@organization) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @organization = Organization.find(params[:id])\n @organization.update_attributes(organization_params)\n \n respond_with(@organization, :...
[ "0.78295016", "0.7434708", "0.7253623", "0.7247928", "0.7240768", "0.7187564", "0.7173343", "0.71054447", "0.70963454", "0.70263505", "0.6951313", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.69379544", "0.6911741", "0.6906686"...
0.71293944
7
DELETE /organizations/1 DELETE /organizations/1.json
def destroy @organization.destroy respond_with(@organization) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteOrganization id\n \n APICall(path: \"organizations/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n fo...
[ "0.7767288", "0.75106853", "0.75106853", "0.7457346", "0.7439525", "0.7439525", "0.7439525", "0.7331174", "0.73253006", "0.73227197", "0.7295465", "0.7285924", "0.7278945", "0.7270234", "0.726735", "0.72643864", "0.72632885", "0.723405", "0.7200872", "0.7193817", "0.71657467"...
0.69501054
52
Note: Midnight is 12:00:00AM on a 12hour clock, and 00:00:00 on a 24hour clock. Noon is 12:00:00PM on a 12hour clock, and 12:00:00 on a 24hour clock. Input Format A single string containing a time in hour clock format (i.e.: or ), where and . Output Format Convert and print the given time in hour format, where . Sample Input 07:05:45PM Sample Output 19:05:45
def timeConversion(s) time = s.split(':') if time.first == "12" && time.last[-2..-1] == 'AM' time[0] = time.first.to_i - 12 elsif time.first != "12" && time.last[-2..-1] == 'PM' time[0] = time.first.to_i + 12 end time.last.gsub!(/[PM AM pm am]/, '') # required to add leading zero to pass all hackerrank tests time[0] = '0' + time[0].to_s if time[0].to_s.size <= 1 time.join(":") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timeConversion(s)\n # Write your code here\n b = s[-2..-1] == 'PM' ? 12 : 0\n p b\n h = s.split(':')[0]\n h = h.to_i%12 + b\n p h\n p h.to_s + s[2..-3]\nend", "def convert_to_usable_time(xanga_time)\n arr = xanga_time.split(\" \")\n ret = arr[0]\n ret.insert(0,\"0\")...
[ "0.74392605", "0.7401905", "0.7399482", "0.7308697", "0.72945887", "0.72411305", "0.72367275", "0.72241366", "0.7184251", "0.7158791", "0.7097165", "0.7096342", "0.69559735", "0.6792906", "0.67880046", "0.6787258", "0.6785053", "0.67141044", "0.66891676", "0.66418207", "0.661...
0.7371044
3
Initializer. It prepares all the dirty stuff needed to have a
def initialize(args={}) @cfg = { :path => "/Users/cremes/dev/mygit/proto-rina/README.md", :id => 25, :len => 1024, :mode => Shared::IPC_CREAT, :access => Shared::IPC_W | Shared::IPC_R } @cfg.merge! args @key = Shared::try("ftok") {Shared::ftok(@cfg[:path], @cfg[:id])} @id = Shared::try("shmget") {Shared::shmget(@key, @cfg[:len], 0666 | @cfg[:mode])} p @id, @key, @cfg[:len], (0666 | @cfg[:mode]) @mem = Shared::shmat(@id, 0, @cfg[:access]) p @mem, @id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_init\n end", "def pre_initialize; end", "def init; end", "def init; end", "def init; end", "def init; end", "def pre_initialize\n end", "def init\n end", "def init\n end", "def init\n end", "def post_init\n end", "def at_init\n\n\t\tend", "def init\n\n end", ...
[ "0.7586399", "0.7392385", "0.7365339", "0.7365339", "0.7365339", "0.7365339", "0.7297682", "0.7227676", "0.7227676", "0.7227676", "0.72090983", "0.71922284", "0.7171496", "0.7045878", "0.7009534", "0.70022476", "0.70022476", "0.6986332", "0.69289833", "0.6917057", "0.68771005...
0.0
-1
Closes the shared memory area end frees its content.
def close Shared::try("dhmdt") {Shared::shmdt(@mem)} Shared::try("shmctl") {Shared::shmctl(@id, Shared::IPC_RMID, nil)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close\n @sp.close if @sp != nil\n @sp = nil\n end", "def close\n @io.close if @io\n @m.munmap if @m\n @m = nil\n @io = nil\n end", "def dispose\n call Memory.deAlloc(self)\n end", "def dispose\n call Memory.deAlloc(self)\n end", "def close() end", "def close() en...
[ "0.6465218", "0.63502145", "0.63124734", "0.63124734", "0.62463796", "0.62463796", "0.62463796", "0.62463796", "0.6243381", "0.6235345", "0.6208395", "0.61819994", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0...
0.68270093
0
Writes a string len bytes.
def write(str, len=nil) raise ArgumentError, "str must respond to :to_s" unless str.respond_to? :to_s @mem.write_string(str.to_s, len) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(string)\n send(string)\n string.length\n end", "def write(str)\n s = str.to_s\n # TODO: implement String#bytesize\n @length += s.size\n @writer.call s\n\n set_header(Rack::CONTENT_LENGTH, @length)\n str\n end", "def write(string)\n string.to_s.bytesize...
[ "0.7160371", "0.6932254", "0.67634094", "0.65381235", "0.64792395", "0.62913436", "0.61667496", "0.6080244", "0.60673696", "0.6021334", "0.6009206", "0.596005", "0.5925651", "0.59051514", "0.5896064", "0.58767563", "0.5869751", "0.5854464", "0.58264357", "0.58109885", "0.5783...
0.8049257
0
without refilling it. And you need to get from point A to point B, and the distance between them is 950 kilometers. Of course, you need to refuel on your way, and luckily, there are a few gas stations on your way from A to B. These are denoted by blue circles, and the numbers above them mean the distance from A to the corresponding gas station along the way from A to B. And you need to find the minimum number of refuels to get from A to B. input: we have a car which can travel at most L kilometers, where L is a parameter if it's filled up to full tank. We have a source and destination, A and B, and we have n gas station at distances from x1 to xn in kilometers, from A along the path from A to B. And we need to output the minimum number of refills to get from A to B, not counting the initial refill at A. We want to solve this problem using a greedy strategy, and greedy strategy in general is very easy. You first make some greedy choice, then you reduce your problem to a smaller subproblem, and then you iterate until there are no problems left. D = total distance between A and B
def min_refuel array_of_gas_station, total_distance, l_km t1 = Time.now total_refuel = 0 refueld_at = [] can_travel = l_km flag = "yes" array_of_gas_station.each_with_index do |arr,index| if arr > can_travel can_travel += l_km total_refuel += 1 refueld_at << (index-1) elsif arr == can_travel can_travel += l_km total_refuel += 1 refueld_at << index end end refueld_at.each_with_index do |arr, i| if refueld_at[i] == refueld_at[i+1] || refueld_at[i] < 0 flag = "no" end end if flag.eql? "yes" t2 = Time.now p "total refuel : #{total_refuel}" p "refueled at : #{refueld_at}" p "Time taken : #{t2 - t1}" else t2 = Time.now p "can't travel" p "Time taken : #{t2 - t1}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_refills(x,n,L)\n\t# total number of refills done so far\n\tnum_refills = 0\n\t# the stop from where we are evaluating whether or not to refill \n\tcurrent_stop = 0\n\n\t# while there are still stops on the road\n\twhile current_stop <= n\n\t\t# last stop where added gas\n\t\tlast_stop_refill = current_stop...
[ "0.71177846", "0.62346464", "0.61523235", "0.6033831", "0.6024065", "0.60100675", "0.5988783", "0.5965839", "0.595736", "0.5826507", "0.5799008", "0.5764749", "0.5764295", "0.57489306", "0.5745554", "0.5735429", "0.5727455", "0.5722662", "0.5702264", "0.5689565", "0.56660587"...
0.59606487
8
As a user, if 'modify' is selected, I am prompted to enter an id for the contact to be modified. As a user, when an id is entered, I am prompted to type 'yes' or 'no' to confirm my selection. As a user, if 'yes' is typed, I am prompted to change 'firstname', 'lastname', 'email' or 'notes' by number. You shouldn't be able to change the 'id'.
def modify_contact puts "Please enter the id of the contact to modify: " id = gets.chomp.to_i puts "Please confirm 'yes' or 'no' to modify this contact: " puts @rolodex.display_contact(id) answer = gets.chomp.downcase if answer == 'yes' puts "Please enter the number of the attribute you would like to edit: \n 1. First Name \n 2. Last Namme \n 3. Email \n 4. Note" option = gets.chomp.to_i puts "Please provide the edit:" new_attribute = gets.chomp @rolodex.modify_contact(id, option, new_attribute) puts "Edit complete: " puts @rolodex.display_contact(id) elsif answer == 'no' return else puts "That is not a valid answer, please try again." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_contact\n puts \"Enter the id of the contact you would like to modify\"\n id_to_modify = gets.chomp \n\n contact = Contact.find(id_to_modify)\n \n puts \"Are you sure? (y/n)\"\n \tuser_input = gets.chomp\n\n if user_input == \"y\"\n puts \"Enter the id of the contact that you wou...
[ "0.7670978", "0.767083", "0.7332969", "0.7313281", "0.7264931", "0.7229206", "0.7188044", "0.7134588", "0.6988199", "0.6899287", "0.6848723", "0.6702242", "0.66444314", "0.6616212", "0.6594362", "0.6581", "0.65768516", "0.651908", "0.6315838", "0.6197697", "0.61948967", "0....
0.7869783
0
As a user, if 'display attribute' is selected, I am prompted to enter an attribute ('firstname', 'lastname', 'email', or 'notes') so that I can see all of the contacts according to that attribute.
def display_attribute puts "Please enter an attribute: " attribute = gets.chomp @rolodex.display_attribute(attribute) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_info_by_attribute(contact)\n puts \"Enter attribute you want to display\"\n puts \"(1) First name\"\n puts \"(2) Last name\"\n puts \"(3) Email\"\n puts \"(4) Note\"\n att = gets.chomp.to_i\n print \"Is this the correct contact y/n?: \"\n user_choice = gets.chomp\n if user_ch...
[ "0.7907715", "0.7787269", "0.7581397", "0.73593324", "0.7228612", "0.70733535", "0.6630586", "0.6630586", "0.6598577", "0.6567943", "0.6505169", "0.6167311", "0.6132295", "0.610253", "0.6082505", "0.6054668", "0.60449684", "0.60171616", "0.6008596", "0.59610456", "0.5958544",...
0.6810416
6
Returns the type of this comment. Inline comments correspond to `:inline`: whatever Block comments correspond to `:document`: =begin hi i am a document =end
def type case text when /^#/ :inline when /^=begin/ :document end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comment?\n [\"text\", \"text_wholepage\"].include?(@type)\n end", "def commentable_type\n read_attribute(:commentable_type) == 'Topic' ? Topic.find(commentable_id).class.to_s : read_attribute(:commentable_type)\n end", "def type comment\n comment.nil? ? 'Solution' : 'Comment'\n end", "def get...
[ "0.6380302", "0.6371671", "0.6371038", "0.6366362", "0.6309205", "0.6304772", "0.60622334", "0.604331", "0.59842545", "0.5919068", "0.5901766", "0.5866075", "0.58624786", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5847068", ...
0.7114647
0
Compares comments. Two comments are identical if they correspond to the same source range.
def ==(other) other.is_a?(Source::Comment) && @location == other.location end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_parses_with_comments(ast_pattern, source, comments_pattern)\n with_versions(ALL_VERSIONS) do |_ver, parser|\n source_file = Parser::Source::Buffer.new('(comments)', source: source)\n\n comments_pattern_here = comments_pattern.map do |(from, to)|\n range = Parser::Source::Range.new(so...
[ "0.63363314", "0.6174508", "0.5982283", "0.59663063", "0.5859584", "0.5847983", "0.58178973", "0.58064544", "0.58064544", "0.5803391", "0.5803391", "0.5803391", "0.57457685", "0.5739237", "0.57106584", "0.56896263", "0.56792617", "0.56792617", "0.5666213", "0.56462944", "0.56...
0.6715794
0
GET /badges GET /badges.json
def index @games = Game.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def badges\n get(\"user/#{user_id}/badges.json\")\n end", "def badges(id)\n get(\"users/#{id}/badges\")\n end", "def badges(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/badges.json\")\n end", "def badges(options={})\n self.class.parse_badges(...
[ "0.87536204", "0.8055727", "0.77719414", "0.7684046", "0.7552645", "0.74981487", "0.72334045", "0.713744", "0.6892226", "0.6846787", "0.68157053", "0.67125493", "0.6708214", "0.66353303", "0.6620842", "0.65226746", "0.65138704", "0.65126044", "0.64497757", "0.64222705", "0.64...
0.0
-1
DELETE /badges/1 DELETE /badges/1.json
def destroy @game.destroy respond_to do |format| format.html { redirect_to admin_users_path(@admin), notice: 'Game was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, not...
[ "0.79502434", "0.77699876", "0.77665925", "0.7672124", "0.7605875", "0.7516433", "0.6969911", "0.69289273", "0.672313", "0.6656472", "0.6632456", "0.6632145", "0.6627479", "0.6593265", "0.6510939", "0.6510934", "0.6457726", "0.6455014", "0.64465874", "0.64278996", "0.64102", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_game @game = game.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def badge_params params[:user].permit(:name, :badge, :admin_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69802505", "0.6781974", "0.67470175", "0.67430073", "0.67350477", "0.6593221", "0.6504263", "0.64988977", "0.6481794", "0.64800006", "0.64568025", "0.64411247", "0.6379476", "0.63765615", "0.6368045", "0.6320141", "0.6300363", "0.6300057", "0.62952244", "0.6294712", "0.629...
0.0
-1
HTTParty raises an errors after time limit defined by ::default_timeout if it cannot connect to server, then it raises Net::OpenTimeout if it cannot read response from server, then it raises Net::ReadTimeout
def handle_timeouts yield rescue Net::OpenTimeout, Net::ReadTimeout {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def http_get(url)\n response = HTTParty.get(url)\n\n puts url\n\n if response.key?('errorMessage')\n puts 'error, retry...'\n begin\n http_get(url)\n rescue Net::ReadTimeout\n puts 'takes too long to respond, retry...'\n http_get(url)\n end\n else\n puts 'no error, return'\n re...
[ "0.7373712", "0.72976816", "0.6759297", "0.67525446", "0.66723037", "0.66665757", "0.66437876", "0.6566575", "0.65500784", "0.65281385", "0.65281385", "0.6470986", "0.64634985", "0.64576036", "0.64485043", "0.6425141", "0.6394152", "0.63933957", "0.6325352", "0.6325352", "0.6...
0.7299478
1
Resize the image to fit within the specified dimensions while retaining the aspect ratio of the original image. If necessary, crop the image in the larger dimension. Possible values for options[:gravity] are: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast
def resize(path) gravity = @options.key?(:gravity) ? @options[:gravity] : 'Center' img = MiniMagick::Image.open(@file) cols, rows = img[:dimensions] img.combine_options do |cmd| if @width != cols || @height != rows scale_x = @width/cols.to_f scale_y = @height/rows.to_f if scale_x >= scale_y cols = (scale_x * (cols + 0.5)).round rows = (scale_x * (rows + 0.5)).round cmd.resize "#{cols}" else cols = (scale_y * (cols + 0.5)).round rows = (scale_y * (rows + 0.5)).round cmd.resize "x#{rows}" end end cmd.quality @options[:quality] if @options.key?(:quality) cmd.gravity gravity cmd.background 'rgba(255,255,255,0.0)' cmd.extent "#{@width}x#{@height}" if cols != @width || rows != @height end img.write(path) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cut_to_fit(options)\n %Q{-thumbnail #{options.width}x#{options.height}^ \\\n -gravity #{options.gravity} \\\n -unsharp 0x.5 \\\n -auto-orient \\\n -extent #{options.width}x#{options.height}}\n end", "def resize_with_crop(w, h, options = {})\n gravity = o...
[ "0.68711936", "0.676364", "0.67492026", "0.6653965", "0.66281796", "0.65456635", "0.6379377", "0.63703144", "0.6335966", "0.6228251", "0.6186818", "0.6184387", "0.61810917", "0.6165767", "0.6144524", "0.60968006", "0.60968006", "0.6029723", "0.60177845", "0.60110766", "0.5991...
0.65981674
5
A singleuse login link for Express accounts to access their Stripe dashboard
def login_link(**options) ::Stripe::Account.create_login_link(processor_id) rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_url\n generate_login_token unless login_token.present?\n ENV['RESERVE_URL'] + '/sign-in/' + login_token\n end", "def connect\n connector = StripeConnect.new( current_user )\n connect_url, error = connector.connect_url( redirect_uri: confirm_users_url )\n\n if connect_url.nil?\n fla...
[ "0.64338595", "0.6402026", "0.6330011", "0.62373126", "0.6001847", "0.5928493", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5894325", "0.5872273", "0.58568376", "0.5845082", "0.5832217", "0.58172125",...
0.6526143
0
Transfer money from the platform to this connected account
def transfer(amount:, currency: "usd", **options) ::Stripe::Transfer.create({ amount: amount, currency: currency, destination: processor_id }.merge(options)) rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transfer(amount,to,memo=nil)\n client.post(transaction_url,{:amount=>amount,:to=>to,:memo=>memo}) if client\n end", "def transfer(amount, other)\n @balance -= amount\n other.balance += amount\n puts \"#{@owner} your balance will be #{@balance} after the transfering to #{other.owner}\"\n end...
[ "0.70087665", "0.7006318", "0.69888043", "0.69229966", "0.69038266", "0.68295", "0.68111616", "0.67981184", "0.6719248", "0.66791123", "0.6669493", "0.66501474", "0.6639558", "0.6621356", "0.6602872", "0.656344", "0.6552691", "0.6551508", "0.65243673", "0.651749", "0.64946085...
0.0
-1
Retourne true si l'user a une autorisation icarien
def has_autorisation_icarien?(duser) drequest = { where: {user_id: duser[:id], raison: 'ICARIEN ACTIF'} } table_autorisations_online.count(drequest) > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fully_authed?\n !(user.nil? || password.nil?)\n end", "def authorized?\n if $credentials != nil\n @Userz = User.first(:username => $credentials[0])\n if @Userz\n if @Userz.edit == true\n return true\n else\n ...
[ "0.75615644", "0.7354853", "0.72822124", "0.72623444", "0.72504246", "0.72224027", "0.71456814", "0.7091601", "0.7083509", "0.7068737", "0.7060223", "0.70302737", "0.70252806", "0.70240587", "0.70169854", "0.6987988", "0.6964478", "0.6964335", "0.6963867", "0.69626135", "0.69...
0.7055177
11
authenticate an end user through api (creator)
def authenticate_api_token if request.headers["Authorization"].present? auth_header = request.headers['Authorization'].split(' ').last #try to get the data from jwt token @payload = decode auth_header #couldnt get data for whatever reason if !@payload render json: { error: "Problem med autentiseringssträngen. Försök att logga in igen." }, status: :bad_request #success! else @payload end #no token was sent with header else render json: { error: "En autentiseringssträng krävs."}, status: :forbidden # The header isn´t present end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_auth\n creator = Creator.find_by(username: request.headers[:username])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end", ...
[ "0.8111138", "0.79972166", "0.7672294", "0.7579332", "0.7407124", "0.7370928", "0.73388743", "0.73003125", "0.73003125", "0.72622067", "0.71878606", "0.7119684", "0.71135455", "0.70811915", "0.70805335", "0.706688", "0.7066381", "0.70249623", "0.70173377", "0.70173377", "0.69...
0.0
-1
encode jwt token with some user info.
def encode(creator) #data to be saved in JSON payload = { id: creator.id, userName: creator.userName, expires: 2.hours.from_now.to_i} #very much safe JWT.encode( payload, Rails.application.secrets.secret_key_base, "HS512") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_token(payload) # arg is data identifying user — e.g., DB id and username\n \n JWT.encode(payload, secret,algorithm)\n end", "def encode_token(payload) #encodes your username\n JWT.encode(payload, ENV['SECRET'])\n end", "def encode_token(payload)\n # I expect something like payload...
[ "0.84249854", "0.81916314", "0.81704336", "0.80670553", "0.80382407", "0.80230844", "0.78954375", "0.7851505", "0.7799227", "0.7790294", "0.76953954", "0.76314104", "0.7589528", "0.75711215", "0.7547424", "0.7483958", "0.7466236", "0.7420829", "0.74078274", "0.73513883", "0.7...
0.7560801
14
check so jwt token looks ok
def decode(token) payload = JWT.decode(token, Rails.application.secrets.secret_key_base, "HS512") #check expiration time and return if still fresh if payload[0]["expires"] >= Time.now.to_i payload[0] #old token else false end #couldn't decode token rescue false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate\n token = jwt\n return unless token\n token.validate\n end", "def verify_jwt_token\n head :unauthorized if request.headers['Authorization'].nil? ||\n !AuthToken.valid?(request.headers['Authorization'].split(' ').last)\n end", "def verify_jwt_token\n begin\n ...
[ "0.8277854", "0.8028546", "0.7849945", "0.768868", "0.7674077", "0.7668755", "0.7651806", "0.7630365", "0.75399965", "0.74746734", "0.7453291", "0.741709", "0.73746973", "0.73735464", "0.73695624", "0.7356309", "0.7301621", "0.72854567", "0.7258933", "0.72148865", "0.7212866"...
0.7086127
31
converts 0terminated ASCII string to ruby string
def asciiz_to_str(asciiz) zero_byte_idx = asciiz.index("\x00") if zero_byte_idx != nil return asciiz[0, zero_byte_idx] else return asciiz end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end", "def asciiz_to_str(asciiz)\n\t\t\t\t\t\t\tzero_byte_idx = asciiz.index(\"\\x00\")\n\t\t\t\t\t\t\tif zero_byte_idx != nil\n\t\t\t\t\t\t\t\treturn asciiz[0, zero_byte_idx]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t...
[ "0.6826558", "0.66348594", "0.66280144", "0.66049564", "0.6590987", "0.65588754", "0.6540646", "0.6517224", "0.65146315", "0.6509764", "0.6485041", "0.6485041", "0.63960546", "0.63591695", "0.63521105", "0.6332553", "0.63181746", "0.62761414", "0.6260183", "0.625749", "0.6233...
0.673281
1
converts ruby string to zeroterminated WCHAR string
def str_to_uni_z(str) enc = str.encode('UTF-16LE').force_encoding('binary') enc += "\x00\x00" return enc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end", "def toutf8(str)\n ::NKF::nkf('-wm', str)\n end", "def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend", "def read_wstring(p...
[ "0.6431486", "0.6391995", "0.59874135", "0.5955165", "0.5926847", "0.5863911", "0.57815164", "0.5760506", "0.57093066", "0.5672315", "0.56306213", "0.5539554", "0.551608", "0.539294", "0.52962923", "0.5289942", "0.52657145", "0.5259343", "0.5255698", "0.524429", "0.52297443",...
0.60921353
2
converts 0terminated UTF16 to ruby string
def uniz_to_str(uniz) uniz.force_encoding('UTF-16LE').encode('UTF-8') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_utf16\r\n Iconv.iconv(\"utf-16LE\", \"utf-8\", self).first + \"\\x00\\x00\"\r\n end", "def from_utf16\r\n ret = Iconv.iconv(\"utf-8\", \"utf-16le\", self).first\r\n if ret[-1] == 0\r\n ret = ret[0..-2]\r\n end\r\n end", "def from_u...
[ "0.77126575", "0.7271607", "0.7269446", "0.7199437", "0.7115227", "0.6987118", "0.69070077", "0.68631154", "0.662868", "0.6573966", "0.6479391", "0.62668204", "0.6221663", "0.62088335", "0.62075686", "0.6115668", "0.6109874", "0.6107324", "0.60561806", "0.605347", "0.6009152"...
0.6867994
7
parses a number param and returns the value raises an exception if the param cannot be converted to a number examples: nil => 0 3 => 3 "MB_OK" => 0 "SOME_CONSTANT | OTHER_CONSTANT" => 17 "tuna" => !!!!!!!!!!Exception Parameter "consts_mgr" is a ConstantManager
def param_to_number(v, consts_mgr = @consts_mgr) if v.class == NilClass then return 0 elsif v.kind_of? Integer then return v # ok, it's already a number elsif v.kind_of? String then dw = consts_mgr.parse(v) # might raise an exception if dw != nil return dw else raise ArgumentError, "Param #{v} (class #{v.class}) cannot be converted to a number. It's a string but matches no constants I know." end else raise "Param #{v} (class #{v.class}) should be a number but isn't" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_numeric_constant\n if peek?(:LIT_INT)\n ExprInt.new(expect(:LIT_INT))\n else\n ExprFloat.new(expect(:LIT_FLOAT))\n end\n end", "def parseNumber _args\n \"parseNumber _args;\" \n end", "def number\n # -> uncomment the next line to manually enable rule tracing\n # ...
[ "0.62339985", "0.6207843", "0.60914016", "0.60410696", "0.602025", "0.5942447", "0.5900362", "0.58967775", "0.58392525", "0.5786673", "0.5775598", "0.57234186", "0.57106143", "0.57106143", "0.56917995", "0.5656442", "0.5652993", "0.56514347", "0.56455946", "0.5641099", "0.563...
0.7642137
0
assembles the buffers "in" and "inout"
def assemble_buffer(direction, function, args) layout = {} # paramName => BufferItem blob = "" #puts " building buffer: #{direction}" function.params.each_with_index do |param_desc, param_idx| #puts " processing #{param_desc[0]} #{param_desc[1]} #{param_desc[2]}" # we care only about inout buffers if param_desc[2] == direction buffer = nil # Special case: # The user can choose to supply a Null pointer instead of a buffer # in this case we don't need space in any heap buffer if param_desc[0][0,1] == 'P' # type is a pointer if args[param_idx] == nil next end end case param_desc[0] # required argument type when "PDWORD" dw = param_to_number(args[param_idx]) buffer = [dw].pack('V') when "PWCHAR" raise "param #{param_desc[1]}: string expected" unless args[param_idx].class == String buffer = str_to_uni_z(args[param_idx]) when "PCHAR" raise "param #{param_desc[1]}: string expected" unless args[param_idx].class == String buffer = str_to_ascii_z(args[param_idx]) when "PBLOB" raise "param #{param_desc[1]}: please supply your BLOB as string!" unless args[param_idx].class == String buffer = args[param_idx] # other types (non-pointers) don't reference buffers # and don't need any treatment here end if buffer != nil #puts " adding #{buffer.length} bytes to heap blob" layout[param_desc[1]] = BufferItem.new(param_idx, blob.length, buffer.length, param_desc[0]) blob += buffer # sf: force 8 byte alignment to satisfy x64, wont matter on x86. while( blob.length % 8 != 0 ) blob += "\x00" end #puts " heap blob size now #{blob.length}" end end end #puts " built buffer: #{direction}" return [layout, blob] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def out_buffers; @out_buffers; end", "def receive_out_arguments(*types)\n\n #Create a pointer to each of the requested types.\n pointers = types.map { |type| FFI::MemoryPointer.new(type) }\n\n #Yield each of the pointers to the given block.\n yield(*pointers)\n\n #Read each of ...
[ "0.70660084", "0.66418654", "0.6359748", "0.62572575", "0.6142362", "0.6142362", "0.6142362", "0.61342454", "0.61342454", "0.60732245", "0.59306526", "0.5913204", "0.5861195", "0.58545095", "0.5722738", "0.56917465", "0.56917065", "0.56917065", "0.5688953", "0.5663412", "0.56...
0.59630877
10
RESEARCHERS don't have a profile, but they shouldn't have a U.Va. computing id.
def virginia_borrower? # @profile !~ /^[a-z]{2,3}([0-9][a-z]{1,2})?$/i profile.match?(/Virginia Borrower|Other VA Faculty|Alum/i) || profile.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_profile (profile_name)\n # Find the matching profile\n profile_data = @master_data.select { |p, d| p[/^#{profile_name}/] }\n profile_count = profile_data.count\n if profile_count > 1\n puts \"Profile match not specific enough. Please refine match\"\n exit 1\n elsif profile_count < 1\n puts \...
[ "0.57742465", "0.55844605", "0.5362191", "0.52931607", "0.52541614", "0.52518713", "0.52007985", "0.5175641", "0.51248634", "0.5113948", "0.509429", "0.50562435", "0.50559705", "0.5047303", "0.50360304", "0.5018535", "0.50017405", "0.4994866", "0.4987648", "0.49832666", "0.49...
0.62510306
0
Indicate whether the user can make LEO requests.
def can_use_leo? faculty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_access?\n allows_current_user_access_to? :access\n end", "def can_make_leaderbit_active?\n system_admin?\n end", "def requestable?\n (ill? || available? || recallable? ||\n processing? || on_order? || offsite? || ezborrow?)\n end", "def has_access?\n true\n end", "def has...
[ "0.6835903", "0.68082494", "0.67199904", "0.66991717", "0.66991717", "0.6541649", "0.6534193", "0.65265447", "0.64978856", "0.64619035", "0.6459172", "0.6442419", "0.64302295", "0.6411048", "0.640631", "0.6359368", "0.63518286", "0.63334036", "0.6331683", "0.63188004", "0.630...
0.6672446
5
Indicate whether the user can make Interlibrary Loan requests.
def can_use_ill? !virginia_borrower? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_access?\n allows_current_user_access_to? :access\n end", "def rollcall_isd_required\n if current_user.has_non_public_role?(:rollcall)\n return true\n else\n redirect_to :action => \"unauthorized\", :controller => 'rollcall/rollcall_app'\n return false\n end\n end", "def loa...
[ "0.6588476", "0.6532069", "0.6531698", "0.6522074", "0.6485742", "0.6448632", "0.6448632", "0.64459956", "0.6398791", "0.6386855", "0.63670903", "0.6344715", "0.6311231", "0.6307324", "0.63029677", "0.6298655", "0.627857", "0.62715656", "0.6265863", "0.6244471", "0.6242587", ...
0.6187547
25
Indicate whether the user can place items on course reserve.
def can_make_reserves? !undergraduate? && !virginia_borrower? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_add_course?\n self.available_courses > 0 || self.clearance?\n end", "def can_create_reserve_schedule?\n kit_schedule = KitSchedule.new\n kit_schedule.current_user = User.current_user\n return kit_schedule.can_create_reserve?(self.center_ids)\n end", "def quantity_cat_allowed?(reservations...
[ "0.695287", "0.6828737", "0.67396617", "0.6489839", "0.64477384", "0.63922393", "0.63138723", "0.63077044", "0.627996", "0.62151104", "0.6207479", "0.6204981", "0.6193661", "0.61868215", "0.61826515", "0.61429346", "0.6136469", "0.6124357", "0.6121084", "0.6102407", "0.607678...
0.6440669
5
Indicate whether the user can recommend an item for purchase.
def can_request_purchase? true # TODO: Should this be !virginia_borrower? ? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_buy?(item)\r\n item.buyable_by?(self)\r\n end", "def recommendable?() false end", "def can_buy?(item)\n item.buyable_by?(self)\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def item_usable?\n user.usable?(item) && item_effects_valid?\n en...
[ "0.7157503", "0.7148289", "0.7135049", "0.68390083", "0.6827606", "0.66412073", "0.6575622", "0.65648973", "0.6534497", "0.6449945", "0.64439887", "0.6420681", "0.63699496", "0.63678914", "0.6348184", "0.6330634", "0.6326045", "0.631778", "0.63173556", "0.63016737", "0.629554...
0.63130325
19
Indicate whether the user can request item scanning.
def can_request_scanning? true # TODO: Should this be !virginia_borrower? ? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_allowed?(scan_result)\n logger.debug scan_result\n (scan_result['response_code'] < 1) || !contains_in_bases?(scan_result)\n end", "def validate_item_results?\n if @item.user.private\n authenticate_user!\n if !current_user.subscribed_to(@item.user)\n return false\n end...
[ "0.6683219", "0.64934236", "0.6476095", "0.6403977", "0.63911766", "0.6346303", "0.63239706", "0.6288409", "0.6245314", "0.6237274", "0.6226871", "0.6226871", "0.620057", "0.61792797", "0.6166664", "0.6158132", "0.61561495", "0.61561495", "0.61387146", "0.6111477", "0.6111416...
0.7451331
0
Notice how it's currently impossible to tell if a key is simply mistyped as a public or private key, or if it's a badly formatted key. Too bad.
def test_bogus_raise bogus_key = "Oh hey I'm a key. Ok, not really." assert_raise OpenSSL::PKey::PKeyError do Net::SSH::Utils::Key.fingerprint(:data => bogus_key) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_key?(key)\n return false unless key.is_a?(String)\n return false unless key = encoded_key(key)\n key.length >= 2 && key.length <= 255 && (key !~ BAD_KEY_RE rescue false)\n end", "def valid_key(key)\n valid_rsa_key(key) && (key['x5c']&.length || (key['n'] && key['e']))\n end", "def v...
[ "0.7068131", "0.698523", "0.66918844", "0.6560176", "0.6560176", "0.65575236", "0.6521562", "0.64730006", "0.64236367", "0.6412967", "0.6370177", "0.6334298", "0.63255316", "0.6294084", "0.6239767", "0.6216906", "0.61859053", "0.6165006", "0.60283136", "0.6022161", "0.6019604...
0.64606845
8
Update properties of this object
def update!(**args) @audit_log_configs = args[:audit_log_configs] if args.key?(:audit_log_configs) @service = args[:service] if args.key?(:service) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @exempted_members = args[:exempted_members] if args.key?(:exempted_members) @log_type = args[:log_type] if args.key?(:log_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @condition = args[:condition] if args.key?(:condition) @members = args[:members] if args.key?(:members) @role = args[:role] if args.key?(:role) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @matched_permissions = args[:matched_permissions] if args.key?(:matched_permissions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.70124525", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.6738901", "0.67084897", "0.67084897", "0.66983044", "0.66983044", "0.66983044", "0.66983044", "0.66188794", "0.6571416", "0.6538292", "0.65194744", "0.63953435", "0.63903284", "0.63903284", ...
0.0
-1
Update properties of this object
def update!(**args) @description = args[:description] if args.key?(:description) @expression = args[:expression] if args.key?(:expression) @location = args[:location] if args.key?(:location) @title = args[:title] if args.key?(:title) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @explanation = args[:explanation] if args.key?(:explanation) @policy = args[:policy] if args.key?(:policy) @project = args[:project] if args.key?(:project) @resource = args[:resource] if args.key?(:resource) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @permissions = args[:permissions] if args.key?(:permissions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @audit_configs = args[:audit_configs] if args.key?(:audit_configs) @bindings = args[:bindings] if args.key?(:bindings) @etag = args[:etag] if args.key?(:etag) @version = args[:version] if args.key?(:version) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.70124525", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.6738901", "0.67084897", "0.67084897", "0.66983044", "0.66983044", "0.66983044", "0.66983044", "0.66188794", "0.6571416", "0.6538292", "0.65194744", "0.63953435", "0.63903284", "0.63903284", ...
0.0
-1
Update properties of this object
def update!(**args) @next_page_token = args[:next_page_token] if args.key?(:next_page_token) @results = args[:results] if args.key?(:results) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @next_page_token = args[:next_page_token] if args.key?(:next_page_token) @results = args[:results] if args.key?(:results) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
Update properties of this object
def update!(**args) @additional_attributes = args[:additional_attributes] if args.key?(:additional_attributes) @asset_type = args[:asset_type] if args.key?(:asset_type) @description = args[:description] if args.key?(:description) @display_name = args[:display_name] if args.key?(:display_name) @labels = args[:labels] if args.key?(:labels) @location = args[:location] if args.key?(:location) @name = args[:name] if args.key?(:name) @network_tags = args[:network_tags] if args.key?(:network_tags) @project = args[:project] if args.key?(:project) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n ...
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328...
0.0
-1
In JRuby HTMLScanner is somehow loaded before this class and all String returned do not use StringFormatter refinement. Mapping HTMLScanner output with `to_s` method ensures those strings are using the StringFormatter refinement.
def periods @periods ||= HTMLScanner.new(thead).all("th").map { |e| e.to_s.strip_html.squish } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_simple\n HtmlFormatter.new(self, options).to_s\n end", "def to_s\n @parser ||= WikitextParser.new\n @parsed ||= @parser.parse(@string).to_s\n end", "def html_string\n @html.join(\"\")\n end", "def html2text\n doc = self.scrape.hdoc\n text = node_to_text(doc)\n# ...
[ "0.65539694", "0.6337547", "0.60731256", "0.6029887", "0.59733486", "0.58989763", "0.5893461", "0.5859967", "0.5849473", "0.57687694", "0.56923485", "0.5690252", "0.56864876", "0.56626284", "0.56611425", "0.5656557", "0.56231284", "0.5603021", "0.558099", "0.5562777", "0.5558...
0.0
-1
Basically, the rest of the functions here are simply implementing Enumerable. You can probalbly skip reading these, but start reading again at the "private" keywordthere are plenty of methods there that you may want to know about.
def [] which @activity_log[which] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterator()\n raise NotImplementedError\n end", "def enumerator ; end", "def enumerator ; end", "def enumerator; end", "def get_iterator\n\t\tend", "def through; end", "def each # And define each on top of next\n loop {yield self.next }\n end", "def list\n return @enumerable\n end", ...
[ "0.65930915", "0.62626314", "0.62626314", "0.6219581", "0.62102324", "0.6177583", "0.59968305", "0.59596276", "0.5875629", "0.58463424", "0.5828805", "0.57927144", "0.57927144", "0.57927144", "0.57927144", "0.57927144", "0.57927144", "0.5755338", "0.5699245", "0.5689466", "0....
0.0
-1
GET /skydata/1 GET /skydata/1.json
def show @skydatum = Skydatum.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @skydatum } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end", "def index \n\t@skyrequest = Skyrequest::Connector.all.first\n...
[ "0.6829497", "0.6247083", "0.6238176", "0.61522734", "0.6127507", "0.6115243", "0.6096944", "0.6081085", "0.60582757", "0.6055503", "0.60550386", "0.6037855", "0.6026869", "0.5995837", "0.5995837", "0.59456366", "0.59098107", "0.5899252", "0.58925456", "0.5881252", "0.5866732...
0.71188694
0
GET /skydata/new GET /skydata/new.json
def new @skydatum = Skydatum.new respond_to do |format| format.html # new.html.erb format.json { render json: @skydatum } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @skydatum = Skydatum.new(params[:skydatum])\n\n respond_to do |format|\n if @skydatum.save\n format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' }\n format.json { render json: @skydatum, status: :created, location: @skydatum }\n else\n ...
[ "0.6810448", "0.6803557", "0.67507285", "0.6744339", "0.6744339", "0.6675255", "0.6573055", "0.6561094", "0.6553184", "0.6551011", "0.6516404", "0.6516404", "0.6513286", "0.6508919", "0.6491953", "0.6461754", "0.64489913", "0.6439948", "0.6439326", "0.64370465", "0.64351285",...
0.75690526
0
POST /skydata POST /skydata.json
def create @skydatum = Skydatum.new(params[:skydatum]) respond_to do |format| if @skydatum.save format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' } format.json { render json: @skydatum, status: :created, location: @skydatum } else format.html { render action: "new" } format.json { render json: @skydatum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @sky = Sky.new(sky_params)\n\n respond_to do |format|\n if @sky.save\n format.html { redirect_to @sky, notice: 'Sky was successfully created.' }\n format.json { render :show, status: :created, location: @sky }\n else\n format.html { render :new }\n format.js...
[ "0.69015986", "0.6075114", "0.5954964", "0.5856782", "0.55876577", "0.558316", "0.55304563", "0.5490992", "0.5442317", "0.54271805", "0.5388965", "0.53783524", "0.5361033", "0.5328871", "0.53170747", "0.53074276", "0.53010297", "0.52858555", "0.528165", "0.5276898", "0.527114...
0.6743967
1
PUT /skydata/1 PUT /skydata/1.json
def update @skydatum = Skydatum.find(params[:id]) respond_to do |format| if @skydatum.update_attributes(params[:skydatum]) format.html { redirect_to @skydatum, notice: 'Skydatum was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @skydatum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @sky.update(sky_params)\n format.html { redirect_to @sky, notice: 'Sky was successfully updated.' }\n format.json { render :show, status: :ok, location: @sky }\n else\n format.html { render :edit }\n format.json { render json: @sky.e...
[ "0.6673671", "0.6190524", "0.6128267", "0.60708034", "0.59574443", "0.5956493", "0.59364563", "0.57902145", "0.57610625", "0.57604295", "0.5743673", "0.5713474", "0.5699177", "0.56764513", "0.56631386", "0.5649809", "0.5641391", "0.56283784", "0.5625239", "0.56158745", "0.561...
0.66098225
1
DELETE /skydata/1 DELETE /skydata/1.json
def destroy @skydatum = Skydatum.find(params[:id]) @skydatum.destroy respond_to do |format| format.html { redirect_to skydata_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def api_delete(path, data = {})\n...
[ "0.7065175", "0.70328176", "0.6761301", "0.6746985", "0.66991705", "0.6678536", "0.6649326", "0.66250056", "0.66250056", "0.66237664", "0.6608072", "0.6595052", "0.6554437", "0.65450907", "0.65388983", "0.65388983", "0.6516033", "0.6509626", "0.6499219", "0.64822525", "0.6480...
0.7398046
0