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
DELETE /code_samples/1 DELETE /code_samples/1.json
def destroy @code_sample.destroy respond_to do |format| format.html { redirect_to code_samples_url, notice: 'Code sample was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @sample = Sample.find(params[:id])\n @sample.destroy\n\n respond_to do |format|\n format.html { redirect_to samples_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sample = Sample.find(params[:id])\n @sample.destroy\n\n respond_to do |format|\n...
[ "0.71839494", "0.71839494", "0.7168637", "0.71536934", "0.70669526", "0.6961494", "0.6961494", "0.6961494", "0.6961494", "0.6961494", "0.69059694", "0.6855563", "0.6843512", "0.68383676", "0.68169045", "0.68169045", "0.68169045", "0.68169045", "0.67387795", "0.6698845", "0.66...
0.73903066
0
Use callbacks to share common setup or constraints between actions.
def set_code_sample @code_sample = CodeSample.friendly.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 code_sample_params params.require(:code_sample).permit(:title, :versions, :description, :code, :featured, :code_info) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
TODO: we could assign a function to window.onerror to track last js error public
def cause raise NotImplementedError end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def onerror(&blk); super; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def get_js_error_feedback\n jserror_descriptions = \"\"\n begin\n jserrors = @driver.execute_script(\"return window.JSErrorCollec...
[ "0.67494404", "0.64479005", "0.64479005", "0.64479005", "0.64479005", "0.64479005", "0.64479005", "0.64479005", "0.6435499", "0.63773024", "0.6302577", "0.6272955", "0.62500525", "0.62468773", "0.6241184", "0.623738", "0.62148887", "0.62148887", "0.61710334", "0.6126671", "0....
0.0
-1
public full_message public inspect public
def java_script_object @js_wrapper end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inspect; message; end", "def inspect\n \"#<#{self.class.name}: #{message}>\"\n end", "def message; end", "def message; end", "def message; end", "def message; end", "def message; end", "def message; end", "def description\n self[:message]\n end", "def to_s; message; end", "def m...
[ "0.82042533", "0.75174487", "0.74912155", "0.74912155", "0.74912155", "0.74912155", "0.74912155", "0.74912155", "0.7262634", "0.71599984", "0.709416", "0.7063028", "0.7063028", "0.70591396", "0.70509076", "0.69943976", "0.69943976", "0.69943976", "0.69943976", "0.69943976", "...
0.0
-1
Create a new configuration populated with values from the environment.
def initialize @content_root = ENV.fetch('CONTENT_ROOT', '') @envelope_dir = ENV.fetch('ENVELOPE_DIR', File.join(Dir.pwd, '_site', 'deconst-envelopes')) @asset_dir = ENV.fetch('ASSET_DIR', File.join(Dir.pwd, '_site', 'deconst-assets')) @verbose = ENV.fetch('VERBOSE', '') != '' @content_id_base = ENV.fetch('CONTENT_ID_BASE', '').gsub(%r{/\Z}, '') @jekyll_document = ENV.fetch('JEKYLL_DOCUMENT', '') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config_from_env\n CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env_vars|\n if value = option_from_env(option)\n env_vars[option] = value\n end\n end\n end", "def config=(env, override_configurations = T.unsafe(nil)); end", "def env_config; end", "def env_conf...
[ "0.70851594", "0.665301", "0.65740186", "0.65740186", "0.65740186", "0.65740186", "0.6555943", "0.6526633", "0.64551026", "0.64226204", "0.6369767", "0.6290395", "0.6279958", "0.6275706", "0.62677073", "0.6252293", "0.6249908", "0.6249908", "0.6202572", "0.61791444", "0.61141...
0.0
-1
Determine and report (to stderr) whether or not we have enough information to prepare.
def validate reasons = [] if @content_id_base.empty? reasons << "CONTENT_ID_BASE is missing. It should be the common prefix used to generate " \ "IDs for content within this repository." end unless reasons.empty? $stderr.puts "Unable to prepare content because:" $stderr.puts $stderr.puts reasons.map { |r| " * #{r}\n"}.join $stderr.puts @should_submit = false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanityCheck\n @executor.nil? and raise \"Executor has not been initialized.\"\n @manipulator.nil? and raise \"Manipulator has not been initialized.\"\n @monitor.nil? and raise \"Monitor has not been initialized.\"\n @subject.nil? and raise \"Subject has not been initialized.\"\n end", ...
[ "0.60802853", "0.604605", "0.5985647", "0.5985647", "0.59699684", "0.58934075", "0.58794045", "0.56214064", "0.56115824", "0.5609108", "0.56026334", "0.5597771", "0.5582721", "0.5571713", "0.5541828", "0.5532825", "0.55272156", "0.55221486", "0.54941916", "0.54941916", "0.549...
0.0
-1
Supports Postgres only. Needs to be moved to ActiveRecord extensions.
def direct_import_from_csv(dataset, opts = {:to => nil, :delimiter => nil, :header => nil}) delimiter = opts[:delimiter] || "," header = "HEADER" if opts[:header] == true table = opts[:to].table_name raise TypeError if dataset.class != String ActiveRecord::Base.connection.execute("COPY #{table} FROM '#{dataset}' DELIMITER \'#{delimiter}\' CSV #{header}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def target_postgresql_version; end", "def postgres\n @postgres ||= Connections::Postgres.new(options: @postgres_options)\n end", "def postgresql?\n config = ActiveRecord::Base.configurations[Rails.env]\n config && config['adapter'] == 'postgresql'\n end", "def postgresql_version\n 100...
[ "0.69039094", "0.6826688", "0.6645085", "0.65970147", "0.64158607", "0.6412464", "0.6356771", "0.6355766", "0.6298663", "0.62926847", "0.6149216", "0.6105301", "0.6087088", "0.6059465", "0.6011691", "0.5914842", "0.590385", "0.5837955", "0.5815534", "0.5746708", "0.5734309", ...
0.0
-1
, only: [:create, :login]
def index users = User.all render json: users end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login\n\n end", "def login\n\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n\tend", "def login\n end", "def login; end", "def...
[ "0.76520145", "0.76520145", "0.7559467", "0.7559467", "0.7559467", "0.7559467", "0.7559467", "0.7559467", "0.7559467", "0.7559467", "0.7559467", "0.74458677", "0.7398518", "0.73394483", "0.71505755", "0.7068012", "0.69846034", "0.6904445", "0.6822403", "0.68112504", "0.678373...
0.0
-1
I haven't written a test for it but the implemenation seems incorrect to me. It doesn't take into account the colour of the area you're filling. Your test passes only because you're limiting the area you're filling with the colour used to fill but if you change the colour, it fails. Also, it fails with a stack level too deep error, which shouldn't be happening on a small grid (10x10 in your test). A better approach would be to read the colour of the very first pixel that's being filled and pass it on every recursive call, so that only the adjacent pixels of that colour were filled.
def floodfill(x, y, color) if @pixels[y-1][x-1] != color @pixels[y-1][x-1] = color floodfill(x+1, y, color) floodfill(x-1, y, color) floodfill(x, y + 1, color) floodfill(x, y - 1, color) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def floodFill(col, row)\r\n (col > @columns-1 || col < 0 || row > @rows-1 || row < 0) && return #Returns if the tile index is outside of the grid bounds.\r\n @tile[col][row].revealed && return #Returns if the tile is already revealed.\r\n\r\n @tile[col][row].revealed = true #Marks the tile as revealed.\r\n @hi...
[ "0.7119922", "0.6965181", "0.6864852", "0.6861658", "0.6798411", "0.6793343", "0.6761053", "0.6688027", "0.6616791", "0.65391827", "0.6428579", "0.6405382", "0.6401684", "0.6350412", "0.62816596", "0.6251833", "0.62218", "0.6150228", "0.6107627", "0.6072554", "0.6034519", "...
0.7314697
0
Due Care is taken not to make all these methods global
def initialize( controller ) super( controller ); colorFillClass = widgetClass('HooColorFill') li = widgetClass("HooLoremIpsumView") simpleButton = widgetClass('HooFormButtonSimple') toggleButton = widgetClass('HooFormButtonSimple') @window.showGrid; colorFillView = colorFillClass.new() @window.contentView.addSubView( colorFillView ) liInstance = li.new() colorFillView.addSubView( liInstance ) lambda { @simpleButton1 = simpleButton.new( :initialState=>1 ); @simpleButton1.img = '../images/buttons/simple-button/3-state-combine.png'; @simpleButton1.size = [105,45]; @simpleButton1.labelStates = ['-- --', 'Submit', 'Pressed']; @simpleButton1.initialState = 1; @simpleButton1.labelColor = '#fff' @simpleButton1.action = '/widgets/_ajaxPostTest' #@simpleButton1.javascript = "this.hookupAction( function(){ # alert('Holy Cock'); #});"; @window.contentView.addSubView( @simpleButton1 ); }.call end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def internal; end", "def methods() end", "def implementation; end", "def implementation; end", "def methods; end", "def methods; end", "def methods; end", "def methods; end", "def global\n raise NotImplementedError\n end", "def global; end", "def refutal()\n end...
[ "0.7921942", "0.7226431", "0.71834815", "0.7179939", "0.7179939", "0.7140155", "0.7140155", "0.7140155", "0.7140155", "0.70414156", "0.7016301", "0.69167167", "0.6815069", "0.67985386", "0.6795256", "0.6795256", "0.6730885", "0.6673475", "0.6604983", "0.6604983", "0.6604983",...
0.0
-1
GET /contests/1 GET /contests/1.json
def show redirect_to :controller => 'sessions', :action => 'connect' if !session[:access_token] @contest = Contest.find(params[:id]) client = Instagram.client(:access_token => session[:access_token]) @user = client.user pictures = client.tag_recent_media('mazeh9art') pictures.data.each do |p| picture = Picture.find_or_initialize_by_instagram_id(p.id) picture.update_attributes(title: p.caption.text, url: p.images.standard_resolution.url ) end gon.pics = pictures #Contest.first.getNextPictures() respond_to do |format| format.html # show.html.erb format.json { render json: @contest } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @contest = Contest.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contest }\n end\n end", "def show\n @contest = Contest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format...
[ "0.8039824", "0.80027866", "0.79434526", "0.79434526", "0.7894636", "0.78603256", "0.74444187", "0.73176265", "0.73176265", "0.73176265", "0.73176265", "0.7205758", "0.7156151", "0.7156151", "0.71495616", "0.7118187", "0.7028238", "0.6884724", "0.6837134", "0.6814197", "0.681...
0.0
-1
GET /contests/new GET /contests/new.json
def new @contest = Contest.new respond_to do |format| format.html # new.html.erb format.json { render json: @contest } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @contest = Contest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @contest }\n end\n end", "def new\n @contest = Contest.new\n @problem_count = 4\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { r...
[ "0.8337197", "0.818067", "0.8151273", "0.7914055", "0.76858914", "0.753359", "0.753359", "0.753359", "0.7529654", "0.75065213", "0.75065213", "0.73803174", "0.73803174", "0.73803174", "0.73363173", "0.72187024", "0.72187024", "0.72187024", "0.72105795", "0.7195674", "0.705507...
0.84163564
0
POST /contests POST /contests.json
def create @contest = Contest.new(params[:contest]) respond_to do |format| if @contest.save format.html { redirect_to @contest, notice: 'Contest was successfully created.' } format.json { render json: @contest, status: :created, location: @contest } else format.html { render action: "new" } format.json { render json: @contest.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @contest = @event.contests.build(contest_params)\n\n respond_to do |format|\n if @contest.save\n format.html { redirect_to [@event, @contest], notice: 'Contest was successfully created.' }\n format.json { render :show, status: :created, location: @contest }\n else\n ...
[ "0.7152174", "0.7103855", "0.70241404", "0.70208913", "0.69897294", "0.695391", "0.68805426", "0.68404317", "0.68307537", "0.68174773", "0.6759615", "0.6731611", "0.67187345", "0.67118084", "0.6692199", "0.6692199", "0.66318876", "0.66176033", "0.6520299", "0.6520299", "0.652...
0.74872786
0
PUT /contests/1 PUT /contests/1.json
def update @contest = Contest.find(params[:id]) respond_to do |format| if @contest.update_attributes(params[:contest]) format.html { redirect_to @contest, notice: 'Contest was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @contest.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @contest = Contest.find_by(path: params[:id])\n\n respond_to do |format|\n if @contest.update_attributes(params[:contest])\n format.html { redirect_to contest_path(@contest.path)+'/upload' }\n #format.json { head :no_content }\n else\n format.html { render action: ...
[ "0.7452851", "0.7452833", "0.7441542", "0.7191935", "0.71750563", "0.7164745", "0.7117877", "0.705355", "0.70395637", "0.7026145", "0.69851846", "0.6976812", "0.69482785", "0.6924179", "0.69112897", "0.67661893", "0.67661893", "0.6714746", "0.6714746", "0.6714746", "0.6714746...
0.74279934
4
DELETE /contests/1 DELETE /contests/1.json
def destroy @contest = Contest.find(params[:id]) @contest.destroy respond_to do |format| format.html { redirect_to contests_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @contest = Contest.find(params[:id])\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @contest.destroy\n respond_to do |format|\n format.html { redirect_to contests_url ...
[ "0.80987906", "0.80896854", "0.7983932", "0.79219407", "0.7868613", "0.7868047", "0.78431594", "0.7790738", "0.77683955", "0.77683955", "0.77683955", "0.77602553", "0.76734424", "0.76611394", "0.75796723", "0.7568219", "0.74781656", "0.7476672", "0.73513526", "0.7268441", "0....
0.8085642
4
swagger_controller :channels, "User Channels" swagger_api :index do summary "Retreive all channels" param :query, 'user[email]', :string, :required param :query, 'user[authentication_token]', :string, :required end swagger_api :show do summary "Retrieve the information of a channel" param :path, :id, :integer, :required param :query, 'user[email]', :string, :required param :query, 'user[authentication_token]', :string, :required end swagger_api :update do summary "Update the position of a channel" param :path, :id, :integer, :required param :body, :body, :channel, :required end swagger_api :destroy do summary "Deletes a channel or remove user from a channel" param :path, :id, :integer, :required param :path, :user_id, :integer, :optional param :form, 'user[email]', :string, :required param :form, 'user[authentication_token]', :string, :required end swagger_api :create do summary "Creates a channel or add a user to the channel" param :path, :user_id, :integer, :optional param :form, 'user[email]', :string, :required param :form, 'user[authentication_token]', :string, :required param :form, 'channel[title]', :string, :required param :form, 'channel[longitude]', :float, :required param :form, 'channel[latitude]', :float, :required end swagger_model :channel do description "The editable information of a channel" property :latitude, :float, :optional, "The latitude of a channel" property :longitude, :float, :optional, "The longitude of a channel" property :creator_id, :integer, :optional, "The id of the owner of the channel" property :user, :user_credentials, :required, "The user credentials" end swagger_model :user_credentials do description "The user login information" property :email, :string, :required, "User email" property :authentication_token, :string, :required, "User authentication_token" end
def index @channels = Channel.all render json: @channels end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n apis = site_account.api_docs_services\n .published\n .with_system_names((params[:services] || \"\").split(\",\"))\n .select{ |api| api.specification.swagger_1_2? }\n\n respond_with({\n swaggerVersion: \"1.2\",\n apis: apis.map!{ |service| swagger_spec_for(service) },\n ...
[ "0.63487923", "0.5909661", "0.5733724", "0.57287383", "0.5578284", "0.5572897", "0.5501468", "0.5500546", "0.55002093", "0.5499937", "0.5483446", "0.54654956", "0.54368263", "0.5435152", "0.54279554", "0.54052234", "0.5387846", "0.53864014", "0.5370787", "0.53571904", "0.5357...
0.49544272
79
GET /vanos/1 GET /vanos/1.json
def show @vano = Vano.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @vano } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @vanos = Vano.all\n end", "def show\n @volantino = Volantino.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volantino }\n end\n end", "def show\n @vodka = Vodka.find(params[:id])\n\n respond_to do |format|\n ...
[ "0.6829573", "0.6780538", "0.671385", "0.67125195", "0.6626964", "0.66235274", "0.6606887", "0.66032594", "0.65865487", "0.6581894", "0.6528772", "0.6516062", "0.6447883", "0.64475924", "0.6440455", "0.64249116", "0.64249116", "0.64249116", "0.642256", "0.6390795", "0.638326"...
0.7074363
0
GET /vanos/new GET /vanos/new.json
def new @vano = Vano.new respond_to do |format| format.html # new.html.erb format.json { render json: @vano } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @po = Po.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @po }\n end\n end", "def new\n @volantino = Volantino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volantino }\n end\n e...
[ "0.74409693", "0.73978406", "0.7373073", "0.73017687", "0.7276522", "0.72739065", "0.7255778", "0.72509056", "0.7245187", "0.7237352", "0.7231472", "0.7224756", "0.7209617", "0.71968424", "0.7194532", "0.7192254", "0.71458995", "0.71458995", "0.71458995", "0.7123853", "0.7121...
0.75199854
0
POST /vanos POST /vanos.json
def create @vano = Vano.new(params[:vano]) respond_to do |format| if @vano.save format.html { redirect_to @vano, notice: 'Vano was successfully created.' } format.json { render json: @vano, status: :created, location: @vano } else format.html { render action: "new" } format.json { render json: @vano.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @vano = Vano.new(vano_params)\n\n respond_to do |format|\n if @vano.save\n format.html { redirect_to @vano, notice: 'Vano was successfully created.' }\n format.json { render :show, status: :created, location: @vano }\n else\n format.html { render :new }\n fo...
[ "0.65094936", "0.6346268", "0.6317516", "0.6213228", "0.61727434", "0.61343896", "0.60662377", "0.6063277", "0.6059031", "0.6041116", "0.60224843", "0.60210156", "0.6019828", "0.6013145", "0.5997783", "0.59836125", "0.59815365", "0.5971525", "0.59701365", "0.5959958", "0.5947...
0.653171
0
PUT /vanos/1 PUT /vanos/1.json
def update @vano = Vano.find(params[:id]) respond_to do |format| if @vano.update_attributes(params[:vano]) format.html { redirect_to @vano, notice: 'Vano was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @vano.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", ...
[ "0.6466889", "0.633817", "0.6320665", "0.62113655", "0.62092394", "0.6105025", "0.60748714", "0.6063246", "0.59944105", "0.59539396", "0.59413433", "0.5915456", "0.5911947", "0.5862531", "0.58585703", "0.58584934", "0.5844563", "0.58098227", "0.58069044", "0.57905406", "0.577...
0.6172887
5
DELETE /vanos/1 DELETE /vanos/1.json
def destroy @vano = Vano.find(params[:id]) @vano.destroy respond_to do |format| format.html { redirect_to vanos_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @nodo.destroy\n respond_to do |format|\n format.html { redirect_to nodos_url }\n format.json { head :no_content }\n en...
[ "0.7635278", "0.7225469", "0.7017266", "0.6978059", "0.69667196", "0.69404894", "0.6909755", "0.6909755", "0.6909755", "0.6909755", "0.6901307", "0.68969226", "0.68740904", "0.6865582", "0.685141", "0.6843221", "0.6838565", "0.6834352", "0.68157345", "0.6811135", "0.68090856"...
0.7125306
2
depends on contacts & checks
def migrate_contact_entity_linkages contacts_for_keys = @source_redis.keys('contacts_for:*') all_entity_names_by_id = @source_redis.hgetall('all_entity_names_by_id') contacts_for_keys.each do |contacts_for_key| unless contacts_for_key =~ /\Acontacts_for:(#{ID_PATTERN_FRAGMENT})(?::(#{CHECK_PATTERN_FRAGMENT}))?\z/ raise "Bad regex for '#{contacts_for_key}'" end entity_id = $1 check_name = $2 entity_name = all_entity_names_by_id[entity_id] contact_ids = @source_redis.smembers(contacts_for_key) next if contact_ids.empty? contacts = contact_ids.collect {|c_id| find_contact(c_id) } contacts.each do |contact| @check_ids_by_contact_id_cache[contact.id] ||= [] end tag_for_check = proc do |en, cn, tn| check = find_check(en, cn) check.tags << find_tag(tn, :create => true) contacts.each do |contact| @check_ids_by_contact_id_cache[contact.id] << check.id end end if check_name.nil? # interested in entity, so apply to all checks for that entity tag_name = "entity_#{entity_name}" all_checks_for_entity = @source_redis.zrange("all_checks:#{entity_name}", 0, -1) all_checks_for_entity.each do |check_name| tag_for_check.call(entity_name, check_name, tag_name) end else # interested in check tag_for_check.call(entity_name, check_name, "check_#{entity_name}:#{check_name}") end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact; end", "def contacts\r\n\r\n end", "def scrape_contacts; end", "def contact \n\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n end", "def contact\n ...
[ "0.7484399", "0.7415514", "0.7192713", "0.712471", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70585734", "0.70137876", "0.70137876", "...
0.0
-1
depends on contacts, media, checks
def migrate_rules notification_rules_keys = @source_redis.keys('contact_notification_rules:*') contact_counts_by_id = {} check_counts_by_id = {} notification_rules_keys.each do |notification_rules_key| raise "Bad regex for '#{notification_rules_key}'" unless notification_rules_key =~ /\Acontact_notification_rules:(#{ID_PATTERN_FRAGMENT})\z/ contact_id = $1 contact = find_contact(contact_id) contact_num = contact_counts_by_id[contact.id] if contact_num.nil? contact_num = contact_counts_by_id.size + 1 contact_counts_by_id[contact.id] = contact_num end check_ids = @check_ids_by_contact_id_cache[contact.id] rules = [] notification_rule_ids = @source_redis.smembers(notification_rules_key) notification_rule_ids.each do |notification_rule_id| notification_rule_data = @source_redis.hgetall("notification_rule:#{notification_rule_id}") time_restrictions = Flapjack.load_json(notification_rule_data['time_restrictions']) entities = Set.new( Flapjack.load_json(notification_rule_data['entities'])) regex_entities = Set.new( Flapjack.load_json(notification_rule_data['regex_entities'])) tags = Set.new( Flapjack.load_json(notification_rule_data['tags'])) regex_tags = Set.new( Flapjack.load_json(notification_rule_data['regex_tags'])) # collect specific matches together with regexes regex_entities = regex_entities.collect {|re| Regexp.new(re) } + entities.to_a.collect {|entity| /\A#{Regexp.escape(entity)}\z/} regex_tags = regex_tags.collect {|re| Regexp.new(re) } + tags.to_a.collect {|tag| /\A#{Regexp.escape(tag)}\z/} media_states = {} Flapjack::Data::Condition.unhealthy.keys.each do |fail_state| next if !!Flapjack.load_json(notification_rule_data["#{fail_state}_blackhole"]) media_types = Flapjack.load_json(notification_rule_data["#{fail_state}_media"]) unless media_types.nil? || media_types.empty? media_types_str = media_types.sort.join("|") media_states[media_types_str] ||= [] media_states[media_types_str] << fail_state end end media_states.each_pair do |media_types_str, fail_states| rule = Flapjack::Data::Rule.new rule.time_restrictions = time_restrictions rule.conditions_list = fail_states.sort.join("|") rule.save media = media_types_str.split('|').each_with_object([]) do |media_type, memo| medium = contact.media.intersect(:transport => media_type).all.first memo << medium unless medium.nil? end rule.media.add(*media) unless media.empty? checks_for_rule = Flapjack::Data::Check.intersect(:id => check_ids) checks = if regex_entities.empty? && regex_tags.empty? checks_for_rule.all else # apply the entities/tag regexes as a filter checks_for_rule.select do |check| entity_name = check.name.split(':', 2).first if regex_entities.all? {|re| re === entity_name } # copying logic from https://github.com/flapjack/flapjack/blob/68a3fd1144a0aa516cf53e8ae5cb83916f78dd94/lib/flapjack/data/notification_rule.rb # not sure if this does what we want, but it's how it currently works matching_re = [] check_tags.each do |check_tags| matching_re += regex_tags.select {|re| re === check_tag } end matching_re.size >= regex_tags.size else false end end end tags = checks.collect do |check| check_num = check_counts_by_id[check.id] if check_num.nil? check_num = check_counts_by_id.size + 1 check_counts_by_id[check.id] = check_num end tag = Flapjack::Data::Tag.new(:name => "migrated-contact_#{contact_num}-check_#{check_num}|") tag.save check.tags << tag tag end rule.tags.add(*tags) unless tags.empty? rules << rule end end contact.rules.add(*rules) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def contact; end", "def contacts\r\n\r\n end", "def common\n #if Contact.where(:organization_id => current_user.organization.id).any?\n # #@users = current_user.organization.contacts.group_by{|u| u.first_name[0]}\n # @users = Contact.where(:organization_id => current_user.organization.id).order(\"na...
[ "0.6366829", "0.59400487", "0.5905234", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58620995", "0.58468467", "0.57976425", "0.57976425", ...
0.0
-1
Variables that do not depend on the environment name.
def simple_variables strong_memoize(:simple_variables) do scoped_variables(environment: nil) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def env_variable_names\n [\n CONSUMER_KEY_NAME,\n CONSUMER_SECRET_NAME,\n ACCESS_TOKEN_KEY_NAME,\n ACCESS_TOKEN_SECRET_NAME\n ]\n end", "def extract_environment_variables! #:nodoc:\n args.delete_if do |arg|\n next unless arg.match(/^(...
[ "0.7047515", "0.6882864", "0.68726313", "0.6766753", "0.6686882", "0.6574362", "0.6564002", "0.65490276", "0.65183884", "0.6507424", "0.6490663", "0.6482867", "0.64455396", "0.63930196", "0.6390161", "0.6377418", "0.63727313", "0.6349514", "0.6337908", "0.6326876", "0.6303311...
0.6407643
13
This method will return the k most common elements in the case of a tie it will select the first occuring element. Time Complexity: O(n) Space Complexity: O(n^2)
def top_k_frequent_elements(list, k) return [] if list == [] hash = Hash.new(0) counter = 0; list.each do |value| hash[value] = [] if hash[value].nil? hash[value]+=1 end if k > hash.size() raise ArgumentError, "Not Enough Values to Display" end solution = hash.max(k){ |a, b| b<=>a} p solution numbers = [] solution.each do |array| numbers << array[0] end return numbers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_k_frequent_elements(list, k)\n results = []\n\n return list if list.length == k\n return results if list.length == 0 \n\n list = list.sort.uniq\n\n i = 0\n k.times do \n results << list[i]\n i += 1\n end \n return results\nend", "def top_k_frequent_elements(list, k)\n result_arr = []\n re...
[ "0.8254349", "0.82195437", "0.82076234", "0.81828433", "0.81789684", "0.81527865", "0.8146139", "0.8143594", "0.8132496", "0.81318384", "0.81297475", "0.81083286", "0.8103692", "0.8087182", "0.8085673", "0.8078475", "0.8044227", "0.8034774", "0.8007754", "0.7993153", "0.79674...
0.80297536
18
This method will return the true if the table is still a valid sudoku table. Each element can either be a ".", or a digit 19 The same digit cannot appear twice or more in the same row, column or 3x3 subgrid Time Complexity: ? Space Complexity: ?
def valid_sudoku(table) raise NotImplementedError, "Method hasn't been implemented yet!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_sudoku(table)\n table.each do |row|\n row_map = {}\n row.each do |elem|\n if elem != '.'\n if row_map[elem] \n return false\n else\n row_map[elem] = 1\n end\n end\n end\n end\n \n i = 0\n 9.times do\n column_map = {}\n table.each do |row|\n...
[ "0.8212088", "0.81887585", "0.81469035", "0.8069628", "0.80010355", "0.79224867", "0.78968567", "0.76087445", "0.7594696", "0.73546576", "0.7341427", "0.7301686", "0.7012823", "0.69957775", "0.6977555", "0.69177145", "0.685407", "0.6809085", "0.6776621", "0.67565316", "0.6711...
0.6489313
52
GET /positioncoefficients GET /positioncoefficients.xml
def index @positioncoefficients = Positioncoefficient.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @positioncoefficients } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @positioncoefficient = Positioncoefficient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end", "def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n ...
[ "0.65258884", "0.6046247", "0.5679516", "0.5533102", "0.5532579", "0.53812826", "0.5181406", "0.5174721", "0.51607746", "0.50951135", "0.5091188", "0.50303143", "0.5020803", "0.49832216", "0.4978589", "0.4956052", "0.4905392", "0.4902835", "0.48825383", "0.48513266", "0.48492...
0.7403955
0
GET /positioncoefficients/1 GET /positioncoefficients/1.xml
def show @positioncoefficient = Positioncoefficient.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @positioncoefficient } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end", "def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.h...
[ "0.74998224", "0.6315164", "0.5776348", "0.5688913", "0.564511", "0.5529654", "0.54390216", "0.533006", "0.53189373", "0.52742636", "0.51853716", "0.5152585", "0.5140186", "0.51255345", "0.511978", "0.5106641", "0.50957143", "0.50730157", "0.50649565", "0.4977526", "0.4964364...
0.68329537
1
GET /positioncoefficients/new GET /positioncoefficients/new.xml
def new @positioncoefficient = Positioncoefficient.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @positioncoefficient } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end", "def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respo...
[ "0.67789316", "0.6614078", "0.63938475", "0.636018", "0.6129326", "0.6106632", "0.6076105", "0.6076105", "0.6076105", "0.6047523", "0.600763", "0.591057", "0.5851495", "0.58120257", "0.5784976", "0.5750409", "0.5680605", "0.5642594", "0.56354", "0.56230664", "0.5603886", "0...
0.7581399
0
POST /positioncoefficients POST /positioncoefficients.xml
def create @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient]) respond_to do |format| if @positioncoefficient.save format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') } format.xml { render :xml => @positioncoefficient, :status => :created, :location => @positioncoefficient } else format.html { render :action => "new" } format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end", "def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.h...
[ "0.63139105", "0.60718316", "0.58930624", "0.5589935", "0.54409516", "0.5332197", "0.5322689", "0.52606946", "0.52483875", "0.5248295", "0.52323455", "0.51994646", "0.5166757", "0.51469284", "0.51469284", "0.51145875", "0.5083312", "0.5083286", "0.5060266", "0.5059451", "0.50...
0.6944485
0
PUT /positioncoefficients/1 PUT /positioncoefficients/1.xml
def update @positioncoefficient = Positioncoefficient.find(params[:id]) respond_to do |format| if @positioncoefficient.update_attributes(params[:positioncoefficient]) format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @positioncoefficient.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respond_to do |format|\n if @positioncoefficient.save\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') }\n format.xml { render :xml =>...
[ "0.60126203", "0.58573455", "0.57445574", "0.554824", "0.54882663", "0.54754776", "0.54361254", "0.54283375", "0.5397946", "0.53792685", "0.5372173", "0.5352605", "0.53466403", "0.52502984", "0.5244632", "0.5235216", "0.52308124", "0.5219644", "0.5197457", "0.51897436", "0.51...
0.6778262
0
DELETE /positioncoefficients/1 DELETE /positioncoefficients/1.xml
def destroy @positioncoefficient = Positioncoefficient.find(params[:id]) @positioncoefficient.destroy respond_to do |format| format.html { redirect_to(positioncoefficients_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @position = Position.find(params[:id])\n @position.destroy\n \n respond_to do |format|\n format.html { redirect_to(positions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cash_position = CashPosition.find(params[:id])\n @cash_position.destroy\n\n ...
[ "0.5921333", "0.5915622", "0.5900425", "0.58856875", "0.5871932", "0.5863749", "0.5847981", "0.5796321", "0.5786627", "0.57745445", "0.5736627", "0.570602", "0.56330585", "0.56232315", "0.56163514", "0.5598683", "0.5596947", "0.5574214", "0.5563767", "0.5555509", "0.5554605",...
0.7180604
0
Action to update a topic of Sticky
def update Post.suspended_delta do @topic.update_attributes(params[:topic]) end if @topic.errors.empty? flash[:notice] = "Topic Updated Successfully" redirect_to @topic.forum else render :action => 'edit' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @topic = args[:topic] if args.key?(:topic)\n end", "def update!(**args)\n @topic = args[:topic] if args.key?(:topic)\n end", "def update!(**args)\n @topic = args[:topic] if args.key?(:topic)\n end", "def update!(**args)\n @topic_n...
[ "0.78336924", "0.7833626", "0.7833626", "0.72487736", "0.72487736", "0.72369504", "0.71856505", "0.7148054", "0.7118872", "0.70974183", "0.7091626", "0.7086457", "0.68585014", "0.684564", "0.684564", "0.68262696", "0.67747", "0.67739725", "0.67693985", "0.6697203", "0.6681895...
0.6422773
81
Override to set the database owner and call setup_gis
def create(master_established = false) establish_master_connection unless master_established extra_configs = { "encoding" => encoding } extra_configs["owner"] = username if has_su? connection.create_database(configuration["database"], configuration.merge(extra_configs)) setup_gis rescue ::ActiveRecord::StatementInvalid => error if /database .* already exists/ === error.message raise ::ActiveRecord::Tasks::DatabaseAlreadyExists else raise end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_publication_owner(name, owner)\n typed_exec(\"ALTER PUBLICATION #{connection.quote_ident(name)} OWNER TO #{connection.quote_ident(owner)}\")\n end", "def setup\n @factory = ::RGeo::Cartesian.preferred_factory(:srid => 3785)\n @geographic_factory = ::RGeo::Geographic.spherical_fa...
[ "0.5967111", "0.58636177", "0.5626587", "0.5576757", "0.55435574", "0.5490979", "0.54764825", "0.54536545", "0.54211426", "0.5399195", "0.5394341", "0.5312541", "0.5306964", "0.5292873", "0.52897614", "0.5286431", "0.5285781", "0.52285874", "0.5174421", "0.51685476", "0.51540...
0.55210555
5
Override to use su_username and su_password
def establish_master_connection establish_connection(configuration.merge( "database" => "postgres", "password" => su_password, "schema_search_path" => "public", "username" => su_username )) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n super(\"ssh-userauth\")\n end", "def session_passwd\n super\n end", "def session_passwd\n super\n end", "def passwd(*) end", "def passwd(*) end", "def setup_credentials\n\n cmd = @config[:path] + @command_line_tool + \" \" + @@login_command\n\n Open3.pop...
[ "0.68070596", "0.64964235", "0.64964235", "0.6370419", "0.6370419", "0.63482475", "0.62980735", "0.62621254", "0.62514716", "0.6160244", "0.6150333", "0.610928", "0.610928", "0.610928", "0.6104333", "0.60956097", "0.60879886", "0.60374445", "0.60262877", "0.60214937", "0.6005...
0.0
-1
must figure out dependent destroy on polymorphic table
def is_about downcased_noteable_type = self.noteable_type.downcase if downcased_noteable_type == "comment" if Comment.find(self.noteable_id).sentence == nil self.destroy "Notification Removed" elsif Comment.find(self.noteable_id).sentence.paragraph.story Comment.find(self.noteable_id).sentence.paragraph.story.title else "Notification Removed" end else Course.find(Enrollment.find(self.noteable_id).course_id).name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detach parent\n\n # the ordinary *able table\n parent.send( self.class.to_s.underscore.pluralize).delete self\n\n # case child.class.to_s\n # when \"Event\",\"WageEvent\"\n # ev = Eventable.where( event: child, eventable: self)\n # ev.delete_all\n # when \"Printer\"\n # pr = Print...
[ "0.6654317", "0.62547594", "0.6190418", "0.6168673", "0.6152492", "0.6117316", "0.6096514", "0.60938495", "0.6024632", "0.60083514", "0.6004811", "0.59926766", "0.5987495", "0.5975938", "0.59620714", "0.5870119", "0.58695346", "0.5867962", "0.5860982", "0.5856882", "0.5851851...
0.0
-1
before_action :set_task, only: %i[ show edit update destroy ]
def index @pagy, @tasks = pagy(apply_scopes(current_user.tasks), items: 5) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_task\n #byebug\n @task = Task.find(params[:id])\n\n case params[:action]\n when 'edit'\n admin_author_assignee_manager(@task, 'change this task') \n when 'update'\n admin_author_assignee_manager(@task, 'change this task') \n when 'destroy'\n admin_author_m...
[ "0.76910704", "0.7668901", "0.7647632", "0.72978556", "0.72130585", "0.7194126", "0.7163046", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", "0.7159563", ...
0.0
-1
Automatically respond with 404 for ActiveRecord::RecordNotFound
def record_not_found render :partial => "shared/error", :layout => "one_box", :status => 404, :locals => {:error_title => 'No hemos encontrado lo que buscabas', :error_message => 'Puedes haber tecleado mal la dirección o la página puede haber sido movida.'} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def not_found\n respond_with 404\n end", "def record_not_found\n render json: \"Record not found\", status: 404\n end", "def record_not_found\n render json: { error: { message: 'Record not found.' }}, status: :not_found\n end", "def record_not_found!\n render partial: 'errors/404', sta...
[ "0.7977074", "0.7908341", "0.7899114", "0.7889307", "0.78878707", "0.78789586", "0.7864075", "0.7860034", "0.7849858", "0.7825134", "0.776247", "0.7757481", "0.77490914", "0.7729603", "0.7714778", "0.7624227", "0.7610271", "0.7610271", "0.7610271", "0.7610271", "0.7610271", ...
0.0
-1
Register the validations here
def register_validation(field_sym,lamb_func_with_message) lamb_func_with_message.each_index { |i| if lamb_func_with_message[i].instance_of?(ValidatorFunctionUnit) lamb_func_with_message[i] = {:f=>lamb_func_with_message[i]} end } @__fields_to_validate ||= {} @__fields_to_validate[field_sym] ||= [] @__fields_to_validate[field_sym] += lamb_func_with_message # puts @__fields_to_validate.inspect end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate\n # add errors if not validate\n end", "def run_validations\n true\n end", "def run_validations!\n run_callbacks(:validation) do\n super\n end\n end", "def setting_validations\n if errors.empty?\n e...
[ "0.7569708", "0.7502359", "0.74852765", "0.73412144", "0.7326972", "0.7326972", "0.73187923", "0.7314348", "0.7227129", "0.7215006", "0.7215006", "0.7215006", "0.72024304", "0.7174918", "0.71515495", "0.713861", "0.71205837", "0.7099116", "0.70956177", "0.70956177", "0.709561...
0.0
-1
Register the uniqueness validations
def register_uniqueness(field_sym) @__fields_to_validate_uniqueness ||= {} @__fields_to_validate_uniqueness[field_sym] = true # puts @__fields_to_validate_uniqueness.inspect end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preconditions\n validator.kind == :uniqueness\n end", "def validates_uniqueness_of(*args)\n validates_with(UniquenessValidator, _merge_attributes(args))\n end", "def validates_uniqueness_of(*args)\n validates_with(UniquenessValidator, _merge_attributes(args))\n end",...
[ "0.7606207", "0.7171119", "0.6988157", "0.69003606", "0.686787", "0.6673246", "0.6542856", "0.6540174", "0.65135443", "0.6268777", "0.6264936", "0.6209169", "0.6149086", "0.61488277", "0.60979897", "0.6078019", "0.6047371", "0.6019001", "0.600618", "0.5964764", "0.5917258", ...
0.70031935
2
Returns true if business is paid through today.
def paid_thru_now # Turn off March 1 of year following paid year paid_thru_year >= (Date.today - 59).year end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paid?\n unless self.last_paid_at.blank?\n return Time.now - 365.days < self.last_paid_at\n else\n return false\n end\n end", "def paid?\n date_paid_out.present?\n end", "def paid?\n !!paid_at\n end", "def paid?\n payment_at?\n end", "def overdue?\n next_payment_at...
[ "0.7834351", "0.7636704", "0.7320001", "0.71789056", "0.71392745", "0.699476", "0.6926821", "0.68859845", "0.68713886", "0.687133", "0.6860084", "0.6796483", "0.6763264", "0.6752877", "0.6740175", "0.6691168", "0.66271865", "0.6626101", "0.6621665", "0.66160995", "0.6603483",...
0.6756987
13
Sets the coordinates for a business.
def set_coordinates addrs = [ "#{address_line_1}", "#{address_line_2}", "#{address_line_1}, #{address_line_2}" ] catch(:geocoded) do addrs.each do |addr| begin loc = MultiGeocoder.geocode( "#{addr}, #{city}, #{state} #{zip}" ) if loc.success self.lat = loc.lat self.lng = loc.lng throw :geocoded end rescue Exception => ex puts " -> #{addr} did not resolve" puts " -> #{ex.message}" end end puts "did not match any combination of address1 and address2" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def coordinates=(coordinates)\n self.latitude, self.longitude = coordinates\n end", "def set_business_geopoint\n @business_geopoint = BusinessGeopoint.find(params[:id])\n end", "def xy=(value)\n set(:xy => value)\n end", "def set_location_coordinates\n address = \"#{self.address.gsub('...
[ "0.63420475", "0.63239855", "0.62276506", "0.6190533", "0.6090764", "0.60856366", "0.60675246", "0.5993829", "0.5948529", "0.58766675", "0.5772516", "0.5759539", "0.57577324", "0.5732269", "0.5720599", "0.5689424", "0.5673951", "0.5671426", "0.5671426", "0.5671426", "0.567142...
0.49479866
96
takes a code returned by wepay oauth2 authorization and makes an api call to generate oauth2 token for this farmer.
def request_wepay_access_token(code, redirect_uri) response = GemsUsage::Application::WEPAY.oauth2_token(code, redirect_uri) if response['error'] raise "Error - "+ response['error_description'] elsif !response['access_token'] raise "Error requesting access from WePay" else self.wepay_access_token = response['access_token'] self.save self.create_wepay_account end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_wepay_access_token(code, redirect_uri)\n response = WEPAY.oauth2_token(code, redirect_uri)\n if response['error']\n raise \"Error - \"+ response['error_description']\n elsif !response['access_token']\n raise \"Error requesting access from WePay\"\n else\n self.wepay_access_token = response...
[ "0.7482357", "0.7470306", "0.73334104", "0.7279733", "0.7279112", "0.7184088", "0.7152392", "0.71414405", "0.7128365", "0.7109416", "0.7034843", "0.7016859", "0.70067984", "0.6990521", "0.6941618", "0.69037986", "0.69030356", "0.68375874", "0.6817902", "0.68138623", "0.681263...
0.74810106
1
makes an api call to WePay to check if current access token for farmer is still valid
def has_valid_wepay_access_token? if self.wepay_access_token.nil? return false end response = GemsUsage::Application::WEPAY.call("/user", self.wepay_access_token) response && response["user_id"] ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_wepay_access_token(code, redirect_uri)\n response = WEPAY.oauth2_token(code, redirect_uri)\n if response['error']\n raise \"Error - \"+ response['error_description']\n elsif !response['access_token']\n raise \"Error requesting access from WePay\"\n else\n self.wepay_access_token = response...
[ "0.7140138", "0.7067149", "0.6779129", "0.6745647", "0.67225766", "0.6720021", "0.6677144", "0.6677144", "0.66480213", "0.6634246", "0.6632952", "0.6610832", "0.65765285", "0.6564849", "0.65591305", "0.65376264", "0.65329546", "0.6513627", "0.6455548", "0.6454063", "0.6441651...
0.6814433
2
creates a WePay account for this farmer with the farm's name
def create_wepay_account if self.has_wepay_access_token? && !self.has_wepay_account? params = { :name => self.name, :description => "Event - " + self.name } response = GemsUsage::Application::WEPAY.call("/account/create", self.wepay_access_token, params) if response["account_id"] self.wepay_account_id = response["account_id"] return self.save else raise "Error - " + response["error_description"] end end raise "Error - cannot create WePay account" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_wepay_account\n raise 'Error - cannot create WePay account' unless wepay_access_token? && !wepay_account?\n params = { name: farm, description: 'Farm selling ' + produce }\n response = Wefarm::Application::WEPAY.call('/account/create', wepay_access_token, params)\n\n raise 'Error - ' + respo...
[ "0.84593177", "0.8210238", "0.6931161", "0.66629356", "0.6605075", "0.6540837", "0.6511814", "0.64503384", "0.6416121", "0.63049054", "0.61965", "0.61965", "0.61664593", "0.6043625", "0.5988993", "0.596523", "0.59083587", "0.5901779", "0.5834812", "0.58004194", "0.5794443", ...
0.663668
4
File staging and cleanup
def stage_unzipped(zipfile, stage_dir) # Unzip file to a specified directory Dir.mkdir stage_dir unless Dir.exist?(stage_dir) Zip::File.open(zipfile) do |z| z.each do |f| extract_path = File.join(stage_dir, f.name) z.extract(f, extract_path) unless File.exist?(extract_path) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup\n File.delete(temp_file_path)\n end", "def cleanup\n File.delete(@tmp_state) rescue nil\n end", "def process(&blk)\n result = tempfile(&blk)\n\n # Should we add destroy to an ensure block? Im not sure if it makes sense\n # to delete failed files.\n file.destroy\n\n ...
[ "0.7183107", "0.70705885", "0.69252986", "0.68893105", "0.68152714", "0.680847", "0.67785966", "0.673514", "0.66969645", "0.66234565", "0.6603937", "0.6484947", "0.64607406", "0.64607406", "0.64607406", "0.64607406", "0.64599407", "0.6440046", "0.64189106", "0.6407404", "0.63...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_object @profile = Klass.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 object_params params.require(Klass.name.downcase).permit(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
o operador vai transformar todos os parametros em array
def varios_args(*args) puts "Tamanho de args: #{args.size}" args.each { |x| p x} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def params_array_from(raw_params); end", "def rewrite_param_values(array_params); end", "def array_converter(*args)\n \nend", "def splat(*numeros)\n\tnumeros.max #devuelve el maximo de muchos parametros, los almacena en un arreglo\nend", "def build_array(param1, param2, param3)\n\t[param1, param2, param...
[ "0.672856", "0.6564216", "0.6515357", "0.6462002", "0.6156554", "0.61270934", "0.6098941", "0.60718465", "0.60718465", "0.60718465", "0.6023961", "0.6010657", "0.59756786", "0.5940247", "0.5933365", "0.5868176", "0.5858322", "0.5839578", "0.58332247", "0.5826651", "0.58243734...
0.0
-1
searchable do text :title do NetworkKanjiFilter.to_hiragana(title) end text :title_en end
def first_release self.releases.where(status: STATUS[:completed]).first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def searchtitle\n end", "def title_for_search\n (title || \"\").strip.sub(/\\Athe\\s+/i, \"\").sub(/\\Aan?\\s+/i, \"\")\n end", "def to_search_string\n\t\tself.title\n\tend", "def slogan\n search_by_text 'слоган'\n end", "def title_en\n search_by_itemprop 'alternativeHeadline'\n end", ...
[ "0.70106524", "0.6777615", "0.6683918", "0.6529928", "0.6506478", "0.6476711", "0.64364284", "0.6310106", "0.6304922", "0.62525785", "0.6210233", "0.6175444", "0.61528605", "0.6132699", "0.6105639", "0.6077407", "0.6065755", "0.6015742", "0.6015142", "0.60107875", "0.59802616...
0.0
-1
Feel free to google "how to generate a random number in ruby" using the random
def roll # code goes here 1 + rand(6) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_number\r\n return randomNumber = 1 + rand(100)\r\n end", "def rand\n return extract_number / (2**32 -1).to_f\n end", "def random\n 1 + (10 * rand(0))\n end", "def gen_num\n rand(1..100)\nend", "def random_number\n t = Time.now.to_f / (Time.now.to_f % Time.now.to_i)\n r...
[ "0.8369675", "0.8257068", "0.82547355", "0.81025475", "0.8089324", "0.8072731", "0.79939806", "0.79765075", "0.79765075", "0.7972613", "0.7961023", "0.7952416", "0.7915623", "0.7878636", "0.78605103", "0.7834599", "0.7827221", "0.780836", "0.7801179", "0.7745336", "0.7735712"...
0.0
-1
Helper method for bottomup implementation
def knapsack_table(weights, values, capacity) solution_table = [] (0..capacity).each do |i| solution_table[i] = [] (0...weights.length).each do |j| if i == 0 solution_table[i][j] = 0 elsif j == 0 solution_table[i][j] = weights[j] > i ? 0 : values[j] else option1 = solution_table[i][j - 1] option2 = weights[j] > i ? 0 : solution_table[i - weights[j]][j - 1] + values[j] optimum = [option1, option2].max solution_table[i][j] = optimum end end end solution_table end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_bottom\n return unless in_list?\n\n decrement_positions_on_lower_items\n assume_bottom_position \n end", "def move_to_bottom\n return unless in_list?\n\n decrement_positions_on_lower_items\n assume_bottom_position\n end", "def move_to_bottom\n ...
[ "0.70185775", "0.6855966", "0.6792547", "0.66875625", "0.66756815", "0.6672704", "0.66373646", "0.663226", "0.6596407", "0.6587347", "0.6516622", "0.65097195", "0.6507161", "0.64792657", "0.6440934", "0.6431597", "0.6431418", "0.63186693", "0.6293141", "0.62752163", "0.626493...
0.0
-1
Retrieves a single resource
def find(id, options = {}) response = client.get("#{base_path}/#{id}", options) return parse(response) unless block_given? yield response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_resource\n execute(resource_path, method: :get)\n end", "def find_resource\n get params[:resource_path]\n end", "def resource\n klass, param = resource_class\n klass&.find(params[param.to_sym])\n end", "def get_resource_to_use\n return @resources.first\n end", "def ge...
[ "0.85338926", "0.77728117", "0.7647298", "0.76227075", "0.75751865", "0.7545986", "0.7457722", "0.7360439", "0.7292875", "0.7287937", "0.7249435", "0.72328496", "0.71400493", "0.71370107", "0.71356344", "0.71356344", "0.71301067", "0.7024544", "0.7021953", "0.70050436", "0.69...
0.0
-1
Retrieves a specific page of a collection
def page(pagenum = 1, options = {}) per = options[:per] || client.config[:pagination_page_size] response = client.get(base_path, { page: pagenum, per: per }.merge(options)) return parse(response) unless block_given? yield response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_page\n collection.next_page\n end", "def page_collection!\n return unless paginate\n\n page = params[:page].to_i\n page = 1 if page.zero?\n page_size = params[:page_size].to_i\n page_size = DEFAULT_PAGE_SIZE if page_size <= 0\n self.collection = collecti...
[ "0.69254494", "0.68476516", "0.68079156", "0.6805436", "0.6805436", "0.66945153", "0.6667308", "0.6661761", "0.66353804", "0.66188407", "0.6616022", "0.6616022", "0.65988135", "0.65988135", "0.6558365", "0.65333027", "0.65045583", "0.6502502", "0.64963126", "0.6468567", "0.64...
0.5911296
76
Retrieves a collection of resources
def all(options = {}) response = client.get(base_path, options) return parse(response) unless block_given? yield response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collection\n resource_class.all\n end", "def resources\n self.collection.find({}, :sort => [:_id, :asc]).map do |hash|\n self.normalize hash\n end\n end", "def collection(options={})\n response = client.get(api_path, options)\n\n if response.success?\n ...
[ "0.78975713", "0.75651526", "0.73177934", "0.7306009", "0.7232982", "0.72016895", "0.72016895", "0.72016895", "0.70865995", "0.7059169", "0.70431733", "0.70049995", "0.70029676", "0.69989496", "0.69456136", "0.6924579", "0.6924579", "0.6924579", "0.6924579", "0.6924579", "0.6...
0.0
-1
accepts_nested_attributes_for :cuttings, allow_destroy: true calculates the days to recover a plant
def recovered? date = self.arrival_date rec_date = self.recovery_date if rec_date == nil "Not Recovered" elsif date > rec_date "Not Recovered" else a = Date.parse("#{date}") b = Date.parse("#{rec_date }") c = b.mjd - a.mjd "#{rec_date.month}/#{rec_date.day}/#{rec_date.year} | #{c} day" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def planting_params\n params.require(:planting).permit(:date, :seed_treated, :soil_condition, :grow_id)\n end", "def form_object_params\n params.require(:meal).permit(:consumption_time, ingredients_attributes: %i(name id commit _destroy))\n end", "def planting_params\n params.require(:plan...
[ "0.53947544", "0.5384133", "0.52744126", "0.5182724", "0.5168537", "0.5125227", "0.5067677", "0.5035993", "0.49974865", "0.49877486", "0.49656504", "0.49314135", "0.49262202", "0.49210846", "0.48812333", "0.4849214", "0.48455626", "0.48437196", "0.48405296", "0.4825629", "0.4...
0.0
-1
Retrieve all template information. Build an array of template ids here over which to iterate
def retrieve_all_template_info puts "Retrieving all template ids and names for #{@primary_username} ..." puts uri = URI(@config['endpoint']) # Retrieve templates http = Net::HTTP.new( uri.host,uri.port ) http.use_ssl = true request = Net::HTTP::Get.new( uri.request_uri ) request.basic_auth(@primary_username, @primary_password) response = http.request( request ) templates = JSON.parse( response.body ) # Create template_id array @template_array = Array.new # Create a template hash w/ name and id for each template found templates['templates'].each do |t| @template_array.push({:id => t['id'], :name => t['name']}) end # Return constructed temmplate array return template_array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n @client.call(method: :get, path: 'templates')\n end", "def list\n @client.make_request :get, templates_path\n end", "def select_template\n templatelist = []\n templatelist\n end", "def get_ids_by_host(data)\n result = []\n @client.api_request(:method => \...
[ "0.6812131", "0.66967785", "0.66958106", "0.6672116", "0.6672116", "0.6652211", "0.6617218", "0.6595698", "0.6591689", "0.6560652", "0.6559263", "0.6516133", "0.6483969", "0.6438744", "0.6349718", "0.63436997", "0.6337578", "0.6334029", "0.6328988", "0.63022083", "0.63022083"...
0.82086986
0
Retrieve single template. This method will be iterative over the result of retrieve_all_template_info
def retrieve_single_template( template_id ) puts "Retrieving template id #{template_id}." uri = URI(@config['endpoint'] + '/' + template_id) # Retrieve templates http = Net::HTTP.new( uri.host,uri.port ) http.use_ssl = true request = Net::HTTP::Get.new( uri.request_uri ) request.basic_auth(@primary_username, @primary_password) response = http.request( request ) template = JSON.parse( response.body ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def details\n response = get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def details\n response = CreateSend.get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def get_template(template_name)\n self.api_get(:template,...
[ "0.7586648", "0.74029773", "0.7339263", "0.7268522", "0.7008067", "0.68500745", "0.68413126", "0.68368345", "0.68368345", "0.6663513", "0.6575016", "0.6574777", "0.6563132", "0.64946645", "0.64781356", "0.64725524", "0.64099216", "0.6406067", "0.63910824", "0.63813275", "0.63...
0.7499402
1
Save each template content here. This method will be iterative over the result of retrieve_single_template
def backup_template( template ) filename = "./templates/#{template['id']}.json" file = File.new(filename, "w") puts "Backing up #{filename} ..." file.write( template ) file.close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_template\n if @processed.nil?\n @processed, @rest = templates.keys.partition { |k| k.to_s.include? \".\" }\n end\n\n @processed.each do |k|\n yield k, templates[k]\n end\n\n @rest.each do |k|\n yield k, templates[k]\n end\n end", "def each_template(markup)\n @tem...
[ "0.5983914", "0.594096", "0.58217496", "0.5722226", "0.56351703", "0.56322646", "0.56096065", "0.5551468", "0.5501448", "0.547453", "0.5463591", "0.5455485", "0.5446203", "0.54287803", "0.5423405", "0.5396925", "0.5387826", "0.5386698", "0.5323596", "0.5321989", "0.53176475",...
0.5115024
50
Create a single template (in new location/account). This method will be iterative over the result of save_templates. The templates created here will be blank.
def create_template( template_name ) puts "Creating new template #{template_name} at #{@secondary_username}..." uri = URI(@config['endpoint']) # Retrieve templates http = Net::HTTP.new( uri.host,uri.port ) http.use_ssl = true request = Net::HTTP::Post.new( uri.request_uri, initheader = {'Content-Type:' => 'application/json'} ) request.basic_auth(@secondary_username, @secondary_password) payload = {:name => "#{template_name}"}.to_json request.body = payload response = http.request( request ) new_template_info = JSON.parse( response.body ) new_template_id = new_template_info['id'] return new_template_id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n authorize Template\n args = template_params\n # Swap in the appropriate visibility enum value for the checkbox value\n args[:visibility] = parse_visibility(args, current_user.org)\n\n # creates a new template with version 0 and new family_id\n @template = Template.new(arg...
[ "0.73595446", "0.7247145", "0.71185", "0.69296783", "0.68861276", "0.6782731", "0.6688092", "0.6598686", "0.65560687", "0.64464146", "0.64348936", "0.64022124", "0.63150847", "0.62699467", "0.6267875", "0.6226521", "0.61884165", "0.61726815", "0.6120168", "0.6080297", "0.6076...
0.67197317
6
Popuate the newy created templates with the content received from save_templates. Each file will be read in iteratively, and content matched to correct template.
def populate_template( template_id, imported_template ) puts "Populating new tempalte id: #{template_id}..." uri = URI(@config['endpoint']+"/#{template_id}/versions") # Retrieve templates http = Net::HTTP.new( uri.host,uri.port ) http.use_ssl = true request = Net::HTTP::Post.new( uri.request_uri, initheader = {'Content-Type:' => 'application/json'} ) request.basic_auth(@secondary_username, @secondary_password) # If versions exist, transfer each to new template imported_template['versions'].each do |version| version.delete("id") version.delete("user_id") version.delete("template_id") version.delete("updated_at") puts " Adding template version #{version['name']}..." payload = version.to_json request.body = payload response = http.request( request ) response_message = JSON.parse( response.body ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def templates_for(file); end", "def generate(page_setup = {})\n Zip::File.open(@template_path) do |template_zip|\n buffer = Zip::OutputStream.write_buffer do |out|\n template_zip.each do |entry|\n out.put_next_entry entry.name\n if @replaceable_files[entry.name] && entr...
[ "0.6779656", "0.6523972", "0.6401049", "0.6318663", "0.6313441", "0.62529856", "0.62517434", "0.6200578", "0.61539805", "0.61352575", "0.6117156", "0.6111401", "0.6107214", "0.60853106", "0.6067784", "0.60462075", "0.6042569", "0.60304505", "0.6016003", "0.59777576", "0.59440...
0.0
-1
Creates and initializes a new instance of the SnapshotOperations class.
def initialize(client) @client = client end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(configuration, options = {})\n super(configuration, 'snapshots', 'Microsoft.Compute', options)\n end", "def create_snapshot(metadata={})\n Azure::Blobs.create_snapshot(self, metadata)\n end", "def initialize(operation)\n @operation = operation\n @databas...
[ "0.60971373", "0.6010111", "0.58373743", "0.57937086", "0.56721276", "0.5568523", "0.54883784", "0.547017", "0.5396341", "0.536269", "0.53358746", "0.5322654", "0.5315434", "0.5293061", "0.5268752", "0.5233057", "0.5207205", "0.5199257", "0.5197871", "0.51711124", "0.51641476...
0.0
-1
Given a string or an IO object, this will attempt a parse of its contents and return a result. If the parse fails, a Parslet::ParseFailed exception will be thrown.
def parse(io) if io.respond_to? :to_str io = StringIO.new(io) end result = apply(io) # If we haven't consumed the input, then the pattern doesn't match. Try # to provide a good error message (even asking down below) unless io.eof? # Do we know why we stopped matching input? If yes, that's a good # error to fail with. Otherwise just report that we cannot consume the # input. if cause raise Parslet::ParseFailed, "Unconsumed input, maybe because of this: #{cause}" else error(io, "Don't know what to do with #{io.string[io.pos,100]}") end end return flatten(result) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(io)\n source = Parslet::Source.new(io)\n context = Parslet::Atoms::Context.new\n \n result = nil\n value = apply(source, context)\n \n # If we didn't succeed the parse, raise an exception for the user. \n # Stack trace will be off, but the error tree should explain the reason\n ...
[ "0.72174203", "0.6852277", "0.6852277", "0.6703048", "0.631334", "0.6219154", "0.6219154", "0.6219154", "0.6219154", "0.61336005", "0.61092764", "0.6071023", "0.6033791", "0.5999352", "0.5886984", "0.5871687", "0.5851328", "0.5810459", "0.5778697", "0.569109", "0.56814206", ...
0.69466734
1
Construct a new atom that repeats the current atom min times at least and at most max times. max can be nil to indicate that no maximum is present. Example: match any number of 'a's str('a').repeat match between 1 and 3 'a's str('a').repeat(1,3)
def repeat(min=0, max=nil) Parslet::Atoms::Repetition.new(self, min, max) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeat(min = T.unsafe(nil), max = T.unsafe(nil)); end", "def rep(rule, min=1, max=Infinity, &block)\n ext(Repeat.new(rule, min, max), block)\n end", "def rep(rule, min=1, max=Infinity, &block)\n ext(Repeat.new(min, max, rule), block)\n end", "def repeat min = nil, max = nil\n Parslet...
[ "0.64874667", "0.64760303", "0.6467832", "0.6409728", "0.5549661", "0.51496565", "0.51174235", "0.511173", "0.49808976", "0.49430907", "0.49255964", "0.49134278", "0.48976672", "0.48437476", "0.48371568", "0.48275897", "0.47970575", "0.47713268", "0.47107324", "0.47024688", "...
0.70429593
0
Returns a new parslet atom that is only maybe present in the input. This is synonymous to calling repeat(0,1). Generated tree value will be either nil (if atom is not present in the input) or the matched subtree. Example: str('foo').maybe
def maybe Parslet::Atoms::Repetition.new(self, 0, 1, :maybe) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_if_nil(word, value)\n current = @root\n current_prefix = word\n\n while current_prefix != \"\"\n current, current_prefix = find_canididate_insertion_node(current, current_prefix)\n end\n\n current[:value] ||= value\n return current[:value]\n end", "def maybe(*args, **opts, &block)...
[ "0.51193595", "0.48774472", "0.48455667", "0.47992495", "0.47945142", "0.4708897", "0.46568134", "0.46323395", "0.4578652", "0.45517424", "0.4451846", "0.44018352", "0.43995935", "0.43551353", "0.43493292", "0.43220568", "0.4316036", "0.43117633", "0.42866147", "0.42510933", ...
0.6656186
0
Chains two parslet atoms together as a sequence. Example: str('a') >> str('b')
def >>(parslet) Parslet::Atoms::Sequence.new(self, parslet) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chain( s )\n @pipe[-1] << \".#{s}\"\n end", "def makeMove mv\n @pipe1.puts mv \n @pipe1.flush\n\n input = \"\"\n begin\n line = @pipe2.gets\n input += line\n end while !line.include? \">\\n\"\n\n moves = input.split(\"<\").last.delete(\">\")\nend", "def shovel\n ->(m1, m2) {\n bind...
[ "0.5985303", "0.57310134", "0.5723036", "0.56342447", "0.5550799", "0.53289574", "0.53173035", "0.52855676", "0.526712", "0.52621454", "0.5261136", "0.52579725", "0.52575976", "0.5187974", "0.5152323", "0.5149229", "0.51439124", "0.51308405", "0.51308405", "0.51217604", "0.51...
0.55887026
4
Chains two parslet atoms together to express alternation. A match will always be attempted with the parslet on the left side first. If it doesn't match, the right side will be tried. Example: matches either 'a' OR 'b' str('a') | str('b')
def |(parslet) Parslet::Atoms::Alternative.new(self, parslet) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def |( other )\n\t\treturn Regexp.new( \"(?:%s|%s)\" % [self.to_s, other.to_s] )\n\tend", "def or(argument1, argument2)\n argument1 || argument2\n end", "def either(left, right)\n \"#{quotify left} OR #{quotify right}\"\n end", "def or(e1, e2)\n eval_ex(e1) | eval_ex(e2)\n end", "de...
[ "0.6599361", "0.6116721", "0.60981584", "0.6083554", "0.60451037", "0.6035708", "0.6023002", "0.5913581", "0.58657324", "0.5855425", "0.5779021", "0.5775417", "0.5757424", "0.57457024", "0.57374763", "0.5737463", "0.57156444", "0.56731385", "0.5655394", "0.56277335", "0.56174...
0.0
-1
Tests for absence of a parslet atom in the input stream without consuming it. Example: Only proceed the parse if 'a' is absent. str('a').absnt?
def absnt? Parslet::Atoms::Lookahead.new(self, false) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def liberal_parsing?() @liberal_parsing end", "def none?\n @value.to_s.empty? or /\\Anone\\z/io.match(@value.to_s)\n end", "def atom_safe?( str )\n not ATOM_UNSAFE === str\n end", "def is_missing?(value)\n value.nil? or (String===value and value.strip.empty?)\n end", "def ...
[ "0.5951514", "0.57234496", "0.563946", "0.5633084", "0.5585235", "0.5575473", "0.5559646", "0.5534272", "0.55145633", "0.5508625", "0.5506903", "0.549662", "0.5493121", "0.54790026", "0.54713666", "0.5426929", "0.5417753", "0.54136544", "0.54093033", "0.54036856", "0.5374929"...
0.5851146
1
Tests for presence of a parslet atom in the input stream without consuming it. Example: Only proceed the parse if 'a' is present. str('a').prsnt?
def prsnt? Parslet::Atoms::Lookahead.new(self, true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def liberal_parsing?() @liberal_parsing end", "def can_parse?(str)\n str.match(/^#{tag}\\=[^\\x01]*\\x01/)\n end", "def prad_valid? str\n return false unless str\n !!parse(str)\n end", "def should_parse?\n parsed? == false && headers['x-amp'] != 'skip'\n end", "def shou...
[ "0.6248207", "0.5958705", "0.5909923", "0.5788839", "0.5725381", "0.5696414", "0.56573516", "0.5643221", "0.5618856", "0.5614513", "0.55949306", "0.55343765", "0.5502125", "0.5455556", "0.54213727", "0.5390533", "0.5375019", "0.5373965", "0.53689283", "0.5319413", "0.5296652"...
0.589633
3
Cause should return the current best approximation of this parslet of what went wrong with the parse. Not relevant if the parse succeeds, but needed for clever error reports.
def cause # :nodoc: @last_cause end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_failure_cause; end", "def cause_message\n root_cause.best_message\n end", "def cause # :nodoc:\n @last_cause && @last_cause.to_s || nil\n end", "def cause\n data.cause\n end", "def parse_failed(cause, exception_klass=Parslet::ParseFailed)\n @last_cause = cause\n raise ex...
[ "0.65493697", "0.6492258", "0.63392115", "0.62310016", "0.6196395", "0.58563733", "0.55567557", "0.5497331", "0.5495598", "0.54370177", "0.5403716", "0.5403716", "0.529751", "0.52580476", "0.5218009", "0.5160588", "0.5141969", "0.50906146", "0.50320584", "0.498276", "0.493253...
0.61801594
5
Report/raise a parse error with the given message, printing the current position as well. Appends 'at line X char Y.' to the message you give. If +pos+ is given, it is used as the real position the error happened, correcting the io's current position.
def error(io, str, pos=nil) pre = io.string[0..(pos||io.pos)] lines = Array(pre.lines) if lines.empty? formatted_cause = str else pos = lines.last.length formatted_cause = "#{str} at line #{lines.count} char #{pos}." end @last_cause = formatted_cause raise Parslet::ParseFailed, formatted_cause, nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def error(error_message, current_scope = nil, current_exp = nil)\n if current_exp.respond_to?(:position) && current_exp.position && current_exp.position.lineno\n pos = current_exp.position\n location = \" @ #{pos.inspect}\"\n elsif @lastpos\n location = \" near (after) #{@lastpos}\"\n else\...
[ "0.6947295", "0.6947295", "0.6276376", "0.614279", "0.60134834", "0.59056336", "0.5842644", "0.5829156", "0.58288133", "0.5718064", "0.5662606", "0.56615263", "0.56347984", "0.56316334", "0.56172544", "0.5604067", "0.55866724", "0.55265605", "0.54059964", "0.53876317", "0.535...
0.72440624
0
Sets the password reset attributes.
def create_reset_digest self.reset_token = ApplicationController.new_token update_attribute(:reset_digest, ApplicationController.digest(reset_token)) update_attribute(:reset_sent_at, Time.zone.now) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_reset_password_instructions(attributes={})\n send_instructions_for(:reset_password, attributes)\n end", "def set_password_reset\n\t\tself.code = SecureRandom.urlsafe_base64\n\t\tself.expires_at = 4.hours.from_now\n\t\tself.save!\n\tend", "def attempt_set_password(params)\n p = {}\n ...
[ "0.7047396", "0.69583577", "0.6818595", "0.6749292", "0.6737656", "0.670031", "0.6676551", "0.66730624", "0.66577595", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103", "0.66103",...
0.0
-1
Sends password reset email.
def send_password_reset_email UserMailer.password_reset(self.class.name.to_s.downcase.pluralize, self).deliver_now logger.info "email: admin password reset sent to #{email}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_password_reset_email\n\t\tUserMailer.password_reset(id, self.reset_token).deliver_later\n \tend", "def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end", "def send_password_reset_email\r\n UserMailer.password_reset(self).deliver_now\r\n end", "de...
[ "0.8790497", "0.86796135", "0.86796135", "0.8663904", "0.86629623", "0.86629623", "0.86629623", "0.86629623", "0.86629623", "0.86629623", "0.86629623", "0.86629623", "0.86629623", "0.86587805", "0.8652506", "0.8650495", "0.8648778", "0.8633209", "0.8633209", "0.8633209", "0.8...
0.0
-1
Returns true if a password reset has expired.
def password_reset_expired? reset_sent_at < 2.hours.ago end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def password_reset_expired?\n reset_sent_at < Settings.timeout_reset_password.hours.ago\n end", "def password_reset_expired?\n reset_sent_at < 2.hours.ago # password reset sent earlier than two hours ago.\n end", "def password_reset_expired?\n reset_sent_at < 2.hours.ago # reads as password reset se...
[ "0.8866848", "0.87405956", "0.869067", "0.86877984", "0.86600757", "0.86578995", "0.86572534", "0.86572534", "0.86572534", "0.86572534", "0.86572534", "0.86572534", "0.86572534", "0.86572534", "0.8651915", "0.8649047", "0.86207587", "0.8620148", "0.86081725", "0.86076194", "0...
0.8742425
1
GET /fnf_items GET /fnf_items.json
def index @fnf_items = FnfItem.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @items = Item.find(params[:id])\n render json: @items\n end", "def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend", "def fetch\n result = WebApi.json!('ITFItems_440', 'GetPlayerItems', 1, { :SteamID => @steam_...
[ "0.68880343", "0.6700884", "0.66582596", "0.6637868", "0.6602145", "0.6580473", "0.65746987", "0.6528283", "0.6508454", "0.6503422", "0.64814156", "0.6465555", "0.64136887", "0.64136887", "0.64136887", "0.64136887", "0.6407439", "0.6405341", "0.63968736", "0.63893515", "0.638...
0.75232977
0
GET /fnf_items/1 GET /fnf_items/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @fnf_items = FnfItem.all\n end", "def show\n @items = Item.find(params[:id])\n render json: @items\n end", "def show\n require 'net/http'\n require 'json'\n\n response = Net::HTTP.get_response( URI.parse( \"http://freeshit.firebaseio.com/items/%s.json\" % [ params[:id] ] ) );\n\...
[ "0.7148471", "0.7062004", "0.6954867", "0.6825546", "0.67909724", "0.66906935", "0.66899335", "0.66705793", "0.6653222", "0.66157293", "0.6610018", "0.6580018", "0.6576504", "0.6542761", "0.65418804", "0.65412927", "0.6505877", "0.6498046", "0.64964974", "0.6484782", "0.64847...
0.0
-1
POST /fnf_items POST /fnf_items.json
def create @fnf_item = FnfItem.new(fnf_item_params) respond_to do |format| if @fnf_item.save format.html { redirect_to @fnf_item, notice: 'Fnf item was successfully created.' } format.json { render :show, status: :created, location: @fnf_item } else format.html { render :new } format.json { render json: @fnf_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end", "def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end", "def create\n create_params = item_params\n item = Item.new(\n name: creat...
[ "0.72207713", "0.67484325", "0.67477804", "0.66641617", "0.6635152", "0.6523007", "0.64696527", "0.6447944", "0.6436264", "0.6428302", "0.63975084", "0.6395761", "0.63598627", "0.6294305", "0.6270345", "0.626063", "0.6258671", "0.625775", "0.6232487", "0.6231857", "0.6193738"...
0.7313476
0
PATCH/PUT /fnf_items/1 PATCH/PUT /fnf_items/1.json
def update respond_to do |format| if @fnf_item.update(fnf_item_params) format.html { redirect_to @fnf_item, notice: 'Fnf item was successfully updated.' } format.json { render :show, status: :ok, location: @fnf_item } else format.html { render :edit } format.json { render json: @fnf_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n json_response(@food_item.update!(food_item_params))\n end", "def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end", "def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item...
[ "0.7083626", "0.7041379", "0.68925995", "0.67435515", "0.6677418", "0.6621005", "0.66181964", "0.6582088", "0.6561441", "0.65573895", "0.6556058", "0.6530383", "0.6519308", "0.65159804", "0.6510725", "0.64919347", "0.64915043", "0.64876", "0.6476257", "0.645653", "0.6449354",...
0.72149175
0
DELETE /fnf_items/1 DELETE /fnf_items/1.json
def destroy @fnf_item.destroy respond_to do |format| format.html { redirect_to fnf_items_url, notice: 'Fnf item was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body...
[ "0.73617923", "0.7226795", "0.70814204", "0.7033399", "0.70078087", "0.6970182", "0.6960349", "0.695755", "0.6948101", "0.69021577", "0.6897318", "0.68926764", "0.6892373", "0.6892373", "0.6892373", "0.6892373", "0.6892373", "0.6892373", "0.6892373", "0.6892373", "0.6892373",...
0.73346955
1
Use callbacks to share common setup or constraints between actions.
def set_fnf_item @fnf_item = FnfItem.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 fnf_item_params params.require(:fnf_item).permit(:no_of_fnf, :pulse, :fnf_on_net_tariff, :fnf_off_net_tariff, :fnf_atw, :fnf_priority) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
with K <= x <= K, and add x to A[i]. After this process, we have some array B. Return the smallest possible difference between the maximum value of B and the minimum value of B.
def smallest_range_i(a, k) result = a.max - a.min - 2 * k result >= 0 ? result : 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def largest_sum_after_k_negations_a(a, k)\n while k > 0\n min = a.index(a.min)\n a[min] = -a[min]\n k -= 1\n end\n a.sum\nend", "def maxMin(k, arr)\n # 1) sort the array in asceding order\n arr.sort!\n\n min = nil\n # 2) iterate array from 0 to array length - k\n for i in 0..(arr.length - k)\n ...
[ "0.64099276", "0.63714606", "0.63676614", "0.63227135", "0.6063917", "0.59130305", "0.5908817", "0.5861737", "0.5845204", "0.57851243", "0.5775096", "0.57551897", "0.573973", "0.5710654", "0.56615865", "0.56445765", "0.55736977", "0.5570576", "0.5569705", "0.55530894", "0.555...
0.5856305
8
GET /users/1 GET /users/1.json
def show #here session[:mad] is the session variable which holds current logged in user id. if session[:mad]==nil redirect_to(:controller => 'logins',:action => 'homelog') else @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @user } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.722...
0.0
-1
GET /users/new GET /users/new.json
def new #here, while creating the user, the default user type(utype) is set to zero. @user = User.new @user.utype=0 respond_to do |format| format.html # new.html.erb format.json { render json: @user } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end", "def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n ...
[ "0.8287397", "0.8169197", "0.8155916", "0.80483407", "0.8022376", "0.8021751", "0.8009459", "0.7950995", "0.793078", "0.793078", "0.7873476", "0.7873476", "0.7873476", "0.7860956", "0.7860956", "0.7860956", "0.7860956", "0.7860956", "0.7860956", "0.7860956", "0.7860956", "0...
0.0
-1
POST /users POST /users.json
def create @user = User.new(params[:user]) respond_to do |format| if @user.save format.html { redirect_to @user, notice: 'User was successfully created.' } format.json { render json: @user, status: :created, location: @user } else format.html { render action: "new" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post b...
[ "0.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69...
0.0
-1
PUT /users/1 PUT /users/1.json
def update # here session[:ad] is the session variable which hols the id of the logged in admin and session[:mad] holds the id of the logged in user. # an update can be made only when admin is logged in or if the update is being made on the user that is logged in currently. #this is the functionality of this method. @user = User.find(params[:id]) if(session[:ad]!=nil || session[:mad].to_i==@user.id) respond_to do |format| if @user.update_attributes(params[:user]) format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @user.errors, status: :unprocessable_entity } end end else flash[:notice]="Cannot update information of other user" redirect_to(:controller => 'logins',:action => 'homelog') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "de...
[ "0.74114245", "0.73920554", "0.73041475", "0.7254177", "0.7202618", "0.70756376", "0.70535713", "0.7029043", "0.70075685", "0.69883573", "0.6983195", "0.694263", "0.69409895", "0.692315", "0.6909438", "0.687742", "0.68486536", "0.6834162", "0.6821841", "0.6801179", "0.6770304...
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy @user = User.find(params[:id]) #here session[:ad] holds the id of the logged in admin. and the user is destroyed only if the logged in user is admin. That is the functionality of this method. if(session[:ad]!=nil) @user.destroy respond_to do |format| format.html { redirect_to users_url } format.json { head :ok } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\...
[ "0.78750724", "0.77518034", "0.7713981", "0.7610077", "0.747295", "0.74073994", "0.74073994", "0.7369968", "0.7346072", "0.7340465", "0.7328618", "0.7309635", "0.73095363", "0.7306841", "0.7297868", "0.72917855", "0.7291585", "0.7289111", "0.7284347", "0.7250935", "0.7250935"...
0.0
-1
validate :a_method_used_for_validation_purposes def a_method_used_for_validation_purposes errors[:base] << "This person is invalid because ..." end
def a_method_before_add(comment) puts "================== Something before comment get added! ========================" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_validation_errors(value); end", "def validate\n errors.add(:post_office, \"- must be filled for postalcode #{self.postal_code}\") if self.post_office.blank? && !self.postal_code.blank?\n errors.add(:postal_code, \"- must be filled for #{self.post_office}\") if self.postal_code.blank? && !self.post_...
[ "0.74915016", "0.7408134", "0.70487005", "0.70487005", "0.70481586", "0.704153", "0.6984929", "0.6984929", "0.6984929", "0.6969289", "0.6969289", "0.6969289", "0.6969289", "0.68569046", "0.68340254", "0.6774232", "0.6774232", "0.6755191", "0.66835773", "0.6657226", "0.6599348...
0.0
-1
Pass a value, and a boolean flag to convert it
def check_bool @output = bool_safe(bool) render :plain => "#{bool.inspect} #{@output.inspect}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _convert_value(val)\n v = case val\n when :nil then nil\n when :false then false\n when :true then true\n else\n val\n end\n v\n end", "def typecast_value_boolean(opts={});true;end", "def typecast_value_boolean(value)\n case value\n when fa...
[ "0.76891327", "0.7603148", "0.7395087", "0.7267215", "0.7242795", "0.7169323", "0.71594125", "0.7080612", "0.70476913", "0.70445126", "0.70445126", "0.69600624", "0.6936285", "0.6900871", "0.68703413", "0.68611324", "0.6836495", "0.67875594", "0.6785985", "0.6783603", "0.6763...
0.0
-1
check to see if a character exists in a string. /put_character_here/ =~ operator or .match method matches the character in the string "string" =~ /character_here/ /character_here/.match("string") boolean_regex.rb
def has_a_b?(string) if string =~ /b/ puts "We have a match!" else puts "No match here." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string_contains_reg_exp?(char_string, reg_exp)\n (char_string =~ reg_exp).nil?\nend", "def has_special_ch?(str)\n (str =~ @@regex)?true:false\n end", "def contains?(char)\r\n any_letter_found = false\r\n each do |letter|\r\n if char.upcase == letter.content\r\n letter.state = :found\...
[ "0.8013797", "0.7780736", "0.7591087", "0.7517885", "0.74107563", "0.73752326", "0.73617053", "0.7229862", "0.72144413", "0.7200005", "0.71541405", "0.7153099", "0.7136904", "0.71316314", "0.71103823", "0.7051643", "0.7013593", "0.7000807", "0.69556653", "0.68760824", "0.6854...
0.0
-1
Methods Exercise 9: Print Me (Part 1) Write a method named print_me that prints "I'm printing within the method!" when invoked.
def print_me puts "I'm printing within the method!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_me()\n \"I'm printing within the method!\"\nend", "def print_me\n puts \"I'm printing within the method!\"\nend", "def print_me\n puts \"I'm printing within the method!\"\nend", "def print_me\n puts \"I'm printing within the method!\"\nend", "def print_me\n puts \"I'm printing within the met...
[ "0.8546282", "0.85374385", "0.85374385", "0.85374385", "0.85374385", "0.85374385", "0.85374385", "0.85374385", "0.8520836", "0.8517741", "0.7448558", "0.7270837", "0.7270837", "0.7270837", "0.7270837", "0.7270837", "0.72488195", "0.7220609", "0.7214637", "0.70818084", "0.7081...
0.8505331
10
breakpoint.enabled? Returns whether breakpoint is enabled or not.
def enabled?() #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breakpoint?\n type == :breakpoint\n end", "def waiting_for_breakpoint?\n @breakpoint_listener.status == 'sleep'\n end", "def waiting_for_breakpoint?\n @breakpoint_listener.status == 'sleep'\n end", "def enabled?\n @enabled\n end", "def enabled?\n @enabled\n end",...
[ "0.76685584", "0.7057735", "0.7028567", "0.68170124", "0.68170124", "0.68170124", "0.68170124", "0.6726431", "0.6704576", "0.669025", "0.6648542", "0.66412187", "0.66412187", "0.66183513", "0.66183513", "0.66145736", "0.66145736", "0.66132134", "0.65971726", "0.6575421", "0.6...
0.62973887
30
breakpoint.expr > string Returns a codition expression when this breakpoint should be activated.
def expr() #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def at_breakpoint(_context, breakpoint)\n @pry ||= Pry.new\n\n output.puts bold(\"\\n Breakpoint #{breakpoint.id}. \") + n_hits(breakpoint)\n\n expr = breakpoint.expr\n return unless expr\n\n output.puts bold('Condition: ') + expr\n end", "def at_breakpoint(breakpoint)\n @pry ||...
[ "0.60961115", "0.6030832", "0.56119454", "0.5579488", "0.5509498", "0.5367534", "0.53491104", "0.5175877", "0.5140106", "0.5128539", "0.50933677", "0.5053711", "0.5004409", "0.5003229", "0.4993003", "0.4980137", "0.49778333", "0.49630427", "0.49523926", "0.49256495", "0.49137...
0.52103394
7
breakpoint.expr = string | nil Sets the codition expression when this breakpoint should be activated.
def expr=(p1) #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def at_breakpoint(_context, breakpoint)\n @pry ||= Pry.new\n\n output.puts bold(\"\\n Breakpoint #{breakpoint.id}. \") + n_hits(breakpoint)\n\n expr = breakpoint.expr\n return unless expr\n\n output.puts bold('Condition: ') + expr\n end", "def at_breakpoint(breakpoint)\n @pry ||...
[ "0.6343736", "0.6342272", "0.6135151", "0.5978265", "0.5975826", "0.59049606", "0.58666414", "0.54781944", "0.5375797", "0.53199506", "0.5250446", "0.52364224", "0.5160919", "0.5148373", "0.50811243", "0.5078002", "0.5035016", "0.49991992", "0.4967007", "0.4914151", "0.490665...
0.4518698
42
breakpoint.hit_condition > symbol Returns the hit condition of the breakpoint: +nil+ if it is an unconditional breakpoint, or :greater_or_equal, :equal, :modulo
def hit_condition() #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def at_breakpoint(breakpoint)\n @pry ||= Pry.new\n\n output.puts bold(\"\\n Breakpoint #{breakpoint.id}. \") + n_hits(breakpoint)\n\n expr = breakpoint.expr\n return unless expr\n\n output.puts bold(\"Condition: \") + expr\n end", "def at_breakpoint(_context, breakpoint)\n @pry ...
[ "0.65352756", "0.6514767", "0.6458988", "0.5585574", "0.5547592", "0.54225415", "0.537794", "0.5352983", "0.53435326", "0.5325748", "0.5325748", "0.5314808", "0.53116083", "0.5271799", "0.5253159", "0.52375305", "0.5230157", "0.5230157", "0.5230157", "0.5215123", "0.52122414"...
0.61762595
3
breakpoint.hit_condition = symbol Sets the hit condition of the breakpoint which must be one of the following values: +nil+ if it is an unconditional breakpoint, or :greater_or_equal(:ge), :equal(:eq), :modulo(:mod)
def hit_condition= symbol #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def at_breakpoint(breakpoint)\n @pry ||= Pry.new\n\n output.puts bold(\"\\n Breakpoint #{breakpoint.id}. \") + n_hits(breakpoint)\n\n expr = breakpoint.expr\n return unless expr\n\n output.puts bold(\"Condition: \") + expr\n end", "def at_breakpoint(_context, breakpoint)\n @pry ...
[ "0.70646346", "0.7031818", "0.6581376", "0.65412825", "0.61108035", "0.5783104", "0.56519616", "0.55837977", "0.5389279", "0.53603435", "0.53221023", "0.52690893", "0.51907635", "0.5189416", "0.5189416", "0.5184524", "0.5155536", "0.512498", "0.5091033", "0.50805616", "0.5073...
0.7109952
0
breakpoint.hit_count > int Returns the hit count of the breakpoint.
def hit_count() #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hit_count\n self[:hit_count] && self[:hit_count].to_i\n end", "def hit_count\n item_hash.deep_find(:hit_count, 0)\n end", "def hit_count_increament\n self.hit_count = self.hit_count + 1\n self.update\n end", "def num_hits; @hits.size; end", "def num_hits; @hits.size; ...
[ "0.77391016", "0.69725823", "0.653472", "0.6135756", "0.6135756", "0.6135756", "0.6075219", "0.6005014", "0.5868335", "0.583589", "0.5815476", "0.5736305", "0.56796646", "0.56718105", "0.5655607", "0.5600057", "0.55880976", "0.55845207", "0.5541998", "0.5528223", "0.55129576"...
0.72230375
1
breakpoint.hit_value > int Returns the hit value of the breakpoint.
def hit_value() #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hit_value= int\n #This is a stub, used for indexing\n end", "def native_hit\n 95\n end", "def hit_count\n self[:hit_count] && self[:hit_count].to_i\n end", "def hit\n malus_hit = has2w ? CPanel::TWHIT : 0\n [super - malus_hit, 0].max\n end", "def should_hit?\n...
[ "0.6995996", "0.6346121", "0.6185641", "0.5980916", "0.5891098", "0.5760935", "0.5760935", "0.56833166", "0.55650693", "0.55058306", "0.5492335", "0.54455924", "0.5442931", "0.54348075", "0.5426388", "0.5421468", "0.5396576", "0.5396576", "0.5396576", "0.5391494", "0.5367503"...
0.6643117
1
breakpoint.hit_value = int Sets the hit value of the breakpoint.
def hit_value= int #This is a stub, used for indexing end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hit_value()\n #This is a stub, used for indexing\n end", "def hit_id=(value)\n @hit_id = value\n end", "def trigger_breakpoint\n local_var = 6 * 7\n local_var\n end", "def receive_damage\n @hit_points-= 10\n end", "def white_hits=(hits)\n ...
[ "0.6196517", "0.59898365", "0.5663979", "0.56413996", "0.5607882", "0.55528563", "0.55480903", "0.5525361", "0.55206543", "0.54973465", "0.54973465", "0.54681706", "0.5415442", "0.53903043", "0.53068984", "0.5277721", "0.52742463", "0.5254985", "0.52476543", "0.52073383", "0....
0.70791703
0