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
This returns the user that was being replied to if this was a reply
def replying_to return nil unless self.reply? user = self.text[0...self.text.index(" ")] return nil unless user[0...1] == "@" user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_reply_to_user\n previous_tweet.try(:author).try(:screen_name) || params[:in_reply_to_user]\n end", "def get_reply_to\n @reply_to\n end", "def reply_to\n return @reply_to\n end", "def reply_author(reply)\n user_signed_in? && current_user.id == reply.user_id\n end",...
[ "0.76121134", "0.74957883", "0.74244213", "0.7380581", "0.72780997", "0.72673935", "0.7219902", "0.72044265", "0.7176745", "0.70954794", "0.7013381", "0.70027786", "0.69747806", "0.69319975", "0.69319975", "0.68909776", "0.68707734", "0.6759535", "0.67265797", "0.67129654", "...
0.80432045
1
This provides a summary of the text update, if it's longer than 30 characters
def text_summary summary = self.text summary = summary[(summary.index(" ") + 1)...summary.length] if self.text[0...1] == "@" summary = (summary.length > 30 ? "#{summary[0..30]}..." : summary[0..30]) summary end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_summary\n summary = attribute_get(:text)\n summary = summary[(summary.index(\" \") + 1)...summary.length] if summary[0...1] == \"@\"\n summary = (summary.length > 30 ? \"#{summary[0..30]}...\" : summary[0..30])\n summary\n end", "def update_summary\n if self.description != nil\n ...
[ "0.6241136", "0.62100136", "0.61621076", "0.612147", "0.60632205", "0.6052493", "0.5978225", "0.5968104", "0.5921031", "0.5888422", "0.5877222", "0.5851496", "0.58510053", "0.5850388", "0.5832156", "0.5823413", "0.58208996", "0.5795114", "0.57815146", "0.5771636", "0.5733697"...
0.6357538
0
This builds a direct url to the tweet
def url "http://twitter.com/#{self.username}/statuses/#{self.twitter_id}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def twitter_url; \"https://twitter.com/#{twitter}\" end", "def construct_tweet(path = \"\", text = ENV[\"TWEET_COPY_GENERAL\"])\n return \"https://twitter.com/share?url=\"+u(get_url(path))+\"&text=\"+text\n end", "def twitter_url(username)\n \"https://twitter.com/#!/#{username}\"\n end", "def main_ur...
[ "0.78231025", "0.74246895", "0.7329112", "0.7257571", "0.7155517", "0.71393454", "0.7008962", "0.69889295", "0.694052", "0.69196093", "0.6816109", "0.6809329", "0.66530037", "0.6626561", "0.66080195", "0.657513", "0.65730524", "0.65545917", "0.6541043", "0.6507886", "0.650603...
0.711108
6
Commas as thousands separators for numbers.
def delimited_number(value, symbol: '', delimiter: ',', no_decimals: 2) val = value.nil? ? 0.0 : value parts = format("#{symbol}%.#{no_decimals}f", val).split('.') parts[0] = parts.first.reverse.gsub(/([0-9]{3}(?=([0-9])))/, "\\1#{delimiter}").reverse parts.join('.') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def thousands_separator; end", "def thousands( sep = \",\" )\n self.groupsep( 3, sep )\n end", "def to_thousands( thousands=0 )\n\t\tparts = []\n\t\t(0..thousands).step( Thousands.length - 1 ) {|i|\n\t\t\tif i.zero?\n\t\t\t\tparts.push Thousands[ thousands % (Thousands.length - 1) ]\n\t\t\telse\n\t\t\t\tpa...
[ "0.8567925", "0.8393682", "0.70651275", "0.7004506", "0.70028806", "0.6947596", "0.69110864", "0.6852019", "0.6850784", "0.680207", "0.6760471", "0.6613289", "0.6566781", "0.6548864", "0.6548864", "0.65416783", "0.6518674", "0.6450666", "0.6449905", "0.64178836", "0.6390772",...
0.60067433
50
Takes a Numeric and returns a string without trailing zeroes. Example: 6.03 => "6.03". 6.0 => "6".
def format_without_trailing_zeroes(numeric_value) s = format('%<num>f', num: numeric_value) i = s.to_i f = s.to_f i == f ? i.to_s : f.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def str_zero(n)\n n.to_s.sub(/\\.?0+$/, '')\nend", "def f(natural_number)\n string = natural_number.to_s\n string.reverse!\n \"0.#{string}\"\nend", "def reformat(number)\n num_without_decimal = number.gsub('.','') \n unless num_without_decimal.length == 4\n num_without_decimal = '0' + num_withou...
[ "0.77230847", "0.7192507", "0.7120248", "0.7061099", "0.67901987", "0.6679071", "0.66348773", "0.6596844", "0.6557345", "0.6541706", "0.6535843", "0.6534145", "0.65117836", "0.6479519", "0.6479519", "0.64748627", "0.6333535", "0.6330317", "0.63200665", "0.62542546", "0.625268...
0.76462203
1
Deep merge for two hashes
def merge_recursively(left, right) left.merge(right) { |_, a_item, b_item| a_item.is_a?(Hash) ? merge_recursively(a_item, b_item) : b_item } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _deep_merge(hash, other_hash); end", "def deep_merge_hashes(master_hash, other_hash); end", "def deep_merge(source, hash); end", "def deep_merge(source, hash); end", "def deep_merge(*other_hashes, &blk); end", "def deep_merge!(*other_hashes, &blk); end", "def deep_merge!(other_hash, &block); end", ...
[ "0.8893713", "0.8890643", "0.8801239", "0.8801239", "0.86377233", "0.86339533", "0.86317194", "0.84317505", "0.84317505", "0.8346855", "0.8295126", "0.82467055", "0.8196193", "0.8148336", "0.8057258", "0.80432576", "0.80432576", "0.80432576", "0.804214", "0.80057573", "0.7997...
0.73373336
65
Change string keys in a nested hash into symbol keys.
def symbolize_keys(hash) if hash.is_a?(Hash) Hash[ hash.map do |k, v| [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys(v)] end ] else hash end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deep_symbolize_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_sym rescue key }\n end", "def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end", "def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end", "def deep_sym...
[ "0.787746", "0.7751766", "0.7735223", "0.76313615", "0.76313615", "0.76313615", "0.7628558", "0.7628558", "0.7627677", "0.7615821", "0.76116437", "0.7607828", "0.7607828", "0.7542802", "0.753703", "0.75127363", "0.75127363", "0.73781943", "0.7374877", "0.73698217", "0.7335413...
0.715162
25
Calculate the 4digit pick ref: 1: Second digit of the ISO week 2: day of the week (Mon = 1, Sun = 7) 3: Packhouse number 4: First digit of the ISO week
def calculate_pick_ref(packhouse_no, for_date: Date.today) raise ArgumentError, "Pick ref calculation: Packhouse number #{packhouse_no} is invalid - it must be a single character." unless packhouse_no.to_s.length == 1 iso_week1, iso_week2 = for_date.strftime('%V').split(//).reverse "#{iso_week1}#{for_date.strftime('%u')}#{packhouse_no}#{iso_week2}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iso_week_num(wkst)\n iso_year_and_week_num(wkst)[1]\n end", "def mweek; (5 - wday + day) / 7 end", "def week_pattern\n year_weeks == 53 ? [5,4,5]+[4,4,5]*3 : [4,4,5]*4\n end", "def first_wday; (wday - day + 1) % 7 end", "def day_of_week\n dnum = day\n dnum -= 10 if dnu...
[ "0.67262375", "0.66566485", "0.6542902", "0.63121444", "0.6281256", "0.61641264", "0.6115551", "0.6108956", "0.6097245", "0.6066938", "0.6055815", "0.6043245", "0.6035154", "0.5995601", "0.5986837", "0.5960838", "0.59523726", "0.59295994", "0.5901489", "0.5885397", "0.5878731...
0.6892222
0
Required Sends a search query with provided input to your API and returns results as a string.
def search_api(input) client response = client.call :get_mac_address do message configurationId: CONFIG[:id], macAddress: input[:mac] end data = response.body[:get_mac_address_response][:return] rescue {} expand_properties data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Search query\n \n APICall(path: \"search.json?query=#{query}\",method: 'GET')\n \n end", "def search(query)\n params = { key: self.api_key, cx: self.search_engine_id, q: query }\n uri = URI(BASE_URL)\n uri.query = URI.encode_www_form(params)\n request = build_req...
[ "0.74727404", "0.735932", "0.71774787", "0.71219754", "0.70440716", "0.700937", "0.69665253", "0.69590056", "0.69443953", "0.6914212", "0.69072443", "0.68716997", "0.68430203", "0.68395007", "0.6838574", "0.6766557", "0.67637473", "0.67574936", "0.6714652", "0.67113924", "0.6...
0.0
-1
Transforms input one last time before API call. Will be called on input for all search_methods using this adapter. For search_methodspecific transformations, use the format_input method in your search_method.
def format(input) input end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def processed_input!\n unknown_handling :process\n not_researched_handling :process\n self\n end", "def preprocess_input(input)\nend", "def normalize search\n if search.is_a? Search\n search\n else\n Search.new :query => search\n end\n end", "def ...
[ "0.59613824", "0.5812981", "0.5633147", "0.56253374", "0.5612083", "0.5609917", "0.556805", "0.55662936", "0.5435163", "0.54321116", "0.543156", "0.5413476", "0.5362796", "0.5355979", "0.5345927", "0.53124607", "0.5287423", "0.5221086", "0.5173668", "0.51716", "0.5170374", ...
0.4850696
46
Incapsulate internal option information, mainly used to store option specific configuration data, most of the meat of this class is found in the value method. slop The instance of Slop tied to this Option. short The String or Symbol short flag. long The String or Symbol long flag. description The String description text. config A Hash of configuration options. block An optional block used as a callback.
def initialize(slop, short, long, description, config = {}, &block) @slop = slop @short = short @long = long @description = description @config = DEFAULT_OPTIONS.merge(config) @count = 0 @callback = block_given? ? block : config[:callback] @value = nil @types = { :string => proc { |v| v.to_s }, :symbol => proc { |v| v.to_sym }, :integer => proc { |v| value_to_integer(v) }, :float => proc { |v| value_to_float(v) }, :range => proc { |v| value_to_range(v) }, :regexp => proc { |v| Regexp.new(v) }, :count => proc { |v| @count } } if long && long.size > @slop.config[:longest_flag] @slop.config[:longest_flag] = long.size end @config.each_key do |key| predicate = :"#{key}?" unless self.class.method_defined? predicate self.class.__send__(:define_method, predicate) { !!@config[key] } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inspect\n \"#<Slop::Option [-#{short} | --#{long}\" +\n \"#{'=' if expects_argument?}#{'=?' if accepts_optional_argument?}]\" +\n \" (#{description}) #{config.inspect}\"\n end", "def option(name, short, long, desc, default = nil, &block)\n desc = desc + \" (default: #{default})\" if defa...
[ "0.73821783", "0.6935406", "0.6801366", "0.64054304", "0.6404614", "0.6347412", "0.632679", "0.63174385", "0.62681574", "0.62464875", "0.62438416", "0.6238746", "0.62291694", "0.61811966", "0.61335146", "0.61059624", "0.60704416", "0.6049459", "0.6044704", "0.6040065", "0.603...
0.7358785
1
Returns true if this option expects an argument.
def expects_argument? config[:argument] && config[:argument] != :optional end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expects_argument?\n true\n end", "def has_option?(arg)\n !!find_option(arg)\n end", "def arguments_valid?\n ret = false\n ret = true unless (@options.action == nil)\n end", "def argument_required?\n !short.to_s.match(SHORT_ARGUMENT_REQUIRED_RE).nil? ||\n !...
[ "0.815382", "0.7400651", "0.7358677", "0.7298264", "0.72874177", "0.72125876", "0.7187095", "0.7066249", "0.70649135", "0.7042134", "0.7042134", "0.7042134", "0.70254385", "0.70254385", "0.7019636", "0.70097834", "0.6978008", "0.69713587", "0.6952521", "0.69513714", "0.694141...
0.84725225
0
Returns true if this option accepts an optional argument.
def accepts_optional_argument? config[:optional_argument] || config[:argument] == :optional end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optional?\n !!options[:optional]\n end", "def argument_optional?\n !short.to_s.match(SHORT_ARGUMENT_OPTIONAL_RE).nil? ||\n !long.to_s.match(LONG_ARGUMENT_OPTIONAL_RE).nil?\n end", "def has_option?(arg)\n !!find_option(arg)\n end", "def option?(param)\n para...
[ "0.8099959", "0.77925897", "0.7786213", "0.74916387", "0.73086095", "0.7157834", "0.7056165", "0.70465446", "0.6981133", "0.69693667", "0.69664896", "0.69500273", "0.69268465", "0.6858912", "0.6835114", "0.6835114", "0.68179035", "0.68123925", "0.68120635", "0.67836833", "0.6...
0.8634949
0
Returns the String flag of this option. Preferring the long flag.
def key long || short end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def long_for_optparse\n (arg and not(long.nil?)) ? (\"%s %s\" % [long, arg]) : long\n end", "def test_stringflag_as_string\n @p.opt :xyz, \"desc\", :type => :stringflag\n @p.opt :abc, \"desc\", :type => :flag\n opts = @p.parse %w(--xyz abcd)\n assert_equal true, opts[:xyz_given]\n ...
[ "0.66871476", "0.635277", "0.6303171", "0.6291905", "0.62404186", "0.62013173", "0.6200951", "0.6120641", "0.6120023", "0.6020478", "0.5916484", "0.59109044", "0.5909008", "0.5898241", "0.58919346", "0.58374023", "0.5814298", "0.5808295", "0.56898516", "0.5688456", "0.5665265...
0.0
-1
Call this options callback if one exists, and it responds to call(). Returns nothing.
def call(*objects) @callback.call(*objects) if @callback.respond_to?(:call) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(_value)\n fail NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end", "def call(_value)\n raise NotImplementedError,\n \"you must override the `call' method for option #{self.class}\"\n end", "def call_options=(value)\n ...
[ "0.72449553", "0.7199742", "0.70488256", "0.678104", "0.6653813", "0.6480733", "0.6405001", "0.635398", "0.63014877", "0.61865294", "0.6149083", "0.6120024", "0.6094306", "0.60737836", "0.6051778", "0.60258806", "0.60156316", "0.60154057", "0.60021406", "0.5979981", "0.597566...
0.0
-1
Set the new argument value for this option. We use this setter method to handle concatenating lists. That is, when an array type is specified and used more than once, values from both options will be grouped together and flattened into a single array.
def value=(new_value) if config[:as].to_s.downcase == 'array' @value ||= [] if new_value.respond_to?(:split) @value.concat new_value.split(config[:delimiter], config[:limit]) end else @value = new_value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def <<(arg)\r\n if arg.is_a?(Array)\r\n @opts += arg\r\n else\r\n @opts << arg\r\n end\r\n self\r\n end", "def set_option(value)\r\n\t\tif value.is_a? Array\r\n\t\t\tvalue.each do |cur_value|\r\n\t\t\t\to_v = OptionValue.find(cur_value)\r\n\t\t\t\tself.line_item_option_values...
[ "0.6393711", "0.6210131", "0.6171569", "0.61513245", "0.6061137", "0.60461587", "0.6029686", "0.595405", "0.5834191", "0.5757202", "0.5694754", "0.5669367", "0.5661604", "0.5592485", "0.5563983", "0.5379566", "0.5353615", "0.53354126", "0.532834", "0.53201556", "0.529878", ...
0.6109828
4
Fetch the argument value for this option. Returns the Object once any type conversions have taken place.
def value value = @value.nil? ? config[:default] : @value if [true, false, nil].include?(value) && config[:as].to_s != 'count' return value end type = config[:as] if type.respond_to?(:call) type.call(value) else if callable = types[type.to_s.downcase.to_sym] callable.call(value) else value end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_raw_value_for_argument(arg=nil)\n if arg.class == Hash && !block_given?\n return @j_del.java_method(:getRawValueForArgument, [Java::IoVertxCoreCli::Argument.java_class]).call(Java::IoVertxCoreCli::Argument.new(::Vertx::Util::Utils.to_json_object(arg)))\n end\n raise ArgumentError, \"I...
[ "0.641058", "0.62255895", "0.6186157", "0.61377984", "0.6043146", "0.60007113", "0.59658957", "0.5952338", "0.59479225", "0.5856225", "0.58560866", "0.58012325", "0.5789928", "0.5742832", "0.57234484", "0.5685781", "0.5683691", "0.567404", "0.5651824", "0.56436825", "0.564278...
0.554948
29
Returns the help String for this option.
def to_s return config[:help] if config[:help].respond_to?(:to_str) out = " #{short ? "-#{short}, " : ' ' * 4}" if long out << "--#{long}" size = long.size diff = @slop.config[:longest_flag] - size out << (' ' * (diff + 6)) else out << (' ' * (@slop.config[:longest_flag] + 8)) end "#{out}#{description}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def help_string()\n str = \"The follow options are to be given as environment variables or commandline arguments:\\n\"\n @required_env_vars.each do |v|\n str += \" #{v}=VALUE\\n\"\n end\n @optional_env_vars.each do |v|\n str += \" [OPTIONAL] #{v}=VALUE\\n\"\n end\n str += \"\\nThe Y...
[ "0.7685743", "0.7600661", "0.7526248", "0.75048137", "0.74192625", "0.7290113", "0.728622", "0.7267909", "0.72543466", "0.718445", "0.71308017", "0.7124863", "0.71144325", "0.7113658", "0.70755035", "0.70123035", "0.7003801", "0.7003801", "0.70028704", "0.69889235", "0.698376...
0.70590204
15
Returns the String inspection text.
def inspect "#<Slop::Option [-#{short} | --#{long}" + "#{'=' if expects_argument?}#{'=?' if accepts_optional_argument?}]" + " (#{description}) #{config.inspect}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n text\n end", "def to_s\n text\n end", "def to_s\n return @text\n end", "def to_s\n text\n end", "def to_s\n @text\n end", "def to_s\n text.to_s\n end", "def exp_text\n @exp.to_s\n end", "def to_s\n @text\n end", ...
[ "0.64682657", "0.64682657", "0.64166504", "0.6405088", "0.63259804", "0.6320951", "0.6310292", "0.6269694", "0.6269694", "0.62570614", "0.62441427", "0.623013", "0.62118024", "0.62026554", "0.62026554", "0.61983114", "0.61867285", "0.61672026", "0.6165723", "0.6165723", "0.61...
0.0
-1
Convert an object to an Integer if possible. value The Object we want to convert to an integer. Returns the Integer value if possible to convert, else a zero.
def value_to_integer(value) if @slop.strict? begin Integer(value.to_s, 10) rescue ArgumentError raise InvalidArgumentError, "#{value} could not be coerced into Integer" end else value.to_s.to_i end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value_to_integer(value)\n case value\n when TrueClass, FalseClass\n value ? 1 : 0\n else\n value.blank? ? nil : value.to_i rescue nil\n end\n end", "def typecast_value_integer(value)\n value.to_i\n end", "def typecast_value_integer(value)\n ...
[ "0.7516344", "0.72826254", "0.72249365", "0.71980333", "0.7129018", "0.7051218", "0.7051218", "0.69346124", "0.6921653", "0.6860812", "0.6784545", "0.6784545", "0.6784545", "0.6784545", "0.67501765", "0.6735388", "0.6663527", "0.66488916", "0.6559779", "0.6299139", "0.6296176...
0.6801429
10
Convert an object to a Float if possible. value The Object we want to convert to a float. Returns the Float value if possible to convert, else a zero.
def value_to_float(value) if @slop.strict? begin Float(value.to_s) rescue ArgumentError raise InvalidArgumentError, "#{value} could not be coerced into Float" end else value.to_s.to_f end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def coerce_float(value, _options = {})\n Float(value) rescue nil\n end", "def coerce_float(value, options = {})\n Float(value) rescue nil\n end", "def coerce_float(value, options = {})\n Float(value) rescue nil\n end", "def typecast_value_float(value)\n Float(value)\n end", ...
[ "0.7660923", "0.7645218", "0.7645218", "0.7622633", "0.74854386", "0.7412537", "0.7235834", "0.71421164", "0.694935", "0.6886163", "0.68637866", "0.6856613", "0.66426396", "0.6509349", "0.64117897", "0.6410814", "0.63727087", "0.63131994", "0.6276192", "0.62605906", "0.625207...
0.7188214
7
Convert an object to a Range if possible. value The Object we want to convert to a range. Returns the Range value if one could be found, else the original object.
def value_to_range(value) case value.to_s when /\A(\-?\d+)\z/ Range.new($1.to_i, $1.to_i) when /\A(-?\d+?)(\.\.\.?|-|,)(-?\d+)\z/ Range.new($1.to_i, $3.to_i, $2 == '...') else if @slop.strict? raise InvalidArgumentError, "#{value} could not be coerced into Range" else value end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_range\n case\n when open?, unknown?\n nil\n else\n Range.new(unknown_start? ? Date.new : @from, max)\n end\n end", "def parse_range_value(value)\r\n value << nil if value.kind_of?(Array) && value.length == 1\r\n value = [value, nil] if (value.kind_of?(String)...
[ "0.59370136", "0.5914834", "0.5776145", "0.5735018", "0.57116187", "0.56726044", "0.5645548", "0.55775434", "0.54783434", "0.54593927", "0.5392443", "0.5377554", "0.5363562", "0.5334151", "0.5327587", "0.52788085", "0.52541167", "0.5227817", "0.5189326", "0.517939", "0.517096...
0.6801699
0
Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab", Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut.
def min_cut(s) palindrome = Array.new(s.size + 1).map { |x| Array.new(s.size + 1).map { |y| false } } dp = [] 0.upto(s.size) { |i| dp[i] = i - 1 } 2.upto(s.size).each { |i| (i - 1).downto(0).each { |j| if s[i - 1] == s[j] && ( i - 1 - j < 2 || palindrome[j + 1, i - 1]) palindrome[j][i] = true dp[i] = [dp[i], dp[j] + 1].min end } } return dp[s.size] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def partition(s)\n palindrome = Array.new(s.size) {\n Array.new(s.size)\n }\n \n cuts = [[]]\n \n (0...s.size).each { |i|\n (0..i).each { |j|\n palindrome[j][i] = if i == j\n true\n elsif i == j + 1\n ...
[ "0.757859", "0.7022382", "0.6562834", "0.6295299", "0.62747926", "0.62489986", "0.61538434", "0.61378384", "0.6127826", "0.61099476", "0.61049306", "0.6097427", "0.60894924", "0.607885", "0.6070483", "0.60479265", "0.6040002", "0.6020969", "0.60123783", "0.6008312", "0.600052...
0.83805674
0
calls predicted deaths and speed of spread methods from below
def virus_effects predicted_deaths(self) speed_of_spread(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def virus_effects\n speed_of_spread(predicted_deaths()) \n\n end", "def virus_effects #looks DRY but not using the full scope of the variables \r\n predicted_deaths\r\n speed_of_spread\r\n end", "def virus_effects \n predicted_deaths(@population_density, @population, @state)\n speed_of_spread...
[ "0.6877583", "0.6798683", "0.67180866", "0.66168237", "0.6581443", "0.6539198", "0.6530316", "0.6473437", "0.64492905", "0.639995", "0.6394241", "0.6389315", "0.6389315", "0.6385812", "0.6381701", "0.6354181", "0.6343001", "0.6328419", "0.6323763", "0.630848", "0.6302198", ...
0.60591626
65
If you moved this keyword about virus_effects, you would not be able to call any method in the entire class from driver code outside the class (other than the initialize method that is invoked during object creation). You would only want to use this method when you want to prohibit calling the method from outside the class. They are basically methods that the calling program does not need to know anything about. Gives us a hard value of the number of deaths that will occur in a given state
def predicted_deaths(this) # predicted deaths is solely based on population density case @population_density when 200.. number_of_deaths = (@population * 0.4).floor when 150..200 number_of_deaths = (@population * 0.3).floor when 100..150 number_of_deaths = (@population * 0.2).floor when 50..100 number_of_deaths = (@population * 0.1).floor when 0..50 number_of_deaths = (@population * 0.05).floor end print "#{@state} will lose #{number_of_deaths} people in this outbreak" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def virus_effects #HINT: What is the SCOPE of instance variables? Instance variables are available to all methods of the instance. There is no need to pass the instance variables into the instance methods.\n\n predicted_deaths()\n speed_of_spread()\n end", "def virus_effects #HINT: What is the SCOPE of...
[ "0.7461806", "0.6955893", "0.68925744", "0.68925744", "0.68925744", "0.6880787", "0.677679", "0.6768114", "0.67363393", "0.6735252", "0.6731398", "0.67215747", "0.67215747", "0.67215747", "0.6673979", "0.6654738", "0.6602867", "0.6591326", "0.6591326", "0.6576877", "0.6567268...
0.0
-1
uses population density to find how fast the virus will spread in a given state.
def speed_of_spread(this) #in months # We are still perfecting our formula here. The speed is also affected # by additional factors we haven't added into this functionality. speed = 0.0 case @population_density when 200.. speed += 0.5 when 150..200 speed += 1 when 100..150 speed += 1.5 when 50..100 speed += 2 when 0..50 speed += 2.5 end puts " and will spread across the state in #{speed} months.\n\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n elsif @population_density >= 150\r\...
[ "0.74307096", "0.72917277", "0.72740394", "0.72014225", "0.7200535", "0.7146113", "0.71353495", "0.71353495", "0.71353495", "0.71353495", "0.7131055", "0.7113184", "0.7100646", "0.70955753", "0.7079691", "0.7066149", "0.7066149", "0.7066149", "0.7066149", "0.70578605", "0.704...
0.6524688
99
Queue up a job to call `.reduce` on keys for `handle`
def perform(handle, implementation) Bramble::State.running?(handle) do # Set how many reduce call we expect all_raw_keys = storage.map_keys_get(keys_key(handle)) storage.set(reduce_total_count_key(handle), all_raw_keys.length) # Enqueue a job for each reduce call all_raw_keys.each do |raw_key| Bramble::ReduceJob.perform_later(handle, implementation.name, raw_key) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_reduce(handle, implementation, raw_key)\n if Bramble::State.running?(handle)\n raw_values = storage.map_result_get(data_key(handle, raw_key))\n values = Bramble::Serialize.load(raw_values)\n key = Bramble::Serialize.load(raw_key)\n reduced_value = nil\n\n Bramble...
[ "0.6278902", "0.5260997", "0.51157814", "0.5110429", "0.5073991", "0.503201", "0.502923", "0.50201064", "0.50201064", "0.49699134", "0.4906718", "0.4896511", "0.4856344", "0.4808672", "0.47960958", "0.4778607", "0.4759038", "0.47557056", "0.47381786", "0.473655", "0.46919587"...
0.7016725
0
Perform `.reduce` on `raw_key`, handling errors and saving the result
def perform_reduce(handle, implementation, raw_key) if Bramble::State.running?(handle) raw_values = storage.map_result_get(data_key(handle, raw_key)) values = Bramble::Serialize.load(raw_values) key = Bramble::Serialize.load(raw_key) reduced_value = nil Bramble::ErrorHandling.rescuing(implementation) do # Run the defined .reduce function reduced_value = implementation.reduce(key, values) # Store the result Bramble::State.running?(handle) do storage.reduce_result_set(result_key(handle), raw_key, Bramble::Serialize.dump(reduced_value)) end end # Mark this key as reduced, check if we're finished Bramble::State.running?(handle) do storage.increment(reduce_finished_count_key(handle)) if Bramble::State.percent_reduced(handle) >= 1 storage.set(finished_at_key(handle), Time.now.to_i) end end else Bramble::State.clear_reduce(handle) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _reduce_379(val, _values, result); end", "def reduce_function\n 'function (key, values) { return reduce(key, values);};'\n end", "def _reduce_391(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_391(val, _values, result)\n ...
[ "0.53665537", "0.53629094", "0.5289318", "0.5289318", "0.5196219", "0.5191559", "0.5191559", "0.5184798", "0.5159547", "0.51338434", "0.51338434", "0.51338434", "0.51338434", "0.5132777", "0.5125154", "0.51174927", "0.51174927", "0.5116494", "0.509979", "0.509979", "0.5097824...
0.6516185
0
rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity
def type if validator_hash[:numericality] == true || validator_hash[:numericality] == { allow_nil: true } 'Decimal' elsif validator_hash.dig(:numericality, :only_integer) 'Integer' elsif validator_hash[:ingested_date] 'Date' elsif validator_hash.dig(:case_insensitive_inclusion, :in) == %w[Y N] 'YesNo' elsif inclusion_list_with_lookup_values?(validator_hash.dig(:case_insensitive_inclusion, :in)) attr.name.tr(' ', '') else 'String' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def strategy; end", "def schubert; end", "def refutal()\n end", "def used?; end", "def offences_by; end", "def isola...
[ "0.7540561", "0.6259775", "0.6259775", "0.61758363", "0.60206604", "0.60206604", "0.60206604", "0.60206604", "0.60124767", "0.6003864", "0.60011727", "0.58624804", "0.585165", "0.5821098", "0.5821098", "0.5774673", "0.5774673", "0.57745266", "0.57745266", "0.57745266", "0.577...
0.0
-1
rubocop:enable Metrics/PerceivedComplexity rubocop:enable Metrics/CyclomaticComplexity
def lhs if known? @klass.export_mappings.key(attr.name) elsif additional? "#{type} #{@klass.export_mappings.key(attr.name)}" else type end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def implementation; end", "def implementation; end", "def probers; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def refutal()\n end", "def strategy; end", "def used?; end", "def operations; end", "def operat...
[ "0.7586421", "0.63274026", "0.63274026", "0.6273931", "0.61012506", "0.6088008", "0.6088008", "0.6088008", "0.6088008", "0.6035053", "0.60319775", "0.59403867", "0.586957", "0.586957", "0.5868608", "0.5864063", "0.5847177", "0.5847177", "0.5845981", "0.5839414", "0.5839414", ...
0.0
-1
/CONSTANTS GOAL: THE GOAL HERE IS TO KEEP DATA AWAY FROM THE API METHOD
def pack_box # @packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS) @packages = ActiveShipping::Package.new((WEIGHT * 16), DIMENSIONS, UNITS) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_data\n @api_data ||= {\n address: @ethereum_address,\n phase: 0,\n client_whitelist_detail_obj: get_client_whitelist_detail_obj\n }\n end", "def get_data()\t\n\tend", "def data\n retrieve_data\n end", "def data; @data ||= fetch; end", "def call_api\n @client.build...
[ "0.6724695", "0.6666964", "0.65561074", "0.65017223", "0.65011054", "0.64345956", "0.6434113", "0.6243197", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", "0.62295866", ...
0.0
-1
The main installation script
def install virtualenv_install_with_resources #system "pip3", "install", "." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install\n end", "def install\n end", "def install\n end", "def prepare_for_installation; end", "def install\n \n end", "def install\n #python executable files\n end", "def main\n generate_config unless $dont_gen_conf\n\n if $just_gen_conf\n puts \"\\nSkips installing, just generat...
[ "0.7886467", "0.7804689", "0.7804689", "0.77704585", "0.7736508", "0.7718833", "0.7678016", "0.76638037", "0.7621142", "0.74154276", "0.73596185", "0.72469884", "0.72175264", "0.7196859", "0.7149671", "0.7103089", "0.7093363", "0.7058893", "0.70350856", "0.7013218", "0.690176...
0.0
-1
Looks up or creates a Customer on your stripe account
def lookupOrCreateExampleCustomer customerEmail = "example@test.com" begin customerList = Stripe::Customer.list(email: customerEmail, limit: 1).data if (customerList.length == 1) return customerList[0] else return Stripe::Customer.create(email: customerEmail) end rescue Stripe::StripeError => e status 402 return log_info("Error creating or retreiving customer! #{e.message}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_stripe_customer!\n Stripe::Customer.create(\n email: user.email,\n description: store.name,\n source: stripe_source_id\n )\n end", "def create_or_get_stripe_customer(options = {})\n return as_stripe_customer if stripe_id?\n\n create_as_stripe_customer(option...
[ "0.8266742", "0.8265208", "0.80930835", "0.8068719", "0.7908001", "0.7897205", "0.78880477", "0.78228396", "0.7723199", "0.7710555", "0.77003956", "0.758674", "0.7426079", "0.74200964", "0.73987204", "0.7319991", "0.72986317", "0.7290853", "0.724008", "0.724008", "0.723847", ...
0.7880268
7
def procedures(path) TODO TODO work with Flor.load_procedures end If found, returns [ source_path, path ]
def library(domain, name=nil) domain, name = split_dn(domain, name) path = (Dir[File.join(root, '**/*.{flo,flor}')]) .sort .sort_by(&:length) .select { |f| f.index('/lib/') } .select { |f| path_name_matches?(domain, name, f) } .first path ? [ Flor.relativize_path(path), File.read(path) ] : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_procedures\n connect_db.fetch(\"SELECT RDB$PROCEDURE_NAME, RDB$PROCEDURE_SOURCE FROM RDB$PROCEDURES\")\n end", "def file_and_line\n path, line = *@proc.inspect.match(PROC_PATTERN)[1..2]\n path = File.expand_path(path)\n pwd = File.expand_path(PWD)\n if path.index(...
[ "0.6327719", "0.602674", "0.53850967", "0.5347146", "0.5309015", "0.5243989", "0.52203053", "0.51995456", "0.5163558", "0.5163558", "0.51564634", "0.51564634", "0.5155371", "0.5153279", "0.51506096", "0.5146192", "0.5146192", "0.5146192", "0.5146192", "0.5146192", "0.51327145...
0.0
-1
get user's weight and height (in meter)
def bmi puts "Let's check your body mass".center(70) puts "-=" * 40 puts "[y] - begin BMI calculator" puts "[n] - quit" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bmi\n ( weight.to_f / ( (height.to_f)**2 ) ) * 703.0\n end", "def calculated_bmi\n user_profile = current_user.profile \n height = user_profile.height \n weight = user_profile.weight \n bmi = (weight / ((height / 100) ** 2))\n end", "def calculate_bmi weight, height\n ...
[ "0.7648784", "0.75964946", "0.75207025", "0.7356583", "0.7354583", "0.7316398", "0.73044163", "0.72896826", "0.693208", "0.68926007", "0.67565495", "0.6686951", "0.6641628", "0.65261257", "0.6516807", "0.6502468", "0.6502468", "0.65018773", "0.6492123", "0.6482159", "0.646084...
0.0
-1
BMI calculation function // not showing
def bmi_formula (kg, m) result = kg / (m ** 2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculated_bmi\n user_profile = current_user.profile \n height = user_profile.height \n weight = user_profile.weight \n bmi = (weight / ((height / 100) ** 2))\n end", "def bmi\n ( weight.to_f / ( (height.to_f)**2 ) ) * 703.0\n end", "def calculate_bmi(height,weight)\n ...
[ "0.8309173", "0.81913793", "0.8158111", "0.8132423", "0.81250626", "0.80853754", "0.80404603", "0.7788806", "0.77698743", "0.7644778", "0.7626373", "0.7584574", "0.7488257", "0.74627155", "0.73617333", "0.7268319", "0.7236469", "0.7188025", "0.71678036", "0.71539754", "0.6965...
0.74444795
14
Register usage of lexical variable
def add_lvar_access(identifier) if @lexical_var_names.include?(identifier) @lexical_variables.add(identifier) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_variable variable\n @variables ||= {}\n @variables[variable.name] = variable\n end", "def var *args\n TheDude::Variable.new(*args).register\n end", "def createRegister symbol\n s(:send, nil, :register,\n s(:sym, symbol),\n s(:lvar, symbol)\n )\n end"...
[ "0.6960505", "0.67519134", "0.6540689", "0.6540689", "0.626034", "0.62032074", "0.62032074", "0.62032074", "0.60960114", "0.6067597", "0.6045962", "0.6045962", "0.6045962", "0.59529185", "0.59529185", "0.5885527", "0.5876775", "0.5823084", "0.5823084", "0.5808844", "0.5798213...
0.60158527
13
GET /assets GET /assets.json
def index if params[:search] @assets = Asset.find_with_index(params[:search]) @title = "Search: #{params[:search]} (#{@assets.count})" else @assets = Asset.includes(:user, :scene).where(:assets_scenes => { :scene_id => nil }).where('asset_type != ?', 'animatic').order('assets.created_at DESC').page(params[:page]).per(params[:number]) # @assets = Asset.joins('LEFT OUTER JOIN "assets_scenes" ON "assets_scenes"."asset_id" = "assets"."id" LEFT OUTER JOIN "scenes" ON "scenes"."id" = "assets_scenes"."scene_id"').includes(:versions, :episode, :scene, :taggings).where(:assets_scenes => { :scene_id => nil }).where('asset_type != ?', 'animatic').order('created_at DESC').page(params[:page]).per(params[:number]) @pager = true @title = "All Assets (#{Asset.count})" end # per_page = 20 # @assets = Asset.limit(per_page).offset(params[:page] ? params[:page].to_i * per_page : 0) respond_to do |format| format.html # index.html.erb format.json { render json: @assets } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_assets\n get('/video/v1/assets')\n end", "def index\n\t\t@assets = Asset.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @assets }\n\t\tend\n\tend", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |...
[ "0.7551416", "0.75446445", "0.7363419", "0.7361636", "0.7324648", "0.7280881", "0.72793496", "0.7116608", "0.70093375", "0.69739133", "0.69455814", "0.69455814", "0.69455814", "0.69455814", "0.69455814", "0.6937285", "0.6893164", "0.6893164", "0.68895555", "0.68548894", "0.67...
0.5996531
96
GET /assets/1 GET /assets/1.json
def show @asset = Asset.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @asset } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def asset(id, params = {})\n get \"assets/#{id}\", {query: params}\n end", "def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\n end\n end", "def show\n @asset = ...
[ "0.7564326", "0.755969", "0.7391883", "0.73493266", "0.72864586", "0.7193312", "0.7117282", "0.70314026", "0.70302755", "0.70222485", "0.70035976", "0.6947735", "0.69283456", "0.6886361", "0.68494326", "0.6805927", "0.6805927", "0.67897666", "0.67567056", "0.67270285", "0.669...
0.72254884
9
GET /assets/new GET /assets/new.json
def new @asset = Asset.new @title = 'New Asset' respond_to do |format| format.html # new.html.erb format.json { render json: @asset } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n repo = assets_repo\n @v_asset = repo.new\n\n respond_to do |format|\n format.html new.html.erb\n format.json { render json: @v_asset }\n end\n end", "def new\n @asset = Asset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: ...
[ "0.80105716", "0.79801935", "0.79801935", "0.7888442", "0.7581416", "0.75565296", "0.75331193", "0.7525611", "0.7452888", "0.7346667", "0.73428935", "0.7326248", "0.7151477", "0.71323776", "0.71323776", "0.709953", "0.6998511", "0.6949301", "0.6934552", "0.6923812", "0.691982...
0.7861013
4
POST /assets POST /assets.json
def create @asset = Asset.new(params[:asset]) @asset.parse_meta if @asset.id? && Asset.exists?(@asset.id) @asset = Asset.find(@asset.id) @asset.user_id = nil @asset.submitted = true @asset.revision = false @asset.approved = false @asset.checked_out = false success = @asset.update_attributes(params[:asset]) else success = @asset.save end respond_to do |format| if success format.html { redirect_to @asset, notice: 'Asset was successfully created.' } format.json { render json: @asset, status: :created, location: @asset } else format.html { render action: "new" } format.json { render json: @asset.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add\n @asset = Asset.create!(asset_param)\n json_response(@asset, :created)\n end", "def create\n @asset = Asset.new(params[:asset])\n\n respond_to do |format|\n if @asset.save\n format.html { redirect_to assets_url, notice: 'Asset was successfully created.' }\n forma...
[ "0.6785361", "0.67662287", "0.6751027", "0.6710337", "0.66698694", "0.6639351", "0.6637279", "0.66082245", "0.65693337", "0.65518445", "0.6524463", "0.6506682", "0.65047514", "0.64792407", "0.6478554", "0.64650124", "0.6443495", "0.6401173", "0.63432854", "0.6306109", "0.6291...
0.6218353
24
PUT /assets/1 PUT /assets/1.json
def update @asset = Asset.find(params[:id]) respond_to do |format| if @asset.update_attributes(params[:asset]) format.html { redirect_to session.delete(:return_to) || request.referer || edit_asset_path(@asset), notice: 'Asset was successfully updated.' } format.json { render json: { asset: @asset, assigned_to: @asset.user_id ? User.find(@asset.user_id).name : nil } } else format.html { render action: "edit" } format.json { render json: @asset.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n find_asset\n @asset.update!(asset_params)\n\n render json: @asset, adapter: :json\n end", "def update\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n if @asset.update_attributes(params[:asset])\n format.html { redirect_to @asset, notice: 'Asset was...
[ "0.7083384", "0.6879702", "0.6879702", "0.6879702", "0.6761707", "0.67099196", "0.66577655", "0.66428435", "0.6623867", "0.6613277", "0.6599539", "0.6593902", "0.6567701", "0.65564317", "0.6553473", "0.6550015", "0.6536143", "0.6533886", "0.6533282", "0.65275127", "0.6496173"...
0.6323831
24
DELETE /assets/1 DELETE /assets/1.json
def destroy @asset = Asset.find(params[:id]) @asset.destroy respond_to do |format| format.html { redirect_to assets_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asset.destroy\n respond_to do |format|\n format.html { redirect_to assets_url }\n format.json { head :no_content }\n ...
[ "0.7579968", "0.7579968", "0.7579968", "0.7579968", "0.7579968", "0.74313027", "0.74123305", "0.7330137", "0.7314967", "0.7314967", "0.7314967", "0.72860706", "0.728522", "0.7264658", "0.7249606", "0.724224", "0.72383016", "0.71932286", "0.7183883", "0.71676016", "0.7163135",...
0.7603381
3
Returns the value of the markup attribute equivalent to the content attribute but with bold and italic markup
def markup unless @text.empty? line = fix_markup("#{@text.join("").strip}#{@last_tag_end}") @lines << line @text = [] end if @footer.join("").strip.empty? if @lines.last.empty? output = @lines[0..-2].join("\n") else output = @lines.join("\n") end else output = %Q|#{@lines.join("\n")}\n#{@footer.join("")}| end output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markup\n self.text.sub(/^(.*)$/,'<b>\\1</b>')\n end", "def markup\n if tag?\n @value.raw\n elsif @value.instance_variable_defined?(:@markup)\n @value.instance_variable_get(:@markup)\n end\n end", "def bold\n @info[:bold]\n end", "def help_value( text ...
[ "0.7296416", "0.70724016", "0.6839703", "0.6725262", "0.6417913", "0.63533103", "0.63247687", "0.6323885", "0.62630045", "0.62136114", "0.62136114", "0.61945975", "0.61945975", "0.6176724", "0.61608994", "0.6136246", "0.6098027", "0.6056704", "0.6016363", "0.59638196", "0.591...
0.0
-1
Returns the value of the content attribute
def content lines = super.lines.to_a fixed = [] current_line = 0 offset = 0 formatted_lines = markup.lines.to_a lines.each_with_index do |line, index| formatted_line = formatted_lines[index + offset] if line.strip == "" and (formatted_line and formatted_lines[index + offset].strip != "") offset -= 1 else fixed << line end end lines = fixed.join("") lines end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_content_attr(nodes)\n nodes.first.andand['content']\n end", "def value\n if self.namespace\n content_from 'ns:value', :ns => self.namespace.href\n else\n content_from :value\n end\n end", "def content(element_or_attribute)\n ...
[ "0.76946294", "0.71907485", "0.6926489", "0.6926489", "0.6833026", "0.6731639", "0.66863006", "0.66863006", "0.6675223", "0.66444325", "0.66444325", "0.66444325", "0.66444325", "0.66444325", "0.66444325", "0.6620091", "0.6620091", "0.65601003", "0.65601003", "0.65601003", "0....
0.0
-1
Return the quotient after dividing divident by divisor.
def divide_integers(dividend, divisor) return 1 if dividend == divisor quotient = 0 counter = divisor.abs until dividend.abs < counter quotient += 1 counter += divisor.abs end if dividend > 0 && divisor > 0 || dividend < 0 && divisor < 0 quotient else quotient * -1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def secure_div(divident, divisor)\n return nil if divisor == 0\n divident.to_f/divisor\n end", "def divide(dividend, divisor)\n negative_sign = (dividend < 0 && divisor >= 0) || (dividend >= 0 && divisor < 0)\n\n remaining = dividend.abs\n abs_divisor = divisor.abs\n quotient = 0\n while remaining >=...
[ "0.765988", "0.73819566", "0.726575", "0.7255464", "0.71354085", "0.7093396", "0.6976577", "0.69641167", "0.6936442", "0.69315845", "0.6856636", "0.68437713", "0.67094415", "0.666903", "0.6667955", "0.6647101", "0.6645193", "0.6603557", "0.65925664", "0.6581187", "0.6567914",...
0.6649643
15
def adjusted_capital result = 0.0
def adjusted_capital return 0.0 if @capital <= 0.0 return 0.0 if @interest_rate <= 0.0 || @duration <= 0.0 (@income/ @duration) * ADJ_FACTOR end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interest\n return (@capital / 100) * @rate\n end", "def converted_capital\n @investment.converted_capital + current_converted_interest\n end", "def annualy_insurance\n return @capital * @insurance * -1\n end", "def price_adjustment \n price_adjustment_fixed / 100.0 \n end", ...
[ "0.7238797", "0.71902394", "0.7102495", "0.6194234", "0.61899495", "0.61584663", "0.61199707", "0.6027775", "0.6021439", "0.6001982", "0.59158295", "0.59158295", "0.589282", "0.58856153", "0.5882897", "0.58803463", "0.58516264", "0.58439946", "0.5843392", "0.58333355", "0.582...
0.83664626
0
Encode the response wrapper to return to the client
def encoded_response logger.debug { sign_message("Encoding response: #{response.inspect}") } env.encoded_response = wrapped_response.encode rescue => exception log_exception(exception) # Rescue encoding exceptions, re-wrap them as generic protobuf errors, # and re-raise them raise PbError, exception.message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wrap_response(response)\n\t\t\t\tString === response ? {\"body\" => response} : response\n\t\t\tend", "def encode_body\n body = response.body\n chosen_charset = metadata['Charset']\n chosen_encoding = metadata['Content-Encoding']\n charsetter = resource.charsets_provided && resour...
[ "0.6893614", "0.6600332", "0.6593233", "0.6593233", "0.6441301", "0.64316237", "0.64161384", "0.640182", "0.640182", "0.6371233", "0.63487417", "0.6346483", "0.6332964", "0.6311115", "0.629941", "0.6296822", "0.6291847", "0.625872", "0.62332535", "0.6230749", "0.6222072", "...
0.6927627
0
Prod the object to see if we can produce a proto object as a response candidate. Validate the candidate protos.
def response return @response unless @response.nil? candidate = env.response return @response = validate!(candidate) if candidate.is_a?(Message) return @response = validate!(candidate.to_proto) if candidate.respond_to?(:to_proto) return @response = env.response_type.new(candidate.to_hash) if candidate.respond_to?(:to_hash) return @response = candidate if candidate.is_a?(PbError) @response = validate!(candidate) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate!(candidate)\n if candidate.class != env.response_type\n fail BadResponseProto, \"Expected response to be of type #{env.response_type.name} but was #{candidate.class.name}\"\n end\n\n candidate\n end", "def can_fit(obj)\n# $logger.info \"can_fit: #{...
[ "0.5462472", "0.5315664", "0.49850458", "0.47970745", "0.47501078", "0.46684253", "0.4662701", "0.4653992", "0.46361202", "0.46304417", "0.4629866", "0.46143287", "0.46020347", "0.4580239", "0.45637745", "0.45389232", "0.4533185", "0.45290565", "0.45251903", "0.45224926", "0....
0.47686434
4
Ensure that the response candidate we've been given is of the type we expect so that deserialization on the client side works.
def validate!(candidate) if candidate.class != env.response_type fail BadResponseProto, "Expected response to be of type #{env.response_type.name} but was #{candidate.class.name}" end candidate end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fixup_response_content_type( response )\n\n\t\t# Make the error for returning something other than a Response object a little\n\t\t# nicer.\n\t\tunless response.respond_to?( :content_type )\n\t\t\tself.log.error \"expected response (%p, a %p) to respond to #content_type\" %\n\t\t\t\t[ response, response.class ...
[ "0.6120421", "0.5898316", "0.58512515", "0.58404547", "0.5838752", "0.58046204", "0.57963735", "0.5780922", "0.56771135", "0.56555974", "0.56124794", "0.55961806", "0.55961806", "0.55961806", "0.55632436", "0.5521663", "0.55208117", "0.54928714", "0.54823685", "0.54500574", "...
0.7331544
0
The middleware stack returns either an error or response proto. Package it up so that it's in the correct spot in the response wrapper
def wrapped_response if response.is_a?(::Protobuf::Rpc::PbError) ::Protobuf::Socketrpc::Response.new(:error => response.message, :error_reason => response.error_type, :server => env.server) else ::Protobuf::Socketrpc::Response.new(:response_proto => response.encode, :server => env.server) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def middleware; end", "def call env\n return @app.call(env) unless should_handle?(env)\n\n # Wrap request and response\n env['rack.input'].rewind\n env['rails3amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)\n env['rails3amf.response'] = RocketAMF::Env...
[ "0.6152303", "0.60548025", "0.6026653", "0.5955913", "0.59293795", "0.59293795", "0.5915381", "0.58082306", "0.5798255", "0.5759519", "0.5757905", "0.57516795", "0.57344276", "0.5715803", "0.5709813", "0.56964374", "0.56936324", "0.5682639", "0.5660126", "0.5643334", "0.56316...
0.5907536
7
Returns the next date for the passed day. === Attributes day+ The day to set the date too.
def next_available_date(day) date = Date.today.change(day: day) date += 1.month if Time.now.day >= day date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_day\r\n if @next_day.nil?\r\n @next_day = convert_day_to_date(current_day).tomorrow.strftime('%Y%m%d')\r\n end\r\n @next_day\r\n end", "def next_day(date)\n date + (60 * 60 * 24)\n end", "def date_of_next(day)\n date = Date.parse(day)\n delta = date > Date...
[ "0.83474225", "0.8309688", "0.82345164", "0.8194028", "0.81827265", "0.8062129", "0.79713565", "0.7925333", "0.7832786", "0.7626622", "0.76197636", "0.7538015", "0.73688793", "0.7163175", "0.7160034", "0.71295744", "0.70869505", "0.7046332", "0.6977848", "0.6904563", "0.68449...
0.72641504
13
Write a method that returns a list of all substrings of a string that start at the beginning of the original string. The return value should be arranged in order from shortest to longest substring.
def leading_substrings(str) running_str = '' sub_strings = [] str.each_char { |chr| sub_strings << running_str += chr } sub_strings end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def substrings_at_start(string)\n string.size <= 1 ? [string] : [substrings_at_start(string.chop), string].flatten\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |substring|\n result << string.slice(0, substring)\n end\n result\nend", "def substrings_at_start(string)\n ...
[ "0.8325496", "0.8154765", "0.8154765", "0.8121116", "0.8113466", "0.8098688", "0.80885327", "0.80885327", "0.80857354", "0.8056578", "0.8056578", "0.80452406", "0.8028997", "0.80259115", "0.80193686", "0.80193686", "0.8013796", "0.8005799", "0.7999885", "0.7994656", "0.799353...
0.0
-1
Tags an article with the given tag, creating it if it does not already exist. +tag+:: A tag to associate to this article.
def add_tag(tag) t = Tagging.new() t.translation = self t.tag = tag begin self.taggings << t rescue # Already tagged false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_tag!(tag)\r\n tag = add_tag(tag)\r\n tag.save\r\n end", "def add_tag(tag)\r\n self.tags.new(:name => tag.name)\r\n end", "def create(tag)\n validate_type!(tag)\n\n attributes = sanitize(tag)\n _, _, root = @client.post(\"/tags\", attributes)\n\n Tag.ne...
[ "0.7105606", "0.6824836", "0.6691246", "0.66778237", "0.65557486", "0.6541293", "0.65292233", "0.65283525", "0.6487917", "0.6404491", "0.62503576", "0.6142314", "0.61393726", "0.6041199", "0.5991361", "0.59657115", "0.59657115", "0.59657115", "0.59657115", "0.59657115", "0.59...
0.68521917
1
parse_FAMI params: fami obj returns: Family object
def parse_FAMI(fami) family = nil @families.each do |fam| family = fam if fam.id == fami['id'] end if family.nil? family = Family.new family.id = fami['id'] @families.push(family) end data = fami['data'] family.house_number = Utils::hex_to_int(data[12..15], Utils::LITTLE_ENDIAN) family.cash = Utils::hex_to_int(data[20..23], Utils::LITTLE_ENDIAN) return family end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_fam\n layer_regexp = %r{%fam/[^/]*/}\n return self unless match?(layer_regexp)\n\n while match?(layer_regexp)\n original = match(layer_regexp)[0]\n icons = scan_layer_icons(original)\n gsubs!(original, FA::Layer.p(icons))\n end\n end", "def set_foaf\n @f...
[ "0.6395579", "0.5659122", "0.56583583", "0.56234646", "0.5575009", "0.55162895", "0.5457516", "0.54406804", "0.5413464", "0.5405111", "0.5405111", "0.5386716", "0.53709733", "0.5353778", "0.53333044", "0.5322311", "0.5322311", "0.53176296", "0.52670044", "0.52626485", "0.5261...
0.837269
0
dont think the first 24 bytes matter parse_NBRS params: nbrs obj returns: Array of neighbors
def parse_NBRS(nbrs) neighbors = [] data = nbrs['data'][24..-1] while !data.nil? && data.size > 0 do res = parse_neighbor(data) neighbors.push(res[0]) unless res[0].nil? data = res[1] end return neighbors end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def know_neighbors\n bomb_neighbors = 0\n neighbor_coords = []\n rel_neighbor_coords = [[0, 1], [1, 1], [-1, 0], [-1, 1], [1, 0], [1, -1], [0, -1], [-1, -1]]\n rel_neighbor_coords.each do | coord |\n neighbor_coords << [@coords[0] + coord[0], @coords[1] + coord[1]]\n end\n neighbor_coords.se...
[ "0.6136991", "0.58310646", "0.57239944", "0.5689455", "0.5619582", "0.56116074", "0.55726826", "0.55723554", "0.5533684", "0.5510668", "0.54993796", "0.54298943", "0.5415185", "0.53877074", "0.538184", "0.5363942", "0.5317723", "0.5313626", "0.5307439", "0.5294898", "0.525809...
0.86747515
0
parse_neighbor params: char from NBRS obj returns: Neighbor object, remaining string
def parse_neighbor(char) neighbor = Neighbor.new id = '' while !char.nil? && char.size > 0 && Utils::hex_to_int(char[0]) != 0 do id = id + char[0].to_s char = char[1..-1] end return [nil,''] if char.empty? neighbor.id = id if is_npc(id) neighbor.is_npc = true f_start = 0 ffs_in_a_row = 0 while ffs_in_a_row < 4 return [nil,''] if char[f_start + ffs_in_a_row].nil? if char[f_start + ffs_in_a_row].unpack('H*')[0] == 'ff' ffs_in_a_row = ffs_in_a_row + 1 else ffs_in_a_row = 0 f_start = f_start + 1 end end neighbor.relationship_id = char[(f_start - 6)..(f_start - 5)].unpack('H*')[0] neighbor.unknown_id = char[(f_start - 4)..(f_start - 1)].unpack('H*')[0] relationships, char = parse_relationships(char[(f_start + 4)..-1]) neighbor.relationships = relationships return [neighbor, char] end neighbor.is_npc = false personality = {} personality['nice'] = Utils::hex_to_int(char[13..14], Utils::LITTLE_ENDIAN) personality['active'] = Utils::hex_to_int(char[15..16], Utils::LITTLE_ENDIAN) personality['playful'] = Utils::hex_to_int(char[19..20], Utils::LITTLE_ENDIAN) personality['outgoing'] = Utils::hex_to_int(char[21..22], Utils::LITTLE_ENDIAN) personality['neat'] = Utils::hex_to_int(char[23..24], Utils::LITTLE_ENDIAN) neighbor.personality = personality skills = {} skills['cooking'] = Utils::hex_to_int(char[29..30], Utils::LITTLE_ENDIAN) skills['charisma'] = Utils::hex_to_int(char[31..32], Utils::LITTLE_ENDIAN) skills['mechanical'] = Utils::hex_to_int(char[33..34], Utils::LITTLE_ENDIAN) skills['creativity'] = Utils::hex_to_int(char[39..40], Utils::LITTLE_ENDIAN) skills['body'] = Utils::hex_to_int(char[43..44], Utils::LITTLE_ENDIAN) skills['logic'] = Utils::hex_to_int(char[45..46], Utils::LITTLE_ENDIAN) neighbor.skills = skills char = char[100..-1] #skip 100 bytes interests = {} interests['travel/toys'] = Utils::hex_to_int(char[1..2], Utils::LITTLE_ENDIAN) interests['violence/aliens'] = Utils::hex_to_int(char[3..4], Utils::LITTLE_ENDIAN) interests['politics/pets'] = Utils::hex_to_int(char[5..6], Utils::LITTLE_ENDIAN) interests['60s/school'] = Utils::hex_to_int(char[7..8], Utils::LITTLE_ENDIAN) interests['weather'] = Utils::hex_to_int(char[9..10], Utils::LITTLE_ENDIAN) interests['sports'] = Utils::hex_to_int(char[11..12], Utils::LITTLE_ENDIAN) interests['music'] = Utils::hex_to_int(char[13..14], Utils::LITTLE_ENDIAN) interests['outdoors'] = Utils::hex_to_int(char[15..16], Utils::LITTLE_ENDIAN) interests['technology'] = Utils::hex_to_int(char[17..18], Utils::LITTLE_ENDIAN) interests['romance'] = Utils::hex_to_int(char[19..20], Utils::LITTLE_ENDIAN) neighbor.interests = interests career = {} career['path'] = hex_to_career_path(char[21..22]) career['level'] = Utils::hex_to_int(char[23..24], Utils::LITTLE_ENDIAN) neighbor.career = career neighbor.age = Utils::hex_to_int(char[25..26], Utils::LITTLE_ENDIAN) neighbor.skin_tone = hex_to_skin_tone(char[29..30]) neighbor.gender = hex_to_gender(char[39..40]) f_start = 0 ffs_in_a_row = 0 while ffs_in_a_row < 4 if char[f_start + ffs_in_a_row].unpack('H*')[0] == 'ff' ffs_in_a_row = ffs_in_a_row + 1 else ffs_in_a_row = 0 f_start = f_start + 1 end end neighbor.relationship_id = char[(f_start - 6)..(f_start - 5)].unpack('H*')[0] neighbor.unknown_id = char[(f_start - 4)..(f_start - 1)].unpack('H*')[0] relationships, char = parse_relationships(char[(f_start + 4)..-1]) neighbor.relationships = relationships return [neighbor, char] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_NBRS(nbrs)\n\t\tneighbors = []\n\t\tdata = nbrs['data'][24..-1]\n\t\twhile !data.nil? && data.size > 0 do\n\t\t\tres = parse_neighbor(data)\n\t\t\tneighbors.push(res[0]) unless res[0].nil?\n\t\t\tdata = res[1]\n\t\tend\n\t\treturn neighbors\n\tend", "def parse_description(config, name)\n value =...
[ "0.60925156", "0.5423758", "0.53942496", "0.53104764", "0.5252241", "0.51077586", "0.5011245", "0.49477252", "0.49477252", "0.49277407", "0.48856008", "0.48245937", "0.47963604", "0.47931093", "0.4768224", "0.47532898", "0.47358856", "0.47126374", "0.47113723", "0.46859342", ...
0.7477034
0
is_npc params: string id returns: bool whether or not char is an npc
def is_npc(id) !id.start_with?('user') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pond? # Etang / Rivière etc...\n return $game_player.system_tag == TPond\n end", "def set_npc\n @npc = Npc.find(params[:id])\n end", "def set_npc\n @npc = Npc.find(params[:id])\n end", "def set_npc\n @npc = Npc.find(params[:id])\n end", "def creature_in_dir?(dir)\n px...
[ "0.56634825", "0.5618721", "0.5618721", "0.5618721", "0.5550694", "0.5541158", "0.55063087", "0.5447762", "0.5397278", "0.5386303", "0.53756136", "0.5355775", "0.53260076", "0.52950686", "0.5282946", "0.52736455", "0.5265509", "0.5242578", "0.52253646", "0.5221634", "0.520478...
0.7863091
0
called from compiled XPath expression
def ==(other) if other.is_a? XPathNodeSet or other.is_a? XPathBoolean or other.is_a? XPathNumber then other == self else to_str == other.to_str end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xpath; end", "def xpath; end", "def xpath(*args); end", "def xpath(*args); end", "def at_xpath(*args); end", "def at_xpath(*args); end", "def xpath_for(string, prefix, visitor); end", "def xpath(expression)\n document.xpath expression\n end", "def to_xpath(prefix, visitor); end", "def...
[ "0.77049714", "0.77049714", "0.7383023", "0.7383023", "0.73754805", "0.73754805", "0.66942114", "0.65562654", "0.6466453", "0.6405319", "0.63758266", "0.6368349", "0.62571037", "0.6076022", "0.60094446", "0.5991392", "0.5964706", "0.59572715", "0.5933769", "0.58895034", "0.58...
0.0
-1
def to_f def true?
def to_ruby true? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_f() end", "def to_f() end", "def to_f() end", "def to_f() end", "def to_f; end", "def to_f\n end", "def to_f\n end", "def to_f\n end", "def to_f_with_method\n to_x_with_method.to_f\n end", "def to_f\n (self.v || self.d).to_f\n end", "def to_f\n self.class.new(@val...
[ "0.9080219", "0.9080219", "0.9080219", "0.9080219", "0.8657793", "0.83348525", "0.83348525", "0.83348525", "0.8070299", "0.76468295", "0.7597658", "0.75087595", "0.742081", "0.742081", "0.742081", "0.742081", "0.7368721", "0.7342434", "0.7237657", "0.72146326", "0.71782446", ...
0.0
-1
have been shifted x number of times to the right (and loops around from Z>A if required)
def Caesar_cipher(input_string,input_shift) alphabet = ('a'..'z').to_a alphabetUpCase = ('A'..'Z').to_a input_string.each_char {|letter| if letter =~ /[A-Z]/ new_letter_index = alphabetUpCase.index(letter) + input_shift if new_letter_index > 25 new_letter_index -= 26 puts alphabetUpCase[new_letter_index] else puts alphabetUpCase[new_letter_index] end elsif letter =~ /[a-z]/ new_letter_index = alphabet.index(letter) + input_shift if new_letter_index > 25 new_letter_index -= 25 puts alphabet[new_letter_index] else puts alphabet[new_letter_index] end else puts letter end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_rotate(shift = 1)\n shift = shift % count\n drop(shift) + take(shift)\nend", "def shift_out_left\n size.times do |i|\n yield(bit_at_position(size - i - 1), i)\n end\n end", "def shift_left(list)\n overflow = 0\n overflow = list[0]\n point = 0\n list.size.times d...
[ "0.65501535", "0.6400582", "0.6271834", "0.6209629", "0.62086505", "0.6193689", "0.6192336", "0.61633945", "0.61485785", "0.61352956", "0.6068593", "0.60490537", "0.60490537", "0.6034525", "0.59748626", "0.59748626", "0.5954267", "0.5892364", "0.5846135", "0.582501", "0.58239...
0.0
-1
Validate if numbers are allowed. Displays to the player the selected numbers and the size of the board. Pushes number into empty array denoted as board_dimensions
def construct_board board_dimensions = [] puts "Select board width between 1 and 500".colorize(:green) board_width = gets.chomp puts "Select board height between 1 and 500".colorize(:green) board_height = gets.chomp puts sep = "------------------------------------------------------".colorize(:yellow) validate_width_is_number = board_width.to_i validate_height_is_number = board_height.to_i if validate_width_is_number <= 0 || validate_height_is_number > 500 && validate_height_is_number <= 0 || validate_height_is_number > 500 puts "Selection must be a number and between 1 and 500".colorize(:red) return construct_board else validated_width = validate_width_is_number validated_height = validate_height_is_number board_size = validated_width.to_i * validated_height.to_i puts "You have selected a board width of #{validated_width} and a board height of #{validated_height}.".colorize(:green) puts "Constructing a board with #{board_size} tiles.".colorize(:green) if validated_width == validated_height board_dimensions.push(validated_width, validated_height) puts sep else puts "Sorry, the board's width and height must be equal to each other. Try again".colorize(:red) puts sep return construct_board end end return board_dimensions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_numbers\n allowed = @board.map { |n| n.nil? ? 511 : 0 }\n coordinate_systems.each do |c|\n (0..8).each do |x|\n bits = axis_missing(x, c)\n (0..8).each { |y| allowed[index_for(x, y, c)] &= bits }\n end\n end\n allowed\n end", "def board_size()\n p \"What board ...
[ "0.63791114", "0.62149364", "0.5936996", "0.59235525", "0.58990824", "0.5892769", "0.58861965", "0.57890576", "0.5774365", "0.57033706", "0.56981117", "0.56885046", "0.56815404", "0.56160116", "0.55648243", "0.55549634", "0.55454123", "0.55209863", "0.5518022", "0.5516089", "...
0.69159615
0
Prompts player to make a selection of commands they wish to execute.
def user_commands puts sep = "------------------------------------------------------".colorize(:yellow) prompt = TTY::Prompt.new commands = [ {name: 'Place', value: 1}, {name: 'Move', value: 2}, {name: 'Left', value: 3}, {name: 'Right', value: 4}, {name: 'Report', value: 5}, {name: 'Execute Selected Commands', value: 6}, ] players_input = prompt.select("Select Your Commands:", commands) case players_input when 1 place_command = prompt_place @commands_sequence.push(place_command) p @commands_sequence puts sep user_commands when 2 move_command = validate_move @commands_sequence.push(move_command) p @commands_sequence puts sep user_commands when 3 left_command = validate_left @commands_sequence.push(left_command) p @commands_sequence puts sep user_commands when 4 right_command = validate_right @commands_sequence.push(right_command) p @commands_sequence puts sep user_commands when 5 report_command = validate_report @commands_sequence.push(report_command) p @commands_sequence puts sep user_commands when 6 legal_commands = valid_commands(@commands_sequence) if legal_commands.length == 0 puts "Command sequence must begin with a Place Command".colorize(:red) user_commands else return legal_commands end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input_commands\n @new_prompt.command_selection\n command = gets.chomp.upcase\n while command != 'EXIT GAME'\n @player_command = command\n handle_commands(@player_command)\n @new_prompt.command_selection\n command = gets.chomp.upcase\n end\n @new_prompt.exit_...
[ "0.7175048", "0.707023", "0.6908076", "0.6882818", "0.68043417", "0.67969036", "0.6777705", "0.6744601", "0.67386776", "0.6698638", "0.6634613", "0.6545919", "0.65029997", "0.6480039", "0.6472914", "0.6472623", "0.6468051", "0.6458188", "0.6454961", "0.64435744", "0.6416312",...
0.69351894
2
When called, prompts the player to select a x,y position and direction.
def prompt_place place_command ={} puts "Position X and Y Selection:".colorize(:green) puts "Inputs must be a positive number between 0 and your pre-selected board width and height parameters".colorize(:green) puts "Example -- If board width and height are 30,30, inputs must be between 0 and 30".colorize(:green) puts "Select position X".colorize(:green) user_position_x = gets.chomp place_command[:position_x] = user_position_x puts "Select position Y".colorize(:green) user_position_y = gets.chomp place_command[:position_y] = user_position_y puts "Select Direction between one of the following:".colorize(:green) puts "NORTH, SOUTH, EAST, WEST".colorize(:green) user_position_direction = gets.chomp.upcase place_command[:position_f] = user_position_direction return place_command end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prompt\n puts \"Select a position e.g. 0, 0\"\n position = gets.chomp.split(\", \").map {|i| i.to_i }\n puts \"Would you like to reveal or toggle flag? e.g. R or F\"\n action = gets.chomp.upcase\n [position, action]\n end", "def set_player_positions\n self.print_grid\n\n xy = self.ask_f...
[ "0.68029827", "0.6654795", "0.6378755", "0.6327734", "0.63108814", "0.6275581", "0.62698907", "0.6197889", "0.619403", "0.61884165", "0.61838424", "0.61769706", "0.6151847", "0.61514604", "0.61415064", "0.6139575", "0.6096667", "0.6052929", "0.6050231", "0.60064936", "0.59930...
0.6892792
0
If Move is selected, adds it to the move_command hash.
def validate_move move_command ={} move_command[:user_move] = true puts "Move command has been added".colorize(:green) return move_command end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_move_command(disabled)\n add_command(GTBS::Menu_Move, :move, !@actor.moved?) unless GTBS::HIDE_INACTIVE_COMMANDS && @actor.moved?\n end", "def move(command)\n command = command.upcase\n return false unless ALLOWED_COMMANDS.include?(command)\n\n (command == 'M') ? walk : turn(command)\n end"...
[ "0.6597643", "0.61887276", "0.6114687", "0.6063352", "0.59799564", "0.5972622", "0.587741", "0.58692497", "0.58602625", "0.58142155", "0.5803289", "0.57010096", "0.56915957", "0.5688379", "0.5668076", "0.5654532", "0.56451035", "0.56274474", "0.5609931", "0.5603401", "0.55594...
0.5792039
11
If Left is selected, adds it to the move_command hash.
def validate_left left_command ={} left_command[:user_left] = true puts "Left command has been added".colorize(:green) return left_command end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interpret_left(command)\n ensure_placed\n @robot.rotate_left\n end", "def left\n direction.move_left!\n end", "def move_left(environment)\n @previous_action = 'moved left'\n location[:x] -= 1 if can_move_right?(environment)\n\n environment.state\n end", "def cursor_left(*ar...
[ "0.6865797", "0.6290406", "0.62495583", "0.61935186", "0.61773485", "0.61473656", "0.6125383", "0.61059576", "0.6082387", "0.59817964", "0.59760386", "0.5960484", "0.59592927", "0.5946529", "0.59354997", "0.5902715", "0.5867718", "0.5862508", "0.5836013", "0.58224595", "0.581...
0.5325849
93
If Right is selected, adds it to the move_command hash.
def validate_right right_command ={} right_command[:user_right] = true puts "Right command has been added".colorize(:green) return right_command end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interpret_right(command)\n ensure_placed\n @robot.rotate_right\n end", "def update_other_commands\n return unless active && cursor_movable?\n shift_left if Input.repeat?(:LEFT)\n shift_right if Input.repeat?(:RIGHT)\n #shift_left(true) if Input.repeat?(:L)\n #shift_right(true) if ...
[ "0.6307112", "0.6259635", "0.60802436", "0.58467835", "0.5819407", "0.57487595", "0.57056063", "0.5633248", "0.56168073", "0.5603032", "0.5572277", "0.5559164", "0.5555624", "0.55317664", "0.5518126", "0.5491378", "0.5490315", "0.54750526", "0.5474526", "0.54623526", "0.54181...
0.4981408
72
If Report is selected, adds it to the move_command hash.
def validate_report report_command ={} report_command[:request_report] = true puts "Report command has been added".colorize(:green) return report_command end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def begin_report_command(command, report)\n @report = report\n end", "def interpret_report(command)\n ensure_placed\n @ui.write_text @robot.report\n end", "def move_finished\n @glade['toolbar_generate_map'].sensitive = true\n @glade['toolbar_record_points'].sensitive = true\n @locate_...
[ "0.5534242", "0.5221695", "0.51000166", "0.49272147", "0.48825568", "0.48811254", "0.48602656", "0.47802177", "0.47746313", "0.4756151", "0.4699997", "0.4699997", "0.4699997", "0.4699997", "0.4693746", "0.46917003", "0.4682384", "0.4655952", "0.4614775", "0.4607005", "0.46070...
0.0
-1
Checks the command array, drops any command that occurs before a valid Place command.
def valid_commands(user_commands) return legal_commands = user_commands.drop_while { |command| !command.dig(:position_x)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_first_command(command)\n arr_1 = command.split(' ') #only one space\n return false if arr_1.length != 2\n return false if arr_1[0] != 'PLACE'\n command_arr = command.split(' ').join(',').split(',')\n directions = [\"NORTH\", \"EAST\", \"SOUTH\", \"WEST\"]\n coords = ['0', '1','2','3','4...
[ "0.6672725", "0.6224769", "0.61702347", "0.61634845", "0.6117254", "0.5887813", "0.5877694", "0.5877694", "0.58407974", "0.574217", "0.5688254", "0.56356704", "0.5624038", "0.56157655", "0.54924184", "0.5490925", "0.54703015", "0.5457223", "0.5436758", "0.5427793", "0.5427087...
0.6546614
1
When called, prompts the player if they wish to play agian or be redirected to the main menu.
def play_again prompt = TTY::Prompt.new choices = [ {name: 'Yes', value: 1}, {name: 'No', value: 2}, ] players_input = prompt.select("Would You like to play again?", choices) case players_input when 1 execute_game when 2 main_menu end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play\n\t\tdisplay_welcome\n\t\twhile true\n\t\t\tchoice = get_menu_choice\n\t\t\tchoice_result = handle_menu_choice choice\n\t\t\tbreak if choice_result == :quit\n\t\tend\n\t\tputs \"Thanks for playing Hangman :-) Play again soon.\"\n\tend", "def main_menu\n menu_options = [\"Start exploring\", \"Chec...
[ "0.7169791", "0.68095183", "0.6796149", "0.6658349", "0.6655153", "0.65526295", "0.65108603", "0.6459318", "0.64513344", "0.644917", "0.63930964", "0.63709", "0.6368305", "0.636643", "0.6363137", "0.63449633", "0.6343585", "0.6326807", "0.63037395", "0.6269242", "0.626853", ...
0.6093223
42
ok, that args is actually pointless, we can just do this
def puts_two_again(arg1, arg2) puts "arg1: #{arg1}, arg2: #{arg2}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def args(*) end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args;...
[ "0.8081542", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624", "0.78817624",...
0.0
-1
this just take one argument
def puts_one(arg1) puts "arg1: #{arg1}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def args(*) end", "def arg; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; ...
[ "0.6968434", "0.69270384", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925", "0.67807925",...
0.0
-1
this one takes no argument
def puts_none() puts "I have nothin'." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def standalone=(_arg0); end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def probers=(_arg0); end...
[ "0.703902", "0.69603497", "0.6924788", "0.6924788", "0.6924788", "0.6924788", "0.6883299", "0.6883299", "0.6883299", "0.6883299", "0.6883299", "0.6883299", "0.6883299", "0.6883299", "0.6844467", "0.68064326", "0.67232347", "0.6698278", "0.6698278", "0.6669987", "0.6665863", ...
0.0
-1
3, 2, 5, 4, 8
def windowed_max_range_good(array, window_size) mmsq = MinMaxStackQueue.new big_diff = nil i = 0 while i < array.length mmsq.enqueue(array[i]) if mmsq.size == window_size mmsq.size next_diff = mmsq.max - mmsq.min big_diff = next_diff if big_diff.nil? || big_diff < next_diff mmsq.dequeue end i+=1 end big_diff end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def given\n [6,5,3,1,8,7,2,3]\nend", "def three(array)\n array.sort!.shift\n array << 6\nend", "def append3(ary, n)\n n.downto(0) { |n| ary << n }\n ary\n #5.downto(1) { |n| ary << n }\nend", "def last_ids(number)\n (1 + size - number..size).to_a\n end", "def number_counting_seq(n)\r\n\r\nend"...
[ "0.7456231", "0.64125574", "0.5876139", "0.5742608", "0.5723807", "0.5693131", "0.56887", "0.5685128", "0.56804", "0.5678524", "0.5670917", "0.5656851", "0.5648089", "0.5638762", "0.56382513", "0.5634118", "0.563381", "0.561821", "0.561458", "0.56112474", "0.5600682", "0.55...
0.0
-1
creates new instance with name and adds to existing array
def initialize(name) @name = name @@all << self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize (name)\n @name = name\n @@all_authors.push(self)\n #when an instance is made with its name, we push that intance to the array\n end", "def create(name)\n object = new(name)\n @instances.push(object)\n object\n end", "def initialize name\n\t\t@name = name\n\t\t@@instances << sel...
[ "0.7104697", "0.7081393", "0.6959307", "0.673407", "0.6473962", "0.6430573", "0.64020246", "0.6383008", "0.6375387", "0.6367595", "0.635651", "0.63538784", "0.6350137", "0.63439786", "0.6325773", "0.6297348", "0.628816", "0.6253709", "0.6232477", "0.6211529", "0.6204912", "...
0.6051839
34
adds existing song to artist
def add_song(song) song.artist = self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_song(song)\n # Add song to @songs if it doesn't already exist\n @songs << song if !@songs.include?(song)\n # Add artist if not already assigned\n song.artist = self if song.artist ==nil\n save\n end", "def add_song(song)\n if song.artist == nil #does not assign the song if the song alr...
[ "0.8722219", "0.8539627", "0.85023415", "0.85023415", "0.8475985", "0.844806", "0.8447762", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.8446692", "0.84447426", "0.8442083", "0.8441888", ...
0.83952415
33
creates a new song by name and adds to artist
def add_song_by_name(name) song = Song.new(name) song.artist = self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_song_by_name(song_name)\n # Create a new song called \"song\" with argument passed in.\n song = Song.new(song_name)\n # Associate it with the artist\n song.artist = self\n end", "def add_song_by_name(name)\n\t\tSong.new(name).artist = self \n\tend", "def add_song_by_name(name)\n song = ...
[ "0.8786191", "0.8649262", "0.8647444", "0.86272436", "0.8616903", "0.85379285", "0.85181653", "0.84430444", "0.8403085", "0.8371659", "0.8371659", "0.8371659", "0.827204", "0.8255781", "0.8230657", "0.8208831", "0.8201268", "0.8192444", "0.8192444", "0.8192444", "0.8192444", ...
0.88251525
1
displays all songs assigned to artist
def songs Song.all.select {|song| song.artist == self} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def view_artist_songs(artist)\n artist_name = artist\n artist_id = Artist.find_by(name: artist_name).id\n songs = Song.where(artist_id: artist_id).map{|song| song.name}\n puts \"**************************\"\n puts \"**************************\"\n prompt(\"#{artist_name}'s ...
[ "0.8228453", "0.7723126", "0.7661022", "0.75838524", "0.7576205", "0.7540986", "0.7530085", "0.7471719", "0.7413922", "0.73718655", "0.73682404", "0.7357418", "0.7308801", "0.724191", "0.7210421", "0.7204577", "0.71673864", "0.71673864", "0.71628433", "0.7161698", "0.71606123...
0.6733774
93
Instantiates and inserts an object at its table
def instantiate(table_class, *data) ele = table_class.new(*data) ele = self.insert(ele) return ele end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(object, table)\n sql = object.to_sql(table)\n execute(sql)\n end", "def insert_obj(obj) # :nodoc:\n chk_conn\n tx = @hibernate_session.begin_transaction\n @hibernate_session.save(obj)\n tx.commit\n obj\n end", "def create\r\n if self.id.nil? && connection.pr...
[ "0.737687", "0.71231335", "0.71104985", "0.6921618", "0.68344676", "0.68163115", "0.674935", "0.66795677", "0.66458637", "0.6612687", "0.6601553", "0.65838504", "0.65298206", "0.65267646", "0.64739674", "0.6437321", "0.643439", "0.6429539", "0.64110273", "0.6382407", "0.63703...
0.67814136
6
Inserts an object at its class table Options: :duplicate :ignore, :replace, :fail default :fail
def insert(instance, options = {}) table_class = instance.class options = {:duplicate => :fail}.merge(options) raise "Table for object class #{table_class} does not exist" if @tables[table_class] == nil #TODO: Check if method dump is declared in the class raise "Attempt to insert null key" if instance.key == nil @semaphore.synchronize do if @tables[table_class][instance.key] == nil || options[:duplicate] == :replace @db.transaction do @db["tables"][table_class][instance.key] = instance.dump @tables[table_class][instance.key] = instance end else if options[:duplicate] ==:fail raise "Element #{instance} already exists in table #{table_class}" end end end return instance end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(object, table)\n sql = object.to_sql(table)\n execute(sql)\n end", "def insert_obj(obj) # :nodoc:\n chk_conn\n tx = @hibernate_session.begin_transaction\n @hibernate_session.save(obj)\n tx.commit\n obj\n end", "def insert\n # the array of ::columns of the class ...
[ "0.7238822", "0.7076078", "0.6944046", "0.688321", "0.6873698", "0.6797097", "0.6700148", "0.6687936", "0.6686144", "0.6648275", "0.659366", "0.6485969", "0.6439855", "0.63811344", "0.6337109", "0.6322957", "0.6299807", "0.625583", "0.622362", "0.6173207", "0.6134878", "0.6...
0.76599395
0
Instantiates and inserts an object at its table Options: :duplicate :ignore, :replace, :fail default :fail
def load_insert(table_class, data, options = {}) raise "Table does not exist" if @tables[table_class] == nil element = table_class.new.load(data) return self.insert(element, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(instance, options = {})\n table_class = instance.class\n options = {:duplicate => :fail}.merge(options)\n raise \"Table for object class #{table_class} does not exist\" if @tables[table_class] == nil\n #TODO: Check if method dump is declared in the class\n raise \"Atte...
[ "0.73375654", "0.6949779", "0.6915101", "0.69047374", "0.6846315", "0.6760927", "0.66489094", "0.66217303", "0.65904695", "0.65772337", "0.6531288", "0.6528735", "0.64879096", "0.6476737", "0.6368562", "0.63589805", "0.63560784", "0.63428015", "0.633832", "0.6309278", "0.6290...
0.6267865
22
GET /accounts GET /accounts.json
def index @accounts = Account.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accounts\n get('/accounts')['accounts']\n end", "def get_accounts()\n http_get(accounts_url)\n end", "def get_account\n as_json(get_results('/account'))\n end", "def index\n\t\t@accounts = Account.all\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @accounts }\n\t\tend\n...
[ "0.853379", "0.831886", "0.79738474", "0.77710557", "0.7715818", "0.76106566", "0.7565733", "0.7560473", "0.7477256", "0.7466753", "0.73992366", "0.73606426", "0.7348876", "0.7347771", "0.7334897", "0.72753763", "0.7272824", "0.7226032", "0.7212077", "0.7173881", "0.7171776",...
0.68259454
68
GET /accounts/1 GET /accounts/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accounts\n get('/accounts')['accounts']\n end", "def get_accounts()\n http_get(accounts_url)\n end", "def get_account\n as_json(get_results('/account'))\n end", "def account(id)\n make_json_api_request :get, \"v2/accounts/#{id}\"\n end", "def show\n authorize @account...
[ "0.76850796", "0.7638545", "0.7636625", "0.7543032", "0.74303883", "0.72776806", "0.72650754", "0.7220039", "0.7220039", "0.7220039", "0.7220039", "0.7220039", "0.72091615", "0.71906865", "0.718959", "0.7189367", "0.71788657", "0.7175258", "0.7168455", "0.716439", "0.7142084"...
0.0
-1
POST /accounts POST /accounts.json
def create @account = Account.new(account_params) respond_to do |format| if @account.save format.html { redirect_to @account, notice: 'Account was successfully created.' } format.json { render :show, status: :created, location: @account } else format.html { render :new } format.json { render json: @account.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n megam_rest.post_accounts(to_hash)\n end", "def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n ...
[ "0.7704493", "0.7442799", "0.6997527", "0.6844751", "0.68422955", "0.6837734", "0.68307513", "0.6804143", "0.676803", "0.6764939", "0.6762548", "0.6747317", "0.67175066", "0.67166245", "0.6707795", "0.6687809", "0.66749424", "0.66687435", "0.663616", "0.6630253", "0.6618579",...
0.6744821
19
PATCH/PUT /accounts/1 PATCH/PUT /accounts/1.json
def update respond_to do |format| if @account.update(account_params) format.html { redirect_to @account, notice: 'Account was successfully updated.' } format.json { render :show, status: :ok, location: @account } else format.html { render :edit } format.json { render json: @account.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update \n begin\n @resource = Account.find(params[:id])\n @resource.update_attributes!(params[:account])\n render :response => :PUT\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def update\n respond_to do |format|\...
[ "0.6888058", "0.6805634", "0.66244066", "0.6590727", "0.6511931", "0.6495116", "0.64945376", "0.64945376", "0.6483295", "0.64544296", "0.6452603", "0.6377159", "0.6355293", "0.63540685", "0.63120645", "0.63075304", "0.6296196", "0.6243909", "0.62437785", "0.6234137", "0.62247...
0.6129985
45
DELETE /accounts/1 DELETE /accounts/1.json
def destroy @account.destroy respond_to do |format| format.html { redirect_to accounts_url, notice: 'Account was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_account\n @connection.request({\n :method => 'DELETE'\n }) \n end", "def destroy\n @api_v1_account.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_accounts_url, notice: 'Account was successfully destroyed.' }\n format.jso...
[ "0.7661168", "0.7553564", "0.754891", "0.7351063", "0.7351063", "0.7345915", "0.7345915", "0.7345915", "0.73266613", "0.73266613", "0.73266613", "0.73266613", "0.73266613", "0.73266613", "0.7279808", "0.7279808", "0.7255806", "0.71934515", "0.7172692", "0.71393716", "0.710492...
0.7059445
44
Use callbacks to share common setup or constraints between actions.
def set_account @account = Account.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.533...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def account_params params.require(:account).permit(:app_id, :customer_id, :account_no) 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.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
_cat and _cluster endpoints
def help_health_data __elasticsearch__.client.cluster.health end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def endpoints; end", "def cluster_servers\n endpoint.config.nodes.map { |h| \"#{h[:host]}:#{h[:port]}\" }\n end", "def cluster(subcommand, *args); end", "def cluster_list\n super\n end", "def __cluster_url\n if '_local_' == arguments[:network_host]\n \"http://loc...
[ "0.6654088", "0.6284055", "0.61901027", "0.6188556", "0.61866254", "0.5890762", "0.58621144", "0.5849636", "0.5827489", "0.5753197", "0.5753197", "0.5753197", "0.5753197", "0.57107496", "0.5703133", "0.5703133", "0.5703133", "0.5697788", "0.56738216", "0.56613886", "0.5658269...
0.0
-1
get full list of
def help_node_names_data __elasticsearch__.client.cat.nodes(:format => 'json', :h => 'name') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n return @list\n end", "def list\n return @lists\n end", "def list\n only.to_a\n end", "def list; end", "def list; end", "def list; end", "def list; end", "def list; end", "def all\n @list\n end", "def list\n @list\n end", "def li...
[ "0.7420012", "0.72633773", "0.7229569", "0.7201715", "0.7201715", "0.7201715", "0.7201715", "0.7201715", "0.7155948", "0.7144365", "0.70879936", "0.70834124", "0.70760953", "0.70245093", "0.7015727", "0.6963783", "0.6963783", "0.694486", "0.6933326", "0.6927651", "0.6905699",...
0.0
-1
list full dump of all node stats groups for all nodes, or for one named node using humanreadable name (one of those returned by node_names_data endpoint)
def help_node_stats_data(name = nil) ns = __elasticsearch__.client.nodes.stats(:format => 'json') if name filtered_ns = ns['nodes'].keys.map do |k| [ k, ns['nodes'][k] ] if ns['nodes'][k]['name'] == name end.to_h ns['nodes'] = filtered_ns end ns end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_all_node_stats\n print_stats(stats: get_stats)\n end", "def node_names\n @groups.inject(local_node_names) do |acc, g|\n acc.merge(g.node_names)\n end\n end", "def help_node_names_data\n\t\t__elasticsearch__.client.cat.nodes(:format => 'json', :h => 'name')\n\tend",...
[ "0.6668664", "0.6473538", "0.63171417", "0.61247617", "0.596684", "0.5966785", "0.589314", "0.5883299", "0.5791346", "0.5784716", "0.5746883", "0.5708691", "0.5705035", "0.5693815", "0.56685805", "0.56585443", "0.56400096", "0.55659103", "0.55319333", "0.5528992", "0.5493939"...
0.6786242
0
WARNING: this isn't JSONformatable, it's raw text for some reason
def help_hot_threads_data(count = 5) __elasticsearch__.client.nodes.hot_threads(:threads => count) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_json\n @raw_json ||= @content.gsub(/---(.|\\n)*---/, '')\n end", "def inspect\n `/* borrowed from json2.js, see file for license */\n var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n\n escapable = /...
[ "0.6793139", "0.6760107", "0.6705647", "0.65277314", "0.6526622", "0.6478268", "0.634098", "0.6323682", "0.62973166", "0.6277746", "0.62506217", "0.6231731", "0.62259287", "0.6211461", "0.6207569", "0.62074614", "0.620335", "0.6173254", "0.6171392", "0.6171344", "0.6146783", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_category @category = Category.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def category_params params.require(:category).permit(:name) 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.6980244", "0.6782812", "0.6745103", "0.6741142", "0.6733961", "0.65925", "0.6503602", "0.64967257", "0.64822173", "0.64796996", "0.6456357", "0.6439594", "0.63803256", "0.6376499", "0.63644457", "0.6319286", "0.6299465", "0.6298051", "0.62935406", "0.62923044", "0.6291212"...
0.0
-1
For use by RecordChangelog
def record_changelog_identifier self.valve_code end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def history_added; end", "def history_added=(_arg0); end", "def private; end", "def modified?; end", "def modification_date=(_); end", "def reopen_logs; end", "def modification_date; end", "def log_tags; end", "def log_tags; end", "def log_tags; end", "def save_changes_from(record)\n self.sa...
[ "0.65269864", "0.6377878", "0.62482953", "0.61131096", "0.6064107", "0.5940745", "0.5938573", "0.5921703", "0.5921703", "0.5921703", "0.5875161", "0.58594745", "0.5816324", "0.5814158", "0.58137333", "0.5803324", "0.5798907", "0.5798907", "0.5798907", "0.5780521", "0.57665545...
0.6249332
2
Clones the valve, including its valve components and manufacturers Does it all in a transaction block so it rolls back all changes if validations fail. Turns off recording changes so that the cloned valve components don't show up. We do a customized record_creation call, passing in 'Cloned' as the action so it is more understandable to the user when scanning through the revision history.
def deep_clone(new_code) RecordChangelog.enable_recording = false # Need to initialize this variable since it doesn't carry across # if created inside the transaction block. logger.error "Before Clone" @new_valve = self.dup logger.error "After Clone" transaction do @new_valve.valve_code = new_code # Auto-archive new clones @new_valve.archived = true @new_valve.save! logger.error "After New Valve Save" # Clones each component self.valves_valve_components.each do |detail| new_detail = detail.dup new_detail.valve = @new_valve new_detail.save! end logger.error "After Valve Components Clone" # Clones each manufacturer link self.manufacturers_valves.each do |detail| new_detail = detail.dup new_detail.valve = @new_valve new_detail.save! end logger.error "After Manufacturers Clone" # Clones each superseded manufacturer link self.old_manufacturers_valves.each do |detail| new_detail = detail.dup new_detail.valve = @new_valve new_detail.save! end logger.error "After Old Manufacturers Clone" end RecordChangelog.enable_recording = true # Custom revision history record RecordChangelog.record_creation(@new_valve, { :action => 'Cloned', :field_name => 'Valve', :old_value => self.valve_code, :new_value => @new_valve.valve_code }) return @new_piping_class rescue ActiveRecord::RecordInvalid ensure # Be sure to re-enable recording even if this fails. RecordChangelog.enable_recording = true return @new_valve end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_clone_for_relist(new_seller, include_images)\n is_copart_default_seller = (new_seller.present? && new_seller.copart_default?)\n employee_id = Employee.current.try(:id) rescue nil\n\n Vehicle.transaction do\n vehicle_copy = self.dup\n vehicle_copy.id = nil\n vehicle_copy.auction...
[ "0.58029574", "0.57096803", "0.56456316", "0.5577357", "0.55081767", "0.5487101", "0.54752105", "0.547379", "0.547379", "0.5456761", "0.54253197", "0.5420978", "0.54100704", "0.54100704", "0.54100704", "0.5394556", "0.5391399", "0.53905004", "0.5386274", "0.5386274", "0.53862...
0.71099925
0
Sets the archived variable to true and saves the valve.
def archive self.archived = true self.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def archived=(archived)\n if ActiveRecord::Type::Boolean.new.cast(archived)\n archive\n else\n restore\n end\n end", "def archival_for(object)\n object.archived = true\n end", "def archive!\n self.update_attribute(:archived, true)\n end", "def archive!\n ...
[ "0.75728625", "0.7493209", "0.74423283", "0.74423283", "0.74423283", "0.7117577", "0.70325124", "0.6988416", "0.6800116", "0.67411596", "0.6731054", "0.66398245", "0.6558013", "0.646331", "0.64592177", "0.63616955", "0.63183326", "0.62946165", "0.6197986", "0.6186325", "0.609...
0.75541073
1
Chops off the valve_note string at 200 chars. If it goes over, adds "..."
def chopped_valve_note if !self.valve_note.blank? && self.valve_note.length > 200 return self.valve_note[0..200] + "..." end return self.valve_note end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def short(str)\n limit = 140\n str = str.gsub(/(\\n|\\r)/, \"\")\n return str if str.size <= limit\n str.strip[0...(limit-3)]\n .concat(\"...\")\n end", "def shortened_string(string)\n string[0, 100] << \"...\" unless string.length < 100\n end", "def shortened_tweet_truncator(tweet_string...
[ "0.7103447", "0.70764816", "0.6995681", "0.6966064", "0.6917151", "0.68134063", "0.67675114", "0.6765203", "0.67506903", "0.67061967", "0.6626677", "0.6603051", "0.65898603", "0.6559503", "0.6558872", "0.65270483", "0.65225804", "0.6515258", "0.65082943", "0.6491099", "0.6479...
0.84989184
0
Attempts to login a user
def login_user(params) val = validate_user(params) if val == false return { error: true, message: "no such user user" } end username = params["name"] pswrd = params["password"] db = connect() result = db.execute("SELECT id, password FROM Users WHERE name = ?", username).first password = result["password"] if BCrypt::Password.new(password) != pswrd return { error: true, message: "Wrong password" } else return { error: false, id:result["id"] } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def try_to_login\n User.login(self.name, self.password)\n end", "def attempt_login\n if params[:email].present? && params[:password].present?\n found_user = User.where(email: params[:email]).first\n authorized_user = found_user.authenticate(params[:password]) if found_user\n end\n\n if aut...
[ "0.8032233", "0.778525", "0.77474105", "0.77390164", "0.77195925", "0.76771307", "0.7329193", "0.7325986", "0.72234744", "0.72154224", "0.72151273", "0.7179315", "0.71755743", "0.7167922", "0.7157715", "0.71358407", "0.71356493", "0.71152383", "0.7101863", "0.7067294", "0.704...
0.0
-1
Attempts to create new user
def register_user(params) val = validate_new_user(params) if val == false return { error: true, message: "not enough letter in name or password" } end name = params["name"] password = BCrypt::Password.create(params["password"]) db = connect() result = db.execute("SELECT id FROM Users WHERE name = ?",name) if result.length > 0 return { error: true, message: "User already exists" } end db.execute("INSERT INTO Users (name,password) VALUES (?,?)",name,password) result = db.execute("SELECT id FROM Users WHERE name = ?",name) return { error: false, data: result.first.first } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_user_create\n @user = User.create_user(user_params, current_user.account_id) # New User\n begin\n @user.save!\n @users = User.get_all(current_user.account_id)\n flash[:success] = \"User was created successfully!\"\n rescue => e\n flash[:alert] = \"User creation failed!\"\n e...
[ "0.7727776", "0.76288265", "0.7593009", "0.7568826", "0.7539452", "0.7533504", "0.75155693", "0.7485675", "0.7483122", "0.7472601", "0.73961604", "0.7386518", "0.7353579", "0.73440456", "0.73276526", "0.7327496", "0.7325968", "0.72917384", "0.7289302", "0.728532", "0.72792566...
0.0
-1