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
Create a new Spanner client object.
def initialize # These require statements are intentionally placed here to initialize # the gRPC module only when it's required. # See https://github.com/googleapis/toolkit/issues/446 require "gapic/grpc" require "google/spanner/v1/spanner_services_pb" # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT && !@config.endpoint.split(".").first.include?("-") credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @spanner_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::Spanner::V1::Spanner::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @client = Client.new\n end", "def new\n @client = Client.new\n end", "def new\n @client = Client.new\n end", "def new\n\t\t@client = Client.new\n\tend", "def new_client\n Savon.client(\n wsdl: @wsdl,\n endpoint: @endpoint,\n ...
[ "0.6986114", "0.6986114", "0.6986114", "0.67052305", "0.6580621", "0.6496268", "0.6377539", "0.6372808", "0.6353549", "0.62784785", "0.61829644", "0.6166497", "0.6165346", "0.61387175", "0.61275196", "0.6092542", "0.607398", "0.60600674", "0.6059014", "0.6048901", "0.60480887...
0.62966794
9
Configurations for individual RPCs
def rpcs @rpcs ||= begin parent_rpcs = nil parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) Rpcs.new parent_rpcs end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rpc_configs\n @rpc_enabled = true\n @rpc_configs = OpenStruct.new(\n :address => rpc_default_path,\n :verbose => false,\n :server => OpenStruct.new(\n :preload => nil,\n :num_workers => 5\n ...
[ "0.7670324", "0.65388", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6519626", "0.6496722", "0.64504987", "0.64504987", "...
0.6475326
50
GET /learn GET /learn.json
def current_repetition @cards = current_user.cards_due @card = @cards.sample end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @learn }\n end\n end", "def new\n @learn = Learn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @learn }\...
[ "0.7505591", "0.69095147", "0.6632864", "0.6514951", "0.6372981", "0.63381803", "0.6310782", "0.6226623", "0.6147296", "0.60580903", "0.6048885", "0.602975", "0.5987045", "0.5956902", "0.5950432", "0.5927009", "0.59180695", "0.5908847", "0.5851757", "0.5849044", "0.5838203", ...
0.0
-1
Returns the current loggedin user (if any).
def current_user if session[:user_id] @current_user ||= User.find_by(id: session[:user_id]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end", "def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end", "def current_user\n return unless session[:user_id...
[ "0.85960984", "0.8593657", "0.855797", "0.8545853", "0.8534344", "0.8497545", "0.847914", "0.8460573", "0.8457271", "0.84556973", "0.84472865", "0.8442264", "0.8441092", "0.84366953", "0.8400402", "0.83765614", "0.8368829", "0.8337418", "0.8337418", "0.8314651", "0.8311652", ...
0.8078152
96
Initializes an empty options hash to store ActiveConfiguration::Option instances containing configuration details.
def initialize @options = HashWithIndifferentAccess.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options\n @options ||= Hash.new{ |h, k| h[k] = {} }\n end", "def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option.name.to_sym => option.value})\n end\n opts\n end", "def initialize_options\n @options = @spec.options.inject({}) ...
[ "0.77682495", "0.74370295", "0.7346797", "0.72785294", "0.7230288", "0.7230288", "0.7230288", "0.71697503", "0.71620077", "0.7138633", "0.7127613", "0.7113905", "0.7098109", "0.7095942", "0.70636994", "0.70636994", "0.70636994", "0.70473963", "0.7045181", "0.70262027", "0.702...
0.67623013
48
Creates and accepts the configuration details for an Option. An example of setting an option with a block: option :sort do default 'alphabetical' restrict 'alphabetical', 'manual' end Here, the option method is called and passed the key of :sort and then the the block that follows. The block given to option is then evaluated against a new instance of ActiveConfiguration::Option.
def option(key, &block) opt = Option.new(key) opt.instance_eval(&block) @options[key.to_sym] = opt end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configuration_option(*opts, &block)\n Autoproj.config.declare(*opts, &block)\nend", "def configure(&block)\n raise ArgumentError, \"Block is required.\" unless block_given?\n yield @options\n end", "def construct( &block )\n self.instance_eval(&block)\n @options\n end", "def in...
[ "0.6747116", "0.65691507", "0.64178103", "0.6314809", "0.62327296", "0.6194542", "0.61855745", "0.614044", "0.61189175", "0.60965264", "0.60913324", "0.60803825", "0.60517997", "0.6040868", "0.60336405", "0.6019346", "0.60152006", "0.60050344", "0.6003364", "0.60033184", "0.5...
0.6593896
1
Returns the size of the bitfield in number of bits +bitfield_max :column
def bitfield_max column_name @@bitfields[column_name].values.sum.max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bit_length\n @bit_length ||= ECDSA.bit_length(field.prime)\n end", "def size\n BitCounter.count(@val)\n end", "def bit_set_size\n @bit_set.size\n end", "def bit_length\n (negative? ? -self : self + ONE).log2.ceil\n end", "def column_size; end", "def size\n (@bit_length*@l...
[ "0.71370023", "0.6767409", "0.6750003", "0.6675906", "0.6595411", "0.64401454", "0.6420186", "0.6418719", "0.63654286", "0.6361144", "0.63010246", "0.62875146", "0.6273314", "0.6264639", "0.6259859", "0.6259859", "0.62225676", "0.62160003", "0.62077475", "0.6169275", "0.61202...
0.8107433
0
Returns the field names for the bitfield column +bitfields
def bitfields column_name @@bitfields[column_name].keys end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def field_names\n fields.keys\n end", "def field_names\n @field_names ||= (columns_hash.keys.map(&:to_sym) rescue [])\n end", "def bits_for(*field_names)\n bits = []\n \n field_names.flatten.each do |i|\n if i.is_a?(Integer)\n bits << i\n next...
[ "0.6971322", "0.6948479", "0.6645891", "0.6638981", "0.65271646", "0.6456592", "0.64458656", "0.6425023", "0.6373594", "0.6361138", "0.61620855", "0.61535007", "0.61535007", "0.6116174", "0.6113793", "0.6084116", "0.60780674", "0.6060987", "0.60595375", "0.6041304", "0.604034...
0.8190619
0
Returns the column by name +column_for
def range_for column_name, field_name column = @@bitfields[column_name] raise ArgumentError, "Unknown column for bitfield: #{column_name}" if column.nil? return column[field_name] if column[field_name] raise ArugmentError, "Unknown field: #{field_name} for column #{column_name}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def column_for(col_name)\n relation.column_names.detect { |col| col == col_name }\n end", "def column(name)\n @name_to_columns[name]\n end", "def column_for_attribute(name)\n self.class.columns_hash[name.to_s]\n end", "def column_for_attribute(name)\n self.class.columns...
[ "0.80981773", "0.7893585", "0.77641433", "0.76494175", "0.75689787", "0.7542143", "0.73651725", "0.73638535", "0.73638535", "0.7333518", "0.7333518", "0.72934926", "0.7252329", "0.72387636", "0.7210727", "0.71819156", "0.7118217", "0.7116076", "0.7039199", "0.6917202", "0.688...
0.0
-1
Returns a "reset mask" for a list of fields +reset_mask_for :fields
def reset_mask_for column_name, *fields fields = bitfields if fields.empty? max = bitfield_max(column_name) (0..max).sum{|i| 2 ** i} - only_mask_for(column_name, *fields) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mask\n (@bound_fields + @unbound_fields + @operands).map do |(field,_)|\n WordField[field].mask\n end.inject do |memo,field_mask|\n memo | field_mask\n end\n end", "def reset_bitfields column_name, *fields\n mask = reset_mask_for column_name, *fields\n update_all \"#{column_name...
[ "0.631488", "0.6240865", "0.5869973", "0.5704371", "0.56187505", "0.53187746", "0.5154865", "0.5145627", "0.5107875", "0.50851136", "0.50851136", "0.5072117", "0.49948743", "0.48419213", "0.4832822", "0.48278758", "0.47796956", "0.47496808", "0.47422838", "0.47414747", "0.471...
0.66708994
0
Returns an "increment mask" for a list of fields +increment_mask_for :fields
def increment_mask_for column_name, *fields fields = bitfields if fields.empty? column = @@bitfields[column_name] raise ArgumentError, "Unknown column for bitfield: #{column_name}" if column.nil? fields.sum do |field_name| raise ArugmentError, "Unknown field: #{field_name} for column #{column_name}" if column[field_name].nil? 2 ** (bitfield_max(column_name) - column[field_name].last) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calcIndex(inFields)\n index = 0\n field = 0\n @inMask.each_index do |i|\n index += inFields[i] << field\n field += @inMask[i] \n end\n index\n end", "def increment_bitfields column_name, *fields\n mask = increment_mask_for column_name, *fields\n update_all \"#{column_name}...
[ "0.64448756", "0.64394754", "0.60582227", "0.5737367", "0.54996616", "0.5363126", "0.52102506", "0.5117863", "0.5067465", "0.5027698", "0.50190216", "0.50178236", "0.50029695", "0.4988282", "0.49580488", "0.48778778", "0.48602548", "0.48440126", "0.4824261", "0.4753182", "0.4...
0.6035005
3
Returns an "only mask" for a list of fields +only_mask_for :fields
def only_mask_for column_name, *fields fields = bitfields if fields.empty? column = @@bitfields[column_name] max = bitfield_max(column_name) raise ArgumentError, "Unknown column for bitfield: #{column_name}" if column.nil? column.sum do |field_name, range| fields.include?(field_name) ? range.invert(max).sum{|i| 2 ** i} : 0 end # fields.inject("0" * (bitfield_max(column_name) + 1)) do |mask, field_name| # raise ArugmentError, "Unknown field: #{field_name} for column #{column_name}" if column[field_name].nil? # range = column[field_name] # mask[range] = "1" * range.count # mask # end.to_i(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mask\n (@bound_fields + @unbound_fields + @operands).map do |(field,_)|\n WordField[field].mask\n end.inject do |memo,field_mask|\n memo | field_mask\n end\n end", "def only(*args)\n clone.tap do |crit|\n if args.any?\n crit.options[:fields] = {:_type => 1}\n ...
[ "0.70332766", "0.63485366", "0.6307429", "0.562097", "0.550545", "0.5471939", "0.5459215", "0.54271746", "0.5417391", "0.54117924", "0.5371074", "0.52499115", "0.5242881", "0.5218936", "0.52105075", "0.51930135", "0.5143433", "0.5108858", "0.5104175", "0.5073474", "0.50555354...
0.60703146
3
Sets one or more bitfields to 0 within a column +reset_bitfield :column, :fields
def reset_bitfields column_name, *fields mask = reset_mask_for column_name, *fields update_all "#{column_name} = #{column_name} & #{mask}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_mask_for column_name, *fields\n fields = bitfields if fields.empty?\n max = bitfield_max(column_name)\n (0..max).sum{|i| 2 ** i} - only_mask_for(column_name, *fields)\n end", "def clear\n @field.each_index { |i| @field[i] = 0 }\n end", "def increment_bitfields column_name, *fiel...
[ "0.7262586", "0.6679082", "0.6489623", "0.61005795", "0.6023518", "0.59675944", "0.59645706", "0.5939816", "0.592227", "0.5879115", "0.5879115", "0.58146495", "0.56871295", "0.5653341", "0.5648795", "0.5642839", "0.5557983", "0.54491323", "0.5445896", "0.54279023", "0.5410517...
0.85810494
0
Increases one or more bitfields by 1 value +increment_bitfield :column, :fields
def increment_bitfields column_name, *fields mask = increment_mask_for column_name, *fields update_all "#{column_name} = #{column_name} + #{mask}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increment_bitfields column_name, *fields\n mask = self.class.increment_mask_for column_name, *fields\n self[column_name] = self[column_name] += mask\n save\n end", "def increment_mask_for column_name, *fields\n fields = bitfields if fields.empty?\n column = @@bitfields[column_name...
[ "0.87612927", "0.77834016", "0.6443977", "0.5953096", "0.5942322", "0.59417933", "0.583617", "0.583617", "0.5690166", "0.5625212", "0.5625212", "0.5588072", "0.55383843", "0.549851", "0.54783934", "0.5478259", "0.54649013", "0.54446375", "0.5435712", "0.5432103", "0.54049903"...
0.89511776
0
Counts resources grouped by a bitfield +count_by :column, :fields
def count_by column_name, field inc = increment_mask_for column_name, field only = only_mask_for column_name, field # Create super-special-bitfield-grouping-query w/ AREL sql = arel_table. project("count(#{primary_key}) as #{field}_count, (#{column_name} & #{only})/#{inc} as #{field}"). group(field).to_sql connection.send :select, sql, 'AREL' # Execute the query end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count\n size = 0\n core_search.group(\"name.id, #{main_group_by_columns}\").each do |_x|\n size += 1\n end\n size\n end", "def count_for(resource)\n\t\tself.find(resource).count\n\tend", "def count(resource)\n list(resource.to_s,1)[\"meta\"][\"total_count\"]\n end", "def countab...
[ "0.6700518", "0.63404983", "0.62339914", "0.6218993", "0.6062148", "0.60613865", "0.60381085", "0.60381085", "0.60129595", "0.59839845", "0.5957038", "0.59498876", "0.5930106", "0.5909058", "0.5902918", "0.5897846", "0.5897376", "0.58841914", "0.5878093", "0.58779985", "0.583...
0.74481875
0
Increases one or more bitfields by 1 value +increment_bitfield :column, :fields
def increment_bitfields column_name, *fields mask = self.class.increment_mask_for column_name, *fields self[column_name] = self[column_name] += mask save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increment_bitfields column_name, *fields\n mask = increment_mask_for column_name, *fields\n update_all \"#{column_name} = #{column_name} + #{mask}\"\n end", "def increment_mask_for column_name, *fields\n fields = bitfields if fields.empty?\n column = @@bitfields[column_name]\n rai...
[ "0.89512604", "0.7784009", "0.6442566", "0.59542763", "0.5943443", "0.59417194", "0.5836268", "0.5836268", "0.5690341", "0.5625472", "0.5625472", "0.5587132", "0.55391765", "0.5497798", "0.54786706", "0.5478626", "0.5463752", "0.54449135", "0.5435353", "0.54316", "0.54045564"...
0.8761737
1
Possible moves a knight can make
def possible_moves(x, y) @moves = [[x+1,y+2], [x+1,y-2], [x-1,y+2], [x-1,y-2], [x+2,y+1], [x+2,y-1], [x-2,y+1], [x-2,y-1]] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def knight_moves(position_start,position_end)\n \n\n move = [-2,-1,1,2,].product([-2,-1,1,2]).select do |x,y| x.abs != y.abs end\n \n board = (0..7).map do \n [Array.new(8,nil)]\n end\n \n queue= []\n queue.push(position_start)\n notFind = true\n \n...
[ "0.75381595", "0.7486832", "0.74303484", "0.7376419", "0.73356426", "0.72956777", "0.7270879", "0.72465944", "0.7216324", "0.7215012", "0.7179586", "0.7146166", "0.7139532", "0.7114055", "0.7110928", "0.7104329", "0.7094344", "0.708093", "0.7063682", "0.70535696", "0.7033753"...
0.67855936
46
FIXME remove and use filter in views def conditions_for_collection [ '(workcamps.begin >= ?)', Date.new(2010,1,1) ] end
def email_all wc = Incoming::Workcamp.find(params[:id]) addresses = wc.participants.map { |p| p.organization.email.to_s.strip } redirect_to "mailto:#{addresses.join(',')}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n current_year = DateTime.now.year\n date_registration_opens = DateTime.new(current_year, 1, 1)\n date_registration_closes = DateTime.new(current_year+1, 1, 1)\n @camps = Camp.where(\"(start_date >= ? AND start_date < ?)\", date_registration_opens, date_registration_closes).all\n end", "de...
[ "0.6571027", "0.65448755", "0.63149136", "0.62904465", "0.6232841", "0.613697", "0.61290294", "0.6059844", "0.6059844", "0.6058535", "0.5981415", "0.59449416", "0.59449416", "0.593825", "0.59343964", "0.59343964", "0.59343964", "0.58803636", "0.58066624", "0.57854086", "0.576...
0.0
-1
GET /missions/1 GET /missions/1.xml
def show @mission = Mission.find(params[:id]) respond_to do |format| format.js {@mission.to_json} format.html {@mission} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n if not @mission = Mission.find(params[:id])\n render json: \"Mission not found for id: \" + params[:id]\n else\n respond_to do |format|\n format.json { render json: @mission }\n format.xml { render xml: @mission }\n end\n end\n end", "def index\n @missions = M...
[ "0.6442743", "0.6334556", "0.6334556", "0.6334556", "0.6334556", "0.6154974", "0.61020136", "0.60673654", "0.6055454", "0.6037528", "0.60260445", "0.5943436", "0.5816645", "0.57859576", "0.5764186", "0.5731234", "0.5714797", "0.56805295", "0.567767", "0.56710225", "0.5664581"...
0.0
-1
GET /missions/new GET /missions/new.xml
def new @mission = Mission.new respond_to do |format| format.html # new.html.erb end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @mission = Mission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mission }\n end\n end", "def new\n @modulo = Modulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @modulo }\n ...
[ "0.68822676", "0.676747", "0.67286885", "0.6657133", "0.6579722", "0.6579722", "0.6574091", "0.655989", "0.6556449", "0.65373224", "0.65348136", "0.652663", "0.6524759", "0.6521269", "0.6520349", "0.6518998", "0.6511877", "0.6511858", "0.650504", "0.65037197", "0.649668", "...
0.67462385
2
POST /missions POST /missions.xml
def create @mission = Mission.new(params[:mission]) respond_to do |format| if @mission.save format.js { missions = Array.new Mission.all.each do |m| mission = Hash.new mission[:id] = m.id mission[:name] = m.name if m.id == @mission.id mission[:selected] = "true" else mission[:selected] = "false" end missions << mission end render :json => missions.sort_by { |mission| mission[:name]} } format.html { redirect_to(@mission, :notice => "The #{@mission.name} was sucesfully created.") } else format.html { render :action => "new" } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @mission_membership = MissionMembership.new(mission_membership_params)\n\n respond_to do |format|\n if @mission_membership.save\n format.html { redirect_to @mission_membership, notice: 'Mission membership was successfully created.' }\n format.json { render :show, status: :crea...
[ "0.59712154", "0.5774457", "0.5764914", "0.5764914", "0.5734137", "0.56896967", "0.5676138", "0.5545584", "0.5517663", "0.5495247", "0.5484578", "0.54711264", "0.54429877", "0.54247534", "0.5392861", "0.5379041", "0.531111", "0.531111", "0.531111", "0.531111", "0.5307907", ...
0.0
-1
PUT /missions/1 PUT /missions/1.xml
def update @mission = Mission.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n if @mission.update_attributes(mission_params)\n format.html { redirect_to @mission, notice: 'Mission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render acti...
[ "0.6356518", "0.62677306", "0.62677306", "0.62677306", "0.6198845", "0.61596245", "0.59818494", "0.59580255", "0.5948959", "0.5912207", "0.5886129", "0.58220345", "0.5815251", "0.5794813", "0.5771521", "0.572228", "0.57096887", "0.57015574", "0.569868", "0.5684844", "0.568137...
0.62584555
4
DELETE /missions/1 DELETE /missions/1.xml
def destroy @mission = Mission.find(params[:id]) @mission.destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end", "def destroy\n @ipadmission = Ipadmission.find(params[:id])\n @ipadmission.destroy\n\n respond_to do |format|\n format.html { redirect_to(ipadmissions_url) }\n format.xml { head :ok }\n end\n end...
[ "0.6556368", "0.6511632", "0.64810014", "0.640924", "0.64016426", "0.63914824", "0.6342617", "0.6337935", "0.6328765", "0.6326571", "0.6316322", "0.6315472", "0.6277839", "0.62714213", "0.6256996", "0.62533706", "0.62397665", "0.62386996", "0.6229038", "0.62103415", "0.620458...
0.650412
2
has_many :posts has_many :reviews
def avatar if object.dp.present? k = object.dp.url.gsub('upload','upload/g_face,c_thumb,w_150,h_150') else k = object.avatar end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reviews\n reviews = []\n katas = Kata.all\n katas.each { |k| reviews += k.reviews.where(user_id: self.id) }\n return reviews\n end", "def my_reviews\n self.reviews.select do |review|\n review.user.id = self.id \n end \n end", "def fetch\n Product.includes(:revie...
[ "0.6980106", "0.6744505", "0.67256397", "0.65626365", "0.6464096", "0.6464096", "0.6464096", "0.64589745", "0.6436625", "0.64264774", "0.64059836", "0.63755494", "0.6359005", "0.62737733", "0.62632424", "0.6257059", "0.6255399", "0.6217944", "0.62071806", "0.6188471", "0.6170...
0.0
-1
get a specific stat based on an entity_type and an entity_id
def get_stats(tagging) hash = {} tagging.first.tags.each do |tag| hash = fill_hash_with_tag(hash,tag) end @array = [] @array = fill_array_with_hash(hash) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_entity(entity_id, entity_type)\n entity_class = begin; entity_type.constantize; rescue; nil; end\n return if entity_class.nil?\n\n @entity = if entity_class.respond_to?(:visible)\n entity_class.visible.find_by(id: entity_id)\n else\n ...
[ "0.6633558", "0.62709147", "0.60815454", "0.6045277", "0.6008174", "0.5924431", "0.582173", "0.5774409", "0.57586753", "0.5747536", "0.57082707", "0.56715655", "0.5650089", "0.5649181", "0.56151795", "0.5604592", "0.5596424", "0.5546341", "0.55349576", "0.5534275", "0.5528539...
0.0
-1
GET /export_budgets GET /export_budgets.json
def index @export_budgets = ExportBudget.get_export_budgets_by_user current_user @export_budgets = @export_budgets.page(params[:page]).per(25) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @export_budgets = ExportBudget.all\n end", "def index\n get_budgets\n end", "def index\n @budgets = Budget.all\n end", "def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {...
[ "0.7589122", "0.6765112", "0.6594881", "0.65468884", "0.64546865", "0.6392319", "0.62771064", "0.6250989", "0.6243598", "0.61574376", "0.60981613", "0.6057186", "0.6057186", "0.6053283", "0.59907717", "0.59508246", "0.59342587", "0.59255177", "0.5895308", "0.58896405", "0.588...
0.7251409
1
GET /export_budgets/1 GET /export_budgets/1.json
def show respond_to do |format| format.html format.pdf { render pdf: @export_budget.title, formats: [:html], template: 'export_budgets/create_pdf.html.haml', show_as_html: params.key?('debug') } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @export_budgets = ExportBudget.all\n end", "def index\n @export_budgets = ExportBudget.get_export_budgets_by_user current_user\n @export_budgets = @export_budgets.page(params[:page]).per(25)\n end", "def set_export_budget\n @export_budget = ExportBudget.find(params[:id])\n end", ...
[ "0.7548582", "0.71902925", "0.6794416", "0.6652618", "0.66223776", "0.6508981", "0.6422111", "0.6389017", "0.6345606", "0.6345606", "0.63383055", "0.63162136", "0.6138084", "0.6087938", "0.60656977", "0.60319436", "0.6016057", "0.6016057", "0.600245", "0.5995106", "0.5991982"...
0.0
-1
POST /export_budgets POST /export_budgets.json
def create @export_budget = ExportBudget.new(export_budget_params) @export_budget.author = current_user respond_to do |format| if @export_budget.save format.html { redirect_to @export_budget, notice: 'Export budget was successfully created.' } format.js { } format.json { render :back, status: :created, location: @export_budget } else format.html { render :new } format.js { } format.json { render json: @export_budget.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @export_budgets = ExportBudget.all\n end", "def create\n @export_budget = ExportBudget.new(params[:export_budget])\n respond_to do |format|\n if @export_budget.save\n @result = 'save'\n format.html { redirect_to :back, notice: 'Export budget was successfully created.' }\n...
[ "0.6652156", "0.6514427", "0.62387013", "0.6163214", "0.6105515", "0.6072496", "0.6053069", "0.6045837", "0.59647715", "0.59647715", "0.59000593", "0.589061", "0.5880425", "0.5880353", "0.58298516", "0.57742", "0.5751221", "0.5738721", "0.5677169", "0.5677169", "0.56648296", ...
0.6523707
1
PATCH/PUT /export_budgets/1 PATCH/PUT /export_budgets/1.json
def update respond_to do |format| if @export_budget.update(export_budget_params) format.html { redirect_to @export_budget, notice: 'Export budget was successfully updated.' } format.json { render :show, status: :ok, location: @export_budget } else format.html { render :edit } format.json { render json: @export_budget.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n budgets = update_budgets(params[:budgets])\n\n render json: budgets, status: :ok\n end", "def update\n respond_to do |format|\n if @budget.update(budget_params)\n Item.where([\"budget_id = #{params[:id]}\"]).update_all(budget_id: nil)\n if !params[:budget][:items].nil?\n...
[ "0.70865214", "0.6602434", "0.6531733", "0.6527077", "0.6527077", "0.64581615", "0.64581615", "0.6326326", "0.63256735", "0.6191894", "0.6118001", "0.6056394", "0.60519725", "0.60293", "0.60031736", "0.6001804", "0.6001043", "0.5991407", "0.59882265", "0.5937003", "0.5888964"...
0.7553417
1
DELETE /export_budgets/1 DELETE /export_budgets/1.json
def destroy @export_budget.destroy respond_to do |format| format.html { redirect_to :back, notice: 'Export budget was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @budget = Budget.find(params[:id])\n @budget.destroy\n\n respond_to do |format|\n format.html { redirect_to budgets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @budget = Budget.find(params[:id])\n @budget.destroy\n respond_to do |format|\n ...
[ "0.7124757", "0.7117221", "0.69661367", "0.68645066", "0.68367815", "0.6817065", "0.6817065", "0.6817065", "0.6806081", "0.6765439", "0.6673919", "0.660283", "0.65861756", "0.6483434", "0.64724207", "0.6471914", "0.64633", "0.6438148", "0.64346224", "0.64345163", "0.64345163"...
0.75227684
1
Use callbacks to share common setup or constraints between actions.
def set_export_budget @export_budget = ExportBudget.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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def export_budget_params # params.require(:export_budget).permit(:year, :title,:town,:pages => [:title_page,:content_page,:last_page,:content => [:public_budget]]) params.require(:export_budget).permit! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Returns the ID of the customer success with most customers
def execute customer_success_attending = @away_customer_success.any? ? fetch_customer_success_attending : @customer_success ordered_customer_success = order_by_score(customer_success_attending) ordered_customers = @customers.empty? ? [] : order_by_score(@customers) distribute_customers_per_customer_success(ordered_customer_success, ordered_customers) customer_success_with_most_customers = group_by_most_attendings(ordered_customer_success) return 0 unless customer_success_with_most_customers[1].count == 1 customer_success_with_most_customers[1].first[:id] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def best_customers\n Invoice.where(merchant_id: self.id)\n .joins(:transactions, :customer)\n .select('customers.*, count(transactions) as most_success')\n .where('transactions.result = ?', 0)\n .group('customers.id')\n .order('most_success desc')\n .l...
[ "0.73630947", "0.6858806", "0.662369", "0.64193577", "0.6311541", "0.62901014", "0.6272751", "0.6252109", "0.6050386", "0.5881546", "0.5833581", "0.58074903", "0.5763817", "0.5755153", "0.5738761", "0.5693936", "0.56691223", "0.5653916", "0.55835515", "0.5535157", "0.5531788"...
0.6535336
3
checks if a given dictionary word from the original dictionary can be made using the given tiles
def check_word(word) letters = make_letter_array(@tiles) w = word.split("") for letter in w if letters.index(letter) letters[letters.index(letter)] = nil letters.compact! else return false end end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def construct_word(word, word_len, dict, twos=@@two_tiles, threes=@@three_tiles, fours=@@four_tiles)\n\t\n\t\tleftover = word_len - word.length\n\t\t\n\t\t# NOTE: I decided to repeat .each routines, as the alternative would mean passing a whole lot of variables to a routine that only executes a few lines of code. ...
[ "0.6588492", "0.65031785", "0.64959717", "0.6491809", "0.6129646", "0.5994317", "0.59269834", "0.58905125", "0.5888142", "0.5878064", "0.5856911", "0.58515334", "0.5843693", "0.5808219", "0.5802023", "0.5760909", "0.57211196", "0.5671177", "0.5657717", "0.56404006", "0.563115...
0.599113
6
returns the dictionary of all valid words for given tiles and their inverses
def check_dictionary(dict) dictionary_redux = [] for word in dict result = check_word(word) if result dictionary_redux << word end end new_dict = add_reversals(dictionary_redux) return new_dict end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_valid \n h = @horizontal.reject { |(x,y),r| x==r }\n v = @vertical.reject { |(x,y),r| y==r }\n\n words = h.map { |position,right|\n x,y = position\n (x..right).map { |x| @board.tile_at([x,y]) }\n }\n words.concat v.map {|position, bottom|\n ...
[ "0.65597695", "0.59374464", "0.5908689", "0.59035337", "0.58894753", "0.5857034", "0.581963", "0.5784805", "0.5776234", "0.5724411", "0.56745124", "0.56719923", "0.5671813", "0.56216055", "0.55539846", "0.5538507", "0.55145586", "0.5502408", "0.5490264", "0.54880303", "0.5434...
0.62545735
1
Remembers a user in a persistent session.
def remember(user) user.remember cookies.permanent.signed[:user_id] = user.id cookies.permanent[:remember_token] = user.remember_token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end", "def change_password\n @user = User.find_by_id(session[:remember_token])\n end", "def log_in_user!(user)\n session[:session_token] = ...
[ "0.675591", "0.6644072", "0.6311052", "0.6311052", "0.62816244", "0.62358135", "0.6200064", "0.6200064", "0.6180077", "0.61798525", "0.6169222", "0.6156497", "0.6137487", "0.61251116", "0.6117853", "0.6090493", "0.60684174", "0.6063047", "0.60603493", "0.605217", "0.6049069",...
0.5917268
72
Returns true if the given user is the current user.
def current_user?(user) user == current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_current_user(user)\n if user == current_user\n return true\n else\n return false\n end\n end", "def is_current_user(user)\n logged_in? && @current_user.id == user.id\n end", "def current_user?(user)\n\t\tcurrent_user == user\n\tend", "def current_user?(user)\n\t\tuser == cu...
[ "0.9062532", "0.8867281", "0.8851428", "0.881641", "0.881641", "0.881641", "0.881641", "0.881641", "0.881641", "0.881641", "0.881641", "0.881641", "0.881641", "0.8816007", "0.87907284", "0.8765191", "0.8765191", "0.8765191", "0.8765191", "0.8765191", "0.8765191", "0.8765191...
0.0
-1
Returns the current loggedin user (if any).
def current_user if (user_id = session[:user_id]) @current_user ||= User.find_by(id: user_id) elsif (user_id = cookies.signed[:user_id]) user = User.find_by(id: user_id) if user && user.authenticated?(:remember, cookies[:remember_token]) log_in user @current_user = user end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end", "def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end", "def current_user\n return unless session[:user_id...
[ "0.85960984", "0.8593657", "0.855797", "0.8545853", "0.8534344", "0.8497545", "0.847914", "0.8460573", "0.8457271", "0.84556973", "0.84472865", "0.8442264", "0.8441092", "0.84366953", "0.8400402", "0.83765614", "0.8368829", "0.8337418", "0.8337418", "0.8314651", "0.8311652", ...
0.0
-1
Returns true if the user is logged in, false otherwise.
def logged_in? !current_user.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end", "def logged_in?\n user._logged_in?\n end", "def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n r...
[ "0.90813833", "0.8762974", "0.87540007", "0.871761", "0.8688184", "0.8648873", "0.86459655", "0.86361825", "0.8630182", "0.8627261", "0.8627261", "0.85820407", "0.85658157", "0.85602945", "0.85602945", "0.8550414", "0.85482794", "0.8543129", "0.85398126", "0.85386676", "0.851...
0.0
-1
Forgets a persistent session.
def forget(user) user.forget cookies.delete(:user_id) cookies.delete(:remember_token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_session!\n raw_session.clear\n end", "def abandon!\n @user = nil\n session.delete\n end", "def abandon!\n @user = nil\n session.delete\n end", "def abandon!\n @user = nil\n session.clear\n end", "def invalidate_session\n @sequence = 0\n ...
[ "0.7149095", "0.7059213", "0.7059213", "0.70340604", "0.69786507", "0.68063825", "0.6668415", "0.6590212", "0.65894204", "0.65851307", "0.65851307", "0.6546038", "0.6429771", "0.6429771", "0.6391262", "0.63660854", "0.63422614", "0.6315281", "0.63146967", "0.62607706", "0.625...
0.0
-1
Logs out the current user.
def log_out forget(current_user) session.delete(:user_id) @current_user = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out\n reset_session\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user = nil\n end", "def log_out\n session.delete(:user_id)\n @current_user ...
[ "0.85847217", "0.8553567", "0.8553567", "0.8553567", "0.8553567", "0.8553567", "0.85448325", "0.85448325", "0.85448325", "0.85448325", "0.85447145", "0.8513818", "0.85132295", "0.85004026", "0.8490199", "0.84505224", "0.84501094", "0.84357476", "0.843385", "0.843385", "0.8433...
0.8369916
70
Redirects to stored location (or to the default).
def redirect_back_or(default) redirect_to(session[:forwarding_url] || default) session.delete(:forwarding_url) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redirect_to_stored(default='/')\n return_to = session[:return_to] || default\n session[:return_to] = nil\n redirect return_to\n end", "def redirect_to_stored_location_or(default)\n redirect_to(session[:forward_url] || default)\n session.delete(:forward_url)\n end", "def redirect_ba...
[ "0.7730111", "0.7649159", "0.704684", "0.7029194", "0.6981081", "0.6871779", "0.67809576", "0.67569697", "0.6699827", "0.65908873", "0.6580519", "0.65731466", "0.65681744", "0.6567211", "0.654002", "0.653624", "0.6530604", "0.65075284", "0.64961356", "0.64893895", "0.6443822"...
0.0
-1
Stores the URL trying to be accessed.
def store_location session[:forwarding_url] = request.original_url if request.get? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store_location\n session[:forwarding_url] = request.url if request.get?\n # Makes sure that the URL is saved only for a GET request because submitting\n # DELETE, PATCH or POST will raise errors when the URL is expecting\n # a GET request.\n end", "def store_location\n # store last url as lon...
[ "0.6911905", "0.6895635", "0.6885458", "0.67844397", "0.67844397", "0.67844397", "0.67844397", "0.67844397", "0.67844397", "0.6695066", "0.6679288", "0.66376084", "0.6633876", "0.6629198", "0.6593085", "0.6593085", "0.6593085", "0.6593085", "0.6592063", "0.65686387", "0.65581...
0.0
-1
Confirms a loggedin user.
def logged_in_user unless logged_in? store_location flash[:danger] = "Please log in." redirect_to login_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correct_user\n @user = User.find(params[:id])\n if !current_user?(@user)\n message = \"currently logged in as #{current_user.name}. Not you? \"\n message += \"#{view_context.link_to('Log out.', log_out)}\".html_safe\n flash[:warning] = message\n redirect_to(root_url)\n ...
[ "0.70087826", "0.6982988", "0.6919373", "0.688131", "0.6845446", "0.68326277", "0.67944413", "0.67929715", "0.6642435", "0.6624581", "0.66114175", "0.66022736", "0.6589018", "0.65539706", "0.65349805", "0.65303934", "0.6512816", "0.650312", "0.64878744", "0.6487622", "0.64804...
0.0
-1
Confirms the correct user.
def correct_user user_id = params[:user_id] || params[:id] || session[:user_id] @user = User.find_by(id: user_id) unless @user.nil? unless current_user?(@user) || current_user.administrator? flash[:danger] = "Only the account owner or an adminstrator to do that." redirect_to(root_path) end else nonexistent_user_error end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def correct_user\n msg = \"You do not have permission to update another user's information\"\n require_correct_user(@user, msg)\n end", "def correct_user\n\t\t\tauthenticate_user!\n\t\t\tunless @user == current_user || current_user.admin?\n\t\t\t\tredirect_to (root_path)\n\t\t\t\tflash[:alert]\n...
[ "0.7474259", "0.73411936", "0.7317917", "0.7183303", "0.7174887", "0.7049758", "0.70130193", "0.7012358", "0.7006517", "0.7006201", "0.7003461", "0.69663024", "0.69136065", "0.6911695", "0.690295", "0.6892608", "0.68439376", "0.6842948", "0.68397075", "0.683463", "0.6826711",...
0.67279315
41
Confirms an administrator user.
def administrator_user unless current_user.administrator? flash[:danger] = "Only an administrator can do that." redirect_to(root_path) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm_admin\n \tunless session[:admin]\n \t\tflash[:notice] = \"You are not an admin.\"\n \t\tredirect_to(user_path( :id => session[:user_id]))\n \tend\n end", "def admin_user\n\t\t\tflash_text = \"Administrative privilege required to perform this action.\"\n\t\t\tflash[:danger] = flash_text unless cu...
[ "0.7336965", "0.7294434", "0.7221028", "0.7094599", "0.7063222", "0.7063222", "0.70558053", "0.70520467", "0.7024281", "0.69845605", "0.6948249", "0.6948249", "0.6920176", "0.6908153", "0.69053614", "0.68236005", "0.68215466", "0.6812401", "0.6775577", "0.6770334", "0.6765672...
0.7330511
1
Stores form data that was entered incorrectly
def store_form_data(type,data) session[type] = data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_values\n self.first_name = @first_name_field.text.strip.chomp\n self.last_name = @last_name_field.text.strip.chomp\n self.email = @email_field.text.strip.chomp\n self.github = @github_field.text.strip.chomp\n self.twitter = @twitter_field.text.strip.chomp\n self.fun_fact = @fun_fact_fiel...
[ "0.5970889", "0.5915759", "0.5806278", "0.5710323", "0.5621386", "0.5597883", "0.55682224", "0.55341727", "0.5475433", "0.5446921", "0.5413465", "0.5412846", "0.53921187", "0.53308517", "0.5308128", "0.5276593", "0.5228124", "0.52257395", "0.5215078", "0.52000785", "0.5194648...
0.54940546
8
Delete stored form data that was entered incorrectly
def forget_form_data(type) session.delete(type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_forms_data\n @forms_data.nil? || @forms_data.clear\n end", "def single_item_action_remove_form_fields(form, document)\n single_item_action_form_fields(form, document, 'remove')\n end", "def delete_form handle_form_text\n click_to_handle_form handle_form_text\n de...
[ "0.63713485", "0.6062579", "0.6004183", "0.5855256", "0.5829446", "0.5769565", "0.57015496", "0.56871647", "0.5650975", "0.56423175", "0.5634057", "0.5633094", "0.55811006", "0.555289", "0.55388856", "0.5536716", "0.55052346", "0.55005515", "0.54896647", "0.5480619", "0.54691...
0.5654744
8
Get stored form data
def get_form_data(my_class,type) my_class.new(session[type]) unless session[type].nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def form_data\n session[\"form_data\"].nil? ? params : JSON.parse(session[\"form_data\"])\n end", "def form_field_data\n @attributes[:form_field_data]\n end", "def form_data?; end", "def data\n @field.widget.value_from_formdata(@form.data, @html_name)\n end", "def form_data=(dat...
[ "0.7457978", "0.72240597", "0.71780986", "0.68642616", "0.6664833", "0.6656767", "0.66216385", "0.6374409", "0.63553625", "0.6313211", "0.6298149", "0.6247504", "0.61912787", "0.61226165", "0.5964709", "0.58886707", "0.5871895", "0.5852051", "0.58491945", "0.58333147", "0.575...
0.552423
51
GET /brothers/1 GET /brothers/1.json
def show @brother = Brother.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @brother } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @brothers = Brother.all\n @brother = Brother.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @brother }\n end\n end", "def index\n @brothers = Brother.all\n\n respond_to do |format|\n format.html # index.html.e...
[ "0.67831814", "0.6519778", "0.6460452", "0.64538556", "0.64479095", "0.6350875", "0.6316107", "0.62831056", "0.62824655", "0.62755793", "0.6224052", "0.6218453", "0.6191556", "0.6189039", "0.61557543", "0.615159", "0.61464834", "0.613041", "0.6125705", "0.6106855", "0.6104007...
0.7428551
0
GET /brothers/new GET /brothers/new.json
def new @brother = Brother.new respond_to do |format| format.html # new.html.erb format.json { render json: @brother } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @brother = Brother.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @brother }\n end\n end", "def new\n @neighborhood = Neighborhood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ne...
[ "0.72790605", "0.72424227", "0.72424227", "0.72308916", "0.72308916", "0.71890324", "0.7178286", "0.71629953", "0.71312666", "0.70962596", "0.70483905", "0.7040475", "0.7011177", "0.7010174", "0.6997991", "0.69556075", "0.6937822", "0.69256485", "0.69250315", "0.69229984", "0...
0.80829954
0
POST /brothers POST /brothers.json
def create @brother = Brother.new(params[:brother]) respond_to do |format| if @brother.save format.html { redirect_to @brother, notice: 'Cadastro atualizado com sucesso.' } format.json { render json: @brother, status: :created, location: @brother } else format.html { render action: "new" } format.json { render json: @brother.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @brother = Brother.new(params[:brother])\n\n respond_to do |format|\n if @brother.save\n flash[:notice] = 'Brother was successfully created.'\n format.html { render :back }\n format.xml { render :xml => @brother, :status => :created, :location => @brother }\n else...
[ "0.6466032", "0.6211106", "0.60093606", "0.59345394", "0.5867465", "0.5820366", "0.5792608", "0.57537764", "0.5731565", "0.57216257", "0.56253964", "0.5610201", "0.5601729", "0.5597856", "0.5586489", "0.5586489", "0.55731267", "0.55707574", "0.5569151", "0.5549769", "0.554194...
0.6761459
0
PUT /brothers/1 PUT /brothers/1.json
def update @brother = Brother.find(params[:id]) respond_to do |format| if @brother.update_attributes(params[:brother]) format.html { redirect_to @brother, notice: 'Cadastro atualizado com sucesso.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @brother.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @brother = Brother.find(params[:id])\n\n respond_to do |format|\n if @brother.update_attributes(params[:brother])\n flash[:notice] = 'Brother was successfully updated.'\n format.html { redirect_to roster_show_path(@brother) }\n format.xml { head :ok }\n else\n ...
[ "0.6104035", "0.60589164", "0.5952275", "0.59332794", "0.59122056", "0.57768595", "0.57257557", "0.5720278", "0.57149225", "0.56968457", "0.568262", "0.5672292", "0.5654336", "0.56326383", "0.56300616", "0.56052566", "0.55928266", "0.5584219", "0.55590075", "0.554855", "0.554...
0.6645645
0
DELETE /brothers/1 DELETE /brothers/1.json
def destroy @brother = Brother.find(params[:id]) @brother.destroy respond_to do |format| format.html { redirect_to brothers_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @brother = Brother.find(params[:id])\n @brother.destroy\n\n respond_to do |format|\n format.html { redirect_to(brothers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @brohoof = Brohoof.find(params[:id])\n @brohoof.destroy\n\n respond_to do |format|\n...
[ "0.72989035", "0.69535923", "0.69262016", "0.6899237", "0.6887502", "0.68759006", "0.68281394", "0.6821217", "0.6782569", "0.67393094", "0.6728552", "0.67242306", "0.66811126", "0.66722196", "0.66638386", "0.66624045", "0.66524476", "0.66489494", "0.6648019", "0.6642682", "0....
0.7612961
0
end user auth stuff
def currentHand #finds current hand during game self.hands.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth\n end", "def auth\n end", "def destroy_auth\n\t\tsession[:user_id] = nil\n\t\tredirect_to root_path\n\tend", "def endscreen\n @user = nil\n login\nend", "def auth_user\n redirect_to new_user_session_url unless user_signed_in?\n end", "def after_custom_authentication; end", "def tea...
[ "0.70541954", "0.70541954", "0.670564", "0.657376", "0.65385485", "0.6523281", "0.6472897", "0.64707947", "0.6462708", "0.6431547", "0.6421424", "0.64102525", "0.63444734", "0.63045686", "0.6300721", "0.6300721", "0.6300721", "0.6287041", "0.6286316", "0.62838674", "0.6267622...
0.0
-1
Inspect the file referenced in the kubectl stderr to make it easier for developer to understand what's going on
def inspect_kubectl_out_for_files(stderr) # Output example: # Error from server (BadRequest): error when creating "/path/to/configmap-gqq5oh.yml20170411-33615-t0t3m": match = stderr.match(%r{BadRequest.*"(?<path>\/\S+\.yml\S+)"}) return unless match path = match[:path] if path.present? && File.file?(path) suspicious_file = File.read(path) KubernetesDeploy.logger.warn("Inspecting the file mentioned in the error message (#{path})") KubernetesDeploy.logger.warn(suspicious_file) else KubernetesDeploy.logger.warn("Detected a file (#{path.inspect}) referenced in the kubectl stderr " \ "but was unable to inspect it") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stderr\n \"#{dir}__job.stderr\"\n end", "def chef_error(e)\n if e.is_a?(::RightScale::Exceptions::Exec)\n msg = \"External command error: \"\n if match = /RightScale::Exceptions::Exec: (.*)/.match(e.message)\n cmd_output = match[1]\n else\n cmd_output = e.m...
[ "0.56038433", "0.54105234", "0.5351739", "0.5315673", "0.5247662", "0.5230266", "0.52056587", "0.51863414", "0.5159915", "0.50922036", "0.50868344", "0.5082352", "0.5082352", "0.5082352", "0.5082352", "0.5057147", "0.5043923", "0.5039056", "0.50374234", "0.50092894", "0.50051...
0.7479636
0
DISPLAY_BOARD Should accept a board as an argument and print out the current state of the board for the user.
def display_board(board) puts " #{board[0]} " "|" " #{board[1]} " "|" " #{board[2]} " puts "-----------" puts " #{board[3]} " "|" " #{board[4]} " "|" " #{board[5]} " puts "-----------" puts " #{board[6]} " "|" " #{board[7]} " "|" " #{board[8]} " end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_board\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend", "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"--------...
[ "0.76173735", "0.7579887", "0.7579887", "0.7548516", "0.7545671", "0.75404227", "0.7484964", "0.74778295", "0.7472563", "0.74558", "0.744315", "0.7424092", "0.7424092", "0.7376109", "0.7361076", "0.7348736", "0.7341896", "0.7341896", "0.7341896", "0.7341896", "0.7341896", "...
0.0
-1
INPUT_TO_INDEX convert input to index
def input_to_index(user_input) index = user_input.to_i - 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input_to_index(input)\n index = input.to_i - 1\n end", "def input_to_index(input)\n index = input.to_i - 1\n end", "def input_to_index(input)\n index = input.to_i - 1\n end", "def input_to_index(input)\n input_int = input.to_i\n index = input_int - 1\nend", "def input_to_index(input)\n #...
[ "0.80348045", "0.80348045", "0.80348045", "0.7754606", "0.77542037", "0.7719133", "0.7689075", "0.76875436", "0.76393837", "0.76328695", "0.75974524", "0.7592872", "0.758357", "0.758357", "0.7532466", "0.7532466", "0.7528449", "0.752264", "0.75185645", "0.7486758", "0.7482508...
0.7231833
34
VALID_MOVE? Should accept a board and an index from the user and return true if the index is within the correct range of 08 and is currently unoccupied by an X or O token. Hint: While not explicitly required by this lab, you might want to encapsulate the logic to check if a position is occupied in its own method, perhaps position_taken?
def valid_move?(board, index) if index.between?(0, 8) # re-define your #position_taken? method here, so that you can use it in the #valid_move? method above. def position_taken?(board, index) if board[index] == " " !false elsif board[index] == "" !false elsif board[index] == nil !false elsif board[index] == "X" || board[index] == "O" !true end end position_taken?(board, index) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_move?(board, index)\n if position_taken?(board, index)\n false\n elsif index.between?(0, 8)\n true\n end\nend", "def valid_move?(board, index)\n !position_taken?(board, index) && index.between?(0, 8)\nend", "def valid_move?(board, index)\n if !position_taken?(board, index) && index.between...
[ "0.8777406", "0.8740289", "0.873629", "0.87340057", "0.873219", "0.87258273", "0.87258273", "0.87258273", "0.87243336", "0.8723622", "0.87199694", "0.87199694", "0.87199694", "0.87199694", "0.87199694", "0.87199694", "0.87199694", "0.87199694", "0.87199694", "0.87199694", "0....
0.0
-1
Common intersected stop for all the three lines
def getCommonStation @common_station end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_line(stop1, stop2)\n if @purple_line.include?(stop1) && @purple_line.include?(stop2)\n \"either\"\n elsif @purple_line.include?(stop1) && @blue_line_west.include?(stop2)\n \"blue\"\n elsif @purple_line.include?(stop1) && @red_line_only.include?(stop2)\n \"red\"\n elsif @red...
[ "0.6422492", "0.63610756", "0.6301229", "0.6251706", "0.6182258", "0.61659557", "0.60998935", "0.6080237", "0.6048151", "0.60255915", "0.59983194", "0.5922342", "0.5824108", "0.5824108", "0.5824108", "0.5821958", "0.58083475", "0.57616735", "0.5754628", "0.5747442", "0.568724...
0.0
-1
get the lines hash object
def getLines @lines end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_hash\n Hash[ *(map { |line| [line.key, line] }).flatten ]\n end", "def lines\n @lines ||= build_lines\n end", "def lines\n @lines ||= line_codes.map {|l| Line.get(l)}\n end", "def process_lines\n\t#file_string is a string array,\n\t#extendable_hash is a hash that is created thr...
[ "0.6546754", "0.65418655", "0.64126307", "0.6276187", "0.61619484", "0.6139667", "0.60879976", "0.6072377", "0.6065265", "0.605903", "0.6048124", "0.60414183", "0.6040343", "0.60105085", "0.60105085", "0.59932464", "0.5989374", "0.5947223", "0.59408617", "0.58206403", "0.5813...
0.61386997
6
the question max score is the max score of the questionnaire, except if the question is a true/false, in which case the max score is one.
def question_max_score question = Question.find(self.question_id) if question.type == "Checkbox" return 1 elsif question.is_a? ScoredQuestion @question_max_score else "N/A" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_maximum_score()\n max_score = 0\n\n self.scores.each { |score| max_score = max_score + score.question.questionnaire.max_question_score }\n\n max_score\n end", "def max_score(creative_quality)\n max_score = 0\n self.question_responses\n .select{|el| max_score += el.question.question_cho...
[ "0.79807544", "0.7314736", "0.71533525", "0.70973194", "0.7061899", "0.702873", "0.70216316", "0.69702077", "0.67640877", "0.6742938", "0.6736504", "0.6735746", "0.6650699", "0.6577726", "0.6536788", "0.652327", "0.6481408", "0.6450408", "0.63993376", "0.6363122", "0.63475907...
0.8718923
1
Initialize an empty array of loaders.
def initialize @roots = {} @ordered = Array.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loaders\n @loaders ||= profile.loaders\n end", "def initialize(parent_loader, loaders, module_name, path, loader_name, loadables = LOADABLE_KINDS)\n super\n @path_index = Set.new\n end", "def instantiate_modules\n mods = Array(modules)\n mods = load!(mods) if callback?(:load)...
[ "0.7213359", "0.6257221", "0.606636", "0.5897861", "0.5824166", "0.58073574", "0.5804754", "0.5773121", "0.5763127", "0.56880045", "0.56823254", "0.56823254", "0.5667685", "0.55950236", "0.5583014", "0.5579116", "0.55786663", "0.5545126", "0.55282784", "0.5521089", "0.5457819...
0.0
-1
Whether any loaders are defined.
def empty? @ordered.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loading?\n !load_stack.empty?\n end", "def loadable?\n %w(test development).include?(Rails.env) || !loaded?\n end", "def has_classes_or_modules?\n has_classes? || has_modules?\n end", "def has_assets?\n assets.none?\n end", "def has_includes?\n @context.includes.length ...
[ "0.70104516", "0.6803148", "0.67900383", "0.6699241", "0.6563936", "0.6551992", "0.6551992", "0.6534312", "0.6500152", "0.6497048", "0.6460796", "0.64527583", "0.6450757", "0.64465064", "0.64465064", "0.64439017", "0.64380276", "0.6425917", "0.6421785", "0.64194757", "0.64130...
0.0
-1
Add loaders according to the current working directory and loaded gems.
def append_defaults(working_directory) # Load recipes from working directory: self.append_path(working_directory) # Load recipes from loaded gems: self.append_from_gems end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_loader(loader)\n @loaders << loader\n end", "def add_loader(ext, loader)\n ext = \".#{ext}\" unless ext =~ /^\\./\n @loaders[ext] = loader\n end", "def loaders\n @loaders ||= profile.loaders\n end", "def loader_for_gem(root_file)\n loaders_managing_gems[root_file] ...
[ "0.6958738", "0.6769579", "0.67014104", "0.6690688", "0.6512384", "0.6338011", "0.6273093", "0.6265319", "0.6259796", "0.61743593", "0.6166281", "0.61078006", "0.6106352", "0.5996599", "0.5953585", "0.5948297", "0.5878427", "0.5869075", "0.58575153", "0.5810175", "0.58043027"...
0.0
-1
Enumerate the loaders in order.
def each(&block) @ordered.each(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eager_load_all\n Registry.loaders.each(&:eager_load)\n end", "def loaders\n @loaders ||= profile.loaders\n end", "def enumerate_available path\n trace :loading, \"Enumerating under #{path.inspect}\" do\n Loadable.new(path).\n enumerate.\n map do |filename|\n beg...
[ "0.6469344", "0.63590944", "0.5967607", "0.5807772", "0.5679374", "0.55955046", "0.55936867", "0.55761826", "0.5503", "0.54998714", "0.5471823", "0.5432709", "0.54241973", "0.53220826", "0.52880293", "0.52799827", "0.5246397", "0.5246397", "0.5221942", "0.5210524", "0.5170697...
0.0
-1
Append a specific project path to the search path for recipes. The computed path will have `bake` appended to it.
def append_path(current = Dir.pwd, **options) bake_path = File.join(current, "bake") if File.directory?(bake_path) return insert(bake_path, **options) end return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append_path(path)\n @paths.push(File.expand_path(path, root))\n end", "def append_path(path)\n mutate_config(:paths) do |paths|\n path = File.expand_path(path, root).dup.freeze\n paths.push(path)\n end\n end", "def recipe_path(recipe_name, target_name=recipe_name, mode=07...
[ "0.6082594", "0.6030097", "0.54458094", "0.54321307", "0.54231465", "0.53517425", "0.5346747", "0.5346091", "0.5333329", "0.5313596", "0.52504045", "0.51761323", "0.5155627", "0.50925446", "0.50910854", "0.50903577", "0.50615364", "0.5038487", "0.50376916", "0.5033187", "0.50...
0.6025862
2
Search from the current working directory until a suitable bakefile is found and add it.
def append_from_root(current = Dir.pwd, **options) while current Console.logger.debug(self) {"Checking current #{current}..."} append_path(current, **options) parent = File.dirname(current) if current == parent break else current = parent end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def look_for_default_recipe_file! #:nodoc:\n current = Dir.pwd\n\n loop do\n %w(Capfile capfile).each do |file|\n if File.file?(file)\n options[:recipes] << file\n return\n end\n end\n\n pwd = Dir.pwd\n Dir.chdir(\".....
[ "0.6172704", "0.5901362", "0.584487", "0.56504875", "0.5535056", "0.54181826", "0.52999705", "0.5185311", "0.5165647", "0.5159209", "0.5153402", "0.5129354", "0.5125458", "0.51127267", "0.51035696", "0.5097743", "0.50874895", "0.50675446", "0.50660783", "0.5060657", "0.504005...
0.0
-1
Enumerate all loaded gems and add them.
def append_from_gems ::Gem.loaded_specs.each do |name, spec| Console.logger.debug(self) {"Checking gem #{name}: #{spec.full_gem_path}..."} if path = spec.full_gem_path and File.directory?(path) append_path(path, name: spec.full_name) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gems(*args)\n gems.each{|g| gem(g) }\n end", "def add_gems\n add_gems_mutex = get_mutex 'add_gems'\n\n add_gems_mutex.synchronize do\n break unless @gem_queue.empty?\n\n @swift.paginate_objects @gems_container do |object_info|\n @gem_queue.enq object_info['name']\n end\n ...
[ "0.69318855", "0.6896375", "0.68240154", "0.6698656", "0.65583885", "0.64724356", "0.64542335", "0.6431579", "0.6413541", "0.6395281", "0.63546485", "0.63410026", "0.6337361", "0.63278574", "0.63278574", "0.63278574", "0.63274044", "0.6273701", "0.62305623", "0.6224238", "0.6...
0.6800024
3
has_many :months, through: :years
def set_urut if self.month.bulan == 'Januari' self.urut = 1 elsif self.month.bulan == 'Februari' self.urut = 2 elsif self.month.bulan == 'Maret' self.urut = 3 elsif self.month.bulan == 'April' self.urut = 4 elsif self.month.bulan == 'Mei' self.urut = 5 elsif self.month.bulan == 'Juni' self.urut = 6 elsif self.month.bulan == 'Juli' self.urut = 7 elsif self.month.bulan == 'Agustus' self.urut = 8 elsif self.month.bulan == 'September' self.urut = 9 elsif self.month.bulan == 'Oktober' self.urut = 10 elsif self.month.bulan == 'November' self.urut = 11 elsif self.month.bulan == 'Desember' self.urut = 12 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def months\n @years * 12\n end", "def months; self * MONTH; end", "def associated_months\n result = [] # expect no months if no dates\n years = associated_years\n \n\t start_date = event_start\n\t start_date = entry_deadline if is_opportunity?\n\t \t \n start_month_year = Ti...
[ "0.6522529", "0.63244814", "0.61449414", "0.61361724", "0.61064523", "0.60459274", "0.5997878", "0.5933426", "0.5920522", "0.59103644", "0.58216566", "0.5768318", "0.5764634", "0.57090944", "0.5697174", "0.5643094", "0.5639142", "0.55642974", "0.55642974", "0.55642605", "0.55...
0.0
-1
Devuelve un array con los email de tus contactos de gmail
def contacts_gmail_email(contacts) @hash_contactos = Hash.new @contact_email = [] contacts.each {|lista| lista.each {|key,value| if (key == :email) @contact_email << value end } } return @contact_email end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def emails\n self[\"gd$email\"] ? self[\"gd$email\"].map { |e| e.address } : []\n end", "def emails\n Array(@emails)\n end", "def getEmailList\n\t\tdata = index()\n\t\temailList = []\n\t\tdata.each do |person|\n\t\t\temailList.push(\"#{person[\"email_address\"]}\")\n\t\tend\n\t\treturn emailLis...
[ "0.75003815", "0.7323449", "0.7223449", "0.7215217", "0.7199187", "0.71222275", "0.7070534", "0.70284665", "0.69598526", "0.6809422", "0.6738477", "0.6727385", "0.67266846", "0.66951585", "0.6684176", "0.6680344", "0.667053", "0.6644871", "0.660687", "0.65794307", "0.65697116...
0.76919174
0
Busca en la tabla usuarios los email y devuelve los que ya estan > agregar amigos
def add_new_friends(emails) @list_email = [] emails.each {|email| @list_email << email if already_exits?(email) } @list_email_no_friend = [] list_email.each {|email| id_email = get_id_by_email(email) #TODO: Sacar mi id de la sesion if !is_friend?(id_usuario_de_la_sesion,id_email) @list_email_no_friend << email end } return @list_email_no_friend end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_user_emails_for_edit\n @edit[:user_emails] = {}\n to_email = @edit[:new][:email][:to] || []\n users_in_current_groups = User.with_groups(User.current_user.miq_groups).distinct.sort_by { |u| u.name.downcase }\n users_in_current_groups.each do |u|\n next if u.email.blank?\n next if to...
[ "0.616047", "0.5944903", "0.5830487", "0.5655905", "0.55667967", "0.55326265", "0.5519343", "0.5499764", "0.5458312", "0.5456736", "0.54508513", "0.5449318", "0.5449297", "0.5445801", "0.544288", "0.5361915", "0.5354674", "0.5353646", "0.5343716", "0.53362054", "0.53282547", ...
0.5008871
85
Buscamos en la tabla usuarios los emails, devolvemos los que no esten > invitar personas
def add_new_contacts(emails) @list_email = [] emails.each {|email| @list_email << email if !already_exits?(email) } return @list_email end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete_email_list\n #Email.select(:email).map{|email_record| email_record.email}\n User.all.map(&:email)\n end", "def index\n @usuarios_emails = UsuariosEmail.all\n end", "def get_reg_users(guest_emails)\n g_arr = Array.new\n guest_emails.split(\",\").each do |e|\n # add user ...
[ "0.6641623", "0.64631045", "0.6461937", "0.6350435", "0.6322121", "0.63143635", "0.6282568", "0.6160918", "0.6085946", "0.6085378", "0.60636866", "0.60064137", "0.6005424", "0.6004359", "0.5991073", "0.5967878", "0.59591496", "0.5921857", "0.5913721", "0.58975244", "0.5891260...
0.0
-1
Devolver si es amigo o no
def is_friend?(follower_id,following_id) Follow.where(follower_id: follower_id).where(following_id: following_id).exists? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def semact?; false; end", "def placebo?; false end", "def suivre; end", "def positive?; end", "def delicious?\n\t\treturn true\n\tend", "def usable?; end", "def used?; end", "def isolated?; end", "def isolated?; end", "def delicious?\n #its automattically true\n true\n end", "def absent?...
[ "0.7175963", "0.6922928", "0.66088533", "0.65619004", "0.654149", "0.6457825", "0.6451403", "0.64073837", "0.64073837", "0.6385908", "0.6324781", "0.6291342", "0.6267003", "0.62651056", "0.62016547", "0.6200845", "0.6182826", "0.6176957", "0.61622536", "0.61503667", "0.614933...
0.0
-1
Sends an invite to a resident, from the given user Params: resident user
def deliver_invite_to_resident(resident, user) enqueue(ResidentInvitation, resident.id, user.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deliver_invite_to_resident(resident, user)\n return\n end", "def invite(user)\n participation = @tandem.participations.create(\n user:user,\n token: generate_token\n )\n\n send_invitation_mail participation\n true\n end", "def invite(user, data = {})\n @user = user\n @u...
[ "0.7875361", "0.7409569", "0.72580934", "0.71687394", "0.7155036", "0.7117217", "0.7102348", "0.70202494", "0.6974214", "0.69494957", "0.69450635", "0.68922514", "0.6872253", "0.6859638", "0.6843247", "0.68290806", "0.68261147", "0.6823207", "0.6821242", "0.6817716", "0.67828...
0.7767632
1
Select Children Entity of File Entity
def test_cases(email_id = nil, root_folder = nil) file_selector(root_folder).email_id(email_id) .map(&:test_cases).reject(&:empty?).flatten.unwrap end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def children\n c = file_log.children(file_node)\n c.map do |x|\n VersionedFile.new(@repo, @path, :file_id => x, :file_log => file_log)\n end \n end", "def children\n# Dir[file_path + '/*'].map do |path|\n# child File.basename(path)\n# end\n @collection.find(...
[ "0.65462726", "0.62598735", "0.6126877", "0.6052726", "0.59739906", "0.58670396", "0.5845405", "0.5786994", "0.57763016", "0.57571495", "0.5747008", "0.57430923", "0.5725942", "0.5724671", "0.5688765", "0.56602407", "0.5643537", "0.56219006", "0.5613663", "0.55840254", "0.558...
0.0
-1
def owned_methods(email_id, folder = nil) all_methods(nil, folder).select do |method| method.line_percentage[email_id].to_i >= threshold end end
def complexity_methods(email_id = nil) file_selector.to_methods.too_complexity(15).unwrap.map do |method| if email_id 1.0 * (method.line_percentage[email_id].to_f / 100) else 1 end end.sum.round end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filtered_methods\n @filtered_methods ||= []\n end", "def filter_methods; end", "def report_methods cm\n return if cm.method_list.empty?\n\n report = []\n\n cm.each_method do |method|\n next if method.documented? and @coverage_level.zero?\n\n if @coverage_level > 0 then\n param...
[ "0.5408398", "0.528725", "0.51977926", "0.51311713", "0.51252735", "0.5055385", "0.49779195", "0.49562535", "0.49326468", "0.49144018", "0.4911979", "0.4907823", "0.4881014", "0.48604232", "0.48261976", "0.47978246", "0.4793017", "0.47929212", "0.47819003", "0.47785315", "0.4...
0.6775092
0
maintains previous file number values while allowing for reseeding
def file_number_initial_value @file_number ||= 100_000 # this seed file creates 40 new veterans on each run, 100 is sufficient margin to add more data @file_number += 100 while Veteran.find_by(file_number: format("%<n>09d", n: @file_number)) @file_number end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_num_generate\n \t\t_random(6) + \"#{file_uid}\"\n\tend", "def next_file_number\r\n most_recent_file_number + 1\r\n end", "def auto_tracknumber\n i = 0\n @files.each { |file|\n next unless @selected_files.include? file\n file.set_values('TRACKNUMBER', (i+1).to_s)...
[ "0.66594434", "0.6558658", "0.65488243", "0.64710116", "0.63970584", "0.6373229", "0.6373229", "0.6373229", "0.6373229", "0.6373229", "0.6373229", "0.6373229", "0.6368856", "0.63578445", "0.63262576", "0.61928105", "0.60107714", "0.5927393", "0.590658", "0.5809058", "0.579503...
0.71149606
0
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
def vacate_at_attorney_review(mtv_judge, drafting_attorney, lit_support_user) # These are ready to be reviewed by the decision drafting attorney on the vacate stream 3.times do original_stream = create_decided_appeal(mtv_judge, drafting_attorney) mtv_task = create_motion_to_vacate_mail_task(original_stream) mtv_task.update!(status: "on_hold") jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "denied") judge_addresses_mtv(jam_task, "denied", nil, lit_support_user) end 3.times do original_stream = create_decided_appeal(mtv_judge, drafting_attorney) mtv_task = create_motion_to_vacate_mail_task(original_stream) mtv_task.update!(status: "on_hold") jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "dismissed") judge_addresses_mtv(jam_task, "dismissed", nil, lit_support_user) end 3.times do original_stream = create_decided_appeal(mtv_judge, drafting_attorney) mtv_task = create_motion_to_vacate_mail_task(original_stream) mtv_task.update!(status: "on_hold") jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted") judge_addresses_mtv(jam_task, "granted", "straight_vacate", drafting_attorney) end 3.times do original_stream = create_decided_appeal(mtv_judge, drafting_attorney) mtv_task = create_motion_to_vacate_mail_task(original_stream) mtv_task.update!(status: "on_hold") jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted") judge_addresses_mtv(jam_task, "granted", "vacate_and_readjudication", drafting_attorney) end 3.times do original_stream = create_decided_appeal(mtv_judge, drafting_attorney) mtv_task = create_motion_to_vacate_mail_task(original_stream) mtv_task.update!(status: "on_hold") jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted") judge_addresses_mtv(jam_task, "granted", "vacate_and_de_novo", drafting_attorney) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def offences_by; end", "def strategy; end", "def used?; end", "def custo...
[ "0.765617", "0.6290868", "0.6230358", "0.6230358", "0.61819583", "0.6159073", "0.6159073", "0.6159073", "0.6159073", "0.61298186", "0.59577805", "0.5946047", "0.5894433", "0.5822073", "0.5822073", "0.58099234", "0.58099234", "0.5807123", "0.57961935", "0.5735039", "0.5690081"...
0.0
-1
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize rubocop:disable Metrics/MethodLength
def fully_processed_vacate_appeal(mtv_judge, drafting_attorney, lit_support_user) 3.times do original_stream = create_decided_appeal(mtv_judge, drafting_attorney) mtv_task = create_motion_to_vacate_mail_task(original_stream) mtv_task.update!(status: "on_hold") jam_task = send_mtv_to_judge(original_stream, mtv_judge, lit_support_user, mtv_task, "granted") post_decision_motion = judge_addresses_mtv(jam_task, "granted", "vacate_and_de_novo", drafting_attorney) vacate_stream = post_decision_motion.appeal jdr_task = vacate_stream.tasks.find_by(type: "JudgeDecisionReviewTask") attorney_task = jdr_task.children.find_by(type: "AttorneyTask") [jdr_task, attorney_task].each { |t| t.update!(status: "completed") } root_task = vacate_stream.tasks.find_by(type: "RootTask") BvaDispatchTask.create_from_root_task(root_task) dispatch_user = vacate_stream.tasks .reload.assigned_to_any_user.find_by(type: "BvaDispatchTask").assigned_to last_six = original_stream.veteran.file_number[-6..-1] citation_number = "A19#{last_six}" outcode_params = { citation_number: citation_number, decision_date: Time.zone.now, redacted_document_location: "\\\\bvacofil1.dva.va.gov\\archdata$\\arch1901\\#{citation_number}.txt", file: last_six } BvaDispatchTask.outcode(vacate_stream.reload, outcode_params, dispatch_user) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def schubert; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def custom; end", "def custom; end", "def strategy; end", "def offences_...
[ "0.76603997", "0.64038944", "0.6309454", "0.6309454", "0.62159014", "0.6211626", "0.6132683", "0.6132683", "0.6132683", "0.6132683", "0.5941469", "0.5941469", "0.5925082", "0.5923184", "0.59110045", "0.5883552", "0.587536", "0.587536", "0.5871816", "0.5847384", "0.58034223", ...
0.0
-1
GET /order_items GET /order_items.json
def index @order_items = OrderItem.where(deal_id: params[:deal_id]).order("created_at DESC").page(params[:page]).per(5) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @order_items = OrderItem.all\n # render json: @order_item, status: :created\n # render json: @order_item.as_json(include: :item)\n\n end", "def index\n @order_line_items = @order.order_line_items\n\n render json: @order_line_items\n end", "def show\n @order = Order.find(request[:...
[ "0.77639645", "0.77324706", "0.757844", "0.7544158", "0.7426385", "0.7392113", "0.7380861", "0.7173808", "0.7167277", "0.7163156", "0.7154946", "0.7152882", "0.7142722", "0.7101051", "0.7025074", "0.7025074", "0.7025074", "0.7022062", "0.7006934", "0.69940186", "0.6992866", ...
0.0
-1
GET /order_items/1 GET /order_items/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @order = Order.find(request[:order_id])\n @order_item = @order.order_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order_item }\n end\n end", "def index\n @order_items = OrderItem.all\n # render json: @order_...
[ "0.77925336", "0.75096756", "0.746528", "0.7419868", "0.7324154", "0.732138", "0.732138", "0.732138", "0.7269875", "0.72579354", "0.7254903", "0.71073955", "0.71066314", "0.70790046", "0.70769566", "0.7068799", "0.7018789", "0.69945437", "0.69678044", "0.6893998", "0.67697597...
0.0
-1
POST /order_items POST /order_items.json
def create @order_item = OrderItem.new(order_item_params) respond_to do |format| if @order_item.save format.html { redirect_to @order_item, notice: '成功创建订单项目!' } format.json { render :show, status: :created, location: @order_item } else format.html { render :new } format.json { render json: @order_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @order_item = OrderItem.new(order_items_params)\n\n respond_to do |format|\n if @order_item.save\n format.html { redirect_to @order_item, notice: \"Order item was successfully created.\" }\n format.json { render json: @order_item, status: :created, location: @order_item }\n ...
[ "0.7376621", "0.7354197", "0.73392534", "0.7206495", "0.7199507", "0.71602315", "0.7092501", "0.6968247", "0.6902384", "0.68802124", "0.68724215", "0.6868365", "0.6807257", "0.6797156", "0.6774272", "0.67573595", "0.67440546", "0.6721686", "0.666089", "0.66552764", "0.6621188...
0.64350766
35
PATCH/PUT /order_items/1 PATCH/PUT /order_items/1.json
def update respond_to do |format| if @order_item.update(order_item_params) format.html { redirect_to @order_item, notice: '成功更新订单项目!' } format.json { render :show, status: :ok, location: @order_item } else format.html { render :edit } format.json { render json: @order_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @order = Order.find(request[:order_id])\n @order_item = @order.order_items.find(params[:id])\n\n respond_to do |format|\n if @order_item.update_attributes(params[:order_item])\n format.html { redirect_to [@order, @order_item], notice: 'Order Item was successfully updated.' }\n ...
[ "0.73584485", "0.73085594", "0.7268084", "0.7251094", "0.7163649", "0.7150832", "0.71481746", "0.7033415", "0.7033415", "0.7020219", "0.69194925", "0.68931943", "0.6845944", "0.68067646", "0.67961067", "0.6782734", "0.67605895", "0.6758097", "0.6731265", "0.6728509", "0.67191...
0.64298946
40
DELETE /order_items/1 DELETE /order_items/1.json
def destroy @order_item.destroy respond_to do |format| format.html { redirect_to order_items_url, notice: '成功删除订单项目!' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @order_item.destroy\n\n render json: { operation: 'OK' }, status: :ok\n end", "def destroy\n @order = Order.find(params[:order_id])\n @order_item = @order.order_items.find(params[:id])\n @order_item.destroy\n\n respond_to do |format|\n format.html { redirect_to order_order_i...
[ "0.7897787", "0.7759607", "0.7612084", "0.7612084", "0.76079386", "0.751049", "0.751049", "0.7484588", "0.73727953", "0.7366761", "0.72802234", "0.72445196", "0.72379076", "0.7165061", "0.7161339", "0.7150915", "0.71417683", "0.7120653", "0.7064155", "0.70632917", "0.7020535"...
0.69449836
25
Use callbacks to share common setup or constraints between actions.
def set_order_item @order_item = OrderItem.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def order_item_params params.require(:order_item).permit(:deal_id, :serv_offer_id, :serv_offer_user_name, :serv_offer_titile, :lately_chat_content, :offer_user_id, :request_user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6981273", "0.6783789", "0.67460483", "0.6742222", "0.67354137", "0.65934366", "0.65028495", "0.6497783", "0.64826745", "0.6479415", "0.6456823", "0.6440081", "0.63800216", "0.6376521", "0.636652", "0.6319898", "0.6300256", "0.62994003", "0.6293621", "0.6292629", "0.6291586...
0.0
-1
Create a Customer using a predefined XML template as a REST request.
def create(name="Default name") xml_req = "<?xml version='1.0' encoding='UTF-8'?> <customer> <name>#{name}</name> </customer>" request = Net::HTTP::Post.new(@url) request.add_field "Content-Type", "application/xml" request.body = xml_req http = Net::HTTP.new(@uri.host, @uri.port) response = http.request(request) response.body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_customer(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n response = post(\"customers\",options)\n if response['success']\n return response['results']['customer']\n else\n return response\n end\n end", "def create_customer(options = {...
[ "0.7364722", "0.7239721", "0.7223057", "0.7203944", "0.7150991", "0.7072596", "0.7033259", "0.698657", "0.697075", "0.6887057", "0.6811839", "0.6810424", "0.6802065", "0.6773241", "0.6728933", "0.67265713", "0.67158604", "0.6685042", "0.66801244", "0.6666459", "0.6666459", ...
0.71268785
5
Read can get all customers with no arguments or get one customer with one argument. For example: customer_api = customer_api.new customer_api.read 2 => one customer customer_api.read => all customers
def read(id=nil) request = Net::HTTP.new(@uri.host, @uri.port) if id.nil? response = request.get("#{@uri.path}.xml") else response = request.get("#{@uri.path}/#{id}.xml") end response.body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_customer(id)\n get(\"customers/#{id}\")\n end", "def get_customer(id)\n get(\"customers/#{id}\")\n end", "def get_customer_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CustomerApi.get_customer_all_using_get...
[ "0.66092145", "0.66092145", "0.6608839", "0.64987445", "0.62481326", "0.62453616", "0.6194944", "0.6124262", "0.6096411", "0.60867864", "0.5989913", "0.59816", "0.5981485", "0.5968173", "0.5959214", "0.58885443", "0.58872616", "0.58872616", "0.58567536", "0.5851207", "0.58401...
0.0
-1
Update a customer using a predefined XML template as a REST request.
def update(id, name= "Updated Name") xml_req = "<?xml version='1.0' encoding='UTF-8'?> <customer> <id type='integer'>#{id}</id> <name>#{name}</name> </customer>" request = Net::HTTP::Put.new("#{@url}/#{id}.xml") request.add_field "Content-Type", "application/xml" request.body = xml_req http = Net::HTTP.new(@uri.host, @uri.port) response = http.request(request) # no response body will be returned case response when Net::HTTPSuccess return "#{response.code} OK" else return "#{response.code} ERROR" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_customer(id, data)\n put(\"customers/#{id}\", { body: data })\n end", "def update(params = {})\n req = WebPay::CustomerRequestUpdate.create(params)\n raw_response = @client._request(:post, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end", "def u...
[ "0.7414512", "0.7409766", "0.7388895", "0.731159", "0.72316325", "0.7102524", "0.70180017", "0.70110196", "0.70047396", "0.70047396", "0.69754744", "0.6951559", "0.68436646", "0.6773493", "0.6772214", "0.6771773", "0.6771773", "0.6771773", "0.6771773", "0.6771773", "0.6771773...
0.6518837
69
Delete a customer with an ID using HTTP Delete
def delete(id) request = Net::HTTP::Delete.new("#{@url}/#{id}.xml") http = Net::HTTP.new(@uri.host, @uri.port) response = http.request(request) # no response body will be returned case response when Net::HTTPSuccess return "#{response.code} OK" else return "#{response.code} ERROR" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(params = {})\n req = WebPay::CustomerIdRequest.create(params)\n raw_response = @client._request(:delete, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end", "def delete_customer_by_id(customer_id)\n host = Swagger.configuration.host\n api_key ...
[ "0.83748233", "0.821034", "0.8065541", "0.7861734", "0.77919567", "0.77881485", "0.7708202", "0.75335425", "0.7529182", "0.7529182", "0.7529182", "0.7529182", "0.7529182", "0.7529182", "0.7529182", "0.7526181", "0.7526181", "0.75032836", "0.7492786", "0.74036956", "0.74036956...
0.0
-1
switching on just for 1 hour a day
def update_mode(new_mode) #return if new_mode == mode #gateway = Eth485Gateway.new(ENV['ETH485_GATEWAY_IP'], ENV['ETH485_GATEWAY_PORT'].to_i) gateway = SerialportGateway.new(ENV['SERIAL_PORT']) meter = Mercury.new(gateway, ENV['METER_ADDRESS'].to_i) result = {} case new_mode when HEATIN_CORD_OFF_MODE then result = meter.disable_consumer if result['status'] = 'OK' self.update!(enable: false, mode: new_mode) end when HEATIN_CORD_MANUAL_ON_MODE then result = meter.enable_consumer if result['status'] = 'OK' self.update!(enable: true, mode: new_mode) end when HEATIN_CORD_AUTOMATIC_1H_SWITCH_MODE, HEATIN_CORD_AUTOMATIC_1H_PER_DAY_MODE then update!(mode: new_mode) #puts meter.enable_consumer end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hour() end", "def once_per_hour &block\n\tcurrent_hour = Time.now.hour\n\n\tblock.call\n\t\nend", "def tick_tock\n @hour += 1\n @minute = 0\n @second = 0\n end", "def tock\n @minute += 1\n end", "def set_hour_created\n self.hour_created = Time.now.in_time_zone('Eastern Time (US & Canad...
[ "0.6659656", "0.65116674", "0.6474604", "0.64349383", "0.64174885", "0.639536", "0.63817996", "0.63180625", "0.63003594", "0.63003594", "0.62766516", "0.62766516", "0.6272764", "0.61520207", "0.61097425", "0.60934424", "0.60471153", "0.6046477", "0.60246766", "0.60157883", "0...
0.0
-1
POST /api/rests POST /api/rests.jsonb
def create unless @rest = Rest.where(["report_id = ? AND ended_at IS NULL", params[:report_id]]).first @rest = Rest.new(:report_id => params[:report_id], :latitude => params[:latitude], :longitude => params[:longitude], :address => params[:address], :started_at => Time.now() ) end respond_to do |format| if @rest.save @json = Hash[:rest => { :id => @rest.id, :report_id => @rest.report_id, :latitude => @rest.latitude, :longitude => @rest.longitude, :address => @rest.address, :started_at => @rest.started_at }] format.json { render json: @json, status: :created, location: @json } else format.json { render json: {:error => "Rest creation faild."}, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def create\n @rest = Rest.new(rest_params)\n @rest.owners << current_owner\n respond_to do |format|\n if @rest.save\n format.html { redirect_to @rest, notice: 'Rest was successfully created.' }\...
[ "0.63335425", "0.59180254", "0.5916169", "0.5909367", "0.58648837", "0.58631915", "0.58021826", "0.5626741", "0.55788445", "0.5542703", "0.5520616", "0.5499403", "0.5472638", "0.54371214", "0.54256797", "0.5393185", "0.53848064", "0.5380046", "0.53756267", "0.5374399", "0.532...
0.5333968
20
PUT /api/rests/1 PUT /api/rests/1.json
def update @rest = Rest.where(["id = ? AND report_id = ?" , params[:id], params[:report_id]]).first if @rest respond_to do |format| if @rest.update_attributes({ :location => params[:location], :ended_at => DateTime.now }) @json = Hash[:rest => { :id => @rest.id, :report_id => @rest.report_id, :location => @rest.location, :latitude => @rest.latitude, :longitude => @rest.longitude, :address => @rest.address, :started_at => @rest.started_at, :ended_at => @rest.ended_at }] format.json { render json: @json } else format.json { render json: {:error => "Rest update failed."}, status: :unprocessable_entity } end end else respond_to do |format| format.json { render json:{ :error => "Not Acceptable:rests#update", :status => 406 } } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Cont...
[ "0.71501756", "0.68428665", "0.6766224", "0.6570423", "0.6564734", "0.6536515", "0.6536515", "0.65325564", "0.63774365", "0.623174", "0.6210878", "0.62084824", "0.62084824", "0.618625", "0.6171196", "0.6146451", "0.6126203", "0.6098457", "0.60959095", "0.6078001", "0.6069012"...
0.5647829
76
returns a copy of this Hash where all String keys are symbolized.
def with_symbolized_keys inject({}) do |hash, (key, value)| if key.is_a?(String) hash.update key.to_sym => value else hash.update key => value end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_sym!\n self.keys.each do |key| \n self[key.to_sym] = self.delete key if key.class == String\n end\n return self\n end", "def symbolize_keys!; self end", "def symbolize_keys\n dup.symbolize_keys!\n end", "def symbolize_keys!\n replace(self.symbolize_k...
[ "0.7969364", "0.7870518", "0.78095144", "0.778851", "0.7737107", "0.7574516", "0.7574516", "0.7574516", "0.7574516", "0.7574516", "0.7574516", "0.7555497", "0.753237", "0.7474813", "0.7453979", "0.7453979", "0.7453979", "0.7405228", "0.7382833", "0.731224", "0.7284966", "0....
0.6350714
91
returns a copy of this Hash where all keys (including, e.g. Fixnums) are stringified.
def with_stringified_keys inject({}) do |hash, (key, value)| hash.update key.to_s => value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stringify_keys!\n\t\t\tself.each do |k,v|\n\t\t\t\tnext if k.kind_of? String\n\t\t\t\tself[k.to_s] = v\n\t\t\t\tself.delete k\n\t\t\tend\n\t\tend", "def hashie_stringify_keys!\n keys.each do |k|\n self[k.to_s] = delete(k) unless String === k\n end\n self\n end", "def stri...
[ "0.73330635", "0.71148425", "0.69609624", "0.69609624", "0.69243413", "0.69144374", "0.6893453", "0.68298596", "0.6828672", "0.68169385", "0.68169385", "0.68169385", "0.68151194", "0.67741877", "0.6757653", "0.67398566", "0.672602", "0.6724877", "0.6724877", "0.6724877", "0.6...
0.66043335
36
tries to find and authenticate user to create a new session
def create @user = User.find_by(email: params[:user][:email]) @user = @user.try(:authenticate, params[:user][:password]) if @user session[:user_id] = @user.id redirect_to contacts_path else flash.now[:alert] = "Invalid combination. Try again - or try logging in via Google" render :new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_session\n req_params = params[:user]\n unless req_params\n @msg = \"Login details not found\"\n render \"objects/msg.json\", status: :unauthorized and return\n end\n @user = User.find_by_email(req_params[:email])\n if @user && @user.authenticate(req_params[:password])\n ses...
[ "0.7728926", "0.767955", "0.76678735", "0.7634079", "0.76272017", "0.7523402", "0.74983436", "0.7497016", "0.74340916", "0.7414648", "0.74095887", "0.74053264", "0.7404066", "0.73638254", "0.73620033", "0.7350743", "0.73401463", "0.7339073", "0.7327648", "0.7316882", "0.73028...
0.0
-1
uses googleAuth code to create a user from omniauth, set tokens, and set session id
def googleAuth access_token = request.env["omniauth.auth"] @user = User.from_omniauth(access_token) @user.save @user.google_token = access_token.credentials.token refresh_token = access_token.credentials.refresh_token @user.google_refresh_token = refresh_token if refresh_token.present? session[:user_id] = @user.id redirect_to contacts_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_google\n @user = GetOauthUser.new(:service_hash => omniauth_hash).call\n\n if @user\n establish_session @user\n redirect_to return_location\n else\n redirect_to sign_in_url, :notice => \"Error signing in\"\n end\n end", "def omniauth\r\n @user = User.create_by_google_omn...
[ "0.8297299", "0.8058901", "0.7720402", "0.7710405", "0.7607388", "0.7527249", "0.75107896", "0.74775237", "0.74680215", "0.7454767", "0.7301353", "0.72472113", "0.72195834", "0.7186868", "0.7171435", "0.7079342", "0.70787036", "0.70184803", "0.70133746", "0.6966851", "0.69518...
0.75637466
5
Creates a new RubyToDot object.
def initialize @classes = Array.new # A set instead of the hashes would be a nicer choice, but # RubyToDot should not depend on any library to allow more complete graphs. @modules = Hash.new @ignored = Hash.new @ignored_tree = Hash.new set_defaults end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dot(**options) = convert_to('dot', **options)", "def to_dot\n Dot::Digraph.new(:fontsize => 10, :shape => :box, :size => 5) do |g|\n parse_tree.to_dot(g)\n end.to_dot\n end", "def dotchart(*args)\n Dot.new(self, *args)\n end", "def initialize(p='btex $\\bullet$ etex')\n...
[ "0.6079827", "0.5947084", "0.58866173", "0.58001757", "0.5606832", "0.5593928", "0.53332484", "0.5312729", "0.5307401", "0.52014214", "0.5120336", "0.5067539", "0.50627553", "0.505601", "0.505601", "0.50343364", "0.5014287", "0.50011337", "0.5000201", "0.49768192", "0.4972694...
0.5252093
9
All currently loaded classes and modules will not be shown in the output graph. If new classes inherit one of these already existing classes, they will be shown in grey color.
def hide_current_state @classes = Array.new ObjectSpace.each_object(Class) do |klass| @classes.push klass end @modules = Hash.new ObjectSpace.each_object(Module) do |mod| @modules[mod] = true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hide_tree(*classOrModules)\n\t\tclassOrModules.each do |classOrModule|\n\t\t\t@ignored_tree[classOrModule] = true\n\t\tend\n\tend", "def hide(*classOrModules)\n\t\tclassOrModules.each do |classOrModule|\n\t\t\t@ignored[classOrModule] = true\n\t\tend\n\tend", "def display_class name\n return if name =~ /...
[ "0.6373043", "0.61872894", "0.5890121", "0.58712715", "0.58534676", "0.581856", "0.579209", "0.5779362", "0.5774515", "0.57436", "0.5743313", "0.5741707", "0.5731197", "0.5730855", "0.5725498", "0.57057655", "0.56915677", "0.56719434", "0.5658555", "0.56471443", "0.5629149", ...
0.6972091
0