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
Set the ignore pattern(s) for a resource type. This overwrites any existing ignore rules for that type. +pattern+ should be either a single string, or an array of strings with the pattern(s) to ignore.
def set_resource_ignore_pattern(type, pattern) raise TypeError "Ignore pattern must be a string or an array" unless pattern.is_a?(String) || pattern.is_a?(Array) @ignore_rules[type] = pattern end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ignore_resources(type, *patterns)\n @ignore_rules[type] += patterns\n end", "def ignore_resource_type(type)\n @ignore_rules[type] = \"*\"\n end", "def ignore(*patterns)\n @ignore_patterns += patterns\n end", "def ignore_files=(patterns)\n @finder.add_patterns(patterns)\n end", "...
[ "0.7843947", "0.7253926", "0.66458595", "0.641933", "0.618149", "0.61504966", "0.587761", "0.587761", "0.5745591", "0.56906414", "0.568445", "0.56734306", "0.56327707", "0.5601934", "0.5596171", "0.5550153", "0.54824615", "0.54457396", "0.5352503", "0.5320289", "0.5293905", ...
0.90202105
0
Render and deliver the chart
def getchart() # The x and y coordinates of the grid dataX = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] dataY = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] # The values at the grid points. In this example, we will compute the values using # the formula z = sin((x - 0.5) * 2 * pi) * sin((y - 0.5) * 2 * pi) dataZ = Array.new((dataX.length) * (dataY.length)) 0.upto(dataY.length - 1) do |yIndex| y = (dataY[yIndex] - 0.5) * 2 * 3.1416 0.upto(dataX.length - 1) do |xIndex| x = (dataX[xIndex] - 0.5) * 2 * 3.1416 dataZ[yIndex * (dataX.length) + xIndex] = Math.sin(x) * Math.sin(y) end end # Create a SurfaceChart object of size 720 x 540 pixels c = ChartDirector::SurfaceChart.new(720, 540) # Add a title to the chart using 20 points Times New Roman Italic font c.addTitle("Quantum Wave Function", "timesi.ttf", 20) # Set the center of the plot region at (360, 245), and set width x depth x height # to 360 x 360 x 270 pixels c.setPlotRegion(360, 245, 360, 360, 270) # Set the elevation and rotation angles to 20 and 30 degrees c.setViewAngle(20, 30) # Set the data to use to plot the chart c.setData(dataX, dataY, dataZ) # Spline interpolate data to a 80 x 80 grid for a smooth surface c.setInterpolation(80, 80) # Set surface grid lines to semi-transparent black (dd000000) c.setSurfaceAxisGrid(0xdd000000) # Set contour lines to semi-transparent white (80ffffff) c.setContourColor(0x80ffffff) # Add a color axis (the legend) in which the left center is anchored at (645, # 270). Set the length to 200 pixels and the labels on the right side. Use smooth # gradient coloring. c.setColorAxis(645, 270, ChartDirector::Left, 200, ChartDirector::Right ).setColorGradient() # Set the x, y and z axis titles using 10 points Arial Bold font c.xAxis().setTitle("x/L(x)", "arialbd.ttf", 10) c.yAxis().setTitle("y/L(y)", "arialbd.ttf", 10) c.zAxis().setTitle("Wave Function Amplitude", "arialbd.ttf", 10) # Output the chart send_data(c.makeChart2(ChartDirector::JPG), :type => "image/jpeg", :disposition => "inline") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_chart\n assert_privileges(\"view_graph\")\n\n if params[:report]\n rpt = MiqReport.for_user(current_user).find_by(:name => params[:report])\n rpt.generate_table(:userid => session[:userid])\n else\n rpt = if session[:report_result_id]\n MiqReportResult.for_user(curre...
[ "0.73793256", "0.71304905", "0.70487463", "0.7032319", "0.69694126", "0.69295007", "0.69255656", "0.69129133", "0.69128174", "0.68344223", "0.6826156", "0.68255234", "0.6810791", "0.6803158", "0.6785608", "0.67432153", "0.67410535", "0.6721165", "0.67112935", "0.67078435", "0...
0.6592078
33
Removes whitespaces in the front and end of the input from first and last name and also the biography
def remove_whitespace self.first_name = self.first_name.strip self.last_name = self.last_name.strip self.biography = self.biography.strip end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_name(first, last)\n return nil if first.empty? || last.empty?\n f = first.delete(\" \")\n l = last.delete(\" \")\n username = f[0]\n username << l\n user = username.downcase\n user.gsub(/[\\W]/, '') # this is meant to remove special characters, but it doesn't work!\nend", "def format_name(first...
[ "0.7499903", "0.7409945", "0.7345406", "0.73359597", "0.73234427", "0.7306973", "0.7280086", "0.72570145", "0.7240452", "0.7238246", "0.722455", "0.721664", "0.721664", "0.721664", "0.721664", "0.7210476", "0.71797687", "0.71405506", "0.71381617", "0.7131518", "0.7061805", ...
0.76936907
0
Capitalises the first letter of the first and last name and also the biography
def capitalize self.first_name = self.first_name.capitalize self.last_name = self.last_name.capitalize self.biography = self.biography.capitalize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def capitalize_names\n unless first_name.nil?\n self.first_name.downcase!\n self.first_name.capitalize!\n end\n unless last_name.nil?\n self.last_name.downcase!\n self.last_name.capitalize!\n end\n end", "def full_name\n new_name = first_name.capitalize + \" \" + last_name.capit...
[ "0.8037622", "0.78923017", "0.7864819", "0.77065295", "0.7674585", "0.76695436", "0.7617023", "0.75796074", "0.7579526", "0.757426", "0.7566343", "0.75640696", "0.75434285", "0.7542181", "0.7542181", "0.75418705", "0.739342", "0.7386974", "0.73840624", "0.73785585", "0.735428...
0.8472335
0
this is here in case no tests get defined; otherwise we get a warning
def test_nothing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __dummy_test__\n end", "def tests; end", "def tests; end", "def test_nothing\n end", "def my_tests\n end", "def test_nothing; end", "def default_test; end", "def default_test\r\n end", "def self_test; end", "def self_test; end", "def testing\n # ...\n end", "def test...
[ "0.7581276", "0.75529873", "0.75529873", "0.74052745", "0.73819876", "0.729273", "0.7260453", "0.72526103", "0.7183206", "0.7183206", "0.71438366", "0.71270245", "0.7096424", "0.70690125", "0.7068104", "0.7003627", "0.6997074", "0.69238853", "0.69235075", "0.68588597", "0.685...
0.7261434
6
There's no way to actually retrieve the list of classes from the transaction.
def snippet_tag end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def classes\n @classes.values\n end", "def classes\n @classes.values\n end", "def get_classes(trans)\n classes = []\n trans.each do |t|\n classes.push(t[:program])\n end\n classes.uniq\n end", "def classes\n @classes\n end", "def classes\n return [] unless c...
[ "0.69420046", "0.69420046", "0.680655", "0.67554045", "0.6689844", "0.66499114", "0.66397643", "0.657022", "0.64763314", "0.6397757", "0.63282716", "0.632577", "0.6323959", "0.6319028", "0.63084394", "0.62863106", "0.62860376", "0.6283725", "0.62686276", "0.62490124", "0.6227...
0.0
-1
Make sure that set tags are correctly in place, yo.
def snippet_tagged tags = {"testing" => true, "yayness" => false, "both" => false, "bothtrue" => true, "define" => true} tags.each do |tag, retval| assert_file("/tmp/tagged#{tag}#{retval.to_s}") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_tags(tags = Array.new)\n\n if tags.is_a?(String) and tags.downcase == 'all'\n @@default_tags.each do |value|\n @@edit_tags[value] = ''\n end\n elsif tags.is_a?(Array)\n tags.each do |value|\n @@edit_tags[value] = ''\n end\n elsif tags.is_a?(Hash)\n # NOTE: mi...
[ "0.70114285", "0.6884418", "0.68538433", "0.68538433", "0.68522084", "0.675157", "0.6566219", "0.6560281", "0.6560281", "0.653501", "0.6507399", "0.63874114", "0.6379803", "0.6365612", "0.63314134", "0.63188416", "0.6312225", "0.6300959", "0.6292585", "0.62651116", "0.6236579...
0.0
-1
GET /houses GET /houses.json
def index @houses = House.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\n @houses = House.page(params[:page]).per(House::PER_PAGE_COUNT)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @houses }\n end\n end", "def show\n @house = House.find(params[:id])\n\n respond_to do |format|\n format.html # show.h...
[ "0.7755468", "0.72251153", "0.72251153", "0.72251153", "0.7013426", "0.68941134", "0.6879322", "0.6842397", "0.6824697", "0.67889386", "0.6775232", "0.6765745", "0.6748915", "0.67026335", "0.6695037", "0.6578647", "0.6536889", "0.6505747", "0.64853257", "0.64805007", "0.64299...
0.70419747
7
GET /houses/1 GET /houses/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @house = House.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @house }\n end\n end", "def show\n @house = House.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render...
[ "0.7757515", "0.7757515", "0.7757515", "0.7454755", "0.7165616", "0.703296", "0.703296", "0.69945854", "0.6888096", "0.6836465", "0.68340325", "0.6821874", "0.6821874", "0.6821874", "0.6821874", "0.67988986", "0.67411494", "0.66795", "0.6622453", "0.6611221", "0.6591484", "...
0.0
-1
POST /houses POST /houses.json
def create @house = House.new(house_params) # respond_to do |format| @house.user_id = current_user.id puts current_user.inspect if @house.save render json: {:success => true} # render action: 'show', status: :created, location: @house # format.html { redirect_to @house, notice: 'House was successfully created.' } # format.json { render action: 'show', status: :created, location: @house } else render json: @house.errors, status: :unprocessable_entity # format.html { render action: 'new' } # format.json { render json: @house.errors, status: :unprocessable_entity } end # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @house = House.new(house_params)\n\n if @house.save\n render :show, status: :created, location: @house\n else\n render json: @house.errors, status: :unprocessable_entity\n end\n end", "def create\n @house = House.new(house_params)\n\n respond_to do |format|\n if @ho...
[ "0.71898353", "0.7159553", "0.70852417", "0.6993344", "0.6758313", "0.66763836", "0.6674277", "0.6674277", "0.6666474", "0.66180235", "0.6509482", "0.6463673", "0.6460983", "0.64502454", "0.64481866", "0.6395167", "0.6385454", "0.6384295", "0.6343362", "0.6325791", "0.6325475...
0.56404895
75
PATCH/PUT /houses/1 PATCH/PUT /houses/1.json
def update_address # respond_to do |format| @house = House.find_by(house_id: params[:house][:house_id],user_id: current_user.id) puts "*"*100 puts @house.inspect puts "*"*100 if @house.update(house_params) render json: {success: true} # format.html { redirect_to @house, notice: 'House was successfully updated.' } # format.json { head :no_content } else render json: @house.errors, status: :unprocessable_entity # format.html { render action: 'edit' } # format.json { render json: @house.errors, status: :unprocessable_entity } end # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @house = House.find(params[:id])\n\n respond_to do |format|\n if @house.update_attributes(params[:house])\n format.html { redirect_to @house, notice: 'Gig was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\"...
[ "0.69251406", "0.68048066", "0.6693043", "0.6693043", "0.6693043", "0.6693043", "0.66694534", "0.66694534", "0.66694534", "0.66694397", "0.65902984", "0.6501705", "0.6501705", "0.6394291", "0.6343564", "0.6331725", "0.62952983", "0.6277867", "0.6246994", "0.6243397", "0.62151...
0.6194299
22
DELETE /houses/1 DELETE /houses/1.json
def destroy @house.destroy respond_to do |format| format.html { redirect_to houses_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @house = House.find(params[:id])\n @house.destroy\n\n respond_to do |format|\n format.html { redirect_to houses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @house = House.find(params[:id])\n @house.destroy\n\n respond_to do |format|\n f...
[ "0.77543455", "0.77543455", "0.7672112", "0.7645166", "0.75765413", "0.7476717", "0.7476717", "0.7476717", "0.7476717", "0.7476717", "0.7476717", "0.7449904", "0.74197245", "0.7403426", "0.7398418", "0.72781473", "0.72177786", "0.7163746", "0.71527755", "0.711563", "0.7107729...
0.7702942
3
Use callbacks to share common setup or constraints between actions.
def set_house @house = House.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def house_params params.require(:house).permit(:country, :state, :city, :addl1, :addl2, :unit, :zip , :label , :street ,:Notes , :house_id, :phone, :email) 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
A Passenger should be initialized with a name as a string.
def initialize(name) @name = name @@all << self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_passenger(name)\n @passengers.push(name)\n end", "def initialize(name)\n if name == \"\"\n @name = \"User\"\n else\n @name = name[0].upcase + name[1..-1].downcase\n end\n end", "def initialize(params)\n @name = params[:name]\n end", "def initialize(name = '')\n ...
[ "0.67671907", "0.6475377", "0.62679577", "0.6222186", "0.62177825", "0.62137026", "0.62135583", "0.62019205", "0.62019205", "0.61755925", "0.61736083", "0.6169448", "0.6165174", "0.6150029", "0.6148645", "0.61421454", "0.6135963", "0.6135963", "0.6135963", "0.6135963", "0.613...
0.0
-1
Passengerrides Returns an array of Ride instances that this person has been on
def rides Ride.all.select {|ride| ride.passenger == self} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rides_as_passenger\n ride_ids = self.relationships.select(:ride_id).where(is_driving: false).joins(:ride).where(\"rides.user_id <> ?\", self.id)\n if ride_ids.count > 0\n Ride.where(\"id in (?)\", ride_ids)\n else\n []\n end\n end", "def rides\n Ride.all.select { |ride| ride.passeng...
[ "0.78584754", "0.7819839", "0.7783197", "0.77719986", "0.7579126", "0.7405516", "0.7275163", "0.7252747", "0.71211755", "0.7116556", "0.71062905", "0.70806444", "0.69916075", "0.6751973", "0.674884", "0.67207366", "0.66721326", "0.66454244", "0.6376701", "0.6319529", "0.62994...
0.78563064
1
Passengerdrivers Returns an array of Driver instances that this person has rode with
def drivers rides.map {|ride| ride.driver}.uniq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drivers\n rides.map { |ride| ride.driver }\n end", "def drivers()\n self.rides().map { | ride | ride.driver }\n end", "def return_all_drivers\n return @trips.map{ |trip| trip.driver }\n end", "def drivers\n driver_ids = trips.map { |trip| trip.driver_id }\n driver_ids.sort...
[ "0.7290532", "0.7185316", "0.7154262", "0.70732373", "0.6782371", "0.6642001", "0.6637319", "0.6563457", "0.64012957", "0.61659527", "0.60942173", "0.60743207", "0.6070962", "0.60134745", "0.5931216", "0.59010863", "0.58814186", "0.5861235", "0.58592016", "0.58387476", "0.583...
0.69327915
4
Passengertotal_distance Returns the floating number that represents the total distance the passenger has travelled using the service
def total_distance rides.reduce(0) {|total, ride| total + ride.distance} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_distance\n approved_flights.sum(:distance)\n end", "def total_distance\n distances = self.rides.map { |ride| ride.distance }\n distances.inject(:+).to_f\n end", "def getTotalDistance\n return @totalDistance\n end", "def total_distance()\n self.rides().map() { | ride | ride.dis...
[ "0.7340697", "0.73107654", "0.7024033", "0.6875924", "0.66844004", "0.66844004", "0.6642755", "0.6633383", "0.6573535", "0.6539771", "0.65032685", "0.6499423", "0.64359236", "0.6272329", "0.6167455", "0.61355585", "0.60976255", "0.6084541", "0.6074582", "0.60536134", "0.60293...
0.7018495
4
FIXME: Is this required after going to Ember / Go sim?
def simulation_data(number_of_periods=1440) # Key names depended on by Javascript return { number_of_periods: number_of_periods, selected_portfolio_weights: sorted_weights, simulation_parameters: simulation_input, expenses: expenses, time_steps: time_steps, real_estate: { mean: RealEstate.mean, std_dev: RealEstate.std_dev }, inflation: { mean: Inflation.mean, std_dev: Inflation.std_dev }, asset_return_data: asset_return_data } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spec; end", "def spec; end", "def ios; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def weber; end", "def private; end", "def mob; end", "def req\n \n end", "def respond(); end", "def standalone; end", "def request; end", "def request; end",...
[ "0.6086566", "0.6086566", "0.6060495", "0.60502523", "0.60502523", "0.60502523", "0.60502523", "0.59589607", "0.5946379", "0.58980834", "0.58281934", "0.5815878", "0.57507205", "0.5638545", "0.5638545", "0.5638545", "0.5638545", "0.5638545", "0.5638545", "0.5638545", "0.56385...
0.0
-1
Basically all of these private methods have been stubbed throughout the spec for this class. Careful.
def sorted_weights selected_portfolio_weights = @user.portfolio.weights sorted_weights = {} selected_portfolio_weights.keys.sort.each do |k| sorted_weights[k] = selected_portfolio_weights[k] end return sorted_weights end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def private_method\n end", "def stub_implementation; end", "def private_method; end", "def spec; end", "def spec; end", "def verify_stubbed_calls; end", "def internal; end", "def internal_methods; end", "def stubs; end", "def private_method\n end", "def __mock_reset;...
[ "0.75490767", "0.7315025", "0.7283141", "0.69403803", "0.69149214", "0.69149214", "0.6888036", "0.67300075", "0.66347194", "0.6609968", "0.65022534", "0.6492251", "0.6399474", "0.63616705", "0.63481694", "0.6332745", "0.6332745", "0.627845", "0.627845", "0.61683", "0.61507714...
0.0
-1
A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n. As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit. subtract array of intergers from array of abundant_sums
def abundant?(num) return false if num == 1 divisor_sum = (1..num/2).select {|divisor| num % divisor == 0}.reduce(:+) return true if divisor_sum > num end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def non_abundant_sums\r\n max = 28123\r\n range = (2..28123)\r\n abundants = range.select{|n| abundant?(n) }\r\n numbers_made_from_abundants = []\r\n abundants.each do |i|\r\n abundants.each do |j|\r\n sum = i + j \r\n break if sum > max \r\n numbers_made_from_abundants << sum \r\n...
[ "0.791095", "0.76900864", "0.7243866", "0.683217", "0.6756627", "0.67105687", "0.6623428", "0.65865076", "0.6484953", "0.6360068", "0.62639725", "0.62161577", "0.6206335", "0.6155544", "0.61219496", "0.60722834", "0.6013483", "0.59512556", "0.58757436", "0.5863895", "0.584631...
0.5943909
18
Used for uglifying source to minify
def uglify(str) IO.popen('uglifyjs -nc', 'r+') do |i| i.puts str i.close_write return i.read end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uglify(file)\n #'hello world'\n template = Tilt.new(File.join('views',file)).render(self)\n Uglifier.compile(template)\n #Uglifier.compile(ERB.new(File.read(File.join('views', file))).result(binding).force_encoding('UTF-8').gsub(/^#.*?\\n/,''))\n end", "def run_uglifyjs(input, generate_map)\n ...
[ "0.6779364", "0.677172", "0.67293745", "0.6713181", "0.6632158", "0.6632158", "0.6626246", "0.6353627", "0.6352437", "0.6340634", "0.63357973", "0.63155407", "0.61167014", "0.6087156", "0.60686487", "0.59780663", "0.5956528", "0.5905", "0.5898447", "0.58796734", "0.5878243", ...
0.68501604
0
Gzip code to check file size
def gzip(str) IO.popen('gzip -f', 'r+') do |i| i.puts str i.close_write return i.read end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compressed_size; end", "def compressed_size; end", "def decompressed_size; end", "def compressed_size=(_arg0); end", "def compressed_file_size\n return @compressed_file_size\n end", "def gzip?\n path.extname == '.gz'\n end", "def get_file_size\n file_size = @response[\"content-length...
[ "0.7381111", "0.7381111", "0.70838493", "0.69136703", "0.6896801", "0.68094325", "0.67686725", "0.6712575", "0.66536176", "0.6573888", "0.6446687", "0.631375", "0.6297984", "0.62793064", "0.6262253", "0.6258228", "0.6245231", "0.61108136", "0.6088114", "0.607803", "0.6066037"...
0.0
-1
IRB.conf[:PROMPT_MODE] = :SIMPLE IRB.conf[:SAVE_HISTORY] = 1000
def j(obj) puts obj.to_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_history\n IRB.conf[:SAVE_HISTORY]\n end", "def history_to_vi\n handling_jruby_bug do\n file = Tempfile.new(\"irb_tempfile\")\n get_lines(0..(Readline::HISTORY.size - 1)).each do |line|\n file << \"#{line}\\n\"\n end\n file.close\n system(\"vim #{file.path}\")\n end\nend", ...
[ "0.7302015", "0.6674004", "0.66518354", "0.6552477", "0.6266662", "0.6219309", "0.6087381", "0.5960961", "0.59565246", "0.59381163", "0.58746135", "0.58534133", "0.5849545", "0.58228105", "0.5803992", "0.57872075", "0.5744658", "0.5734214", "0.5734214", "0.5721341", "0.563901...
0.0
-1
Return only the methods not present on basic objects
def interesting_methods (self.methods - Object.instance_methods).sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_methods; end", "def unimplemented_methods_for(interface)\n interface.instance_methods(false).reject { |method| respond_to_missing?(method.to_sym, true) || self.method(method.to_sym).owner != interface }.sort.map(&:to_sym)\n end", "def unboring_instance_methods\n if [::BasicObject,::Object,::K...
[ "0.74134207", "0.7137985", "0.713452", "0.71170515", "0.7103655", "0.7080528", "0.7018574", "0.6998091", "0.69765466", "0.69636345", "0.694767", "0.6930179", "0.68457025", "0.68457025", "0.6813762", "0.6799226", "0.6773447", "0.6768513", "0.6725825", "0.67254245", "0.6704878"...
0.7209885
1
todo/check: can we make it work without "virtual" block_class method e.g. use constant lookup with singleton class or something possible?
def block_class() Block; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def singleton_class(&block)\n\t\tif block_given?\n\t\t(class << self; self; end).class_eval(&block)\n\t\tself\n\t\telse\n\t\t(class << self; self; end)\n\t\tend\n\tend", "def block_proc(&block)\n block.class\nend", "def subclass( & block )\n \n return frame_definer.subclass( & block )\n\n end", "def ...
[ "0.69367486", "0.67080015", "0.6588334", "0.6582744", "0.64662135", "0.6313277", "0.6258647", "0.6131594", "0.61151403", "0.6103358", "0.6103358", "0.61015606", "0.6099192", "0.6024898", "0.60237455", "0.59960234", "0.5992423", "0.59359664", "0.5925877", "0.5915566", "0.59155...
0.76308995
0
overwrite devises methods to allow for extra user attributes.
def sign_up_params params.require(:user).permit(:firstname, :lastname, :age, :email, :password, :password_confirmation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_fields(user)\n self.screen_name = user.screen_name\n self.name = user.name\n description_urls = user.attrs[:entities].try(:fetch, :description).try(:fetch, :urls, nil)\n self.description = description_urls ? expand_urls(user.description, description_urls) : user.description\n self.locatio...
[ "0.639865", "0.6391063", "0.6333518", "0.6229188", "0.6220647", "0.62104833", "0.61685735", "0.6092518", "0.6092518", "0.60889274", "0.6087485", "0.6078701", "0.6070846", "0.60453343", "0.60436386", "0.6030879", "0.60267097", "0.5981184", "0.5975785", "0.59614325", "0.595771"...
0.0
-1
upvote_from user downvote_from user
def upvote @recipe.upvote_from current_user redirect_to root_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upvote_from(user)\n votes.find_by(user_id: user.id)\n end", "def auto_upvote\n upvote(self.user)\n end", "def upvote(current_user)\n if current_user && current_user.voted_up_on?(self)\n self.unliked_by current_user\n else\n self.liked_by current_user\n end\n end", "def vote_up...
[ "0.80569184", "0.80558366", "0.7833712", "0.773781", "0.7732453", "0.7718296", "0.7629553", "0.76186705", "0.7618643", "0.7579774", "0.7489388", "0.7396136", "0.72932684", "0.72932273", "0.727609", "0.726667", "0.72539365", "0.72468776", "0.7237623", "0.7175208", "0.71313894"...
0.68259525
44
initialize Declare basic hash containing setting statistics
def initialize @statistics = { settings: {}, profiles: {} }.with_indifferent_access end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n # We start with an empty hash of stats\n @stats = {}\n end", "def initialize\n\t\t\t@hash = {}\n\t\tend", "def initialize\n @settings = Hash.new\n end", "def initialize\n @stats = {}\n @schema = {}\n @ebd_cache = {}\n end", "def initialize option = {}\n @option = Fl...
[ "0.72860324", "0.7223091", "0.715398", "0.6958149", "0.6907958", "0.689372", "0.689372", "0.68097514", "0.67500633", "0.65943366", "0.6585405", "0.65459746", "0.65378326", "0.65085196", "0.64230186", "0.64079624", "0.6406629", "0.63806295", "0.63699716", "0.6364578", "0.63519...
0.7382707
0
[] Accessor method for setting statistics to guarantee proper initialization of hashes.
def [](name) @statistics[:settings][name] = { usages: 0, failures: 0 }.with_indifferent_access if @statistics[:settings][name].blank? @statistics[:settings][name] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def statistics\n @statistics ||= []\n end", "def initialize\n # We start with an empty hash of stats\n @stats = {}\n end", "def stats\n DEFAULT_STATS.dup\n end", "def stats\n {}\n end", "def initialize\n @statistics = { settings: {}, profiles: {} }.with_indiffere...
[ "0.6902335", "0.6779108", "0.6388082", "0.6363075", "0.6247054", "0.6233056", "0.61346155", "0.61035657", "0.60775715", "0.6071706", "0.6065663", "0.60240275", "0.60240275", "0.5982505", "0.59807867", "0.59780264", "0.5953733", "0.5936543", "0.5930254", "0.59212637", "0.59212...
0.58704436
38
increment_profile_failure_of Increments the number of failures for settings while a profile is active
def increment_profile_failure_of(name) @statistics[:profiles][name] ||= 0 @statistics[:profiles][name] += 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increment_failure_of(setting_name)\n self[setting_name][:failures] += 1\n\n current_profile = Profile.current\n increment_profile_failure_of(current_profile.name) if current_profile\n\n Sail.reset(setting_name) if self[setting_name][:failures] > Sail.configuration.failures_until_reset\n ...
[ "0.7820291", "0.65397227", "0.627024", "0.6156453", "0.6133318", "0.5793997", "0.57900935", "0.57900935", "0.5704575", "0.5649008", "0.5595164", "0.5537438", "0.54746467", "0.5416328", "0.5405627", "0.5390397", "0.53641045", "0.53641045", "0.5350467", "0.53100514", "0.5300143...
0.7994284
0
profile Profile statistics accessor
def profile(name) @statistics[:profiles][name] ||= 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile; end", "def profile; end", "def profile\n @property[:profile]\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile(value)\n _profile(value) or fail ArgumentError, \"Unkno...
[ "0.74901223", "0.74901223", "0.71991503", "0.7026443", "0.7026443", "0.7026443", "0.7026443", "0.7026443", "0.7026443", "0.69429266", "0.6940027", "0.6867196", "0.6833371", "0.6818106", "0.6664187", "0.66213435", "0.66213435", "0.65993446", "0.65993446", "0.65550613", "0.6552...
0.7112698
3
increment_usage Simply increments the number of times a setting has been called
def increment_usage_of(setting_name) self[setting_name][:usages] += 1 expire_cache_fragment(setting_name) if (self[setting_name][:usages] % USAGES_UNTIL_CACHE_EXPIRE).zero? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inc_usage\n @mutex.synchronize { @usage_count += 1 }\n end", "def increase_used\n self[:numUsed] += 1\n end", "def increment_update_count\n self.settings.increment!(:updates) if settings\n end", "def use(n=1)\n self.used += n\n end", "def incr_count\n @count ||= 0\n @count += ...
[ "0.79424", "0.69918543", "0.6857216", "0.6770971", "0.6655218", "0.6629269", "0.6586875", "0.647175", "0.6434713", "0.64162827", "0.6409127", "0.6370788", "0.6335237", "0.6335237", "0.6322065", "0.631959", "0.6261403", "0.62443113", "0.6235154", "0.617777", "0.61706305", "0...
0.7640431
1
relative_usage_of Calculates the relative usage of a setting compared to all others in percentage
def relative_usage_of(setting_name) return 0.0 if @statistics[:settings].empty? (100.0 * self[setting_name][:usages]) / @statistics[:settings].map { |_, entry| entry[:usages] }.reduce(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def percent_used\n 100 - (100.0 * bytes_free.to_f / bytes_total.to_f)\n end", "def percentage_change\n return unless starting_weight && up_by\n @percentage_change ||= up_by.to_f / starting_weight * 100\n end", "def target_utilization\n target_allocation = TargetAllocation.find_by_level(le...
[ "0.601073", "0.5942003", "0.5923456", "0.5844276", "0.5833148", "0.5814743", "0.5802318", "0.57745516", "0.5745064", "0.57014793", "0.5692378", "0.5689783", "0.5689783", "0.5662484", "0.56592226", "0.5638739", "0.5602038", "0.5602038", "0.5598719", "0.5576063", "0.55709153", ...
0.84657663
0
increment_failure_of Counts the number of failed code block executions enveloped by a given setting. If the number of failures exceeds the amount configured, resets the setting value
def increment_failure_of(setting_name) self[setting_name][:failures] += 1 current_profile = Profile.current increment_profile_failure_of(current_profile.name) if current_profile Sail.reset(setting_name) if self[setting_name][:failures] > Sail.configuration.failures_until_reset end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def failure!\n @count += 1\n end", "def failed_count=(value)\n @failed_count = value\n end", "def increment_failures_metric\n metric_increment(:failures)\n end", "def work_profile_password_sign_in_failure_count_before_factory_reset=(value)\n @work_profile_...
[ "0.64376277", "0.6352721", "0.63196594", "0.61855066", "0.60934675", "0.59774035", "0.59313023", "0.59313023", "0.580858", "0.58063483", "0.574833", "0.5730803", "0.5713291", "0.5710953", "0.5690186", "0.5638161", "0.559329", "0.55760986", "0.5528688", "0.55102706", "0.550726...
0.745808
0
Displays a link to user's account page if active
def link_to_user(user, options={}) if (User.current.admin || User.current.allowed_to?(:view_profiles, @project, :global => true)) && user.is_a?(User) name = h(user.name(options[:format])) if user.active? link_to name, :controller => 'users', :action => 'show', :id => user else name end else h(user.to_s) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account_link\n return link_to I18n.t('user.show'), user_path(current_user) if current_user?\n link_to I18n.t('navigation.sign_up'), new_user_path\n end", "def link_to_user(user, options={})\r\n (user) ? link_to(user.name, :controller => 'account', :action => 'show', :id => user) : 'Anonymous'\r\n ...
[ "0.7703806", "0.73711205", "0.6979982", "0.6949762", "0.6945772", "0.6841198", "0.6809197", "0.68034136", "0.68033653", "0.6779746", "0.67665553", "0.674798", "0.6727749", "0.6676344", "0.6671614", "0.6669214", "0.6637192", "0.6624057", "0.66022456", "0.66012007", "0.65949357...
0.68082136
7
Convert the object to an Entities::List.
def extract_list(object) Entities::List.from_object(object) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_a\n @list\n end", "def entities_list\n raise 'Not implemented'\n end", "def to_a; @list; end", "def _list\n if @_structure_changed \n @list = nil\n @_structure_changed = false\n end\n unless @list\n $log.debug \" XXX recreating _list\"\n conve...
[ "0.66906315", "0.6631621", "0.6453327", "0.62231094", "0.6194671", "0.61227715", "0.61081135", "0.60315806", "0.59791106", "0.5958592", "0.5884611", "0.58758193", "0.5813732", "0.57883805", "0.5786677", "0.5731349", "0.5720063", "0.56986356", "0.5668976", "0.56686765", "0.566...
0.80707115
0
Retrieve the list name.
def extract_listname(object) extract_list(object).list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_name\n @data['list_name']\n end", "def to_list_name value\n (value.to_s.singularize + '_list').to_sym\n end", "def names\n\n get_list['list'].collect { |re, pa| re }\n end", "def html_list_name(list_type, open_tag)\n tags = LIST_TYPE_TO_HTML[list_type]\n raise RDoc::Err...
[ "0.86761695", "0.7279757", "0.7238744", "0.6776345", "0.674686", "0.67207086", "0.6608825", "0.65842164", "0.6560843", "0.6545548", "0.6535988", "0.6535988", "0.6535988", "0.6535988", "0.65160257", "0.6478881", "0.6478578", "0.64691514", "0.64525956", "0.64414674", "0.6440179...
0.6762101
4
Retrieve the marketing email name
def extract_marketing_email(marketing_email) case marketing_email when ::String marketing_email when Entities::MarketingEmail marketing_email.name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_name\n email\n end", "def name\n \temail.split('@')[0]\n end", "def email_name\n @email_name || if self[:email]\n split_host = URI.parse(\"#{self[:email]}\").path.split('@')\n \"#{split_host.first}\" if 2 == split_host.size\n end\n rescue URI::InvalidURIError\n nil\n ...
[ "0.7349181", "0.7344511", "0.7327517", "0.72585213", "0.72141165", "0.71533537", "0.7066453", "0.7062101", "0.7054095", "0.7027778", "0.7017925", "0.7012335", "0.69684196", "0.69684196", "0.69684196", "0.69056696", "0.68915087", "0.6886579", "0.68687564", "0.6865236", "0.6864...
0.75861174
0
>> JavaScript Method Hooks
def onfocus_js "le_onfocus(this)" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hooks\n # ???\n end", "def hook1; end", "def hook\n self.class.hook\n end", "def action_hook; end", "def before_hook(method_name)\n hooks << method_name\n end", "def method_added(*) end", "def methods() end", "def method; end", "def method; end", "def method; end", "def meth...
[ "0.7293643", "0.7098805", "0.6901638", "0.6529105", "0.6471412", "0.6436388", "0.64324456", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.6427748", "0.63704133", "0.63633066", ...
0.0
-1
Taken from FakeStripe.stub_stripe at fake_stripe gem:
def prepare reset yield self if block_given? # Since the OAuth flow is performed by the browser, we'll need to boot # the Sinatra app instead of just stubbing the app with WebMock... boot_once OmniAuth::Strategies::Icalia.instances.each do |strategy| strategy.options.client_options.tap do |options| options.site = url options.token_url = "#{url}/oauth/token" options.authorize_url = "#{url}/oauth/authorize" end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stub_stripe_customer(email = 'current.user@email.com')\n url = 'https://api.stripe.com/v1/customers'\n url2 = 'https://api.stripe.com/v1/customers/us_123'\n\n stub_request(:post, url).with(body: { 'email' => email })\n .to_return(status: 200, body: { id: 'us_123' }.to_json, headers: {})\n\n st...
[ "0.6546358", "0.5954333", "0.59513944", "0.5908589", "0.59028006", "0.58841497", "0.5869665", "0.5862415", "0.5826116", "0.582205", "0.57981074", "0.578663", "0.578663", "0.57705325", "0.57517576", "0.57432944", "0.57329184", "0.57045287", "0.5696884", "0.5696462", "0.5685467...
0.0
-1
Taken from FakeStripe::Utils at fake_stripe gem: =======================
def find_available_port server = TCPServer.new(FIND_AVAILABLE_PORT) server.addr[1] ensure server.close if server end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def managed?; stripe_account_type == 'managed'; end", "def managed?; stripe_account_type == 'managed'; end", "def test_successful_purchase_encryption_credit_card_recurring_metadata\n test_successful_purchase_credit_card_recurring_metadata(true)\n end", "def test_successful_purchase_encryption_stored_card...
[ "0.5973838", "0.5973838", "0.5920452", "0.5885415", "0.58686286", "0.58686286", "0.5850595", "0.58435917", "0.58156514", "0.5798956", "0.572943", "0.57120454", "0.566375", "0.5661029", "0.56446445", "0.5639294", "0.562298", "0.56021726", "0.5594526", "0.5593123", "0.55795735"...
0.0
-1
Taken from Bootable at fake_stripe gem: ================================
def boot(port = find_available_port) instance = new Capybara::Server.new(instance, port: port).tap(&:boot) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guard_process_payment_from_created; true; end", "def guard_process_payment_from_created; true; end", "def managed?; stripe_account_type == 'managed'; end", "def managed?; stripe_account_type == 'managed'; end", "def stripe_config\n Lynr.config('app').stripe\n end", "def create_stripe(server)\...
[ "0.5913649", "0.5913649", "0.5892587", "0.5892587", "0.5778524", "0.577635", "0.55657077", "0.5537797", "0.5521136", "0.5470261", "0.5460663", "0.5458072", "0.5403846", "0.539318", "0.53696615", "0.5331071", "0.5321385", "0.53211695", "0.5280641", "0.52569264", "0.5247539", ...
0.0
-1
GET /platos/1 GET /platos/1.json
def show @plato = Plato.find(params[:id]) if !@plato.comentario.first.nil? render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id], include: [comentario:{only: [:id]}]) else render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @platforms = Platform.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @platforms }\n end\n end", "def show\n @platform = Platform.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { r...
[ "0.6509391", "0.650262", "0.62856686", "0.6278362", "0.6015262", "0.60054135", "0.5962152", "0.59464663", "0.5942659", "0.59119475", "0.590621", "0.590621", "0.590621", "0.588067", "0.5836736", "0.58217686", "0.5784175", "0.5750938", "0.57506424", "0.57491654", "0.57395405", ...
0.5857115
14
POST /platos POST /platos.json
def create if params[:get] @plato = Plato.where("soda_id = ?", params[:soda_id]) #if !@plato.comentario.first.nil? # render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id], include: [comentario:{only: [:id]}]) #else render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id]) #end else @plato = Plato.new(plato_params) if @plato.save render json: @plato, status: :created, location: @plato else render json: @plato.errors, status: :unprocessable_entity end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @platoon = Platoon.new(platoon_params)\n\n respond_to do |format|\n if @platoon.save\n format.html { redirect_to @platoon, notice: 'Platoon was successfully created.' }\n format.json { render action: 'show', status: :created, location: @platoon }\n else\n format.ht...
[ "0.6343715", "0.6261399", "0.61363", "0.6133776", "0.60872984", "0.60626936", "0.60403645", "0.6013021", "0.5995882", "0.59625965", "0.58955556", "0.58465827", "0.5845856", "0.58165956", "0.5798757", "0.57879645", "0.57771593", "0.57741386", "0.5749923", "0.57379115", "0.5728...
0.6004806
8
PATCH/PUT /platos/1 PATCH/PUT /platos/1.json
def update @plato = Plato.find(params[:id]) if @plato.update(plato_params) head :no_content else render json: @plato.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plato...
[ "0.68450093", "0.646693", "0.644885", "0.6244275", "0.62308604", "0.6219468", "0.6196651", "0.6165147", "0.61600596", "0.61321187", "0.6100461", "0.605178", "0.6041475", "0.60122305", "0.5967836", "0.5965216", "0.5954541", "0.5929694", "0.59289336", "0.59240055", "0.5913639",...
0.69962424
0
DELETE /platos/1 DELETE /platos/1.json
def destroy @plato = Plato.find(params[:id]) @plato.destroy head :no_content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @platoon.destroy\n respond_to do |format|\n format.html { redirect_to platoons_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete_tenant_circle(args = {}) \n...
[ "0.7145133", "0.69759876", "0.69366765", "0.6792817", "0.6758421", "0.6724626", "0.67171943", "0.6705854", "0.6705635", "0.6668557", "0.66610414", "0.66610414", "0.66610414", "0.66610414", "0.6654543", "0.6640999", "0.6640544", "0.66265494", "0.6623942", "0.6621288", "0.66121...
0.69127905
3
Purchase first period's subscription now. If that's successful, schedule recurring payments starting in one period and continuing indefinitely.
def purchase!(parent) return false unless self.valid? && parent.valid? response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options) begin ot = OrderTx.new(:user_id => parent.user_id, :action => "subscribe", :amount => price_in_cents, :response => response) unless response.success? errors[:base] << response.message else recurring_response = GATEWAY.recurring(price_in_cents, credit_card, recurring_purchase_options) unless recurring_response.success? GATEWAY.void(response.authorization) errors[:base] << recurring_response.message else self.order_tx = ot self.upstream_authorization = recurring_response.authorization self.end_at = nil # Time.now + billing_interval parent.upstream_authorization = self.upstream_authorization return parent.save! end end ot.save! return false rescue # void the purchase if we aren't able to save details GATEWAY.void(response.authorization) raise end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_recurring_payment\n return unless recurring_period.present?\n run_at = nil\n if recurring_period.to_s.is_i? # each custom days\n run_at = recurring_period.to_i.days.from_now\n # run_at = recurring_period.to_i.minutes.from_now\n else\n case recurring_period\n when 'daily'...
[ "0.7582205", "0.68755877", "0.6595211", "0.65620285", "0.6549252", "0.6469632", "0.63975316", "0.6393924", "0.636656", "0.6350344", "0.63404393", "0.6303728", "0.62999046", "0.62759703", "0.6263765", "0.62575316", "0.62371194", "0.6189156", "0.6187016", "0.61640525", "0.61014...
0.557868
85
Defining class attributes Initializing class attriutes
def initialize # Call function to generate the account number account_number_gen # Initialize instance variables @checking_account_balance = 0 @saving_account_balance = 0 @@total_accounts += 1 @interest_rate = 0.01 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_attributes\n @loader_for = 'class'\n @type_path = ''\n @module = ::Interferon\n end", "def initialize attr={}\n super\n self.attributes = attr\n end", "def initialize(attrs = {})\n @attributes = attrs\n\n # Set values where we have defined a reader, pr...
[ "0.739431", "0.72977334", "0.72131425", "0.71884054", "0.71657777", "0.71407163", "0.7119774", "0.71158797", "0.71139354", "0.7096723", "0.7040006", "0.7032338", "0.7021734", "0.6980931", "0.6980931", "0.6977362", "0.6971191", "0.69620985", "0.6961375", "0.69606537", "0.69576...
0.0
-1
Defininf public methods Print account number
def account_number return @account_number end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bank_account_number\n @account_number = 12345\n puts \"My bank account number is #{@account_number}.\"\n end", "def get_account_number\n @acct_num\n end", "def display_account_details\n puts \"\"\n puts \"Account Details\"\n puts \"-------------------------\"\n ...
[ "0.74063075", "0.72764075", "0.727415", "0.7247245", "0.712404", "0.7011481", "0.7011481", "0.6919054", "0.6852189", "0.65861195", "0.64077425", "0.63976824", "0.6385888", "0.62082225", "0.620233", "0.6187413", "0.61802304", "0.6178631", "0.6154061", "0.6147708", "0.61440414"...
0.68937635
8
Print checking account current balance.
def checking_account_balance return @checking_account_balance end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_wallet\n\t\tputs \"\\n\\n\\n\"\n\t\tputs \"Your balance: #{@balance.round(2)}\"\n\tend", "def display_balance()\n puts \"Balance:$#{@balance}.\"\n returned\n end", "def check_balance_display\n\t\tputs \"#######################\"\n\t\tputs \"# #\"\n\t\tputs \"# ...
[ "0.81002116", "0.79789686", "0.77659386", "0.7747762", "0.7621027", "0.76210153", "0.7619947", "0.75144976", "0.74738955", "0.74432164", "0.74281424", "0.7400929", "0.7390365", "0.7375084", "0.7372229", "0.72485095", "0.7190354", "0.7176619", "0.7176619", "0.71187425", "0.711...
0.6732359
34
Print saving account current balance.
def saving_account_balance return @saving_account_balance end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_wallet\n\t\tputs \"\\n\\n\\n\"\n\t\tputs \"Your balance: #{@balance.round(2)}\"\n\tend", "def to_s\n\t\t puts \"Bank Account:\\t#{name}\\n\"\n\t\t puts \"Your current balance is:\\t#{sprintf(\"%0.2f\", balance)} USD\" \n\tend", "def to_s\n\t\t puts \"\\nEnding balance:\\nBank Account Name:\\t#{name...
[ "0.8030263", "0.7688791", "0.76697963", "0.758089", "0.75275236", "0.7353605", "0.7331738", "0.7327936", "0.7325618", "0.72926426", "0.72005695", "0.7191653", "0.70464885", "0.7038669", "0.70366156", "0.70358866", "0.701993", "0.701993", "0.69952375", "0.69769317", "0.6966855...
0.70284337
16
Print total balance the user holds on the bank.
def total_balance return @checking_account_balance + @saving_account_balance end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_balance\n\t\tputs \"Total Balance: #{@@accounts.total}\"\n\tend", "def print_wallet\n\t\tputs \"\\n\\n\\n\"\n\t\tputs \"Your balance: #{@balance.round(2)}\"\n\tend", "def show_balance(user)\n puts \"Name: #{user.name}, balance: #{user.balance}, points: #{user.card_points}\"\n end", "def balan...
[ "0.8205086", "0.81467044", "0.7955425", "0.7843821", "0.7840803", "0.76372194", "0.7609323", "0.75589335", "0.7487697", "0.7474823", "0.7451758", "0.73776925", "0.7370854", "0.7359118", "0.7285713", "0.7167877", "0.7126468", "0.7119258", "0.7064329", "0.70585954", "0.705025",...
0.6622177
40
Print total accounts open in the bank.
def total_accounts return @@total_accounts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_balance\n\t\tputs \"Total Balance: #{@@accounts.total}\"\n\tend", "def print_billcoins\r\n\t\t@billcoins.each_pair {|k, v| puts \"#{k}: #{v} billcoins\" unless k==\"SYSTEM\"}\t# don't print SYSTEM billcoin count\r\n\tend", "def print_register\n\t\tputs \"#{name}'s Bank Account\"\n\t\tputs \"-\" * 40\...
[ "0.6575668", "0.6406739", "0.6248954", "0.62293774", "0.62293774", "0.6195105", "0.617477", "0.6136102", "0.60654604", "0.6036869", "0.5965247", "0.5959392", "0.5929593", "0.58603865", "0.5852249", "0.58458614", "0.5840265", "0.5805269", "0.5789608", "0.57781315", "0.5744938"...
0.57352066
21
Method for providing overall information of the account
def account_information puts "====================" puts "Account information:" puts "====================" puts "\nAccount number: %d" % [@account_number] puts "\nTotal money: %d" % [total_balance] puts "\nChecking account balance: %d" % [@checking_account_balance] puts "\nSaving account balance: %d" % [@saving_account_balance] puts "\nInterest rate: %.2f" % [@interest_rate] puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account_information\n puts \"Account Number: #%d\" % @account_number\n puts \"\\t- Checking Amount: $%d\" % @checking_amount \n puts \"\\t- Saving Amount: $%d\" % @saving_amount\n puts \"\\t- Total Amouunt: $%d\" % (@checking_amount + @saving_amount)\n puts \"\\t- inter...
[ "0.79762834", "0.79762834", "0.78916734", "0.77339315", "0.7381825", "0.727287", "0.7072165", "0.70392656", "0.70191723", "0.70191723", "0.6996307", "0.69509715", "0.68972355", "0.6857849", "0.6838006", "0.680566", "0.67781204", "0.67724854", "0.6742002", "0.6719641", "0.6694...
0.7820353
3
Method for depositing money to either the saving or checking account. Takes 2 arguments, the amount to deposit and the account to deposit to.
def deposit (amount, account) if account == "checking" @checking_account_balance += amount elsif account == "saving" @saving_account_balance += amount else puts "No account was selected" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deposit acct, amount\n\t\t\treturn \"Invalid account: '#{acct}'\" unless valid_acct acct\n\n\t\t\tamount = to_money amount.abs\n\n\t\t\tadjust acct, amount\n\t\tend", "def deposit(amount, options={})\n adjust_and_save(amount.abs, :deposit, options)\n end", "def deposit(amount)\n deposit_account = Ac...
[ "0.79598594", "0.7762837", "0.7737345", "0.76928484", "0.766417", "0.7637499", "0.7522926", "0.73803616", "0.7380066", "0.73645747", "0.7341934", "0.7339288", "0.7339288", "0.7335199", "0.731025", "0.7304748", "0.7304748", "0.7304748", "0.7301779", "0.73015845", "0.73009914",...
0.8411288
0
Method for withdrawing money to either the saving or checking account. Takes 2 arguments, the amount to witdraw and the account to witdraw to.
def withdraw (amount, account) if account == "checking" @checking_account_balance -= amount elsif account == "saving" @saving_account_balance -= amount else puts "No account was selected" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def withdraw acct, amount\n\t\t\treturn \"Invalid account: '#{acct}'\" unless valid_acct acct\n\n\t\t\tamount = to_money -(amount)\n\n\t\t\tadjust acct, amount\n\t\tend", "def withdraw(name_of_account, amount)\n\t\taccount = find_account(name_of_account)\n\t\tbalance_check = account[:balance] \n\t\tif balance_ch...
[ "0.7211299", "0.7044004", "0.69914114", "0.6919707", "0.6918348", "0.6905271", "0.6827556", "0.68068707", "0.6793618", "0.6759879", "0.6735974", "0.6693255", "0.6691027", "0.6690633", "0.66809934", "0.66729665", "0.6651623", "0.6651623", "0.66445464", "0.664298", "0.66083634"...
0.7885702
0
Helper function to determine if the file_contents view should show nested process_files.
def check_for_nested_process_files if params[:parent_controller] == "process_files" @show_nested_process_files = false else @show_nested_process_files = true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def partial?\n file_type == :view and basename !~ /^_/\n end", "def outlineView(outlineView, isItemExpandable:item)\n return (item.instance_of? MatchedFile) ? true : false;\n end", "def are_sub_contents_posts?\n ret_val = true\n\n if @is_post\n ret_val = false\n else\n sub_dire...
[ "0.6185017", "0.6159389", "0.60998213", "0.6017511", "0.5970456", "0.5934107", "0.58309615", "0.5782715", "0.5750077", "0.5750077", "0.5708891", "0.56668335", "0.5630697", "0.56290984", "0.5590042", "0.5575117", "0.5563208", "0.5543678", "0.55217224", "0.55185395", "0.5515883...
0.79074156
0
Helper function to allow users to download data for any corresponding FileContent.
def download_data file_content = nil begin file_content = FileContent.find(params[:id]) rescue file_content = nil end # We need to figure out which groups are allowed to download this file content. # Unfortunately, this requires iterating through any referenced URLs and collecting # all applicable group_ids. group_ids = [] if (!file_content.nil? && !file_content.data.nil?) file_content.process_files.each do |process_file| if (!process_file.os_process.nil? && !process_file.os_process.fingerprint.nil? && !process_file.os_process.fingerprint.url.nil?) # Clear the cache, if need be. process_file.os_process.fingerprint.url.expire_caches group_ids << process_file.os_process.fingerprint.url.group_id end end group_ids.uniq! end if (!file_content.nil? && !file_content.data.nil? && (!group_ids.index(nil).nil? || current_user.has_role?(:admin) || ((current_user.groups.map{|g| g.is_a?(Group) ? g.id : g} & group_ids).size > 0))) send_file(RAILS_ROOT + '/' + file_content.data.to_s, :x_sendfile => true) else redirect_back_or_default('/') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download\n # TODO: Find out why this is needed, should be handeled in ability.rb\n authorize! :read, params[:id]\n begin\n send_data @file.datastreams['content'].content, {:filename => @file.original_filename, :type => @file.mime_type}\n rescue ActiveFedora::ObjectNotFoundError => obj_not_foun...
[ "0.707737", "0.67335", "0.67031246", "0.63948214", "0.63370013", "0.63067627", "0.6273001", "0.6262625", "0.6241434", "0.6236238", "0.62046343", "0.6199757", "0.61783695", "0.61345077", "0.60444546", "0.6016278", "0.5974224", "0.597248", "0.59624565", "0.59589076", "0.5941575...
0.7514178
0
XXX: This should mimic UrlsController.conditions_for_collection. Restrict who can see what records in list view. Admins can see everything. Users in groups can see only those corresponding records along with records not in any group. Users not in a group can see only those corresponding records.
def conditions_for_url_collection return [ 'urls.group_id IS NULL' ] if current_user.nil? return [] if current_user.has_role?(:admin) groups = current_user.groups if (groups.size > 0) return [ '(urls.group_id IN (?) OR urls.group_id IS NULL)', groups.map!{|g| g.is_a?(Group) ? g.id : g} ] else return [ 'urls.group_id IS NULL' ] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conditions_for_collection\n return [ 'urls.group_id IS NULL' ] if current_user.nil?\n return [] if current_user.has_role?(:admin)\n groups = current_user.groups\n if (groups.size > 0)\n return [ '(urls.group_id IN (?) OR urls.group_id IS NULL)', groups.map!{|g| g.is_a?(Group) ? g.id : g} ]\n ...
[ "0.7600885", "0.64430946", "0.6179417", "0.6151778", "0.6120144", "0.59720254", "0.5917369", "0.58986294", "0.58748364", "0.5848452", "0.5754401", "0.5744626", "0.5744308", "0.5716397", "0.57077754", "0.5706226", "0.5682254", "0.5660932", "0.56556225", "0.5646421", "0.5631965...
0.76540864
1
We will eventually fill the hard disk if we don't clean old files from our temp dir. We consider the file to be "old" enough to delete if it has not been modified in the last hour. This is enough time that we won't clobber a file that another rails thread/process may be in the middle of serving to a different user.
def remove_old_files Dir .glob("#{@tmp_dir_path}/**/*") .each { |path| FileUtils.rm_rf(path) if old?(path) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup_old_files\n # make a local copy of to_delete while simultaneously clearing the original (atomicity)\n # local_to_delete = $to_delete.slice!(0..-1).to_a\n local_to_delete = []\n $to_delete.delete_if { |v| local_to_delete << v; true }\n\n $files.each_pair do |uuid, file|\n if file.nil?\n $fi...
[ "0.7041321", "0.70320725", "0.6979031", "0.67682135", "0.6691422", "0.6595511", "0.65894234", "0.64592665", "0.6456341", "0.6444902", "0.64295876", "0.63831514", "0.63831514", "0.6314637", "0.629275", "0.62773174", "0.62562317", "0.6248398", "0.62380874", "0.6226413", "0.6197...
0.5831666
51
GET /illustrations GET /illustrations.json
def index @illustrations = Illustration.all respond_to do |format| format.html # index.html.erb format.json { render json: @illustrations } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @illustration = Illustration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @illustration }\n end\n end", "def show\n @illustration = Illustration.find(params[:id])\n\n respond_to do |format|\n format.html # show.h...
[ "0.78365785", "0.779795", "0.73788106", "0.69480324", "0.6921894", "0.66705", "0.6611732", "0.63962114", "0.63949335", "0.6276904", "0.621465", "0.6160132", "0.6123969", "0.6116585", "0.6110125", "0.61045986", "0.6098228", "0.6080609", "0.6068715", "0.6068075", "0.6057891", ...
0.80229855
0
GET /illustrations/1 GET /illustrations/1.json
def show @illustration = Illustration.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @illustration } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @illustration = Illustration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @illustration }\n end\n end", "def index\n @illustrations = Illustration.all\n\n respond_to do |format|\n format.html # index.html.erb\...
[ "0.8136571", "0.7968159", "0.7377078", "0.7308708", "0.7281195", "0.69048876", "0.67916495", "0.66066676", "0.6527715", "0.6518617", "0.65029526", "0.6457165", "0.64571434", "0.642235", "0.6421315", "0.6357346", "0.63562316", "0.6346873", "0.62983316", "0.6279917", "0.6276558...
0.81777936
0
GET /illustrations/new GET /illustrations/new.json
def new @illustration = Illustration.new respond_to do |format| format.html # new.html.erb format.json { render json: @illustration } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @illustration = Illustration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @illustration }\n end\n end", "def create\n @illustration = Illustration.new(params[:illustration])\n\n respond_to do |format|\n if @illustration.save\...
[ "0.8359883", "0.765464", "0.7623027", "0.719481", "0.7158022", "0.70888704", "0.70683604", "0.70683604", "0.70683604", "0.703232", "0.694322", "0.6934547", "0.6922091", "0.69080925", "0.69080925", "0.69080925", "0.69080925", "0.69080925", "0.69080925", "0.6870186", "0.686742"...
0.8417096
0
POST /illustrations POST /illustrations.json
def create @illustration = Illustration.new(params[:illustration]) respond_to do |format| if @illustration.save format.html { redirect_to @illustration, notice: 'Illustration was successfully created.' } format.json { render json: @illustration, status: :created, location: @illustration } else format.html { render action: "new" } format.json { render json: @illustration.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @illustration = Illustration.new(params[:illustration])\n\n respond_to do |format|\n if @illustration.save\n format.html { redirect_to @illustration, :notice => 'Illustration was successfully created.' }\n format.json { render :json => { :normal_url => @illustration.attachment...
[ "0.7514649", "0.7010254", "0.6967858", "0.6845353", "0.6828422", "0.6800282", "0.6716906", "0.6566204", "0.65339994", "0.6392234", "0.63073933", "0.62491363", "0.6240274", "0.6212084", "0.6186521", "0.61698264", "0.59309155", "0.5735406", "0.5724795", "0.5643828", "0.5625372"...
0.760457
0
PUT /illustrations/1 PUT /illustrations/1.json
def update @illustration = Illustration.find(params[:id]) respond_to do |format| if @illustration.update_attributes(params[:illustration]) format.html { redirect_to @illustration, notice: 'Illustration was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @illustration.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @illustration = Illustration.find(params[:id])\n\n respond_to do |format|\n if @illustration.update_attributes(params[:illustration])\n format.html { redirect_to @illustration, :notice => 'Illustration was successfully updated.' }\n format.json { head :ok }\n else\n ...
[ "0.78649753", "0.7384994", "0.67194176", "0.6656395", "0.65376955", "0.6497663", "0.64239866", "0.6386787", "0.63053036", "0.62881756", "0.62729406", "0.6244577", "0.6179941", "0.61719316", "0.6025085", "0.597871", "0.5932373", "0.59301704", "0.58543825", "0.5843059", "0.5841...
0.78056544
1
DELETE /illustrations/1 DELETE /illustrations/1.json
def destroy @illustration = Illustration.find(params[:id]) @illustration.destroy respond_to do |format| format.html { redirect_to illustrations_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @illustration = Illustration.find(params[:id])\n @illustration.destroy\n\n respond_to do |format|\n format.html { redirect_to illustrations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @illustration.destroy\n respond_to do |format|\n format.html { ...
[ "0.82673883", "0.7745296", "0.71213955", "0.7036805", "0.6914853", "0.68550074", "0.6711836", "0.6668847", "0.6623818", "0.6603219", "0.65992224", "0.658602", "0.6582396", "0.65752894", "0.6570055", "0.6553664", "0.6547936", "0.65275645", "0.6524393", "0.6514618", "0.65121406...
0.8265636
1
Get the name of this application from an i18n string key: blacklight.application_name Try first in the current locale, then the default locale
def application_name # It's important that we don't use ActionView::Helpers::CacheHelper#cache here # because it returns nil. Rails.cache.fetch 'blacklight/application_name' do t('blacklight.application_name', default: t('blacklight.application_name', locale: I18n.default_locale)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def application_name\n @application_name ||= t('application.name')\n end", "def application_name\n if Rails.application.config.respond_to? :application_name\n Deprecation.warn(self, \"BlacklightHelper#application_name will no longer delegate to config.application_name in version 7.0. Set the i18n for...
[ "0.74399596", "0.7407995", "0.6944458", "0.6920393", "0.6766582", "0.6701616", "0.6695391", "0.66189134", "0.6512662", "0.64497316", "0.6447032", "0.6427098", "0.6365714", "0.6364275", "0.6358664", "0.6320045", "0.6320045", "0.6320045", "0.6310448", "0.62950265", "0.626108", ...
0.73780483
2
Render a partial of an arbitrary format inside a template of a different format. (e.g. render an HTML partial from an XML template) code taken from: (zgchurch)
def with_format(format) old_formats = formats self.formats = [format] yield self.formats = old_formats nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_partial(template, types, context)\n templates.get(template, types).render(context)\n end", "def partial(template, *args)\n template_array = template.to_s.split('/')\n template = template_array[0..-2].join('/') + \"/_#{template_array[-1]}\"\n options = args.last.is_a?(Hash) ? args.pop ...
[ "0.70352745", "0.70249206", "0.69945925", "0.69838935", "0.6874967", "0.6874967", "0.6862633", "0.6822051", "0.6802403", "0.67766315", "0.66388583", "0.6634993", "0.66204494", "0.66088355", "0.6598179", "0.6584182", "0.65485895", "0.65269434", "0.65269434", "0.6456303", "0.64...
0.0
-1
GET /receivables GET /receivables.xml
def index @filter = {:starts_at => "", :ends_at => "", :field_filter => "1"} params[:receivables] ||= {} if params[:receivables][:starts_at].blank? && params[:receivables][:ends_at].blank? @filter[:starts_at] = Date.today.beginning_of_month @filter[:ends_at] = Date.today.end_of_month else @filter[:starts_at] = params[:receivables][:starts_at] @filter[:ends_at] = params[:receivables][:ends_at] end @receivables = Receivable.grid @filter[:starts_at], @filter[:ends_at], @filter[:field_filter] respond_to do |format| format.html # index.html.erb format.xml { render :xml => @receivables } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @receivables = Receivable.all.where(secure: true, user_id: current_user.id)\n end", "def index\n @receiving_items = ReceivingItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receiving_items }\n end\n end", "def show\n @acc...
[ "0.6337441", "0.6214563", "0.6045008", "0.5983918", "0.57592195", "0.5741166", "0.57253855", "0.5691124", "0.5643203", "0.56050396", "0.56041205", "0.5590633", "0.5586817", "0.55841815", "0.5577051", "0.5568165", "0.5563527", "0.55370134", "0.55197495", "0.547917", "0.5396996...
0.5706603
7
GET /receivables/1 GET /receivables/1.xml
def show @receivable = Receivable.find(params[:id]) session[:rec_id] = params[:id] respond_to do |format| format.html # show.html.erb format.xml { render :xml => @receivable } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @account_receivable = AccountReceivable.find(params[:id])\n @account_receivables = AccountReceivable.where(parent_id: @account_receivable.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @account_receivable }\n end\n end", "def index\n @...
[ "0.61085993", "0.6092532", "0.5962244", "0.59402204", "0.5719963", "0.5680886", "0.561287", "0.55813044", "0.5536437", "0.5525889", "0.5505332", "0.5500946", "0.54660565", "0.5362093", "0.5348986", "0.5346776", "0.5331492", "0.531789", "0.52811974", "0.5280574", "0.5275318", ...
0.6139611
0
GET /receivables/new GET /receivables/new.xml
def new @receivable = Receivable.new @division = ReceivableCostDivision.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @receivable } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\r\n @receivable = Receivable.new(params[:receivable])\r\n\r\n respond_to do |format|\r\n if @receivable.save\r\n flash[:notice] = 'Título a receber criado.'\r\n format.html { redirect_to(@receivable) }\r\n format.xml { render :xml => @receivable, :status => :created, :lo...
[ "0.6310484", "0.61955845", "0.6081978", "0.5961428", "0.59396225", "0.59267396", "0.59081644", "0.5902238", "0.5901212", "0.5895293", "0.58951503", "0.5879152", "0.58639485", "0.5850283", "0.58451635", "0.58451635", "0.58451635", "0.58441967", "0.5839272", "0.5838839", "0.583...
0.64595526
0
POST /receivables POST /receivables.xml
def create @receivable = Receivable.new(params[:receivable]) respond_to do |format| if @receivable.save flash[:notice] = 'Título a receber criado.' format.html { redirect_to(@receivable) } format.xml { render :xml => @receivable, :status => :created, :location => @receivable } else format.html { render :action => "new" } format.xml { render :xml => @receivable.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_receivable\n @receivable = Receivable.find(params[:id])\n end", "def receivable_params\n params.require(:receivable).permit(:company_id, :receiveable_amount, :check_date, :transaction_date, :remarks, :bill_no)\n end", "def destroy\r\n @receivable = Receivable.find(params[:id])\r\n ...
[ "0.555241", "0.53743315", "0.52616787", "0.50699687", "0.5019647", "0.4883769", "0.4874821", "0.48553044", "0.4798842", "0.47946125", "0.47623774", "0.4761077", "0.47319287", "0.47260323", "0.47013366", "0.46716368", "0.4671442", "0.4656825", "0.4652881", "0.46513727", "0.464...
0.53281695
2
PUT /receivables/1 PUT /receivables/1.xml
def update @receivable = Receivable.find(params[:id]) respond_to do |format| if @receivable.update_attributes(params[:receivable]) flash[:notice] = 'Título a receber atualizado.' format.html { redirect_to(@receivable) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @receivable.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_receivable\n @receivable = Receivable.find(params[:id])\n end", "def destroy\r\n @receivable = Receivable.find(params[:id])\r\n @receivable.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(receivables_url) }\r\n format.xml { head :ok }\r\n end\r\n end",...
[ "0.59127337", "0.57440567", "0.5228107", "0.51379484", "0.5068359", "0.5066991", "0.50611925", "0.50456583", "0.50351065", "0.5026737", "0.50076824", "0.49860886", "0.49506196", "0.49335426", "0.49186087", "0.49085823", "0.4900029", "0.48939782", "0.4885339", "0.48654073", "0...
0.6081234
0
DELETE /receivables/1 DELETE /receivables/1.xml
def destroy @receivable = Receivable.find(params[:id]) @receivable.destroy respond_to do |format| format.html { redirect_to(receivables_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @account_receivable = AccountReceivable.find(params[:id])\n @account_receivable.destroy\n\n respond_to do |format|\n format.html { redirect_to account_receivables_url }\n format.json { head :no_content }\n end\n end", "def netdev_resxml_delete( xml )\n top = netdev_resxml_...
[ "0.6557468", "0.6291568", "0.6130711", "0.5991867", "0.59546214", "0.58427", "0.58307743", "0.5818832", "0.5814328", "0.57919073", "0.5768768", "0.5756435", "0.5750247", "0.57407796", "0.57051516", "0.5704089", "0.56941324", "0.5693632", "0.5651324", "0.5636266", "0.56315166"...
0.74343026
0
GET /candies/new GET /candies/new.json
def new @candy = Candy.new respond_to do |format| format.html # new.html.erb format.json { render :json => @candy } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @county = County.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @county }\n end\n end", "def new\n @borrow = Borrow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @borrow }\n end\n...
[ "0.7096646", "0.7065967", "0.70286304", "0.6951581", "0.6949998", "0.69169044", "0.6900484", "0.6880899", "0.68494534", "0.6804563", "0.6800513", "0.679223", "0.6763984", "0.6763371", "0.67626065", "0.67626065", "0.67469656", "0.67469656", "0.6733507", "0.673343", "0.6723348"...
0.70596904
2
POST /candies POST /candies.json
def create @candy = PendingCandy.new(params[:candy]) respond_to do |format| if @candy.save logger.info "candy saved successfully" logger.info @candy.to_json format.html { redirect_to @candy, :notice => 'Candy was successfully created.' } format.json { render :json => { :status => 200, :candy => @candy } } else logger.info "error saving candy" logger.info @candy.errors.full_messages format.html { render :action => "new" } format.json { render :json => {:message => @candy.errors.full_messages.join("\n"), :status => 404} } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_candies\n @candies.each do |candy|\n get_candy(candy) unless Candy.where(name: candy['name']).first\n end\n end", "def create\n @candy = Candy.new(candy_params)\n\n respond_to do |format|\n if @candy.save\n format.html { redirect_to @candy, notice: \"Candy was successfull...
[ "0.6453379", "0.6292946", "0.62412006", "0.61069024", "0.60269284", "0.59473306", "0.5817647", "0.5817647", "0.5785647", "0.5756256", "0.5712163", "0.56907934", "0.56806684", "0.56797105", "0.56761825", "0.5669325", "0.5661755", "0.5639899", "0.562185", "0.56083655", "0.55960...
0.63642883
1
PUT /candies/1 PUT /candies/1.json
def update @candy = Candy.find(params[:id]) respond_to do |format| if @candy.update_attributes(params[:candy]) format.html { redirect_to @candy, :notice => 'Candy was successfully updated.' } format.json { render :json => @candy, :status => :updated, :candy => @candy } else format.html { render :action => "edit" } format.json { render :json => @candy.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entit...
[ "0.61696976", "0.6080346", "0.60092515", "0.5963338", "0.59329", "0.5878397", "0.586978", "0.58394194", "0.57620823", "0.57230973", "0.5720888", "0.5720888", "0.57129395", "0.5697846", "0.566383", "0.563406", "0.56286097", "0.55991185", "0.55990696", "0.5579943", "0.5573553",...
0.6109583
1
DELETE /candies/1 DELETE /candies/1.json
def destroy @candy = Candy.find(params[:id]) @candy.destroy respond_to do |format| format.html { redirect_to candies_url } format.json { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @candy.destroy\n respond_to do |format|\n format.html { redirect_to candies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @candy = Candy.find(params[:id])\n @candy.destroy\n\n respond_to do |format|\n format.html { redirect_to(candies_url) }...
[ "0.7244314", "0.70599824", "0.7010737", "0.7001017", "0.69814837", "0.6952611", "0.6908932", "0.68725973", "0.6819381", "0.68108755", "0.68068427", "0.6800659", "0.6790558", "0.6770035", "0.67495173", "0.6739481", "0.6739481", "0.6715737", "0.6697108", "0.66877985", "0.667452...
0.73060846
0
Reparse the query vars.
def parse_query_vars parse_query end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_query\n @attributes = nil\n @scope = nil\n @filter = nil\n @extensions = nil\n\n if @query\n attrs, scope, filter, extensions = @query.split('?')\n\n @attributes = attrs if attrs && attrs.size > 0\n @scope = scope if scope && scope.size > 0\n ...
[ "0.68767333", "0.67069584", "0.67069584", "0.61917484", "0.61615074", "0.61615074", "0.5997025", "0.5985104", "0.5982722", "0.5958779", "0.5918082", "0.5886137", "0.58828044", "0.5849108", "0.5733178", "0.57066786", "0.56501836", "0.56459856", "0.5616411", "0.560355", "0.5579...
0.80148566
0
Fills in the query variables, which do not exist within the parameter.
def fill_query_vars(array) array.stringify_keys! keys = [ 'error', 'm', 'p', 'post_parent', 'subpost', 'subpost_id', 'attachment', 'attachment_id', 'name', 'static', 'pagename', 'page_id', 'second', 'minute', 'hour', 'day', 'monthnum', 'year', 'w', 'category_name', 'tag', 'cat', 'tag_id', 'author', 'author_name', 'feed', 'tb', 'paged', 'meta_key', 'meta_value', 'preview', 's', 'sentence', 'title', 'fields', 'menu_order', 'embed', ] keys.each do |key| array[key] ||= '' end array_keys = [ 'category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 'post_name__in', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'post_parent__in', 'post_parent__not_in', 'author__in', 'author__not_in', ] array_keys.each do |key| array[key] ||= [] end array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_params=(_arg0); end", "def prep_query\n @options[:query]['region_id'] = @region_id if @region_id\n @options[:query]['state'] = @state if @state\n @options[:query]['county'] = @countye if @county\n @options[:query]['city'] = @city if @city\n @options[:query]['childtype'] = @childtype if @...
[ "0.6482687", "0.64347243", "0.62002134", "0.6139179", "0.6049604", "0.6038028", "0.6021706", "0.5969806", "0.5950411", "0.5927248", "0.5918062", "0.5868425", "0.5867173", "0.5850482", "0.5832334", "0.5819101", "0.5782775", "0.5782775", "0.5782775", "0.5782775", "0.578019", ...
0.5909831
11
Parses various taxonomy related query vars.
def parse_tax_query(q) if !q['tax_query'].blank? && q['tax_query'].is_a?(Array) tax_query = q['tax_query'] else tax_query = [] end if !q['taxonomy'].blank? && !q['term'].blank? tax_query << { taxonomy: q['taxonomy'], terms: [q['term'] ], field: 'slug' } end get_taxonomies({}, 'objects').each do |taxonomy, t| next if taxonomy == 'post_tag' # Handled further down in the $q['tag'] block if !t.query_var.blank? && !q[t.query_var].blank? tax_query_defaults = {taxonomy: taxonomy, field: 'slug'} # if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) { # $q[ $t->query_var ] = wp_basename( $q[ $t->query_var ] ); # } term = q[t.query_var] term = term.join(',') if term.is_a? Array if term.include? '+' terms = term.split(/[+]+/) terms.each do |term| tax_query << tax_query_defaults.merge({terms: [term]}) end else tax_query << tax_query_defaults.merge({terms: term.split(/[,]+/)}) end end # If querystring 'cat' is an array, implode it. q['cat'] = q['cat'].join(',') if q['cat'].is_a?(Array) # Category stuff if !q['cat'].blank? && !@is_singular cat_in = cat_not_in = [] cat_array = CGI.unescape(q['cat'].to_s).split(/[,\s]+/) cat_array.map! { |num| num.to_i } q['cat'] = cat_array.join(',') cat_array.each do |cat| if cat > 0 cat_in << cat elsif cat < 0 cat_not_in << cat.abs end end unless cat_in.blank? tax_query << { taxonomy: 'category', terms: cat_in, field: 'term_id', include_children: true, } end unless cat_not_in.blank? tax_query << { taxonomy: 'category', terms: cat_not_in, field: 'term_id', operator: 'NOT IN', include_children: true, } end end end # TODO continue... # if ( ! empty( $q['category__and'] ) && 1 === count( (array) $q['category__and'] ) ) { # $q['category__and'] = (array) $q['category__and']; # if ( ! isset( $q['category__in'] ) ) { # $q['category__in'] = array(); # } # $q['category__in'][] = absint( reset( $q['category__and'] ) ); # unset( $q['category__and'] ); # } # # if ( ! empty( $q['category__in'] ) ) { # $q['category__in'] = array_map( 'absint', array_unique( (array) $q['category__in'] ) ); # $tax_query[] = array( # 'taxonomy' => 'category', # 'terms' => $q['category__in'], # 'field' => 'term_id', # 'include_children' => false, # ); # } # # if ( ! empty( $q['category__not_in'] ) ) { # $q['category__not_in'] = array_map( 'absint', array_unique( (array) $q['category__not_in'] ) ); # $tax_query[] = array( # 'taxonomy' => 'category', # 'terms' => $q['category__not_in'], # 'operator' => 'NOT IN', # 'include_children' => false, # ); # } # # if ( ! empty( $q['category__and'] ) ) { # $q['category__and'] = array_map( 'absint', array_unique( (array) $q['category__and'] ) ); # $tax_query[] = array( # 'taxonomy' => 'category', # 'terms' => $q['category__and'], # 'field' => 'term_id', # 'operator' => 'AND', # 'include_children' => false, # ); # } # If querystring 'tag' is array, implode it. q['tag'] = q['tag'].join(',') if q['tag'].is_a?(Array) # Tag stuff # TODO continue... @tax_query = Railspress::WpTaxQuery.new(tax_query) # Fires after taxonomy-related query vars have been parsed. do_action( 'parse_tax_query', self ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_query_vars\n parse_query\n end", "def parse_query(query); end", "def parse_query(query); end", "def clean_query(query)\n # if ( empty( $query['taxonomy'] ) ) {\n # \t\t\tif ( 'term_taxonomy_id' !== $query['field'] ) {\n # \t\t\t\t$query = new WP_Error( 'invalid_taxonomy', __( 'In...
[ "0.65669143", "0.5547232", "0.5547232", "0.5521944", "0.5507666", "0.5404734", "0.51076716", "0.5072543", "0.5054574", "0.50284165", "0.50119704", "0.49987212", "0.49947557", "0.497099", "0.49345332", "0.49224475", "0.49050453", "0.48731032", "0.48612463", "0.4854482", "0.485...
0.72704977
0
Generates SQL for the WHERE clause based on passed search terms.
def parse_search(q) # TODO continue end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_where_phrase\n opt_where = @opt[:where]\n\n return '' if opt_where.nil? or opt_where.empty?\n\n where = []\n opt_where.each_pair { |k, v|\n a = @entity.attr(k)\n r = @entity.rel(k)\n if a\n raise \"Field #{k.inspect} is not indexed\" unless a.indexed?\...
[ "0.7320163", "0.7135825", "0.7023859", "0.68449897", "0.6811561", "0.6793269", "0.67417085", "0.67106235", "0.66950905", "0.66763455", "0.6647353", "0.66157925", "0.6535915", "0.6496179", "0.6473605", "0.63994575", "0.63555133", "0.63551784", "0.63451785", "0.63169605", "0.62...
0.0
-1
Sets up the WordPress query by parsing query string.
def query(query) init @query = @query_vars = Railspress::Functions.wp_parse_args(query) get_posts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_query\n @attributes = nil\n @scope = nil\n @filter = nil\n @extensions = nil\n\n if @query\n attrs, scope, filter, extensions = @query.split('?')\n\n @attributes = attrs if attrs && attrs.size > 0\n @scope = scope if scope && scope.size > 0\n ...
[ "0.6550332", "0.6344027", "0.63421404", "0.6324232", "0.6324232", "0.6220426", "0.6207033", "0.61564", "0.61523545", "0.608825", "0.60618573", "0.59877247", "0.597761", "0.597761", "0.58748287", "0.5761146", "0.57447433", "0.5742489", "0.56799585", "0.56799585", "0.56799585",...
0.6780597
0
Retrieve queried object. If queried object is not set, then the queried object will be set from the category, tag, taxonomy, posts page, single post, page, or author query variable. After it is set up, it will be returned.
def get_queried_object return @queried_object unless @queried_object.blank? @queried_object = nil @queried_object_id = nil if @is_category || @is_tag || @is_tax if @is_category if get('cat') term = get_term( get('cat'), 'category' ) elsif get('category_name') term = get_term_by('slug', get('category_name'), 'category' ) end elsif @is_tag if get('tag_id') term = get_term( get('tag_id'), 'post_tag' ) elsif get('tag') term = get_term_by('slug', get('tag'), 'post_tag' ) end else # For other tax queries, grab the first term from the first clause. # TODO continue.. end if !term.blank? && !term.is_a?(Railspress::WP_Error) @queried_object = term @queried_object_id = term.term_id end elsif @is_post_type_archive post_type = get('post_type') if post_type.is_a?(Array) # ??? $post_type = reset( $post_type ); end @queried_object = get_post_type_object(post_type) elsif @is_posts_page page_for_posts = get_option('page_for_posts') @queried_object = get_post(page_for_posts) @queried_object_id = @queried_object.id elsif @is_singular && !@post.blank? @queried_object = @post @queried_object_id = @post.id elsif is_author? @queried_object_id = get('author').to_i @queried_object = Railspress::User.find(@queried_object_id) # get_userdata(@queried_object_id) else end @queried_object end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def object(query, kwargs = {})\n objs = objects(query, kwargs)\n return objs.length == 1 ? objs[0] : nil\n end", "def query query_object\n\t\tcase query_object.kind\n\t\t\twhen \"random\"\n\t\t\t\tget_random query_object\n\t\t\twhen \"query\"\n\t\t\t\tget_query query_object\n\t\t\twhen \"category_ki...
[ "0.68817705", "0.6471857", "0.6345158", "0.62917197", "0.60367376", "0.6002035", "0.5916103", "0.5841156", "0.5799064", "0.5771868", "0.5656308", "0.563125", "0.55190575", "0.5503859", "0.5499184", "0.5498822", "0.54932845", "0.5459291", "0.54539955", "0.54539955", "0.5453995...
0.7061635
0
Retrieve ID of the current queried object.
def get_queried_object_id get_queried_object return @queried_object_id unless @queried_object_id.blank? return 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def id\n object.id.to_i\n end", "def getId()\n @obj.getId()\n end", "def get_id()\n return @id\n end", "def id\n object.id.to_s\n end", "def id\n object.object_id\n end", "def id\n object[\"id\"]\n end", "def get_id()\n return @id\n end", "d...
[ "0.81119543", "0.8094947", "0.793199", "0.7922853", "0.7817728", "0.7802929", "0.776647", "0.77650774", "0.77650774", "0.77602416", "0.77602416", "0.76921755", "0.7664316", "0.7645097", "0.7645097", "0.7645097", "0.7645097", "0.76091623", "0.7574229", "0.75512654", "0.7503596...
0.0
-1
Is the query for an existing archive page? Month, Year, Category, Author, Post Type archive...
def is_archive? @is_archive end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def archive\n @truncate_posts = true\n year = params[:year]\n month = params[:month]\n @date = Date.parse(\"#{year}-#{month}-01\").strftime('%B, %Y')\n @posts = Post.from_archive(year, month)\n\n if can? :read_drafts, Post\n @posts = @posts.recent\n else\...
[ "0.6691832", "0.6373195", "0.6351096", "0.63156956", "0.6272957", "0.6270318", "0.62238777", "0.6179511", "0.6140963", "0.60801023", "0.6004127", "0.6004127", "0.59405285", "0.5919919", "0.5917389", "0.5895011", "0.58752227", "0.5823575", "0.58220583", "0.5777848", "0.5769375...
0.639489
1
Is the query for an existing post type archive page?
def is_post_type_archive?(post_types = '') return @is_post_type_archive if post_types.blank? || !@is_post_type_archive post_type = get('post_type') if post_type.is_a?(Array) post_type = post_type.first end post_type_object = get_post_type_object(post_type) post_types.include?(post_type_object.name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_page?\n is_entry? && params[:_entry_type_] == 'page'\n end", "def is_post?\n is_entry? && params[:_entry_type_] == 'post'\n end", "def is_archive?\n @is_archive\n end", "def in_archive?\n self.display\n end", "def is_blog_post?\n self.type == 'Blog'\n end", "def is_blog_post?\n...
[ "0.70335776", "0.6754136", "0.66437536", "0.6640215", "0.6507107", "0.6507107", "0.6486546", "0.63852787", "0.63293755", "0.6316673", "0.6241803", "0.6194146", "0.6137484", "0.60818356", "0.6062333", "0.60269415", "0.60148305", "0.5947584", "0.59276843", "0.59025645", "0.5892...
0.74770606
0
TODO is_attachment Is the query for an existing author archive page? If the $author parameter is specified, this function will additionally check if the query is for one of the authors specified.
def is_author?( author = '' ) return false unless @is_author return true if author.blank? author_obj = get_queried_object author = [author].map {|a| a.to_s} if author.include?(author_obj.id.to_s) return true elsif author.include?(author_obj.nickname) return true elsif author.include?(author_obj.user_nicename) return true end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_author\n if person_signed_in?\n @is_author = Author.where(\"person_id = ? AND document_id = ?\", current_person.id, @document.id).present?\n else\n @is_author = false\n end\n end", "def author?\n !author.nil? && !author.empty?\n end", "def has_author?(author)\n ret = ...
[ "0.64646894", "0.627879", "0.61562186", "0.6089134", "0.60124487", "0.5770352", "0.5765772", "0.575442", "0.5754295", "0.5746283", "0.56931084", "0.56663644", "0.56190133", "0.5563878", "0.5465746", "0.54545265", "0.54290193", "0.5376997", "0.53534865", "0.5336007", "0.532840...
0.6661737
0
Is the query for an existing category archive page? If the $category parameter is specified, this function will additionally check if the query is for one of the categories specified.
def is_category?( category = '' ) return false unless @is_category return true if category.blank? cat_obj = get_queried_object category = [category] unless category.is_a?(Array) category.map!(&:to_s) if category.include?(cat_obj.term_id.to_s) return true elsif category.include?(cat_obj.name) return true elsif category.include?(cat_obj.slug) return true end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_category?(category, article)\n if article[:categories].nil?\n false\n else\n article[:categories].include?(category)\n end\n end", "def is_categories?\n is_entries? && params[:_taxonomies_].present? && params[:_slug_].present? && is_not_page?\n end", "def has_category?(category_...
[ "0.6522713", "0.6466872", "0.6180042", "0.5966112", "0.5905771", "0.59022003", "0.58958185", "0.58790237", "0.5787471", "0.572194", "0.5712258", "0.5687633", "0.56745255", "0.5652634", "0.5627494", "0.5611841", "0.5609814", "0.5603988", "0.5593569", "0.5521446", "0.55120265",...
0.68502265
0
Is the query for an existing tag archive page? If the tag parameter is specified, this function will additionally check if the query is for one of the tags specified.
def is_tag?( tag = '' ) return false unless @is_tag return true if tag.blank? tag_obj = get_queried_object tag = [tag] unless tag.is_a?(Array) tag.map!(&:to_s) if tag.include?(tag_obj.term_id.to_s) return true elsif tag.include?(tag_obj.name) return true elsif tag.include?(tag_obj.slug) return true end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tagged?(tag)\n @tags.include?(tag)\n end", "def has_tag? (tag)\n\n @tags.include?(tag)\n end", "def has_tag?(tag)\n tags.include?(tag.to_s)\n end", "def filtered_by_tag?(tag)\n tags_from_params.include?(tag.name)\n end", "def hastag?(tag)\n @...
[ "0.6592629", "0.659149", "0.65853673", "0.65747106", "0.64483607", "0.6382933", "0.6373077", "0.63703823", "0.63127327", "0.62849385", "0.62689394", "0.6253935", "0.621102", "0.61685306", "0.6164206", "0.60774225", "0.59926987", "0.5987077", "0.5961041", "0.59171116", "0.5881...
0.6893459
0
Is the query for an existing custom taxonomy archive page? If the $taxonomy parameter is specified, this function will additionally check if the query is for that specific $taxonomy. If the $term parameter is specified in addition to the $taxonomy parameter, this function will additionally check if the query is for one of the terms specified.
def is_tax(taxonomy = '', term = '') return false unless @is_tax return true if taxonomy.blank? queried_object = get_queried_object # TODO continue is_tax # $tax_array = array_intersect( array_keys( $wp_taxonomies ), (array) $taxonomy ); # $term_array = (array) $term; # # // Check that the taxonomy matches. # if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) ) { # return false; # } # Only a Taxonomy provided. return true if term.blank? # return isset( $queried_object->term_id ) && # count( # array_intersect( # array( $queried_object->term_id, $queried_object->name, $queried_object->slug ), # $term_array # ) # ); false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_categories?\n is_entries? && params[:_taxonomies_].present? && params[:_slug_].present? && is_not_page?\n end", "def is_tags?\n is_categories? && params[:_taxonomies_] == 'post_tag'\n end", "def term_multiple?( term )\n #puts \"=====> GenericWork.term_multiple? #{term}\"\n return true if [...
[ "0.5892783", "0.5204153", "0.51289153", "0.50723755", "0.5020871", "0.49739817", "0.485651", "0.47832564", "0.47623128", "0.47470236", "0.47386256", "0.47268522", "0.4659903", "0.45171627", "0.4516291", "0.45093387", "0.44910285", "0.44817853", "0.44680434", "0.4419216", "0.4...
0.70556474
0
TODO is_comments_popup Is the query for an existing date archive?
def is_date @is_date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def directed_at_by_date(other_user_id, options={})\n parse_comments(request(singular(id) + \"comments\" + other_user_id.to_s + \"recent\", options))\n end", "def show\n @comments = Comment.where(\"submission_id=\" + (params[:id])).order(\"created_at DESC\")\n end", "def get_recent_comments\n url...
[ "0.55526173", "0.5551668", "0.55365074", "0.55273247", "0.5366166", "0.5326709", "0.5310457", "0.53033525", "0.52830553", "0.5246114", "0.5239433", "0.5231362", "0.52210253", "0.5217713", "0.5215119", "0.52143085", "0.5189444", "0.5187008", "0.5163445", "0.5142744", "0.512125...
0.0
-1
Is the query for an existing day archive?
def is_day @is_day end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def archived?\n !archived_at.nil?\n end", "def archive_ok?\n #todo, we lack any real heuristic for this.\n true\n end", "def archived?\n archived == true\n end", "def includes?(date)\n false\n end", "def archival?\n false\n end", "def archival?\n false\n ...
[ "0.675163", "0.67139465", "0.66019917", "0.65872806", "0.657372", "0.657372", "0.6509365", "0.6468436", "0.64597327", "0.6353335", "0.6352318", "0.6352318", "0.63009864", "0.6284355", "0.6282623", "0.6280952", "0.6244855", "0.62163544", "0.62139785", "0.62067926", "0.61904585...
0.0
-1
Is the query for the front page of the site? This is for what is displayed at your site's main URL. Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_on_front'. If you set a static page for the front page of your site, this function will return true when viewing that page.
def is_front_page? # Most likely case. if 'posts' == get_option( 'show_on_front' ) && @is_home true elsif 'page' == get_option( 'show_on_front' ) && !get_option( 'page_on_front' ).blank? && is_page?( get_option( 'page_on_front' ) ) true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def if_front_page\n view_context.request.path == '/'\n end", "def first_page?\n\t\t\t!prev_page_url if paginated?\n\t\tend", "def is_current_page_home?\n puts \"url_home\"\n puts request.url\n if request.url == \"http://127.0.0.1:3000/\" #home url\n @home = true\n end\n end", "def redir...
[ "0.75660527", "0.6636231", "0.65985924", "0.6446283", "0.64358944", "0.64239824", "0.64239824", "0.64239824", "0.64239824", "0.64165676", "0.64165676", "0.6412487", "0.62952924", "0.6252158", "0.62342244", "0.62279904", "0.62107134", "0.6186397", "0.6178412", "0.6144028", "0....
0.89608693
0
Is the query for the blog homepage? This is the page which shows the time based blog content of your site. Depends on the site's "Front page displays" Reading Settings 'show_on_front' and 'page_for_posts'. If you set a static page for the front page of your site, this function will return true only on the page you set as the "Posts page".
def is_home? @is_home end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_front_page?\n # Most likely case.\n if 'posts' == get_option( 'show_on_front' ) && @is_home\n true\n elsif 'page' == get_option( 'show_on_front' ) && !get_option( 'page_on_front' ).blank? && is_page?( get_option( 'page_on_front' ) )\n true\n else\n false\n end\n end", "def i...
[ "0.8167445", "0.71346784", "0.69034207", "0.68163216", "0.6795014", "0.6757955", "0.66553104", "0.6615894", "0.65989363", "0.6579339", "0.6498348", "0.6477358", "0.63366467", "0.6294754", "0.6294754", "0.6280271", "0.6280271", "0.6280271", "0.6280271", "0.6267154", "0.6267154...
0.6313576
13
Is the query for the Privacy Policy page? This is the page which shows the Privacy Policy content of your site. Depends on the site's "Change your Privacy Policy page" Privacy Settings 'wp_page_for_privacy_policy'. This function will return true only on the page you set as the "Privacy Policy page".
def is_privacy_policy? if !get_option( 'wp_page_for_privacy_policy' ).blank? && is_page?( get_option( 'wp_page_for_privacy_policy' ) ) true else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restricted?\n page.restricted?\n end", "def pro_page?\n (session[:user_type] && session[:user_type] == USER_TYPES[:pro])\n end", "def restricted?\n pages.any? && pages.not_restricted.blank?\n end", "def restricted?\n pages.any? && pages.not_restricted.blank?\n end", "def res...
[ "0.69110996", "0.6849933", "0.68286145", "0.68286145", "0.68286145", "0.6516757", "0.64942575", "0.63872075", "0.63486665", "0.63473916", "0.6320097", "0.6244672", "0.60999846", "0.60884273", "0.6045161", "0.60064393", "0.5972122", "0.5957852", "0.59264755", "0.5880362", "0.5...
0.83016866
0
Is the query for an existing single page? If the page parameter is specified, this function will additionally check if the query is for one of the pages specified.
def is_page?(page = '') return false unless @is_page return true if page.blank? page_obj = get_queried_object() page = [page] unless page.is_a?(Array) page.map!(&:to_s) if page_obj.is_a?(Railspress::Page) && page.include?(page_obj.id.to_s) return true elsif page_obj.is_a?(Railspress::Page) && page.include?(page_obj.post_title) return true elsif page_obj.is_a?(Railspress::Page) && page.include?(page_obj.post_name) return true else page.each do |pagepath| next unless pagepath.include?('/') pagepath_obj = get_page_by_path(pagepath) if !pagepath_obj.blank? && pagepath_obj.id == page_obj.id return true end end end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page?\n !!self.page_id\n end", "def first_page?\n page == 1\n end", "def is_page?\n is_entry? && params[:_entry_type_] == 'page'\n end", "def page_parameters_defined?\n if params[:document_counter].nil? || current_per_page==0\n @query_params[:page]=1\n logger.warn \"do...
[ "0.7100719", "0.70518064", "0.7001173", "0.6958426", "0.69255006", "0.68529433", "0.6807031", "0.6773141", "0.6719975", "0.6691068", "0.6664434", "0.6664434", "0.6664434", "0.6664434", "0.66590905", "0.66590905", "0.6587062", "0.65834516", "0.6495287", "0.647884", "0.64717674...
0.68298686
6
Input dummy contact data
def prime first_name = ["James", "Mark", "Angela", "Theodore", "Sarah"] last_name = ["Bond", "Sheffield", "La Roche", "Michaels", "Robertson"] email = ["jamesbond@mi6.gov.uk", "mshef@gmail.com", "angie@hotmail.com", "theo23@yahoo.com", "srobertson@aol.com"] note = ["This guys is badass!", "He's ok.", "Super annoying", "Great customer!", "Not much to say"] first_name.each_index do |i| contact = Contact.new(first_name[i], last_name[i], email[i], note[i]) Rolodex.add_contact(contact) Rolodex.contacts end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_contact\n\t\tprint \"First Name: \".pink\n\t\tfirst_name = gets.chomp\n\t\tprint \"Last Name: \".pink\n\t\tlast_name = gets.chomp\n\t\tprint \"Email :\".pink\n\t\temail = gets.chomp\n\t\tprint \"Note :\".pink\n\t\tnote = gets.chomp #could use a hash but it is not ideal - if you need a cutstom piece of data...
[ "0.62058455", "0.61029494", "0.60384464", "0.59797764", "0.5914462", "0.59004223", "0.5891532", "0.58781534", "0.58776504", "0.5876533", "0.5870084", "0.5849395", "0.5849395", "0.5849395", "0.5849395", "0.5849395", "0.5849395", "0.5849395", "0.5849395", "0.5849395", "0.584939...
0.53651094
64
Add a list of keys (Symbols) to each subclass Accepts a hash of initial values, adds them to itself and keeps track of them in the "records" class instance variable
def initialize(*args) # Don't allow an object to be created unless key values are provided and a list of keys has been defined at the class level raise ArgumentError unless args[0].has_keys?(self.class.keys) and !(self.class.keys.empty?) args.each do |arg| raise ArgumentError, 'Creating a Record expects a hash as an argument' unless arg.is_a?(Hash) arg.each do |k, v| self.send("#{k.to_s}=".to_sym, v) end end # create the primary key for this record then # store the pk and the record in the records class instance variable # Use a non-printable character as the delimiter \x01 to avoid code/data conflicts self.class.records[self.class.build_key(self)] = self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(dow_hash)\n dow_hash.each do |key, value|\n self.send(\"#{key}=\", value)\n end\n @@all << self\n end", "def initialize(key_vals)\n fields = self.class.fields_list\n if not fields.nil? then # record paramétré\n if fields == key_vals.keys then # tout va bien\n ...
[ "0.5922752", "0.58543104", "0.57579565", "0.57477283", "0.57430786", "0.5732458", "0.5662578", "0.5591907", "0.558638", "0.549539", "0.5452568", "0.5448585", "0.5395005", "0.53931767", "0.53595984", "0.5313487", "0.5296471", "0.5263523", "0.5257238", "0.52542615", "0.5250503"...
0.56077063
7