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
Multi Fields generation in nested form > Start
def new @dish = Dish.new @dish_icons = @dish.dishes_icons.build end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nested_field_set(f, assoc, options = {})\n wrapper_partial = \"shared/nested_fields_wrapper\"\n options[:inner_partial] ||= \"#{f.object.class.model_name.route_key}/#{assoc.to_s.singularize}_fields\"\n options[:multiple] = true unless options.has_key?(:multiple)\n\n wrapper_classes = [\"nested-fiel...
[ "0.702322", "0.69084704", "0.690355", "0.66229945", "0.651817", "0.65178764", "0.6386444", "0.6330734", "0.63272774", "0.6269174", "0.625008", "0.62041116", "0.61990696", "0.61758083", "0.614339", "0.61265403", "0.6052867", "0.6048651", "0.6043439", "0.6034277", "0.6008626", ...
0.0
-1
Multi Fields generation in nested form > End
def create @dish = Dish.new(params[:dish]) if @dish.save redirect_to @dish, notice: 'Dish was successfully created.' else render action: "new" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nested_forms\n []\n end", "def nested_field_set(f, assoc, options = {})\n wrapper_partial = \"shared/nested_fields_wrapper\"\n options[:inner_partial] ||= \"#{f.object.class.model_name.route_key}/#{assoc.to_s.singularize}_fields\"\n options[:multiple] = true unless options.has_key?(:multiple)\n\...
[ "0.7029286", "0.6964953", "0.69032335", "0.65125805", "0.645006", "0.64157134", "0.634944", "0.634421", "0.62955743", "0.6256891", "0.62413335", "0.62315226", "0.6226325", "0.6188444", "0.6176591", "0.6129178", "0.6046312", "0.6026328", "0.60059804", "0.60059804", "0.5994267"...
0.0
-1
returns a chromosome object
def chromosome(id=nil) return if id.nil? begin self.chromosomes[id.intern] rescue end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chromosome_group\n chromosome[0]\n end", "def chromosomes\n # Cache for performance\n if @chromosomes.nil?\n s = Set.new\n self.each { |entry| s << entry.chr }\n @chromosomes = s.to_a\n end\n \n return @chromosomes\n end", "def new_rand_chrom\n ...
[ "0.69087785", "0.66675186", "0.6616339", "0.6476195", "0.6351701", "0.60748726", "0.58518857", "0.56697726", "0.56495184", "0.5591868", "0.5515572", "0.5507487", "0.54251176", "0.54151255", "0.5386429", "0.53572005", "0.53010887", "0.5288723", "0.52870905", "0.5265328", "0.52...
0.7262938
0
puts b Shows error, not initialized outside block
def some_method a = 4 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def b; end", "def b; end", "def run(b=new_toplevel)\n print self.result(b)\n end", "def b=(value)\n @b = value\n end", "def b\n return @b\n end", "def f(...
[ "0.629755", "0.629755", "0.6157741", "0.6142725", "0.59497166", "0.5856764", "0.576168", "0.576168", "0.57318705", "0.5727564", "0.57033414", "0.5675371", "0.5672679", "0.55991167", "0.5590924", "0.5554245", "0.55517817", "0.5549723", "0.5539023", "0.5527367", "0.5387455", ...
0.0
-1
Returns whether this is a new session or not.
def new? !!@new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_session?\n new_session != false\n end", "def new_session?\n new_session != false\n end", "def new_session?\n new_session != false\n end", "def session_is_new?\n session[:last_activity].nil?\n end", "def is_new\n @values.fetch('ai.session.isNe...
[ "0.9030406", "0.90066814", "0.9006021", "0.83690375", "0.7507616", "0.745895", "0.74235666", "0.7306285", "0.7297617", "0.72503334", "0.7155766", "0.71184665", "0.7114954", "0.7091365", "0.70851576", "0.70477134", "0.70157653", "0.7007417", "0.6987059", "0.69829917", "0.69824...
0.6540632
45
Returns true if a user is defined.
def user_defined? !@user.nil? || !@user['userId'].nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user?(name)\n eval(USER_CHECK, binding, __FILE__, USER_CHECK_LINE)\n nil\nend", "def custom?\n user_id.present? || is_a?(DSLDefined)\n end", "def has_user?\n !user.nil?\n end", "def user?\n get_mode == :user\n end", "def is_potential_user?\n\t\ttrue\n\tend", "def user_present?\n ...
[ "0.74699235", "0.72796094", "0.71275294", "0.71097934", "0.704967", "0.698266", "0.69224554", "0.69224554", "0.6908096", "0.6872325", "0.6848843", "0.6789121", "0.6716347", "0.66968864", "0.6690535", "0.66733754", "0.66626996", "0.665802", "0.66425085", "0.6585555", "0.656851...
0.8091406
0
Check to see if attributes are present.
def has_attributes? !@attributes.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes_exist?\n\tend", "def attributes?\n attributes.length > 0\n end", "def attributes_are_defined?\n # attributes are defined\n return false if @attributes == []\n @attributes.each do |a|\n return false unless a.class == RelationAttribute\n end\n ...
[ "0.78843075", "0.78615195", "0.77598435", "0.77466637", "0.7591995", "0.75661135", "0.750503", "0.74876285", "0.7455706", "0.7379565", "0.7358541", "0.7357248", "0.73470753", "0.7342278", "0.7333776", "0.73133004", "0.72984457", "0.72981244", "0.7277732", "0.7274257", "0.7272...
0.769052
4
before_action :check_user, only: [:show] GET /users GET /users.json
def index @users = User.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n check_user\n end", "def show\n # not_found unless @user\n # @user = User.get(params[:id]) || not_found\n # authorize! :show, @user\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @user }\n end\n end", "def show\n @user= se...
[ "0.75004846", "0.74206525", "0.73295814", "0.72252816", "0.70871323", "0.70750296", "0.70745564", "0.7061335", "0.70514286", "0.70405805", "0.7038469", "0.70378447", "0.7034503", "0.70309144", "0.7012312", "0.70060533", "0.69993234", "0.699672", "0.6991802", "0.6981788", "0.6...
0.0
-1
GET /users/1 GET /users/1.json
def show if current_user == @user @lender_loans = Loan.where(lender_id: @user) @p_count = 0 #count of pending loans @a_count = 0 #count of active loans @c_count = 0 #count of completed loans @lender_loans.each do |pending| if pending.status == "Pending" @p_count = @p_count + 1 end end @lender_loans.each do |active| if active.status == "Active" @a_count = @a_count + 1 end end @lender_loans.each do |completed| if completed.status == "Completed" @c_count = @c_count + 1 end end else redirect_to profile_path(current_user) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.722...
0.0
-1
POST /users POST /users.json
def create @user = User.new(user_params) return render action: 'new' unless @user.save client = Dwolla.new first_name = @user.first_name last_name = @user.last_name email = @user.email type = "personal" address = @user.address city = @user.city state = @user.state postal_code = @user.postal_code date_of_birth = @user.date_of_birth last_four_of_ssn = @user.last_four_of_ssn client.create_customer(first_name, last_name, email, type, address, city, state, postal_code, date_of_birth, last_four_of_ssn) redirect_to user_path(@user), notice: 'Created user' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post b...
[ "0.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69...
0.0
-1
PATCH/PUT /users/1 PATCH/PUT /users/1.json
def update respond_to do |format| if @user.update(user_params) format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { render :show, status: :ok, location: @user } else format.html { render :edit } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "de...
[ "0.72257185", "0.71295637", "0.7003568", "0.69038403", "0.68215626", "0.6815601", "0.67085636", "0.66936487", "0.6680699", "0.6673503", "0.6672789", "0.6664273", "0.6664273", "0.6659702", "0.6659702", "0.66541827", "0.66483825", "0.6643504", "0.6641462", "0.6635027", "0.66181...
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy @user.destroy respond_to do |format| format.html { redirect_to users_url, notice: 'User was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\...
[ "0.7875409", "0.7751816", "0.7713785", "0.76098853", "0.74721044", "0.74075884", "0.74075884", "0.7369372", "0.7346144", "0.7339956", "0.7328181", "0.7309978", "0.73097116", "0.73067564", "0.7297328", "0.72913545", "0.7291246", "0.72887707", "0.72839034", "0.72504604", "0.725...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.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
GET /songs/1 GET /songs/1.xml
def show @song = Song.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @song }\n end\n end", "def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :x...
[ "0.71872026", "0.71872026", "0.71872026", "0.69846314", "0.6810127", "0.6683843", "0.66091436", "0.6525814", "0.6518597", "0.6518597", "0.6518597", "0.6518597", "0.64852947", "0.6483567", "0.64577067", "0.6454189", "0.644389", "0.64423215", "0.6413461", "0.63756496", "0.63079...
0.64855474
13
GET /songs/new GET /songs/new.xml
def new @song = Song.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @song } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @tags_songs = TagsSongs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tags_songs }\n end\n end", "def new\n @song = @playlist.songs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: ...
[ "0.7286893", "0.7229135", "0.71294427", "0.71294427", "0.71294427", "0.71294427", "0.7113181", "0.7113181", "0.7089227", "0.7089227", "0.705693", "0.691341", "0.68660915", "0.66852117", "0.66736627", "0.6627354", "0.65915114", "0.6588537", "0.65839016", "0.65839016", "0.65839...
0.7696563
4
DSL for 0arity predicates
def <<(goals); TempClause.new(@db, self, []) << goals; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nonzero?() end", "def zero?()\n #This is a stub, used for indexing\n end", "def zero?() end", "def zero?() end", "def nonzero?; end", "def none?\n fail NotImplementedError\n end", "def none?; end", "def none?; end", "def none?; end", "def zero?; end", "def zero?; end", "def ...
[ "0.61447525", "0.6110208", "0.5971578", "0.5971578", "0.5879392", "0.58148926", "0.5774028", "0.5774028", "0.5774028", "0.57738477", "0.57738477", "0.5749259", "0.5728354", "0.57214344", "0.5711479", "0.5698141", "0.5668301", "0.5642106", "0.5608909", "0.5608909", "0.5608909"...
0.0
-1
=> Launch the Application
def run(argv = ARGV) # => Parse CLI Configuration cli = Options.new cli.parse_options(argv) # => Parse JSON Config File (If Specified and Exists) json_config = Util.parse_json_config(cli.config[:config_file] || Config.config_file) # => Grab the Default Values default = Config.options # => Merge Configuration (CLI Wins) config = [default, json_config, cli.config].compact.reduce(:merge) # => Apply Configuration Config.setup do |cfg| cfg.config_file = config[:config_file] cfg.cache_timeout = config[:cache_timeout].to_i cfg.bind = config[:bind] cfg.port = config[:port] cfg.environment = config[:environment].to_sym.downcase cfg.do_api_key = config[:do_api_key] end # => Launch the API API.run! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def launch_app\n @bridge.launch_app\n end", "def launch(app_name, *options)\n options = combine_options(*options)\n \n compatible_call :launch, app_name, options\n end", "def launch(app_name, *options)\n options = combine_options(*options)\n\n ensure_window = nil\n ...
[ "0.82850605", "0.7305946", "0.72759837", "0.7255567", "0.7212822", "0.7182324", "0.6942555", "0.6926906", "0.6914419", "0.6867765", "0.6804551", "0.67725134", "0.67444825", "0.67325157", "0.67190796", "0.66492176", "0.6647323", "0.6612465", "0.6612465", "0.6594305", "0.658039...
0.0
-1
=begin problem: Complete the function that takes an array of words. You must concatenate the nth letter from each word to construct a new word which should be returned as a string, where n is the position of the word in the list. =end
def nth_char(arr) arr.map.with_index { |word, idx| word[idx] }.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nth_char(words)\n final_word = []\n words.each_with_index { |word, index| \n final_word << word[index]\n }\n return final_word.join('')\nend", "def get_word\n @lettercollection.push(@string_as_array[@i])\n @lettercollection.join('')\nend", "def typoglycemiaWord(input)\n if input.lengt...
[ "0.7509894", "0.7119066", "0.70673037", "0.7008157", "0.70066255", "0.6972385", "0.69626737", "0.69122255", "0.68784577", "0.6859578", "0.6840821", "0.68321276", "0.6817684", "0.6811018", "0.68086755", "0.678137", "0.6767597", "0.6749509", "0.6749509", "0.6749509", "0.6736852...
0.70846355
2
creating method to pick a random word from the list of possible game words & phrases. this could be refactured to combine within above method but left as the assignment specification had it.
def gensecretword @wordtable.sample.gsub(/\s+/, "") # revoving all whitespaces as wordfile has phrases as possible secret words end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def selectWord\n\twords = [\n\t\t\"anvil\",\n\t\t\"black\",\n\t\t\"break\",\n\t\t\"clear\",\n\t\t\"doubt\",\n\t\t\"exist\",\n\t\t\"first\",\n\t\t\"girth\",\n\t\t\"heart\",\n\t\t\"icons\",\n\t\t\"joker\",\n\t\t\"loath\",\n\t\t\"mirth\",\n\t\t\"notch\",\n\t\t\"overt\",\n\t\t\"print\",\n\t\t\"qualm\",\n\t\t\"react\",...
[ "0.82101005", "0.8003725", "0.7924125", "0.7850692", "0.7797546", "0.7792975", "0.7689707", "0.76704293", "0.7669795", "0.759776", "0.75835365", "0.7569125", "0.75547206", "0.7539337", "0.7502712", "0.7484366", "0.7456372", "0.745609", "0.74144137", "0.7329093", "0.7324742", ...
0.0
-1
human readable description of modeling approach
def modeler_description return '' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end", "def modeler_description\n return \"Example use case is adding special loads like an elevator to a model as part of an analysis workflow\"\n end", "def m...
[ "0.7709673", "0.76146215", "0.7592412", "0.7400973", "0.7300466", "0.7296075", "0.72779685", "0.7191089", "0.71907765", "0.71907765", "0.70995873", "0.7096783", "0.70615566", "0.70446914", "0.704276", "0.703993", "0.7039482", "0.70320314", "0.7025324", "0.701749", "0.6986445"...
0.678705
51
define the arguments that the user will input
def arguments args = OpenStudio::Measure::OSArgumentVector.new # this measure does not require any user arguments, return an empty list return args end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def arguments; end", "def arguments; end", "def arguments; end", "def arguments\n \"\"\n end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end", "def args; end...
[ "0.73753476", "0.73753476", "0.73753476", "0.70890766", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301", "0.7008301",...
0.0
-1
define the outputs that the measure will create
def outputs outs = OpenStudio::Measure::OSOutputVector.new # this measure does not produce machine readable outputs with registerValue, return an empty list return outs end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def outputs \n result = OpenStudio::Measure::OSOutputVector.new\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('panel_rated_output') # w/m^2\n result << OpenStudio::Measure::OSOutput.makeDoubleOutput('panel_rated_output_ip') # w/ft^2\n result << OpenStudio::Measure::OSOutput.makeDoubleOutpu...
[ "0.7556974", "0.70015025", "0.68349844", "0.65264237", "0.63755965", "0.628786", "0.61429816", "0.6112792", "0.6083238", "0.60332656", "0.6021887", "0.60021985", "0.59786016", "0.59681743", "0.5928986", "0.5898399", "0.5887987", "0.5887987", "0.5887987", "0.5887987", "0.58879...
0.68907607
2
return a vector of IdfObject's to request EnergyPlus objects needed by the run method Warning: Do not change the name of this method to be snake_case. The method must be lowerCamelCase.
def energyPlusOutputRequests(runner, user_arguments) super(runner, user_arguments) result = OpenStudio::IdfObjectVector.new # use the built-in error checking if !runner.validateUserArguments(arguments, user_arguments) return result end request = OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Drybulb Temperature,Hourly;').get result << request return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def energyPlusOutputRequests(runner, user_arguments)\n super(runner, user_arguments)\n\n # use the built-in error checking\n if !runner.validateUserArguments(arguments, user_arguments)\n return result\n end\n\n result = OpenStudio::IdfObjectVector.new\n\n # request zone variables for the run...
[ "0.6318877", "0.6308563", "0.6292341", "0.6276216", "0.6094002", "0.6020391", "0.5965369", "0.5955979", "0.59372544", "0.5885784", "0.5860911", "0.58062977", "0.57539207", "0.56363034", "0.5428969", "0.540341", "0.53108454", "0.5246608", "0.5240743", "0.5231769", "0.52304673"...
0.5924496
9
define what happens when the measure is run
def run(runner, user_arguments) super(runner, user_arguments) # use the built-in error checking if !runner.validateUserArguments(arguments, user_arguments) return false end # get the last model and sql file model = runner.lastOpenStudioModel if model.empty? runner.registerError('Cannot find last model.') return false end model = model.get sql_file = runner.lastEnergyPlusSqlFile if sql_file.empty? runner.registerError('Cannot find last sql file.') return false end sql_file = sql_file.get model.setSqlFile(sql_file) output_manager = OutputManager.new(model, sql_file) output_manager.hydrate json_out = File.open("../loads_out.json", "w") json_out.write(output_manager.to_json) # close the sql file sql_file.close return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def measure; end", "def measure=(_arg0); end", "def measure\n\t\t1\n\tend", "def measure(*args, &b)\n end", "def communicate_measure_result(_ = nil, _ = nil); end", "def communicate_measure_result(_ = nil, _ = nil); end", "def called\n self.measurement.called\n end", "def measure\n ...
[ "0.7984654", "0.76391506", "0.7635997", "0.71696514", "0.6692245", "0.6692245", "0.6672187", "0.6630635", "0.6598557", "0.6587669", "0.65313715", "0.6481984", "0.6405212", "0.64018977", "0.63331616", "0.6284003", "0.6284003", "0.6284003", "0.6280883", "0.6269114", "0.6242129"...
0.0
-1
=> 5 Phase I First, write a function that compares each element to every other element of the list. Return the element if all other elements in the array are larger. What is the time complexity for this function? Phase II Now rewrite the function to iterate through the list just once while keeping track of the minimum. What is the time complexity? def largest_contiguous_subsum(list)0(n^3) new_arr = [] (0...list.length).each do |i| (i...list.length).each do |j| new_arr << list[i..j].sum end end new_arr.max end
def largest_contiguous_subsum(list) current_max = list[0] current_sum = list[0] (1...list.size).each do |i| current_sum += list[i] if current_sum > current_max current_max = current_sum end if current_sum < 0 current_sum = 0 end end current_max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def largest_contiguous_subsum_1(list)\n subs = []\n (0...list.length).each do |idx| #O(n)\n (idx...list.length).each do |idx_2| #O(n)\n subs << list[idx..idx_2] #O(n)\n end\n end\n max = list.first\n subs.each do |subarr|\n if subarr.sum > max\n max = suba...
[ "0.9269417", "0.9231172", "0.91395384", "0.91220176", "0.9090307", "0.90778863", "0.90721405", "0.9059933", "0.9048553", "0.9021661", "0.9000857", "0.8998376", "0.8998222", "0.89965117", "0.89892554", "0.89688325", "0.8960531", "0.8937953", "0.8935685", "0.89301443", "0.89031...
0.8877425
23
function2 ===> test no.2
def total_cash(petshop) return petshop[:admin][:total_cash] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_function2()\n 'ouch'\nend", "def method2() end", "def stest_method_1(test); end", "def two\n end", "def yet_another_func\r\n 18\r\n end", "def foo2(x)\n bar(x)\n end", "def xyz2\n\n end", "def sum2(n1, n2)\n puts n1+n2\nend", "def second_method(name_1, name_2)\n puts...
[ "0.7040361", "0.6511971", "0.6446112", "0.6443784", "0.61250985", "0.6123539", "0.61125404", "0.6106946", "0.60680604", "0.60140276", "0.6003924", "0.5933421", "0.5923851", "0.5880884", "0.5880179", "0.5857769", "0.58499277", "0.5846838", "0.5841441", "0.58226895", "0.5822637...
0.0
-1
function3 ===> tests no.3 & 4.
def add_or_remove_cash(petshop,cash) petshop[:admin][:total_cash] += cash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def three_and_5(number)\r\n \r\nend", "def func1 val #missing the symbols for arguments\r\n if val = 1 #missing 1 equal symbol.\r\n return true\r\n else\r\n return false\r\n end\r\nend", "def min_3(x, y, z)\nend", "def m3; 3 end", "def check_funcall (f)\nend", "def test\n\t\t@a+@b > @c && @a+@c > @...
[ "0.63424164", "0.5920216", "0.59028673", "0.588423", "0.5800671", "0.5777478", "0.5733854", "0.5730103", "0.57189965", "0.5676787", "0.5675387", "0.5674722", "0.56545454", "0.56521684", "0.5649689", "0.5616876", "0.56115955", "0.56103843", "0.5606925", "0.56060153", "0.559875...
0.0
-1
function5 ===> test no.5
def pets_sold(petshop) return petshop[:admin][:pets_sold] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def high_five; end", "def f5(x, x:); end", "def addFive(num)\n num + 5\nend", "def five\n return 5 # Some people choose to use the return statement just to be clear, \n end", "def by_five?(n)\n return n % 5 == 0\nend", "def five(number)\n number % 5 == 0 ? true : false\nend", "def by_five?(num)...
[ "0.68881714", "0.664261", "0.6531995", "0.649462", "0.64598274", "0.64357376", "0.6423189", "0.6418871", "0.6347563", "0.63415694", "0.6324647", "0.6319709", "0.629111", "0.6233271", "0.6202924", "0.61625344", "0.61592185", "0.6149848", "0.6146304", "0.61423147", "0.61381704"...
0.0
-1
function6 ===> test no.6
def increase_pets_sold(petshop,sold) petshop[:admin][:pets_sold]+=sold end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stest_method_1(test); end", "def bad_smell_by_nfunctions\n end", "def six\n square_of_sum(100) - sum_of_squares(100)\nend", "def v6?\n return v6\n end", "def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++;...
[ "0.60805726", "0.5982458", "0.597286", "0.58375", "0.5827457", "0.58069617", "0.57995415", "0.57995415", "0.5794804", "0.5748315", "0.56986994", "0.5657895", "0.5638173", "0.5520828", "0.5514025", "0.5509899", "0.5503745", "0.5488426", "0.5487556", "0.54803187", "0.5441254", ...
0.0
-1
function7 ===> test no.7
def stock_count(petshop) return petshop[:pets].size() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiple_of_7(num)\n num % 7 == 0\nend", "def bad_smell_by_nfunctions\n end", "def check_funcall (f)\nend", "def stest_method_1(test); end", "def high_five; end", "def test_function2()\n 'ouch'\nend", "def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n ...
[ "0.6374842", "0.60398775", "0.5972006", "0.58968633", "0.5895581", "0.5858507", "0.5851899", "0.58467114", "0.5822782", "0.5784375", "0.5767312", "0.5753044", "0.57227296", "0.571081", "0.56736726", "0.5634649", "0.5619564", "0.5570747", "0.5562352", "0.5551127", "0.55335116"...
0.0
-1
function8 ===> test no.8 & 9 using ".each"
def pets_by_breed(petshop,breed) pets=[] petshop[:pets].each do |pet| if pet[:breed] == breed pets.push(breed) end end return pets end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end", "def each(*) end", "def each(&block); end", "def each(&block); end", ...
[ "0.6608434", "0.6592421", "0.65745664", "0.65745664", "0.65745664", "0.65745664", "0.65745664", "0.65745664", "0.6443152", "0.637548", "0.637548", "0.637548", "0.637548", "0.637548", "0.637548", "0.637548", "0.637548", "0.637548", "0.637548", "0.637548", "0.6112291", "0.604...
0.0
-1
function9 ===> no.8 & 9 using "for loop"
def pets_by_breed(petshop,breed) pets=[] for pet in petshop[:pets] do if pet[:breed] == breed pets.push(breed) end end return pets end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def looper\n for i in 1..10\n return i\n end\nend", "def looper \r\n for i in 1..10\r\n puts i\r\n end\r\nend", "def looper\n for i in 1..10\n puts i\n end\nend", "def generateLoop2\n for i in 1...10 do #do optional\n puts i\n end\n end", "def func7\n arr = []\n for i in (0..9) d...
[ "0.6779122", "0.67550707", "0.67104614", "0.66926473", "0.6656659", "0.65270895", "0.6499904", "0.6495576", "0.64103496", "0.64103496", "0.64103496", "0.6312063", "0.62044024", "0.6197904", "0.61917573", "0.61780125", "0.61780125", "0.6070426", "0.6065542", "0.60293585", "0.5...
0.0
-1
function10 ===> test no.10 & 11 using ".each"
def find_pet_by_name(petshop,pet_name) petshop[:pets].each do if pet_hash[:name] == pet_name return pet_hash end end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end", "def each(*) end", "def each(&block); end", "def each(&block); end", ...
[ "0.66305876", "0.6582482", "0.6336903", "0.6336903", "0.6336903", "0.6336903", "0.6336903", "0.6336903", "0.6327795", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.63255477", "0.5...
0.0
-1
function11 answering to test no.10 and 11 using ".each"
def find_pet_by_name(petshop,pet_name) for pet_hash in petshop[:pets] do if pet_hash[:name] == pet_name return pet_hash end end return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_0010_each\n @@log.debug \"test_0010_each starts\" if @@log.debug?\n count = 0\n @list.each do |elt|\n count += 1\n end\n assert_equal(4, count)\n @@log.debug \"test_0010_each ends\" if @@log.debug?\n end", "def isbn10(isbn_array, isbn_number) #defines a function used to check a 1...
[ "0.6203731", "0.61079866", "0.6024744", "0.6020365", "0.58519197", "0.58336186", "0.5807084", "0.5807084", "0.57963276", "0.5780439", "0.5742017", "0.5737671", "0.5737671", "0.5737671", "0.57339376", "0.573385", "0.57212484", "0.5715685", "0.5701855", "0.56791925", "0.5653938...
0.0
-1
function13 ===> test no.13
def add_pet_to_stock(petshop,new_pet) petshop[:pets].push(new_pet) return petshop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def yet_another_func\r\n 18\r\n end", "def bad_smell_by_nfunctions\n end", "def p15\n\t\nend", "def a3()\n puts('123454')\nend", "def problem_14\nend", "def exercise_119 (number)\n end", "def method_12475663\n\nend", "def test_that_10_works\n assert_equal(true, funk_master(\"1234567...
[ "0.62322813", "0.61237425", "0.6097154", "0.5938337", "0.5909476", "0.5887184", "0.587739", "0.56158996", "0.56122303", "0.55790186", "0.5565156", "0.5563447", "0.55595183", "0.55380505", "0.5536725", "0.55009884", "0.55009884", "0.55009884", "0.54868233", "0.54649353", "0.54...
0.0
-1
function14 ===> test no.14
def customer_pet_count(customer) return customer[:pets].count() # return customer[:pets].length() # return customer[:pets].size() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def yet_another_func\r\n 18\r\n end", "def bad_smell_by_nfunctions\n end", "def problem_14\nend", "def test_function2()\n 'ouch'\nend", "def p15\n\t\nend", "def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-EOD\r\n void fun1(integer arg) {\r\n i = i++...
[ "0.6461965", "0.6421681", "0.6294361", "0.6123404", "0.6119711", "0.6095419", "0.6059656", "0.5884191", "0.5880202", "0.587424", "0.58327544", "0.58093905", "0.57898176", "0.5744506", "0.5723393", "0.571815", "0.5709012", "0.56760544", "0.5658918", "0.5658918", "0.5658918", ...
0.0
-1
...functions 14 attempts... attempt1 def customer_pet_count(customers) string="" for customer in customers do string+=customers[:pets].to_s end return string.to_i end attempt2 def customer_pet_count(customers) string_value=customers[:pets].to_s return string_value.to_i end attempt3 def customer_pet_count(customers) for customer in customers do return customers[:pets].to_s.to_i end end function15 ===> test no.15
def add_pet_to_customer(customer,new_pet) customer[:pets].push(new_pet[:pet_type]) return customer[:pets].count() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def customer_pet_count(customer)\n return customer[:pets].count()\n # return customer[:pets].length()\n # return customer[:pets].size()\n end", "def customer_pet_count(number)\n return number[:pets].count\nend", "def customer_pet_count(supplied_customer)\n return supplied_customer[:pets].length\nen...
[ "0.7764381", "0.7669291", "0.76637095", "0.7663579", "0.7645392", "0.7645392", "0.7618273", "0.7611017", "0.7607454", "0.7607454", "0.7606744", "0.75951016", "0.74921995", "0.7414525", "0.73596346", "0.728692", "0.7129551", "0.6684505", "0.6606899", "0.659277", "0.65199405", ...
0.5946747
54
OPTIONAL function16 ===> test no.16 & 17
def customer_can_afford_pet(customer,new_pet) customer[:cash] >= new_pet[:price] ? true : false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bad_smell_by_nfunctions\n end", "def conditionally(*) end", "def conditionally(*) end", "def p15\n\t\nend", "def stest_method_1(test); end", "def check_funcall (f)\nend", "def yet_another_func\r\n 18\r\n end", "def xxxtest_overloaded_functions\r\n length = initialize_length(\r\n <<-E...
[ "0.62424505", "0.5744811", "0.5744811", "0.57002884", "0.56974125", "0.5674824", "0.56678206", "0.5629981", "0.55861497", "0.54871476", "0.5477791", "0.54751116", "0.5471525", "0.5470599", "0.54658854", "0.5418365", "0.5362668", "0.5346376", "0.53306895", "0.5303516", "0.5302...
0.0
-1
function17 ===> test no.16 & 17
def customer_can_afford_pet(customer,new_pet) customer_cash=customer[:cash] @pet_shop[:pets].push(new_pet) for pet in @pet_shop[:pets] do if customer_cash >= pet[:price] return true else return false end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bad_smell_by_nfunctions\n end", "def three_and_5(number)\r\n \r\nend", "def yet_another_func\r\n 18\r\n end", "def p15\n\t\nend", "def functions\n\n end", "def stest_method_1(test); end", "def check_funcall (f)\nend", "def test; true; end", "def xxxtest_overloaded_functions\r\n length...
[ "0.62383884", "0.6220641", "0.6165646", "0.599516", "0.59046304", "0.5853994", "0.57610255", "0.5720108", "0.571919", "0.5699902", "0.5638538", "0.55419165", "0.5516256", "0.55126685", "0.5488994", "0.54596925", "0.5451892", "0.5430361", "0.54229474", "0.53785235", "0.5374746...
0.0
-1
Integration tests function18 for test no.1820
def sell_pet_to_customer(petshop,pet,customer) if (customer[:cash] >= pet[:price]) #&& (petshop[:pets][:name] == pet[:name]) customer[:pets].push(pet[:name]) end # return customer[:pets].count() end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def graffiti_test\n end", "def test_cases; end", "def test_function2()\n 'ouch'\nend", "def stest_method_1(test); end", "def running_test_case; end", "def tests; end", "def tests; end", "def testing\n # ...\n end", "def my_tests\n end", "def test_case; end", "def test_step; end",...
[ "0.6423968", "0.6356973", "0.6353363", "0.6257234", "0.6252131", "0.62388027", "0.62388027", "0.6235027", "0.62203115", "0.6206287", "0.6122316", "0.611179", "0.6097247", "0.6097247", "0.60902935", "0.60641396", "0.6047217", "0.6033881", "0.6018191", "0.6017146", "0.6017146",...
0.0
-1
Instructions: Create a function that takes a string and returns a string in which each character is repeated once.
def double_char(str) characters = [] str.split("").each do |x| characters << x*2 end p characters.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repeater(str)\n repeated_str = ''\n\n str.each_char do |char|\n repeated_str << char * 2\n end\n\n repeated_str\nend", "def repeater(string)\n new_string = ''\n string.chars.each do |char|\n 2.times { new_string << char }\n end\n new_string\nend", "def repeater(string)\n string.chars.map do ...
[ "0.82889843", "0.8127127", "0.8047757", "0.7999656", "0.7944132", "0.7913355", "0.781617", "0.7799636", "0.77930003", "0.77930003", "0.7761988", "0.77335757", "0.7730579", "0.77258474", "0.77258474", "0.77258474", "0.77258474", "0.77258474", "0.77220994", "0.7715247", "0.7713...
0.0
-1
GET /favorite_tweets GET /favorite_tweets.json
def index @favorite_tweets = FavoriteTweet.where(:user => session[:user_id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def favorite_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::FavoriteTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::FavoriteTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(crea...
[ "0.7687445", "0.7336894", "0.7269229", "0.72110707", "0.7145635", "0.7080381", "0.7061777", "0.699663", "0.6964348", "0.69222003", "0.691475", "0.6902407", "0.68968076", "0.686262", "0.68007827", "0.6799856", "0.6792255", "0.6792255", "0.6792255", "0.6792255", "0.6792255", ...
0.7241433
3
GET /favorite_tweets/1 GET /favorite_tweets/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def favorite_tweets\n logger.debug { \"#{__method__} is called twitter_user_id=#{id}\" }\n tweets = []\n tweets = InMemory::FavoriteTweet.find_by(uid) if InMemory.enabled? && InMemory.cache_alive?(created_at)\n tweets = Efs::FavoriteTweet.where(uid: uid) if tweets.blank? && Efs::Tweet.cache_alive?(crea...
[ "0.74497986", "0.7217033", "0.7212017", "0.71911246", "0.7177048", "0.70935404", "0.70396423", "0.7016141", "0.70106065", "0.69962627", "0.6890951", "0.6883632", "0.6850413", "0.6797372", "0.67810524", "0.6780074", "0.67399305", "0.67399305", "0.67399305", "0.67399305", "0.67...
0.0
-1
POST /favorite_tweets POST /favorite_tweets.json
def create @favorite_tweet = FavoriteTweet.new(favorite_tweet_params) respond_to do |format| if @favorite_tweet.save format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully created.' } format.json { render action: 'show', status: :created, location: @favorite_tweet } else format.html { render action: 'new' } format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n user = user_from_token\n @tweet = user.tweets.new()\n @tweet.tweet = params[:tweet]\n if @tweet.save\n render :json => @tweet, :status => :created\n else\n render :json => @tweet.errors, :status => :unprocessable_entity\n end\n end", "def create_favorite(id)\n post \"...
[ "0.71963686", "0.69921327", "0.69658303", "0.68816566", "0.68612856", "0.685439", "0.68041986", "0.6791777", "0.6752056", "0.6720362", "0.67200935", "0.669575", "0.669575", "0.6688767", "0.66724735", "0.6639043", "0.65915155", "0.658637", "0.65502", "0.6545046", "0.6530948", ...
0.7433148
0
PATCH/PUT /favorite_tweets/1 PATCH/PUT /favorite_tweets/1.json
def update respond_to do |format| if @favorite_tweet.update(favorite_tweet_params) format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @favorite_tweet.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @tweet = Tweet.find(params[:id])\n\n respond_to do |format|\n if @tweet.update_attributes(params[:tweet])\n format.html { redirect_to @tweet, notice: 'Tweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit...
[ "0.6960678", "0.6960678", "0.6960678", "0.69604725", "0.69222766", "0.69034183", "0.6883614", "0.68249536", "0.6781655", "0.6781655", "0.6781655", "0.6781655", "0.6761557", "0.675751", "0.67472273", "0.67472273", "0.67472273", "0.6719685", "0.6706669", "0.67002296", "0.668918...
0.75267
0
DELETE /favorite_tweets/1 DELETE /favorite_tweets/1.json
def destroy TwitterSyncWorker.new.delete(session[:user_id], @favorite_tweet.id) @favorite_tweet.destroy respond_to do |format| format.html { redirect_to request.referer } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n user = user_from_token\n user.tweets.destroy(params[:id])\n head :no_content\n end", "def destroy\n @interesting_tweet.destroy\n respond_to do |format|\n format.html { redirect_to interesting_tweets_url }\n format.json { head :no_content }\n end\n end", "def destroy\...
[ "0.73611623", "0.7237081", "0.72364336", "0.72051394", "0.72051394", "0.71854454", "0.71765554", "0.714541", "0.7023002", "0.70183814", "0.69963676", "0.6993292", "0.69846225", "0.6979157", "0.69612306", "0.6947594", "0.6946989", "0.6946989", "0.6946989", "0.6946989", "0.6946...
0.7240167
1
Use callbacks to share common setup or constraints between actions.
def set_favorite_tweet @favorite_tweet = FavoriteTweet.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
Never trust parameters from the scary internet, only allow the white list through.
def favorite_tweet_params params[:favorite_tweet] 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.69811666", "0.6782836", "0.6747644", "0.6742015", "0.6735273", "0.6593917", "0.65037674", "0.6498627", "0.6482372", "0.64795715", "0.64566946", "0.6439213", "0.6380714", "0.6378147", "0.63657266", "0.63206697", "0.6300169", "0.62992156", "0.6295538", "0.62943023", "0.62915...
0.0
-1
jobs Show recent and running jobs. l, limit LIMITJOBS Limit the number of jobs returned (defaults to 10) s, skip SKIPJOBS Skip a certain amount of jobs (defaults to 0) Examples: List the last 20 jobs: $ mortar jobs l 20
def index validate_arguments! options[:limit] ||= '10' options[:skip] ||= '0' jobs = api.get_jobs(options[:skip], options[:limit]).body['jobs'] jobs.each do |job| if job['start_timestamp'] job['start_timestamp'] = Time.parse(job['start_timestamp']).strftime('%A, %B %e, %Y, %l:%M %p') end end headers = [ 'job_id', 'script' , 'status' , 'start_date' , 'elapsed_time' , 'cluster_size' , 'cluster_id'] columns = [ 'job_id', 'display_name', 'status_description', 'start_timestamp', 'duration', 'cluster_size', 'cluster_id'] display_table(jobs, columns, headers) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jobs(opts = {})\n api(\n @client.list_jobs(\n @project_id,\n deep_symbolize_keys(opts)\n )\n )\n end", "def get_jobs_list(status = :all, page = 1, reload = false)\n Bitmovin::Job.list(status, page, reload)\n end", "def jobs\n command('.j...
[ "0.7115468", "0.7035529", "0.69772846", "0.6892695", "0.6824405", "0.68047684", "0.6725643", "0.6671638", "0.66124475", "0.659958", "0.6595867", "0.65953207", "0.6593811", "0.654509", "0.65241235", "0.6510012", "0.6495486", "0.6466259", "0.64655596", "0.6454251", "0.64518386"...
0.6439239
21
jobs:status JOB_ID Check the status of a job. p, poll Poll the status of a job
def status job_id = shift_argument unless job_id error("Usage: mortar jobs:status JOB_ID\nMust specify JOB_ID.") end # Inner function to display the hash table when the job is complte def display_job_status(job_status) job_display_entries = { "status" => job_status["status_description"], "progress" => "#{job_status["progress"]}%", "cluster_id" => job_status["cluster_id"], "job submitted at" => job_status["start_timestamp"], "job began running at" => job_status["running_timestamp"], "job finished at" => job_status["stop_timestamp"], "job running for" => job_status["duration"], "job run with parameters" => job_status["parameters"], } unless job_status["error"].nil? || job_status["error"]["message"].nil? error_context = get_error_message_context(job_status["error"]["message"]) unless error_context == "" job_status["error"]["help"] = error_context end job_status["error"].each_pair do |key, value| job_display_entries["error - #{key}"] = value end end if job_status["num_hadoop_jobs"] && job_status["num_hadoop_jobs_succeeded"] job_display_entries["hadoop jobs complete"] = '%0.2f / %0.2f' % [job_status["num_hadoop_jobs_succeeded"], job_status["num_hadoop_jobs"]] end if job_status["outputs"] && job_status["outputs"].length > 0 job_display_entries["outputs"] = Hash[job_status["outputs"].select{|o| o["alias"]}.collect do |output| output_hash = {} output_hash["location"] = output["location"] if output["location"] output_hash["records"] = output["records"] if output["records"] [output['alias'], output_hash] end] end styled_header("#{job_status["project_name"]}: #{job_status["pigscript_name"]} (job_id: #{job_status["job_id"]})") styled_hash(job_display_entries) end # If polling the status if options[:poll] ticking(polling_interval) do |ticks| job_status = api.get_job(job_id).body # If the job is complete exit and display the table normally if Mortar::API::Jobs::STATUSES_COMPLETE.include?(job_status["status_code"] ) redisplay("") display_job_status(job_status) break end # If the job is running show the progress bar if job_status["status_code"] == Mortar::API::Jobs::STATUS_RUNNING progressbar = "=" + ("=" * (job_status["progress"].to_i / 5)) + ">" if job_status["num_hadoop_jobs"] && job_status["num_hadoop_jobs_succeeded"] hadoop_jobs_ratio_complete = '%0.2f / %0.2f' % [job_status["num_hadoop_jobs_succeeded"], job_status["num_hadoop_jobs"]] end printf("\r[#{spinner(ticks)}] Status: [%-22s] %s%% Complete (%s MapReduce jobs finished)", progressbar, job_status["progress"], hadoop_jobs_ratio_complete) # If the job is not complete, but not in the running state, just display its status else redisplay("[#{spinner(ticks)}] Status: #{job_status['status_description']}") end end # If not polling, get the job status and display the results else job_status = api.get_job(job_id).body display_job_status(job_status) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def status(*job_id)\n #take default job_id if not specified\n if job_id.empty?\n job_id = @job_id\n else\n job_id = job_id[0]\n end\n\n \n url=\"#{@base_url}/#{@tool}/status/#{URI.encode(job_id)}\"\n uri = URI.parse(url)\n\n resp = Net::HTTP.get_response(uri)\n ...
[ "0.7153619", "0.7117048", "0.71071595", "0.7082527", "0.69060886", "0.6898863", "0.6862939", "0.6821774", "0.6779827", "0.67699057", "0.67117155", "0.6661498", "0.6643092", "0.6625317", "0.6611041", "0.65927327", "0.6582257", "0.64325106", "0.64257914", "0.6416165", "0.641616...
0.60737044
32
Inner function to display the hash table when the job is complte
def display_job_status(job_status) job_display_entries = { "status" => job_status["status_description"], "progress" => "#{job_status["progress"]}%", "cluster_id" => job_status["cluster_id"], "job submitted at" => job_status["start_timestamp"], "job began running at" => job_status["running_timestamp"], "job finished at" => job_status["stop_timestamp"], "job running for" => job_status["duration"], "job run with parameters" => job_status["parameters"], } unless job_status["error"].nil? || job_status["error"]["message"].nil? error_context = get_error_message_context(job_status["error"]["message"]) unless error_context == "" job_status["error"]["help"] = error_context end job_status["error"].each_pair do |key, value| job_display_entries["error - #{key}"] = value end end if job_status["num_hadoop_jobs"] && job_status["num_hadoop_jobs_succeeded"] job_display_entries["hadoop jobs complete"] = '%0.2f / %0.2f' % [job_status["num_hadoop_jobs_succeeded"], job_status["num_hadoop_jobs"]] end if job_status["outputs"] && job_status["outputs"].length > 0 job_display_entries["outputs"] = Hash[job_status["outputs"].select{|o| o["alias"]}.collect do |output| output_hash = {} output_hash["location"] = output["location"] if output["location"] output_hash["records"] = output["records"] if output["records"] [output['alias'], output_hash] end] end styled_header("#{job_status["project_name"]}: #{job_status["pigscript_name"]} (job_id: #{job_status["job_id"]})") styled_hash(job_display_entries) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def info_hash\n puts \"monitor{#@id} - jobs statuses: \"\n @j_hash.each do |key, value|\n puts \"#{key} : #{value}\"\n end\n puts \"-------------------------------\"\n end", "def output_hash; end", "def status\n job_id = shift_argument\n unless job_id\n error(\"Usage: m...
[ "0.6631238", "0.6258912", "0.6101561", "0.5896043", "0.58573925", "0.58538145", "0.58102214", "0.5682262", "0.5674862", "0.56625235", "0.56623787", "0.56602186", "0.5655557", "0.5626425", "0.56256115", "0.5615027", "0.56135696", "0.56107056", "0.5602099", "0.5602099", "0.5594...
0.5888107
4
jobs:stop JOB_ID Stop a running job.
def stop job_id = shift_argument unless job_id error("Usage: mortar jobs:stop JOB_ID\nMust specify JOB_ID.") end response = api.stop_job(job_id).body #TODO: jkarn - Once all servers have the additional message field we can remove this check. if response['message'].nil? display("Stopping job #{job_id}.") else display(response['message']) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop(options = {})\n # set :stopping\n info \"stopping job\"\n unsubscribe\n kill if options[:force]\n end", "def kill_job(job_id)\n __push([], :kill_job, job_id)\n end", "def job_stopped? job=@current_job\n return false unless job and j...
[ "0.73273987", "0.7175865", "0.71753585", "0.71748996", "0.6982509", "0.6982509", "0.6942156", "0.67249715", "0.6706788", "0.6540835", "0.65160674", "0.6445151", "0.643705", "0.64167774", "0.63927066", "0.6387198", "0.63614136", "0.635167", "0.6337637", "0.633173", "0.6301892"...
0.8248524
0
GET /favourite_foods/1 GET /favourite_foods/1.json
def show @favourite_food = FavouriteFood.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @favourite_food } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end", "def show\n @favourite_listing = get_favourite_listing(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @favourite_listing }\n end\n end", "def get_favou...
[ "0.84989434", "0.7063839", "0.7056084", "0.7033001", "0.70282334", "0.69767", "0.697556", "0.6894857", "0.6857454", "0.68488467", "0.67617226", "0.66966665", "0.66960293", "0.66952133", "0.6692517", "0.6680044", "0.66745186", "0.66721827", "0.66412985", "0.66412985", "0.66392...
0.7635762
1
GET /favourite_foods/new GET /favourite_foods/new.json
def new @favourite_food = FavouriteFood.new respond_to do |format| format.html # new.html.erb format.json { render json: @favourite_food } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @fav = Fav.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fav }\n end\n end", "def new\n @favorite = Favorite.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @favorite }\n end\n ...
[ "0.7602866", "0.74826956", "0.74777085", "0.7373788", "0.73180306", "0.72258997", "0.72258997", "0.71241575", "0.7093327", "0.70832", "0.70824677", "0.7039349", "0.69641525", "0.69337416", "0.6918807", "0.69062984", "0.6884498", "0.6866088", "0.68614453", "0.6861139", "0.6858...
0.78515697
0
POST /favourite_foods POST /favourite_foods.json
def create @favourite_food = FavouriteFood.new(params[:favourite_food]) respond_to do |format| if @favourite_food.save format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully created.' } format.json { render json: @favourite_food, status: :created, location: @favourite_food } else format.html { render action: "new" } format.json { render json: @favourite_food.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end", "def add_favorite_food(food_id)\n post(\"/user/#{@user_id}/foods/log/favorite/#{food_id}.json\")\n end", "def mark_favourite\n @favourite_artist = FavouriteArtist.where(spotify_id: params[:spotify_id]).first_or_c...
[ "0.7474016", "0.72381335", "0.68717104", "0.67320657", "0.67147535", "0.6686058", "0.6683381", "0.66759866", "0.66702694", "0.66301703", "0.6624711", "0.6616305", "0.6553704", "0.64493114", "0.64317966", "0.6424552", "0.6421776", "0.64178", "0.63654524", "0.6352685", "0.63417...
0.7219231
2
PUT /favourite_foods/1 PUT /favourite_foods/1.json
def update @favourite_food = FavouriteFood.find(params[:id]) respond_to do |format| if @favourite_food.update_attributes(params[:favourite_food]) format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @favourite_food.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end", "def update\n json_response(@food_item.update!(food_item_params))\n end", "def update\n respond_to do |format|\n if @favory.update(favory_params)\n format.html { redirect_to @favory, notice: \"Fav...
[ "0.7014924", "0.67057246", "0.6702148", "0.66944414", "0.66811377", "0.667469", "0.666159", "0.6640309", "0.6587724", "0.6557583", "0.65235865", "0.64982474", "0.64741874", "0.64741874", "0.64584434", "0.64584434", "0.64584434", "0.63933563", "0.6358495", "0.6343483", "0.6337...
0.6960666
1
DELETE /favourite_foods/1 DELETE /favourite_foods/1.json
def destroy @favourite_food = FavouriteFood.find(params[:id]) @favourite_food.destroy respond_to do |format| format.html { redirect_to favourite_foods_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_favorite_food(food_id)\n delete(\"/user/#{@user_id}/foods/favorite/#{food_id}.json\")\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def ...
[ "0.7427092", "0.7296844", "0.7296844", "0.70963365", "0.7025781", "0.70044833", "0.69768685", "0.6970896", "0.6966709", "0.6951589", "0.69415987", "0.6933586", "0.6929641", "0.6925296", "0.69223464", "0.692048", "0.6912096", "0.69096017", "0.6908586", "0.68933874", "0.6893387...
0.7730022
0
use before filter to validate authenticity
def create sent_email = SentEmail.find_by_slug(params[:s]) Event.create_from_api!(:category => "email", :type => params[:event].try(:titleize), :prospect_id => sent_email.prospect_id, :sent_email_id => sent_email.id) head :created end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def any_authenticity_token_valid?; end", "def verify_authenticity_token; end", "def verify_authenticity_token\n if auth_token_param.present?\n verify_valid_auth_token!\n else\n super\n end\n end", "def form_authenticity_param; end", "def verify_authenticity_token\n verified_reque...
[ "0.696648", "0.69142133", "0.6748593", "0.6724684", "0.6712404", "0.66588014", "0.6544405", "0.64587235", "0.6415576", "0.6415576", "0.6372786", "0.6349039", "0.6349039", "0.6327784", "0.6327461", "0.6254966", "0.6254722", "0.62340516", "0.6218359", "0.619184", "0.6170809", ...
0.0
-1
GET /shops/1 GET /shops/1.xml
def show @user = User.find(params[:user_id]) @shop = Shop.find(params[:id]) redirect_to user_shop_products_path(:user_id => @user, :shop_id => @shop) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @hops_addition = HopsAddition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @hops_addition }\n end\n end", "def show\n @shops_favorite = ShopsFavorite.find(params[:id])\n\n respond_to do |format|\n format.html #...
[ "0.6238221", "0.61808896", "0.61581135", "0.614906", "0.60675645", "0.6041577", "0.60405374", "0.6007169", "0.6007169", "0.6007169", "0.6007169", "0.6007169", "0.5956732", "0.59397095", "0.5939524", "0.59149855", "0.58711517", "0.58564293", "0.5843357", "0.5841318", "0.583804...
0.0
-1
GET /shops/new GET /shops/new.xml
def new @shop = Shop.new @user = User.find(params[:user_id]) # @categories =Category.find(:all, :conditions => { :parent_id => nil}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @shop = Shop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @shop }\n end\n end", "def new\n @hops_addition = HopsAddition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hops_add...
[ "0.70002466", "0.68457824", "0.6811468", "0.6742787", "0.6641042", "0.66259116", "0.66259116", "0.6603827", "0.6557197", "0.6501302", "0.64788455", "0.6448646", "0.6429665", "0.6394656", "0.63940257", "0.63940257", "0.63940257", "0.6389104", "0.6389104", "0.6389104", "0.63891...
0.0
-1
POST /shops POST /shops.xml
def create @user = User.find(params[:user_id]) @shop = Shop.new(params[:shop]) @shop.user = @user @shop.status = 1 respond_to do |format| if @shop.save flash[:notice] = "您的店铺己激活#{params[:category_id]}=shop#{params[:shop][:category_id]}。" format.html { redirect_to control_path(:user_id => @shop.user) } else format.html { render :action => "new" } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @shop = @shops.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: \"Shop was successfully created.\" }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render ...
[ "0.6073832", "0.57361233", "0.5615422", "0.5612782", "0.5589205", "0.5582772", "0.5566365", "0.55600804", "0.55398667", "0.5537808", "0.55039555", "0.5498018", "0.5498018", "0.54216623", "0.54216623", "0.5421615", "0.5402898", "0.53979045", "0.5373297", "0.5363733", "0.535158...
0.0
-1
PUT /shops/1 PUT /shops/1.xml
def update @shop = Shop.find(params[:id]) @user = @shop.user respond_to do |format| if @shop.update_attributes(params[:shop]) flash[:notice] = 'Shop was successfully updated.' format.html { redirect_to userhome_path(:user_id => @user) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @shop.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def upd...
[ "0.6442686", "0.6177593", "0.57824564", "0.5660673", "0.56010354", "0.5593099", "0.5546171", "0.5471413", "0.545599", "0.54085034", "0.54083234", "0.539672", "0.53673124", "0.535751", "0.53493255", "0.5347734", "0.53435487", "0.53432304", "0.5343018", "0.53414613", "0.5339738...
0.5278759
29
DELETE /shops/1 DELETE /shops/1.xml
def destroy @shop = Shop.find(params[:id]) @shop.destroy respond_to do |format| format.html { redirect_to(admin_shops_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete()\n response = send_post_request(@xml_api_delete_path)\n response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)\n end", "def destroy\n @repairshop = Repairshop.find(params[:id])\n @repairshop.destroy\n\n respond_to do |format|\n format.html { redirect_to(re...
[ "0.65141165", "0.6476739", "0.6475688", "0.6457269", "0.6414871", "0.6388637", "0.6360673", "0.6348651", "0.6323372", "0.6276365", "0.6236237", "0.6235271", "0.623514", "0.6194304", "0.6172855", "0.6166707", "0.6166707", "0.61563534", "0.6146716", "0.612103", "0.6108715", "...
0.6776488
0
Note When giving a block to this helper, use <%. Otherwise, use <%=
def flash_display(flash_type, &block) message = flash_message_for(flash_type) return '' if message.nil? marked_up_message = build_flash_display(message) (block_given?) ? wrap_flash(marked_up_message, flash_type, &block) : %Q[<div id="flash_#{flash_type}">#{marked_up_message}</div>] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html\n #this is a way to create longer strings in place easily.\n x = <<DELIM\n<html>\n<body>\n#{yield}\n</body>\n</html>\nDELIM\nend", "def render(context)\n # Sanitize the code inside the block\n resolve_code = super.to_s.gsub(/\\A(\\n|\\r)+|(\\n|\\r)+\\z/, \"\")\n \n # Invoke...
[ "0.6574328", "0.6565752", "0.65264815", "0.64930767", "0.6360935", "0.6347731", "0.62378734", "0.62313664", "0.62101454", "0.61420566", "0.61019504", "0.6092712", "0.6082125", "0.6030616", "0.6028208", "0.6025939", "0.6020808", "0.5966871", "0.5965985", "0.59492224", "0.59479...
0.0
-1
Returns the metaclass or eigenclass so that i can dynamically add class methods to active record models
def metaclass class << self; self end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metaclass\n class << self; self; end;\n end", "def metaclass\n class << self; self end\n end", "def meta_eval\n metaclass.instance_eval\n end", "def metametaclass; self.metaclass.metaclass; end", "def metaclass\n class << self\n self\n end\n end", "def metaclass\n class << ...
[ "0.7443653", "0.736564", "0.73096275", "0.7266055", "0.7168175", "0.7168175", "0.7155354", "0.7136638", "0.71214074", "0.71214074", "0.6859118", "0.68331546", "0.6738636", "0.6725199", "0.6725199", "0.6720037", "0.662257", "0.6601476", "0.65788364", "0.6539718", "0.65267575",...
0.70322067
11
the most important part
def re_define_class_method(name, &block) #klass = self.to_s metaclass.instance_eval do undef_method(name) if method_defined?(name) define_method(name, &block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def offences_by; end", "def first; end", "def first; end", "def probers; end", "def first?; end", "def schubert; end", "def suivre; end", "def first() end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def offences_by=(_arg0); end", "def who_we_are\r\n end...
[ "0.67971194", "0.677613", "0.677613", "0.6759582", "0.6559737", "0.6454681", "0.6317848", "0.62660635", "0.62423116", "0.62423116", "0.62423116", "0.62423116", "0.62187135", "0.62176746", "0.6162741", "0.6160375", "0.6093518", "0.6093518", "0.5998459", "0.5995323", "0.5980306...
0.0
-1
the most important part
def alias_class_method(new_name, old_name) #klass = self.to_s metaclass.instance_eval do alias_method new_name, old_name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def offences_by; end", "def first; end", "def first; end", "def probers; end", "def first?; end", "def schubert; end", "def suivre; end", "def first() end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def offences_by=(_arg0); end", "def who_we_are\r\n end...
[ "0.67971194", "0.677613", "0.677613", "0.6759582", "0.6559737", "0.6454681", "0.6317848", "0.62660635", "0.62423116", "0.62423116", "0.62423116", "0.62423116", "0.62187135", "0.62176746", "0.6162741", "0.6160375", "0.6093518", "0.6093518", "0.5998459", "0.5995323", "0.5980306...
0.0
-1
++ Call all necessary methods to convert a string of HTML into Textile markup.
def to_textile headings(@workingcopy) structure(@workingcopy) text_formatting(@workingcopy) entities(@workingcopy) tables(@workingcopy) @workingcopy = CGI::unescapeHTML(@workingcopy) @workingcopy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_markup_textile(text); end", "def convert_html(text)\n auto_html text do\n html_escape :map => {\n '&' => '&amp;',\n '>' => '&gt;',\n '<' => '&lt;',\n '\"' => '\"'\n }\n image\n youtube :width => 510, :height => 332\n vimeo :width => 510, :height =>...
[ "0.7921789", "0.71427923", "0.7081709", "0.6979907", "0.69110125", "0.6898772", "0.67728746", "0.6702057", "0.66206914", "0.65856284", "0.65273196", "0.6499709", "0.6467193", "0.64440393", "0.63703775", "0.6330149", "0.6281741", "0.6262261", "0.6204559", "0.6200194", "0.61998...
0.60097146
35
def create_self(keys) if keys and keys != None
def __tkvariable_optkeys super() << 'listvariable' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new(keys)\n to_ary == keys ? self : self.class.new(keys)\n end", "def initialize(left_keys, right_keys)\n @left_keys = left_keys\n @right_keys = right_keys\n\n @map = join_key_map\n end", "def create_key(arg = nil)\n set_or_return(\n :create_key,\n ...
[ "0.62678665", "0.60088927", "0.58794594", "0.58340746", "0.57857406", "0.57857406", "0.57188386", "0.57139456", "0.57139456", "0.5679811", "0.5597602", "0.557066", "0.55679655", "0.55502874", "0.5540782", "0.55354774", "0.55298954", "0.550549", "0.54759586", "0.54719937", "0....
0.0
-1
Emit our attribute values as a line of CSVs
def to_csv nombre_completo << " - " << debe end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_csv\n attributes = %w{id email name course_ids major_title created_at}\n \n CSV.generate(headers: true) do |csv|\n csv << attributes\n csv << attributes.map{ |attr| self.send(attr) }\n end\n end", "def to_csv\n self.all.to_promise.then do |all|\n io...
[ "0.71113497", "0.7096309", "0.661558", "0.65616846", "0.6488295", "0.64558345", "0.63784313", "0.6370484", "0.6339045", "0.6316517", "0.6316517", "0.62874985", "0.62566775", "0.6248133", "0.6228902", "0.6189181", "0.6157887", "0.6132368", "0.61217993", "0.6103656", "0.6100651...
0.56636155
61
Constructs an instance of Padrino::PathRouter::Compiler
def initialize(routes) @routes = routes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Router\", 1)\n else\n reset!\n end\n end", "def compile\n Tipsy::Runners::Compiler.new(@args, @site)\n end", "def mkcompiler source=''\n VishCompiler.new source\nend", "d...
[ "0.6617182", "0.63980216", "0.62864166", "0.6168754", "0.6168754", "0.61174935", "0.6088863", "0.5981532", "0.597832", "0.5890744", "0.5830917", "0.5811533", "0.5811146", "0.57788706", "0.5757336", "0.5754809", "0.5747623", "0.5712318", "0.563797", "0.5606646", "0.5567982", ...
0.0
-1
Compiles all routes into regexps.
def compile! return if compiled? @routes.each_with_index do |route, index| route.index = index route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/ end @compiled = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end", "def compile\n ...
[ "0.8115772", "0.7071185", "0.7014843", "0.6735203", "0.6690873", "0.64595294", "0.62049437", "0.6125483", "0.61136585", "0.61121184", "0.61121184", "0.6107773", "0.60939205", "0.6033074", "0.59805006", "0.5959296", "0.59400547", "0.59196824", "0.59196824", "0.59196824", "0.59...
0.7659134
1
Returns true if all routes has been compiled.
def compiled? !!@compiled end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty?\n @routes.empty?\n end", "def any_empty_routing?\n self.empty?(self, \"routings\", false)\n end", "def built?\n Namespace.root.executed_blueprints.include?(self)\n end", "def routing_params?\n routing_params.any?\n end", "def routing_params?\n routing_p...
[ "0.671087", "0.65421283", "0.63469076", "0.60441524", "0.60304177", "0.5986562", "0.5969123", "0.5889682", "0.58432394", "0.58432394", "0.5822604", "0.58051395", "0.5800606", "0.57533544", "0.5716744", "0.5689925", "0.56418836", "0.5616786", "0.5600265", "0.5600265", "0.55954...
0.62956077
4
Finds routes by using request or env.
def find_by(request_or_env) request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env pattern = decode_pattern(request.path_info) verb = request.request_method rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def route(env)\n routes.each do |route|\n return route if route.match(env)\n end\n\n nil\n end", "def find_route(request)\n @routes.find {|r| r.match?(request) }\n end", "def find_route(routes, request)\n transport = request.websocket? ? 'WS' : 'HTTP'\n routes.match(r...
[ "0.7627223", "0.74200827", "0.7418732", "0.721284", "0.7113679", "0.70978194", "0.6911638", "0.67903876", "0.6689333", "0.6689333", "0.66392386", "0.6619604", "0.6610928", "0.65896064", "0.6587124", "0.65777093", "0.6553928", "0.6553928", "0.65202415", "0.647904", "0.6425076"...
0.77067447
0
Calls routes by using request.
def call_by_request(request) rotation do |offset| pattern = decode_pattern(request.path_info) if route = match?(offset, pattern) params = route.params_for(pattern, request.params) yield(route, params) if route.verb == request.request_method route end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def route() request.route end", "def routes\n request :get, '/routes'\n end", "def route!(request)\n @@request = request\n @@routes.each do |route|\n if route.first == request.path\n return route.last.call\n break\n end\n end\n end", "...
[ "0.7804204", "0.7695202", "0.7332975", "0.7323927", "0.72675323", "0.7197363", "0.70404977", "0.69913316", "0.6950314", "0.6933684", "0.68899107", "0.68899107", "0.68702203", "0.6848445", "0.6842834", "0.6825233", "0.6780787", "0.67286074", "0.67237717", "0.66959727", "0.6691...
0.73251754
3
Finds routes by using PATH_INFO.
def find_by_pattern(pattern) pattern = decode_pattern(pattern) rotation { |offset| match?(offset, pattern) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recognize_path(path_info)\n prepare! unless prepared?\n route = @engine.find_by_pattern(path_info).first\n [route.name, route.params_for(path_info, {})]\n end", "def recognize_path(path_info)\n route, params = recognize(Rack::MockRequest.env_for(path_info)).first\n [route....
[ "0.7454343", "0.72434527", "0.6600313", "0.65620273", "0.65375525", "0.65008414", "0.6498602", "0.6491022", "0.6232778", "0.6200488", "0.61655927", "0.6153882", "0.6104795", "0.60673475", "0.60335666", "0.5991156", "0.5972602", "0.5970464", "0.5961672", "0.5954706", "0.593720...
0.0
-1
Returns a instance of PathRouter::Route if path is matched with current regexp
def match?(offset, path) @routes[offset..-1].find do |route| route.regexp === path || (path.end_with?("/") && route.regexp === path[0..-2]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_for(path)\n @routes.select { |rt| rt.match?(path) }.first\n end", "def match(path, method)\n path = StringUtils.normalize_path(path)\n\n @routes[method.to_sym].each{|r| \n case r[0]\n when Regexp\n if data = r[0].match(path)\n return r, data\n en...
[ "0.7349533", "0.67221475", "0.667222", "0.6633995", "0.66129345", "0.66046774", "0.6552336", "0.6493807", "0.6399288", "0.63146263", "0.62720984", "0.62518644", "0.6239918", "0.6239918", "0.6216776", "0.6210377", "0.62056637", "0.6177853", "0.61745334", "0.61745334", "0.61736...
0.63866186
9
Runs through all regexps to find routes.
def rotation(offset = 0) compile! unless compiled? loop.with_object([]) do |_, candidacies| return candidacies unless route = yield(offset) candidacies << route offset = route.index.next end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_routes\n matching_routes\n end", "def each(*args)\n routes.each(*args)\n end", "def routes\n routes_method.call\n end", "def each\n @routes.each do |rt|\n yield rt\n end\n self\n end", "def routes(&block); end", "def routes(&block); end", "def rout...
[ "0.731993", "0.67177325", "0.65614885", "0.65394974", "0.6522915", "0.6522915", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63694364", "0.63645214", "0.6329907", "0.63205886", "...
0.0
-1
Encode string with Encoding.default_external
def encode_default_external(string) string.encode(Encoding.default_external) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def external_encoding\n Encoding.default_external\n end", "def string_encoder\n return string if string.valid_encoding?\n str = string\n Encoding.list.each do |e|\n begin\n str.force_encoding(e.name)\n tmp_string = str.encode('UTF-8')\n return tmp_string if tm...
[ "0.75890625", "0.7542044", "0.7473844", "0.7416969", "0.73306304", "0.7306955", "0.7156714", "0.70741445", "0.70741445", "0.7058213", "0.70472217", "0.70415145", "0.7039941", "0.7026714", "0.69621706", "0.6928945", "0.6855664", "0.68282866", "0.6804509", "0.6754842", "0.67507...
0.8961825
0
Decode uri escape sequences
def decode_uri(string) string.split(/%2F|%2f/, -1).map { |part| Rack::Utils.unescape(part) }.join('%2F') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unescape_uri(uri); end", "def decode_uri(uri)\n return uri unless uri\n CGI::unescape(uri)\n end", "def process_uri(uri)\n URI.parse(URI.escape(URI.unescape(uri)))\n end", "def process_uri(uri)\n URI.parse(URI.escape(URI.unescape(uri)))\n end", "def uri_...
[ "0.7888991", "0.76751953", "0.7377986", "0.7377986", "0.7302313", "0.7176729", "0.7032956", "0.6931313", "0.6842274", "0.66753316", "0.66569096", "0.66569096", "0.65852684", "0.6547811", "0.6443195", "0.64291817", "0.63833445", "0.6372182", "0.6342235", "0.6263125", "0.625113...
0.7497991
2
uisti sa, ze sa na tento produkt neodkazuju ziadne polozky
def ensure_not_referenced_by_any_line_item if line_items.empty? return true else errors.add(:base, 'Existuju polozky') return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def zuruecksetzen()\n end", "def mi_carrera\n\n\tend", "def nacti_data(data, pomer)\n poc_nactenych_klauzuli = 0 \n pole_radku = data.split(\"\\n\")\n \n pole_radku.each do |radek|\n if(radek[0]!=\"c\")then #preskakuji komentar\n pole_hodnot = radek.split(' ') # ...
[ "0.6882641", "0.6487756", "0.62509865", "0.62468296", "0.6132075", "0.6107403", "0.60560375", "0.5961454", "0.5881994", "0.58724505", "0.58693266", "0.5839062", "0.5838738", "0.58377206", "0.58095086", "0.57931495", "0.578898", "0.5776171", "0.57430786", "0.57404333", "0.5699...
0.0
-1
after entering login credentials, see if we can't authenticate the user. if not, present them a message and redirect back to the login page. On success, remember them in the session.
def login user = User.find_by_userid(params[:session][:userid]) if user && user.authenticate(params[:session][:password]) session[:remember_token] = user.id session[:last_seen] = Time.now if user.authorizationlevel == 1 redirect_to '/documents' elsif user.authorizationlevel == 2 redirect_to '/documents' elsif user.authorizationlevel > 2 redirect_to '/documents' else redirect_to '/' end else flash[:error] = 'Invalid Login' redirect_to '/sessions' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate_user\n unless logged_in?\n store_location\n redirect_to new_session_url\n flash[:info] = \"You must be authenticated to perform this action.\"\n end\n end", "def authenticate_login\n if session[:user].nil? #There's definitely no user logged in\n flash[:notice] = \"<div c...
[ "0.77564836", "0.77532744", "0.7543252", "0.7472004", "0.7447287", "0.7388099", "0.73638034", "0.7356388", "0.7333298", "0.73331183", "0.73003006", "0.72960305", "0.7268579", "0.7268159", "0.7256869", "0.7255079", "0.72422075", "0.7228445", "0.7227032", "0.72177845", "0.72100...
0.0
-1
Remove the user from the session and send them to the home page.
def logout session[:remember_token] = nil session[:last_seen] = nil redirect_to '/' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n # Remove the user id from the session\n @_current_user = session[:current_user_id] = nil\n # @_current_user = session[:email] = nil\n redirect_to root_url\n end", "def destroy\n # when session is destroyed, it is empty\n \tsession[:user_id] = nil \n # redirect ...
[ "0.7877501", "0.78695405", "0.7802991", "0.7750761", "0.77169764", "0.7704763", "0.77002597", "0.7698789", "0.76759464", "0.76523733", "0.76475424", "0.7632359", "0.76097924", "0.760768", "0.75990623", "0.7571205", "0.755414", "0.7550515", "0.7543335", "0.7540896", "0.7525574...
0.0
-1
The list of users the bot shares a server with.
def users gateway_check unavailable_servers_check @users end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shares\n @users.map { |u| u.share }.uniq\n end", "def all_users\n\t\tshared_users.map(&:id).join(\", \")\n\tend", "def clients\n clis = []\n url = prefix + \"listc\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n clis << ShareUser.new(u[\"id...
[ "0.7453593", "0.7089753", "0.68664044", "0.6681071", "0.66530734", "0.65349287", "0.65217024", "0.6470246", "0.6450175", "0.6442677", "0.6370006", "0.63691556", "0.6362759", "0.633017", "0.633017", "0.6301922", "0.6262014", "0.6259862", "0.6259451", "0.6254173", "0.62533486",...
0.6338713
13
The list of servers the bot is currently in.
def servers gateway_check unavailable_servers_check @servers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def servers\n servers_for\n end", "def servers\n @servers.keys\n end", "def servers\n servers_by_name.values\n end", "def list_known_servers\n connect.servers.all\n end", "def servers\r\n @servers.values\r\n end", "def servers\n @servers ||= ex...
[ "0.8201467", "0.8065964", "0.80123717", "0.79888934", "0.7987453", "0.79544026", "0.7818131", "0.78065455", "0.78065455", "0.78004616", "0.77382463", "0.7703609", "0.761837", "0.75812453", "0.7504051", "0.7484996", "0.7484996", "0.74728686", "0.74665624", "0.7406516", "0.7329...
0.7339068
20
Finds an emoji by its name.
def find_emoji(name) LOGGER.out("Resolving emoji #{name}") emoji.find { |element| element.name == name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_emoji?(emoji)\n Emoji.find_by_name emoji\n end", "def find_emoji(key, server = nil)\n server = server || $bot.servers[SERVER_ID] || $bot.servers.first\n return if server.nil?\n if key.is_a?(Integer)\n server.emojis[key]\n elsif key.is_a?(String)\n server.emojis.find{ |id, e| e.name.do...
[ "0.66077566", "0.6356576", "0.6225231", "0.6219515", "0.61103976", "0.6058261", "0.60096383", "0.59947395", "0.5861071", "0.58036435", "0.57789695", "0.57694024", "0.56958956", "0.5695522", "0.567858", "0.5659555", "0.56351364", "0.55797064", "0.5572729", "0.55421966", "0.552...
0.9117262
0
The bot's OAuth application.
def bot_application return unless @type == :bot response = API.oauth_application(token) Application.new(JSON.parse(response), self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oauth_application(token)\n request(\n __method__,\n :get,\n \"#{api_base}/oauth2/applications/@me\",\n Authorization: token\n )\n end", "def connection_for_application\n oauth_client.client_credentials.get_token\n end", "def oauth\n ::OAuth::Consumer.new(Config.con...
[ "0.73693085", "0.68700224", "0.6803141", "0.67447376", "0.6739837", "0.6615489", "0.65903246", "0.653939", "0.6537453", "0.65316194", "0.6479371", "0.6466731", "0.644376", "0.6442134", "0.6422361", "0.64063597", "0.6399454", "0.6356976", "0.6350804", "0.6334928", "0.6330561",...
0.80125487
0
Joins the bot's connection thread with the current thread. This blocks execution until the websocket stops, which should only happen manually triggered. or due to an error. This is necessary to have a continuously running bot.
def join @gateway.sync end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_async\n # Handle heartbeats\n @heartbeat_interval = 1\n @heartbeat_active = false\n @heartbeat_thread = Thread.new do\n Thread.current[:discordrb_name] = 'heartbeat'\n loop do\n if @heartbeat_active\n send_heartbeat\n sleep @heartbeat_interva...
[ "0.6952133", "0.69457245", "0.66505915", "0.60932404", "0.6073879", "0.59758526", "0.5974482", "0.58934724", "0.5839568", "0.5815858", "0.5810771", "0.5776136", "0.5776136", "0.5699954", "0.56866944", "0.5628136", "0.56168985", "0.5523956", "0.54936826", "0.54846007", "0.5476...
0.50323856
99
Stops the bot gracefully, disconnecting the websocket without immediately killing the thread. This means that Discord is immediately aware of the closed connection and makes the bot appear offline instantly.
def stop(_no_sync = nil) @gateway.stop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop!\n @connections.each do |connection|\n puts \" -> stopping '#{connection.connection_id}'\"\n connection.disconnect\n end\n\n SweetieBot.log 'Stopped.'\n end", "def stop!\n return unless running?\n @logger.info 'Stopping WebSocket server'\n @client_mutex.synchronize do...
[ "0.7357848", "0.7296975", "0.72584254", "0.7149089", "0.700618", "0.68498033", "0.67867374", "0.665966", "0.6564098", "0.6564098", "0.6564098", "0.6457363", "0.6405716", "0.64038056", "0.6369088", "0.6361477", "0.6351509", "0.6326374", "0.6321919", "0.63198364", "0.6319712", ...
0.0
-1
Creates an OAuth invite URL that can be used to invite this bot to a particular server.
def invite_url(server: nil, permission_bits: nil) @client_id ||= bot_application.id server_id_str = server ? "&guild_id=#{server.id}" : '' permission_bits_str = permission_bits ? "&permissions=#{permission_bits}" : '' "https://discord.com/oauth2/authorize?&client_id=#{@client_id}#{server_id_str}#{permission_bits_str}&scope=bot" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invite_url(server = nil)\n raise 'No application ID has been set during initialization! Add one as the `application_id` named parameter while creating your bot.' unless @application_id\n\n guild_id_str = server ? \"&guild_id=#{server.id}\" : ''\n \"https://discordapp.com/oauth2/authorize?&client...
[ "0.79358506", "0.61601734", "0.6140274", "0.61311567", "0.58596253", "0.57606685", "0.5688839", "0.5661156", "0.56575847", "0.56151354", "0.5590863", "0.5566705", "0.5547112", "0.5542738", "0.5537466", "0.5521269", "0.55186635", "0.54998434", "0.5499122", "0.5492385", "0.5456...
0.7333291
1
Sends a text message to a channel given its ID and the message's content.
def send_message(channel, content, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil) channel = channel.resolve_id debug("Sending message to #{channel} with content '#{content}'") allowed_mentions = { parse: [] } if allowed_mentions == false message_reference = { message_id: message_reference.id } if message_reference.respond_to?(:id) response = API::Channel.create_message(token, channel, content, tts, embed&.to_hash, nil, attachments, allowed_mentions&.to_hash, message_reference, components) Message.new(JSON.parse(response), self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_text(text)\n client.api.send_message(id, text)\n end", "def send_message(channel_id, content, tts = false, server_id = nil)\n channel_id = channel_id.resolve_id\n debug(\"Sending message to #{channel_id} with content '#{content}'\")\n\n response = API.send_message(token, channel_i...
[ "0.76900965", "0.7490646", "0.7319742", "0.70011264", "0.69512475", "0.69056547", "0.69046086", "0.6835208", "0.68224615", "0.67920786", "0.67674214", "0.66974646", "0.65345925", "0.6489949", "0.6481413", "0.6451904", "0.64484125", "0.64401484", "0.64359456", "0.6412115", "0....
0.6538457
12
Sends a text message to a channel given its ID and the message's content, then deletes it after the specified timeout in seconds.
def send_temporary_message(channel, content, timeout, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil) Thread.new do Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg" message = send_message(channel, content, tts, embed, attachments, allowed_mentions, message_reference, components) sleep(timeout) message.delete end nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_temporary_message(channel_id, content, timeout, tts = false, server_id = nil)\n Thread.new do\n message = send_message(channel_id, content, tts, server_id)\n\n sleep(timeout)\n\n message.delete\n end\n\n nil\n end", "def send_message(channel, content, opts = {})\n ...
[ "0.7993938", "0.6187552", "0.60455555", "0.60313004", "0.5957131", "0.589204", "0.5685615", "0.56358874", "0.56257606", "0.56028855", "0.5564914", "0.55448204", "0.5540462", "0.552262", "0.5519717", "0.5516406", "0.5515432", "0.5468322", "0.54659766", "0.541653", "0.5413082",...
0.71656483
1
Sends a file to a channel. If it is an image, it will automatically be embedded.
def send_file(channel, file, caption: nil, tts: false, filename: nil, spoiler: nil) if file.respond_to?(:read) if spoiler filename ||= File.basename(file.path) filename = "SPOILER_#{filename}" unless filename.start_with? 'SPOILER_' end # https://github.com/rest-client/rest-client/blob/v2.0.2/lib/restclient/payload.rb#L160 file.define_singleton_method(:original_filename) { filename } if filename file.define_singleton_method(:path) { filename } if filename end channel = channel.resolve_id response = API::Channel.upload_file(token, channel, file, caption: caption, tts: tts) Message.new(JSON.parse(response), self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_file(path); end", "def send_file(token, channel_id, file, caption: nil, tts: false)\n request(\n __method__,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages\",\n { file: file, content: caption, tts: tts },\n Authorization: token\n )\n end", "def send_file(chann...
[ "0.72900164", "0.72698545", "0.7137879", "0.69675636", "0.68549645", "0.66866946", "0.65693897", "0.649217", "0.64434123", "0.63217616", "0.6277791", "0.6217847", "0.62096065", "0.61116534", "0.6031926", "0.60135734", "0.5973319", "0.5952479", "0.5935816", "0.5908261", "0.588...
0.73033434
0
Creates a server on Discord with a specified name and a region.
def create_server(name, region = :'eu-central') response = API::Server.create(token, name, region) id = JSON.parse(response)['id'].to_i sleep 0.1 until (server = @servers[id]) debug "Successfully created server #{server.id} with name #{server.name}" server end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_server(name, region = :london)\n response = API.create_server(token, name, region)\n id = JSON.parse(response)['id'].to_i\n sleep 0.1 until @servers[id]\n server = @servers[id]\n debug \"Successfully created server #{server.id} with name #{server.name}\"\n server\n end",...
[ "0.83683974", "0.6795294", "0.6512631", "0.65120524", "0.6255154", "0.6223555", "0.6218063", "0.6204458", "0.61825794", "0.61438614", "0.60822433", "0.6000227", "0.599413", "0.59688234", "0.59676874", "0.5899694", "0.58654946", "0.5799056", "0.57472765", "0.5745482", "0.56975...
0.84140956
0
Creates a new application to do OAuth authorization with. This allows you to use OAuth to authorize users using Discord. For information how to use this, see the docs:
def create_oauth_application(name, redirect_uris) response = JSON.parse(API.create_oauth_application(@token, name, redirect_uris)) [response['id'], response['secret']] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_oauth_application(token, name, redirect_uris)\n request(\n __method__,\n :post,\n \"#{api_base}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris }.to_json,\n Authorization: token,\n content_type: :json\n )\n end", "def create_oauth_application(to...
[ "0.69873273", "0.69873273", "0.69777524", "0.6779362", "0.6778442", "0.6722473", "0.672169", "0.66975766", "0.66803485", "0.65305084", "0.62695473", "0.6241559", "0.62196136", "0.62072706", "0.6128522", "0.6127108", "0.60710514", "0.6049424", "0.5999127", "0.5996503", "0.5982...
0.7000048
0
Changes information about your OAuth application
def update_oauth_application(name, redirect_uris, description = '', icon = nil) API.update_oauth_application(@token, name, redirect_uris, description, icon) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_oauth_application\n @oauth_application = Doorkeeper::Application.find(params[:oauth_application_id])\n end", "def update_tokens(oauth_params)\n# binding.pry\n self.oauth_token = oauth_params.credentials.token\n # facebook, google provide this; twitter, linkedin don't\n self.oauth_expi...
[ "0.6815656", "0.6455423", "0.6445419", "0.6440646", "0.6397283", "0.63802683", "0.63802683", "0.6377169", "0.6307532", "0.619249", "0.6080465", "0.60581374", "0.604027", "0.60270953", "0.6023665", "0.5967876", "0.5941198", "0.5936568", "0.5898632", "0.5898611", "0.58880067", ...
0.66020274
1
Gets the users, channels, roles and emoji from a string.
def parse_mentions(mentions, server = nil) array_to_return = [] # While possible mentions may be in message while mentions.include?('<') && mentions.include?('>') # Removing all content before the next possible mention mentions = mentions.split('<', 2)[1] # Locate the first valid mention enclosed in `<...>`, otherwise advance to the next open `<` next unless mentions.split('>', 2).first.length < mentions.split('<', 2).first.length # Store the possible mention value to be validated with RegEx mention = mentions.split('>', 2).first if /@!?(?<id>\d+)/ =~ mention array_to_return << user(id) unless user(id).nil? elsif /#(?<id>\d+)/ =~ mention array_to_return << channel(id, server) unless channel(id, server).nil? elsif /@&(?<id>\d+)/ =~ mention if server array_to_return << server.role(id) unless server.role(id).nil? else @servers.each_value do |element| array_to_return << element.role(id) unless element.role(id).nil? end end elsif /(?<animated>^a|^${0}):(?<name>\w+):(?<id>\d+)/ =~ mention array_to_return << (emoji(id) || Emoji.new({ 'animated' => !animated.nil?, 'name' => name, 'id' => id }, self, nil)) end end array_to_return end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_discord_user(msg)\n user = msg[NAME_PATTERN, 2].downcase\n raise OutteError.new \"You need to provide a user.\" if user.nil?\n\n parts = user.split('#')\n users = User.search(parts[0], !parts[1].nil? ? parts[1] : nil)\n case users.size\n when 0\n raise OutteError.new \"No user named #{user} foun...
[ "0.55238605", "0.53596246", "0.51066905", "0.5099445", "0.5085582", "0.5076298", "0.50474715", "0.50464326", "0.5017118", "0.5015652", "0.5014232", "0.49684095", "0.4908837", "0.48872346", "0.48647833", "0.4846756", "0.48458117", "0.48421288", "0.4820095", "0.47685167", "0.47...
0.5310083
2
Gets the user, channel, role or emoji from a string.
def parse_mention(mention, server = nil) parse_mentions(mention, server).first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_discord_user(msg)\n user = msg[NAME_PATTERN, 2].downcase\n raise OutteError.new \"You need to provide a user.\" if user.nil?\n\n parts = user.split('#')\n users = User.search(parts[0], !parts[1].nil? ? parts[1] : nil)\n case users.size\n when 0\n raise OutteError.new \"No user named #{user} foun...
[ "0.5832218", "0.5755608", "0.57496285", "0.5570609", "0.5467127", "0.53940785", "0.53851926", "0.5309725", "0.5282062", "0.5227845", "0.5220234", "0.5148466", "0.5141419", "0.5109705", "0.51054627", "0.5098822", "0.5064514", "0.5039539", "0.50152624", "0.50080794", "0.4988408...
0.47010303
49
Sets the currently playing game to the specified game.
def game=(name) gateway_check update_status(@status, name, nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_game\n @game = Game.find(params[:game_id] || params[:id])\n end", "def set_game\n @game = Game.find(params[:game_id] ||= params[:id])\n end", "def set_game\n @game = Game.find(params[:id])\n end", "def set_game\n @game = Game.find(params[:id])\n end", "def se...
[ "0.778316", "0.77164775", "0.7599855", "0.7599855", "0.7590458", "0.7547372", "0.7547372", "0.7547372", "0.7547372", "0.7505413", "0.7444924", "0.7390804", "0.73714924", "0.73710436", "0.73702544", "0.73702544", "0.73702544", "0.73702544", "0.73702544", "0.73702544", "0.73702...
0.6583807
96
Sets the current listening status to the specified name.
def listening=(name) gateway_check update_status(@status, name, nil, nil, nil, 2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def watching=(name)\n gateway_check\n update_status(@status, name, nil, nil, nil, 3)\n end", "def set_listening\n @listening = Listening.find(params[:id])\n end", "def name=(name)\n update_channel_data(name: name)\n end", "def competing=(name)\n gateway_check\n update_s...
[ "0.69050187", "0.59569013", "0.58567226", "0.57740796", "0.5582599", "0.5478112", "0.545065", "0.541106", "0.53516525", "0.5338427", "0.53139347", "0.52941483", "0.52941483", "0.528751", "0.52463466", "0.5237454", "0.5224092", "0.5213483", "0.5198355", "0.5149401", "0.5138815...
0.86877954
0