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
Check session expiration date
def fresh?( ses_obj ) return true if ses_obj['expire'] == 0 now = Time.now ses_obj['expire'] >= now end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def session_expired?\n ! (Time.now < session[:expire_at])\n end", "def session_valid?\n @session_expiry_time > Time.now if @session_expiry_time\n end", "def session_valid?\n @session_expiry_time > Time.now if @session_expiry_time\n end", "def session_expired?\n if session[:last_aut...
[ "0.8122333", "0.8054441", "0.7965012", "0.7849204", "0.7798527", "0.7768935", "0.77251244", "0.7589307", "0.757776", "0.757286", "0.7566193", "0.75636715", "0.7481382", "0.7469987", "0.7342385", "0.72825533", "0.72720116", "0.72573155", "0.72456646", "0.7242692", "0.7237066",...
0.6762989
88
Clean out all expired sessions
def clean_expired! sessions.remove( { :expire => { '$lt' => Time.now } } ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup\n @sessions.each_value do |session|\n session.close if session.expired?\n end\n rescue => e\n log.error(\"Expired session cleanup failed: #{e}\")\n end", "def cleanup\n logger.info(\"Cleaning up expired sessions...\", :cleanup, { state: :starting...
[ "0.8176167", "0.8085375", "0.7972365", "0.77706915", "0.77485996", "0.77153325", "0.7592844", "0.7592844", "0.75311095", "0.74809927", "0.74503034", "0.74231356", "0.7334813", "0.73153824", "0.72658134", "0.723724", "0.7180697", "0.7180697", "0.7098137", "0.70691824", "0.7062...
0.8575099
0
parse server description string into host, port, db, cltn
def parse_server_desc( desc ) tokens = desc.split( "/" ) raise "Invalid server description" unless tokens.size == 3 server_desc = tokens[0].split( ":" ) raise "Invalid host:port description" unless server_desc.size == 2 return server_desc.first, server_desc.last.to_i, tokens[1], tokens[2] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_servers\n tuples = config.scan(SERVER_REGEXP)\n hsh = {}\n tuples.map do |(vrf, host, prefer, minpoll, maxpoll, sourcei, key)|\n hsh[host] = {\n vrf: vrf,\n prefer: !prefer.nil?,\n minpoll: minpoll.nil? ? nil : minpoll.to_i,\n maxp...
[ "0.62111753", "0.5973172", "0.5915546", "0.5800562", "0.5744312", "0.57415754", "0.57415754", "0.57277054", "0.568331", "0.5681982", "0.5641119", "0.5606183", "0.5606183", "0.55802464", "0.55693823", "0.55693823", "0.5562231", "0.5502871", "0.5486854", "0.5383189", "0.5377956...
0.76244825
0
Marshal session object BOZO !! Marshal will not dump valid strings for mongo using yaml instead
def serialize( ses ) YAML.dump( ses ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def marshal(session)\n data = [ Marshal.dump(session) ].pack('m').chop\n \"#{data}--#{generate_digest(data)}\"\n end", "def inspect\n \"#<Mongo::Session:0x#{object_id} session_id=#{session_id} options=#{@options}>\"\n end", "def marshal(session)\n data = Base64.encode64(Marshal.dump(session...
[ "0.6728865", "0.6316792", "0.6307911", "0.6299874", "0.62972796", "0.62523395", "0.61927164", "0.6173001", "0.61103636", "0.6015591", "0.6005223", "0.58515424", "0.584148", "0.5840802", "0.5785582", "0.57650965", "0.57336384", "0.57237434", "0.57171303", "0.5692215", "0.56781...
0.6432779
1
fetch session with optional session id
def _get_session(env, sid) logger.debug "Getting session info for #{sid.inspect}" if sid ses_obj = sessions.find_one( { :_id => sid } ) if ses_obj logger.debug "Found session object on #{sid.inspect}" else logger.debug "Unable to find session object #{sid.inspect}" end session = MongoRack::SessionHash.new( deserialize(ses_obj['data']) ) if ses_obj and fresh?( ses_obj ) end unless sid and session logger.warn "Session ID not found - #{sid.inspect} - Creating new session" session = MongoRack::SessionHash.new sid = generate_sid ret = sessions.save( { :_id => sid, :data => serialize(session) } ) raise "Session collision on '#{sid.inspect}'" unless ret end merged = MongoRack::SessionHash.new.merge(session) logger.debug "Setting old session #{merged.inspect}" session.instance_variable_set( '@old', merged ) return [sid, session] rescue => boom logger.error "#{self} Hoy! something bad happened loading session data" logger.error $!.inspect boom.backtrace.each{ |l| logger.error l } return [ nil, MongoRack::SessionHash.new ] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_session(env, sid); end", "def get_with_session_login(path, session)\n get path, nil, {\"rack.session\" => {\"uid\" => session['uid']}}\n end", "def session_get(id)\n sessions.select {|s| s.SessionId().to_s == id.to_s}\n end", "def get_session(session_id)\n session = Se...
[ "0.76285726", "0.74759054", "0.73982865", "0.73835075", "0.73036724", "0.72952044", "0.7293632", "0.72405446", "0.71259445", "0.7094336", "0.7042687", "0.7030073", "0.7030073", "0.7008642", "0.6999981", "0.6956762", "0.6907797", "0.6907797", "0.688152", "0.6879003", "0.686274...
0.6767204
28
update session information with new settings
def _set_session(env, sid, new_session, options) logger.debug "Setting session #{new_session.inspect}" ses_obj = sessions.find_one( { :_id => sid } ) if ses_obj logger.debug "Found existing session for -- #{sid.inspect}" session = MongoRack::SessionHash.new( deserialize( ses_obj['data'] ) ) else logger.debug "Unable to find session for -- #{sid.inspect}" session = MongoRack::SessionHash.new end if options[:renew] or options[:drop] sessions.remove( { :_id => sid } ) return false if options[:drop] sid = generate_sid sessions.insert( {:_id => sid, :data => {} } ) end old_session = new_session.instance_variable_get('@old') || MongoRack::SessionHash.new logger.debug "Setting old session -- #{old_session.inspect}" merged = merge_sessions( sid, old_session, new_session, session ) expiry = options[:expire_after] expiry = expiry ? Time.now + options[:expire_after] : 0 # BOZO ! Use upserts here if minor changes ? logger.debug "Updating session -- #{merged.inspect}" sessions.save( { :_id => sid, :data => serialize( merged ), :expire => expiry } ) return sid rescue => boom logger.error "#{self} Hoy! Something went wrong. Unable to persist session." logger.error $!.inspect boom.backtrace.each{ |l| logger.error l } return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @session_info = args[:session_info] if args.key?(:session_info)\n end", "def update\n return if Settings.readonly \n\n respond_to do |format|\n if @session.update(session_params)\n format.html { redirect_to sessions_url, notice: 'Session was successfully up...
[ "0.7494976", "0.6977965", "0.69675374", "0.69411284", "0.68269837", "0.6774522", "0.6759715", "0.67245764", "0.671641", "0.67149985", "0.67124414", "0.66844946", "0.6641827", "0.65772057", "0.65444505", "0.65294164", "0.65285784", "0.6491644", "0.647826", "0.6371836", "0.6358...
0.6176481
33
merge old, new to current session state
def merge_sessions( sid, old_s, new_s, cur={} ) unless Hash === old_s and Hash === new_s logger.error 'Bad old or new sessions provided.' return cur end delete = old_s.keys - new_s.keys logger.info "//@#{sid}: delete #{delete*','}" if not delete.empty? delete.each{ |k| cur.delete(k) } update = new_s.keys.select do |k| logger.debug "Update #{k}-#{new_s[k] != old_s[k]}? #{new_s[k].inspect} - #{old_s[k].inspect}"; new_s[k] != old_s[k] end logger.info "//@#{sid}: update #{update*','}" if not update.empty? update.each{ |k| cur[k] = new_s[k] } cur end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_session_variables!; end", "def restore\n GLOBAL_HASH_TABLE[@session_id]\n end", "def store_merge_state; end", "def store_merge_state; end", "def restore\n return unless @session\n @data = @session.data\n end", "def update_copy_session\n @user = current_user\n ...
[ "0.6205462", "0.60833365", "0.60774887", "0.60774887", "0.6018721", "0.60031736", "0.59900403", "0.59900403", "0.59826654", "0.5953009", "0.5855512", "0.5820702", "0.58132696", "0.58038795", "0.57369757", "0.57249975", "0.57124716", "0.57119817", "0.57030267", "0.5684279", "0...
0.69177705
0
Set the log level
def set_log_level( level ) case level when :fatal ::Logger::FATAL when :error ::Logger::ERROR when :warn ::Logger::WARN when :info ::Logger::INFO when :debug ::Logger::DEBUG else ::Logger::INFO end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_level=(level); end", "def log_level=(value)\n logger.level = value\n end", "def log_level=(value)\n logger.level = value\n end", "def log_level=(value)\n logger.level = value\n end", "def level=(level)\n @level = level\n @log.level = @level\n end", "def log_le...
[ "0.86843663", "0.8623332", "0.8623332", "0.8622839", "0.8587217", "0.85355294", "0.8532065", "0.8525419", "0.84927607", "0.8450167", "0.82992613", "0.8293287", "0.8149891", "0.81405145", "0.8133903", "0.8133903", "0.8060652", "0.80339855", "0.800927", "0.7959342", "0.79509115...
0.79409564
22
Use callbacks to share common setup or constraints between actions.
def fights_params params.require(:fight).permit('opponent_1_name', 'opponent_1_strength', 'opponent_1_life', 'opponent_1_adv', 'opponent_2_name', 'opponent_2_strength', 'opponent_2_life', 'opponent_2_adv', 'opponent_3_name', 'opponent_3_strength', 'opponent_3_life', 'opponent_3_adv', 'opponent_4_name', 'opponent_4_strength', 'opponent_4_life', 'opponent_4_adv', 'opponent_5_name', 'opponent_5_strength', 'opponent_5_life', 'opponent_5_adv') 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.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", ...
0.0
-1
GET /auctions GET /auctions.json
def index @auctions = Auction.joins(:profile).filter(params.slice(:by_country, :by_city, :by_gender, :by_age_from, :by_age_to)).active.charitable_first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\t\t@auction_items = @auction.auction_items\n\t\trender json: @auction_items.as_json\n\tend", "def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end", "def index\n user_id = @user.id\n @auctions = Auction.where(\"seller_id = ?\", user_id)\n\...
[ "0.79955554", "0.78944343", "0.7664202", "0.7439421", "0.72564614", "0.7212158", "0.7060244", "0.7010294", "0.6995", "0.69549745", "0.68647814", "0.6830017", "0.6798124", "0.6765328", "0.6748584", "0.6702673", "0.66579986", "0.6636632", "0.6569685", "0.65559703", "0.65355676"...
0.0
-1
GET /auctions/1 GET /auctions/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n\t\t@auction_items = @auction.auction_items\n\t\trender json: @auction_items.as_json\n\tend", "def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end", "def show\n render json: @auction\n end", "def show\n\t\trender json: @auction_item.as_jso...
[ "0.77117133", "0.7681789", "0.75758666", "0.7447109", "0.7319728", "0.71859163", "0.7030111", "0.7006114", "0.6900339", "0.6871605", "0.6832682", "0.6764159", "0.6754685", "0.67412204", "0.6713402", "0.67072374", "0.67071885", "0.66385025", "0.65081954", "0.64939857", "0.6490...
0.0
-1
POST /auctions POST /auctions.json
def create if current_user.profile.auctions.active.present? redirect_to auctions_my_bids_path, notice: 'You already have active auction' end @auction = current_user.profile.auctions.build(auction_params) @timezone = current_user.profile.timezone @auction.timezone = @timezone respond_to do |format| if @auction.save format.html { redirect_to @auction.profile, notice: 'Auction was successfully created.' } format.json { render :show, status: :created, location: @auction } else format.html { render :new } format.json { render json: @auction.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @auction = Auction.new(auction_params)\n @auction.seller = @user\n\n if @auction.save\n render json: @auction, status: :created, location: seller_auction_url(@auction)\n else\n render json: @auction.errors, status: :unprocessable_entity\n end\n end", "def create\n @aucti...
[ "0.705162", "0.6969033", "0.69430554", "0.68395746", "0.6675049", "0.6672291", "0.66667366", "0.66174555", "0.6613381", "0.6499353", "0.6220726", "0.6215063", "0.6150765", "0.6138528", "0.61302626", "0.6108555", "0.6104963", "0.608045", "0.6069963", "0.60552746", "0.6037936",...
0.662467
7
PATCH/PUT /auctions/1 PATCH/PUT /auctions/1.json
def update @timezone = current_user.profile.timezone @auction.timezone = @timezone respond_to do |format| if @auction.update(auction_params) format.html { redirect_to @auction.profile, notice: 'Auction was successfully updated.' } format.json { render :show, status: :ok, location: @auction } else format.html { render :edit } format.json { render json: @auction.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @auction.update(auction_params)\n head :no_content\n else\n render json: @auction.errors, status: :unprocessable_entity\n end\n end", "def update\n @auction = Auction.find(params[:id])\n\n respond_to do |format|\n if @auction.update_attributes(params[:auction])\n ...
[ "0.74300045", "0.72069544", "0.7174258", "0.69386613", "0.6926642", "0.68586004", "0.68107283", "0.67690194", "0.65351576", "0.6524235", "0.64921916", "0.6472534", "0.64346886", "0.6425796", "0.6396136", "0.6392779", "0.6392779", "0.6392779", "0.6392779", "0.6331323", "0.6288...
0.0
-1
DELETE /auctions/1 DELETE /auctions/1.json
def destroy @auction.destroy respond_to do |format| format.html { redirect_to auctions_url, notice: 'Auction was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @auction.destroy\n respond_to do |format|\n format.html { redirect_to auctions_url, notice: 'Запись удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @auction = Auction.find(params[:auction_id])\n @bid = Bid.find(params[:id])\n @bid.destr...
[ "0.7688671", "0.76116264", "0.7596809", "0.7451117", "0.7380871", "0.7293882", "0.727182", "0.72403324", "0.7152989", "0.7033975", "0.69657266", "0.694764", "0.68632185", "0.68632185", "0.6774795", "0.6771635", "0.6771635", "0.6771635", "0.6771635", "0.6771635", "0.67710686",...
0.7585603
4
Use callbacks to share common setup or constraints between actions.
def set_auction @auction = Auction.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 auction_params params.require(:auction).permit(:aim, :rater_age_min, :rater_age_max, :rater_gender, :date_duration, :auction_end, :video_date_start, :bid_step, :start_bid, :video_preview, :charitable) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
Returns a service instance for the given service id
def service_instance(id) @@configuration_cache[id] or @@configuration_cache[id] = Psych.load_file("#{data_dir}/service/#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_service_by_id(id)\n if params[:id]\n Service.find(params[:id])\n else\n nil #todo error handling.\n end\n end", "def service(id)\n ss = services\n ss.keep_if {|s| s.id == id}.first unless ss.nil?\n end", "def find_service(id)\n self.class.get(\"/services/#{...
[ "0.8232609", "0.8001466", "0.798906", "0.74800235", "0.72416794", "0.71020395", "0.70208025", "0.6957702", "0.69028586", "0.67009765", "0.66773814", "0.663707", "0.66209364", "0.6619968", "0.65975714", "0.6573358", "0.652599", "0.652599", "0.65230924", "0.64800894", "0.647506...
0.6697947
10
Asserts that a file matches the pattern
def assert_match_in_file(pattern, file) File.file?(file) ? assert_match(pattern, File.read(file)) : assert_file_exists(file) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_match_in_file(pattern, file)\n assert File.exist?(file), \"File '#{file}' does not exist!\"\n assert_match pattern, File.read(file)\n end", "def assert_match_in_file(pattern, file)\n assert File.exist?(file), \"File '#{file}' does not exist!\"\n assert_match pattern, File.read(file)\n en...
[ "0.84720325", "0.84720325", "0.7726407", "0.71817625", "0.6976901", "0.6971162", "0.6956284", "0.6867407", "0.6860901", "0.67609847", "0.6753833", "0.67474234", "0.6743917", "0.67360705", "0.6718352", "0.6703183", "0.66835773", "0.66835034", "0.6605372", "0.6548858", "0.65231...
0.8460051
2
Helper methods Method to display a message with a 'Hash Rocket =>'
def say(msg) puts "=> #{msg}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def farewell_message\n puts \"\"\n puts \"Cheers! \\u{1f37b}\" # beer emoji 🍻\n end", "def foorth_message\r\n \"#{self.foorth_code} #{self.message}\"\r\n end", "def display\n\t\tr_str = \"Message: \"\n\t\t(@length / 5).times { |i| r_str += \"#{@string[(i * 5)...(i * 5) + 5]} \" }\n\t\tputs r_str\n\...
[ "0.67612046", "0.6542514", "0.63498914", "0.634817", "0.62878954", "0.62133276", "0.62074125", "0.6190394", "0.618903", "0.61204034", "0.61004496", "0.605202", "0.6015868", "0.6005052", "0.5968965", "0.59628934", "0.59625727", "0.59114516", "0.5895534", "0.5895534", "0.588788...
0.0
-1
Checks if the user wants to exit the calculator. 'Q' to exit
def exit?(ans) ans.upcase == 'Q' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exit?\n user_input == \"q\" || user_input == \"quit\"\n end", "def finished?\n input == 'q' || input =='quit'\n end", "def menu\n puts 'Welcome to the ruby calculator!'\n puts 'Press 1 to calculate or 2 to quit'\n case\n answer = gets.strip\n when '1'\n calculate\n when '2'\n ...
[ "0.764285", "0.72208023", "0.709679", "0.70717436", "0.68572444", "0.6807866", "0.6711127", "0.6701642", "0.6690668", "0.66805744", "0.6675273", "0.6673463", "0.6670867", "0.6656492", "0.66519773", "0.66414565", "0.6613275", "0.6612734", "0.66043913", "0.65856063", "0.6581397...
0.74919397
1
Check if the given string 'num' is a number. Adapted from
def numeric?(num) !!Float(num) rescue false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_num(str)\n\treturn true if str =~ /^\\d+$/\n true if Int(str) rescue false\nend", "def is_number?(str)\n true if Float(str) rescue false\n end", "def is_a_number?(str)\n str.match(/\\d/)\nend", "def is_number?(string)\n true if Integer(string) && Integer(string) >= 0 rescue false\n end", ...
[ "0.87244636", "0.81180733", "0.81120074", "0.80896354", "0.8079099", "0.8070914", "0.8004416", "0.8004416", "0.798755", "0.798755", "0.7983043", "0.7974296", "0.79679656", "0.7945104", "0.79128224", "0.7909083", "0.78987736", "0.78987736", "0.78788704", "0.7857445", "0.784994...
0.0
-1
Used to check the user input. Valid input is either "Q" or a number
def get_valid_input(input_type, options = {}) input = nil loop do input = gets.chomp # binding.pry if options.has_key?(:result) && input == "" input = options[:result] break else if input_type == "num" numeric?(input) || input.upcase == 'Q' ? break : say("Numbers only") else %w(1 2 3 4 Q).include?(input.upcase) ? break : say("1, 2, 3, or 4 only") end end end input end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def raw_input(msg)\n puts msg\n print \">> \"\n input = gets.chomp\n if input.downcase == \"q\"\n return input, true\n else\n return input, false\n end\nend", "def is_valid_input(input)\n if input == \"rock\" || input == \"paper\" || input == \"scissors\" || input == \"lizard\" || input == \"s...
[ "0.67483205", "0.66702497", "0.6666446", "0.6628097", "0.65997636", "0.6598698", "0.65643185", "0.65577036", "0.6516444", "0.6484169", "0.6446423", "0.6444627", "0.638054", "0.63550824", "0.6346796", "0.6342883", "0.6334482", "0.6298292", "0.6283001", "0.62807816", "0.6279113...
0.73210204
0
Displays the result of the operation performed on the two numbers
def display_result(num1, num2, operator) # say "num1: #{num1}, num2: #{num2}, operator #{operator}" case operator when '1' result = num1.to_i + num2.to_i say "#{num1} + #{num2} = #{result}" when '2' result = num1.to_i - num2.to_i say "#{num1} - #{num2} = #{result}" when '3' begin result = num1.to_f / num2.to_f say "#{num1} / #{num2} = #{result}" rescue say("Div by 0") end else result = num1.to_i * num2.to_i say "#{num1} * #{num2} = #{result}" end result.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_results(num_1, num_2)\n puts \"addition #{num_1 + num_2}\"\n puts \"subtraction #{num_1 - num_2}\"\n puts \"product #{num_1 * num_2}\"\n puts \"remainder #{num_1 % num_2}\"\n puts \"quotient #{num_1 / num_2}\"\n puts \"power #{num_1 ** num_2}\"\n\nend", "def calculator(a,b)\n puts \"The sub ...
[ "0.72165275", "0.69052255", "0.6869239", "0.6859879", "0.6838141", "0.6747097", "0.6725214", "0.6724019", "0.66996586", "0.66837806", "0.6667593", "0.66484004", "0.66381717", "0.6631098", "0.6621911", "0.6606983", "0.6598752", "0.6594458", "0.65312785", "0.65121955", "0.65022...
0.73220927
0
creates security_group and authorizes default port ranges
def create_security_group(name, vpc_id) sg = ec2.create_security_group({ group_name: name, description: "Kontena Grid", vpc_id: vpc_id }) sg.authorize_ingress({ # SSH ip_protocol: 'tcp', from_port: 22, to_port: 22, cidr_ip: '0.0.0.0/0' }) sg.authorize_ingress({ # HTTP ip_protocol: 'tcp', from_port: 80, to_port: 80, cidr_ip: '0.0.0.0/0' }) sg.authorize_ingress({ # HTTPS ip_protocol: 'tcp', from_port: 443, to_port: 443, cidr_ip: '0.0.0.0/0' }) sg.authorize_ingress({ # OpenVPN ip_protocol: 'udp', from_port: 1194, to_port: 1194, cidr_ip: '0.0.0.0/0' }) sg.authorize_ingress({ # Overlay / Weave network ip_permissions: [ { from_port: 6783, to_port: 6783, ip_protocol: 'tcp', user_id_group_pairs: [ { group_id: sg.group_id, vpc_id: vpc_id } ] }, { from_port: 6783, to_port: 6784, ip_protocol: 'udp', user_id_group_pairs: [ { group_id: sg.group_id, vpc_id: vpc_id } ] } ] }) sg end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_security_group_prepared\n provider.create_security_group(system_config.security_group, required_public_ports)\n end", "def adjust_security_groups\n\n all_regions.each do |region|\n c = connection(region)\n g = c.security_groups.get(primary_group)\n \n g.authori...
[ "0.6960418", "0.68461275", "0.67666686", "0.6735143", "0.672424", "0.66636515", "0.6518181", "0.6365194", "0.6365194", "0.63321275", "0.62130576", "0.61536574", "0.6109729", "0.59928954", "0.59671044", "0.5956372", "0.59492046", "0.59347475", "0.5888241", "0.58338535", "0.583...
0.64533263
7
TODO: only allow destroy if not used on any closed invoices
def destroy destroy! do |format| format.html{ redirect_to @awarded_promotion.get_redirect_to_url(self) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @invoice.destroy\n end", "def destroy\n @invoice = current_organization.invoices.find(params[:id])\n @invoice.destroy\n \n redirect_to(invoices_url)\n end", "def destroy\n if @invoice.status == 'fresh'\n @invoice.destroy\n respond_to do |format|\n format.html ...
[ "0.69884855", "0.6904366", "0.6831483", "0.68082774", "0.6807483", "0.677839", "0.67658603", "0.66700685", "0.66537064", "0.66427433", "0.65971416", "0.65868616", "0.6534544", "0.6530909", "0.65227056", "0.65227056", "0.65227056", "0.65227056", "0.6503409", "0.6502425", "0.65...
0.0
-1
PUT /resource We need to use a copy of the resource because we don't want to change the current user in place.
def update params[:user][:role_ids] ||= [] self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) if resource.update_with_password(params[resource_name]) if is_navigational_format? if resource.respond_to?(:pending_reconfirmation?) && resource.pending_reconfirmation? flash_key = :update_needs_confirmation end set_flash_message :notice, flash_key || :updated end sign_in resource_name, resource, :bypass => true respond_with resource, :location => after_update_path_for(resource) else clean_up_passwords resource respond_with resource end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://...
[ "0.7224541", "0.700414", "0.6980963", "0.6971368", "0.6954467", "0.69530743", "0.6754272", "0.6744999", "0.67417157", "0.67165345", "0.67165345", "0.6707067", "0.6707067", "0.6707067", "0.6707067", "0.6707067", "0.6707067", "0.6707067", "0.6707067", "0.6703914", "0.6699215", ...
0.0
-1
serialize the hash into json and save in a cookie add to the responses cookies
def store_session(res) cookie = WEBrick::Cookie.new('_rails_lite_app', @cookie.to_json) res.cookies << cookie end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cookie_hash\n\t\t\t{ 'Cookie' => @cookies.to_s }\n\t\tend", "def store_session(res)\n res.cookies << WEBrick::Cookie.new('_rails_lite_app', @hash.to_json)\n end", "def serialize_into_cookie(record); end", "def encode_to_cookie h, cookie\n cookie[@name] = encode h\n end", "def serialize_...
[ "0.7232483", "0.7079436", "0.70458454", "0.69088364", "0.67860115", "0.6538753", "0.6516383", "0.64779174", "0.6469998", "0.643302", "0.6402495", "0.6361502", "0.636", "0.6339202", "0.63323885", "0.6327872", "0.63275915", "0.629749", "0.62952596", "0.6291643", "0.6252314", ...
0.63407034
13
d1p2.rb This is my implementation for Advent of Code: Day 1 (part 2) (See: function to find matches from arr[i] and arr[i + offset] and return the sum of their numbers
def captchaTwo(array) result = 0 offset = (array.length / 2) for i in 0...(array.length) if array[i] == array[(i + offset) % array.length] result += array[i] end end return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two_sum(numbers, target)\n arr = numbers\n num = target\n index_array = []\n return_array = []\n current_index = 0\n\n loop do\n idx_counter = current_index\n current_element = arr[current_index]\n\n loop do\n break if idx_counter >= arr.length - 1\n next_index = idx_counter + 1\n ...
[ "0.69249415", "0.6826382", "0.6722587", "0.66272825", "0.65868217", "0.658194", "0.6562062", "0.64947915", "0.6480071", "0.6478007", "0.64542824", "0.6444382", "0.6416029", "0.641552", "0.6390692", "0.6314885", "0.6311496", "0.62951857", "0.6284888", "0.62824893", "0.6280062"...
0.0
-1
function to format and get input from argv
def getInput(array) if ARGV[0] == nil puts "Bad input" exit end # input is one string, read it in by char, convert to int, and store in # array, element-by-element ARGV[0].each_byte do |c| array << c.chr.to_i end # puts array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_input \n puts \"to save this game, input 's,filename'\"\n puts \"to load a game, input 'l,filename'\"\n puts \"input a coordinate to access. prefix with r for reveal or f for flag\"\n puts \"example 'f,1,2' places a flag at 1,2\"\n input = gets.chomp\n \n args = input.split(',')\n end...
[ "0.69742966", "0.63995683", "0.63152295", "0.6279123", "0.62648135", "0.6214056", "0.61848414", "0.617962", "0.6157279", "0.6141151", "0.61213", "0.609808", "0.6037148", "0.60286355", "0.5957596", "0.59459776", "0.5942399", "0.5937082", "0.5936803", "0.5915276", "0.59096396",...
0.5605749
64
DELETE /psychologies/1 DELETE /psychologies/1.xml
def destroy @psychology = Psychology.find(params[:id]) @psychology.destroy respond_to do |format| format.html { redirect_to(psychologies_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n \n @ontology = SYMPH::Ontology.find(params[:id])\n @ontology.disable\n @ontology.destroy\n \n respond_to do |format|\n format.html { redirect_to :action => :index }\n format.xml { head :ok }\n end\n end", "def remove_configuration_product\r\n # node = ProductPac...
[ "0.61582494", "0.6086254", "0.6056867", "0.59706193", "0.5956572", "0.5942821", "0.5926905", "0.5917924", "0.5891654", "0.5885887", "0.58780557", "0.5869463", "0.5869463", "0.58542603", "0.5851631", "0.5842676", "0.5840533", "0.5837158", "0.58360296", "0.58262134", "0.5807316...
0.7391541
0
com passagem de parametros
def meu_metodo(parametro, parametro1 = 0) #quando o parametro for opcional pode se atribuir um valor padrão como 0 puts "meu metodo foi executado. parametros #{parametro} #{parametro1}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def parameters; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params...
[ "0.744041", "0.744041", "0.744041", "0.744041", "0.744041", "0.744041", "0.744041", "0.744041", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.7339775", "0.733977...
0.613312
65
string The String to be checked letter The String to be checked for. Examples index_of_char("Hello", "o") => "4" Returns the index or nil if not found.
def index_of_char(string, letter) i = 0 while i < string.length if string[i] == letter return i end i += 1 end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_of_char(string, character)\n i = 0\n position = nil\n while i < string.length\n if string[i] == character\n position = i\n break\n else\n i += 1\n end\n end\n return position\nend", "def index_of_char(str, char)\n i = 0\n while ...
[ "0.7835206", "0.76471406", "0.7409047", "0.709801", "0.70619327", "0.7061357", "0.70180374", "0.6688983", "0.66763335", "0.66719484", "0.6631625", "0.6607552", "0.6589543", "0.65614766", "0.65571266", "0.6525291", "0.64588773", "0.6450701", "0.6373768", "0.6306992", "0.624209...
0.78389734
0
Require token at instantiation
def initialize(key) @key = key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_tokens\n @tokens_required = true\n end", "def initialize(token)\n @token = token.freeze\n end", "def initialize(token)\n @token = token\n end", "def initialize(token)\n @token = token\n end", "def initialize(token)\n #accepts a token to assign\n @token = token\n e...
[ "0.73096997", "0.7015049", "0.6930624", "0.6930624", "0.68641126", "0.68243986", "0.6808781", "0.67778265", "0.6774474", "0.6774474", "0.6658329", "0.6621834", "0.65471387", "0.6446971", "0.6446971", "0.6446971", "0.6446971", "0.6446971", "0.6446971", "0.6394099", "0.6353075"...
0.0
-1
Assemble data for request
def get_data(event, data={}) self['event'] = event self['properties'] = data self['properties']['token'] = @key self['properties']['time'] = Time.now.to_i Base64.encode64(JSON.generate(self)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_data; end", "def request_data\n data = {}\n data[:user_agent] = request.user_agent\n data[:referrer] = request.referrer\n data[:remote_ip] = request.remote_ip\n data\n end", "def assemble_request_body data\n request = { :purlPath => data.purl_path, :type => data.redirect_type,...
[ "0.7092065", "0.6568239", "0.649822", "0.6420911", "0.63801426", "0.62743175", "0.62548745", "0.61686534", "0.6167868", "0.61437047", "0.6139553", "0.6136649", "0.612223", "0.61041224", "0.6095108", "0.60523427", "0.6050128", "0.60491115", "0.60350645", "0.6016136", "0.601113...
0.0
-1
Get data and make HTTP request
def track(event, data={}) params = self.get_data(event, data) r = self.conn.get '/track', {:data => params} r.body.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_request()\n uri = URI.parse(API_BASE_URL + build_request_path())\n response = Net::HTTP.get_response(uri)\n response.body\n end", "def do_get\n Net::HTTP.get(URI.parse(api_url))\n end", "def request_data(request_url)\n\n uri = URI.parse(request_url)\n response = Net::HTTP.get...
[ "0.7289908", "0.7190825", "0.71753836", "0.71177435", "0.70374656", "0.6984405", "0.68778366", "0.6828046", "0.6789741", "0.6789196", "0.6778939", "0.6769434", "0.6759759", "0.6752113", "0.6720222", "0.66766727", "0.664878", "0.6639942", "0.6602201", "0.6599905", "0.6586025",...
0.0
-1
check if any of its tasks is not completed
def not_completed? tasks.any? { |task| task.done != 100 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tasks_remain?\n\t\ttasks.any?{ |t| t.completed.nil? }\n\tend", "def incomplete_tasks\n\t\ttasks.select{ |t| !t.completed? }\n\tend", "def ignore_complete?(task)\n !get_result(task).nil?\n end", "def empty?; tasks.empty? end", "def all_complete\n self.tasks.count == self.tasks.done.count\n end",...
[ "0.7589577", "0.7548989", "0.75104195", "0.7493704", "0.7404067", "0.7304864", "0.70360976", "0.70122945", "0.6991329", "0.6991329", "0.68446267", "0.6811772", "0.6742053", "0.6736515", "0.6727335", "0.67162865", "0.6677665", "0.66746724", "0.6668764", "0.6649169", "0.6611977...
0.794058
0
space complexity is O(1) b/c the storage does not increase based on the size of the input
def reverse_sentence(my_sentence) if my_sentence == nil || my_sentence.empty? return my_sentence end i = 0 j = 0 temp = [] until i == my_sentence.length until my_sentence[j] == " " && my_sentence[j + 1] != " " || my_sentence[j] != " " && my_sentence[j + 1] == " " || j == my_sentence.length - 1 j += 1 end temp << my_sentence[i..j] j += 1 i = j end total_index = my_sentence.length temp.each do |capture| total_index = total_index - capture.length my_sentence[total_index..(total_index + capture.length - 1)] = capture end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size(input); end", "def findlargestdrop(arr)\n\n\n\nend", "def find_dublicate(array)\n sum = 1000000*(1000000+1)/2 # (n*(n+1))/2\n array.each do |el| \n sum -= el\n end\n return sum\nend", "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t ...
[ "0.610956", "0.5955452", "0.5855595", "0.57886446", "0.5786059", "0.57112885", "0.56840974", "0.56586796", "0.56450695", "0.5632296", "0.5598963", "0.5594605", "0.55914265", "0.55795634", "0.5574874", "0.5558279", "0.5556949", "0.55156344", "0.550784", "0.5486466", "0.5474748...
0.0
-1
Get list of records for a given model class.
def get_list_of_records(klass, options = {}, &block) items = klass.name.tableize self.current_page = options[:page] if options[:page] query = options[:query] if options[:query] category = options[:category] if options[:category] pagination = options[:pagination].nil? ? true : options[:pagination] date = options[:date] if options[:date] #date_range = options[:date_range] if options[:date_range] start_date = options[:start_date] if options[:start_date] end_date = options[:end_date] if options[:end_date] sort_fields = options[:sort] if options[:sort] sort_dir = options[:dir] || "ASC" per_page = options[:per_page] if options[:per_page] #self.current_query = options records = { :user => @current_user #, # :order => @current_user.pref[:"#{items}_sort_by"] || klass.sort_by } # Use default processing if no hooks are present. Note that comma-delimited # export includes deleted records, and the pagination is enabled only for # plain HTTP, Ajax and XML API requests. wants = request.format filter = session[options[:filter]].to_s.split(',') if options[:filter] scope = klass.scoped scope = scope.category(category) if category.present? scope = scope.state(filter) if filter.present? scope = scope.search(query) if query.present? scope = scope.at_date(date) if date.present? #scope = scope.between_dates(date_range) if date_range.present? scope = scope.between_dates(start_date, end_date) if (start_date.present? && end_date.present?) if sort_fields.present? words = sort_fields.split(".") if words.length > 1 table = words.shift.tableize # popup first item field = words.join(".") sort_fields2 = "#{table}.#{field}" else sort_fields2 = "#{items}.#{words.first}" end scope = scope.order_by(sort_fields2, sort_dir) end scope = yield scope if block_given? scope = scope.unscoped if wants.csv? scope = scope.page(current_page).per(per_page) scope end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def records(_options = {})\n if defined?(_resource_klass.records)\n _resource_klass.records(_options)\n else\n _resource_klass._model_class.all\n end\n end", "def records_base(_options = {})\n _model_class.all\n end", "def records\n arr = @klass.all(find_options)\...
[ "0.7259449", "0.72117144", "0.7181429", "0.6925908", "0.6874491", "0.6479553", "0.64787513", "0.6426368", "0.6415522", "0.64123756", "0.63960654", "0.6394551", "0.63728976", "0.6365377", "0.6337952", "0.6334368", "0.6272345", "0.61693656", "0.6123235", "0.6117369", "0.611144"...
0.59760606
31
Proxy current page for any of the controllers by storing it in a session.
def current_page=(page) @current_page = session["#{controller_name}_current_page".to_sym] = page.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n session[:return_to] = request.url\n super\n end", "def index\r\n # State machine stuff\r\n current_user.came_home\r\n eval current_user.redirect, binding()\r\n return\r\n end", "def set_current_path\n case params.values_at(:controller, :action).join('/')\n when 'se...
[ "0.63160235", "0.623", "0.6068191", "0.606676", "0.6030942", "0.5964684", "0.59170735", "0.5851382", "0.5844857", "0.58415294", "0.58362776", "0.5808995", "0.5808995", "0.5808995", "0.5808995", "0.5808995", "0.5808995", "0.5808995", "0.5808995", "0.5808995", "0.5808995", "0...
0.6015731
5
Proxy current search query for any of the controllers by storing it in a session.
def current_query=(query) @current_query = session[:advanced_query] = query end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_session\n session[:search] ||= {}\n end", "def perform_search\n if self.class == Alchemy::Admin::PagesController && params[:query].blank?\n params[:query] = 'lorem'\n end\n return if params[:query].blank?\n @search_results = search_results\n if paginate_...
[ "0.66462785", "0.6454236", "0.6440791", "0.6408878", "0.63576627", "0.62517464", "0.61903757", "0.61287576", "0.61168456", "0.60714304", "0.606207", "0.6042536", "0.6034373", "0.6015495", "0.5995451", "0.5992801", "0.598637", "0.5981894", "0.5942771", "0.59143424", "0.5872925...
0.0
-1
method to define all printable menu items
def define_menu_items add_menu_item("Weekly worktime.", 1) add_menu_item("Monthly worktime.", 2) add_menu_item("Custom worktime interval.", 3) add_menu_item("Cancel and return to previous menu.", 4) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_menu_items\n check_attributes\n @menu_description.concat(\"\\n #{set_boundaries}\")\n add_menu_item(\"All tasks to a person in the given #{time_string}.\", 1)\n add_menu_item(\"Worktime of a person in that #{time_string}.\", 2)\n add_menu_item(\"All tasks running durin...
[ "0.7533588", "0.7339405", "0.72757214", "0.72261703", "0.7217888", "0.7196568", "0.7135591", "0.7123347", "0.7101928", "0.7101928", "0.70330614", "0.70162296", "0.6995714", "0.69668365", "0.6911753", "0.68937", "0.68584585", "0.68399435", "0.6831014", "0.678548", "0.6774596",...
0.6971963
13
method to process the provided input
def determine_action(input) case (input.to_i) when 1 then TimeMenu::WeektimeMenu.new.print_menu when 2 then TimeMenu::MonthtimeMenu.new.print_menu when 3 then TimeMenu::CustomtimeMenu.new.print_menu when 4 then return false else handle_wrong_option end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(input)\n process(input)\n end", "def preprocess_input(input)\nend", "def call(input)\r\n process(*input)\r\n end", "def preprocess(input); end", "def preprocess_input(input)\n input\nend", "def process(input)\n\t\tr = processString(input) if input.is_a?(String)\n\t\tr = proc...
[ "0.755243", "0.75354415", "0.7515326", "0.7389755", "0.72351545", "0.7180728", "0.7153225", "0.70450014", "0.7027385", "0.7027385", "0.7027385", "0.6989074", "0.6931572", "0.6921981", "0.68323624", "0.68323624", "0.6760511", "0.6726066", "0.66878957", "0.6669344", "0.66663736...
0.0
-1
List all cookbooks user has access to.
def index @page_title = "Welcome, #{current_user.first_name}! Let's Get Cooking..." @info_panel_title = "Membership info" @user = current_user @cookbooks = @user.owned_cookbooks @contributed_cookbooks = @user.contributed_cookbooks @completed_orders = @user.completed_orders end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @cookbooks = Cookbook.all\n end", "def index\n @cook_books = CookBook.all\n end", "def index\n @books = current_user.books.all\n end", "def index\n @cooks = Cook.includes(:user)\n end", "def index\n @cookbooks = CookbooksDecorator.decorate_collection(Cookbook.all)\n end", ...
[ "0.6798504", "0.66155815", "0.65833116", "0.6545027", "0.65061873", "0.6465697", "0.6434549", "0.6430269", "0.6372158", "0.62748116", "0.62626386", "0.620772", "0.6165968", "0.6126005", "0.61235654", "0.61105585", "0.607098", "0.60628957", "0.6047489", "0.6027409", "0.6008459...
0.0
-1
Select a cookbook to work on. Alert the user if the cookbook owner account has expired.
def select @cookbook = Cookbook.find params[:id] user_is_owner = current_user.owns_cookbook(@cookbook) user_is_contributor = current_user.contributes_to(@cookbook) # Verify the user is authorized to work on this cookbook. if @cookbook && (user_is_owner || user_is_contributor) # User must have a paid account to work on its cookbooks # (Contributor wasn't allowed to create cookbooks but due to a bug some contributors may have cookbooks to works on) if has_contributor_plan? && user_is_owner redirect_to upgrade_account_path(current_user.id), alert: "You must have a paid membership to work on your own cookbooks" return end load_user_cookbook @cookbook # Alert the user it will not be able to work on this cookbook if its owner has expired. if current_cookbook.owner.expired? if user_is_owner flash[:alert] = "Because your membership has expired you can no longer work on your cookbooks." elsif user_is_contributor flash[:alert] = "The owner of this cookbook's membership has expired. They will have to extend it for you to gain access to this cookbook." end end redirect_to templates_path else redirect_to cookbooks_path, alert: "Unable to select cookbook. Either it doesn't exist or you have no permission accessing it." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cookbook_selected?\n if !current_cookbook\n redirect_to cookbooks_path, alert: \"You must have selected a Cookbook project to work on first.\"\n end\n end", "def account_expired?\n if current_user.expired? && current_user.owns_cookbook(current_cookbook)\n redirect_to upgrade_account_path(...
[ "0.6314082", "0.573691", "0.5581856", "0.5515331", "0.54199946", "0.5390674", "0.5250885", "0.51905346", "0.51675564", "0.51355153", "0.51146585", "0.51081425", "0.5051597", "0.50263315", "0.4994299", "0.4979852", "0.49525097", "0.49263906", "0.49219006", "0.49213073", "0.491...
0.7531907
0
Create a new cookbook. The cookbook is created automatically and assigned as the current cookbook.
def new cookbook_id = current_user.create_cookbook if cookbook_id @cookbook = Cookbook.find cookbook_id load_user_cookbook @cookbook redirect_to templates_path, notice: "A new cookbook was created for you." else redirect_to upgrade_account_path(current_user.id), alert: "You must have a paid membership to work on your own cookbooks" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_cookbook(cookbook)\n berksfile = Berkshelf::Berksfile.from_file(File.join(cookbook[:path], \"Berksfile\"))\n berksfile.vendor(\"berks-cookbooks\")\n\n File.open(\"berks-cookbooks/Berksfile\", 'w') { |file|\n file.write(\"source \\\"https://supermarket.chef.io\\\"\\n\\n\")\n f...
[ "0.70700115", "0.70054996", "0.6918313", "0.68459415", "0.6825474", "0.6716979", "0.67027557", "0.66202694", "0.6540583", "0.65399444", "0.65264964", "0.64844555", "0.6471256", "0.6381962", "0.63623846", "0.6323584", "0.63169324", "0.6266003", "0.62150544", "0.62010705", "0.6...
0.68842936
3
Edit the cookbook informations Respond with a content type of plain/text to support IE and Opera see:
def edit @cookbook = current_cookbook end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @cookbook.update(cookbook_params)\n format.html { redirect_to cookbook_path(@cookbook), notice: 'Cookbook was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { ...
[ "0.59516615", "0.59106183", "0.5907394", "0.57482374", "0.5710021", "0.567092", "0.56481665", "0.56384623", "0.563044", "0.5624531", "0.5585982", "0.55820984", "0.557699", "0.55722475", "0.5553311", "0.55373937", "0.5483171", "0.54820913", "0.547613", "0.547613", "0.54696006"...
0.0
-1
Update the cookbook attributes.
def update @cookbook = current_cookbook # Process Paperclip attachments @cookbook.process_attachments(params) if @cookbook.update_attributes_individually params[:cookbook] flash[:notice] = 'The template was updated.' end respond_to do |format| format.js { render :update, content_type: "text/plain" } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_cookbook_attribute\n run_context.cookbook_collection.each do |cookbook_name, cookbook|\n automatic_attrs[:cookbooks][cookbook_name][:version] = cookbook.version\n end\n end", "def update_appd_cookbook\n @ssh.exec! \"cd #{APPD_COOKBOOK_PATH}; git pull origin master\", sudo: true...
[ "0.6996817", "0.639421", "0.6291651", "0.60460126", "0.6008001", "0.5998508", "0.5947056", "0.5924024", "0.59169406", "0.5898999", "0.58650047", "0.5859821", "0.58571523", "0.58571523", "0.5847785", "0.5847785", "0.5847785", "0.5847785", "0.5840827", "0.58240795", "0.5801777"...
0.54358226
91
Edit the cookbook title.
def edit_title @cookbook = current_cookbook end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_title\n @cookbook = current_cookbook\n @cookbook.title = params[:cookbook][:title]\n if @cookbook.save\n redirect_to templates_path, notice: \"Your Cookbook name has been changed!\"\n else\n render :edit_title\n end\n end", "def ctitle(title)\n self.title = title\n en...
[ "0.80122495", "0.72350585", "0.713863", "0.70878845", "0.70584404", "0.7019702", "0.6919573", "0.6919573", "0.6901882", "0.6879555", "0.68733776", "0.68733776", "0.68733776", "0.68733776", "0.68733776", "0.68733776", "0.68733776", "0.68733776", "0.68733776", "0.6863989", "0.6...
0.8330037
0
Update the cookbook title
def update_title @cookbook = current_cookbook @cookbook.title = params[:cookbook][:title] if @cookbook.save redirect_to templates_path, notice: "Your Cookbook name has been changed!" else render :edit_title end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_title\n @cookbook = current_cookbook\n end", "def ctitle(title)\n self.title = title\n end", "def title=(title)\n @attributes.occi!.core!.title = title\n end", "def update_window_title(new_title)\n hc_main_view.title = new_title\n end", "def title=(v)\n if @title != ...
[ "0.77194446", "0.7060066", "0.69450605", "0.6818465", "0.6657042", "0.66266453", "0.6600145", "0.6594344", "0.6585583", "0.65775865", "0.6567257", "0.6566344", "0.6553564", "0.6546017", "0.65452695", "0.65447783", "0.65447783", "0.65447783", "0.65447783", "0.65447783", "0.654...
0.7828986
0
Edit the cookbook introduction
def edit_introduction @cookbook = current_cookbook end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_introduction\n @cookbook = current_cookbook\n\n # Process Paperclip attachments\n @cookbook.process_attachments(params)\n\n if params[:cookbook]\n @cookbook.intro_type = params[:cookbook][:intro_type] if params[:cookbook][:intro_type]\n @cookbook.center_introduction = params[:cookb...
[ "0.6936561", "0.67870855", "0.6385627", "0.6292402", "0.6228709", "0.6201686", "0.6119712", "0.61154443", "0.6063954", "0.60586244", "0.6041879", "0.6041879", "0.60394824", "0.5984697", "0.59635437", "0.59521246", "0.59503376", "0.58997184", "0.5824278", "0.5823441", "0.58144...
0.79031426
0
Update introduction elements Respond with a content type of plain/text to support IE and Opera see:
def update_introduction @cookbook = current_cookbook # Process Paperclip attachments @cookbook.process_attachments(params) if params[:cookbook] @cookbook.intro_type = params[:cookbook][:intro_type] if params[:cookbook][:intro_type] @cookbook.center_introduction = params[:cookbook][:center_introduction] if params[:cookbook][:center_introduction] @cookbook.intro_text = params[:cookbook][:intro_text] if params[:cookbook][:intro_text] @cookbook.intro_image_grayscale = params[:cookbook][:intro_image_grayscale] if params[:cookbook][:intro_image_grayscale] @cookbook.intro_image = params[:cookbook][:intro_image] if !params[:cookbook][:intro_image].nil? # If the user has checked the "Do not include this page" checkbox, set the intro_type do '2' @cookbook.intro_type = 2 if params[:do_not_include] @cookbook.intro_type = 0 if !params[:do_not_include] && @cookbook.intro_type == 2 end if @cookbook.save flash[:notice] = 'The introduction of your cookbook was saved.' end respond_to do |format| format.js { render :update_introduction, content_type: "text/plain" } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def introduction\r\n\r\n end", "def content_for_intro(interpret=true)\n if interpret\n render_for_html(body.paragraphs[0])\n else\n body.paragraphs[0]\n end\n end", "def update\n respond_to do |format|\n if @intro.update(intro_params)\n format.html { redirect_to @intro, notic...
[ "0.6250985", "0.61511034", "0.59314656", "0.5552826", "0.5540283", "0.5529689", "0.55242527", "0.5460215", "0.5401076", "0.5359251", "0.53455067", "0.5310336", "0.53064615", "0.5302194", "0.5291925", "0.52763087", "0.5234108", "0.5215682", "0.52042013", "0.52030325", "0.51799...
0.6728914
0
Display the cookbook price
def check_price @num_cookbooks = (params[:num_cookbooks] && params[:num_cookbooks].to_i > 3) ? params[:num_cookbooks].to_i : 4 ccc = CookbookCostCalculator.new( num_bw_pages: current_cookbook.num_bw_pages, num_color_pages: current_cookbook.num_color_pages, num_books: @num_cookbooks, binding: current_cookbook.book_binding.to_sym ) @cookbook = current_cookbook @printing_cost = ccc.printing_cost || "Unknown" @cost_per_book = (@printing_cost != "Unknown") ? (@printing_cost.to_f / @num_cookbooks).round(2) : "Unknown" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_price(options = {})\n price_unpacked.to_s + '€ per piece, ' + price_packed.to_s + '€ per box'\n end", "def display_price\n Spree::Money.new(new_amount, currency: currency)\n end", "def price\n # puts \"$#{(num_beds*1000) + (num_baths*500)}\"\n (num_beds*1000) + (num_baths*500)\n end...
[ "0.70465463", "0.6970083", "0.69522715", "0.69375265", "0.6929888", "0.69052213", "0.6887135", "0.6852347", "0.6720946", "0.6630209", "0.66119945", "0.65844077", "0.6576495", "0.6561258", "0.6548831", "0.6509127", "0.6491853", "0.6490294", "0.6490294", "0.64888716", "0.648625...
0.65562564
14
Preview the cookbook This can be the current cookbook or a cookbook of another person if an order has been created (guest order)
def preview order = current_user.orders.find_by_cookbook_id(params[:id]) @cookbook = (order) ? order.cookbook : current_cookbook preview_path = "#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf" session[:preview_filename] = preview_path preview = CookbookPreviewWorker.new( cookbook: @cookbook, filename: preview_path ) preview.cookbook render "previews/preview" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n @cookbook = current_cookbook\n end", "def edit_introduction\n @cookbook = current_cookbook\n end", "def show(cookbook)\n cookbooks[cookbook.cookbook_name] = cookbook.pretty_hash\n end", "def edit_title\n @cookbook = current_cookbook\n end", "def show(cookbook)\n path...
[ "0.6933546", "0.6590305", "0.6458196", "0.6370931", "0.616484", "0.60808307", "0.60649455", "0.6053982", "0.60436743", "0.6009953", "0.59808934", "0.5940761", "0.593446", "0.59180933", "0.5885206", "0.58740807", "0.58616465", "0.58076125", "0.5764444", "0.57035583", "0.562246...
0.69126475
1
Preview the cookbook cover
def preview_cover preview_path = "#{PDF_PREVIEW_FOLDER}/preview_cover-#{current_cookbook.id}_#{Time.now.to_i}.pdf" session[:preview_filename] = preview_path preview = CookbookPreviewWorker.new( cookbook: current_cookbook, filename: preview_path ) preview.cover render "previews/preview" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preview\n order = current_user.orders.find_by_cookbook_id(params[:id])\n @cookbook = (order) ? order.cookbook : current_cookbook\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPrevie...
[ "0.6626343", "0.6560433", "0.6560433", "0.6156586", "0.6087413", "0.59966797", "0.59966797", "0.59686", "0.5883065", "0.58734447", "0.5836019", "0.5792734", "0.57913464", "0.57071495", "0.57039464", "0.56878126", "0.5681726", "0.5663612", "0.5663612", "0.56445384", "0.5624729...
0.7587635
0
Preview the title and the table of contents pages
def preview_title_and_toc preview_path = "#{PDF_PREVIEW_FOLDER}/preview_title_toc-#{current_cookbook.id}_#{Time.now.to_i}.pdf" session[:preview_filename] = preview_path preview = CookbookPreviewWorker.new( cookbook: current_cookbook, filename: preview_path ) preview.title_and_toc render "previews/preview" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preview\n end", "def preview\n end", "def preview_page(name, data, format)\n page = @page_class.new(self)\n ext = @page_class.format_to_ext(format.to_sym)\n path = @page_class.cname(name) + '.' + ext\n blob = OpenStruct.new(:name => path, :data => data)\n page.populate(blob, pat...
[ "0.64124614", "0.64124614", "0.6228087", "0.61932886", "0.61879516", "0.6138907", "0.6136847", "0.61265945", "0.6119841", "0.6118165", "0.60977024", "0.6089731", "0.6074166", "0.6062032", "0.60570693", "0.6053675", "0.6051556", "0.6033562", "0.6026164", "0.6017094", "0.600442...
0.76360786
0
Preview the index page
def preview_index preview_path = "#{PDF_PREVIEW_FOLDER}/preview_index-#{current_cookbook.id}_#{Time.now.to_i}.pdf" session[:preview_filename] = preview_path preview = CookbookPreviewWorker.new( cookbook: current_cookbook, filename: preview_path ) preview.index render "previews/preview" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preview_index(urls, path: request.path)\n render(path: __dir__ + \"/index.erb\", locals: { urls: Array(urls), path: path })\n end", "def index\n \n end", "def index\n \n end", "def index\n \n end", "def index\n render\n end", "def index; end", "def index; end", "def ...
[ "0.7894774", "0.74425375", "0.74425375", "0.74425375", "0.7379633", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", "0.73158634", ...
0.77508557
1
Respond with the number of pages for the current cookbook
def count_page num_pages = current_cookbook.num_pages render json: {num_pages: num_pages} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_count; pages.count; end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n retur...
[ "0.710333", "0.69140714", "0.69140714", "0.69140714", "0.69140714", "0.69040275", "0.6766329", "0.6764628", "0.6753337", "0.67044806", "0.6690332", "0.6689448", "0.6682994", "0.66608137", "0.6655366", "0.6606979", "0.65942544", "0.6583469", "0.65683705", "0.6565279", "0.65496...
0.87572855
0
Add Money to users account
def deposit end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_money\n\t\t# get current user's money\n \t@user = current_user\n\t\t@money = @user.money\n\t\t# get refill limit\n\t\t@allowed = @user.money_refill\n\n\t\t# if limit has not been reached, add money to account\n\t\tif @allowed > 0\n\t\t\t@user.money = @money + 1000\n\t\t\t@user.money_refill = @allowed - 1\...
[ "0.8001156", "0.7571441", "0.7441676", "0.7327436", "0.7324111", "0.7010685", "0.68067354", "0.67458415", "0.669875", "0.6665531", "0.6662032", "0.6647681", "0.66472596", "0.66186476", "0.65935326", "0.6566185", "0.6546947", "0.65250087", "0.65192366", "0.65171427", "0.647732...
0.0
-1
returns a json representation of the specified element argv = commandline arguments, requires an element (e) argument, such as 'interfaces', 'hosts' or 'routes' or 'interfaces/a1' or 'hosts/dell9'
def cmd_get argv setup argv e = @hash['element'] response = @api.get(e) msg JSON.pretty_generate(response) return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parseArgs(argv)\n\n result = { \"all\" => false, \"mongo_host\" => \"localhost\", \"mongo_port\" => 27017, \"tenants\" => [] }\n\n for arg in argv\n if arg == \"--all\"\n result[\"all\"] = true\n elsif arg.include?(\":\")\n host_port = arg.split(':')\n result[\"mongo_host\"] = host_port[...
[ "0.6073539", "0.6073539", "0.6073539", "0.6073539", "0.6073539", "0.5711646", "0.56099266", "0.5487876", "0.54710764", "0.5397917", "0.5371958", "0.5348169", "0.53394496", "0.53031284", "0.5281803", "0.52738583", "0.5273534", "0.52599037", "0.52573115", "0.52487284", "0.51750...
0.62305874
0
modifies a network element argv = commandline arguments, requires a json configuration (j) and the element (e) to modify, such as 'interfaces', 'hosts' or 'routes' or 'interfaces/a1' or 'hosts/dell9'
def cmd_modify argv setup argv json = @hash['json'] e = @hash['element'] response = @api.modify(json, e) msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @addon_node = args[:addon_node] if args.key?(:addon_node)\n @annotations = args[:annotations] if args.key?(:annotations)\n @anti_affinity_groups = args[:anti_affinity_groups] if args.key?(:anti_affinity_groups)\n @auto_repair_config = args[:auto_repair_conf...
[ "0.5877967", "0.58464944", "0.5841025", "0.5807635", "0.5739581", "0.57103986", "0.5707734", "0.5687186", "0.5633782", "0.5558491", "0.5511202", "0.5492197", "0.54439795", "0.5435326", "0.5416061", "0.5404252", "0.5400137", "0.5397197", "0.53889453", "0.53607035", "0.5345757"...
0.7363384
0
creates a new network element argv = commandline arguments, requires a json configuration (j) and the element (e) to modify, such as 'interfaces', 'hosts' or 'routes'
def cmd_create argv setup argv json = @hash['json'] e = @hash['element'] response = @api.create(json, e) msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmd_modify argv\n setup argv\n json = @hash['json']\n e = @hash['element']\n response = @api.modify(json, e)\n msg response\n return response\n end", "def create_network_equipment(network_uid, network, refapi_path, site_uid = nil)\n network_path = ''\n if site_uid\n network_path = Pat...
[ "0.57113636", "0.5529602", "0.53176737", "0.5289449", "0.52048165", "0.5111053", "0.50640666", "0.5063005", "0.50531757", "0.5027478", "0.49777773", "0.4975934", "0.4961408", "0.49605873", "0.49578798", "0.49498597", "0.49348983", "0.49090227", "0.48975217", "0.488974", "0.48...
0.63507545
0
deletes an existing network element argv = commandline arguments, requires a json configuration (j) and the element (e) to modify, such as 'interfaces', 'hosts' or 'routes' or 'interfaces/a1' or 'hosts/dell9'
def cmd_delete argv setup argv e = @hash['element'] response = @api.delete(e) msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmd_modify argv\n setup argv\n json = @hash['json']\n e = @hash['element']\n response = @api.modify(json, e)\n msg response\n return response\n end", "def update!(**args)\n @network = args[:network] if args.key?(:network)\n end", "def update!(**args)\n @network =...
[ "0.6460949", "0.5475716", "0.54739", "0.54632664", "0.5437425", "0.5421944", "0.53205013", "0.5300579", "0.5272561", "0.52284783", "0.5146894", "0.50955284", "0.5074325", "0.50561506", "0.5038087", "0.50370777", "0.5027454", "0.5010529", "0.49872196", "0.49847698", "0.4973937...
0.63628566
1
restores the network configuration from a file argv = commandline arguments, requires a path to a json configuration file (f) , and a boolean (b true|false) argument indicating whether or not existing elements should be cleared
def cmd_restore argv setup argv filepath = @hash['filepath'] clear_existing = to_boolean(@hash['boolean']) response = @api.restore(filepath, clear_existing) msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n @config_file = nil\n set_defaults\n load_from_file if config_file\n end", "def clean_up_conf_file(conf_file_path)\n conf_items_patterns = { /^tools\\.remindInstall.*\\n/ => \"tools.remindInstall = \\\"FALSE\\\"\",\n /^uuid\\.action.*\\n/ => \"uuid.action = \\\"cr...
[ "0.5522984", "0.5496737", "0.54178774", "0.53766453", "0.53382134", "0.53363556", "0.53073454", "0.5293508", "0.52713937", "0.5251322", "0.5152444", "0.51470655", "0.5146332", "0.51406515", "0.5125433", "0.5118058", "0.51074433", "0.5100331", "0.5094668", "0.5092635", "0.5063...
0.50177276
25
clears existing network configuration hosts argv = commandline arguments
def cmd_clear_hosts argv setup argv response = @api.clear_hosts msg JSON.pretty_generate(response) return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_unused_host_only_networks\n end", "def clear_host!\n @host_key_files = []\n @known_host_identities = nil\n self\n end", "def reset!\n @hosts = nil\n end", "def delete_unused_host_only_networks\n networks = []\n execute(\"list\", \"...
[ "0.6695341", "0.6572044", "0.6545548", "0.6206237", "0.617071", "0.5949854", "0.5934213", "0.5871286", "0.58433074", "0.57184565", "0.5705588", "0.5698112", "0.5680054", "0.5645454", "0.56192917", "0.5600557", "0.55954653", "0.5586551", "0.5586551", "0.55767447", "0.5560001",...
0.73461294
0
resolves network configuration hosts argv = commandline arguments, requires the name (n) of the host to resolve (determines its ip address and adds it to the network configuration)
def cmd_resolve_hosts argv setup argv name = @hash['name'] response = @api.resolve_hosts(name) msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_hosts (args)\n\n discoveryrc = File.expand_path(\"~/.discoveryrc\")\n aliasmap = {}\n if File.readable?(discoveryrc)\n File.readlines(discoveryrc).each {|line| line.scan(/(\\w+)\\s*=\\s*(.*)/) {|k,v| aliasmap[k]=v}}\n end\n\n if args.size == 0 || args[0] =~ /^-/\n @hosts = aliasm...
[ "0.6984021", "0.60479033", "0.59377795", "0.5851572", "0.5738252", "0.5738252", "0.5715469", "0.5711686", "0.56538963", "0.5591599", "0.55742544", "0.5562225", "0.5532942", "0.5500179", "0.5493819", "0.5484015", "0.5450859", "0.5385188", "0.5376823", "0.53705746", "0.5348531"...
0.7583121
0
clears existing network interfaces argv = commandline arguments, require the names of the interfaces to clear (i name)
def cmd_clear_interface argv setup argv interface = @hash['interfaces'] response = @api.clear_interface(interface) msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CleanUp\n\tallGroups.exec(\"killall ITGRecv >/dev/null 2>&1;\")\n\tallGroups.exec(\"killall ITGManager >/dev/null 2>&1; killall ITGSend >/dev/null 2>&1;\") \n\t#set the interfaces down\n @nodes.each do |node|\n\t\tif node.GetType()==\"R\"\n\t\t node.GetInterfaces().each do |ifn|\n\t\t # se...
[ "0.62533665", "0.59918845", "0.5898995", "0.5898995", "0.5898995", "0.58098364", "0.5726285", "0.5708749", "0.5697775", "0.56189936", "0.5596491", "0.5579363", "0.55717564", "0.54868674", "0.5479407", "0.5453402", "0.54292", "0.5410123", "0.5400418", "0.53941184", "0.5381248"...
0.7769497
0
clears existing vlan configurations argv = commandline arguments
def cmd_clear_vlans argv setup argv response = @api.clear_vlans msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unset(*args)\n run \"unset #{OptArg.parse(*args)}\"\n nil\n end", "def deconfigure\n # assume eth0 primary ip is managed by dhcp\n if name == 'eth0'\n cmd(\"addr flush dev eth0 secondary\")\n else\n cmd(\"rule list\").lines.grep(/^([0-9]+):.*lookup #{route_table}...
[ "0.59625125", "0.58159935", "0.5785312", "0.57039493", "0.557716", "0.5531423", "0.5521691", "0.5521691", "0.5518103", "0.5449379", "0.54206073", "0.5378676", "0.53448755", "0.53358364", "0.5332073", "0.53293234", "0.5310814", "0.5303817", "0.53019005", "0.52892244", "0.52869...
0.57085794
3
clears existing network routes argv = commandline arguments
def cmd_clear_routes argv setup argv response = @api.clear_routes msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset!\n ATTRIBUTES.each {|attr| send(\"#{attr.to_s}=\", nil)}\n routes.clear\n end", "def reset\n @routes.clear\n end", "def flush_routes\n _init\n\n # Remove each of the individual routes so the comms don't think they're\n # still routing after a flush.\n self.routes.each...
[ "0.6123719", "0.60387725", "0.60188967", "0.6004334", "0.593301", "0.5913294", "0.58890086", "0.5653833", "0.55848956", "0.55750537", "0.55709225", "0.5569863", "0.5560173", "0.5555922", "0.55414546", "0.5516868", "0.54875404", "0.5485673", "0.54714286", "0.5470428", "0.54601...
0.74620134
0
saves the network configuration to a file argv = commandline arguments, requires the element (e element, such as 'interfaces', or e all) to save, and a file name (f) to save the settings to
def cmd_save argv setup argv e = @hash['elements'] filepath = @hash['filepath'] || "config.json" response = @api.save(e, filepath) msg response return response end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_config()\nafile = File.open(\"cp3nodes.conf\", \"w\")\nafile.puts \"1 127.0.0.1 25500 25501 25502\\n\"\nafile.puts \"2 127.0.0.1 25503 25504 25505\\n\"\nafile.puts \"3 127.0.0.1 25506 25507 25508\\n\"\nafile.close\nend", "def save(fn)\n begin\n File.open(fn,\"w\") do |file|\n output = ...
[ "0.623356", "0.6000239", "0.5849585", "0.58137697", "0.57539123", "0.5667529", "0.5590036", "0.5588363", "0.5563063", "0.5497579", "0.54847336", "0.5457971", "0.54107577", "0.53860587", "0.5378316", "0.5337453", "0.5304921", "0.5254505", "0.5216638", "0.52010626", "0.5181774"...
0.66596174
0
Filter links whitch doesnt match with the search
def filterProviderOffer(links) useless_links = links.pop #take the offers links.delete(useless_links) links end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_links(search)\n links.select { |link| link.contains? search }\n end", "def filter_links(links)\n filtered_links = links.map do |link|\n next unless link.include?(\"data\") #TODO: Extract into query parameter\n link\n end.compact\n\n #TODO: Extract into exclusion array pa...
[ "0.699109", "0.69394594", "0.66918635", "0.6669999", "0.66317844", "0.65998936", "0.6553799", "0.65034235", "0.64443773", "0.6410349", "0.6396636", "0.6394018", "0.6269745", "0.62178856", "0.6214081", "0.6188525", "0.6159125", "0.6129926", "0.61267155", "0.61257315", "0.61206...
0.6522986
7
GET /cards GET /cards.json
def index #@cards = Card.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cards\n @celebrity = Celebrity.find(params[:id])\n @cards = @celebrity.cards\n render json: @cards\n end", "def index\n @cards = Card.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @cards }\n end\n end", "def cards(options = { :filter => :open })...
[ "0.8067241", "0.78271", "0.7666086", "0.76476836", "0.74856645", "0.74856645", "0.7461866", "0.7461866", "0.7461866", "0.7461866", "0.7461866", "0.74300534", "0.7284355", "0.72508144", "0.72301847", "0.7220295", "0.70856464", "0.7066807", "0.70531297", "0.70461464", "0.704614...
0.69251984
24
GET /cards/1 GET /cards/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cards\n @celebrity = Celebrity.find(params[:id])\n @cards = @celebrity.cards\n render json: @cards\n end", "def show\n @card = Card.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @card }\n end\n end", "def show\n @car...
[ "0.78883135", "0.7717609", "0.7717609", "0.7717609", "0.7717609", "0.7717609", "0.76503384", "0.76283175", "0.7469136", "0.7469136", "0.7467715", "0.7419696", "0.73733157", "0.73434144", "0.7250834", "0.71437824", "0.7125837", "0.71233726", "0.70780337", "0.70430386", "0.7022...
0.0
-1
POST /cards POST /cards.json
def create @card = Card.new(card_params) mm = 3.543307 forms = params.require(:card).permit(:name, :kana_name, :department, :postalcode, :address_prefectural, :address_city, :address_street, :address_building, :tel, :email, :course, :laboratory, :free_text, :card_template, :paper_template) paper_template = PaperTemplate.find(forms[:paper_template]) paper = File.read("app/assets/images/paper/" + paper_template.path) card_template = CardTemplate.find(forms[:card_template]) svg = REXML::Document.new(open("app/assets/images/card/" + card_template.path)) # jikanganai svg.root.elements["//*[@id='text_name']"].text = forms[:name] if card_template.department if forms[:department].present? svg.root.elements["//*[@id='text_department']"].text = School.find(Department.find(forms[:department]).school).name + Department.find(forms[:department]).name else svg.root.elements["//*[@id='text_department']"].text = "" end end if card_template.course and forms[:course] if forms[:course].present? svg.root.elements["//*[@id='text_course']"].text = Course.find(forms[:course]).name else svg.root.elements["//*[@id='text_course']"].text = "" end end if card_template.laboratory and forms[:laboratory] if forms[:laboratory].present? svg.root.elements["//*[@id='text_lab']"].text = Laboratory.find(forms[:laboratory]).name else svg.root.elements["//*[@id='text_lab']"].text = "" end end if card_template.tel if forms[:tel].present? svg.root.elements["//*[@id='text_tel']"].text = forms[:tel] else svg.root.elements["//*[@id='text_tel']"].text = "" end end if card_template.email if forms[:email].present? svg.root.elements["//*[@id='text_email']"].text = forms[:email] else svg.root.elements["//*[@id='text_email']"].text = "" end end if card_template.free if forms[:free_text].present? svg.root.elements["//*[@id='text_free']"].text = forms[:free_text] else svg.root.elements["//*[@id='text_free']"].text = "" end end if card_template.address_city if forms[:address_city].present? svg.root.elements["//*[@id='text_address']"].text = Prefectural.find(forms[:address_prefectural]).name + forms[:address_city] + forms[:address_street] + forms[:address_building] else svg.root.elements["//*[@id='text_address']"].text = "" end end card_text = "" xMargin = paper_template.margin_x * mm yMargin = paper_template.margin_y * mm xSize = card_template.size_x * mm ySize = card_template.size_y * mm debug = "" for xNum in 0..(paper_template.cols - 1) do for yNum in 0..(paper_template.rows - 1) do x = xMargin + xSize * xNum y = yMargin + ySize * yNum svgText = svg.root.to_s svgText.gsub!(/<svg[^>]+>/, '') svgText.gsub!(/<\/svg>/, '') svgText.gsub!(/id='([^']+)'/) { "id='" + $1 + xNum.to_s + "_" + yNum.to_s + "'" } svgText.gsub!(/x='([0-9.]+)'/) { "x='" + ($1.to_f + x).to_s + "'" } svgText.gsub!(/y='([0-9.]+)'/) { "y='" + ($1.to_f + y).to_s + "'" } svgText.gsub!(/d='m ([0-9.]+),([0-9.]+)/) { "d='m #{($1.to_f + x).to_s},#{($2.to_f + y).to_s}" } paper.gsub!(/<g \/>/, svgText + "<g />") end end paper.gsub!(/"/, "'") filename = SecureRandom.hex svgFile = File.open("tmp/#{filename}.svg", 'w') svgFile.puts paper pdf = `cat tmp/#{filename}.svg | cairosvg -` svgFile.close File.unlink("tmp/#{filename}.svg") #pdf = `echo "#{paper}" | cairosvg -` send_data pdf, filename: "card.pdf", type: "application/pdf", disposition: "inline" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @card = Card.new(card_params)\n\n if @card.save\n render json: @card, status: :created, location: @card\n else\n render json: @card.errors, status: :unprocessable_entity\n end\n end", "def create\n @card = Card.create(card_params)\n if @card.errors.any?\n render json:...
[ "0.7442985", "0.7313761", "0.71945184", "0.7166914", "0.7153905", "0.7132376", "0.71268773", "0.7120617", "0.71131635", "0.7086562", "0.7049953", "0.69978523", "0.69978523", "0.69978523", "0.69978523", "0.69898945", "0.6973494", "0.67605746", "0.67355794", "0.66842014", "0.66...
0.0
-1
PATCH/PUT /cards/1 PATCH/PUT /cards/1.json
def update respond_to do |format| if @card.update(card_params) format.html { redirect_to @card, notice: 'Card was successfully updated.' } format.json { render :show, status: :ok, location: @card } else format.html { render :edit } format.json { render json: @card.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # @card = Card.find(params[:id])\n # @card.update(card_params)\n # render json: @card\n end", "def update\n #@card = Card.find(params[:id])\n\n respond_to do |format|\n if @card.update_attributes(params[:card])\n format.html { redirect_to cards_url, :notice ...
[ "0.74138683", "0.73641354", "0.7332616", "0.73224586", "0.7262503", "0.7262503", "0.7262503", "0.72331095", "0.7220635", "0.72159266", "0.7201274", "0.71773446", "0.70944387", "0.70107996", "0.69666153", "0.6961331", "0.6904233", "0.68476", "0.6798736", "0.67981195", "0.67798...
0.70095146
19
DELETE /cards/1 DELETE /cards/1.json
def destroy @card.destroy respond_to do |format| format.html { redirect_to cards_url, notice: 'Card was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n # @card = Card.destroy(params[:id])\n # render json: 200\n end", "def destroy\n @card = Card.find(params[:id])\n @card.destroy\n\n respond_to do |format|\n format.html { redirect_to cards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n...
[ "0.797766", "0.781652", "0.781652", "0.781652", "0.7773019", "0.7738249", "0.7725237", "0.7681169", "0.7677146", "0.76027936", "0.75915974", "0.7586289", "0.7575081", "0.75175333", "0.7495067", "0.74903256", "0.7441149", "0.74211055", "0.7377856", "0.73454833", "0.73294616", ...
0.75335413
19
Use callbacks to share common setup or constraints between actions.
def set_card @card = Card.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def card_params params[:card] 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
Converts the range to an equivalent exclusive range (one where exclude_end? is true) Only works for ranges with discrete steps between values (i.e. integers)
def exclusive if exclude_end? self else Range.new(self.begin, self.end + 1, true) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_range\n min .. max\n end", "def split_range(range)\n start, finish = range.begin, range.end\n start += length if start < 0\n finish += length if finish < 0\n \n [start, finish - start - (range.exclude_end? ? 1 : 0)]\n end", "def to_range\n Range.new(self.start, sel...
[ "0.67048925", "0.66411984", "0.661552", "0.65872425", "0.638718", "0.6381692", "0.63625807", "0.63625807", "0.6331616", "0.6318954", "0.6271104", "0.62284017", "0.6194463", "0.61927426", "0.6190236", "0.6157565", "0.6144774", "0.6083266", "0.60557", "0.60477036", "0.60390145"...
0.73609537
0
Returns whether the range is empty A range is empty if end < begin or if begin == end and exclude_end? is true.
def empty? if exclude_end? self.end <= self.begin else self.end < self.begin end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty?\n\t interval.first == interval.last && interval.exclude_end?\n end", "def exclude_end?\n @ranges.size == 1 ? @ranges[0].exclude_end? : nil\n end", "def exclude_begin?\n @ranges.size == 1 ? @ranges[0].exclude_begin? : nil\n end", "def empty?\n return false if @upper_bou...
[ "0.77110314", "0.75511134", "0.73856896", "0.6896937", "0.68835026", "0.6743136", "0.6574668", "0.6466301", "0.6450598", "0.64366853", "0.63932437", "0.6367697", "0.63334817", "0.6279109", "0.62450194", "0.6210988", "0.6195007", "0.6142625", "0.6123797", "0.61012787", "0.6028...
0.8152051
0
resumes a given eventlet immediately, passing control to it.
def resume(*args) @fiber.resume(*args) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resume event\n f = @fiber.resume event\n\n if !f.nil? \n @finishable = f[0];\n return;\n end\n \n @is_running = false\n @event = nil\n end", "def trap_resume\n Curses.raw\n old_cont = trap 'CONT' do Curses.doupdate end\n\n yield\n\n ensure\n Curses.noraw\n trap 'C...
[ "0.6952863", "0.6713674", "0.63717586", "0.63510805", "0.6338614", "0.62968886", "0.62889594", "0.62606657", "0.62525445", "0.6234762", "0.62002987", "0.6157925", "0.6157925", "0.6136757", "0.6096667", "0.6096667", "0.6064419", "0.6044233", "0.603829", "0.59458303", "0.592276...
0.63763976
2
GET /steps GET /steps.json
def index if params[:project_id] @steps = Step.joins(:projects).includes(:work_items, :work_items => :users, :work_items => :tasks).where('projects.id = ?', params[:project_id]).order('position ASC') steps = @steps.collect do |s| s.work_items.sort!{|a, b| a.position <=> b.position} s end @steps = steps else @steps = Step.all end respond_with @steps end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def index\n @steps = Step.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps ...
[ "0.7637826", "0.71650946", "0.68370473", "0.68370473", "0.68370473", "0.68370473", "0.6820434", "0.67121947", "0.6697843", "0.66859204", "0.6614578", "0.6571187", "0.6571187", "0.6571187", "0.6489213", "0.6478076", "0.6385908", "0.63753617", "0.6344778", "0.6264669", "0.62381...
0.58727586
44
GET /steps/1 GET /steps/1.json
def show @step = Step.find_by_slug(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @step } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def show\n @step = Step.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render js...
[ "0.7460156", "0.7168968", "0.7168968", "0.7168968", "0.7037824", "0.6926366", "0.68012416", "0.6732481", "0.6719113", "0.6685765", "0.6685765", "0.6685765", "0.6685765", "0.6669708", "0.6632687", "0.6623837", "0.65953994", "0.65694636", "0.6513855", "0.6479822", "0.64797056",...
0.6544564
18
GET /steps/new GET /steps/new.json
def new @step = Step.new respond_to do |format| format.html # new.html.erb format.json { render json: @step } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n \n @step = Step.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @step }\n end\n end", "def new\n @step_type = StepType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @step_type }\n ...
[ "0.8326137", "0.7754607", "0.77181315", "0.77040356", "0.76325387", "0.75851744", "0.7393559", "0.73890674", "0.7377804", "0.73325866", "0.73225975", "0.7298311", "0.7256544", "0.7219394", "0.7219394", "0.7219394", "0.72105545", "0.71799856", "0.7178456", "0.7143546", "0.7133...
0.82181114
1
POST /steps POST /steps.json
def create @project = Project.find(params[:project_id]) position = Step.joins(:projects).where('projects.id = ?', @project.id).maximum('steps.position') position = 1 unless position @step = @project.steps.create(params[:step]) @step.position = position - 1 respond_to do |format| if @step.save ProjectMailer.notify_step_created(@step, current_user).deliver format.html { redirect_to @step, notice: 'Step was successfully created.' } format.json do render json: @step, status: :created end else format.html { render action: "new" } format.json { render json: @step.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @step = Step.new(step_params)\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to api_v1_step_url(@step), notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n ...
[ "0.72776073", "0.7162873", "0.7154432", "0.7053331", "0.6981029", "0.69380945", "0.6864185", "0.6797167", "0.67728835", "0.67721575", "0.6742286", "0.671232", "0.66172564", "0.6616853", "0.6608131", "0.659918", "0.6577374", "0.6566789", "0.65660614", "0.6541265", "0.6532123",...
0.63662344
29
PUT /steps/1 PUT /steps/1.json
def update @step = Step.find(params[:id]) respond_to do |format| if @step.update_attributes(params[:step]) format.html { redirect_to @step, notice: 'Step was successfully updated.' } format.json { render :json => {:message => "Success"} } else format.html { render action: "edit" } format.json { render json: @step.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @step = @guide.steps.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to [@guide, @step], notice: 'Step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
[ "0.7260924", "0.7149206", "0.7111334", "0.7084085", "0.7009273", "0.69495946", "0.6942218", "0.69110596", "0.69110596", "0.68177384", "0.67457926", "0.6743555", "0.66804653", "0.6679542", "0.66236097", "0.6623572", "0.6582954", "0.6567151", "0.6558542", "0.6533719", "0.653067...
0.711446
2
DELETE /steps/1 DELETE /steps/1.json
def destroy @step = Step.find(params[:id]) if @step.removable step_name = @step.name project = @step.projects.first @step.destroy ProjectMailer.notify_step_deleted(step_name, project, current_user).deliver respond_to do |format| format.html { redirect_to steps_url } format.json { render :json => {:message => "Success"} } end else respond_to do |format| format.html { redirect_to steps_url } format.json { render :json => "Step #{@step.name} is not removable", :status => :unprocessable_entity} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to steps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @step = Step.find(params[:id])\n @step.status = \"deleted\"\n @step.save!\n\n respond_...
[ "0.7910436", "0.78295755", "0.78116536", "0.7774464", "0.75964475", "0.7572063", "0.7572063", "0.7572063", "0.7572063", "0.742347", "0.74095196", "0.7402601", "0.7400754", "0.73675877", "0.7339873", "0.73136175", "0.73052126", "0.73025376", "0.7301966", "0.73009235", "0.72825...
0.6692822
58
Use callbacks to share common setup or constraints between actions.
def set_customer_contact_person @customer_contact_person = CustomerContactPerson.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.6163821", "0.6045432", "0.5945441", "0.5916224", "0.58894575", "0.5834073", "0.57764685", "0.5702474", "0.5702474", "0.5653258", "0.56211996", "0.54235053", "0.5410683", "0.5410683", "0.5410683", "0.53948104", "0.5378064", "0.5356684", "0.53400385", "0.53399503", "0.533122...
0.0
-1
Only allow a trusted parameter "white list" through.
def customer_contact_person_params params.require(:customer_contact_person).permit(:salutation, :first_name, :last_name, :department, :is_primary, :customer_company_id, :organization_id, contact_attributes: [:id, :email, :mobile, :fax, :is_primary], address_attributes: [:id, :address_line1,:address_line2, :city, :state, :country, :postal_code]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121862", "0.70524937", "0.6947974", "0.69016707", "0.6735245", "0.67157984", "0.66887176", "0.66779864", "0.6660236", "0.6554225", "0.6527208", "0.6456831", "0.6451704", "0.64509416", "0.64478475", "0.6432556", "0.6411603", "0.6411603", "0.6389978", "0.63789994", "0.63789...
0.0
-1
Get an object by an arbitary path. TODO: API endpoint does not play well with remote files
def get(path) path = "/#{path}" unless path[0] == '/' OneDriveItem.smart_new(self, request("drive/root:/#{url_path_encode(path[1..-1])}")) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def object_for(path)\n # We do the traversal so that the user does not need to.\n path.split(\"/\").inject(self) {|tree, name|\n tree.objects.find {|obj| obj.name == name }\n }\n end", "def find_or_create_object_by_absolute_path(path, options = {})\n path = path.to_s\n opti...
[ "0.7028362", "0.6849722", "0.66434616", "0.66336113", "0.6619283", "0.65754616", "0.657161", "0.65404594", "0.64244896", "0.6402493", "0.63924587", "0.639222", "0.6360519", "0.6336129", "0.63170284", "0.6294444", "0.62215006", "0.62136877", "0.618642", "0.6165287", "0.6122037...
0.6003975
32
Responds to slash commands
def index info = ScheduleProcessor.headway_info query = params[:text] workspace = params[:enterprise_name] || params[:team_domain] user_id = params[:user_id] if query == 'help' result = help_response(info[:routes]) elsif (data = info[:routes].find { |r| r[:id] == query}) track_event('slash', "route/#{query}", user_id, workspace) result = route_response(data) elsif query == 'delays' track_event('slash', 'delays', user_id, workspace) result = delays_response(info[:routes]) else track_event('slash', 'default', user_id, workspace) result = default_response(info) end render json: result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_command(command)\n cmd = command.command\n return Response.new unless cmd\n if cmd.start_with?(\"'\")\n cmd = \"say \" + cmd[1, cmd.length-1]\n end\n if cmd.start_with?('say ')\n command.say = cmd[4, cmd.length-4].strip\n end\n command.command = cmd.downcase\n\n handler...
[ "0.64246076", "0.63354075", "0.62353563", "0.5973118", "0.59046525", "0.59046525", "0.59046525", "0.59046525", "0.59046525", "0.59046525", "0.58602", "0.57472044", "0.5744415", "0.5704116", "0.56972784", "0.56835073", "0.5674806", "0.564908", "0.5629635", "0.5621588", "0.5593...
0.0
-1
Responds to select interactive components
def query payload = JSON.parse(params[:payload]).with_indifferent_access info = ScheduleProcessor.headway_info uri = URI(payload[:response_url]) workspace = payload.dig(:enterprise)&.dig(:name) || payload.dig(:team)&.dig(:domain) user_id = payload.dig(:user)&.dig(:id) if payload[:actions].first[:action_id] == 'select_route' if (data = info[:routes].find { |r| r[:id] == payload[:actions].first[:selected_option][:value]}) track_event('default', "route/#{data[:id]}", user_id, workspace) result = route_response(data) end elsif payload[:actions].first[:action_id] == 'select_line' if (borough, _ = info[:lines].find { |borough, lines| data = lines.find { |l| l[:id] == payload[:actions].first[:selected_option][:value]}}) track_event('default', "line/#{data[:id]}", user_id, workspace) result = line_response(borough, data) end end Net::HTTP.post(uri, result.to_json, "Content-Type" => "application/json") render json: result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def request_select\n end", "def selected; end", "def items\n load_selection\n import_selection or render_select\n end", "def selected_options; end", "def selected_options; end", "def select\n self[:select]\n end", "def selected?; end", "def selected?; end", "def select\n ...
[ "0.7299794", "0.69812965", "0.6842775", "0.6836243", "0.6836243", "0.6790073", "0.67284554", "0.67284554", "0.66756946", "0.6578907", "0.6546324", "0.64850855", "0.64850855", "0.6466827", "0.63828564", "0.63312876", "0.62928253", "0.626391", "0.62462276", "0.6235206", "0.6235...
0.0
-1
scope :vendor_only, where(:organization_type_id => MasterType.find_by_type_value("vendor").id) scope :customer_only, where(:organization_type_id => MasterType.find_by_type_value("customer").id) scope :support_only, where(:organization_type_id => MasterType.find_by_type_value("support").id) Sets active to true by default. TODO: this can be done using the schema file (migration)
def default_values self.organization_active = true if attributes.key?('organization_active') && organization_active.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def try_to_set_scope\n #this is a commodity method\n if self.featurable.is_a?(Account)\n self.scope = \"AccountPlan\"\n end\n end", "def to_scope\r\n\r\n table_name = @model.table_name\r\n\r\n @filtering_attributes.select { |attr|\r\n @filtering_values.key?(attr)\r\n }.reduce(@model....
[ "0.6016881", "0.595855", "0.58912444", "0.5831295", "0.5831295", "0.58096254", "0.5733699", "0.5645943", "0.56291556", "0.5555973", "0.5540309", "0.5527291", "0.5523325", "0.55090195", "0.5497261", "0.5496994", "0.5495893", "0.54800564", "0.54698384", "0.5464949", "0.5461882"...
0.49931994
84
Creates a Contact for the organization with contact_type 'address' The information mirrors the organizational entity.
def process_after_create # Note: Both contacts and addresses fields are same so when organization create then address info will store in Address table so commented the code for contact :- Vishal # contact = contacts.build(contact_address_1: organization_address_1, contact_address_2: organization_address_2, # contact_city: organization_city, contact_country: organization_country, contact_description: organization_description, # contact_email: organization_email, contact_fax: organization_fax, contact_notes: organization_notes, # contact_state: organization_state, contact_telephone: organization_telephone, contact_title: organization_name, # contact_website: organization_website, contact_zipcode: organization_zipcode, contact_type: 'address') # contact.save address = addresses.build(address_address_1: organization_address_1, address_address_2: organization_address_2, address_city: organization_city, address_country: organization_country, address_description: organization_description, address_email: organization_email, address_fax: organization_fax, address_notes: organization_notes, address_state: organization_state, address_telephone: organization_telephone, address_title: organization_name, address_website: organization_website, address_zipcode: organization_zipcode, address_type: 'address') address.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_contact\n @contact = Spree::Address.new(contact_params)\n # Currently for demo, I will leave the country id to be 1, later update will be noticed!\n hard_code_contact(contact_params)\n respond_to do |format|\n if @contact.save\n @seller.spree_addresses << ...
[ "0.7105798", "0.69384605", "0.6922415", "0.6889101", "0.6816222", "0.6775892", "0.6737944", "0.6659742", "0.6481586", "0.6474424", "0.64424914", "0.64314663", "0.64115256", "0.6391827", "0.6377442", "0.6361627", "0.63493", "0.6307078", "0.6256583", "0.62469727", "0.6197479", ...
0.6090641
25
Creates a Zipcode Territory if one does not already exist. A zipcode territory is the first 2 digits of the zipcode for the firm. It then assigns the organization to the territory It then checks all the fields, if any are blank, it registers as an incomplete profile.
def process_before_save zipcode = organization_zipcode.split('')[0..1].join('') if organization_zipcode.present? teriitory = Territory.find_by_territory_identifier(zipcode) unless teriitory teriitory = Territory.new(territory_identifier: zipcode) teriitory.save end self.territory = teriitory if CommonActions.nil_or_blank(organization_name) || CommonActions.nil_or_blank(organization_short_name) || CommonActions.nil_or_blank(organization_description) || CommonActions.nil_or_blank(organization_address_1) || CommonActions.nil_or_blank(organization_city) || CommonActions.nil_or_blank(organization_state) || CommonActions.nil_or_blank(organization_zipcode) || CommonActions.nil_or_blank(organization_telephone) || CommonActions.nil_or_blank(organization_website) || (contact_type.type_value == 'fax' ? CommonActions.nil_or_blank(organization_fax) : CommonActions.nil_or_blank(organization_email)) || (organization_type.type_value == 'customer' ? (customer_quality.nil? || min_vendor_quality.nil?) : false) || (organization_type.type_value == 'vendor' ? vendor_quality.nil? : false) self.organization_complete = false else self.organization_complete = true end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_postal_code\n @postal_code = Faker::Address.zip_code(state_abbreviation: @state)\n @postal_code = '' unless @set_blank == false\n end", "def hard_code_to_create_country(iso_name, iso, iso3, name, numcode, states_required, zipcode_required)\n @country = Spree::Country.create(iso_nam...
[ "0.5473488", "0.52503294", "0.5184183", "0.5136867", "0.5084143", "0.5084143", "0.50389785", "0.5036017", "0.5036017", "0.5036017", "0.50329506", "0.502724", "0.5026956", "0.4999854", "0.4992033", "0.49822778", "0.49487337", "0.4945391", "0.4931078", "0.48771018", "0.48741287...
0.64824766
0
TODO: this can be done using the controller respond_with
def redirect_path organization_path(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n respond_with []\n end", "def show\n respond_with @content\n end", "def respond\n end", "def respond\n respond_to do |format|\n format.html\n format.xml { render :xml => @response.to_xml }\n format.json { render :json => @response.to_json }\n end\n end", "def ...
[ "0.68284357", "0.68187296", "0.67677724", "0.66069794", "0.65196997", "0.65096873", "0.6473891", "0.64258885", "0.6401827", "0.6388692", "0.63752514", "0.6368158", "0.6366435", "0.63490534", "0.6314463", "0.6270811", "0.62662494", "0.6260377", "0.62602746", "0.62494355", "0.6...
0.0
-1
If the organization is a customer, it gives us all Chess POs where po_lines have the customer as the organization called on. When a vendor, it shows all PO headers that were made to that vendor
def purchase_orders case organization_type.type_value when 'customer' PoHeader.joins(:po_lines).where('po_lines.organization_id = ?', id).order('created_at desc') when 'vendor' PoHeader.where('organization_id = ?', id).order('created_at desc') else PoHeader.where('organization_id = ?', 0).order('created_at desc') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sales_orders\n case organization_type.type_value\n when 'customer'\n SoHeader.where('organization_id = ?', id).order('created_at desc')\n when 'vendor'\n SoHeader.joins(:so_lines).where('so_lines.organization_id = ?', id).order('created_at desc')\n else\n SoHeader.where('organization...
[ "0.61493427", "0.5473448", "0.53962165", "0.5296063", "0.5255456", "0.51558846", "0.5130783", "0.5066964", "0.5057077", "0.5034083", "0.5027433", "0.5022828", "0.50064874", "0.49958438", "0.49936822", "0.49876022", "0.49786782", "0.49786782", "0.49744272", "0.49582633", "0.49...
0.6666557
0
If the organization is a customer, it gives us all Chess SO to the customer If the organization is a vendor, it shows all SO_lines where the vendor was added as the supplier. TODO: have this backfilled after the lot is chosen. Once a lot is shipped, we know the supplier. By filling this in, we can find all so_line item vendors, not just the ones that are entered manually.
def sales_orders case organization_type.type_value when 'customer' SoHeader.where('organization_id = ?', id).order('created_at desc') when 'vendor' SoHeader.joins(:so_lines).where('so_lines.organization_id = ?', id).order('created_at desc') else SoHeader.where('organization_id = ?', 0).order('created_at desc') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customers; (line_items.map(&:customer).flatten.compact.uniq rescue []); end", "def sales\n sales_this_vendor_made = []\n sales_to_check = FarMar::Sale.all\n sales_to_check.each do |sale_to_check|\n if self.id == sale_to_check.vendor_id\n sales_this_vendor_made << sale_to_check\n ...
[ "0.5410528", "0.5398075", "0.5268887", "0.5240552", "0.5187056", "0.5175252", "0.5175252", "0.5089801", "0.5068672", "0.50150645", "0.49938476", "0.4980419", "0.49351025", "0.4890124", "0.4882353", "0.4875101", "0.4873243", "0.4858815", "0.48545456", "0.4836993", "0.48176032"...
0.5707799
0
Text transformation for Table headings
def organization_type_title if organization_name ' Associated With ' + organization_name else '' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def semanticize_table_headers!\n @document.tree.search('table tr:first td').each { |node| node.node_name = 'th' }\n end", "def latex_table(data, top_headings, left_headings)\n matrix = [[''] + top_headings] +\n left_headings.zip(data).map { |heading, line| [heading] + line }\n latex_matrix matrix\...
[ "0.6840461", "0.673363", "0.66941625", "0.66568744", "0.6486267", "0.645218", "0.63499457", "0.62495327", "0.6234798", "0.62046164", "0.6203615", "0.616092", "0.61553544", "0.61206615", "0.6093966", "0.6070091", "0.6069904", "0.6054214", "0.5988411", "0.59874576", "0.5982909"...
0.0
-1
All po line items which have a PO header to them (vendor only) used for listing vendor items
def po_items # po_items = self.po_headers.joins(:po_lines).select("po_lines.item_id").where("po_headers.organization_id = ?",self.id).order("po_lines.created_at DESC") po_items = PoLine.includes(:po_header).where('po_headers.organization_id = ?', id).order('po_headers.created_at DESC') po_items = po_items.collect(& :item_id) Item.where(id: po_items) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fulfilled_line_items\n return self.order_line_items.where(:status => 'shipped').all\n end", "def line_items_for_customer(customer_id)\n ret_line_items = []\n my_line_items = delivery_details.find_all_by_customer_id(customer_id)\n my_line_items.each do |my_line_item|\n my_line_item.order...
[ "0.6084435", "0.5931355", "0.58267266", "0.56693834", "0.5661872", "0.56595933", "0.5624584", "0.5621584", "0.5589917", "0.5576402", "0.5571669", "0.55144733", "0.54868376", "0.5481903", "0.5469212", "0.5452932", "0.54120755", "0.5409425", "0.5391925", "0.53228915", "0.526590...
0.6458787
0
All so line items which have a sales order written to them (customer only) used for listing all customer items.
def so_items # so_items = self.so_headers.joins(:so_lines).select("so_lines.item_id").where("so_headers.organization_id = ?",self.id).order("so_lines.created_at DESC") so_items = SoLine.includes(:so_header).where('so_headers.organization_id = ?', id).order('so_headers.created_at DESC') so_items = so_items.collect(& :item_id) Item.where(id: so_items) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line_items_for_customer(customer_id)\n ret_line_items = []\n my_line_items = delivery_details.find_all_by_customer_id(customer_id)\n my_line_items.each do |my_line_item|\n my_line_item.order_items.each do |order|\n if order.quantity > 0\n ret_line_items.push(order) unless ret_line...
[ "0.7205433", "0.6967645", "0.6655303", "0.665461", "0.6585721", "0.6155085", "0.61244994", "0.6099178", "0.60833853", "0.6036001", "0.6015484", "0.59267426", "0.58904976", "0.5876737", "0.58697903", "0.5864558", "0.5862323", "0.5862323", "0.5818309", "0.57806844", "0.5765275"...
0.5643551
32