query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
decrypt the twitter oauth token and secret and return them
def decrypt_with(password) token = Justbot::Crypto.decrypt( self.crypted_twitter_token, password, self.iv_twitter_token ) secret = Justbot::Crypto.decrypt( self.crypted_twitter_secret, password, self.iv_twitter_secret ) ...
[ "def secret\n decrypt_secret\n end", "def get_OAuthTokenSecret()\n \t return @outputs[\"OAuthTokenSecret\"]\n \tend", "def decrypt_api_secret\n @api_secret_d = @client_api_detail.decrypted_api_secret\n success\n end", "def get_OAuthTokenSecret()\n \t return @outputs[\"O...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We will rebuild the syntax info from the beginning of the file to the end of the current line TODO This will be extremely slow find a better way
def rebuild_syntax @syntax = [] line = [] current = '' text = buffer.data CodeRay.scan_stream(text, filetype) do |k, a| if a==:space || a==:plain || a==:content || a==:comment then k.each_char do |c| if c=="\n" then unless current.empty? then current.symbol_type = ...
[ "def start_line_syntax_for_editor(file_name, line_number); end", "def process_line(line, index)\n\n # there should be a check for interpolation here, and just run a simple replace for each line\n\n if !indented?(line)\n $context = $root\n add_selector_or_property(line, index)\n # check here for @import...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method to publish an article, must change the stage of the article and then, redirect to the article
def publish @article.publish! redirect_to @article end
[ "def publish\n @article = Article.find params[:id]\n @version = @article.versions.last\n @version.published = true\n if @article.save and @version.save\n append_flash :notice, \"Article was successfully published\", true\n redirect_to admin_article_path @article\n else\n append_flash :...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
test whether the transition is allowed; if yes, transit to next state
def transit_state(signal) permitted_transitions = transitions[signal.to_sym] unless permitted_transitions.nil? next_state = permitted_transitions[state] # if current state is not explicitly permitted, is any state (referred by '*') permitted? next_state = permitted_transitions['*'] unless nex...
[ "def can_walk_to?(transition); end", "def transition_if_valid! *args\n trans = valid_transitions *args\n trans = trans.size == 1 ? trans.first : nil\n queue_transition!(trans, args) if trans\n trans\n end", "def valid_transition?(target_state)\n transitions[target_state].include?(sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /map_areas/1 PUT /map_areas/1.xml
def update @map_area = MapArea.find(params[:id]) respond_to do |format| if @map_area.update_attributes(params[:map_area]) flash[:notice] = 'MapArea was successfully updated.' format.html { redirect_to map_areas_path } format.xml { head :ok } else format.html { render...
[ "def update\n @area_map = AreaMap.find(params[:id])\n\n respond_to do |format|\n if @area_map.update_attributes(params[:area_map])\n flash[:notice] = 'AreaMap was successfully updated.'\n format.html { redirect_to :action=>:show,:id=>@area_map.id }\n format.xml { head :ok }\n el...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /map_areas/1 DELETE /map_areas/1.xml
def destroy @map_area = MapArea.find(params[:id]) @map_area.destroy respond_to do |format| format.html { redirect_to(map_areas_url) } format.xml { head :ok } end end
[ "def destroy\n @area_map = AreaMap.find(params[:id])\n @area_map.destroy\n\n respond_to do |format|\n format.html { redirect_to(area_maps_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @map = Map.find(params[:id])\n @map.destroy\n\n respond_to do |format|\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Processes incoming Sms messages Executes and logs control ones, stores others
def process_incoming @logger.debug("Processing incoming.") # Incoming messages msgs = @phone.messages msgs.each do |msg| @logger.info("Incoming Sms: #{msg.to_s}.") @logger.debug(msg.inspect) sms = ISms.new({ :number => msg.number, ...
[ "def process_msgs\n end", "def process_messages\n execute_sql_query(\n 'select * from messages where processed = 0 and direction = \\'in\\';'\n ).each do |msg|\n execute_sql_statement(\n 'update messages set processed = \\'1\\' ' \\\n \"where id = '#{msg[0]}';\"\n )\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /schools_users/1 GET /schools_users/1.xml
def show @schools_user = SchoolsUser.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @schools_user } end end
[ "def index\n @user = User.find(session[:user_id])\n @schools = @user.schools\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @schools }\n end\n end", "def new\n @schools_user = SchoolsUser.new\n @schools = current_user.ladmin.schools\n respond_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /schools_users/new GET /schools_users/new.xml
def new @schools_user = SchoolsUser.new @schools = current_user.ladmin.schools respond_to do |format| format.html # new.html.erb format.xml { render :xml => @schools_user } end end
[ "def new\n @user = User.new\n\n respond_to do |format|\n format.xml { render xml: @user}\n end\n end", "def new\n logger.debug(\"Create a new user\")\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @user }\n end\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /schools_users POST /schools_users.xml
def create @schools_user = SchoolsUser.new(params[:schools_user]) @schools_user.user = current_user respond_to do |format| if @schools_user.save format.html { redirect_to(schools_users_path, :notice => 'Schools user was successfully created.') } format.xml { render :xml => @schools_us...
[ "def signup\n @portal_student = Portal::Student.new\n @security_questions = SecurityQuestion.fill_array\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_student }\n end\n end", "def signup\n @student = Portal::Student.new\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /schools_users/1 PUT /schools_users/1.xml
def update @schools_user = SchoolsUser.find(params[:id]) respond_to do |format| if @schools_user.update_attributes(params[:schools_user]) format.html { redirect_to(schools_users_path, :notice => 'Schools user was successfully updated.') } format.xml { head :ok } else format...
[ "def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end", "def update\n @user_school = UserSchool.find(params[:i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /schools_users/1 DELETE /schools_users/1.xml
def destroy @schools_user = SchoolsUser.find(params[:id]) @schools_user.destroy respond_to do |format| format.html { redirect_to(schools_users_url) } format.xml { head :ok } end end
[ "def delete\n @user = User.find(params[:id])\n @user.rvsps.delete_all()\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @studentuser = Studentuser.find(params[:id])\n @studentuser.destroy\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /ubicacion_laborales GET /ubicacion_laborales.json
def index @ubicacion_laborales = UbicacionLaboral.all end
[ "def index\n @laboratorios = Laboratorio.all\n end", "def index\n @carga_laboratorios = CargaLaboratorio.all\n end", "def show\n @laboratorio = Laboratorio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @laboratorio }\n end\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /ubicacion_laborales/1 DELETE /ubicacion_laborales/1.json
def destroy @ubicacion_laboral.destroy respond_to do |format| format.html { redirect_to ubicacion_laborales_url, notice: 'Ubicacion laboral was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n \n @laboratorio.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end", "def destroy\n @laboratorio = Laboratorio.find(params[:id])\n @laboratorio.destroy\n\n respond_to do |forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if entry exists, passing an active record model and the name of the candidate or campaign
def entry_exists?(model, name) bool = false model.each do |hash| hash.each do |k, v| if v == name bool = true end end end bool end
[ "def record_found?(model)\n !model.nil? && !model.id.nil?\n end", "def include?(model)\n exists?(model.id)\n end", "def model_exists?(model_type, name)\n get_model(model_type, name) != nil\n end", "def model_exists? name\n name = ruby_to_oo name\n reflection_model.where(:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instantiates a new chatMessageMentionedIdentitySet and sets the default values.
def initialize() super @odata_type = "#microsoft.graph.chatMessageMentionedIdentitySet" end
[ "def initialize()\n super\n @odata_type = \"#microsoft.graph.sharePointIdentitySet\"\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.teamworkConversationIdentity\"\n end", "def initialize()\n su...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Declaration of Sinatra setup
def setup Sinatra::Base.set :environment, :test end
[ "def app() Sinatra::Application end", "def initialize_server(port)\r\n set :port, port # Specify Port For Sinatra Server\r\n set :bind, \"0.0.0.0\" # Allow Ping From External Devices\r\n set :environment, :production # Allow External Nodes To Query Websocket\r\n set :run, true # Start Sinatra Server\r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets up a Sinatra::Base subclass defined with the block given. Used in setup or individual spec methods to establish the application.
def mock_app(base=Sinatra::Base, &block) @app = Sinatra.new(base, &block) end
[ "def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end", "def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end", "def make_app(&blk)\n handler = Class.new(TestApp)\n handler.class_eval(&blk)\n handler\nend", "def setup\n Si...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Flexible method to test the ERB output. Accepts custom :layout & :url options passed. ==== Examples erb_app "" body.should == 'some result' body.should have_tag(:some_tag) NB! the custom URL must be declared in the MyTestApp in order to work erb_app "", :url => "/customerburl" last_request.path_info.should == "/custome...
def erb_app(view, options = {}) options = {:layout => '<%= yield %>', :url => '/tests' }.merge(options) get options[:url], :view => view, :layout => options[:layout], :engine => :erb end
[ "def haml_app(view, options = {}) \n options = {:layout => '= yield ', :url => '/tests' }.merge(options)\n get options[:url], :view => view, :layout => options[:layout], :engine => :haml \n end", "def test_render_erb_route\n # Requesting the htmlPage page of the application.\n request =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Flexible method to test the HAML output ==== Examples haml_app "= some_method('value')" body.should == 'some result' body.should have_tag(:some_tag) NB! the custom URL must be declared in the MyTestApp in order to work haml_app "= 'customhamlurl'.upcase", :url => "/customhamlurl" last_request.path_info.should == "/cust...
def haml_app(view, options = {}) options = {:layout => '= yield ', :url => '/tests' }.merge(options) get options[:url], :view => view, :layout => options[:layout], :engine => :haml end
[ "def haml\n # needed to use haml with erb\n unless is_haml?\n init_haml_helpers\n end\n\n capture_haml do\n yield\n end\n end", "def using_haml?\n Gem.loaded_specs.keys.include?('haml')\n end", "def is_haml?\n false\n end", "def have_a_page_title(expected) \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Checks for the presence of an organisation associated to a user and creates one if none exists
def create_organisation_if_none_exists(user) # rubocop:disable Style/GuardClause unless user.organisations.any? logger.info "No organisation found for user ID: #{user.id}" create_organisation(user) end # rubocop:enable Style/GuardClause end
[ "def check_and_set_organisation(user)\n\n return if user.organisations.any?\n\n user.organisations.create\n\n end", "def create_organisation(user)\n\n user.organisations.create\n\n logger.info \"Successfully created organisation ID: #{user.organisations.first.id}\"\n\n end", "def create\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates an organisation and links this to the current_user
def create_organisation(user) user.organisations.create logger.info "Successfully created organisation ID: #{user.organisations.first.id}" end
[ "def create\n @org = current_user.orgs.create(params[:org])\n\n if @org.save\n flash[:success] = 'Org was successfully created.'\n redirect_to @org\n else\n render :new\n end\n\n end", "def create\n @organisation = current_user_organisations.build(organisation_params)\n\n respond...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Redirects the user based on the completeness of their associated organisation If complete, we redirect to new_application_path, otherwise if an organisation is missing mandatory details, we redirect to the first page of the organisation section of the service
def redirect_based_on_organisation_completeness(organisation) if helpers.complete_organisation_details?(organisation) logger.info "Organisation details complete for #{organisation.id}" redirect_to(:start_an_application) else logger.info "Organisation details not complete for #{organisatio...
[ "def org_redirection_method\n if org_present?\n redirect_to root_path if org_controller?\n else\n redirect_to new_organization_path unless org_controller?\n end\n end", "def force_address_step\n if current_user\n redirect_to landing_page unless current_user.registration_com...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Cancels a call if its state is 'queued' or 'ringing'
def cancel! state_guard { modify_call 'Status' => 'cancelled' } end
[ "def cancelled?\n !@call.status.nil? && @call.status.code == Core::StatusCodes::CANCELLED\n end", "def cancel\n @calls.values.each do |call|\n call.cancel\n finished(call)\n end\n end", "def cancel\n if self.state != \"completed\"\n self.cancelled!\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts self into a new SQL LIKE pattern matching if self ends with another string.
def to_sql_ends_with "%#{to_sql_escaped_for_like}" end
[ "def ends_with(text)\n where_like(\"%#{text}\")\n end", "def to_sql_contains\n \"%#{to_sql_escaped_for_like}%\"\n end", "def equal2like\n cnt=self.scan(/(\\s+=\\s+)/).count\n if cnt.to_i == 0\n foobar = self\n else\n while cnt.to_i > 0\n if self =~ /(\\s+=\\s+)/\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts self into a new SQL LIKE pattern matching if self is part of another string.
def to_sql_contains "%#{to_sql_escaped_for_like}%" end
[ "def equal2like\n cnt=self.scan(/(\\s+=\\s+)/).count\n if cnt.to_i == 0\n foobar = self\n else\n while cnt.to_i > 0\n if self =~ /(\\s+=\\s+)/\n foo=$1\n foobar = self.gsub!(foo, ' LIKE ')\n end\n cnt = cnt.to_i - 1\n end\n end\n cnt=self.scan(/(\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write a function called&nbsp;stringifyNumbers&nbsp;which takes in an object and finds all of the values which are numbers and converts them to strings. Recursion would be a great way to solve this!
def stringify_numbers(obj) obj.update(obj) do |key, value| if value.class == Hash stringify_numbers(value) elsif value.class == Integer value = value.to_s end end end
[ "def stringify_integers_deep!(hash)\n hash.each do |key, value|\n hash[key] = value.to_s if value.kind_of?(Integer)\n stringify_integers_deep!(value) if value.kind_of?(Hash)\n end\n end", "def stringify_integers_deep!(hash)\n hash.each do |key, value|\n hash[key] = val...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /resolveds/1 GET /resolveds/1.xml
def show @resolved = Resolved.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @resolved } end end
[ "def get_resolved_incidents\n # use status of incident as a filter\n res = RestClient.get INCIDENT_QUERY_URL, :params => { :status => \"resolved\", :fields => \"incident_number\" }\n end", "def new\n @resolved = Resolved.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /resolveds/new GET /resolveds/new.xml
def new @resolved = Resolved.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @resolved } end end
[ "def create\n @resolved = Resolved.new(params[:resolved])\n\n respond_to do |format|\n if @resolved.save\n format.html { redirect_to(@resolved, :notice => 'Resolved was successfully created.') }\n format.xml { render :xml => @resolved, :status => :created, :location => @resolved }\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /resolveds POST /resolveds.xml
def create @resolved = Resolved.new(params[:resolved]) respond_to do |format| if @resolved.save format.html { redirect_to(@resolved, :notice => 'Resolved was successfully created.') } format.xml { render :xml => @resolved, :status => :created, :location => @resolved } else ...
[ "def request_resolved!(request)\n request.update!(state: OrgActionRequest::State::RESOLVED)\n end", "def new\n @resolved = Resolved.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resolved }\n end\n end", "def update\n @resolved = Resolved.f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /resolveds/1 PUT /resolveds/1.xml
def update @resolved = Resolved.find(params[:id]) respond_to do |format| if @resolved.update_attributes(params[:resolved]) format.html { redirect_to(@resolved, :notice => 'Resolved was successfully updated.') } format.xml { head :ok } else format.html { render :action => "e...
[ "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end", "def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end", "def create\n @reso...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /resolveds/1 DELETE /resolveds/1.xml
def destroy @resolved = Resolved.find(params[:id]) @resolved.destroy respond_to do |format| format.html { redirect_to(resolveds_url) } format.xml { head :ok } end end
[ "def destroy\n @ref = Ref.find(params[:id])\n @ref.destroy\n\n respond_to do |format|\n format.html { redirect_to(refs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @resolucion = @solicitud.resoluciones.find(params[:id])\n @resolucion.destroy\n\n respond_to do |for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if params of send_code contain correct data
def verify_send_code_data(params) params[:game].is_a?(Game) && params[:code_string].is_a?(String) && params[:user].is_a?(User) end
[ "def check_code params\n private_request 'check_code', params\n end", "def verify_code\n if params.include?(:phone_number) and params.include?(:activate_code)\n if User.exists?(:phone_number => params[:phone_number], :code => params[:activate_code])\n success = true\n message = 'activate...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if params of get_hint contain correct data
def verify_get_hint_data(params) params[:game].is_a?(Game) && (params[:task].is_a?(Task) || params[:task_id].is_a?(String)) && params[:user].is_a?(User) end
[ "def has_hint?\n hint.present?\n end", "def has_hint?\n !!definition[:hint]\n end", "def hint?\n !defined?(@hint) || @hint\n end", "def take_hint(hint)\n @result_from_hint[hint] if hint\n end", "def give_hint(question)\r\n question[\"Hint\"]\r\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This mixin overrides the exploit method so that it can initiate the service that corresponds with what the client has requested.
def exploit start_service() print_status("Server started.") # Call the exploit primer primer # Wait on the service to stop self.service.wait end
[ "def exploit\n\n\t\tstart_service()\n\t\tprint_status(\"Server started.\")\n\n\t\t# Call the exploit primer\n\t\tprimer\n\n\t\t# Wait on the service to stop\n\t\tself.service.wait\n\tend", "def method_missing(method, *args, &block)\n required_set?\n \n begin \n service = @container.f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Called when a client has data available for reading.
def on_client_data(client) end
[ "def on_client_data(client)\n on_client_data_proc.call(client) if on_client_data_proc\n end", "def on_read(socket, data)\n end", "def monitor_clients\n loop do\n self.clients.delete_if {|c| c.closed? }\n if self.on_client_data_proc\n if clients.any? { |cli|\n cli.ha...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Regenerates the payload, substituting the current RHOST and RPORT with the supplied client host and port from the socket.
def regenerate_payload(cli, arch = nil, platform = nil, target = nil) ohost = datastore['RHOST'] oport = datastore['RPORT'] p = nil begin # Update the datastore with the supplied client peerhost/peerport datastore['RHOST'] = cli.peerhost datastore['RPORT'] = cli.peerport if ((...
[ "def regenerate_payload(cli, arch = nil, platform = nil, target = nil)\n\n\t\tohost = datastore['RHOST']\n\t\toport = datastore['RPORT']\n\t\tp = nil\n\n\t\tbegin\n\t\t\t# Update the datastore with the supplied client peerhost/peerport\n\t\t\tdatastore['RHOST'] = cli.peerhost\n\t\t\tdatastore['RPORT'] = cli.peerpor...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines appropriate listener comm
def _determine_server_comm(srv_comm = datastore['ListenerComm'].to_s) case srv_comm when 'local' comm = ::Rex::Socket::Comm::Local when /\A[0-9]+\Z/ comm = framework.sessions[srv_comm.to_i] raise(RuntimeError, "Socket Server Comm (Session #{srv_comm}) does not exist") unless comm rai...
[ "def listener\n return selected if selected\n \n if Bolt['listener'] and ['generic', 'osx'].include?(Bolt['listener'])\n self.selected= Bolt::Listeners::Generic.new if Bolt['listener'] == 'generic'\n self.selected= Bolt::Listeners::Osx.start if Bolt['listener'] == 'osx'\n $stdout...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Open the menu. Specify a path to show where the menu was opened.
def open(path) @last_path = path @gtk_menu.popup(nil, nil, 0, 0) end
[ "def open_project(path)\n UI.puts \"Opening '#{path}'\"\n `open \"#{path}\"`\n end", "def select_menu(path)\r\n menu_item(path).click\r\n end", "def open_menu(menu_choice,opts={})\n # Menu choice is the entire menu choice string\n #menu_name = menu_choice.split.first.dow...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Open a dialog to enter a new file name to create
def menu_new dialog = Gtk::FileChooserDialog.new("New file", @parent_window.gtk_window, Gtk::FileChooser::ACTION_SAVE, nil, [Gtk::Stock::CANCEL, G...
[ "def set_NewFileName(value)\n set_input(\"NewFileName\", value)\n end", "def set_NewFileName(value)\n set_input(\"NewFileName\", value)\n end", "def new_project\n chooser = Gtk::FileChooserDialog.new(\"Open file\", @glade.get_widget(\"appWindow\"),\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Open a dialog to enter a new folder name to create
def menu_new_folder dialog = Gtk::FileChooserDialog.new("New folder", @parent_window.gtk_window, Gtk::FileChooser::ACTION_CREATE_FOLDER, nil, [Gtk...
[ "def new_project\n chooser = Gtk::FileChooserDialog.new(\"Open file\", @glade.get_widget(\"appWindow\"),\n Gtk::FileChooser::ACTION_CREATE_FOLDER,\n nil,\n [Gtk::Stock::CANCEL, Gtk::Dialog::...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Open a dialog to enter a new name for a file or directory
def menu_rename dialog = Gtk::FileChooserDialog.new("Rename #{File.basename(@last_path)}", @parent_window.gtk_window, Gtk::FileChooser::ACTION_SAVE, nil, ...
[ "def set_NewFileName(value)\n set_input(\"NewFileName\", value)\n end", "def set_NewFileName(value)\n set_input(\"NewFileName\", value)\n end", "def menu_new\n dialog = Gtk::FileChooserDialog.new(\"New file\",\n @parent_window.gtk_window,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Open a dialog and ask the user if he really wants to delete the target file or directory. Note that for safety, directories can only be removed if they are empty.
def menu_delete name = File.basename(@last_path) dialog = Gtk::MessageDialog.new(@parent_window.gtk_window, Gtk::MessageDialog::Flags::MODAL, Gtk::MessageDialog::Type::QUESTION, Gtk::MessageDial...
[ "def DeleteDialog(sender, sel, ptr)\r\n dialog = FXRemoveDialog.new(self).execute\r\n if dialog == 1 \r\n $dirlist.delete($dir)\r\n directories\r\n end\r\n end", "def D\n if selected_items.any?\n if ask %Q[Are you sure want to delete #{selected_items.one? ? selected_it...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Bind the autoplayer algorithm with a player player:PlayerOnGame instance
def bind_player(player) @alg_player = player @log.info("[#{@alg_player.type}] Autoplayer #{@alg_player.type} bound with #{player.name}. Ignore actions predifined.") @action_queue = [] end
[ "def bind_player(player)\n @alg_player = player\n @log.info(\"Autoplayer #{@alg_player.type} bind with #{player.name}\")\n @action_queue = []\n end", "def player_of_game(game)\n game.player(self)\n end", "def initialize_players\n\n end", "def onalg_have_to_play(player,command_decl_avail)\r\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determine the median of 4 elements in ary: ar[left] ar[left + gap ] ar[left + gap 2] ar[left + gap 3] Verify: ar[left + gap 2] contains median value
def median_of_four(ary, left, gap) i1 = left + gap i2 = i1 + gap i3 = i2 + gap i4 = i3 + gap val_1, val_2, val_3, val_4 = ary.values_at(i1, i2, i3, i4) if val_1 <= val_2 if val_2 <= val_3 if val_2 <= val_4 if val_3 > val_4 ...
[ "def median\n sorted = @array.sort\n middle = ((@array.size + 1.0) / 2) - 1 # subscript of middle element of array, with .5 if there are two middle values\n if middle.floor == middle # middle is an integer\n sorted[middle]\n else\n (sorted[middle.floor] + sorted[middle.ceil]) / 2.0\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
isSymmetric?(setOfPairs) Given a set of pairs (an array of arrays), return true if the set represents a symmetric relation. Examples: isSymmetric?([[1,2],[2,1]]) should return true isSymmetric?([[1,1],[1,2],[2,1]]) should return true isSymmetric?([]) should return true isSymmetric?([[1,2],[2,1],[1,3]]) should return fa...
def isSymmetric?(pairs) # your code here end
[ "def symmetric?\n return false if not square?\n @sparse_hash.each {|point, val| return false if get(point.x, point.y) != get(point.y, point.x)}\n true\n end", "def symmetrical?(arr)\n\nend", "def symmetric?\n @colt_property.isSymmetric(@colt_matrix)\n end", "def symmetric?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Expected output: ['tea', 'water', 'soda water'] Creating a method beverages Parameters array, letter Select method include with the specific letter
def beverages(array, letter) array.select{|value| value.include?(letter)} end
[ "def beverages(array, letter)\n array.select { |value| value.include?(letter)}\nend", "def letter_select (array, letter)\n newArray = []\n array.each do |value|\n if value.include? letter\n p newArray << value\n end\n end\nend", "def mk_letters_choice_hashes \n choice_a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
def load_library(file) library = YAML.load_file(file) end def get_japanese_emoticon(name) load_library.each do |lib_name, emote| if lib_name == name return emote[1] end end end def get_english_meaning(j_emote) load_library.each do |lib_name, emote| if emote[1] == j_emote return lib_name end end end
def load_library(file_path) library = {"get_meaning" => {}, "get_emoticon" => {} } YAML.load_file(file_path).each do |meaning, array| english, japanese = array library["get_emoticon"][english] = japanese library["get_meaning"][japanese] = meaning end library end
[ "def load_library(file_path)\n emoji_sheet = YAML.load_file(file_path)\n japanese_meaning = {}\n western_to_japanese = {}\n emoji_sheet.each do |meaning, emojis|\n japanese_meaning[emojis.last] = meaning\n western_to_japanese[emojis.first] = emojis.last\n end\n hash = {\"get_emoticon\" => western_to_jap...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This will create a new song on the station and publish it to redis
def create params[:song][:user_id] = current_user.id @song = Song.new(params[:song]) if @song.save redis_auth $redis.publish "new song", ActiveSupport::JSON.encode({ :station => params[:station_id], :user => current_user.name, :song => @song }) render :js => "ajaxCallback('#{params[:div]}'...
[ "def create_song\n\t\t@song = Song.create(params[:song])\n\tend", "def store(details)\n track = RSpotify::Track.search(\"#{details[0]} #{details[1]}\", limit: 1).first\n song_details = {\n 'name' => track.name,\n 'id' => track.id,\n 'artist' => track.artists[0].name\n }\n @playlist << s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
click the element and wait for page to load TODO: wait on block instead if givven
def click_wait @webpage.click_wait(@locator) end
[ "def load_page_with_click\n wait_start\n click()\n # Just wait for the load\n wait_for_window_loaded(\"\")\n end", "def click\n @_node.click\n @_node.getPage.getWebClient.waitForBackgroundJavaScriptStartingBefore(3000)\n end", "def wait_click_e(xpath)\n $browser.element(:x...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
calling the block defined in the method reinit
def reinit @initializer.call(self) end
[ "def reseter(&ruby_block)\n @reseter_proc = ruby_block\n end", "def reset(*args,&ruby_block)\n # Gain access to the accesser as local variable.\n reseter_proc = @reseter_proc\n # Execute the code generating the accesser in context.\n HDLRuby::High.spac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /engineering_projects/1 GET /engineering_projects/1.json
def show @engineering_project = EngineeringProject.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @engineering_project } end end
[ "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inertia-preview+json', :'Authorization' => 'token ' + CONFIG['OAUTH']\n result = JSON.parse(result) \n end", "def projects(enterprise: 'default', organization: nil)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /engineering_projects POST /engineering_projects.json
def create @engineering_project = EngineeringProject.new(params[:engineering_project]) respond_to do |format| if @engineering_project.save format.html { redirect_to engineering_projects_url, notice: 'Engineering project was successfully created.' } format.json { render json: @engineering_...
[ "def create\n unless current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n \n # create project\n due_date = DateTime.parse(params[:due_date]) + 4/24.0\n project = Project.create(name: params[:project_name], due: due_date, course: $selected_course)\n\n # add te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /engineering_projects/1 PUT /engineering_projects/1.json
def update @engineering_project = EngineeringProject.find(params[:id]) respond_to do |format| if @engineering_project.update_attributes(params[:engineering_project]) format.html { redirect_to @engineering_project, notice: 'Engineering project was successfully updated.' } format.json { hea...
[ "def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def update\n @project = Project.find(params[:id])\n\n respond_to do |format|\n if @project.update_attributes(p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /engineering_projects/1 DELETE /engineering_projects/1.json
def destroy @engineering_project = EngineeringProject.find(params[:id]) @engineering_project.destroy respond_to do |format| format.html { redirect_to engineering_projects_url } format.json { head :no_content } end end
[ "def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @root = \"projects\"\n \n @project = Project.find(params[:id])\n @project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a modified version of the URI that: 1. Always has a starting slash 2. Removes all the double slashes
def normalize_uri(*strs) new_str = strs * "/" new_str = new_str.gsub!("//", "/") while new_str.index("//") # Makes sure there's a starting slash unless new_str[0,1] == '/' new_str = '/' + new_str end new_str end
[ "def normalize_uri(*strs)\n new_str = strs * '/'\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\n new_str\n end", "def add_trailing_slash uri # :nodoc:\n uri = uri.to_s\n\n uri << '/' unless uri.end_with? '/'\n\n URI uri\n end", "def normalize_uri\n if @uri.start...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes a new Request, which defaults to the GET HTTP verb and has it's timeouts set to 0
def initialize @action = :get @headers = {} @timeout = 0 @connect_timeout = 0 @max_redirects = -1 end
[ "def init_request(opts)\n raise ArgumentError, \":uri is for backwards compatibilty and conflicts with :request\" \\\n if opts[:request] && opts[:uri]\n\n # For backwards compatibilty\n if opts[:uri]\n HTTP::Request.new(:uri => opts[:uri], :verb => :get)\n else\n opts.fetch(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the type of authentication to use for this request.
def auth_type=(type=:basic) @auth_type = case type when :basic, "basic" Request::AuthBasic when :digest, "digest" Request::AuthDigest when :any, "any" Request::AuthAny else raise "#{type.inspect} is an unknown authentication type" end end
[ "def authentication_type=(value)\n @authentication_type = value\n end", "def type_authentication!()\n @type = TAC_PLUS_AUTHEN\n end", "def auth_type=(auth_type); end", "def auth_type=(auth_type)\n @auth_type = legitimize_auth_type(auth_type)\n end", "def authentic...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the upload data (request body) for the request. If the given argument is a Hash, the contents of the hash will be handled as form fields and will be formencoded. The somposition of the request body is then going to be handled by Curl. If the given `data` is any other object, it is going to be treated as a stringab...
def upload_data=(data) @upload_data = case data when Hash self.multipart ? data : Util.build_query_string_from_hash(data, action == :post) else data end end
[ "def set_upload_body(request, data)\n if data.respond_to? :read\n request.body_stream = data\n if data.respond_to? :size\n request.content_length = data.size\n else\n request[\"Transfer-encoding\"] = \"chunked\"\n end\n else\n request.body = data\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Tells whether this Request is configured the same as the other request
def eql?(request) return false unless Request === request READER_VARS.inject(true) do |memo, name| memo && (self.send(name) == request.send(name)) end end
[ "def ==(other_request)\n return false unless super(other_request)\n return false unless other_request.kind_of?(self.class)\n (other_request.response == response) && (other_request.uri == uri)\n end", "def ==(other)\n super || other.is_a?(Chewy::Search::Request) ? compare_internals(other) : to_a =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /Probe/physical_units/1 GET /Probe/physical_units/1.xml
def show @physical_unit = Probe::PhysicalUnit.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @physical_unit } end end
[ "def new\n @physical_unit = Probe::PhysicalUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @physical_unit }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @physical_unit ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /Probe/physical_units/new GET /Probe/physical_units/new.xml
def new @physical_unit = Probe::PhysicalUnit.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @physical_unit } end end
[ "def create\n @physical_unit = Probe::PhysicalUnit.new(params[:physical_unit])\n\n respond_to do |format|\n if @physical_unit.save\n flash[:notice] = 'Probe::PhysicalUnit.was successfully created.'\n format.html { redirect_to(@physical_unit) }\n format.xml { render :xml => @physical...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /Probe/physical_units POST /Probe/physical_units.xml
def create @physical_unit = Probe::PhysicalUnit.new(params[:physical_unit]) respond_to do |format| if @physical_unit.save flash[:notice] = 'Probe::PhysicalUnit.was successfully created.' format.html { redirect_to(@physical_unit) } format.xml { render :xml => @physical_unit, :stat...
[ "def new\n @physical_unit = Probe::PhysicalUnit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @physical_unit }\n end\n end", "def update\n @physical_unit = Probe::PhysicalUnit.find(params[:id])\n\n respond_to do |format|\n if @physical_un...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /Probe/physical_units/1 PUT /Probe/physical_units/1.xml
def update @physical_unit = Probe::PhysicalUnit.find(params[:id]) respond_to do |format| if @physical_unit.update_attributes(params[:physical_unit]) flash[:notice] = 'Probe::PhysicalUnit.was successfully updated.' format.html { redirect_to(@physical_unit) } format.xml { head :ok ...
[ "def create\n @physical_unit = Probe::PhysicalUnit.new(params[:physical_unit])\n\n respond_to do |format|\n if @physical_unit.save\n flash[:notice] = 'Probe::PhysicalUnit.was successfully created.'\n format.html { redirect_to(@physical_unit) }\n format.xml { render :xml => @physical...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /Probe/physical_units/1 DELETE /Probe/physical_units/1.xml
def destroy @physical_unit = Probe::PhysicalUnit.find(params[:id]) @physical_unit.destroy respond_to do |format| format.html { redirect_to(physical_units_url) } format.xml { head :ok } end end
[ "def destroy\n @physical_unit.destroy\n respond_to do |format|\n format.html { redirect_to(physical_units_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @inventory_unit_of_measurements = user_default_branch.inventory_unit_of_measurements.find(params[:id])\n @inventory_uni...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
render the target according to this column's layout rules
def render(target) align_right? ? Justifier.rjust(target, width) : Justifier.ljust(target, width) rescue StandardError => e raise "Column #{name} failed: #{e.message}" end
[ "def render_layout(output, layout, info); end", "def _layout; end", "def perform_layout\n @needs_layout = false\n @subviews.each(&:perform_layout)\n end", "def layout_for(document); end", "def render\n @columns.each do |column|\n column.css_classes << \"last\" if column == @columns.la...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a Font to the Workbook. Used by the parser. You should not need to use this Method.
def add_font font @fonts.push(font).uniq! if font font end
[ "def AddFont(family,style,file)\n AddFontFamily(family,file)\n end", "def install_font\n require \"win32ole\" if RUBY_PLATFORM.match?(/mswin|mingw|windows/)\n fonts_dir = Chef::Util::PathHelper.join(ENV[\"windir\"], \"fonts\")\n folder = WIN32OLE.new(\"Shell.Application\").Names...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a Worksheet to the Workbook.
def add_worksheet worksheet worksheet.workbook = self @worksheets.push worksheet worksheet end
[ "def add_worksheet(name = '')\n name = check_sheetname(name)\n worksheet = Worksheet.new(self, @worksheets.size, name)\n @worksheets << worksheet\n worksheet\n end", "def add_worksheet(name)\n Worksheet.new(@wb.addWorksheet(name))\n end", "def <<(worksheet)\n if not worksheet.is...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a Worksheet from Workbook by it's index
def delete_worksheet worksheet_index @worksheets.delete_at worksheet_index end
[ "def delete_index index_name\n table = table index_list_table\n name_col = 0\n row = find_target_row table,index_name,name_col\n if row\n delete_button(table,row).click\n alert_ok\n else\n raise \"can not find target row\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Change the RGB components of the elements in the colour palette.
def set_custom_color idx, red, green, blue raise 'Invalid format' if [red, green, blue].find { |c| ! (0..255).include?(c) } @palette[idx] = [red, green, blue] end
[ "def set_color_palette # :nodoc:\n @palette = [\n [0x00, 0x00, 0x00, 0x00], # 8\n [0xff, 0xff, 0xff, 0x00], # 9\n [0xff, 0x00, 0x00, 0x00], # 10\n [0x00, 0xff, 0x00, 0x00], # 11\n [0x00, 0x00, 0xff, 0x00], # 12\n [0xff, 0xff, 0x00, 0x00], # 13\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a new Worksheet in this Workbook. Used without options this creates a Worksheet with the name 'WorksheetN' where the new Worksheet is the Nth Worksheet in this Workbook. Use the option :name => 'My pretty Name' to override this behavior.
def create_worksheet opts = {} opts[:name] ||= client("Worksheet#{@worksheets.size.next}", 'UTF-8') add_worksheet Worksheet.new(opts) end
[ "def create_worksheet( options = {} )\n sheet_name = options[:name]\n\n @workbook = HSSFWorkbook.new if @workbook.nil?\n\n if sheet_name\n\n name = sanitize_sheet_name( sheet_name )\n\n return create_sheet_and_set_styles( name ) if @workbook.getSheetIndex(name) < 0 # Check sheet doesn't...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the count of total worksheets present.
def sheet_count @worksheets.length end
[ "def n_sheets()\n if @file_type == \"xls\"\n return @excel_book.sheet_count\n elsif @file_type == \"xlsx\"\n return @xlsx_book.worksheets.size\n else\n raise RuntimeError, \"File #{@file_name} is not an xls or xlsx file, so has only one sheet\"\n end\n end", "def total_weeks\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The Font at _idx_
def font idx @fonts[idx] end
[ "def [](index)\r\n @fonts[index]\r\n end", "def index(font)\r\n @fonts.index(font)\r\n end", "def font_id(style_index)\n xf_id(style_index)[:fontId]\n end", "def fontId; end", "def get_font(font_name)\n fonts[font_name]\n end", "def store_fontx(index) # :nodoc:\n rec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The Format at _idx_, or if _idx_ is a String the Format with name == _idx_
def format idx case idx when Integer @formats[idx] || @default_format || Format.new when String @formats.find do |fmt| fmt.name == idx end end end
[ "def formats_idx; end", "def format idx\n @formats[idx] || @default_format \\\n || @worksheet.column(idx).default_format if @worksheet\n end", "def set_format idx, fmt\n @formats[idx] = fmt\n @worksheet.add_format fmt\n @worksheet.row_updated @idx, self if @worksheet\n fmt\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The Worksheet at _idx_, or if _idx_ is a String the Worksheet with name == _idx_
def worksheet idx case idx when Integer @worksheets[idx] when String @worksheets.find do |sheet| sheet.name == idx end end end
[ "def [](ind)\n case ind\n when Integer then worksheets[ind]\n when String then worksheets.find { |ws| ws.sheet_name == ind }\n end\n end", "def get_index(sheet)\n @worksheets.index(sheet)\n end", "def worksheet_by_name(sheetname = nil)\n sheets.select { |s| s.name == sheetname }...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new instance of the default Writer class for this Workbook (can only be an Excel::Writer::Workbook at this time)
def writer io_or_path, type=Excel, version=self.version if type == Excel Excel::Writer::Workbook.new io_or_path else raise NotImplementedError, "No Writer defined for #{type}" end end
[ "def writer io_or_path, type=Excel\n Excel::Writer::Workbook.new io_or_path\n end", "def writer_instance!(additional_settings = {})\n writer_class.new(writer_settings.merge(additional_settings))\n end", "def writer!\n writer_class = @writer_class || qualified_const_get(settings[\"writer_class...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /learning_styles GET /learning_styles.json
def index @learning_styles = LearningStyle.all end
[ "def styles\n respond_to do |format|\n format.json{ render :json => helpers.get_style(params[:style_id], :json) }\n end\n end", "def index\n @learner_styles = LearnerStyle.all\n end", "def create\n @learning_style = LearningStyle.new(learning_style_params)\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /learning_styles POST /learning_styles.json
def create @learning_style = LearningStyle.new(learning_style_params) respond_to do |format| if @learning_style.save format.html { redirect_to @learning_style, notice: 'Learning style was successfully created.' } format.json { render :show, status: :created, location: @learning_style } ...
[ "def create\n @learner_style = LearnerStyle.new(learner_style_params)\n\n respond_to do |format|\n if @learner_style.save\n format.html { redirect_to @learner_style, notice: 'Learner style was successfully created.' }\n format.json { render :show, status: :created, location: @learner_style ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /learning_styles/1 PATCH/PUT /learning_styles/1.json
def update respond_to do |format| if @learning_style.update(learning_style_params) format.html { redirect_to @learning_style, notice: 'Learning style was successfully updated.' } format.json { render :show, status: :ok, location: @learning_style } else format.html { render :edit ...
[ "def update\n @learning_style = LearningStyle.find(params[:id])\n\n respond_to do |format|\n if @learning_style.update_attributes(params[:learning_style])\n flash[:notice] = 'LearningStyle was successfully updated.'\n format.html { redirect_to(@learning_style) }\n format.xml { head ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /learning_styles/1 DELETE /learning_styles/1.json
def destroy @learning_style.destroy respond_to do |format| format.html { redirect_to learning_styles_url, notice: 'Learning style was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @learning_style = LearningStyle.find(params[:id])\n @learning_style.destroy\n\n respond_to do |format|\n format.html { redirect_to(learning_styles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @learner_style.destroy\n respond_to do |format|\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /raiway_stations GET /raiway_stations.json
def index @raiway_stations = RaiwayStation.all end
[ "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def index\n @stations = Station.all\n\n render json: @stations\n end", "def get_all_stations\n url = 'radio/station'\n options = {query: {'alt': 'json', 'tier': 'aa', 'hl'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /raiway_stations POST /raiway_stations.json
def create @raiway_station = RaiwayStation.new(raiway_station_params) respond_to do |format| if @raiway_station.save format.html { redirect_to @raiway_station, notice: 'Raiway station was successfully created.' } format.json { render :show, status: :created, location: @raiway_station } ...
[ "def create\n @station = Station.new(station_params)\n\n if @station.save\n render json: @station, status: :created, location: @station\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def create\n @station = Station.new(station_params)\n\n if @s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /raiway_stations/1 PATCH/PUT /raiway_stations/1.json
def update respond_to do |format| if @raiway_station.update(raiway_station_params) format.html { redirect_to @raiway_station, notice: 'Raiway station was successfully updated.' } format.json { render :show, status: :ok, location: @raiway_station } else format.html { render :edit ...
[ "def update\n @station = Station.find(params[:id])\n\n if @station.update(station_params)\n head :no_content\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def update\n @station = Station.find(params[:id])\n\n respond_to do |format|\n if @stat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /raiway_stations/1 DELETE /raiway_stations/1.json
def destroy @raiway_station.destroy respond_to do |format| format.html { redirect_to raiway_stations_url, notice: 'Raiway station was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @line_station = LineStation.find(params[:id])\n @line_station.destroy\n\n respond_to do |format|\n format.html { redirect_to line_stations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @line_station.destroy\n respond_to do |format|\n format....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yields `Script` object concurrently, in different threads.
def each(&block) if block_given? Parallel.each(each_path, in_threads: threads) do |path| load_script_from_path path, &block end else self.enum_for :each end end
[ "def script\n run do |item|\n script = yield\n script.start item\n script.await\n end\n end", "def scripts\n\t\t@scripts.each { |script| yield script } if block_given?\n\n\t\t@scripts\n\tend", "def _common_parent_loop\n loop {yield}\n end", "def run_sc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We want to offer the user a choice of something from 4 sets. 1) The cards available in the town. 2) Unbuilt landmarks. 3) Databank menu (in which case, repeat, once databank is dealt with) 4) Purchase nothing.
def purchase_card(turn) own_money = turn.player.money keep_repeating = true while keep_repeating == true do keep_repeating = false @@cli.say "Now it is time to purchase a card; you have <%= color('#{own_money}', BOLD) %> money." # Create a hash for the cards in the town ...
[ "def pick_a_set\n cards = []\n (1..3).each do |i|\n print \"Choose card #{i}: \"\n answer = gets.to_i\n until answer.between?(1, @board.length) && !cards.include?(@board[answer - 1])\n print \"Try again! Choose card #{i}: \"\n answer = gets.to_i\n end\n cards << @board[a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read YAML file and extract all targets as array
def get_targets(path) config = YAML.load(File.read(path)) targets = config['storage']['targets'].group_by { |key| key['type'] } targets_valid?(targets) process_targets(targets) end
[ "def list_yaml_files\n yaml_files do |file|\n puts file\n end\n end", "def yaml(*files, **options, &block) = read(*files, parse: :yaml, ext: ['.yml', '.yaml'], **options, &block)", "def load_yaml(file)\n YAML.load_file(file).tap do |config|\n # Update the yaml so every node has a setup a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Accept list list of key/value pairs and append `_1`, `_2` etc to all nonunique pairs
def uniqufy(original_list) # Recursive function to bump index unti it is not unique def increment(key, acc) if acc.map { |p| p[0] }.include?(key) then increment(bump(key), acc) else key end end def bump(pair) [pair[0], pair[1] + 1] end # Increment index in pair of key and index list...
[ "def simplify_key_value_list(elements)\n # remove everything form right to left till the double unerline\n elements.each do |element|\n element.keyValueList.transform_keys! do |key|\n index = key.index('__')\n if !index.nil?\n key.slice(index + 2, key.length)\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check that targets have valid type. Throw exception otherwise
def targets_valid?(targets_hash) targets_hash.keys.each { |type| unless KNOWN_TYPES.include? type raise "Unknown target type [#{type}]" end } end
[ "def check_target_validity_of target\n raise 'TargetError' unless target.class.ancestors.include? ExampleGame::Creature\n end", "def ct_validate(target)\n if outputs != target.inputs\n msg = \"#{target.name}(#{target.inputs.join(', ')} does not match #{name}(#{outputs.join(', ')})\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate Redshift target from YAML configuration
def process_redshift(target) { :schema => 'iglu:com.snowplowanalytics.snowplow.storage/redshift_config/jsonschema/1-0-0', :data => { :name => target['name'], :host => target['host'], :database => target['database'], :port => target['port'], :sslMode => target['ssl_mode'...
[ "def generate_staging_config(url, config)\n staging = {'domain' => url, 'baseurl' => url,\n 'assets' => {'baseurl' => \"#{url}/assets\"}}\n File.open(config, 'w') { |f| f.write staging.to_yaml }\nend", "def copy_yml\n template \"config/regulate.yml\", \"config/regulate.yml\"\n end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate Postgres target from YAML configuration
def process_postgres(target) { :schema => 'iglu:com.snowplowanalytics.snowplow.storage/postgresql_config/jsonschema/1-0-0', :data => { :name => target['name'], :host => target['host'], :database => target['database'], :port => target['port'], :sslMode => target['ssl_mod...
[ "def target_postgresql_version; end", "def pg\n uri = URI.parse( hpg_resolve(shift_argument, \"DATABASE_URL\").url )\n config = {\n 'name' => gen_datasource_name(\"PostgreSQL\"),\n 'type' => \"POSTGRESQL\",\n 'config' => {\n 'host' => uri.host,\n 'port' => uri.port || 5432,\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate Elasticsearch target from YAML configuration
def process_elasticsearch(target) { :schema => 'iglu:com.snowplowanalytics.snowplow.storage/elastic_config/jsonschema/1-0-0', :data => { :name => target['name'], :host => target['host'], :index => target['database'], :port => target['port'], :type => target['table'], ...
[ "def generate_yaml_index!(output_doc_path)\n result = {}\n\n ATTACK_API.techniques_by_tactic.each do |tactic, techniques|\n result[tactic] = techniques.collect do |technique|\n [\n technique['external_references'][0]['external_id'],\n {\n 'technique' => techniq...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse rack options. Separate with ""
def parse_rack_options(args=[]) rack_args = [] start_adding = false args.each do |arg| rack_args << arg if start_adding start_adding = true if arg == '--' end opt_parser = ::Rack::Server::Options.new options = default_options options[:config] ...
[ "def rack_options\n opts = Hash.new\n Souffle::Config.configuration.each do |k,v|\n if /^rack/ =~ k.to_s\n param = k.to_s.gsub('rack_', '')\n\n case param\n when \"environment\"\n opts[param.to_sym] = v\n else\n opts[param.capitalize.to_sym] = v\n end\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert Markdown source to HTML.
def markdown_to_html(src) render_options = { prettify: true, } renderer = MarkdownRenderer.new(render_options) extensions = { no_intra_emphasis: true, autolink: true, tables: true, fenced_code_blocks: true, strikethrough: true, underline: t...
[ "def convert_markdown\n self.html_content = Raptor::Markdown.render(self.content)\n end", "def convert_markdown\n # self.content_html = Kramdown::Document.new(content).to_html\n self.content_html = markdown(content)\n end", "def markdown\n convert do |current|\n Kramdown::Document.new(cur...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fill each image in array
def fill self.each {|image| image.fill} end
[ "def populate_new_image #:doc:\n puts 'Populate your image 2D array: '\n\n (0...@width).each do |row|\n (0...@height).each do |cell|\n puts \"At row: #{row}, cell: #{cell}: \"\n @image[row][cell] = gets.to_i\n end\n end\n\n puts '======================'\n puts 'Unfilled image ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the executable name if this service has one defaults to the assembly name of the corresponding project, plus 'exe', which is how the compilers name the executables.
def exe conf['exe'] || "#{proj.asmname}.exe" end
[ "def program_name\n @program_name || File.basename($0)\n end", "def executable_name\n info_string(CFBundle::INFO_KEY_BUNDLE_EXECUTABLE)\n end", "def executable\n return File.basename(archive_path)\n end", "def get_executable(executable)\n if RUBY_PLATFORM =~ /mswin32/\n executa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Resolves the project file given an optional descriptor path or a configuration hash or both. One of the other of the parameters need to exist, or an error will be thrown.
def resolve_project descriptor_path, conf trace { "trying to resolve project, descriptor_path: #{descriptor_path.inspect}, conf: #{conf.inspect} [AppSpec#resolve_path]" } project_path = conf['project_path'] return File.join File.dirname(descriptor_path), project_path if project_path and valid_path de...
[ "def resolve(path, options = {}, &block)\n pathname = Pathname.new(path)\n attributes = environment.attributes_for(pathname)\n\n if pathname.absolute?\n pathname\n\n elsif content_type = options[:content_type]\n content_type = self.content_type if content_type == :self\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets the uri source of the project
def uri conf['uri'] || git_source end
[ "def source_uri\n URI.parse(url_for(@software))\n end", "def uri\n @uri ||= URI(format(BASE_URL, source: @source))\n end", "def source_uri\n information[ \"source_code_uri\" ] || information[ \"homepage_uri\" ]\n end", "def uri()\n @uri\n end", "def source_code_uri\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets the category this package is in, both for the RPM and for puppet and for possibly assigning to a workstealing cluster or to start the app in the correct nodecluster if you have that implemented
def category conf['category'] || 'apps' end
[ "def get_category_newsgroup(category)\n case category\n when \"sell\"\n \"tori.myydaan\"\n when \"buy\"\n \"tori.ostetaan\"\n when \"give\"\n \"tori.myydaan\"\n when \"lost\"\n \"tori.kadonnut\"\n when \"rides\"\n \"tori.kyydit\"\n else\n nil \n end \n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets the version with the following priorities: semver version passed in c'tor ENV['FORMAL_VERSION'] .appspec's version .xxproj's version semver from disk if all above fails; use '1.0.0'
def version semver_version || ENV['FORMAL_VERSION'] || conf['version'] || proj.version || semver_disk_version || '1.0.0' end
[ "def semver_version\n return @semver.format '%M.%m.%p' if @semver\n nil\n end", "def version\n @version ||= if token.nil? || Array(packages).empty?\n '0.1.0'\n else\n packages.map do |p|\n Gem::Version.new(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }