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
POST /parking_spots POST /parking_spots.json
def create @parking_spot = ParkingSpot.new(params[:parking_spot]) respond_to do |format| if @parking_spot.save format.html { redirect_to @parking_spot, notice: 'Parking spot was successfully created.' } format.json { render json: @parking_spot, status: :created, location: @parking_spot } ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n p_name = params[:spot][:name]\n p_latitude = params[:spot][:latitude]\n p_longitude = params[:spot][:longitude]\n p_address = params[:spot][:address]\n p_type = params[:spot][:type]\n p_img = params[:spot][:img]\n p_rating = params[:spot][:rating]\n p_schedule = params[:spot][:...
[ "0.72179353", "0.7157946", "0.7105684", "0.6944679", "0.6860005", "0.6704328", "0.6688589", "0.6630774", "0.6621964", "0.6585812", "0.65726435", "0.6560521", "0.6552271", "0.6537595", "0.6535319", "0.6508802", "0.64958143", "0.64938253", "0.64655566", "0.646024", "0.6433986",...
0.76056874
0
PUT /parking_spots/1 PUT /parking_spots/1.json
def update @parking_spot = ParkingSpot.find(params[:id]) respond_to do |format| if @parking_spot.update_attributes(params[:parking_spot]) format.html { redirect_to @parking_spot, notice: 'Parking spot was successfully updated.' } format.json { head :no_content } else format....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @spot.update(spot_params)\n format.html { redirect_to @spot, notice: 'Spot was successfully updated.' }\n format.json { render :show, status: :ok, location: @spot }\n else\n format.html { render :edit }\n format.json { render json: @...
[ "0.7394324", "0.7394324", "0.73773646", "0.71857816", "0.7185573", "0.70140773", "0.69486016", "0.68645924", "0.681219", "0.6793189", "0.6793189", "0.6793189", "0.6793189", "0.6774357", "0.6748632", "0.6706881", "0.66834575", "0.66534555", "0.661808", "0.66025835", "0.6588023...
0.7388841
2
DELETE /parking_spots/1 DELETE /parking_spots/1.json
def destroy @parking_spot = ParkingSpot.find(params[:id]) @parking_spot.destroy respond_to do |format| format.html { redirect_to parking_spots_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to spots_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spot.destroy\n respond_to do |format|\n format.html { redirect_to spots_path, notice: ...
[ "0.7528674", "0.7342295", "0.7334166", "0.7334166", "0.72566575", "0.72562027", "0.7233133", "0.7194996", "0.7186248", "0.7181438", "0.7108831", "0.7066434", "0.7063465", "0.70190096", "0.7013875", "0.6998434", "0.69618124", "0.69608974", "0.69581515", "0.69351244", "0.691971...
0.7664197
0
GET /businesses/1 GET /businesses/1.xml
def show @user = User.find(params[:id]) # List the last 5 businesses rated by a user. @businesses = Business.paginate_by_sql ["SELECT businesses.id, businesses.name, businesses.street, businesses.suburb, businesses.postcode, businesses.phone, businesses.email, businesses.url, businesses.permalink, businesse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @bus_service = BusService.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bus_service }\n end\n end", "def index\n @boms = Bom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { re...
[ "0.6399964", "0.623588", "0.6137871", "0.6104651", "0.6104651", "0.6104651", "0.6103527", "0.6001186", "0.6001186", "0.5992852", "0.5951351", "0.59374565", "0.5917031", "0.5877673", "0.5872271", "0.58563805", "0.5849045", "0.58390844", "0.5832349", "0.5826215", "0.58161455", ...
0.0
-1
POST /users POST /users.xml
def create @user = User.new(params[:user]) @user.save! self.current_user = @user redirect_to user_path(current_user) flash[:notice] = "Thank You For Signing Up To MyNewFavourite.Biz" rescue ActiveRecord::RecordInvalid render :action => 'new' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end", "def CreateUser params = {}\n \n ...
[ "0.7168688", "0.63396686", "0.62262285", "0.61549276", "0.60888964", "0.60806924", "0.6053796", "0.6010148", "0.5941431", "0.5934541", "0.5930525", "0.59250647", "0.5901337", "0.58794725", "0.5853921", "0.5849757", "0.58432627", "0.582658", "0.5826317", "0.58216405", "0.58106...
0.0
-1
PUT /users/1 PUT /users/1.xml
def update @user = User.find(self.current_user) respond_to do |format| if @user.update_attributes(params[:user]) flash[:success] = 'You Have Successfully Updated Your Details' format.html { redirect_to user_url(@user) } format.xml { head :ok } else format.html { ren...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :a...
[ "0.6636351", "0.65471065", "0.6364191", "0.6259846", "0.6221812", "0.6219103", "0.61729", "0.6132848", "0.6132041", "0.61250746", "0.6111105", "0.61060876", "0.610549", "0.60566336", "0.6034858", "0.6034677", "0.6017268", "0.60129845", "0.60047716", "0.5981848", "0.5979415", ...
0.5717833
78
DELETE /users/1 DELETE /users/1.xml
def destroy @users = Users.find(params[:id]) @users.destroy respond_to do |format| format.html { redirect_to users_url } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def delete_users\n delete(users_path)\n end", "def destroy\n @user = ...
[ "0.71784127", "0.7172879", "0.70625985", "0.7033187", "0.70047104", "0.6962", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69135", "0.69...
0.70615184
3
we need to run a controller hook for some actions
def after_operation_hook(outcome) hook_name = "after_#{@operation.to_s.underscore.gsub('/', '_')}" send(hook_name, outcome) if respond_to?(hook_name, true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_hook; end", "def define_action_hook; end", "def before_dispatch(env); end", "def run_actions; end", "def action_run\n end", "def before_dispatch(_env)\n end", "def hook_controllers!\n ActionController::Base.extend Storehouse::Controller\n end", "def after_products\n...
[ "0.7599479", "0.7216387", "0.7177527", "0.6964656", "0.6921041", "0.6896004", "0.68936354", "0.68052644", "0.67997575", "0.66241777", "0.66009563", "0.66009563", "0.66009563", "0.66009563", "0.66009563", "0.66009563", "0.66009563", "0.66009563", "0.66009563", "0.66009563", "0...
0.0
-1
A Polar coordinate, radius now starts at 0 to spiral outwards
def setup sketch_title 'Exercise Spiral' background(255) @r = 0 @theta = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def polar\n Image.run_cmplx(self) { |x| x.complex :polar }\n end", "def new_polar( angle_rad, magnitude )\n self.new( Math::cos(angle_rad)*magnitude,\n Math::sin(angle_rad)*magnitude )\n end", "def polar\n [abs, arg]\n end", "def polar\n theta = 0.0\n if Point.clo...
[ "0.72354215", "0.6985867", "0.6918092", "0.67502415", "0.66051275", "0.657172", "0.6300038", "0.62130773", "0.61501616", "0.61325777", "0.61266696", "0.6106188", "0.60865813", "0.60463", "0.60345894", "0.60200924", "0.60180336", "0.60180336", "0.60160667", "0.60004294", "0.59...
0.0
-1
TODO: Add callbacks at points (middle, end, user defined) during interpolation
def interpolate(from, to, duration = 0, easing = Easing::LINEAR, &block) @value = from interpolate_to(to, duration, easing, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interpolate_points(measurements)\n points = []\n\n measurements.each_index do |i|\n point = { x: i * 60, y: measurements[i]['count'] } # use the 'count' metric\n # point = { x: i, y: measurements[i]['value'] } # use the 'value' metric\n points << point\n end \n\n points\nend", "def interpolatio...
[ "0.6246883", "0.6166169", "0.6078285", "0.58128095", "0.5806848", "0.5767457", "0.5712198", "0.57121944", "0.57046026", "0.56747156", "0.56271327", "0.5611527", "0.5587582", "0.5536342", "0.54525614", "0.54220015", "0.53648907", "0.53408015", "0.53014123", "0.52907354", "0.52...
0.0
-1
authentica ususario antes de cualquier cosa en hom
def index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user\n #carico l'user da sessione con auth esterna tramite omniauth\n @current_user ||= AuthHub::User.find_by(id: session['warden.user.user.key'][0][0]) unless session['warden.user.user.key'].blank?\n #se non ho fatto login esterna carico id salvato (usato in sign_in omniauth e anche log...
[ "0.60123664", "0.5920054", "0.5695979", "0.5695979", "0.566603", "0.5620293", "0.5619035", "0.55595136", "0.547137", "0.5449199", "0.54298526", "0.5408083", "0.53949565", "0.5376881", "0.5374539", "0.5363169", "0.53384686", "0.5331726", "0.53009266", "0.52962965", "0.5295449"...
0.0
-1
Parses the CSV file for data matching the given filter, or all if no filter provided.
def read(filter = {}) CSVFileTransaction.new(@path).read do |existing_data| existing_data.select do |row| filter.keys.all? do |key| row[key] == filter[key] end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(args={})\n csv_args = {:skip_blanks=>true,:col_sep=>\",\"}\n csv_args[:col_sep] = args[:col_sep] if args[:col_sep]\n args[:value_filter] ||= Csv2sql.method :default_value_filter\n i = 0\n CSV.foreach(@filename,csv_args) do |row|\n values = row\n #values_filter is for whole row\n ...
[ "0.65984774", "0.63166577", "0.6024309", "0.57916075", "0.578839", "0.5750898", "0.57353497", "0.5668208", "0.5571203", "0.5554034", "0.55449986", "0.55429333", "0.55144876", "0.55060256", "0.5492858", "0.54789287", "0.5430998", "0.54262024", "0.5414036", "0.5410369", "0.5385...
0.69080466
0
Saves a task to the CSV file.
def create(queue:, run_at:, expire_at: nil, data: '', initial_run_at: nil) CSVFileTransaction.new(@path).write do |tasks| max_id = tasks.collect { |task| task[:id] }.max || 0 new_data = { id: max_id + 1, queue: que...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_csv\n CSV.open(@csv_file_path, \"wb\") do |csv|\n csv << [\"name\", \"description\", \"rating\", \"prep_time\", \"done\"]\n @recipes.each do |recipe|\n csv << [recipe.name, recipe.description, recipe.rating, recipe.prep_time, recipe.done?]\n end\n end\n end", "def save_csv\n...
[ "0.6945855", "0.6816728", "0.67190933", "0.65595496", "0.64225197", "0.6366404", "0.6320003", "0.6301399", "0.62886614", "0.62712216", "0.6269683", "0.6262733", "0.62491584", "0.62453216", "0.6235925", "0.6209251", "0.61802906", "0.6162914", "0.6151711", "0.61368656", "0.6133...
0.0
-1
Updates an existing task in the CSV file.
def update(id, data) CSVFileTransaction.new(@path).write do |tasks| task_data = tasks.find do |task| task[:id] == id end task_data&.merge!(data) generate(tasks) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update \n\t logger.debug \"Params --------------------------------------- #{params}\"\n\n\t logger.debug \"task params --------------------------------------#{task_params}\"\n\t format_task_attributes(task_params)\n\t \n\t logger.debug \"-------------------------------------------------------------\"\n\t ...
[ "0.6679059", "0.66654855", "0.6604367", "0.6521975", "0.64527565", "0.6374847", "0.63662374", "0.6355844", "0.6320508", "0.6296752", "0.6236184", "0.6210037", "0.61808115", "0.6178884", "0.6153549", "0.6129987", "0.6128332", "0.61231226", "0.6073442", "0.60445046", "0.6043777...
0.7435354
0
Removes an existing task from the CSV file.
def delete(id) CSVFileTransaction.new(@path).write do |existing_data| generate(existing_data.reject { |task| task[:id] == id }) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task_remove(task_name)\n return unless task_present? task_name\n tasks.delete prepare_key(task_name)\n reset\n end", "def delete_task\n\n puts 'Enter task number(ID), please'\n\n entered_id = get_id_input\n\n if @tasks[entered_id]\n\n @tasks.delete(entered_id)\n\n else\n\n ...
[ "0.6573271", "0.6521943", "0.6483531", "0.6483531", "0.6434745", "0.6390004", "0.63816386", "0.6074838", "0.60174495", "0.5995384", "0.59880644", "0.5938574", "0.5934321", "0.59015363", "0.58807427", "0.58794504", "0.58728564", "0.5863691", "0.58499724", "0.5804278", "0.58010...
0.6789618
0
Generates a CSV string from the given data.
def generate(data) lines = data.collect do |d| Task::TIME_FIELDS.each do |field| d[field] = d[field]&.iso8601 end CSV.generate_line(d, headers: HEADERS, force_quotes: true).strip end lines.unshift(HEADERS.join(',')) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv_string\n CSV.generate do |csv|\n header.write_header csv\n records.each {|r| r.write_record csv}\n end\n end", "def generate_csv\n csv_string = CSV.generate do |csv|\n csv << [\"Sl no.\",\"Scheme\",\"IP no.\", \"Patient name\", \"UHID no.\", \"Reg no.\", \"DOA\", \"...
[ "0.72883415", "0.7079462", "0.69112384", "0.6869518", "0.68617517", "0.68617517", "0.6846642", "0.6725864", "0.6725864", "0.6694876", "0.66425544", "0.66211724", "0.6585369", "0.6578842", "0.6534194", "0.65175414", "0.6475968", "0.64707935", "0.6459955", "0.64574474", "0.6451...
0.6706858
9
Create a new successful response
def success(output) respond_with(Response::Success, output) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_success_response\n response = {\n body: {\n status: \"ok\"\n },\n status: 200\n }\n return response\n end", "def new_response\n {:success => true}\n end", "def create_success_response(message='')\n message = message.present? ? message : 'ok'\n response = {\n...
[ "0.80810034", "0.8047007", "0.7525846", "0.71700704", "0.6976498", "0.6923417", "0.68982196", "0.6888395", "0.6869037", "0.68132293", "0.67740554", "0.6755265", "0.672844", "0.66935235", "0.6668525", "0.6579772", "0.65713143", "0.6559111", "0.65312546", "0.65152186", "0.65107...
0.64310205
31
Create a new failure response
def error(output) respond_with(Response::Failure, output) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def failure\n {:response=>:failure}\n end", "def fail_response(data={})\n status = data.delete(:status) || 400\n {\n status: status,\n json: {\n status: \"fail\",\n data: data\n }\n }\n end", "def create_response(api_response, errors)\n Rails.logger.error \"#{Time....
[ "0.7212774", "0.7067432", "0.70068365", "0.6946382", "0.6822346", "0.6742092", "0.660483", "0.6565303", "0.6549323", "0.6520697", "0.64870495", "0.64820105", "0.64443636", "0.64108276", "0.6385243", "0.63821274", "0.62842053", "0.62665963", "0.6264063", "0.6239963", "0.623038...
0.67707795
6
Instantiate an instance of +klass+ and pass +output+
def respond_with(klass, output) klass.new(self, output) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(output)\n @output = output\n end", "def initialize(output)\n @output = output\n end", "def initialize(output)\n @output = output\n end", "def initialize(output)\n @output = output\n end", "def initialize(output)\n @output = output\n end...
[ "0.71798426", "0.69941413", "0.69941413", "0.69941413", "0.6947364", "0.688634", "0.68842703", "0.67187506", "0.6659809", "0.6391661", "0.6358704", "0.6208302", "0.6207928", "0.61918813", "0.6157875", "0.6155659", "0.61152124", "0.6095304", "0.6093219", "0.6045299", "0.590440...
0.7288114
1
takes the code expected to print to stdout returns string that was written I copied this from one of the nice people on StackOverflow... I can't necessarily explain how it works
def capture_stdout(&blk) old = $stdout $stdout = fake = StringIO.new blk.call fake.string ensure $stdout = old end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def stdout; end", "def pout(str)\n print str\n $stdout.flush\nend", "def stdout\n string, @stdout = @stdout, \"\"\n string\n end", "def stdouts; end", "def real_puts mes...
[ "0.70295376", "0.70295376", "0.70295376", "0.70295376", "0.70295376", "0.70295376", "0.700832", "0.68628883", "0.68341875", "0.6742427", "0.6702518", "0.6688412", "0.6598112", "0.659363", "0.6573792", "0.6562288", "0.6546357", "0.6529902", "0.6498583", "0.64913106", "0.646411...
0.6411989
24
Example 1: Input: 1>1>2 Output: 1>2 Example 2: Input: 1>1>2>3>3 Output: 1>2>3
def remove_dupes(head) # 1) if the given node is nil or the next node is nil return the head (nil) # if the next node is nil we want to stop return head if head.nil? || head.next.nil # 2) the node after our head node will be set through recursion # if the next value is nil we'll have head followed by head...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(n)\n siblings = n.to_s.chars.each_slice(1).to_a\n siblings.sort {|x,y| -(x <=> y)}.join.to_i\nend", "def crunch(str)\n if str == '' \n return ''\n end\n \n new_arr = str.split('')\n str_out = new_arr[0]\n \n (1..new_arr.size-1).each {|n|\n new_arr[n] != new_arr[n-1] ? \n str_out ...
[ "0.61594975", "0.58806336", "0.54521483", "0.53566307", "0.5279292", "0.52720964", "0.5237434", "0.5227361", "0.5136991", "0.51123506", "0.5096406", "0.50896424", "0.5087842", "0.507887", "0.5056117", "0.50549203", "0.5044595", "0.50445557", "0.5042675", "0.5027715", "0.50277...
0.0
-1
getters 1 def team_name
def find_player(player) found = false for name in @players if player == name found = true end end return found end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_name\n return @team_name\n end", "def team_name\n self.team == nil ? \"\" : self.team.name\n end", "def team_name\n client.team.name\n end", "def get_team_name\n team ? team.get_full_name : '?'\n end", "def get_team_name\n team ? team.get_full_name : '?'\n end", "def get_team...
[ "0.8814047", "0.8384114", "0.8277951", "0.8273465", "0.8273465", "0.8273465", "0.8273465", "0.80034405", "0.7929613", "0.78965247", "0.7890308", "0.78888863", "0.7840662", "0.7796891", "0.7796891", "0.7796891", "0.7796891", "0.7796891", "0.7796891", "0.77616304", "0.7686721",...
0.0
-1
initialize an overlay for this notes block it has a special hook that updates name to be header always this way we can always find the overlay corresponding to header
def show_text @header_overlay ||= Overlay.find_or_make(left, after_header - 1) @body_overlay ||= Overlay.find_or_make(after_header, right) @body_overlay.invisible = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overlay_init(overlay)\r\n @init << add_overlay(overlay)\r\n end", "def overlay_global_init(overlay,name, options = {})\r\n declare_global_init(overlay,name, options)\r\n @init << add_overlay(overlay)\r\n end", "def newOverlay _obj, _args\n \"_obj newOverlay _args;\" \n ...
[ "0.6681219", "0.608445", "0.5561136", "0.5500768", "0.544678", "0.54360926", "0.5326365", "0.5314265", "0.53112084", "0.52095616", "0.5166569", "0.5166569", "0.5156896", "0.5137611", "0.5108251", "0.50471365", "0.5035975", "0.5035975", "0.5017349", "0.50032", "0.49989703", ...
0.53368706
6
cuts the block, and stores it in archive.file.notes example: ruby.notes > archive.ruby.notes
def archive delete_content filename = 'archive.' + $el.file_name_nondirectory(buffer_file_name) timestamp = "--- archived on #{Time.now.strftime('%Y-%m-%d at %H:%M')} --- \n" $el.append_to_file timestamp, nil, filename $el.append_to_file content, nil, filename end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def appendTemplate2file(file, name, template)\n\t_block_start = \"# #{name} added by chef {\"\n\t_block_end = \"# }\\n\"\n\n\tbash \"Remove #{name} from #{file}\" do\n\t\tcode <<-EOC\n\t\t\tperl -0777 -pi -e 's/\\n*#{_block_start}.*?#{_block_end}//gs' #{file}\n\t\tEOC\n\t\tonly_if \"cat #{file} | grep -q '#{_block...
[ "0.59349096", "0.5760833", "0.55836296", "0.552755", "0.5480607", "0.543546", "0.53769445", "0.5360909", "0.5324599", "0.5282704", "0.52706265", "0.52474785", "0.5205273", "0.51874965", "0.51740694", "0.5167162", "0.51541466", "0.51481706", "0.51126075", "0.5074879", "0.50617...
0.5569207
3
Use callbacks to share common setup or constraints between actions.
def set_report @report_type = params[:report_type] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163754", "0.6045816", "0.5944853", "0.59169096", "0.58892167", "0.58342934", "0.5776148", "0.57057375", "0.57057375", "0.56534296", "0.56209534", "0.54244673", "0.54101455", "0.54101455", "0.54101455", "0.53951085", "0.5378493", "0.53563684", "0.53399915", "0.5338049", "0...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def report_params params[:report_type] 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.6979893", "0.6781746", "0.6746611", "0.6742344", "0.6735229", "0.6592651", "0.65027124", "0.6498011", "0.648163", "0.647716", "0.64556813", "0.64386255", "0.63784456", "0.63756156", "0.636574", "0.6319542", "0.63004524", "0.6299559", "0.62925464", "0.62923217", "0.6289894"...
0.0
-1
GET /system_modules GET /system_modules.json
def index @system_modules = SystemModule.all respond_to do |format| format.html # index.html.erb format.json { render json: @system_modules } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @system_module = SystemModule.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @system_module }\n end\n end", "def client_modules\n get 'client/modules'\n end", "def kernel_modules\n cmd_exec('cat /proc/modules...
[ "0.6970559", "0.68455225", "0.662856", "0.6476541", "0.641495", "0.61911464", "0.61423135", "0.61336213", "0.6106561", "0.60826355", "0.6072761", "0.60560566", "0.60487497", "0.6046614", "0.603772", "0.6000397", "0.5994987", "0.5981464", "0.5981464", "0.5939749", "0.5931545",...
0.75199854
0
GET /system_modules/1 GET /system_modules/1.json
def show @system_module = SystemModule.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @system_module } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @system_modules = SystemModule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @system_modules }\n end\n end", "def client_modules\n get 'client/modules'\n end", "def new\n @system_module = SystemModule.new\n\n respond...
[ "0.77253675", "0.7056701", "0.69571495", "0.6770045", "0.6557487", "0.6455478", "0.64187217", "0.64004827", "0.6387797", "0.63617754", "0.635964", "0.63402456", "0.6303131", "0.61839074", "0.61814773", "0.6115808", "0.60932064", "0.6079503", "0.60775495", "0.60775495", "0.601...
0.7576823
1
GET /system_modules/new GET /system_modules/new.json
def new @system_module = SystemModule.new respond_to do |format| format.html # new.html.erb format.json { render json: @system_module } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @system_module = SystemModule.new(params[:system_module])\n\n respond_to do |format|\n if @system_module.save\n format.html { redirect_to system_modules_path, notice: 'System module was successfully created.' }\n format.json { render json: @system_module, status: :created, loc...
[ "0.7322922", "0.71015453", "0.6919206", "0.6835707", "0.66176844", "0.6594518", "0.65657896", "0.6512526", "0.6475486", "0.64244646", "0.64041245", "0.63811827", "0.6371564", "0.6319135", "0.6306862", "0.6249839", "0.62366706", "0.6223361", "0.61504173", "0.61114", "0.6058218...
0.8183245
0
POST /system_modules POST /system_modules.json
def create @system_module = SystemModule.new(params[:system_module]) respond_to do |format| if @system_module.save format.html { redirect_to system_modules_path, notice: 'System module was successfully created.' } format.json { render json: @system_module, status: :created, location: @sys...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @system_module = SystemModule.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @system_module }\n end\n end", "def index\n @system_modules = SystemModule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.js...
[ "0.6389292", "0.62181056", "0.6107585", "0.58088636", "0.5800439", "0.5687186", "0.56653166", "0.5641828", "0.56236774", "0.56233597", "0.5580009", "0.5450005", "0.5450005", "0.5403786", "0.53923696", "0.5299722", "0.528568", "0.52719164", "0.5258683", "0.5239693", "0.5226133...
0.71339995
0
PUT /system_modules/1 PUT /system_modules/1.json
def update @system_module = SystemModule.find(params[:id]) respond_to do |format| if @system_module.update_attributes(params[:system_module]) format.html { redirect_to system_modules_path, notice: 'System module was successfully updated.' } format.json { head :no_content } else ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @system_module = SystemModule.new(params[:system_module])\n\n respond_to do |format|\n if @system_module.save\n format.html { redirect_to system_modules_path, notice: 'System module was successfully created.' }\n format.json { render json: @system_module, status: :created, loc...
[ "0.65263134", "0.6188692", "0.61165375", "0.59526", "0.58572555", "0.5812963", "0.5749133", "0.5705087", "0.569882", "0.5624962", "0.55474436", "0.5543482", "0.5506861", "0.5493205", "0.542344", "0.5409935", "0.54033667", "0.5373862", "0.5370027", "0.53495455", "0.53495455", ...
0.71949625
0
DELETE /system_modules/1 DELETE /system_modules/1.json
def destroy @system_module = SystemModule.find(params[:id]) @system_module.destroy respond_to do |format| format.html { redirect_to system_modules_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_module(org_unit_id, module_id) # DELETE\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/content/modules/#{module_id}\"\n _delete(query_string)\nend", "def destroy\n @process_module.destroy\n respond_to do |format|\n format.html { redirect_to process_modules_url, notice: 'Process ...
[ "0.70329183", "0.6480735", "0.64432514", "0.6417052", "0.6371683", "0.6340005", "0.63369024", "0.6295293", "0.6278733", "0.626471", "0.617066", "0.6154467", "0.6144245", "0.6137238", "0.6129369", "0.61224574", "0.6100955", "0.6095595", "0.6068985", "0.60584056", "0.6056125", ...
0.77551776
0
skip_before_action :authorize_request, only: :create POST /signup return authenticated token upon signup
def index @users = [] if current_user.admin? @users = User.all @users = @users.where("users.firstname like ?", "%#{params[:firstname]}%") if params[:firstname].present? @users = @users.where("users.lastname like ?", "%#{params[:lastname]}%") if params[:lastname].present? @users = @users....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorize\n redirect_to signup_path unless current_user\n end", "def create\n logger.debug request.content_type\n if request.content_type != 'application/json'\n logger.info \"SignIn method: form\"\n super\n else\n logger.info \"SignIn method: json\"\n token = warden.authenti...
[ "0.69730157", "0.67598164", "0.6510787", "0.63155574", "0.6234815", "0.62314534", "0.61542547", "0.61403185", "0.61384594", "0.6132979", "0.60860354", "0.60826206", "0.6068699", "0.60275936", "0.6027492", "0.60272235", "0.6008765", "0.6008622", "0.60080904", "0.60026455", "0....
0.0
-1
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.professional_mailer.new_professional_contact.subject
def new_professional_contact(email) @email = email mail(to: "henriquepjv@gmail.com", subject: "oi") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end", "def message_subject=(value)\n ...
[ "0.71877027", "0.6919989", "0.69021314", "0.68859905", "0.6803666", "0.67539036", "0.67527074", "0.674321", "0.67381316", "0.66498405", "0.6633942", "0.66331005", "0.6596881", "0.6594864", "0.65881306", "0.657951", "0.6552877", "0.6528901", "0.6453452", "0.6448699", "0.637794...
0.0
-1
Return a list of navigation items for mobile
def mobile_navigation_items @mobile_navigation_items ||= begin result = [] # Collect the four basic navigaton links %i[meditations tracks streams articles].each do |role| next if role == :streams && !Stream.public_stream.any? static_page = static_page_preview_for(role) re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mobile_navigation_items\n @mobile_navigation_items ||= begin\n result = []\n\n # Collect the four basic navigaton links\n %i[meditations tracks streams classes articles].each do |role|\n next if role == :streams && !Stream.public_stream.any?\n\n static_page = StaticPage.preview(...
[ "0.8054396", "0.7371317", "0.6541837", "0.6421904", "0.63462204", "0.62167996", "0.600033", "0.5968205", "0.5800539", "0.5797962", "0.57828826", "0.5710845", "0.5681283", "0.56808156", "0.5675001", "0.5611087", "0.55571246", "0.55350477", "0.54918677", "0.5488649", "0.5475598...
0.8020968
1
used to set the locale namespace.
def default_url_options(options={}) { :locale => I18n.locale }.merge(options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_locale\n end", "def locale=(locale); end", "def set_locale\n I18n.locale = extract_locale_from_tld\n end", "def default_locale=(locale); end", "def locale=(value); end", "def locale=(_arg0); end", "def set_locale \n I18n.locale = extract_locale_from_tld || I18n.default_locale\n end", ...
[ "0.7878038", "0.77320457", "0.74408835", "0.74395114", "0.74289435", "0.73633754", "0.7326805", "0.7313726", "0.7298506", "0.7292317", "0.7232026", "0.72299296", "0.72299296", "0.72041124", "0.71525806", "0.71350425", "0.71350425", "0.7132", "0.7132", "0.713044", "0.71125144"...
0.0
-1
has many through with Personalitys. Didn't end up using it
def personalities villagers.map{ |villager| villager.personality} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def associations; end", "def model_relationships; end", "def many_to_many_associated_tables\n @many_to_many_associated_tables\n end", "def hmt(goal, options)\n thru = options[:through]\n self.has_many(thru)\n self.has_many(goal, :through => thru, :skip_belongs_to => true)\n unless options...
[ "0.6190894", "0.5894519", "0.5842421", "0.58348954", "0.5834738", "0.5833448", "0.5823959", "0.5813767", "0.57524496", "0.5732109", "0.5724861", "0.5694243", "0.5673369", "0.5646965", "0.55877125", "0.5585526", "0.5574954", "0.5512882", "0.5490995", "0.5490995", "0.54741657",...
0.55669326
17
test that quantity of events equals times different id passed
def test_several_active result=[] at=Activity_tracker.new do result.push nil end 3.times do |i| at.active i end sleep at.timeout+at.tick_time assert result.size==3, 'result size is '+result.size.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_on_confirm_with_user_logged_should_add_events_to_current_cart\n login_as users(:user1) \n @cart = carts(:cart_user1_empty_and_not_purchased)\n load_current_cart @cart\n \n assert_difference \"CartsEvent.count\", 2 do\n post(\n :confirm,\n :event_ids => [events(:event1)...
[ "0.6255078", "0.60186297", "0.60099113", "0.5886432", "0.5884491", "0.58670807", "0.58428514", "0.57528025", "0.5749182", "0.5702205", "0.56963456", "0.56920815", "0.56289417", "0.5616411", "0.55829704", "0.5563545", "0.55101144", "0.55083954", "0.55002904", "0.5464628", "0.5...
0.55386925
16
tests that block is triggered only when needed time was passed
def test_time_added result=[] at=Activity_tracker.new do |id| result.push id end at.active 1 sleep at.tick_time at.active 2 sleep at.tick_time at.active 1 sleep at.timeout assert result==[2], 'result was: '+result.join(',') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_block\n start = Time.now\n yield\n time = Time.now - start\n puts \"Block took basically 0 time\" if time < 0.001\n raise \"Block took #{time} to execute\" if time > 0.001\nend", "def time_passed?(_event, time)\n Time.now > time\n end", "def eventually(label, &block)\n current_time = Tim...
[ "0.69910896", "0.6769127", "0.6732968", "0.6704213", "0.66839075", "0.6598466", "0.6540735", "0.6528414", "0.6518364", "0.6518364", "0.64768934", "0.63328445", "0.63165814", "0.63109595", "0.63105994", "0.6290384", "0.62799877", "0.6279543", "0.62396514", "0.6227493", "0.6199...
0.0
-1
tests that block is triggered with id's in correct order
def test_sequence result=[] at=Activity_tracker.new do |id| result.push id end at.active 1 sleep at.tick_time at.active 2 sleep at.tick_time at.active 1 sleep at.tick_time at.active 3 sleep at.timeout+at.tick_time assert result==[2,1,3], "result was: "+result.join("...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_block_id(block_id)\n return @block_id == block_id\n end", "def ==(another_block)\n @id == another_block.id\n end", "def blocks() end", "def id\n @block\n end", "def id\n @block\n end", "def test_methods_can_see_if_they_have_been_called_with_a_block\n assert_equal ...
[ "0.571857", "0.5689771", "0.5661274", "0.5654031", "0.5654031", "0.56426144", "0.55551714", "0.5526933", "0.5475063", "0.544981", "0.544981", "0.544981", "0.5422462", "0.5361328", "0.53611416", "0.535062", "0.5341853", "0.5337583", "0.5287954", "0.52735597", "0.5218828", "0...
0.0
-1
test that accuracy is matching required
def test_max_accuracy result=Array.new at=Activity_tracker.new do |id| result[id]=Time.now-result[id] end 10.times do |i| result[i]=Time.now at.active i sleep at.tick_time end sleep at.timeout+at.tick_time accuracy=result.max-at.timeout expected_accuracy=at.tick_t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accuracy\n\n # Sum and square the error (difference) between predicted Y and actual Y\n summarization = @training_set.sum{|x, y| @hypothesis.error(x, y) ** 2}\n\n # Calculate the average of the errors\n (1.to_f / (2 * @training_set.length)) * summarization\n \n end", "def accuracy...
[ "0.7620611", "0.757965", "0.74401677", "0.72192574", "0.7108348", "0.7077705", "0.6994163", "0.6978975", "0.69204044", "0.64711624", "0.6259472", "0.62218773", "0.6214528", "0.613938", "0.60835844", "0.60551167", "0.6027874", "0.6022611", "0.60217965", "0.59883606", "0.598836...
0.6650109
9
tests that activity tracker control thread do not start if number of active id's reduced to 1
def test_start_stop start_time_for={} stop_time=nil at=Activity_tracker.new do |id| assert((Time.now-start_time_for[id]-at.timeout).to_f.abs<at.tick_time) end if at.tresholds<3 puts "Warning: this test supposed to run successfully"+ "only wich tresholds>3" end 4.times do ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_several_active\n result=[]\n at=Activity_tracker.new do\n result.push nil\n end\n 3.times do |i|\n at.active i\n end\n sleep at.timeout+at.tick_time\n assert result.size==3, 'result size is '+result.size.to_s\n end", "def no_activity?(*counts)\n self.prev_counts ||...
[ "0.635598", "0.6295204", "0.62777543", "0.5941769", "0.5810085", "0.5810085", "0.5810085", "0.5796053", "0.56565833", "0.56565833", "0.5628698", "0.5618682", "0.5602639", "0.54769003", "0.5476797", "0.5463817", "0.5460336", "0.5396104", "0.5340545", "0.53057694", "0.53057694"...
0.6815767
0
GET /counties GET /counties.json
def index @counties = Entity.where(entity_type: 'County').order(:entity_name) respond_with(@counties) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def counties\n @retailer = Retailer.find(params[:retailer_id])\n @counties = Spree::County.find_all_by_state_id(@retailer.physical_address.state_id)\n end", "def get_counties\n @counseling = update_counseling(counseling_params)\n counties = State.find(params[:counseling][:work_state_abbr...
[ "0.74655586", "0.700555", "0.67228657", "0.6452379", "0.64273113", "0.6415411", "0.6352288", "0.63424605", "0.62037164", "0.6130884", "0.60996366", "0.6096908", "0.6009464", "0.5966107", "0.58938736", "0.5892219", "0.5846941", "0.5838353", "0.58352244", "0.5833443", "0.583251...
0.7419675
1
GET /counties/1 GET /counties/1.json
def show @county = Entity.where(id: params[:id]).where(entity_type: 'County').first respond_with(@county) do |format| format.geojson { render text: @county.to_geojson } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @counties = Entity.where(entity_type: 'County').order(:entity_name)\n respond_with(@counties)\n end", "def counties\n @retailer = Retailer.find(params[:retailer_id])\n @counties = Spree::County.find_all_by_state_id(@retailer.physical_address.state_id)\n end", "def get_coun...
[ "0.73182935", "0.72476244", "0.6982715", "0.67128885", "0.6625494", "0.63753194", "0.63633895", "0.62441576", "0.61935836", "0.60862225", "0.60349447", "0.6034126", "0.6023576", "0.5964133", "0.5935941", "0.5918456", "0.59150696", "0.5852348", "0.58355796", "0.58173597", "0.5...
0.64840114
5
Replace this with your real tests.
def test_magic_column_should_add_read_method @bob.magic_columns << MagicColumn.create(:name => "first_name") @bob.first_name #method gets generated the first time it is called :S assert @bob.respond_to?(:first_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testing\n # ...\n end", "def __dummy_test__\n end", "def tests; end", "def tests; end", "def spec; end", "def spec; end", "def self_test; end", "def self_test; end", "def test \n end", "def test_0_dummy\n\t\tend", "def test\n\n end", "def test\n end", "def test\n end"...
[ "0.7444841", "0.6954491", "0.6913394", "0.6913394", "0.6863823", "0.6863823", "0.66389537", "0.66389537", "0.66238844", "0.6545616", "0.6523148", "0.64830077", "0.64830077", "0.64830077", "0.6406177", "0.6389718", "0.6389718", "0.6389718", "0.6389718", "0.6389718", "0.6389718...
0.0
-1
Creates a new token en/decoder for a service that is associated with the the audience_ids, the symmetrical token validation key, and the public and/or private keys.
def initialize(options = {}, obsolete1 = nil, obsolete2 = nil) unless options.is_a?(Hash) && obsolete1.nil? && obsolete2.nil? # deprecated: def initialize(audience_ids, skey, pkey = nil) warn "#{self.class}##{__method__} is deprecated with these parameters. Please use options hash." options = {aud...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_api_token\n begin\n ApiToken.create(api_consumer: self)\n end\n end", "def create_token\n @account_token = SecureRandom.urlsafe_base64(nil, false)\n @authentication_token = create_authentication_token\n key = account_token_key(@account_token)\n redis_token = Redis::HashKey.new(...
[ "0.5957142", "0.5912898", "0.56923527", "0.5615844", "0.5615844", "0.56012857", "0.55893534", "0.55844885", "0.5460313", "0.5418479", "0.5399062", "0.53792804", "0.5376077", "0.5375694", "0.5366912", "0.53646433", "0.5363521", "0.53281176", "0.5313514", "0.52640295", "0.52538...
0.0
-1
As a test, only publish if they are a living legend
def set_published_state self.published = payload["isLivingLegend"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def should_appear_on_map?\n data['visibility'] == 'PUBLIC' && timeslots.any?\n end", "def show_legend=(v) Axlsx.validate_boolean(v); @show_legend = v; end", "def show_legend=(v) Axlsx::validate_boolean(v); @show_legend = v; end", "def use_hidden_layers?\n end", "def legend_data\n if relevant_data...
[ "0.58741474", "0.55490047", "0.5496794", "0.5416851", "0.5398628", "0.5373561", "0.53626007", "0.534349", "0.53156084", "0.529494", "0.52585393", "0.5224291", "0.52066904", "0.5201965", "0.5201965", "0.51976186", "0.5184395", "0.51685596", "0.51556206", "0.5154209", "0.514539...
0.62027514
0
returns combined virus output (predicted_deaths and speed_of_spread) from two methods
def virus_effects predicted_deaths speed_of_spread end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def virus_effects\n predicted_deaths\n speed_of_spread\nend", "def virus_effects\n predicted_deaths \n speed_of_spread \n end", "def virus_effects\n predicted_deaths \n speed_of_spread \n end", "def virus_effects\n #removed parameters for predicted_deaths and speed_of_spread, as these ...
[ "0.7783191", "0.7764983", "0.7764983", "0.7741496", "0.77382433", "0.77382433", "0.77382433", "0.77382433", "0.77382433", "0.7723338", "0.7721581", "0.771126", "0.7696709", "0.7678292", "0.76713175", "0.76116204", "0.76116204", "0.76116204", "0.7610536", "0.7610536", "0.76105...
0.0
-1
takes in population_density, population, & state, determines appropriate calculation, outputs state death totals
def predicted_deaths # predicted deaths is solely based on population density if @population_density >= 200 multiplier = 0.4 elsif @population_density >= 150 multiplier = 0.3 elsif @population_density >= 100 multiplier = 0.2 elsif @population_density >= 50 multipli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deaths_spread(population_density, population, state)\n speed = 0.0\n case \n when @population_density >= 200\n number_of_deaths = (@population * 0.4).floor\n speed += 0.5\n when @population_density >= 150\n number_of_deaths = (@population * 0.3).floor\n speed += 1\n when @pop...
[ "0.7797304", "0.77455676", "0.768392", "0.7675992", "0.76723075", "0.7670498", "0.7668481", "0.7668481", "0.7668481", "0.7668481", "0.7668481", "0.7668481", "0.7659685", "0.76525545", "0.76459384", "0.7626281", "0.7599716", "0.75979185", "0.7595636", "0.7594602", "0.7593801",...
0.0
-1
takes in population_density, & state, determines appropriate calculation, outputs speed of spread
def speed_of_spread #in months # We are still perfecting our formula here. The speed is also affected # by additional factors we haven't added into this functionality. if @population_density >= 200 speed = 0.5 elsif @population_density >= 150 speed = 1 elsif @population_density ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speed_of_spread #(population_density, state) #in months\r\n # We are still perfecting our formula here. The speed is also affected\r\n # by additional factors we haven't added into this functionality.\r\n\r\n if @population_density >= 200\r\n speed = 0.5\r\n elsif @population_density >= 150\r\...
[ "0.8280007", "0.8083867", "0.8041779", "0.8030016", "0.80298966", "0.7985922", "0.7973144", "0.7973144", "0.7973144", "0.7973144", "0.7959136", "0.7951918", "0.79416054", "0.79197335", "0.7906245", "0.7899092", "0.78855544", "0.78781486", "0.7851766", "0.78395283", "0.7834274...
0.7091941
73
To generate quartiles (1/4, 2/4, 3/4): gen_probs(4)
def gen_probs(num, from=0, to=1) step = (to - from) / num.to_f ((from + step)...to).step(step).to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_quartiles(scores)\r\n (0..scores.length-1).each do |i|\r\n sum = 0\r\n if i%(scores.length/4) == 0\r\n (i..(i+scores.length/4-1)).each {|index| sum += scores[index]}\r\n yield sum\r\n end\r\n end\r\n end", "def quartiles(arr)\n sort_arr = arr.sort()\n len = s...
[ "0.6503063", "0.63562995", "0.629197", "0.62639064", "0.6193463", "0.6131235", "0.6059463", "0.59332967", "0.5807494", "0.56795055", "0.5609749", "0.55597794", "0.5484351", "0.5436289", "0.54084665", "0.5381991", "0.5286059", "0.52193147", "0.5208042", "0.5142028", "0.5123789...
0.6562914
0
Calculates weighted quantiles. The +data+ is a list of pairs of values and their corresponding weight: [10, 4], [20, 3], [30, 2]
def wquantiles(data, probs=QUARTILES) grouped = data.group_by(&:first).map { |a, b| [a, b.reduce(0) { |sum, e| sum + e.last }] } values, weights = grouped.sort_by(&:first).transpose sum = 0 cum_weights = weights.map { |e| sum += e } probs.map do |prob| h = 1 + (sum - 1) * prob mod = h % 1 k1 = ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quartiles(arr)\n sort_arr = arr.sort()\n len = sort_arr.size()\n q1_q2_q3 = [0.25, 0.5, 0.75].collect { |v|\n indx_f = (len * v) - 0.5\n indx_i = indx_f.to_i()\n if (indx_i == indx_f)\n sort_arr[indx_i]\n else\n res = indx_f - indx_i\n ...
[ "0.5650042", "0.56224465", "0.5604089", "0.5339969", "0.53229463", "0.52581656", "0.51844984", "0.50766003", "0.50183034", "0.49968216", "0.49813432", "0.49263918", "0.49216646", "0.4861086", "0.48501268", "0.4838986", "0.4832361", "0.48022974", "0.4781189", "0.47297043", "0....
0.8504608
0
Calculates the Gini coefficient. The +data+ is a list of pairs of values and their corresponding weight: [10, 4], [20, 3], [30, 2]
def gini(data) sorted = data.sort_by(&:first) sum_values = 0 sum_weights = 0 # total acumulated value total = sorted.each_with_index.map do |(value, weight), i| sum_values += value * weight sum_weights += weight next_weight = (i + 1 < sorted.size) ? sorted[i + 1].last : 0 sum_values * (weight...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gini_impurity(list)\n purity = 0.0\n histogram = list.to_hist\n length = list.length.to_f \n \n # sigma( f(i,j) * f(i,k) where j != k )\n list.each do |item_j|\n list.each do |item_k|\n unless item_j == item_k\n purity += ( histogram[item_j].to_f/length * histogram[item_k].to_f/length )\n...
[ "0.55996954", "0.5193958", "0.5102363", "0.50316995", "0.49920458", "0.4970565", "0.4947874", "0.4929251", "0.49160537", "0.49085036", "0.49019724", "0.48861498", "0.4866536", "0.48171386", "0.48155516", "0.47528583", "0.47337013", "0.47027963", "0.46721867", "0.46705565", "0...
0.8168251
0
Gets called when you call the new method to create an instance deck = Deck.new
def initialize @ranks = %w(A 2 3 4 5 6 7 8 9 10 J Q K) @suits = %w(Spades Diamonds Clubs Hearts) @cards = [] generate_deck end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @deck = Deck.new\n end", "def new\n @current_deck = Deck.new\n end", "def init_deck\n @deck = Deck.new\nend", "def new\n @decklist = Decklist.new\n end", "def initialize(deck)\n @deck = deck\n end", "def newDeck(name, template = @cur_deck_name)\n\n end", "def initi...
[ "0.90057474", "0.8454545", "0.8093951", "0.79762447", "0.7743105", "0.7528031", "0.73261726", "0.73142076", "0.7186676", "0.7186676", "0.71048427", "0.71019137", "0.7018448", "0.70141023", "0.6916029", "0.68900895", "0.6869348", "0.68589866", "0.6844382", "0.68336886", "0.681...
0.67548233
24
Given the length of a side of a cube calculate the volume def test_volume_of_cube() add test code here end
def volume_calculations_cube(a) return a ** 3 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_volume_of_cube()\n result = volume_of_cube(5)\n assert_equal(125, result)\n end", "def volume_of_cube(length, width, height)\nreturn length * width * height\n #add test code here\nend", "def test_volume_of_a_cube()\n # add test code here\n result = volume_of_a_cube(2)\n assert_equal(8...
[ "0.8687192", "0.86417216", "0.8588064", "0.85557765", "0.8555071", "0.8476113", "0.84124434", "0.83645713", "0.8305737", "0.82774264", "0.82408094", "0.8235612", "0.81698203", "0.80808836", "0.8054068", "0.8054068", "0.8030122", "0.801772", "0.78995574", "0.7850315", "0.77487...
0.7295483
31
Calcula la duracion de la actividad y recursivamente la de sus hijas, este metodo solo funciona cuando no se sabe aun la duracion de la actividad, es decir, cuando se calcula por primera vez
def calcular_tiempo(actividades, fecha_inicio) if self.start_time.nil? || self.end_time.nil? || self.start_time < fecha_inicio.ctime self.start_time = 0.business_hour.after(fecha_inicio) self.end_time = esfuerzo.to_i.business_hour.after(fecha_inicio) actividades.each do |a| if a.is_child_o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recalcular_tiempo(e_participacion, actividades)\n latest_start = self.proyecto.fecha_inicio\n self.participacion += (e_participacion / 100)\n\n latest_start = self.start_time if anteriores.split(/\\s*,\\s*/).count == 0\n anteriores.split(/\\s*,\\s*/).each do |ant|\n a = Actividad.find_by(nombr...
[ "0.68781936", "0.61854666", "0.61376697", "0.60566247", "0.5896524", "0.5826666", "0.58167446", "0.57849485", "0.57048655", "0.56883657", "0.56828403", "0.5663138", "0.5634219", "0.56294405", "0.5547578", "0.553801", "0.553071", "0.5529868", "0.5501091", "0.54849917", "0.5479...
0.6301674
1
Recalcula la duracion de la actividad y recursivamente la de sus hijas cuando se asigna un nuevo trabajador a la actividad y por ello cambia la duracion de la actividad
def recalcular_tiempo(e_participacion, actividades) latest_start = self.proyecto.fecha_inicio self.participacion += (e_participacion / 100) latest_start = self.start_time if anteriores.split(/\s*,\s*/).count == 0 anteriores.split(/\s*,\s*/).each do |ant| a = Actividad.find_by(nombre: ant) l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def actualizar_duracion\n @trayecto = Trayecto.find(params[:id])\n puts @trayecto.id\n @reserva= Reserva.find(@trayecto.reserva_id)\n @hora_inicial= @reserva.fecha.strftime(\"%H\").to_f\n @hora_inicial1= @reserva.fecha.strftime(\"%M\").to_f\n @hora_inicial_um= @hora_inicial1/60\n @hora_inicia...
[ "0.6479383", "0.63735676", "0.6144659", "0.6084887", "0.5967108", "0.58530885", "0.5711935", "0.56954014", "0.56769985", "0.56255955", "0.5605644", "0.55609626", "0.5550374", "0.54832226", "0.54832226", "0.5469868", "0.5458581", "0.54559666", "0.5444691", "0.5425485", "0.5395...
0.6723802
0
Devuelve true si la actividad es hija del padre especificado en los argumentos
def is_child_of(nombre_padre) anteriores.split(/\s*,\s*/).each do |a| return true if a == nombre_padre end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isKeyActive _args\n \"isKeyActive _args;\" \n end", "def IsActive=(arg0)", "def IsActive=(arg0)", "def arguments?\n @config.arguments == Cliqr::Config::ENABLE_CONFIG\n end", "def args?\n\t\treturn !@form.empty?\n\tend", "def arguments_valid?\n # TODO - implement your real l...
[ "0.6734068", "0.6477347", "0.6477347", "0.64728916", "0.64426297", "0.63631773", "0.63602644", "0.63572407", "0.6302017", "0.6294933", "0.62826526", "0.62792784", "0.6253394", "0.62146026", "0.62057203", "0.62057203", "0.6200635", "0.61731696", "0.6170194", "0.6155256", "0.61...
0.0
-1
Override al metodo que transforma el objecto en JSON, se utiliza params enviar el JSON necesario para el calendario
def as_json(options = {}) { title: "#{self.proyecto.nombre} - #{self.nombre}", start: self.start_time, end: self.end_time } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_json(*)\n CalendarJSON.rent(self)\n end", "def as_json(options = {})\n {\n :id => self.id,\n :title => self.titre,\n :description => self.contenu || \"\",\n :start => start_at.rfc822,\n :end => end_at.rfc822,\n :allDay => self.all_day,\n :recurring => false,\n ...
[ "0.724058", "0.7039944", "0.6865456", "0.6819987", "0.6769235", "0.67492235", "0.6677761", "0.66730094", "0.66243154", "0.6607618", "0.6569502", "0.6501039", "0.64647716", "0.64573246", "0.6419073", "0.6419073", "0.6419073", "0.63895696", "0.63394666", "0.63262093", "0.632223...
0.6434079
14
Helper class method to look up all tracks for trackable class name and trackable id.
def find_tracks_for_trackable(trackable_str, trackable_id) find(:all, :conditions => ["trackable_type = ? and trackable_id = ?", trackable_str, trackable_id], :order => "created_at DESC" ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def track_ids\n tracks || []\n end", "def get_tracks\n html_tracks.map do |html_track|\n track(html_track)\n end\n end", "def tracks\n track_ids = REDIS.smembers tracks_key\n track_ids.map!{|track_id| Track.get(self, track_id)}.sort!\n end", "def tracks\n search_children c...
[ "0.6870922", "0.67643905", "0.6735538", "0.6659329", "0.64644146", "0.63806397", "0.6345794", "0.6345794", "0.6269087", "0.6269087", "0.6257743", "0.623979", "0.61032236", "0.59921783", "0.5979485", "0.59781367", "0.5937506", "0.5923072", "0.59193194", "0.5908134", "0.5879928...
0.71573555
0
Helper class method to look up a trackable object given the trackable class name and id
def find_trackable(trackable_str, trackable_id) trackable_str.constantize.find(trackable_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_object_by_id(class_name, id)\n obj = nil\n get_objects_of_class(class_name).each do |o|\n if o.id == id\n obj = o\n break\n end\n end\n obj\n end", "def get_object\n class_name = self.target_type.classify\n klass = Object.cons...
[ "0.6769654", "0.6685169", "0.6539429", "0.65263283", "0.6481855", "0.6481855", "0.64366263", "0.6373589", "0.63726425", "0.6358652", "0.6346196", "0.6320455", "0.63156", "0.6302884", "0.6238765", "0.6208082", "0.6188873", "0.61756384", "0.6162286", "0.61360276", "0.61163884",...
0.7596586
0
Returns a hash of attributes for the Stripe::Customer object
def customer_attributes owner = pay_customer.owner attributes = case owner.class.pay_braintree_customer_attributes when Symbol owner.send(owner.class.pay_braintree_customer_attributes, pay_customer) when Proc owner.class.pay_braintree_customer_attributes.call(pay_cus...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customer_attributes\n owner = pay_customer.owner\n\n attributes = case owner.class.pay_stripe_customer_attributes\n when Symbol\n owner.send(owner.class.pay_stripe_customer_attributes, pay_customer)\n when Proc\n owner.class.pay_stripe_customer_attributes.call(pay_...
[ "0.861377", "0.75021285", "0.74453586", "0.6926853", "0.6903688", "0.6903688", "0.6841569", "0.6808757", "0.67906505", "0.64407295", "0.6399583", "0.6357096", "0.63439226", "0.6330202", "0.632976", "0.6316942", "0.6279135", "0.6220694", "0.6147965", "0.614743", "0.6108009", ...
0.82240885
1
Retrieve the Braintree::Customer object If no processor_id is present, creates a Customer. When 'payment_method_token' is present, it will also set the default payment method
def customer if processor_id? customer = gateway.customer.find(processor_id) if payment_method_token? add_payment_method(payment_method_token, default: true) pay_customer.payment_method_token = nil end customer else result = gat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customer\n stripe_customer = if processor_id?\n ::Stripe::Customer.retrieve({id: processor_id, expand: [\"tax\", \"invoice_credit_balance\"]}, stripe_options)\n else\n sc = ::Stripe::Customer.create(customer_attributes.merge(expand: [\"tax\"]), stripe_options)\n pay_cus...
[ "0.7819338", "0.7469256", "0.7048159", "0.6661165", "0.66594356", "0.66594356", "0.6573314", "0.6550373", "0.63731265", "0.6328318", "0.6317379", "0.626579", "0.6222659", "0.62023896", "0.6108576", "0.6099305", "0.608366", "0.60699934", "0.60699934", "0.6009984", "0.6001715",...
0.86826915
0
Syncs name and email to Braintree::Customer You can also pass in other attributes that will be merged into the default attributes
def update_customer!(**attributes) customer unless processor_id? gateway.customer.update(processor_id, customer_attributes.merge(attributes)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setCustomerAttributes(customernumber, email, firstname, lastname, salutation, password, shopId, street, city, zipcode, country)\n #if string_country\n customer_properties = {\n :number => customernumber,\n :email => email,\n :firstname => firstname,\n :lastname => lastname,\n :sa...
[ "0.67891574", "0.65602696", "0.63524073", "0.63374317", "0.6278832", "0.6274468", "0.623445", "0.6163116", "0.6160894", "0.61296207", "0.61156136", "0.61145407", "0.6109977", "0.60654914", "0.6059736", "0.6056946", "0.60532224", "0.6025581", "0.6022175", "0.6011091", "0.60101...
0.59735477
25
GET /payment_entries GET /payment_entries.json
def index @payment_entries = PaymentEntry.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @payment_entries = ReceiptEntry.all.where(\"user_id =?\", current_user.id)\n end", "def all_payment_entries\n @ac = ApplicationController.new\n @payments = PaymentFromDestination.find(:all, :order => \"created_at\").reverse!\n end", "def index\n @payment_methods = @user.payment_me...
[ "0.6725535", "0.6628945", "0.6545972", "0.6437476", "0.6409785", "0.63779086", "0.63779086", "0.63320494", "0.63112015", "0.63013506", "0.623971", "0.62345773", "0.6213448", "0.6205967", "0.61921084", "0.61879474", "0.6145134", "0.6119035", "0.6101649", "0.6093253", "0.606530...
0.7437573
0
GET /payment_entries/1 GET /payment_entries/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @payment_entries = PaymentEntry.all\n end", "def show\n @payments = Payment.find(params[:id]) \n render json: @payments\n end", "def show\n @payment = Payment.find(params[:payment_id])\n @payment_line = @payment.payment_lines.find(params[:id])\n\n respond_to do |format|\n f...
[ "0.7142042", "0.66691643", "0.6509085", "0.6508877", "0.6481542", "0.6371302", "0.635684", "0.635684", "0.62411714", "0.6217262", "0.6213676", "0.6202175", "0.6200802", "0.61951137", "0.61831653", "0.61645854", "0.61645854", "0.61645854", "0.61645854", "0.61645854", "0.616458...
0.0
-1
POST /payment_entries POST /payment_entries.json
def create @payment_entry = PaymentEntry.new(payment_entry_params) respond_to do |format| if @payment_entry.save format.html { redirect_to :back, notice: 'Payment entry was successfully created.' } format.json { render :show, status: :created, location: @payment_entry } else ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n #assign unpermitted parameter 'entries' to a variable\n entries = params[\"entries\"]\n @invoice = @user.invoices.build(invoice_params)\n #save entries\n @invoice.entries = entries\n if @invoice.save\n ...
[ "0.65707517", "0.640821", "0.63305575", "0.6118295", "0.60621446", "0.5833588", "0.582568", "0.58212113", "0.5712099", "0.56650215", "0.5622013", "0.5592579", "0.5558912", "0.5545933", "0.55453104", "0.5539837", "0.55334646", "0.55299443", "0.55245924", "0.5501683", "0.550070...
0.6681109
0
PATCH/PUT /payment_entries/1 PATCH/PUT /payment_entries/1.json
def update respond_to do |format| if @payment_entry.update(payment_entry_params) format.html { redirect_to @payment_entry, notice: 'Payment entry was successfully updated.' } format.json { render :show, status: :ok, location: @payment_entry } else format.html { render :edit } ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @payment = Payment.find(params[:id])\n params[:payment][:payment_lines_attributes] = @payment.process_removed_lines(params[:payment][:payment_lines_attributes])\n\n respond_to do |format|\n if @payment.update_attributes(payment_params)\n # check_entry = CheckEntry.find_by_check_co...
[ "0.67807287", "0.6648374", "0.63713187", "0.63359004", "0.6305506", "0.62087226", "0.61845577", "0.61829144", "0.61377347", "0.6130006", "0.6130006", "0.6130006", "0.6130006", "0.6130006", "0.6130006", "0.6123381", "0.6114071", "0.61098135", "0.61080253", "0.60691494", "0.606...
0.6805008
0
DELETE /payment_entries/1 DELETE /payment_entries/1.json
def destroy @payment_entry.destroy respond_to do |format| format.html { redirect_to payment_entries_url, notice: 'Payment entry was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @receipt_entry.destroy\n respond_to do |format|\n format.html { redirect_to payment_entries_url, notice: 'Payment entry was successfully destroyed.' }\n format.json { head :no_content }\n ...
[ "0.7173227", "0.7094196", "0.7081608", "0.70184433", "0.6991747", "0.6991747", "0.6991747", "0.6991747", "0.6991747", "0.6991747", "0.6991747", "0.69810456", "0.69810456", "0.69810456", "0.69810456", "0.69810456", "0.69810456", "0.69810456", "0.69810456", "0.69810456", "0.695...
0.74787575
0
Use callbacks to share common setup or constraints between actions.
def set_payment_entry @payment_entry = PaymentEntry.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.6164095", "0.6046031", "0.5945298", "0.59179014", "0.58890367", "0.58341795", "0.5776118", "0.5700777", "0.5700777", "0.5656277", "0.56218207", "0.5423995", "0.5411516", "0.5411516", "0.5411516", "0.5395004", "0.53783494", "0.53593004", "0.53412604", "0.534078", "0.5332865...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def payment_entry_params params.require(:payment_entry).permit(:transaction_id, :id, transactions_attributes: [:id, :payment, :date, :description, :purchase_id, :bank_account_id, :total_amount, :amount, :reference, :bank_id, :gl_account_id, :account_id, :purchase_invoice_id, :sales_invoice_id, :contact_id, :vat_a...
{ "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.6979893", "0.6781746", "0.6746611", "0.6742344", "0.6735229", "0.6592651", "0.65027124", "0.6498011", "0.648163", "0.647716", "0.64556813", "0.64386255", "0.63784456", "0.63756156", "0.636574", "0.6319542", "0.63004524", "0.6299559", "0.62925464", "0.62923217", "0.6289894"...
0.0
-1
Example: makeNegative(1); return 1 makeNegative(5); return 5 makeNegative(0); return 0
def make_negative(num) num > 0 ? -num : num end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeNegative(num)\n num > 0 ? num * -1 : num\nend", "def make_negative(number)\n if number > 0\n number - (-number * -2)\n else\n number\n end\nend", "def makeNegative(num)\r\n if num >= 0\r\n return num * (-1)\r\n else\r\n return num * 1\r\n end\r\n end", "def makeNegative(...
[ "0.83403033", "0.8127164", "0.8110002", "0.80852437", "0.7932239", "0.79269254", "0.7908115", "0.7862934", "0.7764141", "0.7759801", "0.7736771", "0.76952636", "0.7673539", "0.76543635", "0.75771904", "0.7569315", "0.7530291", "0.75269836", "0.75269836", "0.75269836", "0.7526...
0.81923926
1
This calls the normal Jiveapps::Helper run() method, detects if there is an error, and if there is, removes the livedev run/lock file and quits with an error.
def run(cmd) result = super(cmd) if result.error? display "FAILURE" display result.error remove_livedev_run_file exit 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unlink_runfile\n File.unlink(CONFIG[:run_path]) if File.exists?(CONFIG[:run_path]) and File.read(CONFIG[:run_path]).to_i == Process.pid.to_i\n end", "def destroy!\n fail \"Can not destroy a running stone\" if running?\n rm_rf system_config_filename\n rm_rf extent_directory\n rm_rf log_directo...
[ "0.6322435", "0.59193724", "0.5744757", "0.5646756", "0.56010884", "0.5569065", "0.5563581", "0.5522819", "0.54997396", "0.54977715", "0.54793453", "0.54453534", "0.54230446", "0.54147494", "0.54078317", "0.5390626", "0.5390626", "0.5378527", "0.5374368", "0.53686965", "0.536...
0.67823225
0
Because STDIN.gets() blocks on Windows with the systemu library We use this inside the livedev listener loop instead of the normal run() which calls systemu(). Less error handling is possible.
def nonblock_run(command) if debug_mode? puts "DEBUG: $ #{command}" `#{command}` elsif running_on_windows? `#{command} > NUL 2>&1` else `#{command} > /dev/null 2>&1` # silent end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_stdin\n open_connection\n $stdin.each_line { |l| call_write(process_line(l.strip), false) }\n close_connection\n rescue SystemExit, Interrupt\n puts 'ctrl-c. Exiting.'\n wf.close\n exit 0\n end", "def get_stdin(message)\n print message\n STDIN.gets.chomp\nend", "d...
[ "0.6755247", "0.6710324", "0.66827524", "0.6650845", "0.6626704", "0.6622569", "0.6584143", "0.6535484", "0.6476528", "0.6456417", "0.63900876", "0.6280126", "0.6267679", "0.624696", "0.62453467", "0.6242741", "0.62057936", "0.6199604", "0.61962867", "0.617459", "0.6174005", ...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_spree_admin_callback @spree_admin_callback = Spree::CallBack.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.6164095", "0.6046031", "0.5945298", "0.59179014", "0.58890367", "0.58341795", "0.5776118", "0.5700777", "0.5700777", "0.5656277", "0.56218207", "0.5423995", "0.5411516", "0.5411516", "0.5411516", "0.5395004", "0.53783494", "0.53593004", "0.53412604", "0.534078", "0.5332865...
0.0
-1
Only allow a trusted parameter "white list" through.
def spree_admin_callback_params params.require(:call_back).permit(:name, :phone, :comment) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.71230334", "0.70530915", "0.69479465", "0.6902122", "0.67367256", "0.67172784", "0.6689043", "0.66784793", "0.6660117", "0.6555213", "0.6528485", "0.6458438", "0.6452378", "0.6451654", "0.64478326", "0.6433326", "0.6413599", "0.6413599", "0.63907677", "0.63787645", "0.6378...
0.0
-1
Find links of the passed in type. Example: story.link_for("html") => story.link_for("nothing") => nil Returns an the content of that link if found, or nil if not found.
def link_for(type) if link = self.links.find { |link| link.type == type } link.to_s end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matching_links(type)\n link_pattern = config.public_send(\"link_#{type}_pattern\")\n return [] unless link_pattern\n\n metadata\n .select { |key| __send__(\"#{type}?\", key) }\n .map { |key, value| Allure::ResultUtils.public_send(\"#{type}_link\", key.to_s, value, link_pattern) }\n...
[ "0.67740625", "0.5989967", "0.5548586", "0.55472124", "0.5498311", "0.54255044", "0.5410781", "0.54058486", "0.5399724", "0.5349285", "0.5347283", "0.53370523", "0.53072107", "0.5303627", "0.5303627", "0.52901477", "0.5274208", "0.52340674", "0.52309954", "0.52190965", "0.516...
0.70145255
0
Write a method count_e(word) that takes in a string word and returns the number of e's in the word
def count_e(word) i = 0 count = 0 while i < word.length if word[i] == 'e' count += 1 end i += 1 end return count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_e(word)\n puts word.count('e')\nend", "def count_e(word)\n count = 0\n word.each_char { |char| count += 1 if char == \"e\"}\n count\nend", "def count_e(word)\n count = 0 #use count to track number of e's\n\n i = 0 #use i to iterate thru the word\n while i < word.length\n char = wo...
[ "0.93135494", "0.89048785", "0.87674767", "0.8759804", "0.8634594", "0.8441822", "0.84250814", "0.8416622", "0.83798015", "0.8320316", "0.8278037", "0.7837087", "0.7702329", "0.7689668", "0.7672068", "0.7669673", "0.76278806", "0.7615224", "0.75882465", "0.7581019", "0.757435...
0.88175905
2
Write a method that returns the range of its argument (an array of integers).
def range(arr) # your code goes here arr.max - arr.min end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def range(arr)\n\nend", "def range(arr)\n arr.max - arr.min\nend", "def range(arr)\n arr.max - arr.min\nend", "def range(arr)\narr.max - arr.min\nend", "def range(arr)\r\n # your code goes here\r\n\r\n arr.max - arr.min\r\nend", "def range(arr)\n max = arr.max\n min = arr.min\n\n max - min\nend", ...
[ "0.8626893", "0.80259466", "0.80259466", "0.7945608", "0.7872918", "0.77586263", "0.7656329", "0.760674", "0.7339618", "0.72894055", "0.72894055", "0.72894055", "0.72430867", "0.7212974", "0.7203532", "0.71992487", "0.71543735", "0.7145868", "0.7136905", "0.7117204", "0.71130...
0.79161215
5
Write a method that returns a boolean indicating whether an array is in sorted order. Use the equality operator (==), which returns a boolean indicating whether its operands are equal, e.g., 2 == 2 => true, ["cat", "dog"] == ["dog", "cat"] => false
def in_order?(arr) # your code goes here arr.sort == arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_order?(arr)\n arr == arr.sort\nend", "def in_order?(arr)\n arr == arr.sort\nend", "def in_order?(arr)\r\n # your code goes here\r\n\r\n arr == arr.sort\r\nend", "def in_order?(arr)\n arr.sort == arr\nend", "def in_order?(arr)\n arr.sort == arr\nend", "def in_order?(arr)\n # your code goes h...
[ "0.82780784", "0.82780784", "0.8262147", "0.8242829", "0.8242829", "0.8137923", "0.812759", "0.8082833", "0.79464614", "0.76977855", "0.763032", "0.7613827", "0.761091", "0.76104474", "0.7608765", "0.7544718", "0.75005156", "0.74903566", "0.74880165", "0.7486249", "0.7473848"...
0.8112461
7
MEDIUM Write a method that returns the number of vowels in its argument
def num_vowels(str) # your code goes here str.downcase! str.count("aeiou") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_vowels(word)\nend", "def num_vowels(str)\n str.count(VOWELS)\nend", "def count_vowels(s)\n\tp s.count('aeiou')\nend", "def VowelCount(str)\n str.count \"aeiou\" \nend", "def count_vowels(str)\n str.count(\"aeoui\")\nend", "def count_vowels\n text.scan(/[aeoui]/).length\n end...
[ "0.8834374", "0.88235646", "0.8799606", "0.8757887", "0.87475246", "0.86927086", "0.863745", "0.85775834", "0.8576231", "0.85617316", "0.85430384", "0.84289944", "0.84157217", "0.8408926", "0.83952767", "0.83882064", "0.83879", "0.83873934", "0.8346269", "0.83254975", "0.8298...
0.8603274
7
Write a method that returns its argument with all its vowels removed.
def devowel(str) # your code goes here return str.delete("aeiou") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_vowels(s)\n s.downcase.delete('aeiou')\nend", "def elim_vowels(string)\r\n string.downcase.delete(\"aeiou\")\r\nend", "def strip_vowels(s)\n s.delete \"aeiouAEIOU\"\nend", "def remove_vowels string\n string.delete 'aeiouAEIOU'\nend", "def remove_vowels string\n string.delete 'aeiouAEIOU'\nen...
[ "0.78438705", "0.78291404", "0.778056", "0.77427155", "0.77427155", "0.77258646", "0.76760453", "0.7666095", "0.7637331", "0.7623339", "0.7590515", "0.7584422", "0.75764906", "0.7572585", "0.7549314", "0.75368375", "0.7512209", "0.75095564", "0.7509485", "0.7496836", "0.74799...
0.71114963
48
HARD Write a method that returns the returns an array of the digits of a nonnegative integer in descending order and as strings, e.g., descending_digits(4291) => ["9", "4", "2", "1"]
def descending_digits(int) # your code goes here array = int.to_s.split("") sorted = array.sort.reverse return sorted end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def descending_digits(int)\n int.to_s.split('').sort.reverse\nend", "def descending_digits(int)\n int.to_s.split('').sort.reverse\nend", "def descending_digits(int)\n nArray = int.to_s.chars.to_a\n nArray.sort{|x,y| y <=> x}\nend", "def descending_digits(int)\n int.to_s.split(\"\").sort.reverse\nend", ...
[ "0.7830351", "0.7830351", "0.7816069", "0.7798742", "0.7797447", "0.77474874", "0.7703192", "0.7697494", "0.7680459", "0.76226515", "0.7609444", "0.7609444", "0.76043415", "0.7596737", "0.7585382", "0.7583034", "0.75456786", "0.7531971", "0.7485403", "0.7338397", "0.7338397",...
0.774248
6
Write a method that returns a boolean indicating whether a string has repeating letters. Capital letters count as repeats of lowercase ones, e.g., repeating_letters?("Aa") => true
def repeating_letters?(str) # your code goes here str.downcase.chars.uniq.length != str.downcase.chars.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeating_letters?(str)\n str.downcase.chars.uniq.length != str.length\nend", "def repeating_letters?(str)\n # your code goes here\n str.downcase.chars.uniq.length != str.downcase.chars.length\n\n end", "def repeating_letters?(str)\n # your code goes here\n str.each_char do |ch|\n if str.downc...
[ "0.89427686", "0.88702774", "0.8745101", "0.8553428", "0.84803766", "0.8415026", "0.83200276", "0.8208764", "0.8054186", "0.7342648", "0.727094", "0.7265424", "0.72010183", "0.71918654", "0.7180668", "0.7179336", "0.71140146", "0.70583117", "0.70074385", "0.6997094", "0.69864...
0.88760245
1
Write a method that converts an array of ten integers into a phone number in the format "(123) 4567890".
def to_phone_number(arr) area_code_array = arr[0..2].join("").to_s part2_array = arr[3..5].join("").to_s part3_array = arr[6..-1].join("").to_s return "(" + area_code_array + ") " + part2_array + "-" + part3_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_phone_number(arr)\n string = \"(\" + arr[0..2].join + \") \" + arr[3..5].join + \"-\" + arr[6..9].join\nend", "def to_phone_number(arr)\n \"(#{arr[0..2].join}) #{arr[3..5].join}-#{arr[6..10].join}\"\nend", "def to_phone_number(arr)\n \"(#{arr[0..2].join}) #{arr[3..5].join}-#{arr[6..-1].join}\"\nend",...
[ "0.8380273", "0.83730954", "0.83104944", "0.82031775", "0.80742645", "0.80337536", "0.7933474", "0.7922912", "0.7919517", "0.7908028", "0.7907681", "0.7832066", "0.7816008", "0.7813046", "0.7812773", "0.7696569", "0.76566476", "0.76405454", "0.7636464", "0.7495635", "0.743023...
0.8070113
5
Write a method that returns the range of a string of commaseparated integers, e.g., str_range("4,1,8") => 7
def str_range(str) split = str.split(",") minimum = split.min.to_i maximum = split.max.to_i range = maximum - minimum return range end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def str_range(str)\n to_i = lambda { |num| num.to_i }\n nums = str.split(',').map(&to_i)\n nums.max - nums.min\nend", "def str_range(str)\n max = str.delete(\",\").chars.max\n min = str.delete(\",\").chars.min\n\n max.to_i - min.to_i\nend", "def str_range(str)\n ints = str.split(\",\").sort\n ints.last...
[ "0.809637", "0.7929234", "0.7749342", "0.76750976", "0.76223403", "0.75583094", "0.74374926", "0.7293694", "0.7187687", "0.7034955", "0.69699025", "0.69346786", "0.68288994", "0.6759422", "0.6738715", "0.67125267", "0.65680814", "0.6526294", "0.6355175", "0.63280684", "0.6180...
0.83384293
0
EXPERT Write a method that is functionally equivalent to the rotate(offset) method of arrays. offset=1 ensures that the value of offset is 1 if no argument is provided. HINT: use the take(num) and drop(num) methods. You won't need much code, but the solution is tricky!
def my_rotate(arr, offset=1) # your code goes here drop(offset) + take(offset) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_rotate(arr, offset=1)\n # your code goes here\n arr.drop(offset % arr.length) + arr.take(offset % arr.length)\nend", "def my_rotate(arr, offset=1)\n # your code goes here\n shift = offset % arr.length\n arr.drop(shift) + arr.take(shift)\nend", "def my_rotate(arr, offset=1)\n offset = offset % 4\n ...
[ "0.7987576", "0.79628736", "0.7871017", "0.7838629", "0.78277904", "0.7778113", "0.7740498", "0.7727674", "0.76088285", "0.7579245", "0.7425193", "0.73229533", "0.7315808", "0.7217753", "0.7164882", "0.71364695", "0.70696336", "0.7017687", "0.69994956", "0.6950801", "0.694266...
0.83781624
0
VA file number can be up to 10 digits long; An optional leading 'c' or 'C' followed by 79 digits. The file number field on the 4142 form has space for 9 characters so trim the potential leading 'c' to ensure the file number will fit into the form without overflow.
def extract_va_file_number(va_file_number) return va_file_number if va_file_number.blank? || va_file_number.length < 10 va_file_number.sub(/^[Cc]/, '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pfile_digits\n PFILE_REGEX_MATCHING.match(scanned_file)[1]\n end", "def initialize(no)\n parts = no.split(\"-\")\n if parts.count == 4 and (parts.last == \"CR\" or parts.last == \"CV\")\n @no = no\n else\n @no = nil\n end\n end", "def voip_number\n FFaker.numer...
[ "0.5953727", "0.5723631", "0.54449487", "0.54446316", "0.5377889", "0.5265598", "0.5222541", "0.5128117", "0.50863796", "0.505804", "0.5011473", "0.4994142", "0.49809015", "0.49569926", "0.4950638", "0.49195832", "0.49148858", "0.48950994", "0.4877768", "0.48776984", "0.48739...
0.78627676
0
=====================================UPLOIND & DELETING PICTURE=========================================
def add_haircut # Step #3: Processing form @photo = BarberHaircut.new(photo_params) @photo.user_id = current_user.id if @photo.save flash[:success] = "The photo was added!" redirect_to "/profiles/barber" else render 'show_for_barber' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def picture_detach(id)\n pictures[id].pin = false\n end", "def update_bitmap\n if @picture.name.empty?\n self.bitmap = nil\n else\n self.bitmap = swap_cache\n self.mirror = false\n end\n end", "def unload_image(image_handle)\n end", "def update_bitmap\n if @picture.name.empty...
[ "0.6125108", "0.61013716", "0.60763097", "0.60193187", "0.59550095", "0.5857514", "0.58159953", "0.5802352", "0.5739294", "0.5727023", "0.56744087", "0.56552577", "0.5622317", "0.5617083", "0.56163013", "0.5614909", "0.5613712", "0.5607445", "0.5580028", "0.5524841", "0.55054...
0.0
-1
params id : id of the map
def delete_map map = IndoorMap.find(:first, :conditions => {:id => params[:id]}) building = map.building if building.poi.user.id == session[:user] map.destroy end redirect_to(:controller => "indoor_maps", :action => "new", :poi_id => building.poi.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_map\n @map = Map.find(params[:id])\n end", "def map\n unless params[:id].nil?\n return not_found unless map = Map[params[:id].to_i]\n ok map.to_a\n else\n not_found\n end\n end", "def set_map\n @map = Map.find(params[:id])\n end", "def set_map\n @map = Map.fi...
[ "0.7284888", "0.7208882", "0.71893525", "0.71893525", "0.71893525", "0.71893525", "0.71893525", "0.71893525", "0.7098291", "0.68544155", "0.67172766", "0.66989857", "0.65612024", "0.6533403", "0.6456322", "0.64006984", "0.6284312", "0.6254147", "0.6251184", "0.61984885", "0.6...
0.0
-1
Parameters: file: File IO object &sentinel: Block, taking one parameter. Should return true when the sentinel is found.
def initialize(file, &sentinel) @file=file @sentinel=sentinel load_data self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eof_found?\n @eof_found\n end", "def frozen?(file)\n file.words.at(file.content_offset + offset + size - 1) == end_marker\n end", "def eof?()\n #This is a stub, used for indexing\n end", "def single?(file)\n file !~ /\\*/\n end", "def eof; @file.eof...
[ "0.62948424", "0.62624156", "0.62146634", "0.608149", "0.59608084", "0.59097964", "0.5909506", "0.5909506", "0.5909506", "0.588941", "0.5879826", "0.58710134", "0.58710134", "0.58710134", "0.5845235", "0.5844909", "0.58335835", "0.58335835", "0.58335835", "0.5827596", "0.5736...
0.5738073
20
Read all the lines of the file, but don't store them until we find one that satisfies sentinel
def load_data @data=[] marker_found=false @file.rewind @file.each_line do |line| if !marker_found && @sentinel.call(line) then marker_found=true end @data << line if marker_found end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readlines(eol=$/)\n ary = []\n ary << line while line = self.gets(eol)\n ary\n end", "def read_lines(file)\r\n\t\t\tbegin\r\n\t\t\t\tofile = File.new(file, \"r\")\r\n\t\t\t\twhile (line = ofile.gets)\r\n\t\t\t\t\t@lines += 1\r\n\t\t\t\t\tif line.strip == \"\"\r\n\t\t\t\t\t\t@blank_l...
[ "0.6214988", "0.6046981", "0.5999563", "0.59133846", "0.5821788", "0.58008426", "0.5792331", "0.57833105", "0.57811695", "0.5778541", "0.57660073", "0.5701542", "0.5680836", "0.5617509", "0.557957", "0.55741894", "0.5560662", "0.55430657", "0.55430657", "0.55310655", "0.55198...
0.68521875
0
in practice only ever has one
def body ret = read_attribute(:body) if ret.nil? return ret end ret = ret.strip ret = ret.gsub(/(?:\n\s*){2,}/, "\n\n") # remove excess linebreaks that unnecessarily space it out ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def used?; end", "def first; end", "def first; end", "def probers; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def only_once\n end", "def first?; end", "def schubert; end", "def who_we_are\r\n end", "def usable?; end", "def sh...
[ "0.719586", "0.71124876", "0.6404732", "0.6404732", "0.6395443", "0.63819706", "0.63819706", "0.63819706", "0.63819706", "0.63377327", "0.63286334", "0.6262489", "0.62571734", "0.6252193", "0.62059766", "0.62035406", "0.6201223", "0.61857516", "0.6167288", "0.616718", "0.6165...
0.0
-1
Check have edited comment
def validate if self.body.empty? || self.body =~ /^\s+$/ errors.add(:body, "^Please enter your annotation") end if !MySociety::Validate.uses_mixed_capitals(self.body) errors.add(:body, '^Please write your annotation using a mixture of capital and lower case letters. This ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edited?\n @description =~ /^[^\"].*edited \"/\n end", "def validate_update(comment)\n true\n end", "def can_comment_document?(doc = nil)\r\n self.can_edit_document?(doc)\r\n end", "def comment?\n @contents[0] == :comment\n end", "def comment_editable?(comment)\n current_user ...
[ "0.7151928", "0.69644165", "0.6751706", "0.67460954", "0.66919214", "0.6589904", "0.65677196", "0.6535489", "0.6535489", "0.6498572", "0.64627427", "0.6427703", "0.6410251", "0.63858503", "0.63813585", "0.63663965", "0.6335777", "0.6333254", "0.6323292", "0.6320259", "0.63133...
0.0
-1
Return body for display as HTML
def get_body_for_html_display text = self.body.strip text = CGI.escapeHTML(text) text = MySociety::Format.make_clickable(text, :contract => 1) text = text.gsub(/\n/, '<br>') return text end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def body_as_html\n return '' if !body\n return body if content_type && content_type =~ %r{text/html}i\n\n body.text2html\n end", "def render_html_body\n # FIXME actually render the text\n renderer.new(body).to_html\n end", "def body_to_html\n self.body = self.body.gsub(\"\\n\", '<br /...
[ "0.8086462", "0.7895857", "0.7833566", "0.7770269", "0.76918817", "0.76849055", "0.7661397", "0.76116127", "0.7561229", "0.7521177", "0.7479464", "0.745448", "0.74039066", "0.7395077", "0.7368422", "0.7357749", "0.7325746", "0.73053074", "0.7296617", "0.7277943", "0.7265037",...
0.8007179
1
Never trust parameters from the scary internet, only allow the white list through.
def user_params params.require(:user).permit(:name, :email, :email_confirmation, :phone, :company_name, :token, :crew_id, :country_id, :accept_subscription) 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
TODO move scopes to User model
def scope_langs if params[:language_id].present? langs_scope = [] langs_scope << "langs.language_id = #{params[:language_id]}" langs_condition = "SELECT user_id FROM langs WHERE #{langs_scope.join('AND')}" @users = @users.where("users.id IN (#{langs_condition})") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_user_scope\n current_user\n end", "def user_scoped\n @_user_scoped ||= model.respond_to?(:user_scoped) ?\n model.user_scoped(current_user, scope_context, params[:id_target]) :\n model\n end", "def user_scope\n User.includes(:notification_settings)\n end...
[ "0.6521527", "0.64449763", "0.63882995", "0.63776624", "0.63020533", "0.62540686", "0.62275475", "0.61993533", "0.6177998", "0.6139761", "0.60707825", "0.60570544", "0.6054729", "0.6017517", "0.5990831", "0.5978664", "0.59677726", "0.5967384", "0.59650624", "0.59237075", "0.5...
0.0
-1
Starts all of the writers, then starts the reader. Child readers must call this to make sure the writers are all running and ready for data before the reader starts pushing data onto its Channel.
def start(callback) start_loop = EM.tick_loop do if @writers.empty? || @writers.all?(&:running?) :stop end end start_loop.on_stop { callback.call } log "Starting writers for reader #{self.__id__}..." EM::Iterator.new(@writers).each do |writer, ite...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n raise Pants::Error, \"No readers added yet\" if @readers.empty?\n\n starter = proc do\n puts \"Pants v#{Pants::VERSION}\"\n puts \">> Reading from #{@readers.size} readers\"\n\n @readers.each_with_index do |reader, i|\n puts \">> reader#{i}: Starting read on: #{re...
[ "0.7123494", "0.58143204", "0.57839566", "0.5726207", "0.570699", "0.5513256", "0.53999853", "0.53387743", "0.52967155", "0.52830595", "0.52721184", "0.5262513", "0.5211174", "0.51949465", "0.518648", "0.5166423", "0.5162375", "0.50971574", "0.5020702", "0.5010518", "0.497418...
0.6828326
1
Calls the reader's stopper, thus forcing the reader to shutdown. For readers that intend to read a finite amount of data, the Reader should call the stopper when it's done; for readers that read a nonstop stream (i.e. like an open socket), this gets called by OS signals (i.e. if you ctrlc).
def stop! stopper.call end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stopper\n return @stopper if @stopper\n\n @stopper = EM.Callback do\n log \"Got called back after finished reading. Starting shutdown...\"\n\n # remove this next_tick?\n EM.next_tick do\n start_loop = EM.tick_loop do\n if @writers.empty? || @wri...
[ "0.7552698", "0.74326926", "0.7271161", "0.6824287", "0.6737152", "0.6151687", "0.61305976", "0.61305976", "0.6088219", "0.60623294", "0.5922936", "0.581494", "0.58045274", "0.5783289", "0.5754567", "0.5743013", "0.5739097", "0.5732095", "0.5714743", "0.5711849", "0.5650007",...
0.56444496
21
Allows for adding "about me" info, depending on the reader type. This info is printed out when Pants starts, so you know get confirmation of what you're about to do. If you don't define this in your reader, nothing will be printed out.
def read_object if @read_object @read_object else warn "No read_object info has been defined for this reader." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def about\n\t\tputs \"Make: \" + @make\n\t\tputs \"Model: \" + @model\n\t\tputs \"Miles: \" + @miles.to_s\n\t\tputs \"Type: \" + @type\n\t\tputs \"Color: \" + @color\n\t\tputs \"Year: \" + @year.to_s\n\t\tif @used\n\t\t\tputs \"The #{@make} #{@model} is used.\"\n\t\telse\n\t\t\tputs \"The #{@make} #{@model} is new...
[ "0.65803194", "0.6535262", "0.65217555", "0.6515088", "0.64658445", "0.6412082", "0.6379148", "0.63529557", "0.63067555", "0.6280606", "0.6261065", "0.6253184", "0.6233815", "0.6208024", "0.62063164", "0.62063164", "0.62063164", "0.62063164", "0.62063164", "0.62063164", "0.62...
0.0
-1