query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Start a pryremoteem server
def run(obj, host = DEFHOST, port = DEFPORT, opts = {:tls => false}) tries = :auto == port ? 100.tap{ port = DEFPORT } : 1 # TODO raise a useful exception not RuntimeError raise "root permission required for port below 1024 (#{port})" if port < 1024 && Process.euid != 0 begin E...
[ "def start_server(username,ack_port,peer_port,server_type=:thin, dbid=nil)\n cmd = \"rails server -p #{peer_port} -u #{username}\"\n cmd += \" -dbid #{dbid}\" unless dbid.nil?\n begin\n PTY.spawn(cmd) do |stdin,stdout,pid|\n begin\n stdin.each do |line|\n Rails.logger.info ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
auth_attempt(args, &blk) Registers a block to call when authentication fails.
def auth_fail(*args, &blk) block_given? ? @auth_fail_cbs << blk : @auth_fails.push(args) while (fail_data = @auth_fails.shift) @auth_fail_cbs.each { |cb| cb.call(*fail_data) } end end
[ "def retry_on_auth_failure(&block)\n retried = false\n begin\n yield pandora_client\n rescue Pandora::APIError => ex\n if !retried && ex.code == 1001 # INVALID_AUTH_TOKEN\n pandora_client.reauthenticate\n retried = true\n retry\n else\n raise\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determine the list(with properties) of the running instances in the given autoscaling group if asg_name is nil it returns nil
def running_hosts_in_asg(asg_name) return nil unless asg_name asg = @auto_scaling.groups[asg_name] return nil unless asg # return a lost of maps having the list of running instances asg.auto_scaling_instances.collect { |i| if i.health_status != 'Healthly' ec...
[ "def describe_auto_scaling_group_running_instances(group_name)\n # create new client\n client = create_autoscale_client()\n\n pages = client.describe_auto_scaling_groups(auto_scaling_group_names: [group_name])\n \n group_description = pages.first.auto_scaling_groups.first\n \n filtered = []\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If the Elastic IP is unhealthy/unreachable, we will try to assign the Elastic IP to this instance
def try_steal_eip unless eip_healthy? # try to steal the eip eip_instance = @ec2.elastic_ips[@eip] raise "cannot find #{@eip} in list of elastic IPs" unless eip_instance instance = @ec2.instances[my_instance_id] instance.associate_elastic_ip(eip_instance) ...
[ "def ensure_elastic_ips\n all_instances = @ec2.describe_instances()\n @ec2_nodes.each_pair do |node_name, node|\n node_instance = find_ec2_node_instance(node_name, all_instances)\n if !node.elastic_ip.nil?\n if node_instance.nil?\n @logger.error \"ERROR: Node ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetches the instance id for the current machine
def my_instance_id Net::HTTP.get(URI('http://169.254.169.254/1.0/meta-data/instance-id')) end
[ "def id\n @id ||= begin\n url = 'http://169.254.169.254/latest/meta-data/instance-id'\n inspec.command(\"curl #{url}\").stdout.strip\n end\n end", "def lookup_instance_id\n metadata_endpoint = 'http://169.254.169.254/latest/meta-data/'\n instance_id = Net::HTTP.get( URI.parse(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
reload/restart nginx, uses /etc/init.d/nginx
def reload_nginx if nginx_running? `/etc/init.d/nginx reload` else `/etc/init.d/nginx restart` end end
[ "def restart\n Cheese::Verbose.log_task \"Restart nginx server\" do\n %x{ /etc/init.d/nginx restart }\n end\n end", "def restart\n if @time < @next_restart\n log.info \"synapse: at time #{@time} waiting until #{@next_restart} to restart\"\n return\n end\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determine if nginx is running by looking at the pidfile
def nginx_running? if File.exists?('/var/run/nginx.pid') pid = File.open('/var/run/nginx.pid', 'r').readline begin Process.getpgid(pid) true rescue Errno::ESRCH false end else false end end
[ "def nginx?\n webserver == 'NginX'\n end", "def nginx_processes\n @nginx_processes ||= list_processes(:exe => \"nginx\")\n end", "def running?\n File.exists?(pid_file)\n end", "def unicorn_is_running?\n remote_process_exists?(unicorn_pid)\n end", "def old_unicorn_is_runni...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
application_id is duplicated across supported_permissions and user_application_permissions to efficiently address common queries for a user's permissions for a particular application
def assign_application_id self.application_id = supported_permission.application_id if supported_permission.present? end
[ "def application_id=(value)\n @application_id = value\n end", "def application_id\n return @application_id\n end", "def resource_specific_application_permissions=(value)\n @resource_specific_application_permissions = value\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sections Creates OpenNebula section if not exists and returns its section_id. Returns its section_id if OpenNebula section already exists
def init_section one_section = section_by_name(NSXConstants::ONE_SECTION_NAME) one_section ||= create_section(NSXConstants::ONE_SECTION_NAME) return one_section['id'] if one_section end
[ "def get_section_id\n\t section_id_found = nil\n\t section_name = Copy.mysql.escape_string(@section_name.to_s)\n\t sql_query = FIND_SECTION + \" WHERE name = '#{section_name}'\"\n\t\tputs sql_query #DEBUG\n\t res = Copy.mysql.query(sql_query)\n res.each_hash do |h|\n\t section_id_found = h['id']\n end...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Rules Get all rules of a Section, OpenNebula section if it's not defined Return: [Array]
def rules(section_id = @one_section_id) url = @url_sections + '/' + section_id + '/rules' @nsx_client.get(url) end
[ "def rules_by_name(rule_name, section_id = @one_section_id)\n rules = []\n return rules unless section_id\n\n all_rules = rules(section_id)\n return rules unless all_rules\n\n all_rules['results'].each do |rule|\n rules << rule if rule['display_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get rules by name Return: Array with rules or an empty array
def rules_by_name(rule_name, section_id = @one_section_id) rules = [] return rules unless section_id all_rules = rules(section_id) return rules unless all_rules all_rules['results'].each do |rule| rules << rule if rule['display_name'] == rule...
[ "def rules_by_name(rule_name, section_id = @one_section_id)\n rules = Nokogiri::XML::NodeSet.new(Nokogiri::XML::Document.new)\n\n all_rules = rules(section_id)\n return rules unless all_rules\n\n all_rules.xpath(\"//rule[name=\\\"#{rule_name}\\\"]\")\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get rule by regex Return: Array with rules or an empty array
def rules_by_regex(regex, section_id = @one_section_id) rules = [] return rules unless section_id all_rules = rules(section_id) return rules unless all_rules all_rules['results'].each do |rule| rules << rule if rule['display_name'].match(rege...
[ "def parse_rule(line)\n regex = line.gsub /[0-9]/, ''\n regex[0] = '^' if regex[0] == '.'\n regex[-1] = '$' if regex[-1] == '.'\n\n filter = line.gsub /([0-9])[a-z]/, '\\1'\n filter = filter.gsub /[a-z]/, '0'\n filter = filter.gsub /[^0-9]/, ''\n filter = filter.split('').map(&:to_i)\n\n [Regexp.new(regex),...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /personas_nota_seguimiento POST /personas_nota_seguimiento.json
def create @persona = Persona.find(params[:persona_id]) @persona_nota_seguimiento = PersonaNotaSeguimiento.new(persona_nota_seguimiento_params) @persona_nota_seguimiento.persona = @persona @persona_nota_seguimiento.usuario = current_usuario if @persona_nota_seguimiento.save redirect_to @person...
[ "def create\n params[:nota][:usuario_id] = usuario_actual.id\n @nota = @solicitud.notas.new(params[:nota])\n\n respond_to do |format|\n if @nota.save\n format.html { redirect_to( solicitud_notas_path(@solicitud), :notice => 'Seguimiento agregado con exito.') }\n format.xml { render :xml...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /personas_nota_seguimiento/1 PATCH/PUT /personas_nota_seguimiento/1.json
def update if @persona_nota_seguimiento.update(persona_nota_seguimiento_params) redirect_to @persona, notice: 'Actualizado Correctamente.' else render :edit end end
[ "def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This will remove employee from repair order.
def repair_order_employees_delete @repair_order_employee = current_business_user.employee_users_repair_orders.find(params[:id]) @repair_order_employee.destroy if @repair_order_employee render json: { repair_order_employees: @repair_order_employee.as_json }, status: :ok else render jso...
[ "def remove_employee2\n @employees = @department.employees.all\n @assigned_employee = EmployeeSubject.rem_emp(@employee, @subject)\n @assigned_employee.dest(@employee, @subject)\n @assigned_employees = EmployeeSubject.rem_emp2(@subject)\n end", "def remove_employee_from_group(employee)\n self.empl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Confirms if the user is dungeon user.
def is_dungeon_master_user game = Game.find_by id: params[:game_id] if game.nil? or !dungeon_master?(game.dungeon_master) redirect_to(root_url) end end
[ "def is_dungeon_master_user\n\t game = Game.find_by id: params[:id]\n\t if game.nil? or !dungeon_master?(game.dungeon_master)\n\t \tredirect_to(root_url) \n\t end\n\t end", "def conquered_dungeon?\n @current_dungeon.conquered\n end", "def change_dungeon_level\n if dungeons_conquered.any?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /ujumbes POST /ujumbes.json
def create @ujumbe = current_user.ujumbes.build(ujumbe_params) @user = current_user respond_to do |format| if @ujumbe.save format.html { redirect_to edit_ujumbe_path(@ujumbe), notice: 'Ujumbe was successfully created. You can now complete it' } format.json { render action: 'show', sta...
[ "def create\n @kuizuw = Kuizuw.new(kuizuw_params)\n\n respond_to do |format|\n if @kuizuw.save\n format.html { redirect_to @kuizuw, notice: 'Kuizuw was successfully created.' }\n format.json { render :show, status: :created, location: @kuizuw }\n else\n format.html { render :new...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /ujumbes/1 DELETE /ujumbes/1.json
def destroy @ujumbe.destroy respond_to do |format| format.html { redirect_to ujumbes_url } format.json { head :no_content } end end
[ "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ubicacion =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
outputs help for this command argv = commandline arguments
def cmd_help argv help end
[ "def cmd_help argv\n help\n end", "def cmd_cli_help argv\n setup argv\n msg run_cmd(\"help\")\n end", "def display_help\r\n print %{\r\nUsage: #{File.basename($0)} [URI] [options]\r\n\r\n Options:\r\n -c/--clean Cleans up any HTML output for easy screen reading\r\n -h/--help Help. Y...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
restarts the Mu system services (this does not reboot the appliance) argv = commandline arguments
def cmd_restart argv setup argv response = @api.restart msg response return response end
[ "def restart(opts=[]) daemon('restart', opts); end", "def restart\n invoke :stop, :all => input[:all], :apps => input[:apps]\n\n line unless quiet?\n\n input[:apps].each do |app|\n unless input[:command].nil?\n app.command = input[:command]\n end\n app.update!\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
gets the complete System status page argv = commandline arguments
def cmd_status argv setup argv response = @api.status msg response return response end
[ "def do_status\n crawl_id = nil\n \n opts = ARGV.options do |opts|\n opts.banner = %Q!\nUsage: \n #{$script_name} list [options]\n\nDescription: \n List the currently active crawl tasks\n\nDetails:\n!\n do_standard_opts(opts)\n\n opts.parse!\n\n crawl_id = ARGV.shift\n if crawl_id.nil?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
validate and save captured data for a given page PUT /answer_sheets/1/pages/1
def update @page = Page.find(params[:id]) questions = @presenter.all_questions_for_page(params[:id]) questions.post(params[:answers], @answer_sheet) questions.save @elements = questions.elements # Save references if params[:reference].present? param...
[ "def save_page(page)\r\n logger.info \"Processing #{page.url} (#{page.code})\"\r\n if page.code == 200\r\n find_song_in(page.body) do |html|\r\n title = find_description(html)\r\n logger.info \"Creating post #{title} (#{page.url})\"\r\n Post.create(\r\n url: page.url.to_s,\r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /organizations/1/sites GET /organizations/1/sites.json
def index @sites = @organization.sites.order(id: :desc).all end
[ "def index\n @sites = Site.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sites }\n end\n end", "def index\n @api_v1_sites = Api::V1::Site.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @api_v1_sites }...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /organizations/1/sites POST /organizations/1/sites.json
def create @site = @organization.sites.new(site_params) respond_to do |format| if @site.save format.html { redirect_to after_create_path, notice: 'Site was successfully created.' } format.json { render :show, status: :created, location: @site } else format.html...
[ "def create_sites\n params[:sites].select { |hash| hash[:name].present? }.each do |hash|\n site = @project.sites.find_by(id: hash[:id])\n if site\n if hash[:name] == \"Default Site\"\n site.update(name: hash[:name])\n else\n site.update(name: hash[:name], short_name: nil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
create a wrapper object for file upload testing.
def file_for_upload(path) return Mack::Testing::FileWrapper.new(path) end
[ "def fixture_file_upload(*args, **kwargs)\n Rack::Test::UploadedFile.new(*args, **kwargs)\n end", "def build_file(io_wrapper, use)\n IoDecorator.new(io_wrapper.file, io_wrapper.original_name, io_wrapper.mime_type, io_wrapper.size, use)\n end", "def file_upload(criteria = T.unsafe(nil)); end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a Rack::MockRequest. If there isn't one, a new one is created.
def request @request ||= Rack::MockRequest.new(mack_app) end
[ "def request\n @request ||= Rack::MockRequest.new(app)\n end", "def request\n @request ||= Rack::MockRequest.new(mack_app)\n end", "def mock_request\n ugly_warning \"Hard-coded use of Waves::Dispatchers::Default\"\n @request ||= ::Rack::MockRequest.new( ::Waves::Dispatchers::De...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all the Rack::MockResponse objects that get generated by a call.
def responses @responses end
[ "def stub_responses\n Creditsafe::Api::DummyResponse.new\n end", "def flexmock_calls\n @calls\n end", "def responses\n @@responses ||= []\n end", "def mock_response\n @mock_response ||= mock().tap do |mock_response|\n mock_response.stubs(:messages_seen).retu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Clears all the sessions.
def clear_session Mack::SessionStore.expire_all end
[ "def clear_sessions \n sessions.each do |key, session|\n logger.info \"Closing: #{key}\"\n session.close\n end \n sessions.clear \n reset_password\n end", "def clear_session\n session.clear\n end", "def sessions_reset\n self.sessions_flush\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below:
def max_sum_triangle number = "75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 " number += "40 80 70 33 41 48 72 33 47 32 37 16 94 29 53 71 44 65 25 43 91 52 97 51 14 70 11 33 28 77 73 17 78 39 68 17 57 91 71 52 " number += "38 17 14 91 ...
[ "def max_sum(triangle)\n # creating array from data input\n arr = triangle.each_line.map { |line| line.split.map(&:to_i) }\n arr.inject([]) { |res, x|\n maxes = [0, *res, 0].each_cons(2).map(&:max)\n x.zip(maxes).map{ |a, b| a + b }\n }.max\nend", "def maximum_path(triangle)\n numbers = triangle.split\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /testimonios GET /testimonios.json
def index @testimonios = Testimonio.all end
[ "def index\n @testimonies = Testimony.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @testimonies }\n end\n end", "def index\n @testmonials = Testmonial.all\n\n render json: @testmonials\n end", "def index\n @api_v1_victims = Api::V1::Vic...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /testimonios POST /testimonios.json
def create @testimonio = Testimonio.new(testimonio_params) respond_to do |format| if @testimonio.save format.html { redirect_to @testimonio, notice: 'Testimonio was successfully created.' } format.json { render :show, status: :created, location: @testimonio } else format.htm...
[ "def create\n @tokimon = Tokimon.new(tokimon_params)\n\n respond_to do |format|\n if @tokimon.save\n format.html { redirect_to @tokimon, notice: 'Tokimon was successfully created.' }\n format.json { render :show, status: :created, location: @tokimon }\n else\n format.html { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /testimonios/1 PATCH/PUT /testimonios/1.json
def update respond_to do |format| if @testimonio.update(testimonio_params) format.html { redirect_to @testimonio, notice: 'Testimonio was successfully updated.' } format.json { render :show, status: :ok, location: @testimonio } else format.html { render :edit } format.jso...
[ "def update\n @testmonial = Testmonial.find(params[:id])\n\n if @testmonial.update(testmonial_params)\n head :no_content\n else\n render json: @testmonial.errors, status: :unprocessable_entity\n end\n end", "def update\n @one_test = OneTest.find(params[:id])\n\n respond_to do |format|...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /testimonios/1 DELETE /testimonios/1.json
def destroy @testimonio.destroy respond_to do |format| format.html { redirect_to testimonios_url, notice: 'Testimonio was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @testimony = Testimony.find(params[:id])\n @testimony.destroy\n\n respond_to do |format|\n format.html { redirect_to testimonies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mongotest = Mongotest.find(params[:id])\n @mongotest.destroy\n\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Configuration pointing to the SPEC tests and PIN tool to be used.
def load_configuration # Default configuration. config = File.open('pin_spec.yml', 'r') { |f| YAML.load f } if ARGV[0] # If the first argument is a Yaml configuration file, use that to override # the default configuration. if ARGV[0][-4, 4] == '.yml' config.merge! File.open(ARGV[0], 'r') { |f...
[ "def define_config(tool, options={}, &block)\n tool = tool.to_s\n\n @setup ||= {}\n\n if block\n @setup[tool] = Setup.new(tool, options, &block)\n\n # REMOVED: Doing this automatically made it impossible for tools to set the profile.\n #if tool == current_tool\n # configu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs the SPEC test suite. Args:: config:: the configuration read by load_configuration
def run_suite(config) # Build the sandbox. FileUtils.rm_rf config[:output_dir] if File.exist? config[:output_dir] FileUtils.mkdir_p config[:output_dir] File.chmod 0777, config[:output_dir] temp_dir = File.join config[:output_dir], '__temp_' + "#{Time.now.strftime("%Y%m%d%H%M%S")}_#{$PID}_#{rand(1 << 20)...
[ "def run_start(config)\n puts \"The test run is starting\"\n end", "def run_with_spec_runner(tests)\n execute(spec_runner_command(tests))\n end", "def initialize(config, game)\n @config = config\n @game = game\n # Parse tests suites\n @tests_suites = Dir.glob(\"#{__dir__}/tes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Amalgalite is just the SQLite database without a separate SQLite installation.
def database_type :sqlite end
[ "def openDBAventure()\n\t\treturn SQLite3::Database.new File.expand_path(\"../../../Data/aventure.db\", File.dirname(__FILE__))\n\n\tend", "def load_db\n SQLite3::Database.new(LOCAL_DB)\n end", "def uses_sqlite3?() false end", "def db_create_sqlite3(*args)\n\t\t\tcmd_db_disconnect()\n\t\t\t\n\t\t\tinfo = ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Run the given SQL with the given arguments and return the last inserted row id.
def execute_insert(sql, opts=OPTS) _execute(sql, opts){|conn| log_connection_yield(sql, conn){conn.execute_batch(sql)}; conn.last_insert_rowid} end
[ "def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)\n super\n\n @connection.sql('SELECT @@IDENTITY')\n unless @connection.cmd_fail?\n id = @connection.top_row_result.rows.first.first\n id = id.to_i if id\n return id if id > 0\n end\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Mixes in test interface into the configurable module
def enable_test_interface extend Dry::Configurable::TestInterface end
[ "def enable_test_interface; end", "def default_test; end", "def generalise\n Mutiny::Tests::Test.new(@rest)\n end", "def before_test(test); end", "def setup_config\n # To be Extended\n end", "def setup_suite\n end", "def test_placeholder\r\n end", "def test_options\n { input...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
to achieve the desired result. You should be able to run this file from your terminal with the command `ruby day_4/exercises/methods.rb` example: Write a method below that, when called will print your name
def print_name puts "Will Meighan" end
[ "def names\n\tprint \"Hello, #{first_name_method} #{middle_name_method} #{last_name_method}!\"\nend", "def print_name(name)\n puts name\nend", "def print_name\n puts \"Person called #{@name}\"\n end", "def print_name(name)\n print name\nend", "def print_name\n print \"Person called #{@nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tcpdump_logs GET /tcpdump_logs.json
def index @tcpdump_logs = TcpdumpLog.all end
[ "def browser_logs session\n begin\n print_verbose \"Retrieving browser logs [session: #{session}]\"\n response = RestClient.get \"#{@url}logs/#{session}\", {:params => {:token => @token}}\n logs = JSON.parse(response.body)\n print_good \"Retrieved #{logs['logs'].size} browser logs\"\n logs\n rescue...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /tcpdump_logs POST /tcpdump_logs.json
def create @tcpdump_log = TcpdumpLog.new(tcpdump_log_params) respond_to do |format| if @tcpdump_log.save format.html { redirect_to @tcpdump_log, notice: 'Tcpdump log was successfully created.' } format.json { render :show, status: :created, location: @tcpdump_log } else form...
[ "def index\n @tcpdump_logs = TcpdumpLog.all\n end", "def post_create_clone\n response = self.class.post(\"/service/#{$service_id}/version/#{$new_dev_version}/logging/sftp\", \n headers: { \"Fastly-Key\" => $key},\n body: { \"name\" => \"#{$name}\",\n \"address\" => \"#{$address...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /tcpdump_logs/1 PATCH/PUT /tcpdump_logs/1.json
def update respond_to do |format| if @tcpdump_log.update(tcpdump_log_params) format.html { redirect_to @tcpdump_log, notice: 'Tcpdump log was successfully updated.' } format.json { render :show, status: :ok, location: @tcpdump_log } else format.html { render :edit } forma...
[ "def s3LogJsonUpdate\n logs_json_path = \"/etc/instance-controller/logs.json\"\n println \"Updating #{logs_json_path}\"\n json_obj=JSON.parse(File.read(\"#{logs_json_path}\"));\n sections = json_obj[\"logFileTypes\"]\n sections.each { |section|\n if section['typeName'] == 'USER_LOG' then\n user_log = s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tcpdump_logs/1 DELETE /tcpdump_logs/1.json
def destroy @tcpdump_log.destroy respond_to do |format| format.html { redirect_to tcpdump_logs_url, notice: 'Tcpdump log was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @logstash = Logstash.find(params[:id])\n @logstash.destroy\n\n respond_to do |format|\n format.html { redirect_to logstashes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @backuplog = Backuplog.find(params[:id])\n @backuplog.destroy\n\n respon...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This is the depth first method It uses recursion to dive deep as possible. When there are no more children, it checks if the payload matches the target before backing downwards. It eventually gives up when the first_node has no more children and doesn't match the payload.
def depth_first(node, target) if node.children node.children.each do |child| depth_first(child, target) end end return 'Found your target' if node.payload == target 'No luck' end
[ "def depth_first_search target\n\t\topen_stack = [@root]\n\t\tuntil open_stack.empty?\n\t\t\tcurrent = open_stack.pop #currently checks the top element in the stack\n\t\t\treturn current if current.value == target\n\t\t\t#left off here (unfinished)\n\t\t\topen_stack.pop current.right_child unless current.right_chi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Find entities which match all attributes attributes: Hash of attributes to match Returns: Array of entity objects.
def find_all_by(attributes = {}) raise NotImplementedError.new end
[ "def matching_entities( entity_hash )\n\t\tinitial_set = if self.one_of.empty?\n\t\t\t\tentity_hash.values\n\t\t\telse\n\t\t\t\tentity_hash.values_at( *self.one_of )\n\t\t\tend\n\n\t\twith_one = initial_set.reduce( :| ) || Set.new\n\t\twith_all = entity_hash.values_at( *self.all_of ).reduce( with_one, :& )\n\t\twit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
tries to get logs from current or previous pod depending on if it restarted TODO: move into resource_status.rb
def logs(container, end_time) fetch_logs(container, end_time, previous: !!restart_details) rescue *SamsonKubernetes.connection_errors # not found or pod is initializing begin fetch_logs(container, end_time, previous: !restart_details) rescue *SamsonKubernetes.connection_errors ...
[ "def fetch_logs(container, end_time, previous:)\n name = @pod.dig_fetch(:metadata, :name)\n namespace = @pod.dig_fetch(:metadata, :namespace)\n\n if previous\n SamsonKubernetes.retry_on_connection_errors do\n tries = 3\n tries.times do |i|\n logs = @c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
if the pod is still running we stream the logs until it times out to get as much info as possible necessary since logs often hang for a while even if the pod is already done
def fetch_logs(container, end_time, previous:) name = @pod.dig_fetch(:metadata, :name) namespace = @pod.dig_fetch(:metadata, :namespace) if previous SamsonKubernetes.retry_on_connection_errors do tries = 3 tries.times do |i| logs = @client.get_pod...
[ "def logs(container, end_time)\n fetch_logs(container, end_time, previous: !!restart_details)\n rescue *SamsonKubernetes.connection_errors # not found or pod is initializing\n begin\n fetch_logs(container, end_time, previous: !restart_details)\n rescue *SamsonKubernetes.connection...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update user if they sent user params, otherwise return true. This is important because this controller is also handling removing trophies. (but we should move that to a different controller)
def conditionally_update return true unless params[:user] @user.update(user_params) end
[ "def update?\n user == identity.user\n end", "def update_user\n end", "def update?\n record.try(:user) == user || user.admin?\n end", "def user_can_change_info?\n @user_to_modify = User.find_by(id:params[:id])\n @user_now = User.find_by(username: params[:current_user])\n\n if !@user_now\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
if the user wants to remove any trophies, do that here.
def process_trophy_removal params.keys.select { |k, _v| k.starts_with? 'remove_trophy_' }.each do |smash_trophy| smash_trophy = smash_trophy.sub(/^remove_trophy_/, '') current_user.trophies.where(work_id: smash_trophy).destroy_all end end
[ "def remove_tower\n end", "def remove_toy(toy)\n if toy.template.identifier != Constants::SCENE_TOY_IDENTIFIER\n undoManager.registerUndoWithTarget(self, selector: 'add_toy:', object: toy)\n @toys_in_scene.delete(toy)\n unredo\n @selected = nil #@current_tool == :grab ? @strokes.most_rec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set default balance to 0
def set_defaults self.balance ||= 0 end
[ "def set_default_balance\n self.balance ||= 0\n end", "def set_balance!(value)\n\t\t@balance.balance = value\n\t\t@bet = 0 \n\tend", "def zero_difference_balance\n @_zero_difference_balance ||= [overpaid_balance, unpaid_balance].max\n end", "def update_balance(old_value, new_value = 0)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get All Product in Wishlist for User
def index @wishlist = Wishlist.where(:user_id => current_user.id) @wishlist_items = Wishitem.where(:wishlist_id => @wishlist) end
[ "def wishlist\n if session[:wishlist].present?\n @products = session[:wishlist].map do |id|\n Product.find(id)\n end\n end\n end", "def index\n @user_wishlists = UserWishlist.where(\"user_id = ?\", current_user.id)\n end", "def get_wish_list\n check_user_authorization\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /deweys_power_panels/1 GET /deweys_power_panels/1.xml
def show @deweys_power_panel = DeweysPowerPanel.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @deweys_power_panel } end end
[ "def new\n @deweys_power_panel = DeweysPowerPanel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @deweys_power_panel }\n end\n end", "def panel id\n get_request \"panels/#{id}\"\n end", "def panels(params = {}, opts = { full: true, page: 1,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /deweys_power_panels/new GET /deweys_power_panels/new.xml
def new @deweys_power_panel = DeweysPowerPanel.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @deweys_power_panel } end end
[ "def new\n @panel = Panel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @panel }\n end\n end", "def new\n @internalpanel = Internalpanel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @inte...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /deweys_power_panels POST /deweys_power_panels.xml
def create @deweys_power_panel = DeweysPowerPanel.new(params[:deweys_power_panel]) respond_to do |format| if @deweys_power_panel.save format.html { redirect_to(@deweys_power_panel, :notice => 'Deweys power panel was successfully created.') } format.xml { render :xml => @deweys_power_pane...
[ "def new\n @deweys_power_panel = DeweysPowerPanel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @deweys_power_panel }\n end\n end", "def update\n @deweys_power_panel = DeweysPowerPanel.find(params[:id])\n\n respond_to do |format|\n if @de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /deweys_power_panels/1 PUT /deweys_power_panels/1.xml
def update @deweys_power_panel = DeweysPowerPanel.find(params[:id]) respond_to do |format| if @deweys_power_panel.update_attributes(params[:deweys_power_panel]) format.html { redirect_to(@deweys_power_panel, :notice => 'Deweys power panel was successfully updated.') } format.xml { head :...
[ "def update\n @panel = Panel.find(params[:id])\n\n respond_to do |format|\n if @panel.update_attributes(params[:panel])\n format.html { redirect_to(admin_panel_path(@panel), :notice => 'Panel was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /deweys_power_panels/1 DELETE /deweys_power_panels/1.xml
def destroy @deweys_power_panel = DeweysPowerPanel.find(params[:id]) @deweys_power_panel.destroy respond_to do |format| format.html { redirect_to(deweys_power_panels_url) } format.xml { head :ok } end end
[ "def destroy\n @panel = Panel.find(params[:id])\n @panel.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_panels_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @panel = Panel.find(params[:id])\n @panel.destroy\n\n respond_to do |format|\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
called by insurance_billing/sidebar_right also called by _patient_claim partial sums the eob payments
def ins_billing_eob_payments(billing) payment = 0 billing.eobs.each do |eob| payment += eob.payment_amount end return payment end
[ "def save_total_amounts_in_patient_record(insurance_eob)\r\n insurance_eob.total_submitted_charge_for_claim = format_amount_ui_param(@total_charge)\r\n insurance_eob.total_pbid = format_amount_ui_param(@total_pbid)\r\n insurance_eob.total_allowable = format_amount_ui_param(@total_allowable)\r\n insuranc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
2x1 MUX for the Signal Inverter Demonstrated The correctness of it in the VHDL programs. Essentially the logic table overlapped with XOR.
def MUX2X1(x,y) XOR(x,y); end
[ "def ALU1BIT(a,b,cin,binv,op1,op2) \n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\t#Send out an array pair of result, cout\n\treturn MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1]\nend", "def ALU1BIT_OF (a,b,cin,binv,op1,op2)\n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\tputs s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
2BitDecoder Maps a 2bit op signal into a size 4 array of signals. Only one of which are true.
def DECODER2(x,y) #Sends out an array of decoded values return AND(NOT(x),NOT(y)),AND(NOT(x),y),AND(x,NOT(y)),AND(x,y) end
[ "def read_bit_array(length)\n data = reader.read((length+7)/8)\n data.unpack(\"b*\").first. # Unpack into a string of \"10101\"\n split(\"\").map { |c| c == \"1\" }.shift(length) # Return true/false array\n end", "def decode_png_resample_2bit_value(value)\n value << 6 | value << 4 | va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
4X1 MUX Utilizes the 2BitDecoder to map the op signal to the correct ALU output.
def MUX4X1(x,y,a,b,op1,op0) d = DECODER2(op1,op0) OR(OR(AND(x,d[0]),AND(y,d[1])),OR(AND(a,d[2]),AND(b,d[3]))) end
[ "def ALU1BIT_OF (a,b,cin,binv,op1,op2)\n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\tputs sUM_RESULT[0]\n\tovf = OF_CHECKING(a,b,sUM_RESULT[0])\n\t#Send out an array triple of result, cout, overflow\n\treturn MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1], ovf\nend", "def ALU1BIT(a,b,ci...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
1Bit ALU Computes and,or,sum and sends out the overflow, result and a carry out.
def ALU1BIT(a,b,cin,binv,op1,op2) b = MUX2X1(b,binv) sUM_RESULT = ADDER(a,b,cin) #Send out an array pair of result, cout return MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1] end
[ "def ALU1BIT_OF (a,b,cin,binv,op1,op2)\n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\tputs sUM_RESULT[0]\n\tovf = OF_CHECKING(a,b,sUM_RESULT[0])\n\t#Send out an array triple of result, cout, overflow\n\treturn MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1], ovf\nend", "def ALU16BIT(a,b,c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
1Bit ALU with Overflow Checking Same as ALU but with Overflow Checking
def ALU1BIT_OF (a,b,cin,binv,op1,op2) b = MUX2X1(b,binv) sUM_RESULT = ADDER(a,b,cin) puts sUM_RESULT[0] ovf = OF_CHECKING(a,b,sUM_RESULT[0]) #Send out an array triple of result, cout, overflow return MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1], ovf end
[ "def ALU1BIT(a,b,cin,binv,op1,op2) \n\tb = MUX2X1(b,binv)\n\tsUM_RESULT = ADDER(a,b,cin)\n\t#Send out an array pair of result, cout\n\treturn MUX4X1(AND(a,b),OR(a,b),sUM_RESULT[0],0,op1,op2), sUM_RESULT[1]\nend", "def ALU16BIT(a,b,cin,binv,op1,op2)\n\tresult = [nil]*16\n\t15.downto(1).each{|i| result[i],cin = ALU...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
16Bit ALU Connects 16 1Bit ALUs to create a 16 bit result. The last ALU checks for overflow.
def ALU16BIT(a,b,cin,binv,op1,op2) result = [nil]*16 15.downto(1).each{|i| result[i],cin = ALU1BIT(a[i],b[i],cin,binv,op1,op2)} result[0],cout,ovf = ALU1BIT_OF(a[0],b[0],cin,binv,op1,op2) #Send out our result, carry out, and overflow return result,cout,ovf end
[ "def to_16bit a\n a *= 32767\n a = a.round\n\n # clip\n a = 32767 if a > 32767\n a = -32767 if a < -32767\n\n # round\n [a, a].pack('s<s<')\nend", "def process_16_bit\r\n hex = process_hex_character + process_hex_character +\r\n process_hex_character + process_hex_character\r\n eval(\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints the State of the 16Bit Multiplier
def printState(count,md,mq,ac) puts(count.to_s(2)) puts("MD:" + md.join) puts("AC:" + ac.join) puts("MQ:" + mq.join) end
[ "def print_state\n @@rows.times do |row|\n @@columns.times do |column|\n print '%4.4s' % @state_array[row * @@columns + column].to_s,\" \"\n end\n print \"\\n\"\n end\n print \"\\n\"\n end", "def MULTIPLIER16BIT(multiplicand,multiplier)\n\taccumulator = ([0]*16)+multiplier\t\t\t\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
16Bit Multiplier Performs shift multiplication on two register values and outputs the values in a 32bit register.
def MULTIPLIER16BIT(multiplicand,multiplier) accumulator = ([0]*16)+multiplier #Initialize Concatenated Register [AC]+[MQ] count = 16 #Initialize n-bit count. printState(count,multiplicand,accumulator[16,32],accumulator[0,16]) while(count>=0) #Start: if shiftRight(ac...
[ "def word16(a, b)\n (a << 8) | b\n end", "def left16bit(value)\n value >> 32\n end", "def _interleave_bits_16b(x,y)\n x = (x | (x << 8)) & Magic[3]\n x = (x | (x << 4)) & Magic[2]\n x = (x | (x << 2)) & Magic[1]\n x = (x | (x << 1)) & Magic[0]\n y = (y | (y << 8)) & Magic[3]\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Shifts a Register to the Right
def shiftRight(register) register.unshift(0).pop end
[ "def shiftLeft(register)\n\tregister.shift\n\tregister.push(0)\nend", "def move_right\n @memory_position += 1\n @memory_position = 0 if @memory_position > 0xfffffe\n end", "def shift() end", "def mov_imm_to_reg reg, imm\n @reg[reg] = imm\n end", "def handle_shift\n # rm_ref = arg.argument\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Shifts a Register to the Left
def shiftLeft(register) register.shift register.push(0) end
[ "def shiftRight(register)\n\tregister.unshift(0).pop\nend", "def rotate_left(value, shift)\n ((value << shift) | (value >> (20 - shift))) & 0xFFFFF\n end", "def left_rotate(value, shift)\n ((value << shift) & 0xffffffff) | (value >> (32 - shift))\nend", "def move_left\n @memory_position -= 1\n @mem...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gives the template of an use case as JSON
def template_use_case @use_case_template = UseCaseTemplate.find(params[:use_case_template_id]) @json_obj = JSON.parse(@use_case_template.template_form) respond_to do |format| format.js {render 'template_form'} end end
[ "def format_template(template)\n obj_template(template).to_json\n end", "def generate_template(template)\n generate_json template, !template.nopretty\nend", "def template_source_for_aws\n template_type == 'dsl' ? JSON.pretty_generate(template) : template_source\n end", "def temp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gives the list of documents of a project to attach to a use case
def attach_document @use_case = UseCase.find(params[:id]) @document_projects = DocumentProject.where(:project_id => params[:project_id]) respond_to do |format| format.html end end
[ "def use_case_documents\n documents = []\n if not self.requirement.nil?\n self.requirement.use_cases.each do |use_case|\n documents.concat use_case.document_projects\n end\n end\n if not self.use_case.nil?\n documents.concat self.use_case.document_projects\n end\n\n return do...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gives the view of the requirement of a certain use case
def requirements @use_case = UseCase.find(params[:id]) @project = @use_case.project @requirements = @use_case.requirements respond_to do |format| format.html end end
[ "def viewing_hint; end", "def matches_requirement?(query, option, requirement); end", "def purpose\n labware.purpose\n end", "def show\n @user_requirement = UserRequirement.find(params[:id])\n end", "def chooseView\n # views = choose(@schemas)[1][:views]\n # choose(views)\n @st.addView[:NAM...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gives the view of the tasks of a certain use case
def tasks @use_case = UseCase.find(params[:id]) @project = @use_case.project respond_to do |format| format.html end end
[ "def interviewer_tasks\n tasks.find(:all, :conditions => { :context => 'interviewers', :show_for_context_object_tasks => true })\n end", "def show\n appctrl_show( 'Task' )\n end", "def task_view\n @dataset = @user.datasets.find(params[:id])\n raise ActiveRecord::RecordNotFound unless @dataset\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /freelancer_knowledges GET /freelancer_knowledges.json
def index @freelancer_knowledges = FreelancerKnowledge.all end
[ "def index\n @knowledges = Knowledge.order(\"created_at desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @knowledges }\n end\n end", "def index\n @carrierknowledghes = Carrierknowledghe.all\n end", "def new\n @knowledge = current_user.know...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /freelancer_knowledges/1 DELETE /freelancer_knowledges/1.json
def destroy @freelancer_knowledge.destroy respond_to do |format| format.html { redirect_to freelancer_knowledges_url, notice: 'Freelancer knowledge was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @acknowledgment = Acknowledgment.find(params[:id])\n @acknowledgment.destroy\n\n respond_to do |format|\n format.html { redirect_to(acknowledgments_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n response = RestClient.delete $api_service+\"/claim_issues/\"+p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
read_cart_solved_file read the data of the solved cartfile
def read_solved_info(file_path) nil if File.exist? file_path cart_file_resolved = {} IO.foreach(file_path.to_s) do |block| block = block.strip next if block.empty? || (block == "\n") meta = /((?i)binary|git|github)\s+"([^"]+)"\s+"([^"]+)"/.match(block) if meta type = meta[...
[ "def read_cart_file(project_name, cart_file, is_private = false)\n cart_file_data = {}\n\n if File.exist? cart_file\n IO.foreach(cart_file) do |block|\n block = block.strip\n next if (block == '') || (block[0] == \"\\#\")\n\n meta = /((?i)binary|git|github)\\s+\"([^\"]+)\"\\s+(~>|==|>=)?\\s?\"?(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
link to this Goths voting page on gothornot.com
def goth_vote_link(goth) link_to goth.name, "http://gothornot.com/?vote_username=#{goth.name}" end
[ "def vote_cta_url\n ApplicationController.base_url + \"/index.html?photoId=#{id}&action=vote\"\n end", "def image_vote_link(image, vote)\n current_vote = image.users_vote(User.current)\n vote_text = if vote.zero?\n \"(x)\"\n else\n image_vote_as_short...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /tipo_trabajadors GET /tipo_trabajadors.json
def index @tipo_trabajadors = TipoTrabajador.all end
[ "def index\n @tipotrabajadors = Tipotrabajador.all\n end", "def index\n @tipo_tramits = TipoTramit.all\n end", "def index\n @tipo_actividad_turisticas = TipoActividadTuristica.all\n end", "def index\n @territorios = Territorio.all\n\n respond_to do |format|\n format.html # index.html.er...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /tipo_trabajadors POST /tipo_trabajadors.json
def create @tipo_trabajador = TipoTrabajador.new(tipo_trabajador_params) respond_to do |format| if @tipo_trabajador.save format.html { redirect_to @tipo_trabajador, notice: 'Tipo trabajador was successfully created.' } format.json { render :show, status: :created, location: @tipo_trabajad...
[ "def create\n @tipotrabajador = Tipotrabajador.new(tipotrabajador_params)\n\n respond_to do |format|\n if @tipotrabajador.save\n format.html { redirect_to @tipotrabajador, notice: 'Tipotrabajador was successfully created.' }\n format.json { render :show, status: :created, location: @tipotra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /tipo_trabajadors/1 PATCH/PUT /tipo_trabajadors/1.json
def update respond_to do |format| if @tipo_trabajador.update(tipo_trabajador_params) format.html { redirect_to @tipo_trabajador, notice: 'Tipo trabajador was successfully updated.' } format.json { render :show, status: :ok, location: @tipo_trabajador } else format.html { render :...
[ "def update\n respond_to do |format|\n if @trabajo.update(trabajo_params)\n format.html { redirect_to cliente_path(@cliente), notice: 'Trabajo was successfully updated.' }\n format.json { render :show, status: :ok, location: cliente_trabajo_path(@cliente, @trabajo) }\n else\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /tipo_trabajadors/1 DELETE /tipo_trabajadors/1.json
def destroy @tipo_trabajador.destroy respond_to do |format| format.html { redirect_to tipo_trabajadors_url } format.json { head :no_content } end end
[ "def destroy\n @tipologium = Tipologium.find(params[:id])\n @tipologium.destroy\n\n respond_to do |format|\n format.html { redirect_to tipologia_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
STONE PATH TASK RELATED METHODS _____________________________________________________________________ We need to create the stone path task "Evaluate Proposal" and assign it to a workbench of an Organization
def send_evaluate_prop task = @proposal.evaluate_proposals.create task.workbench = Organization.find params[:organization][:organization_id] task.save redirect_to :action => "pending" end
[ "def add_task_to_harvest(project_name, task_desc)\nstr = <<EOS\n <task>\n <billable-by-default type=\"boolean\">true</billable-by-default>\n <default-hourly-rate type=\"decimal\"></default-hourly-rate>\n <is-default type=\"boolean\">false</is-default>\n <name>#{task_desc}</name>\n </task>\nEOS\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch a list of webhook logs Returns a list of webhook logs. Response includes pagination.
def get_webhook_logs(opts = {}) data, _status_code, _headers = get_webhook_logs_with_http_info(opts) data end
[ "def list(options={})\n Mailgun.submit(:get, log_url, options)\n end", "def logs\n log_url = api.get_logs(name).body\n log_uri = URI.parse log_url\n\n http = Net::HTTP.new log_uri.host, log_uri.port\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n reques...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if exit code is successful
def success? exit_code == 0 end
[ "def successful?\n exit_code == 0\n end", "def success?\n exit_status == 0\n end", "def success?\n exited? ? exitstatus == 0 : nil\n end", "def failure?\n exit_code != 0\n end", "def success?\n # note that Linux ruby returns nil when exitstatus is nil and a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Check if exit code is not successful
def failure? exit_code != 0 end
[ "def successful?\n exit_code == 0\n end", "def success?\n exit_code == 0\n end", "def success?\n exit_status == 0\n end", "def error?\n !Array(valid_exit_codes).include?(exitstatus)\n end", "def success?\n exited? ? exitstatus == 0 : nil\n end", "def has...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
FORCE to implement content_for in controller
def view_context super.tap do |view| (@_content_for || {}).each do |name,content| view.content_for name, content end end end
[ "def content_for\n @content_for\n end", "def view_context\n super.tap do |view|\n (@_content_for || {}).each do |name,content|\n view.content_for name, content\n end\n end\n end", "def content_controller\n self\n end", "def global_content_for(name, content =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the Typekit API token to be used for subsequent calls.
def set_token(token) headers 'X-Typekit-Token' => token end
[ "def set_OAuthToken(value)\n set_input(\"OAuthToken\", value)\n end", "def set_token\n @token ||= request.env[\"omniauth.auth\"].credentials.token\n end", "def set_AuthenticationToken(value)\n set_input(\"AuthenticationToken\", value)\n end", "def set_token! model\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List kits available for this account
def kits Kit.all end
[ "def all\n Client.get('/kits').inject([]) do |kits, attributes|\n kits << Kit.new(attributes)\n end\n end", "def list\n @keychain.keys\n end", "def list_keys\n client.make_request('/list-keys', 'get')\n end", "def list_checkout_keys\n CircleCi.request(conf, \"#...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve a specific kit
def kit(id) Kit.find id end
[ "def kit_info(id)\n resp = make_request :get, \"kits/#{id}\"\n check_response_for_field resp, \"kit\"\n end", "def view_kit(id)\n resp = @api.kit_info(id)\n @io.display_kit_info resp\n # return the id so a queued operation can continue operating on this kit\n id\n end", "def list_and_select_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a new kit
def create_kit(params) Kit.create(params) end
[ "def create(params)\n params = @@defaults.merge(params)\n response = Client.post(\"/kits\", :query => params)\n Kit.new(response)\n end", "def create\n # raise params[:kit].inspect\n @kit = Kit.new(params[:kit])\n\n respond_to do |format|\n if @kit.save\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve a specific Family
def family(id) Family.find(id) end
[ "def find(family_id)\n all.each do |family|\n if family.family_id == family_id\n return family\n end\n end\n return nil\n end", "def show\n @family = Family.find(params[:id])\n end", "def family_by_name(name)\n Family.find_by_name(name)\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve a Family by Typekit slug
def family_by_slug(slug) Family.find_by_slug(slug) end
[ "def find_by_slug(slug)\n find(Client.get(\"/families/#{slug}\")['id'])\n end", "def find(slug)\n type = slug.to_s.demodulize.classify\n\n subclasses.find do |subclass|\n subclass.name.gsub(prefix, '') == type.to_s.gsub(prefix, '')\n end || raise(TypeError.new(type, types...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve a Family by font family name
def family_by_name(name) Family.find_by_name(name) end
[ "def get_font(font_name)\n fonts[font_name]\n end", "def parse_font_family(format)\n font = format[:font_family].to_s.split.last\n valid_values = [:none, :roman, :swiss, :modern, :script, :decorative]\n if valid_values.include?(font)\n return font\n elsif valid_values.incl...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the next consecutive semester and year same as above, except instance method
def get_next_semester_and_year return Semester.get_next_semester_and_year(semester, year) end
[ "def year\n ((semester - 1) / 2) + 1\n end", "def next_year\n AcademicYear.find_by(year: self.year + 1)\n end", "def next_semester_indigit\n year = @indigit[0..3]\n term = @indigit[4..-1]\n next_semester = \"\"\n if term == FALL_START_MONTH\n next_semester = (year.to_i + 1).to_s + SPRIN...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
follow character straigh and diagonal
def follow_char(character) sx = distance_x_from(character.x) sy = distance_y_from(character.y) if sx != 0 && sy != 0 move_diagonal(sx > 0 ? 4 : 6, sy > 0 ? 8 : 2) elsif sx != 0 move_straight(sx > 0 ? 4 : 6) elsif sy != 0 move_straight(sy > 0 ? 8 : 2) end end
[ "def diagonal_up_to_string(row_index, col_index)\n #move to edge\n until row_index == @rows - 1 || col_index == 0\n row_index += 1\n col_index -= 1\n end\n\n #form diagonal string from edge\n diagonal_string = \"\"\n while row_index > 0 && col_index < @cols\n diagonal_string += @gri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
jump to specific tiles
def jumpto_tile(x, y) jumpto(0, [x, y]) end
[ "def goto(coords)\n Walker.new.walk_to(coords)\n nil\n end", "def move_one begTile\n @maze.get_adjacent_tiles(begTile).each do |tile|\n if (tile.is_floor) && (!@tiles.include? tile)\n @tiles.push tile\n self.move_one tile\n end\n end\n end", "def jump_next_view ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
User anime sprite creation
def create_anime_sprite_object(item) $game_player.anime_action.each {|i| if i.user == self if i.custom_graphic @transparent = false i.user.using_custom_g = false end $game_player.anime_action.delete(i) end} if PearlKernel.user_graphic != "nil" return if PearlKern...
[ "def main_sprite ; end", "def call_idle(sprite, anime)\n $game_player.set_step_anime(anime)\n $game_player.set_graphic(sprite)\n end", "def create_oneanim_sprite\n @one_anim = Sprite_OneAnim.new(@viewport1)\n end", "def call_idle(sprite, anime)\n $game_player.set_step_anime(anime)\n $game...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
reset knockdown enemies game player call
def reset_knockdown_enemies $game_map.events.values.each do |event| if event.knockdown_data[1] != nil event.knockdown_data[0] = 0 event.knowdown_effect(2) end if event.deadposee and event.killed $game_self_switches[[$game_map.map_id, event.id, PearlKernel::Knockdown...
[ "def reset_player args\n args.state.player.x = 0\n args.state.player.y = args.state.bridge_top\n args.state.player.dy = 0\n args.state.player.dx = 0\n args.state.enemy.hammers.clear # empties hammer collection\n args.state.enemy.hammer_queue.clear # empties hammer_queue\n args.state.game_over_at = args.state...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints the supplied message to the socket.
def print_raw(msg = '') @sock.write(msg) @sock.flush msg end
[ "def print(msg = '')\n\t\t@sock.write(msg)\n\t\t@sock.flush\n\n\t\tmsg\n\tend", "def puts(message)\n\t\t@socket.puts(message)\n\tend", "def send(message)\n puts prefix + message\n end", "def print_message(msg)\n print \">> #{msg.to_s} \\n\"\n end", "def send_single_line_message(socket, mes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /credit_point_packs GET /credit_point_packs.json
def index @credit_point_packs = CreditPointPack.order_by_price end
[ "def create\n @credit_point_pack = CreditPointPack.new(credit_point_pack_params)\n\n respond_to do |format|\n if @credit_point_pack.save\n format.html { redirect_to @credit_point_pack, notice: 'Credit point pack was successfully created.' }\n format.json { render :show, status: :created, lo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /credit_point_packs POST /credit_point_packs.json
def create @credit_point_pack = CreditPointPack.new(credit_point_pack_params) respond_to do |format| if @credit_point_pack.save format.html { redirect_to @credit_point_pack, notice: 'Credit point pack was successfully created.' } format.json { render :show, status: :created, location: @cr...
[ "def create\n @pack = Pack.new(pack_params)\n\n if @pack.save\n render json: @pack, status: :created\n else\n render json: @pack.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @credit_point_pack.update(credit_point_pack_params)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /credit_point_packs/1 PATCH/PUT /credit_point_packs/1.json
def update respond_to do |format| if @credit_point_pack.update(credit_point_pack_params) format.html { redirect_to @credit_point_pack, notice: 'Credit point pack was successfully updated.' } format.json { render :show, status: :ok, location: @credit_point_pack } else format.html ...
[ "def update\n if @recycling_point.update(recycling_point_params)\n render json: @recycling_point, status: :ok\n else\n render json: @recycling_point.errors, status: :unprocessable_entity\n end\n end", "def update\n @pack = Pack.find(params[:id])\n\n respond_to do |format|\n if @pack...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }