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
Simply parse the comment for plus ones
def parse_comment_body(comment_body) # Ignore common markdown prefixes comment_body = comment_body.gsub(/^(>\s|\#{1,4}\s|\*\s|\+\s|-\s).+/u, '') plus_one_regex_pattern = Regexp.new('(' + PLUS_ONE_COMMENTS.map{|item| Regexp.escape(item)}.join('|') + ')') neg_one_regex_pattern = Regexp.new('(' + NEG_ONE_COMMENTS.map{|item| Regexp.escape(item)}.join('|') + ')') total_plus = comment_body.scan(plus_one_regex_pattern).count total_neg = comment_body.scan(neg_one_regex_pattern).count net_pluses = total_plus - total_neg if net_pluses > 0 net_pluses = 1 elsif net_pluses < 0 net_pluses = -1 end return net_pluses end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_with_comments(source); end", "def parse_comments(comments); end", "def parse_with_comments(source_buffer); end", "def parse_with_comments(source_buffer); end", "def parse_with_comments(source_buffer); end", "def parse_comments\n @data[4][0]\n end", "def scan_for_plus(token); end", "def ...
[ "0.69790125", "0.67527467", "0.6735746", "0.6735746", "0.6735746", "0.6641692", "0.6530477", "0.649971", "0.64747095", "0.62162894", "0.6007913", "0.59899265", "0.5982973", "0.59709007", "0.59277725", "0.5925145", "0.59088796", "0.5883426", "0.58637583", "0.58637583", "0.5863...
0.57059443
33
Ensure the delivered webhook is from Github
def verify_signature(payload_body) signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_TOKEN, payload_body) return halt 500, "Signatures didn't match!" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_HUB_SIGNATURE']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def github_webhook?\n # https://developer.github.com/v3/activity/events/types/#pushevent\n @headers.key?('HTTP_X_GITHUB_EVENT')\n end", "def github_webhook\n payload = JSON.parse(params[:payload])\n requested_branch = payload['ref'].split('/').last\n branch_is_valid = @project.git? &&...
[ "0.7136373", "0.6911919", "0.6882233", "0.66394585", "0.6498836", "0.64101005", "0.63556576", "0.6300114", "0.6272983", "0.6263316", "0.62348485", "0.621879", "0.62051046", "0.6111002", "0.6072442", "0.60667765", "0.6032845", "0.60207754", "0.5969444", "0.5953115", "0.592081"...
0.0
-1
Get the view_model class for the given model instance. Note: ViewModels are usually of class ViewModels::. (As returned by default_view_model_class_for) Override specific_mapping if you'd like to install your own. OR: Override default_view_model_class_for(model) if you'd like to change the default.
def view_model_class_for model specific_view_model_class_for(model) || default_view_model_class_for(model) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_class\n @model_class ||= mapping.to\n end", "def process_params_model_view(params, options)\n model_view = options[:model_name].constantize if options[:model_name]\n model_view ||= model_string_to_constant(params[:model_name]) if params[:model_name]\n model_view ||= model_from_ac...
[ "0.6332937", "0.619373", "0.618355", "0.61675394", "0.61671686", "0.6132349", "0.5820911", "0.5811959", "0.569339", "0.56078196", "0.5593443", "0.5486177", "0.54407644", "0.5343196", "0.53384167", "0.52666116", "0.5245672", "0.5213166", "0.5201457", "0.518938", "0.51862705", ...
0.8219892
0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Instance methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% returns true if any of the crop attrs are not blank
def cropping? !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cropping?\n !crop_x.blank? and !crop_y.blank? and !crop_w.blank? and !crop_h.blank?\n end", "def cropping?\n !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?\n end", "def cropping?\n !self.crop_x.blank? && !self.crop_y.blank? && !self.crop_w.blank? && !self.crop_h.blank?\n ...
[ "0.7417442", "0.7396074", "0.736614", "0.7353512", "0.69731385", "0.6630603", "0.6630603", "0.6630603", "0.6630603", "0.65874654", "0.65364647", "0.6360585", "0.6345788", "0.6345788", "0.62882346", "0.62882346", "0.61892074", "0.61764395", "0.61156046", "0.60177296", "0.60086...
0.7393527
3
Sets self.hotness according to the idea's age, upvotes/downvotes, and whether or not the idea has 'preferred' status. Hotness is used to determine where in the list the idea will appear. We've used the same algorithm as reddit does for sorting its contents. At present, having posting an idea later gives more hotness to the idea than upvotes, since vote_weight is calculated using log(10), while the newness of the idea is just newness / 45000. If an idea has preferred status, it is the equivalent of the idea having PREFERRED_MAGNITUDE extra upvotes when it comes to sorting it in the list. If if an idea is preferred, PREFERRED_MAGNITUDE = 5000, and has no upvotes, it will have the approximate hotness of an idea posted about 2 days later. That being the case, if a preferred idea gets no upvotes, it will be overtaken by other ideas about 2 days later. You can see more details about the subject at:
def set_hotness! preferred_weight = self.preferred ? PREFERRED_MAGNITUDE : 0 vote_weight = vote_tally + preferred_weight newness = self.created_at.to_f || Time.now.to_f sign = vote_weight < 0 ? -1 : 1 upvote_magnitude = [ vote_weight.abs, 1.1 ].max order = Math.log upvote_magnitude, 10 self.hotness = sign * order + newness / 45000 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calc_hot_score\n points = upvotes - downvotes\n time_ago_in_hours = ((Time.now - created_at) / 3600).round\n score = hot_score(points, time_ago_in_hours)\n\n update_attributes(points: points, hot_score: score)\n end", "def check_upvote(idea)\n if idea.quality == 'genius'\n elsif idea.q...
[ "0.6177182", "0.608297", "0.5409675", "0.533342", "0.5126721", "0.50411904", "0.50343305", "0.50012684", "0.49902043", "0.49870187", "0.49532056", "0.49509266", "0.49352682", "0.4889389", "0.48779643", "0.48779643", "0.4865043", "0.4858861", "0.4848723", "0.48413908", "0.4829...
0.81946987
0
sets the idea's vote_tally field to be equal to the number upvotes minus the number of downvotes it has
def set_vote_tally! self.vote_tally = self.get_upvotes.size - self.get_downvotes.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tally\n up_votes - down_votes\n end", "def calculate_tallied_votes\n self.tallied_votes = upvotes - downvotes\n self.save\n end", "def get_vote_tally\n return self.get_upvotes.size - self.get_downvotes.size\n end", "def votes\n up_votes - down_votes\n end", "def total_votes\n ...
[ "0.8010913", "0.77478546", "0.7299664", "0.7065575", "0.6974259", "0.696491", "0.6810292", "0.680439", "0.6783879", "0.6761954", "0.6729899", "0.6714184", "0.67135954", "0.6641259", "0.66187316", "0.6618066", "0.65903974", "0.65903974", "0.65258914", "0.65258914", "0.6440316"...
0.84108794
0
Adds a upvote to the idea and then saves it, causing the idea's hotness to update
def upvote_and_update(user) self.liked_by user self.save #trigger set_hotness! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upvote\n self.votes += 1\n save\n end", "def vote_up\n update_votes(1)\n end", "def upvote_question\n self.update(votes_count: self.votes_count + 1)\n end", "def upvote(answer)\n upvoted_answers << answer\n end", "def up_vote\n if current_user\n answer_id = params[:an...
[ "0.81834203", "0.78706074", "0.7494377", "0.7474335", "0.7428273", "0.73941314", "0.73882836", "0.7362275", "0.73327327", "0.7328384", "0.72632366", "0.7261712", "0.7261292", "0.72561544", "0.72396284", "0.7229417", "0.72290385", "0.7161583", "0.71518946", "0.71381867", "0.71...
0.7837854
2
Adds a downvote to the idea and then saves it, causing the idea's hotness to update
def downvote_and_update(user) self.disliked_by user self.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upvote\n self.votes += 1\n save\n end", "def upvote_and_update(user)\n self.liked_by user\n self.save #trigger set_hotness!\n end", "def vote_up\n update_votes(1)\n end", "def vote up\n end", "def upvote\n @vote[:direction] = true\n @vote.save!\n redirect_to :back\...
[ "0.740997", "0.70796835", "0.6971138", "0.67812055", "0.6657157", "0.6638231", "0.6620038", "0.6583766", "0.65543056", "0.6543678", "0.64985836", "0.6495554", "0.6468844", "0.6468204", "0.6464484", "0.64422995", "0.6414893", "0.6409731", "0.6394838", "0.6369945", "0.63282824"...
0.71247953
1
Returns the tally of votes for the idea (upvotes downvotes)
def get_vote_tally return self.get_upvotes.size - self.get_downvotes.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tally\n up_votes - down_votes\n end", "def votes_count\n upvotes + downvotes\n end", "def votes\n up_votes - down_votes\n end", "def total_votes\n up_votes + down_votes\n end", "def set_vote_tally!\n self.vote_tally = self.get_upvotes.size - self.get_downvotes.size\n end", ...
[ "0.89774925", "0.7813947", "0.76699346", "0.7635027", "0.7599955", "0.75703746", "0.7565523", "0.7489117", "0.7436106", "0.7383439", "0.7336825", "0.72956616", "0.72698736", "0.7235209", "0.7214073", "0.7164372", "0.71635085", "0.71578735", "0.7142531", "0.7129869", "0.709990...
0.82861036
1
Registers the passed user as a subscriber to the idea
def add_subscriber!(user) unless self.subscribers.include? user self.subscribers << user unless self.subscribers.include? user IdeaMailer.new_subscriber_email(user, self).deliver_now end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subscribe_author\n self.subscriptions.create user_id: self.user.id\n end", "def register(subscriber)\n subscribers << subscriber\n end", "def register_subscriber(subscriber)\n @subscribers << subscriber\n end", "def set_subscriber\n @subscriber = current_subscriber\n end", "...
[ "0.723578", "0.7168125", "0.71269363", "0.71071494", "0.69696", "0.69315207", "0.69106203", "0.68531716", "0.67488503", "0.6678877", "0.6678877", "0.6678877", "0.6678877", "0.6678877", "0.6678877", "0.6630679", "0.6626333", "0.662532", "0.6583645", "0.6570963", "0.6512023", ...
0.70270294
4
returns true if the instance of idea belongs to the passed user
def belongs_to?(user) return false unless user.instance_of? User return self.owner == user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user?(user)\n user.id == self.user_id if user\n end", "def user?(user)\n self.user_id == user.id if user\n end", "def user?(user)\n self.user_id == user.id if user\n end", "def user?(user)\n self.user_id == user.id if user\n end", "def belongs_to_user?(user)\n self.user == user\n en...
[ "0.7448523", "0.7426268", "0.7426268", "0.7426268", "0.7278143", "0.7236979", "0.7228733", "0.7179906", "0.71000636", "0.7093079", "0.70542383", "0.7043741", "0.70167637", "0.70092", "0.6993139", "0.69781405", "0.6973107", "0.69605607", "0.6953211", "0.69453305", "0.6931483",...
0.7331129
4
converts idea.youtube_link into the form needed to make the video embeddable
def embed_link return nil if self.youtube_link.nil? id_regex = /(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/ youtube_id = self.youtube_link.match(id_regex) return nil if youtube_id.nil? return YOUTUBE_EMBED_PREFIX + youtube_id[1] + "?rel=0" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to_youtube_embed_link\n self.video_url.gsub!(/(youtube.com\\/)(.)*v=([\\w\\-_]+)(.)*$/, '\\1embed/\\3')\n end", "def youtube_embed_url\n VideoInfo.new(self.video_url).embed_url if self.video_url?\n end", "def youtube_movie_embed\n str1 = \"http://www.youtube.com/v/\" \n str2 = mov...
[ "0.8498275", "0.7565774", "0.72716", "0.7156959", "0.70510364", "0.70259106", "0.6964769", "0.69183433", "0.6907878", "0.68751764", "0.687082", "0.6832827", "0.6831723", "0.67978805", "0.6791987", "0.67915565", "0.67915565", "0.6769349", "0.6703219", "0.6690055", "0.6651127",...
0.77095395
1
Returns true if the idea has preferred status, false otherwise
def preferred? self.preferred end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adoptable?\n adoption_status ? \"Adoptable\" : \"Pending Adoption\"\n end", "def decided?\n return (self.status == STATUS_DENIED or self.status == STATUS_ACCEPTED)\n end", "def awarded_by_interview_committee?\n application_interview_decision_type.nil? ? false : application_interview_decisi...
[ "0.70375925", "0.69731855", "0.6902406", "0.689073", "0.6802753", "0.6778904", "0.66817284", "0.66621965", "0.665633", "0.66336936", "0.6611703", "0.659836", "0.6592191", "0.65733737", "0.654889", "0.6472812", "0.6462", "0.64433473", "0.64391756", "0.64391756", "0.64386946", ...
0.7120746
0
Returns an array of all the users who have commented on the idea
def all_commenters commenters = [] for comment in self.comment_threads commenters << comment.author end return commenters end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commenters # the user who commented on you\n self.comments.map do |comment|\n comment.user\n end\n end", "def commenters\n comments = Comment.find_by_sql(\"select distinct user_id from comments \"\\\n \"where commentable_type='Package' \"\\\n ...
[ "0.7169975", "0.7163043", "0.6975001", "0.69564164", "0.69077265", "0.68250406", "0.6775234", "0.67572737", "0.6708272", "0.6695053", "0.6694543", "0.66764164", "0.6604455", "0.6521454", "0.6349899", "0.6288358", "0.62510836", "0.6243967", "0.6224157", "0.61659265", "0.608314...
0.62806684
16
Returns true if any of the crop attrs are not blank, indicating that an image fo the idea is being cropped.
def cropping? !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cropping?\n !self.crop_x.blank? && !self.crop_y.blank? && !self.crop_w.blank? && !self.crop_h.blank?\n end", "def cropping?\n !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?\n end", "def cropping?\n !crop_x.blank? and !crop_y.blank? and !crop_w.blank? and !crop_h.blank?\n ...
[ "0.7850561", "0.78491974", "0.7827817", "0.78227377", "0.7554697", "0.7177846", "0.7177846", "0.7055822", "0.7055822", "0.661373", "0.65339977", "0.6031039", "0.60239226", "0.57624936", "0.57347405", "0.5723163", "0.56123716", "0.5569526", "0.55680317", "0.55669785", "0.55570...
0.7808787
6
returns an array of all the users who have commented on an idea except for the passed user NOTE: this only works on a single user for now. This doesn't work if passed multiple users
def all_commenters_except(user) commenters = self.all_commenters commenters.delete_if { |commenter| commenter == user } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def watch_comment_by_user_ids\n self.watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n end", "def watch_comment_by_user_ids\n user_ids = watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:...
[ "0.726363", "0.6930062", "0.67556727", "0.6714877", "0.66087335", "0.6477277", "0.6403893", "0.6397718", "0.63348085", "0.6313177", "0.62309486", "0.6145412", "0.60886616", "0.60490894", "0.59831727", "0.59464157", "0.5930235", "0.5926613", "0.5918761", "0.5903828", "0.589828...
0.67844874
2
Checks equality by comparing each attribute.
def ==(o) return true if self.equal?(o) self.class == o.class && from_ts == o.from_ts && group_by == o.group_by && groups == o.groups && monitors == o.monitors && overall == o.overall && series == o.series && thresholds == o.thresholds && to_ts == o.to_ts && type == o.type && type_id == o.type_id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n attributes == other.attributes\n end", "def ==(other) # :nodoc:\n @attrs == other.attrs\n end", "def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en...
[ "0.72932124", "0.7189842", "0.70406866", "0.7007727", "0.68881786", "0.68621296", "0.67085785", "0.66622394", "0.661674", "0.6586541", "0.65844727", "0.65818226", "0.65561724", "0.6545535", "0.6508076", "0.64813215", "0.64577025", "0.64179385", "0.6414028", "0.6414028", "0.64...
0.0
-1
Calculates hash code according to all attributes.
def hash [from_ts, group_by, groups, monitors, overall, series, thresholds, to_ts, type, type_id].hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ...
[ "0.7118691", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.70400536", "0.68960655", "0.67847186", "0.6707762", "0.670052", "0.6688737", "0.66705376", "0.6489735", "0.6462376", "0.6462376", "0.64444333", "0.6413127", "0.6395483", "0.638...
0.0
-1
http_basic_authenticate_with name: "jcuAdmin", password: "jcu2017",
def create_landing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate\n authenticate_or_request_with_http_basic('Administration') do |username, password|\n username == 'igp' && password == 'ehkra!Q2w#e'\n end\n end", "def http_basic_authenticate\n authenticate_or_request_with_http_basic do |username, password|\n username == \"mustang\" && passw...
[ "0.8589529", "0.85619384", "0.8517666", "0.83961976", "0.8340814", "0.82661307", "0.8211863", "0.8210803", "0.8196205", "0.8167562", "0.8161598", "0.81232905", "0.8072834", "0.79767114", "0.7876318", "0.7751527", "0.7733128", "0.7701966", "0.76532185", "0.76349366", "0.762413...
0.0
-1
Yield the content for a given block. If the block yiels nothing, the optionally specified default text is shown. yield_or_default(:user_status) yield_or_default(:sidebar, "Sorry, no sidebar") +target+ specifies the object to yield. +default_message+ specifies the message to show when nothing is yielded. (Default: "")
def yield_or_default(message, default_message = "") message.nil? ? default_message : message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_content\n yield if block_given?\n end", "def block_message_printer\n message = \"Welcome to Block Message Printer\"\n if block_given?\n yield\n end\n puts \"But in this function/method message is :: #{message}\"\nend", "def default(&block)\n if block_given?\n @...
[ "0.56731427", "0.5627392", "0.5558145", "0.554566", "0.54367596", "0.53092366", "0.5306978", "0.5287875", "0.5275353", "0.5244768", "0.52124816", "0.52073795", "0.5206291", "0.51859045", "0.5174293", "0.5161968", "0.51515305", "0.51263607", "0.5106384", "0.51012486", "0.50875...
0.66741765
3
Test a condition and throw an exception on failure.
def rtassert(cond, ex_class, msg) if (!cond) raise ex_class, msg end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert cond\n fail! unless cond\n end", "def assert(condition, msg = 'Assertion failed! I quit!')\n raise msg unless condition\nend", "def assert(condition, message=\"Expected condition to be satisfied\")\n @report.on_assertion\n raise AssertionFailed, message unless condition\n end",...
[ "0.72652644", "0.6979133", "0.6766454", "0.674768", "0.66747177", "0.6609237", "0.6589246", "0.6548723", "0.6471597", "0.6471597", "0.6471595", "0.646415", "0.6446988", "0.6386447", "0.62718856", "0.62718856", "0.62718856", "0.615847", "0.61175114", "0.60959095", "0.59958017"...
0.6644009
5
Sniff the format of a date string and then convert it to a date
def parse_date_str (d) ## Preconditions: # check format of date date_arr = d.split(DATE_SPLIT_REGEX) rtassert(date_arr.size() == 3, ArgumentError, "cant recognise format of date '#{d}'") # convert to hyphens as Ruby gets confused with slashes date_str = date_arr.join('-') ## Main: # try each of the supplied date formats DATE_FMTS.each { |fmt| begin date_obj = Date.strptime(date_str, fmt) return date_obj rescue ArgumentError # pass end } # try a brute force approach begin date_obj = Date.parse(date_str) return date_obj rescue pp date_arr raise ArgumentError, "can't recognise format of date '#{d}'" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_date(date)\r\n case date\r\n when /(\\d{2})\\.\\s{0,}(\\d{2})\\.\\s{0,}(\\d{4})/ # format DD.MM.YYYY nebo DD. MM. YYYY\r\n date.scan(/(\\d{2})\\.\\s{0,}(\\d{2})\\.\\s{0,}(\\d{4})/) do |sep|\r\n new_date = \"#{sep[2]}-#{sep[1]}-#{sep[0]}\"\r\n return new_date\r\n end\r\n when /(\\d{2})\\...
[ "0.72022766", "0.712276", "0.70865995", "0.70812714", "0.7058774", "0.70566726", "0.7030246", "0.7016112", "0.69815236", "0.6975984", "0.6954734", "0.69537675", "0.6941491", "0.6941491", "0.69107306", "0.6856061", "0.68031573", "0.6799621", "0.6778264", "0.67719996", "0.67626...
0.6605014
27
Convert an Excel serialformat date to a Ruby date object
def serial_to_date (s) # round down and convert from string if need be # zero day is actually "Jan 0" and indexing starts from 1, so subtract 2 s = s.to_i() - 2 # add to zero day return JAN_1_1900 + s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value\n val = @value\n if format_as_date?(val)\n val = Xl::DateHelper.excel_to_ruby(val)\n end\n val\n end", "def to_date\n Date.new(*to_a[0,3])\n end", "def to_date(date)\n return date if date.is_a?(Date)\n Date.parse(date)\n end", "def to_date()\n #This is a st...
[ "0.62069476", "0.61393535", "0.6094726", "0.6068427", "0.60031927", "0.5970545", "0.5916263", "0.59061056", "0.58625317", "0.58551615", "0.58055675", "0.58047736", "0.57916033", "0.57813406", "0.5780769", "0.57712805", "0.5759168", "0.57471335", "0.57381153", "0.57181656", "0...
0.64726996
0
Puzzle out the format of a date entry in a spreadsheet and return it.
def interp_date (d, after_1925=true) # TODO: add argument for preferred/hinted format? # Main: date_obj = false # handle already converted values and serial values # NOTE: to test for a ruby class in a "case/when" statement, you pass in the # object. When clauses are tested with === and obj.class === obj (but # obj === obj.class case d # if no value when NilClass return nil # if already converted when Date date_obj = d # convert serial values when Float date_obj = serial_to_date(d) when Fixnum return serial_to_date(d) # otherwise must be a string when String d = d.strip() # if they leave it unknown if UNKNOWN_STR_REGEX.match(d) return nil end # is it a serial value as a string? if (INT_REGEX.match(d) || FLOAT_REGEX.match(d)) pp d pp d.class date_obj = serial_to_date(d) else # otherwise must be a date string date_obj = parse_date_str(d) end end if date_obj # we have a date, do we have to adjust years? if after_1925 if date_obj.year <= 25 return Date.new(y=date_obj.year+2000, m=date_obj.month, d=date_obj.day) elsif (date_obj.year < 100) and (25 < date_obj.year) return Date.new(y=date_obj.year+1900, m=date_obj.month, d=date_obj.day) end end return date_obj else # if you get here, it's in a format we don't understand or handle raise ArgumentError, "can't make date from #{d.class}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_date(date)\r\n case date\r\n when /(\\d{2})\\.\\s{0,}(\\d{2})\\.\\s{0,}(\\d{4})/ # format DD.MM.YYYY nebo DD. MM. YYYY\r\n date.scan(/(\\d{2})\\.\\s{0,}(\\d{2})\\.\\s{0,}(\\d{4})/) do |sep|\r\n new_date = \"#{sep[2]}-#{sep[1]}-#{sep[0]}\"\r\n return new_date\r\n end\r\n when /(\\d{2})\\...
[ "0.66740584", "0.65901846", "0.6574244", "0.6430589", "0.6343121", "0.63239056", "0.6299257", "0.6250306", "0.6199356", "0.61805886", "0.6172485", "0.6167092", "0.6110624", "0.60698855", "0.60556436", "0.6052026", "0.6050507", "0.6048614", "0.6026194", "0.60173297", "0.600809...
0.0
-1
Converts the string form of a number to the bestfitting numeric type.
def str_to_number(s) val_str = s.to_s() if INT_REGEX.match(val_str) return val_str.to_i() elsif FLOAT_REGEX.match(val_str) return val_str.to_f() else raise ArgumentError, "can't understand numeric format '#{s}'" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_string_to_number(str); end", "def string_to_number(string)\n case string\n when /^\\d+$/\n string.to_i\n when /^\\d+.\\d$/\n string.to_f\n else \n string\n end\n end", "def string_to_number(string)\n case string\n when /^\\d+$/\n string.to_i\n when /^\\d...
[ "0.72345346", "0.692932", "0.6904537", "0.68334144", "0.6781501", "0.67192346", "0.66544014", "0.66154766", "0.65227914", "0.65227914", "0.65227914", "0.65227914", "0.65222204", "0.65026057", "0.6499859", "0.64872915", "0.6395673", "0.63723105", "0.62653464", "0.6240222", "0....
0.70352906
1
Read the sheet, and return each nonheader row to the passed block. This first reads the headers and cleans them up (see "read_headers"). When each row is read, the values are stored in a hash with the cleaned up column names as keys. If a method exists called "method_", this is used to convert the value. Spreadsheet seems to convert floats but dates are returned as Excel serial values.
def read(&blk) ## Preconditions: # NOTE: you can't grab a row or just read a line in roo, you have to ask # about the bounds and explcitly iter over the cell contents. row_start = @wbook.first_row row_stop = @wbook.last_row col_start = @wbook.first_column col_stop = @wbook.last_column if row_start != 1 raise RuntimeError, "data must start on the first row not #{row_start}" end if col_start != 1 raise RuntimeError, "data must start in the first column not #{col_start}" end # Main: # grab and parse headers headers = read_headers(col_stop) # read each row (2..row_stop).each { |i| row_data = (1..col_stop).collect { |j| @wbook.cell(i,j) } row_zip = headers.zip(row_data).flatten() row_hash = Hash[*row_zip] row_hash.each_pair { |k,v| meth_name = "convert_#{k}" if (self.respond_to?(meth_name)) row_hash[k] = self.send(meth_name, v) else row_hash[k] = convert(v) end } blk.call(row_hash) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(&blk)\r\n\t\t\t## Preconditions:\r\n\t\t\t# NOTE: you can't grab a row or just read a line in roo, you have to ask\r\n\t\t\t# about the bounds and explcitly iter over the cell contents. \r\n\t\t\trow_start = @wbook.first_row\r\n\t\t\trow_stop = @wbook.last_row\r\n\t\t\tcol_start = @wbook.first_column\r\n\...
[ "0.6651849", "0.65022016", "0.6229494", "0.59781986", "0.58720183", "0.5833307", "0.5680039", "0.5666765", "0.5622115", "0.56011903", "0.5594161", "0.5568689", "0.555965", "0.55427134", "0.550082", "0.5436349", "0.54118896", "0.53596354", "0.53558016", "0.5351957", "0.5326071...
0.65913033
2
Return the canonical set of headers. This makes everything lowercase, strips flankning space, and substitutes underscores for spaces. Override to validate or for further process headers.
def read_headers (col_stop) # collect header row headers = (1..col_stop).collect { |j| @wbook.cell(1,j) } # drop case, strip flanking spaces, replace gaps with underscores pp @syn_dict return headers.collect { |h| h_str = h.downcase.strip.gsub(' ', '_').to_sym() pp h_str pp @syn_dict.fetch(h_str, h_str) @syn_dict.fetch(h_str, h_str) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def canonicalized_headers\n x_amz = headers.select{|name, value| name.to_s =~ /^x-amz-/i }\n x_amz = x_amz.collect{|name, value| [name.downcase, value] }\n x_amz = x_amz.sort_by{|name, value| name }\n x_amz = x_amz.collect{|name, value| \"#{name}:#{value}\" }.join(\"\\n\")\n x_am...
[ "0.8089857", "0.778889", "0.74814", "0.74479824", "0.72587913", "0.72310066", "0.70881003", "0.6929799", "0.69124097", "0.68974787", "0.6895633", "0.68510854", "0.68350327", "0.6687266", "0.6683153", "0.66749185", "0.66179836", "0.6562257", "0.6538556", "0.6487755", "0.647136...
0.0
-1
General conversion of spreadsheet cell values
def convert(val) # clean up strings and return nil for if val.class == String val.strip!() if ["?", "unknown"].member?(val.downcase()) return nil end end return val end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_cell(column,xlsx,nrow,ncol)\n d = xlsx.cell(nrow,ncol)\n type = column['type'] || 'string'\n case type\n when 'long'\n d.to_i\n when 'double'\n d.to_f\n when 'string'\n d.to_s\n when 'timestamp'\n convert_time(d)\n ...
[ "0.7384045", "0.69950825", "0.66986823", "0.6696113", "0.65047073", "0.64213437", "0.6411648", "0.63800704", "0.63283294", "0.62727237", "0.6262628", "0.62571836", "0.6235969", "0.6142947", "0.6098324", "0.6096537", "0.6096537", "0.59997606", "0.5998472", "0.5991291", "0.5989...
0.0
-1
Parse command line options.
def parse_options(args) program = Pathname.new(__FILE__).realpath header = <<-END_HEADER # Running #{program} on #{Time.now} # Command-line arguments are: #{args} # Command-line to reproduce: #{program} #{args.join(" ")} # END_HEADER timestamp = Time.now.strftime("%Y%m%d%H%M%S") current_dir = Pathname.pwd output_basename = current_dir + "log" output_basename.mkdir unless output_basename.directory? options = OpenStruct.new options.log_level = :off options.log_destination = STDOUT options.db_url = { :adapter => :in_memory } options.generate = nil options.time = 60 options.profile_strings = false options.output_filename = "dm-tpcc-#{timestamp}.out" options.data_directory = current_dir + "data" options.load = false options.save_data = false opts = OptionParser.new do |opts| opts.banner = "Usage: dm-tpcc [options]" opts.separator "" opts.on("-g NUM_WAREHOUSES", "--generate NUM_WAREHOUSES", Integer, "Generate data for the number of warehouses.") do |g| options.generate = g end opts.on("-s DIRECTORY_NAME", "--save DIRECTORY_NAME", "Save generated data for later use.") do |s| options.data_directory = s unless (s.nil? || s.empty?) end opts.on("-S", "--save-data", "Save generated data for later use.") do |s| options.save_data = s end opts.on("-D", "--load-data", "Load data from saved datasets.") do |l| options.load = l end opts.on("--profile-string-algorithms", "Profile different string generators") do |sg| options.profile_strings = sg end opts.on("-d DB_URL", "--db-url DB_URL", String, "Specify a DataMapper DB URL") do |dburl| options.db_url = dburl end opts.on("-l LOG_LEVEL", "--log-level LOG_LEVEL", LOG_LEVELS, "Specify a log level.") do |l| options.log_level = l.to_sym end opts.on("-L LOG_FILE", "--log-file LOG_FILE", String, "Specify a log file.") do |f| options.log_destination = File.new(f, "a+") end opts.on("-o FILENAME", "--output FILENAME", String, "Filename to save output to.") do |outputfile| options.output_filename = outputfile end opts.on("-t DURATION", "--time DURATION", Integer, "Duration of the test in seconds.") do |time| options.time = time end opts.on("--once", "Run just one time") do |once| options.once = once end opts.separator "Common Options:" opts.on_tail("-h", "--help", "Show this message.") do puts opts print "\nLog Levels:\n" LOG_LEVELS.keys.each { |l| print "\t#{l}\n" } print "\nExample Database URLS:\n" $example_dbs.each { |db| print "\t#{db}\n" } exit end opts.on_tail("--version", "Show version") do puts DataMapper::TPCC::VERSION exit end end opts.parse!(args) # Process options into global variables (ick) $output = File.open(output_basename + options.output_filename, "w+") $output.print header $data_directory = options.data_directory $data_directory.mkdir unless $data_directory.directory? options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_options(opts, args); end", "def parse_opts\n option_parser.parse(@argv)\n end", "def parse_options\n set_defaults\n unless parsed_options? && arguments_valid?\n output_usage\n exit 1\n end\n end", "def parse\n # The options specified on the command l...
[ "0.7955871", "0.78756684", "0.78602433", "0.7780233", "0.7763284", "0.7716871", "0.7704204", "0.7621555", "0.7544811", "0.75415486", "0.74418527", "0.7284101", "0.7271087", "0.72654456", "0.72342515", "0.7206488", "0.71926713", "0.7166847", "0.7149402", "0.71384615", "0.70990...
0.0
-1
return the total number of iterations.
def count @count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_runs\n return @total_runs\n end", "def total_count\n @all.size\n end", "def total_count\n @total_count ||= @possibility_distribution.inject(0) { |sum, n| sum + n.last }\n end", "def total_results\n @set['totalResults'].to_i\n end", "def total_count\n ...
[ "0.7067007", "0.69567555", "0.6883113", "0.686496", "0.6850251", "0.6809951", "0.6783846", "0.677651", "0.67264277", "0.67093563", "0.66052157", "0.65973264", "0.6588905", "0.65530705", "0.65504706", "0.65504336", "0.6534073", "0.6532975", "0.6528494", "0.6524397", "0.6514792...
0.0
-1
returns array of strings to print out for syntax.
def syntax t = @cmd_args t = [[t]] if !t.is_a? Array args = [] count = 0 t.each do |expected_array| count += 1 if count == 1 str = "Syntax: #{@cmd_name}" else str = " #{@cmd_name}" end expected_array.each do |expected| # each expected arg. str += case expected when :arg_none then "" when :arg_dir! then " <direction>" when :arg_str! then " <string literal>" when :arg_word!then " <word>" when :arg_int! then " <#>" when :arg_obj_inv! then " <item>" when :arg_obj_room! then " <item>" when :arg_obj_inv_or_room! then " <item>" when :arg_class! then " <Class>" when :arg_player_in_game! then " <player in game>" when :arg_player_offline! then " <any player>" when :arg_actor_room! then " <npc/player>" when String then " " + expected else "" end end args << str end return args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printable\r\n list = @@words.to_a.sort.map {|word,definition| \"[#{word}] \\\"#{definition}\\\"\"}\r\n list.join(\"\\n\")\r\nend", "def syntaxes\r\n playbook.syntaxes\r\n end", "def syntax(tokens)\n tokens = expect(:\".syntax\", tokens)\n if id?(tokens[0])\n name = tokens[0]\n tok...
[ "0.61984724", "0.6170192", "0.60561275", "0.5983776", "0.58088243", "0.58037555", "0.5798638", "0.57766515", "0.57680833", "0.5703316", "0.5699007", "0.56761307", "0.5639792", "0.56392", "0.5638582", "0.56160325", "0.5596635", "0.5581493", "0.5562743", "0.5552735", "0.553896"...
0.63633734
0
This is the initialize function that must be called manually to grab refernces from the global table.
def init_cmd_table # Right now just adding all commands into the copied table. Maybe later a check for if is immortal or not. @cmds[:unsecure] = $tabCmd @cmds[:secure] = $tabWizCmd return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_table; end", "def initialize\n @get_table = TABLE\n end", "def target_init\n @scope = Scope.new('GLOBAL')\n @references = References.new\n end", "def initialize(table_ref=nil)\n @table_ref = table_ref\n end", "def init; end", "def init; end", "def init; e...
[ "0.7085031", "0.6912361", "0.6798433", "0.65085983", "0.6469237", "0.6469237", "0.6469237", "0.6469237", "0.64547354", "0.6427564", "0.6427564", "0.6427564", "0.64098775", "0.6396756", "0.63724375", "0.63120174", "0.62781143", "0.6265971", "0.62604713", "0.6243602", "0.623191...
0.0
-1
automatically creates new rooms and digs them out in a direction. if a room is supplied we use it unconditionally.
def buildwalk(dir, supplied=nil) if supplied if supplied.is_a?(Room) found = {:room=>supplied} else view "Linking failed. Target was not a room." + ENDL return nil end else m = Automap.new(in_room, [(-1..1),(-1..1)], {:full_traverse=>true}) found = m.find(Automap.offset([0,0], dir)) end if !found new_room = Room.dig_rooms(in_room.vnum, Vnum.gen_vnum, dir) new_room.sector = in_room.sector # same sector as old room new_room.namespace = in_room.namespace new_room.assign_tag Tag.gen_generic_tag(new_room), in_room.namespace return new_room else Room.dig_rooms(in_room.vnum, found[:room].vnum, dir) return found[:room] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_in_direction dir\n new_room = Room.create({:created_at=>Time.now, :x=>self.x, :y=>self.y, :z=>self.z})\n \n case dir\n when \"north\",:north, 0\n new_room.y += 1\n when \"east\", :east, 1\n new_room.x += 1\n when \"south\",:south, 2\n new_room.y -= 1\n when \"west\",:...
[ "0.6722861", "0.668243", "0.64884335", "0.6439694", "0.64079", "0.6379113", "0.63689756", "0.63584304", "0.63232124", "0.6282554", "0.6272412", "0.6272412", "0.6268909", "0.62551105", "0.6141466", "0.6133677", "0.6107761", "0.6098927", "0.6086022", "0.60630333", "0.6040975", ...
0.67359287
0
read an SMS message
def read(idx=1) messages[idx.to_i-1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(idx=1)\n\n cmd('CMGR=' + idx.to_s) do |r| \n begin\n parse_msg r \n rescue SmsSerialError => e\n puts 'Invalid message no.'.warning\n nil\n end\n end\n\n end", "def receive_sms\n @view = \"sms\"\n @body = params[\"Body\"]\n @phone_number = params[\"Fro...
[ "0.7225044", "0.7199825", "0.6954037", "0.6942442", "0.6876826", "0.67744446", "0.67415965", "0.67309004", "0.66017187", "0.65542436", "0.6535531", "0.6520582", "0.6502092", "0.6465553", "0.6398707", "0.6371925", "0.6359698", "0.6359251", "0.635706", "0.62967694", "0.62733346...
0.56900465
71
continuously check for new messages
def start() unread = notifications()['UnreadMessage'].to_i @thread = Thread.new do loop do unread_messages = notifications()['UnreadMessage'].to_i if unread_messages > unread then @callback.call if @callback unread = unread_messages end sleep 3 end end 'checking for new message every 3 seconds ...' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def poll!\n find_and_process_next_available(messages)\n end", "def check_for_new_messages\n messages = twitter.direct_messages(:since_id => last_message_retrieved)\n @num_messages = messages.length\n end", "def work(message)\n if message.is_a?(Message)\n self.count = count + ...
[ "0.71887225", "0.6921472", "0.6517167", "0.6386165", "0.63390267", "0.63080734", "0.62383354", "0.62111443", "0.6200135", "0.61960334", "0.6171409", "0.61618567", "0.6056954", "0.6051132", "0.60491335", "0.5997053", "0.5992488", "0.59821445", "0.5977466", "0.59728944", "0.594...
0.726368
0
returns a Hash object from the flat XML records returned from the response
def query(s) response = RestClient.get "http://#{@host}/api/" + s Rexle.new(response.body).root.xpath('./*').inject({}) do |r,x| x.text ? r.merge(x.name => x.text.unescape) : r end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_h\n doc = Nokogiri::XML raw.body\n hash = Hash.from_xml doc.to_xml\n Hashie::Mash.new(symbolize_keys_deep(hash))\n end", "def extract_xmls(dc_response_parser)\n dc_response = dc_response_parser.for_tag(\"DCResponse\").\n first[\"ContextData\"][\"Field\"]\n\n dc_res...
[ "0.70416325", "0.6780529", "0.6655467", "0.6622383", "0.66137534", "0.65459037", "0.639292", "0.6312239", "0.6306979", "0.61773986", "0.61700517", "0.60874766", "0.6041191", "0.60181165", "0.60173273", "0.60072607", "0.59886366", "0.5981419", "0.59748733", "0.5944615", "0.594...
0.0
-1
Returns the command identifier string. See specification for list of valid command codes.
def command_code raise MovingsignApi::NotImplementedError, "Needs to be implemented in subclass." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hex_cmd_id\n \"0x\" + @cmd_id.to_s(16)\n end", "def command_name(cmd)\n cmd\n end", "def command\n return @command.underscore if @command.is_a?(String)\n @command\n end", "def command_name\n return @command_name\n end", "def command_name\n @command_na...
[ "0.7263898", "0.71711224", "0.6969202", "0.6875923", "0.68441933", "0.68330187", "0.68178886", "0.6757853", "0.675225", "0.67117155", "0.6682618", "0.655117", "0.6544297", "0.6522868", "0.65027136", "0.6496357", "0.64919055", "0.6423834", "0.6296518", "0.6251121", "0.6233588"...
0.5637875
69
Returns a byte array representing this command, appropriate for sending to the sign's serial port
def to_bytes # set defaults self.sender ||= :pc self.receiver ||= 1 bytes = [] bytes.concat [0x00] * 5 # start of command bytes.concat [0x01] # <SOH> bytes.concat self.sender.to_bytes # Sender Address bytes.concat self.receiver.to_bytes # Reciver Address bytes.concat [0x02] # <STX> bytes.concat string_to_ascii_bytes(command_code) # Command Code bytes.concat command_payload_bytes # command specific payload bytes.concat [0x03] # <ETX> bytes.concat generate_checksum_bytes(bytes[10..-1]) # Checksum bytes (4) bytes.concat [0x04] # <EOT> bytes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command_payload_bytes\n raise MovingsignApi::NotImplementedError, \"Needs to be implemented in subclass.\"\n end", "def to_s\n [0, 32, @device_token, @payload.length, @payload ].pack(\"CnH*na*\")\n end", "def encode_to_array\n components = []\n components << [self.class.id...
[ "0.71810544", "0.684708", "0.64292467", "0.6294991", "0.6265461", "0.62143046", "0.6108205", "0.6094925", "0.6072377", "0.60315466", "0.6025726", "0.60173786", "0.60107833", "0.5993043", "0.59814286", "0.5969958", "0.5956447", "0.59559375", "0.5955196", "0.5955189", "0.595079...
0.81100625
0
Returns command specific byte array payload
def command_payload_bytes raise MovingsignApi::NotImplementedError, "Needs to be implemented in subclass." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_bytes\n # set defaults\n self.sender ||= :pc\n self.receiver ||= 1\n\n bytes = []\n\n bytes.concat [0x00] * 5 # start of command\n bytes.concat [0x01] # <SOH>\n bytes.concat self.sender.to_bytes ...
[ "0.7354474", "0.6897268", "0.65994895", "0.656849", "0.6477026", "0.6334336", "0.6322776", "0.6318373", "0.63126856", "0.62323517", "0.61747783", "0.6171956", "0.6127085", "0.60994333", "0.606661", "0.60506225", "0.60489255", "0.60284024", "0.5969242", "0.59648865", "0.596299...
0.7982039
0
Returns a checksum string (4 characters) appropriate for sending to the serial port ie: '12AF' (note capitalization)
def generate_checksum_bytes(payload) sum = payload.reduce :+ sum_hex = ('%04x' % sum).upcase string_to_ascii_bytes sum_hex end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checksum_char\n packed_orcid[-1]\n end", "def checksum sequence_number\n Digest::MD5.hexdigest(@buffer[sequence_number])\n end", "def calc_checksum\n @encrypted_name.chars.delete_elem('-').group_eq.transform_values(&:length).sort_by do |_, v|\n -v\n end.group_by(&:second).map do ...
[ "0.6825213", "0.6631971", "0.6570734", "0.62877893", "0.62284726", "0.61820406", "0.61782444", "0.6170668", "0.6159612", "0.61191756", "0.61150247", "0.6110535", "0.6097082", "0.60664856", "0.60598767", "0.6034758", "0.597008", "0.5901553", "0.5856439", "0.58169925", "0.58127...
0.6274246
4
return array that contains the match
def search_records(match) match = match.downcase conn.exec_params('SELECT * FROM contacts WHERE lower(first_name)=$1 OR lower(last_name)=$1', [match]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matches\n @matches ||= []\n end", "def to_a\n [self] + matches\n end", "def match_result\n [match_x, match_y]\n end", "def matches(str)\n each_match(str).to_a\n end", "def matches\n parse\n end", "def matches\n parse_file.lines.each_with_object([]) do |line,...
[ "0.76751834", "0.7140465", "0.7037351", "0.68132055", "0.6737035", "0.66074365", "0.6540651", "0.63843465", "0.6317616", "0.6303691", "0.6242522", "0.6242522", "0.6242522", "0.6242522", "0.6242522", "0.6242522", "0.62301064", "0.62136096", "0.6174493", "0.61596924", "0.611189...
0.0
-1
set definition and create events
def definition_attributes=(definition_attributes) self.definition = ActivityDefinition::BaseActivityDefinition.from_attributes definition_attributes self.create_events_from_definition end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_events\n end", "def events=(_); end", "def add_events(new_events); end", "def create_event(&blk)\n setup_event(Event.new, &blk)\n end", "def create_event(&blk)\n setup_event(Event.new, &blk)\n end", "def events; end", "def events; end", "def events; end", "def events; en...
[ "0.65046895", "0.6180855", "0.60372907", "0.6009934", "0.6009934", "0.59186745", "0.59186745", "0.59186745", "0.59186745", "0.59186745", "0.59186745", "0.59186745", "0.59186745", "0.581807", "0.57004666", "0.5691634", "0.56817555", "0.56817555", "0.56667155", "0.5655269", "0....
0.63819176
1
Reads the contents of the file from Cloud Files === Returns [String] contents of the file
def read object.content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contents\n\t\tfin = File.new(@filename,'r')\n\t\tc = fin.read\n\t\tfin.close\n\t\treturn c\n\tend", "def get_file_contents(file_path)\n input_file = File.open(file_path, 'r')\n input_file_contents = input_file.read\n input_file.close\n input_file_contents\n end", "def conte...
[ "0.75813705", "0.74770534", "0.73264825", "0.7236603", "0.72137386", "0.71808165", "0.71342", "0.71263385", "0.7110893", "0.7109826", "0.71034366", "0.70895344", "0.70805097", "0.70650035", "0.7056525", "0.7014263", "0.7014263", "0.7008474", "0.69680846", "0.6942495", "0.6862...
0.0
-1
Remove the file from Cloud Files
def delete object.destroy rescue nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove file\n file.delete\n @files -= [file]\n end", "def remove(filename); end", "def remove_file!\n begin\n super\n rescue Fog::Storage::Rackspace::NotFound\n self.file = nil\n self.send(:write_attribute, :file, nil)\n end\n end", "def remove_file\n\n @source_files_id...
[ "0.8315237", "0.7930459", "0.7821289", "0.7794347", "0.77790624", "0.77750176", "0.77453846", "0.7729366", "0.7678892", "0.76143134", "0.7608496", "0.7606489", "0.7592324", "0.7565211", "0.7565211", "0.75286704", "0.75036895", "0.7499145", "0.74917823", "0.7475275", "0.743218...
0.0
-1
Lookup value for file contenttype header === Returns [String] value of contenttype
def content_type @content_type || object.content_type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content_type\n %x(file -bi \"#{self.path}\").chomp.scan(/^[a-z0-9\\-_]+\\/[a-z0-9\\-_]+/).first\n end", "def content_type(path)\r\n ext = File.extname(path).split(\".\").last\r\n CONTENT_TYPE_MAPPING.fetch(ext, DEFAULT_CONTENT_TYPE)\r\nend", "def content_type\n file.try(:content_type)\n ...
[ "0.7819989", "0.77991307", "0.77928126", "0.76539135", "0.76414883", "0.76414883", "0.7621446", "0.7579808", "0.75585824", "0.754864", "0.75441724", "0.7481862", "0.74763966", "0.7463285", "0.7458099", "0.7454041", "0.74477905", "0.7445522", "0.7424664", "0.7417343", "0.74115...
0.0
-1
// End of File
def store!(file) f = CarrierWave::Storage::Grandcloud::File.new(uploader, self, uploader.store_path) f.store(file.read) f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eof; @file.eof; end", "def do_eof; end", "def file_end(file, output)\n end", "def eof!; end", "def eof() end", "def eof() end", "def eof() end", "def eof\n end", "def eof?; end", "def eof?; end", "def end_of_file(arg)\n @offenses << error('At the end of file: Final newline miss...
[ "0.81897926", "0.7748183", "0.77266645", "0.7604533", "0.75958776", "0.75958776", "0.75958776", "0.75927526", "0.7251798", "0.7251798", "0.72380733", "0.71126235", "0.6946192", "0.69368225", "0.69368225", "0.69368225", "0.6908536", "0.6901492", "0.68929523", "0.68929523", "0....
0.0
-1
GET /posts GET /posts.json
def index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @posts = Post.find(params[:id])\n render json: @posts\n end", "def index\n @posts = Post.all\n render json: @posts\n end", "def index\n @posts = Post.all\n\n render json: @posts\n end", "def index\n @posts = Post.all\n\n render json: @posts\n end", "def index\n ...
[ "0.7865315", "0.7494904", "0.7494433", "0.7494433", "0.7488696", "0.74314564", "0.728645", "0.728645", "0.728645", "0.72562826", "0.72522277", "0.7247287", "0.7246305", "0.72221965", "0.72042215", "0.72039723", "0.7169929", "0.71689725", "0.71644753", "0.7121855", "0.71152896...
0.0
-1
POST /posts POST /posts.json
def create @post = Post.create(post_params) set_posts respond_to do |format| format.js format.html end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n render json: Post.create(params[\"post\"])\n end", "def create\n respond_with Post.create(params[:posts])\n end", "def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end", "def create\n @post = Post.new(post_params)\n @po...
[ "0.74463975", "0.73221767", "0.73072433", "0.7123966", "0.7015686", "0.701327", "0.69841874", "0.6939327", "0.69313824", "0.69053805", "0.68196476", "0.6812792", "0.6793222", "0.6792862", "0.6779654", "0.6779654", "0.67625546", "0.67602354", "0.67515427", "0.6735786", "0.6698...
0.63764375
58
Never trust parameters from the scary internet, only allow the white list through.
def post_params params.fetch(:post, {}).permit(:title, :body, :user_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.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954",...
0.0
-1
GET /users/:user_id/uploads Provide all of the uploads for the given user.
def index @uploads = policy_scope(@user.uploads) authorize @uploads end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @uploads = current_user.uploads.all\n end", "def index\n @uploads = @user.uploads\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uploads }\n end\n end", "def index\n @uploads = [].tap do |files|\n Upload.with_attached_files\n ...
[ "0.7084568", "0.7060152", "0.6641204", "0.6372152", "0.6282985", "0.6258394", "0.61764705", "0.6157016", "0.6111285", "0.6076174", "0.60729074", "0.60317457", "0.59622955", "0.59554845", "0.5954905", "0.5954905", "0.5954905", "0.5954905", "0.5954905", "0.58884686", "0.587863"...
0.5392333
57
GET /users/:user_id/uploads/new Build an upload and provide the UI to create it.
def new @upload = @user.uploads.build authorize @upload end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @upload = @user.uploads.build(upload_params)\n authorize @upload\n\n respond_to do |format|\n if @upload.save\n format.json { render json: @upload }\n format.html { redirect_to user_uploads_path(@user) }\n else\n format.json { render json: @upload.errors }\n ...
[ "0.77871794", "0.7580909", "0.75045276", "0.74717766", "0.7422219", "0.7179301", "0.71740174", "0.71701086", "0.7143517", "0.70645696", "0.69469506", "0.6901484", "0.6885519", "0.68832", "0.6800499", "0.6790508", "0.6784306", "0.67661387", "0.67541766", "0.6696461", "0.665431...
0.7059898
10
POST /users/:user_id/uploads Create an upload for the given user. Uploading the image happens behind the scenes in the Upload model.
def create @upload = @user.uploads.build(upload_params) authorize @upload respond_to do |format| if @upload.save format.json { render json: @upload } format.html { redirect_to user_uploads_path(@user) } else format.json { render json: @upload.errors } format.json { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n new_uploads = create_upload_params\n new_uploads[:user_id] = current_or_guest_user.id\n\n @upload = Upload.new(new_uploads)\n\n if @upload.save\n flash[:success] = 'File Upload Successfully!'\n else\n flash[:danger] = 'An error occurred. Please try again!'\n flash[:error]...
[ "0.6854255", "0.68072104", "0.67978126", "0.6712927", "0.66030765", "0.65874016", "0.65626276", "0.65153074", "0.6510397", "0.65059996", "0.64965415", "0.64402765", "0.63979477", "0.6385475", "0.63621604", "0.6350831", "0.6311413", "0.62960654", "0.6290963", "0.6235186", "0.6...
0.7407673
0
DELETE /users/:user_id/uploads/:id Deletes the given user upload.
def destroy @upload = @user.uploads.find(params[:id]) authorize @upload @upload.destroy redirect_to user_uploads_path(@user) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @file_upload=@user.file_uploads.find(params[:id])\n @file_upload.destroy\n respond_to do |format|\n format.html { redirect_to user_file_uploads_path, notice: 'File was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @upload = Uplo...
[ "0.7641387", "0.7635752", "0.76138973", "0.73477024", "0.7314545", "0.7190245", "0.7156397", "0.7029481", "0.702683", "0.69799244", "0.68886316", "0.68665975", "0.6859507", "0.685198", "0.68346083", "0.68346083", "0.6814951", "0.6813265", "0.6793797", "0.6789968", "0.6758627"...
0.79707444
0
upload_params: > Hash Permits the upload fields for assignment.
def upload_params permit = policy(@upload || Upload).permitted_attributes params.require(:upload).permit(*permit) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_params\n params.require(:upload).permit(:name, :category, :information, :course_id, :assignment_id)\n end", "def upload_params\n params.require(:upload).permit(:upload)\n end", "def upload_params\n params.require(:upload).permit(:title, :upload, :user_id)\n end", "def uploa...
[ "0.7795539", "0.77284557", "0.7636273", "0.75941604", "0.75941604", "0.7587071", "0.7560962", "0.75554776", "0.7390583", "0.7352679", "0.7319376", "0.7314301", "0.7303572", "0.7244761", "0.7217983", "0.7134121", "0.7133211", "0.7125759", "0.70994", "0.7097612", "0.7093578", ...
0.76084846
3
Great method doing same thing, but not mine.
def top_3_words(text) count = Hash.new { 0 } text.scan(/\w+'*\w*/) { |word| count[word.downcase] += 1 } count.map{|k,v| [-v,k]}.sort.first(3).map(&:last) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def same; end", "def anchored; end", "def private; end", "def probers; end", "def silly_adjective; end", "def offences_by; end", "def ignores; end", "def suivre; end", "def offences_by=(_arg0); end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def big_bad;...
[ "0.6931145", "0.66643935", "0.61290526", "0.6111131", "0.6021669", "0.587997", "0.58647925", "0.5836738", "0.58288157", "0.5818651", "0.5818651", "0.5818651", "0.5818651", "0.5779536", "0.5760535", "0.5736493", "0.5721958", "0.57170945", "0.56975406", "0.56820214", "0.5644199...
0.0
-1
create grants array define a method to search for duplicates search for grant number in grants array
def grant_search(grants, grant_number) # set up location = nil return if grant_number == nil duplicate_index = nil # search grant hash in the array and if find the duplicate, then set up index # location grants.each_with_index do |grant, i| if grant[:grant_number] == grant_number duplicate_index = i break end end duplicate_index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assigned_investors(sale_rep)\n assigned_accounts = []\n @hash_row_array.each do |hash|\n if hash[\"SALES_REP\"] == sale_rep\n if assigned_accounts.include?(hash[\"INVESTOR\"]) == false\n assigned_accounts << hash[\"INVESTOR\"]\n end\n end\n end\n return assigned_accounts\nend", "de...
[ "0.58155155", "0.5802426", "0.55156547", "0.54996395", "0.54796195", "0.5476039", "0.5366088", "0.5213238", "0.5207325", "0.51864105", "0.5143237", "0.5137791", "0.51286554", "0.5114434", "0.5107566", "0.50922084", "0.50830376", "0.5073611", "0.5055734", "0.5043852", "0.50418...
0.8186372
0
GET /helps/1 GET /helps/1.json
def show @help = Help.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @help } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @helps = Help.all\n end", "def show\n @need_help = NeedHelp.find(params[:id])\n\n respond_to do |format|\n format.json {render json: @need_help}\n end\n end", "def helps(id)\n helps_data(request(\"needs/helps/#{id}.xml\", :auth => true))\n end", "def index\n info = A...
[ "0.6366669", "0.6175718", "0.6076555", "0.6050109", "0.5977681", "0.5977681", "0.5915773", "0.58807933", "0.58522004", "0.5826026", "0.57899225", "0.57687604", "0.57653326", "0.57600844", "0.5758985", "0.5728377", "0.57199764", "0.5718206", "0.5716527", "0.5713024", "0.570569...
0.62706476
1
GET /helps/new GET /helps/new.json
def new @help = Help.new respond_to do |format| format.html # new.html.erb format.json { render json: @help } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end", "def new\n @thing = Thing.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end...
[ "0.7165176", "0.69918215", "0.6981385", "0.69103944", "0.68859935", "0.68859935", "0.68542784", "0.6852886", "0.6852886", "0.6852886", "0.6852886", "0.6852886", "0.68443394", "0.6836141", "0.6821455", "0.6821455", "0.6821455", "0.6821455", "0.6821455", "0.68069977", "0.679305...
0.7155981
1
POST /helps POST /helps.json
def create @help = Help.new(params[:help]) respond_to do |format| if @help.save format.html { redirect_to @help, notice: 'Help was successfully created.' } format.json { render json: @help, status: :created, location: @help } else format.html { render action: "new" } format.json { render json: @help.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @shelter = Shelter.new(shelter_params)\n\n if @shelter.save\n render json: @shelter, status: :created, location: @shelter\n else\n render json: @shelter.errors, status: :unprocessable_entity\n end\n end", "def create\n @need_help = NeedHelp.new(params[:need_help])\n\n re...
[ "0.6136116", "0.61105037", "0.5887056", "0.58332497", "0.577625", "0.5693413", "0.562618", "0.5594344", "0.5446141", "0.5441019", "0.54253054", "0.5405194", "0.5380759", "0.5377785", "0.5377785", "0.5368101", "0.5363749", "0.53591883", "0.5350219", "0.5328846", "0.52986455", ...
0.58716345
3
PUT /helps/1 PUT /helps/1.json
def update @help = Help.find(params[:id]) respond_to do |format| if @help.update_attributes(params[:help]) format.html { redirect_to @help, notice: 'Help was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @help.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @shelter = Shelter.find(params[:id])\n\n if @shelter.update(shelter_params)\n head :no_content\n else\n render json: @shelter.errors, status: :unprocessable_entity\n end\n end", "def update\n @shelter = Shelter.find(params[:id])\n @shelter.update_attributes(params[:shelt...
[ "0.6679929", "0.63309777", "0.61285967", "0.59787774", "0.59257686", "0.59002066", "0.5864059", "0.5774537", "0.5730906", "0.5727064", "0.56655556", "0.56494164", "0.5630657", "0.5610629", "0.55530405", "0.55202657", "0.5504917", "0.5503862", "0.5493402", "0.54802364", "0.547...
0.54530513
25
DELETE /helps/1 DELETE /helps/1.json
def destroy @help = Help.find(params[:id]) @help.destroy respond_to do |format| format.html { redirect_to helps_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def delete(name)\n raise(...
[ "0.68559784", "0.6802321", "0.6770006", "0.6641226", "0.66003", "0.65992326", "0.65839845", "0.6565108", "0.6554588", "0.6533791", "0.65194464", "0.6508947", "0.64808977", "0.6467843", "0.6457057", "0.64319414", "0.6414604", "0.64039606", "0.64039606", "0.64039606", "0.640396...
0.6634471
4
Never trust parameters from the scary internet, only allow the white list through.
def email_template_params params.require(:email_template).permit(:title, :subject, :body) 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
Takes a cache method, and expiry predicate fn and a on_miss fn and returns the value of the cache_method
def read(cache_method, expired_fn: self.class.default_expired_fn, on_miss: F.identity) if cache.send(cache_method) && !expired_fn.(cache, cache_method) #not_expired?(cache_method) log_cache_hit get(cache_method) else log_cache_failure write(cache_method, on_miss.(get(cache_method))) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method_expiration(method, expiration=:_get_)\n if expiration == :_get_\n method_expirations[method]\n else\n method_expirations[method] = expiration\n end\n end", "def get(cache_method)\n cache.send(cache_method)\n end", "def cache_op(meth, ck)\n if @cache_ignor...
[ "0.7117594", "0.6905418", "0.6483995", "0.6477455", "0.62455016", "0.62071514", "0.61068696", "0.60646814", "0.60338104", "0.6000186", "0.5984448", "0.58621997", "0.5859986", "0.5843369", "0.5829759", "0.58256847", "0.58198595", "0.58131707", "0.57464564", "0.5714605", "0.562...
0.7913722
0
Provides access to the underlying cache through its cache methods
def get(cache_method) cache.send(cache_method) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cached\n raise NotImplementedError\n end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache; end", "def cache\n DataCache\n end", "def cache_store; end", "def cache_store; end", "def cache\n @cache ||= ...
[ "0.7974993", "0.78140277", "0.78140277", "0.78140277", "0.78140277", "0.78140277", "0.78140277", "0.78140277", "0.77818835", "0.7752388", "0.7752388", "0.76069593", "0.74965954", "0.73809236", "0.7309405", "0.73067224", "0.7287726", "0.72852653", "0.72758466", "0.7238458", "0...
0.74402547
13
Puts a value into the cache
def put(cache_method, value) cache.send("#{cache_method}=", value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(key, value)\n @cache[key] = value\n end", "def cache(key, value)\n @cache[key] = value\n end", "def cached_set(key, value)\n return unless h = self[:cache]\n Sequel.synchronize{h[key] = value}\n end", "def set_cache(value); end", "def set_cache(value);...
[ "0.8321329", "0.82036793", "0.8186418", "0.81461436", "0.81461436", "0.80279064", "0.8013675", "0.7994771", "0.77570903", "0.7753566", "0.77358323", "0.77284604", "0.7668412", "0.7609113", "0.75113434", "0.74777466", "0.744035", "0.74385303", "0.74105644", "0.73909056", "0.73...
0.7649727
13
son tambien PROC diferencia PROC y lambda PROC se comporta como un Bloque lambda como un metodo diferencias en comportamiento metodo y bloque args a un bloque pasan a ser nulos (son opcionales) metodos son obligatorios y dan peo sin van vacios return desde un bloque, terminas la ejecucion del metodo return desde metodo (lambda) solo se termina la ejecucion del mismo
def test_lambda (->(){return "Game Over"}).call() puts "Despues de la lambda" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proc_lamda_dif_one\n p = Proc.new { |num1, num2| \n num3= num1+num2 \n puts \"\\nProc executes even if it has less or more number of parameters\\n\"\n } \n p.call 50, 55, 60\n\n print \"\\n\\nFollowing Error with lamda if it has more or less no of arguments\"\n print \" than no of parameters it is c...
[ "0.64441127", "0.62665284", "0.6145041", "0.60783654", "0.5977346", "0.59772694", "0.5970601", "0.59508646", "0.5926473", "0.5913331", "0.59103835", "0.5904535", "0.58947235", "0.58831906", "0.5865806", "0.58497536", "0.5837032", "0.5837032", "0.581326", "0.58029526", "0.5802...
0.0
-1
Look up the generator class. Require its class file, find the class in ObjectSpace, tag it with this spec, and return.
def klass unless @klass require class_file @klass = lookup_class @klass.spec = self end @klass end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookup_class\r\n ObjectSpace.each_object(Class) do |obj|\r\n return obj if obj.ancestors.include?(Rails::Generator::Base) and\r\n obj.name.split('::').last == class_name\r\n end\r\n raise NameError, \"Missing #{class_name} class in #{class_file}\"\...
[ "0.71939576", "0.6148053", "0.582786", "0.5793454", "0.5735687", "0.5721393", "0.56409436", "0.56309843", "0.5584267", "0.5560206", "0.5419704", "0.5403766", "0.54036635", "0.53656346", "0.53545034", "0.5330423", "0.5326593", "0.5313185", "0.53128207", "0.53042924", "0.529268...
0.6203847
1
Search for the first Class descending from Rails::Generator::Base whose name matches the requested class name.
def lookup_class ObjectSpace.each_object(Class) do |obj| return obj if obj.ancestors.include?(Rails::Generator::Base) and obj.name.split('::').last == class_name end raise NameError, "Missing #{class_name} class in #{class_file}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_class_named name\n return self if full_name == name\n return self if @name == name\n\n @classes.values.find do |klass|\n next if klass == self\n klass.find_class_named name\n end\n end", "def find_class_named name\n @classes_hash[name]\n end", "def find_class_named_from name...
[ "0.7820382", "0.71787", "0.7123441", "0.69329756", "0.67919314", "0.6738578", "0.66702116", "0.6610641", "0.6608143", "0.6594133", "0.6537088", "0.6501001", "0.6501001", "0.64628756", "0.64341855", "0.642436", "0.6412617", "0.6384348", "0.63720065", "0.6351229", "0.6347497", ...
0.7827669
0
Return the watch for the object, or a new watch if none found. The new watch should be active if the object is new, correspoding to the watch being on by default when the user creates a new CI or Outage.
def watched_by_or_new(user) watched_by(user) || watches.build(user: user, active: !persisted?) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def watching?; @@watching == $$; end", "def watcher(name)\n watchers.find { |watcher| watcher.name == name }\n end", "def watch()\n merge(watch: 'true')\n end", "def watch()\n merge(watch: 'true')\n end", "def set_watch\n @watch = Watch.find(params[:id])\n end", "d...
[ "0.63779765", "0.6354847", "0.6266074", "0.6266074", "0.61898947", "0.61334044", "0.61307955", "0.6052805", "0.6015678", "0.5926923", "0.5763291", "0.5758302", "0.56348324", "0.555375", "0.5520806", "0.54550105", "0.54289323", "0.53874636", "0.53708756", "0.535469", "0.533846...
0.65043986
0
Get user's story choice.
def choosestory(username) storychoice = gets.chomp.downcase case storychoice when 'cop story', 'cop story', 'cop', 'cop' puts " You have chosen Cop Story." copstory(username) when 'rom com', 'rom-com', 'romance', 'rom', 'romcom' puts " You have chosen Rom-Com." romcom(username) when 'sci fi', 'sci-fi', 'sci', 'science fiction' puts " You have chosen Sci-Fi." scifi(username) else puts "Sorry, I don't understand! Would you like to hear a Rom-Com, Cop Story, or Sci-Fi?" choosestory(username) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def choice\n @choice\n end", "def choice\n @choice\n end", "def user_choice_text_version\n this_here = pick_a_story\n puts \"\\n #{this_here.title}\"\n puts \"\\n\"\n Narrabot::Scraper.aesop_fable_text(this_here) if !this_here.text_and_moral\n puts this_here.text_and_mora...
[ "0.6743722", "0.6520691", "0.6262329", "0.61053485", "0.60530037", "0.6051577", "0.5922977", "0.5918739", "0.5847805", "0.5835248", "0.5721274", "0.57099634", "0.56107736", "0.5610764", "0.56018496", "0.55739796", "0.5573249", "0.5570595", "0.55638933", "0.55550295", "0.55021...
0.6438637
2
runs after a story completes
def afterStory(username) puts " Would you like to hear another story?" playagainyesorno = gets.chomp.downcase case playagainyesorno when 'yes', 'yes please', 'yup' puts "Great!" puts "Your choices are: Rom-Com, Cop Story, or Sci-Fi." choosestory(username) when 'no', 'nope', 'no way' puts " Okay, goodbye!" else puts "I don't know what you said! " afterStory(username) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_finished\n end", "def action_complete() self.finished = true; end", "def completed()\n end", "def run_completed\n end", "def finish\r\n #\r\n end", "def finish\n #\n end", "def finish_story(project_id, story_id)\n begin\n set_super_token\n story = Pivotal...
[ "0.6893212", "0.6826164", "0.67688644", "0.6762992", "0.6592162", "0.6580112", "0.65235823", "0.65175605", "0.6510392", "0.649743", "0.64848065", "0.6462638", "0.64126694", "0.63709927", "0.63547385", "0.63547385", "0.63547385", "0.63547385", "0.63547385", "0.63547385", "0.63...
0.0
-1
Individual stories (madlib portion)
def romcom(username) puts "Sweet!" puts " Okay, now a few questions for you." puts " Choose a pastry." romcomPastry = gets.chomp puts " Yum. Ok, now name a large city." romcomCity = gets.chomp.capitalize puts " What is your dream job? (i.e. hairstylist!)" romcomProfession1 = gets.chomp puts " On the flip side, what job would be THE worst? (i.e., telemarketer)" romcomProfession2 = gets.chomp puts " Who is your sassiest friend?" romcomFriend = gets.chomp.capitalize puts " Who is your favorite fashion designer?" romcomDesigner = gets.chomp.capitalize puts " Who do you think is a total hottie?" romcomCrush = gets.chomp.capitalize puts " Choose a breed of dog." romcomDog = gets.chomp puts " Name a tropical island." romcomDestination = gets.chomp.capitalize puts " Sweet. Here comes your story. PRESS ENTER TO CONTINUE." continue = gets.chomp puts" -------------- * ROM-COM STORY * ----------------- You're a quirky young #{romcomProfession1} with a great group of friends, a promising career, an adorable #{romcomDog} named Triscuit, and a beautiful apartment that overlooks downtown #{romcomCity}. On the surface, you seem to have it all..." continue = gets.chomp print " but your love life is a total mess!" continue = gets.chomp puts " Your bff, #{romcomFriend}, keeps trying to set you up on blind dates, but you always seem to find a silly excuse not to go." continue = gets.chomp puts " One day, while running late to a conference, you have a chance meeting with #{romcomCrush}... a particularly annoying #{romcomProfession2} who is quite possibly the most arrogant person you've ever met. You find out that this moron's company is next door to yours." continue = gets.chomp puts " You tell #{romcomCrush} that they are a total turd #{romcomPastry} and if they ever speak to you in public again, you will punch them in the face!" continue = gets.chomp puts " What a morning. When you finally get to work, you have a voicemail." continue = gets.chomp puts " You find out that your friend is being sent on location to work a private party for #{romcomDesigner} in #{romcomDestination}!" continue = gets.chomp puts " #{romcomFriend} has recieved a plus-one ticket to the show and kindly invites you to come, too. You deliberate on whether it's worth the price, but since you haven't left #{romcomCity} in God knows how long, you decide you will say yes." continue = gets.chomp puts " The day finally arrives for the trip!" continue = gets.chomp puts " To your shock, on the plane, who do you end up sitting next to but that ridiculous #{romcomProfession2}?! As it turns out, #{romcomCrush}'s sister happens to live in #{romcomDestination} and #{romcomCrush} is heading to the exact same hotel as yours for a family reunion... Can things possibly get any worse?!" continue = gets.chomp puts " A series of hilarious events are bound to ensue on this exotic, tropical paradise... -----------------------------------" continue = gets.chomp afterStory(username) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stories\n @stories ||= Stories.new(data)\n end", "def stories ; @stories || get_stories ; end", "def stories ; @stories || get_stories ; end", "def stories\n @stories.keys.each_with_index.map { |story_name, i| get_story(story_name, i) }\n end", "def get_stories\n api_url = \"#{CONFIG[:ap...
[ "0.7299301", "0.7254879", "0.7254879", "0.70710564", "0.7056004", "0.7043919", "0.7040603", "0.7032684", "0.70208776", "0.70180446", "0.6894301", "0.68873954", "0.6861479", "0.6700668", "0.66549945", "0.6623883", "0.66229945", "0.65999484", "0.65771544", "0.65370446", "0.6498...
0.0
-1
GET /feedbacks/1 GET /feedbacks/1.json
def show @feedback = Feedback.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @feedback } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @feedbacks = Feedback.find(params[:id])\n render json: @feedbacks\n end", "def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n end\n end", "def show\n render json: @feedback\n end",...
[ "0.8084282", "0.7708273", "0.76050806", "0.74718213", "0.7187808", "0.7148408", "0.7148408", "0.7148408", "0.7148408", "0.7148408", "0.7148408", "0.7148408", "0.7148408", "0.71111286", "0.70773435", "0.70761836", "0.7047566", "0.7027317", "0.7027317", "0.7027317", "0.69922346...
0.754554
7
Helper to convert floats to integers (pennies)
def to_pennies(dec) pennies = (dec * 100).to_int return pennies end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def numericize\n\t\tcollect(&:to_f)\n\tend", "def type_cast(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\n end", "def typecast_to_integer(value)\n typecast_to_numeric(value, :to_i)\n end", "def int_or_f(number)\n if number.to_f - number.to_i == 0.0\n numbe...
[ "0.67189145", "0.6681907", "0.6504741", "0.6380564", "0.6370364", "0.636963", "0.6347934", "0.63348866", "0.6334555", "0.6273026", "0.62485075", "0.62285346", "0.6225016", "0.62224764", "0.6220345", "0.6220345", "0.62096304", "0.62096304", "0.62096304", "0.6187017", "0.618303...
0.0
-1
Helper function to convert centbased money amounts to dollars and cents
def fm(money) money_string = format("%.2f", (money.abs/100.to_f)) if money < 0 money_string = '( ' + money_string + ' )' end return money_string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_in_dollars_and_cents\n total.to_f / 100\n end", "def to_cents amount\n amount = amount.gsub(/[^0-9.]/, \"\")\n (amount.to_f * 100).to_i\n end", "def dollars_to_cents(dollars)\n (100 * dollars.to_r).to_i\nend", "def convert_to_cents(amount_in_usd)\n (amount_in_usd) ? (amount_in_us...
[ "0.81262195", "0.81045693", "0.79996216", "0.7926415", "0.7734494", "0.7716773", "0.7639761", "0.7593025", "0.75784427", "0.75651765", "0.74982554", "0.74623346", "0.7461361", "0.740305", "0.7185292", "0.71624905", "0.7073904", "0.70576066", "0.7043411", "0.6994738", "0.69938...
0.0
-1
using it is a smell, try to find dedicated methods instead
def success? instance_of?(Success) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def probers; end", "def schubert; end", "def custom; end", "def custom; end", "def internal; end", "def suivre; end", "def private_method\n...
[ "0.79596835", "0.68345714", "0.68345714", "0.6818231", "0.6818231", "0.6818231", "0.6818231", "0.6572362", "0.6508349", "0.64531887", "0.64531887", "0.6409746", "0.639816", "0.6370745", "0.6318534", "0.624656", "0.6235846", "0.6211991", "0.6150513", "0.61335653", "0.61335653"...
0.0
-1
use only in tests, prefer other methods such as `map`, `flat_map`, `and`, `fold` or `get_or_else`
def get! throw NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conditionally(*) end", "def conditionally(*) end", "def selected_map!(arr, prc1, prc2)\n arr.map! do |ele|\n if prc1.call(ele)\n prc2.call(ele)\n else\n ele\n end\n end\nnil\nend", "def my_method(array)\n if array.empty?\n []\n elsif array.map {|value...
[ "0.6072054", "0.6072054", "0.598768", "0.59720343", "0.5894473", "0.58847475", "0.58847475", "0.58384115", "0.58384115", "0.58384115", "0.57745826", "0.57745826", "0.5770944", "0.5770944", "0.5770944", "0.5770944", "0.57584614", "0.575663", "0.5730085", "0.56941384", "0.56879...
0.0
-1
use only in tests, prefer other methods such as `on_error`
def error! throw NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_error error\n raise error\n end", "def on_error(err)\n raise err\n end", "def do_failure; end", "def errorhandling\n end", "def on_failure(object, *args); end", "def on_error(exception)\n raise exception\n end", "def example_failed(_)\n end", "def error; end", "def error; end",...
[ "0.7251966", "0.7169255", "0.6739868", "0.6646719", "0.66273904", "0.6565781", "0.65572804", "0.6502941", "0.6502941", "0.6502941", "0.6502941", "0.6502941", "0.6502941", "0.6502941", "0.64963883", "0.64837205", "0.6475662", "0.6466872", "0.64057136", "0.6359451", "0.6359451"...
0.0
-1
Check if the user is logged in. If not, redirect the user to the log in page.
def require_ownership unless current_user redirect_to login_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_logged_in\n unless current_user\n redirect_to '/login'\n end\n end", "def redirect_if_not_logged_in\n if !logged_in?\n flash[:errors] = \"You must be logged in to view the page \"\n redirect '/'\n end\n end", "def redirect_if_logged_in\n ...
[ "0.8608616", "0.8523593", "0.8460603", "0.8435172", "0.8435172", "0.8381257", "0.8381257", "0.8372853", "0.8322884", "0.8294782", "0.828405", "0.8280424", "0.82173187", "0.82094765", "0.8203997", "0.8190787", "0.81859076", "0.81793064", "0.8176551", "0.8162803", "0.8162382", ...
0.0
-1
GET /active_stats/1 GET /active_stats/1.json
def show @active_stat = ActiveStat.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render :json => @active_stat } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stats\n request :get, \"_stats\"\n end", "def stats\n request :get, \"_stats\"\n end", "def stats\n Client.current.get(\"#{resource_url}/stats\")\n end", "def activity_statistics\n get(\"/user/#{@user_id}/activities.json\")\n end", "def activity_statistics\n get(\"/...
[ "0.7551879", "0.7551879", "0.75458974", "0.70523727", "0.70523727", "0.6995069", "0.67771333", "0.6745493", "0.6745493", "0.6745493", "0.6693683", "0.6664412", "0.664501", "0.66362834", "0.6612288", "0.65774196", "0.65427107", "0.6526029", "0.6513008", "0.650902", "0.6497229"...
0.7345192
3
GET /active_stats/new GET /active_stats/new.json
def new @active_stat = ActiveStat.new respond_to do |format| format.html # new.html.erb format.json { render :json => @active_stat } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stat }\n end\n end", "def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stat }\n end\n end", ...
[ "0.745848", "0.7391077", "0.7301487", "0.7186264", "0.706984", "0.7018928", "0.70008487", "0.687276", "0.68291694", "0.68188906", "0.6749778", "0.6730057", "0.6730057", "0.6717459", "0.6698824", "0.66893834", "0.66827387", "0.6679885", "0.6630864", "0.6626687", "0.66025054", ...
0.78863364
0
POST /active_stats POST /active_stats.json
def create @active_stat = ActiveStat.new(params[:active_stat]) respond_to do |format| if @active_stat.save format.html { redirect_to @active_stat, :notice => 'Active stat was successfully created.' } format.json { render :json => @active_stat, :status => :created, :location => @active_stat } else format.html { render :action => "new" } format.json { render :json => @active_stat.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_stats\n first_time = @prev_stat.empty?\n stats = build_request\n @stat.keys.each { |k| stats[k] = @stat[k] - @prev_stat[k] }\n @prev_stat.replace(@stat)\n # These should be reported as absolute values\n [:mt, :ma, :mc].each {|k| @prev_stat[k] = 0}\n return if first_time\...
[ "0.6232018", "0.6167029", "0.6167029", "0.6077778", "0.59208536", "0.5870383", "0.5791311", "0.57828367", "0.5781357", "0.5757478", "0.56984824", "0.568131", "0.56515783", "0.56470543", "0.5643813", "0.56373495", "0.5625128", "0.5615462", "0.5611067", "0.556822", "0.5540162",...
0.65523034
0
PUT /active_stats/1 PUT /active_stats/1.json
def update @active_stat = ActiveStat.find(params[:id]) respond_to do |format| if @active_stat.update_attributes(params[:active_stat]) format.html { redirect_to @active_stat, :notice => 'Active stat was successfully updated.' } format.json { head :ok } else format.html { render :action => "edit" } format.json { render :json => @active_stat.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_stats\n StatService.new(self).update_stats\n end", "def update\n @stat = Stat.find(params[:id])\n\n if @stat.update(stat_params)\n head :no_content\n else\n render json: @stat.errors, status: :unprocessable_entity\n end\n end", "def update\n logger.debug(\"Update of #...
[ "0.6262326", "0.62043226", "0.60624444", "0.6019305", "0.6009201", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5922534", "0.5847465", "0.58171886", "0.58094674", "0.58012223"...
0.6814571
0
DELETE /active_stats/1 DELETE /active_stats/1.json
def destroy @active_stat = ActiveStat.find(params[:id]) @active_stat.destroy respond_to do |format| format.html { redirect_to active_stats_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @backend_stat = Backend::Stat.find(params[:id])\n @backend_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to backend_stats_url }\n format.json { head :ok }\n end\n end", "def destroy\n @stat = Stat.find(params[:id])\n @stat.destroy\n\n respond_to do...
[ "0.7446071", "0.73452574", "0.7344989", "0.7132254", "0.7132254", "0.7132254", "0.7132254", "0.7132254", "0.71168864", "0.70970297", "0.7095509", "0.7095509", "0.7091904", "0.7001243", "0.69636625", "0.6953723", "0.6946767", "0.6903175", "0.6852545", "0.6835242", "0.6826405",...
0.77944946
0
GET /active_stats/team/1 GET /active_stats/team/1.json
def team @team = Team.where('team_id = ?', params[:id]) @active_stats = ActiveStat.where('team_id = ?', params[:id]) respond_to do |format| format.html format.json end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_team_stats()\n query_params = { }\n headers = {}\n body = nil\n\n path = \"/team/stats\"\n\n @client.request(\n method: :get,\n path: path,\n query: query_params,\n headers: headers,\n body: body)\n end", "def team(id)\n get \"/teams/#...
[ "0.78863543", "0.7038234", "0.702839", "0.70033634", "0.69328886", "0.68993145", "0.68926066", "0.68735665", "0.6866543", "0.6856083", "0.6825968", "0.68066007", "0.67841077", "0.6777518", "0.6755418", "0.6755418", "0.6755418", "0.6755418", "0.6754665", "0.67120904", "0.67113...
0.774616
1
Delete empty paragraphs and line breaks at the end of blocklevel elements
def delete_junk_breaks!(node) node.children.reject! do |child| if child.is_a?(TagNode) and !node.is_a?(RootNode) if !child.children.empty? delete_junk_breaks!(child) false elsif child.tag_name == @schema.paragraph_tag_name # It's an empty paragraph tag true elsif @schema.block_level?(node.tag_name) and child.tag_name == @schema.line_break_tag_name and node.children.last == child # It's a line break a the end of the block-level element true else false end else false end end node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_emptytext_below_blocknodes(nodes)\n nodes.each do |node|\n node.children.each {|c| c.unlink if c.text? and c.inner_text =~ /^\\s*$/ }\n end\nend", "def remove_empty_paragraphs(env)\n node = env[:node]\n\n node.unlink if node.element? && (node.name == 'p' || node.name == 'span') && node....
[ "0.73270065", "0.7274272", "0.67452425", "0.64590013", "0.64409304", "0.6403169", "0.63708806", "0.63551295", "0.6309027", "0.62990797", "0.6281875", "0.61500823", "0.6125572", "0.6099613", "0.6087406", "0.6078612", "0.6076282", "0.6058409", "0.6041931", "0.6027673", "0.60040...
0.7031917
2
The schema defines some tags that may not be empty. This method removes any such empty tags from the tree.
def delete_invalid_empty_tags!(node) node.children.reject! do |child| if child.is_a?(TagNode) if child.children.empty? and !@schema.tag_may_be_empty?(child.tag_name) true else delete_invalid_empty_tags!(child) false end end end node end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_empty_tags\n sorted_tags = Tag.all.sort_by { |tag| tag.articles.count }\n return if sorted_tags.first.articles.count > 0\n\n sorted_tags.each { |tag| tag.delete if tag.articles.count == 0 }\n end", "def delete_all_tags\n delete_tags(self.tags)\n nil\n end", "def clean_al...
[ "0.67088604", "0.62291735", "0.6200493", "0.6150672", "0.6046417", "0.60385215", "0.6020291", "0.5999883", "0.5942662", "0.593657", "0.5911939", "0.577986", "0.57653075", "0.57636946", "0.5727941", "0.5725904", "0.56874764", "0.56865513", "0.56790555", "0.5589185", "0.5579459...
0.7883007
0
Whether Markdown implements the PHP Markdown extra syntax. Note: it is not guaranteed that if this is false, then no special features will be used.
def markdown_extra? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markdown?\n @use_markdown && markdown_processor\n end", "def markdown?\n defined?(RDiscount) or defined?(BlueCloth)\n end", "def markdown?\n defined?(RDiscount) or defined?(BlueCloth)\n end", "def latex?\n false\n end", "def tomdoc?\n @format == 'tomdoc'\n end", "def f...
[ "0.73895484", "0.7143385", "0.7143385", "0.6540442", "0.6231355", "0.6106636", "0.6106636", "0.6010146", "0.5995598", "0.59906477", "0.58403295", "0.5759053", "0.5759053", "0.57428753", "0.56916255", "0.56916255", "0.5666334", "0.5665314", "0.5660993", "0.5660993", "0.5652745...
0.8003012
0
Whether Markdown implements the new metadata proposal. Note: it is not guaranteed that if this is false, then no special features will be used.
def new_meta_data? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metadata?\n true\n end", "def metadata?\n true\n end", "def markdown_extra?\n true\n end", "def metadata?\n !!@metadata\n end", "def metadata?\n !!@metadata\n end", "def meta_description?\n meta_description.present?\n end", "def has_meta_description?\n !...
[ "0.7244055", "0.7207773", "0.69506896", "0.6908733", "0.6908733", "0.6695381", "0.6641814", "0.6551538", "0.65438735", "0.64475536", "0.64475536", "0.63714683", "0.6295641", "0.6146806", "0.6111198", "0.6092652", "0.60684633", "0.6060716", "0.6023925", "0.6020089", "0.6018995...
0.6411983
11
Handles sign up submisison
def create @user = User.new(user_params) if @user.save redirect_to login_path else render :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signup\n end", "def signup\n end", "def signup\n sign_out\n puts '----signup called.----'\n redirect_to '/users/sign_up'\n end", "def attemp_signup\n\n end", "def client_sign_up\n\n end", "def signup_info\n end", "def candidate_sign_up\n\n end", "def signup\n return set_session...
[ "0.8075081", "0.8075081", "0.73807573", "0.73402673", "0.732464", "0.7223948", "0.7183166", "0.7058047", "0.70064324", "0.699061", "0.6978432", "0.69737256", "0.6960635", "0.695787", "0.69378656", "0.692887", "0.6927564", "0.69152457", "0.69066954", "0.68908393", "0.6867426",...
0.0
-1
close unclaimed connections in five seconds
def do_connect(host) create_connector.connect(host.ip.to_s).fallback do |error| case error when Errors::ProtocolError synchronize do if @options.protocol_version > 1 @logger.info("Host #{host.ip} doesn't support protocol version #{@options.protocol_version}, downgrading") @options.protocol_version -= 1 do_connect(host) else Ione::Future.failed(error) end end when Error Ione::Future.failed(error) else e = Errors::IOError.new(error.message) e.set_backtrace(error.backtrace) Ione::Future.failed(e) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(timeout=10)\n # Prevent any new connections from being handed out\n self.pool_size = 0\n start_time = Time.now\n while (Time.now - start_time) < timeout\n sleep 1\n @mutex.synchronize do\n return if @connections.empty?\n @logger.info \"#{@name}: Waiting to close, #{@co...
[ "0.72151554", "0.7165466", "0.7165466", "0.7045658", "0.7045658", "0.6994702", "0.69850606", "0.6976655", "0.6900116", "0.6753561", "0.6710939", "0.65831625", "0.656714", "0.6521667", "0.65123343", "0.65006506", "0.6494057", "0.64885294", "0.6410161", "0.63996434", "0.6354053...
0.0
-1
a Rational Number (two ints reping the num and denom of a rat num) outputs: Array (an arr of denoms that are part of an Egyptian Fraction rep of the num) reqs: take a Rational Number rtn an arr reping an Egyptian Fraction rep of the num struct: Array (to hold denoms) algo: init the output arr to [] init a sum at 0 init the denom at 1 while the sum is rat throw away the new sum else sum = new sum copy denom to the output arr increment the denom
def egyptian(rat_num) arr = [] sum = 0 temp_sum = sum denom = 1 while sum < rat_num && denom < 1_000_000 temp_sum += Rational(1, denom) if temp_sum > rat_num # overshot temp_sum = sum # reset else sum = temp_sum arr << denom end # p "denom = #{denom}, sum = #{sum}, arr = #{arr}" denom += 1 end arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def egyptian(rational)\n array = []\n n = 1\n remaining = rational\n until remaining == 0\n if remaining - Rational(1, n) >= 0\n array << n\n remaining = remaining - Rational(1, n)\n end\n n += 1\n end\n array\nend", "def unegyptian(arr)\n sum = 0\n arr.each { |denom| sum += Rational(1...
[ "0.6782674", "0.661094", "0.65043896", "0.6374127", "0.6353443", "0.63053936", "0.6232218", "0.61102", "0.60121995", "0.5889361", "0.5883006", "0.5878256", "0.5858755", "0.5800308", "0.5800201", "0.57821065", "0.57633317", "0.57446957", "0.5668355", "0.5632723", "0.5608964", ...
0.7269487
0
> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 230, 57960] inputs: Array (an arr of denoms that are part of an Egyptian Fraction rep of the num) outputs: a Rational Number (two ints reping the num and denom of a rat num) reqs: take an arr reping an Egyptian Fraction rep of the num rtn a Rational Number struct: num (to hold sum of fractional elements) algo: init a sum at 0 for each element in the arr add rat(1/denom) to the sum rtn the sum
def unegyptian(arr) sum = 0 arr.each { |denom| sum += Rational(1, denom) } sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def egyptian(rat_num)\n arr = []\n sum = 0\n temp_sum = sum\n denom = 1\n while sum < rat_num && denom < 1_000_000\n temp_sum += Rational(1, denom)\n if temp_sum > rat_num # overshot\n temp_sum = sum # reset\n else\n sum = temp_sum\n arr << denom\n end\n # p \"denom = #{denom}, s...
[ "0.74681574", "0.6929715", "0.68888867", "0.6696607", "0.66484076", "0.6642132", "0.66127056", "0.6460344", "0.6410816", "0.6185238", "0.61802244", "0.61361647", "0.61204296", "0.61168563", "0.60516393", "0.60494816", "0.6002087", "0.59625614", "0.58969295", "0.58181685", "0....
0.7453417
1
def search_bar redirect_to :controller => "photos", :action => "search_bar", :latitude => params[:latitude], :longitude => params[:longitude] end
def get_and_store_username @user = User.find_by_id(session[:current_user_id]) if !@user redirect_to logins_path() end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search\n @coordinates = [params[:lat].to_f, params[:lng].to_f]\n session[:search] = @coordinates\n redirect_to places_path\n end", "def post\n\t redirect_to search_path( query: params[:query] )\n\tend", "def search\n redirect_to gallery_path(search_params)\n end", "def adv_search\r\n...
[ "0.72949606", "0.6824905", "0.6790763", "0.6708798", "0.6675814", "0.6622349", "0.65944386", "0.6580077", "0.646505", "0.64432156", "0.6420111", "0.63329655", "0.6331927", "0.6328624", "0.6309461", "0.63008064", "0.6275685", "0.6231363", "0.62241036", "0.6219557", "0.62065554...
0.0
-1
Define method to insert user input into the table
def insert_into_table(db, product, exp_date, prod_type) db.execute("INSERT INTO products (name, expiration_date, type_id) VALUES (?, ?, ?)",[product, exp_date, prod_type]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert()\n\n end", "def insert()\n\n # Kräver att det finns ett \"set_table(\"Table\")\" i klassen\n @insertable_vars_full = self.instance_variables # Ta med namnen user.username osv\n @insertable_vars_full.shift(1) # Kinda frisky\n @insertable_vars = []\n @insertable_valu...
[ "0.7337972", "0.72228664", "0.70378417", "0.70066565", "0.69852406", "0.6839374", "0.67483747", "0.67472166", "0.6745353", "0.6653594", "0.6633105", "0.6626818", "0.6574734", "0.6535419", "0.643038", "0.638177", "0.63712204", "0.63712204", "0.63630843", "0.63350385", "0.63176...
0.59631413
57
Save the load balancer health check
def balancer_health_check(balancer) balancer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_save\n api.balancer_save(self)\n end", "def update_health_check(elb_name, health_check)\n @elb.configure_health_check({\n load_balancer_name: elb_name,\n health_check: health_check.to_aws\n })\n end", "def create\n @operations_check = Operatio...
[ "0.65214473", "0.62630206", "0.62096196", "0.6022025", "0.5440961", "0.54199463", "0.54026926", "0.53924656", "0.53271985", "0.53271985", "0.53271985", "0.53271985", "0.53062093", "0.5276351", "0.5266802", "0.5245896", "0.5245496", "0.5245496", "0.52333295", "0.5231805", "0.5...
0.5682483
4
Save the load balancer attached servers
def balancer_set_instances(balancer) balancer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def server_save(server)\n if(server.persisted?)\n else\n result = request(\n :path => 'containers',\n :method => :post,\n :expects => 202,\n :json => {\n :name => server.name,\n :profiles => [server.flavo...
[ "0.63528025", "0.6137384", "0.604075", "0.59870017", "0.588611", "0.5863238", "0.5829961", "0.57481426", "0.5694544", "0.5691197", "0.56579214", "0.5647648", "0.5645078", "0.56164026", "0.5555861", "0.5554011", "0.54256064", "0.53953266", "0.536694", "0.53525096", "0.5339324"...
0.5179723
30
Reload the balancer data from the API
def balancer_reload(balancer) if balancer.persisted? begin load_balancer_data(balancer) rescue Miasma::Error::ApiError::RequestError => e if e.response_error_msg.include?("LoadBalancerNotFound") balancer.state = :terminated balancer.status = "terminated" balancer.valid_state else raise end end end balancer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_reload\n api.balancer_reload(self)\n end", "def reload_data\n self.class.new reinit_endpoint.do_get\n end", "def reload!\n fetch_data!\n end", "def reload\n reset\n fetch\n end", "def reload\n reset\n fetch\n ...
[ "0.7836738", "0.73334336", "0.7310872", "0.72407776", "0.72407776", "0.7109553", "0.70301884", "0.6807721", "0.6807721", "0.6764059", "0.6615204", "0.66087914", "0.6599976", "0.6550208", "0.6515741", "0.64577997", "0.6422918", "0.63764524", "0.63609815", "0.63409334", "0.6323...
0.7354195
1
Fetch balancers or update provided balancer data
def load_balancer_data(balancer = nil) params = Smash.new("Action" => "DescribeLoadBalancers") if balancer params["LoadBalancerNames.member.1"] = balancer.id || balancer.name end result = all_result_pages(nil, :body, "DescribeLoadBalancersResponse", "DescribeLoadBalancersResult", "LoadBalancerDescriptions", "member") do |options| request( :method => :post, :path => "/", :form => options.merge(params), ) end if balancer health_result = all_result_pages(nil, :body, "DescribeInstanceHealthResponse", "DescribeInstanceHealthResult", "InstanceStates", "member") do |options| request( :method => :post, :path => "/", :form => options.merge( "LoadBalancerName" => balancer.id || balancer.name, "Action" => "DescribeInstanceHealth", ), ) end end result.map do |blr| (balancer || Balancer.new(self)).load_data( Smash.new( :id => blr["LoadBalancerName"], :name => blr["LoadBalancerName"], :state => :active, :status => "ACTIVE", :created => blr["CreatedTime"], :updated => blr["CreatedTime"], :public_addresses => [ Balancer::Address.new( :address => blr["DNSName"], :version => 4, ), ], :servers => [blr.get("Instances", "member")].flatten(1).compact.map { |i| Balancer::Server.new(self.api_for(:compute), :id => i["InstanceId"]) }, ).merge( health_result.nil? ? {} : Smash.new( :server_states => health_result.nil? ? nil : health_result.map { |i| Balancer::ServerState.new( self.api_for(:compute), :id => i["InstanceId"], :status => i["State"], :reason => i["ReasonCode"], :state => i["State"] == "InService" ? :up : :down, ) }, ) ) ).valid_state end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def balancer_reload(balancer)\n if balancer.persisted?\n begin\n load_balancer_data(balancer)\n rescue Miasma::Error::ApiError::RequestError => e\n if e.response_error_msg.include?(\"LoadBalancerNotFound\")\n balancer.state = :terminated\n ...
[ "0.6357205", "0.62527823", "0.624059", "0.61288977", "0.6002497", "0.5981547", "0.58979493", "0.5869539", "0.58688635", "0.58554137", "0.57318085", "0.5725863", "0.56905466", "0.56279457", "0.56279457", "0.55349386", "0.55104166", "0.5417317", "0.5413467", "0.5406602", "0.540...
0.74368066
0
Return all load balancers
def balancer_all(options = {}) load_balancer_data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @cabinet_balancers = Balancer.all\n end", "def describe_load_balancers(ids = [], options = {})\n ids = [*ids]\n params = {}\n params['Marker'] = options[:marker] if options[:marker]\n params['PageSize'] = options[:page_size] if options[:page_size]\n pa...
[ "0.7522266", "0.71692187", "0.69277346", "0.69092095", "0.6514731", "0.646942", "0.6340497", "0.6328993", "0.6328993", "0.6321338", "0.62811565", "0.6130564", "0.60530114", "0.5987703", "0.59585774", "0.575374", "0.5741722", "0.56703496", "0.5657753", "0.55636954", "0.5553757...
0.78813696
0