query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
calculate the distance between two tiles
def linear_distance(tile_a, tile_b) x1, y1 = tile_a.x, tile_a.y x2, y2 = tile_b.x, tile_b.y Math.sqrt((x2 - x1)**2 + (y2 - y1)**2).abs end
[ "def find_distance_between(cell1, cell2)\n if cell1.nil? || cell2.nil?\n return 0\n end\n\n if cell1.col == cell2.col || cell1.row == cell2.row\n return ((cell1.row - cell2.row) + (cell1.col - cell2.col)).abs\n end\n\n 0\n end", "def get_heuristic_distance(node1, node2)\n ((node1.x - ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
find a 90 degree path between two tiles
def find_path(tile_a, tile_b) if rand(0..1).floor() === 1 # start horizontal x, y = tile_a.x, tile_b.y else # start vertical x, y = tile_b.x, tile_a.y end turn_point = tile_by_coordinates(x, y) [tile_a, turn_point, tile_b] # if (x2 > x1) # delta_x = x2 - x1 #...
[ "def pathfind begTile, endTile\n @traveled_tiles = [begTile]\n @current_tiles = [begTile]\n @next_tiles = Array.new\n #iterate through the maze one movement at a time, hard stop when all tiles have been exhausted\n while (!@current_tiles.include? endTile) && @traveled_tiles.length < @maze.size\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Ensures that the referrer is the current host, to prevent spoofing
def referrer_is_self?(request) return false if request.referrer.blank? referrer_host = URI.parse(request.referrer).host self_host = URI.parse(request.url).host referrer_host == self_host end
[ "def request_is_self?\n (request.url == request.referer) rescue false\n end", "def set_origin_from_referer\n # self.original_origin = request.env['HTTP_REFERER'] unless request.env['HTTP_REFERER'].blank?\n self.original_origin = request.referer unless request.referer.blank?\n end", "def user_reffered...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load tags from a CSV file (tags must be in the first column) and order them by length
def initialize(csv) @tags = [] CSV.foreach(csv) do |row| @tags << row[0] end @tags.sort!{|x, y| y.length <=> x.length} end
[ "def tags\n CSV.parse(@tags)\n end", "def sorted_tags; end", "def load_csv\n CSV.foreach(@file_path) do |row|\n # Our CSV stores strings only - so we must initialize all our recipes\n recipe = Recipe.new(row[0],row[1])\n # We push them into the cookbook recipes array\n @recipes << rec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Match given strings with tags extracted from the CSV file Return an array of tag
def match(*strings) result = [] @tags.each do |tag| strings.each do |string| if string.downcase =~ /#{tag.downcase}/ strings.delete string result << tag break end end end return result end
[ "def tags\n CSV.parse(@tags)\n end", "def gather_tags(tagnames)\n if(!tagnames)\n return nil\n end\n tags = Array.new\n tagnames.split(',').each do |tagname|\n tag = find_tag(tagname.strip) \n tags.push(tag) if tag\n end \n return tags \n end", "def find_by_uid_csv(csv, u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Handle incoming requests from QRadar
def on_request_uri(cli, request) print_good("#{peer} - Sending privilege escalation payload to QRadar...") print_good("#{peer} - Sit back and relax, Shelly will come visit soon!") send_response(cli, @payload) end
[ "def on_next_request(&blk); end", "def doRequest(request)\n m = request.get_method\n fsmm = \"sip#{m}\".to_sym\n st = run(request)\n\n if fsm_state_responds_to? st, fsmm \n send(fsmm, request, nil)\n elsif fsm_state_responds_to? st, :sipREQUEST_ANY\n send(:sipREQUEST_ANY, re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines if self is a valid Url or not.
def valid? Wgit::Url.valid?(self) end
[ "def validate_url\n begin\n uri = ::URI.parse(self.url)\n if uri && uri.scheme == \"http\" || uri.scheme == \"https\"\n return true\n else\n return [false, \"Url must be properly formatted\"]\n end\n end\n rescue ::URI::InvalidURIError\n end", "def url_appropriate\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Concats self and the link.
def concat(link) Wgit::Url.concat(self, link) end
[ "def append_links\n @append_links = true\n end", "def with_link(*args)\n @links.push(args.length == 1 ? args.first : Link.new(*args))\n self\n end", "def addLink(link)\n @linkList.push(link) ;\n return self ;\n end", "def buildChain chain # chain is an array\n chain.each do |link|\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Normalises/escapes self and returns a new Wgit::Url.
def normalise Wgit::Url.new(@uri.normalize.to_s) end
[ "def normalize\n Wgit::Url.new(@uri.normalize.to_s)\n end", "def normalize_url(options = {})\n href = URI(url)\n href.path = item.normalized_hashed_url(options)\n href.to_s\n end", "def fix_url\n self.url = UrlNormalizer.normalize_entry_url self.url, self\n end", "def bui...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a normalised URI object for this URL.
def to_uri URI(normalise) end
[ "def normalise\n Wgit::Url.new(@uri.normalize.to_s)\n end", "def normalize\n Wgit::Url.new(@uri.normalize.to_s)\n end", "def uri_normalizer; end", "def normalized_uri; end", "def coerce_uri incoming_uri\n if incoming_uri.is_a? Hash\n Addressable::URI.new deep_hash_normalize(i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url containing just the host of this URL e.g. Given is returned.
def to_host host = @uri.host host ? Wgit::Url.new(host) : nil end
[ "def build_url(host)\n host.protocol + host.url\n end", "def build_url(host)\n host.protocol + host.url\n end", "def normalise\n Wgit::Url.new(@uri.normalize.to_s)\n end", "def normalize\n Wgit::Url.new(@uri.normalize.to_s)\n end", "def without_trailing_slash\n end_with?...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url containing just the domain of this URL e.g. Given google.co.uk is returned.
def to_domain domain = @uri.domain domain ? Wgit::Url.new(domain) : nil end
[ "def full_url\n full_domain(:with_protocol => true)\n end", "def to_sub_domain\n return nil unless to_host\n\n dot_domain = \".#{to_domain}\"\n return nil unless include?(dot_domain)\n\n sub_domain = to_host.sub(dot_domain, '')\n Wgit::Url.new(sub_domain)\n end", "def domain\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url containing just the brand of this URL e.g. Given google is returned.
def to_brand domain = to_domain domain ? Wgit::Url.new(domain.split('.').first) : nil end
[ "def get_brand_link(website)\n begin\n @brand_link ||= online_retailer_link(website).url\n rescue\n return nil\n end\n end", "def construct_ss_cathist_url(brand)\n if (brand.casecmp(\"jcrew\") == 0)\n url_str = \"http://api.shopstyle.com/action/apiGetCategoryHistogram?pid=uid289-3680017-16...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the endpoint of this URL e.g. the bit after the host with any slashes included. For example: Wgit::Url.new(" returns "/about.html/". See Wgit::Urlto_path if you don't want the slashes.
def to_endpoint endpoint = @uri.path endpoint = '/' + endpoint unless endpoint.start_with?('/') Wgit::Url.new(endpoint) end
[ "def url\n URI.parse(endpoint).join(path.to_s).to_s\n end", "def path\n URI.parse(@url).path\n rescue URI::InvalidURIError # Invalid URLs will be added and caught when we try to navigate to them\n @url\n end", "def endpointURL\n return request.scheme + '://' + request.host_wit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url containing just the anchor string of this URL e.g. Given about is returned.
def to_anchor anchor = @uri.fragment anchor ? Wgit::Url.new("##{anchor}") : nil end
[ "def without_anchor\n anchor = to_anchor\n without_anchor = anchor ? gsub(anchor, '') : self\n\n Wgit::Url.new(without_anchor)\n end", "def url\n begin\n URI.join(self.root, (self.href || '')).to_s\n rescue StandardError\n nil\n end\n end", "def href_str\n target_url.t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url containing just the file extension of this URL e.g. Given html is returned.
def to_extension path = to_path return nil unless path segs = path.split('.') segs.length > 1 ? Wgit::Url.new(segs.last) : nil end
[ "def process_url_extension(url)\n return url if uses_extension?\n\n url += Ruhoh::Converter.extensions.include?(ext) ? '.html' : ext\n\n # Prettify by default\n @page_data['permalink_ext'] ?\n url :\n url.gsub(/index|index.html$/, '').gsub(/\\.html$/, '')\n end", "def url\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url containing self without a trailing slash. Is idempotent meaning self will always be returned regardless of whether there's a trailing slash or not.
def without_trailing_slash end_with?('/') ? Wgit::Url.new(chop) : self end
[ "def omit_trailing_slash\n end_with?('/') ? Wgit::Url.new(chop) : self\n end", "def without_base\n base_url = to_base\n without_base = base_url ? gsub(base_url, '') : self\n\n return self if ['', '/'].include?(without_base)\n\n Wgit::Url.new(without_base).without_slashes\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url with the base (proto and host) removed e.g. Given search?q=somethingabout is returned. If relative and base isn't present then self is returned. Leading and trailing slashes are always stripped from the return value.
def without_base base_url = to_base without_base = base_url ? gsub(base_url, '') : self return self if ['', '/'].include?(without_base) Wgit::Url.new(without_base).without_slashes end
[ "def omit_base\n base_url = to_base\n omit_base = base_url ? gsub(base_url, '') : self\n\n return self if ['', '/'].include?(omit_base)\n\n Wgit::Url.new(omit_base).omit_slashes\n end", "def without_trailing_slash\n end_with?('/') ? Wgit::Url.new(chop) : self\n end", "def omit_tra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url with the query string portion removed e.g. Given is returned. Self is returned as is if no query string is present. A URL consisting of only a query string e.g. '?q=hello' will return an empty URL.
def without_query_string query = to_query_string without_query_string = query ? gsub(query, '') : self Wgit::Url.new(without_query_string) end
[ "def omit_query\n query = to_query\n omit_query_string = query ? gsub(\"?#{query}\", '') : self\n\n Wgit::Url.new(omit_query_string)\n end", "def omit_fragment\n fragment = to_fragment\n omit_fragment = fragment ? gsub(\"##{fragment}\", '') : self\n\n Wgit::Url.new(omit_fragment)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a new Wgit::Url with the anchor portion removed e.g. Given is returned. Self is returned as is if no anchor is present. A URL consisting of only an anchor e.g. 'about' will return an empty URL. This method assumes that the anchor is correctly placed at the very end of the URL.
def without_anchor anchor = to_anchor without_anchor = anchor ? gsub(anchor, '') : self Wgit::Url.new(without_anchor) end
[ "def to_anchor\n anchor = @uri.fragment\n anchor ? Wgit::Url.new(\"##{anchor}\") : nil\n end", "def remove_url_anchor(url)\n url.gsub /(.+)(#.+)/, '\\1'\nend", "def omit_fragment\n fragment = to_fragment\n omit_fragment = fragment ? gsub(\"##{fragment}\", '') : self\n\n Wgit::Url.ne...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if self is a URL query string e.g. ?q=hello etc.
def is_query_string? start_with?('?') end
[ "def valid_query?\n (query =~ URL_PATTERN) != nil\n end", "def qs_or_hash? url\n hash = false\n qs = false\n hash = true if url.match(/\\#/)\n qs = true if url.match(/\\?/)\n return \"both\" if hash && qs\n return \"hash\" if hash && !qs\n return \"qs\" if !hash && qs\n return \"none\" if !has...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if self is a URL anchor/fragment e.g. top etc.
def is_anchor? start_with?('#') end
[ "def link_contains_anchor?(link)\n uri = URI.parse(link)\n uri.fragment.present?\n rescue URI::InvalidURIError\n false\n end", "def absolute_url?\n (self.include?('://') || self.start_with?('/')) ? true : false\n end", "def id_link?\n @url[0] == '#'\n end", "def local?(href)\n return...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Using the Ruby language, have the function CountingMinutes(str) take the str parameter being passed which will be two times (each properly formatted with a colon and am or pm) separated by a hyphen and return the total number of minutes between the two times. The time will be in a 12 hour clock format. For example: if ...
def counting_minutes(str) time1, time2 = str.split('-') mins1, mins2 = time_to_minutes(time1), time_to_minutes(time2) difference = mins2 - mins1 if difference.negative? difference += 1440 end difference end
[ "def CountingMinutesI(str)\n time1, time2 = str.split(\"-\")\n time_regex = /^(\\d+):(\\d+)(am|pm)/\n \n hour1, minute1, meridian1 = time1.scan(time_regex).first\n hour2, minute2, meridian2 = time2.scan(time_regex).first\n\n if (meridian1 == 'pm')\n hour1 = hour1.to_i + 12\n end \n\n if (meridian2 == 'pm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List all tape statistics. API Key Scope: tape_stats / index
def index_tape_stats(opts = {}) data, _status_code, _headers = index_tape_stats_with_http_info(opts) data end
[ "def index_tape_stats_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TapesApi.index_tape_stats ...'\n end\n # resource path\n local_var_path = '/tape_stats'\n\n # query parameters\n query_params = opts[:query_params] |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List all tape statistics. API Key Scope: tape_stats / index
def index_tape_stats_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TapesApi.index_tape_stats ...' end # resource path local_var_path = '/tape_stats' # query parameters query_params = opts[:query_params] || {} qu...
[ "def index_tape_stats(opts = {})\n data, _status_code, _headers = index_tape_stats_with_http_info(opts)\n data\n end", "def stats\n request :get, \"_stats\"\n end", "def index\n @tw_stats = TwStat.all\n end", "def stats\n perform_get('/stats', Neows::Models::Stat)\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get mount status of Tape. API Key Scope: tapes / mount_status
def mount_status_tape(tape_id, opts = {}) data, _status_code, _headers = mount_status_tape_with_http_info(tape_id, opts) data end
[ "def disk_status\n get_device_info[:disk_status]\n end", "def mount_status_tape_with_http_info(tape_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TapesApi.mount_status_tape ...'\n end\n # verify the required parameter 'tape_id' is set\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get mount status of Tape. API Key Scope: tapes / mount_status
def mount_status_tape_with_http_info(tape_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TapesApi.mount_status_tape ...' end # verify the required parameter 'tape_id' is set if @api_client.config.client_side_validation && tape_id.nil? ...
[ "def mount_status_tape(tape_id, opts = {})\n data, _status_code, _headers = mount_status_tape_with_http_info(tape_id, opts)\n data\n end", "def disk_status\n get_device_info[:disk_status]\n end", "def mounts_info\n @mounts_info ||= vault_client.request(:get, \"/v1/sys/internal/ui/mounts\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Displays a specific tape. API Key Scope: tapes / show
def show_tape(tape_id, opts = {}) data, _status_code, _headers = show_tape_with_http_info(tape_id, opts) data end
[ "def show\n @tape_type = TapeType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tape_type }\n end\n end", "def show\n @mag_tape = MagTape.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Display statistic for a specific tape. API Key Scope: tape_stats / show
def show_tape_stat(tape_id, opts = {}) data, _status_code, _headers = show_tape_stat_with_http_info(tape_id, opts) data end
[ "def show_tape_stat_with_http_info(tape_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TapesApi.show_tape_stat ...'\n end\n # verify the required parameter 'tape_id' is set\n if @api_client.config.client_side_validation && tape_id.nil?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Display statistic for a specific tape. API Key Scope: tape_stats / show
def show_tape_stat_with_http_info(tape_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: TapesApi.show_tape_stat ...' end # verify the required parameter 'tape_id' is set if @api_client.config.client_side_validation && tape_id.nil? fail ...
[ "def show_tape_stat(tape_id, opts = {})\n data, _status_code, _headers = show_tape_stat_with_http_info(tape_id, opts)\n data\n end", "def index_tape_stats(opts = {})\n data, _status_code, _headers = index_tape_stats_with_http_info(opts)\n data\n end", "def index_tape_stats_with_http_in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /staff_measurements GET /staff_measurements.json
def index @staff_measurements = StaffMeasurement.all end
[ "def index\n @measurements = current_account.measurements\n respond_with @measurements\n end", "def show\n @measurement = Measurement.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @measurement }\n end\n end", "def measurements\t\n\t @measurements = Measurement....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /staff_measurements POST /staff_measurements.json
def create @staff_measurement = StaffMeasurement.new(staff_measurement_params) respond_to do |format| if @staff_measurement.save format.html { redirect_to @staff_measurement, notice: (t 'staff_measurements.title')+(t 'actions.created')} format.json { render action: 'show', status: :create...
[ "def create\n @measurements = Measurements.new(measurements_params)\n\n respond_to do |format|\n if @measurements.save\n format.html { redirect_to @measurements, notice: 'Measurements was successfully created.' }\n format.json { render :show, status: :created, location: @measurements }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /staff_measurements/1 PATCH/PUT /staff_measurements/1.json
def update respond_to do |format| if @staff_measurement.update(staff_measurement_params) format.html { redirect_to @staff_measurement, notice: (t 'staff_measurements.title')+(t 'actions.updated')} format.json { head :no_content } else format.html { render action: 'edit' } ...
[ "def update\n respond_to do |format|\n if @measurements.update(measurements_params)\n format.html { redirect_to @measurements, notice: 'Measurements was successfully updated.' }\n format.json { render :show, status: :ok, location: @measurements }\n else\n format.html { render :edit...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /staff_measurements/1 DELETE /staff_measurements/1.json
def destroy @staff_measurement.destroy respond_to do |format| format.html { redirect_to staff_measurements_url, notice: (t 'staff_measurements.title')+(t 'actions.removed') } format.json { head :no_content } end end
[ "def destroy\n @measurement.destroy\n respond_to do |format|\n format.html { redirect_to measurements_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dbh_measurement.destroy\n respond_to do |format|\n format.html { redirect_to dbh_measurements_url }\n for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: get a computer message
def computer_message computer_msg.text end
[ "def get_system_message message\n @webservice.getSystemMessageExt( Tnt::GetSystemMessageExt.new(print_client_id_ext,message) ).getSystemMessageExtResult\n end", "def receive_message(msg)\n speakers = get_speakers(@resource[:name])\n answer = speakers.first.send(msg)\n Puppet.debug(\"#{resource[:name]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Verify that case exists in Court Listener database
def exists_in_CL if !cl_hash errors.add(:cite1, "doesn't exist in CourtListener database.") end end
[ "def test_unexistent_course_registering_member\n\t\tregistering_member = Enrollment.new(:participantID => participants(:one).participantID, :courseID => \"nap09877\")\n\t\tassert Participant.find_by(participantID: registering_member.participantID), \"Member was not found in Participant database\"\n \t\tassert !Cour...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return full Bluebook citation
def full_citation "#{name}, #{cite1} (#{date_decided.year})" end
[ "def citation\n return nil unless owner.present? && dmp_id.is_a?(Identifier)\n\n # authors = owner_and_coowners.map { |author| author.name(false) }\n # .uniq\n # .sort { |a, b| a <=> b }\n # .join(\", \")\n # TODO:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get case info from CourtListener
def cl_hash if @cl_hash return @cl_hash else courtlistener = CourtListener.new @cl_hash = courtlistener.case_by_cite(cite1) end end
[ "def casebody\n retrieve_casebody\n end", "def get_course\n\t return TestCase.find(params[:id]).assignment.course\n end", "def case_activity_list\n\t\t@case_activitites = @surgery_case.case_activities\n\tend", "def case_detail\n {\n admin_status: @user_kyc_detail.admin_status,\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return five most recent citations as courtlistener urls
def recent_citations courtlistener = CourtListener.new citations = courtlistener.citing_opinions(cite1) citation_list = citations[0..4].map do |citation| data_hash = courtlistener.case_data_by_opinion(citation["citing_opinion"]) c = CLOpinion.new(data_hash) c.id = courtlistener.id_from_url...
[ "def get_urls\n\n url_array = []\n top_five = 0\n\n while top_five < 5\n url_array << @news_instance[\"response\"][\"docs\"][top_five][\"web_url\"]\n top_five += 1\n end\n\n # returns the array\n return url_array\n\n end", "def popular_links\n urls.sort_by { |url| -url.num_clic...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Compare function for sorting simulators in order by OS Name: ascending OS Version: descending Device type: iPhone first, then ascending Model: ascending
def sim_list_compare(other) return os_name.to_s <=> other.os_name.to_s unless os_name == other.os_name return other.os_version <=> os_version unless os_version == other.os_version device1, model1 = device_and_model device2, model2 = other.device_and_model return device_compare(device1, dev...
[ "def ordered_by_os_arch_match\n PATHS.sort_by do |path|\n [path.os == OS ? 0 : 1, path.arch == ARCH ? 0 : 1]\n end\n end", "def sort_by_version(images)\n # 7.1 -> [ img1, img2, img3 ]\n # 6 -> [ img4, img5 ]\n # ...\n images.group_by do |image|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the [device, model] for use during sorting Examples: [iPhone, 5s], [iPhone, 6s Plus], [Apple Watch Series 2, 38mm]
def device_and_model if os_name == :watchos # Sample string: Apple Watch Series 2 - 38mm name.split ' - ' else # Sample string: "iPhone 5s" or "iPhone 6 Plus" or "iPad Air 2" if name.start_with? 'Apple TV' # The last part is the model, and the rest is the device ...
[ "def manufacturer_model\n get_prop('ro.product.model')\n end", "def getAvailCPUs(model, display=nil)\n cpuArray = []\n if model == \"MacBook\"\n cpuArray = getCpuArr(@MacBookObjs, display)\n elsif model==\"MacBook Pro\"\n cpuArray = getCpuArr(@MacBookProObjs, display...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the simulators and transforms the simctl json into Simulator objects
def fetch_sims device_list = JSON.parse(list(['-j', 'devices']))['devices'] unless device_list.is_a?(Hash) msg = "Expected devices to be of type Hash but instated found #{device_list.class}" fail Fourflusher::Informative, msg end device_list.flat_map do |runtime_str, devices| ...
[ "def simulators\n @instruments_simulators ||= lambda do\n fetch_devices[:out].chomp.split(\"\\n\").map do |line|\n stripped = line.strip\n if line_is_simulator?(stripped) &&\n !line_is_simulator_paired_with_watch?(stripped) &&\n !line_is_apple_tv?(stripped...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /signspot/projects/1 GET /signspot/projects/1.json
def show @signspot_project = Signspot::Project.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @signspot_project } end end
[ "def new\n @signspot_project = Signspot::Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @signspot_project }\n end\n end", "def getProjectID()\n result = RestClient.get GITHUB_API + PROJECTS_PATH, :accept => 'application/vnd.github.inerti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /signspot/projects/new GET /signspot/projects/new.json
def new @signspot_project = Signspot::Project.new respond_to do |format| format.html # new.html.erb format.json { render json: @signspot_project } end end
[ "def new\n @root = \"projects\"\n @branch = \"new\"\n \n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @new_project = NewProject.new\n\n respond_to do |format|\n format.html # ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /signspot/projects POST /signspot/projects.json
def create @signspot_project = Signspot::Project.new(params[:signspot_project]) respond_to do |format| if @signspot_project.save format.html { redirect_to @signspot_project, notice: 'Project was successfully created.' } format.json { render json: @signspot_project, status: :created, locat...
[ "def create\n find_projects(params[:api_key])\n end", "def create\n project = @user.projects.create(projects_params)\n task = Task.create(project_id: project.id, description: \"Have fun!\")\n render json: project\n end", "def create\n @sproject = Sproject.new(sproject_params)\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /signspot/projects/1 PUT /signspot/projects/1.json
def update @signspot_project = Signspot::Project.find(params[:id]) respond_to do |format| if @signspot_project.update_attributes(params[:signspot_project]) format.html { redirect_to @signspot_project, notice: 'Project was successfully updated.' } format.json { head :no_content } els...
[ "def project_update(project)\n raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?\n put('/projects', nil, project)\n end", "def update\n @sproject = current_user.sprojects.find(params[:id])\n\n respond_to do |format|\n if @sp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /signspot/projects/1 DELETE /signspot/projects/1.json
def destroy @signspot_project = Signspot::Project.find(params[:id]) @signspot_project.destroy respond_to do |format| format.html { redirect_to signspot_projects_url } format.json { head :no_content } end 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 format.json { head :no_content }\n end\n end", "def destroy\n @project.destroy\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /incidents/new GET /incidents/new.xml
def new @incident = Incident.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @incident } end end
[ "def new\r\n @incident = Incident.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @incident }\r\n end\r\n end", "def new\n @incidence = Incidence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { rende...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /incidents/1 DELETE /incidents/1.xml
def destroy @incident = Incident.find(params[:id]) @incident.destroy respond_to do |format| format.html { redirect_to(incidents_url) } format.xml { head :ok } end end
[ "def destroy\n @incidente = Incidente.find(params[:id])\n @incidente.destroy\n\n respond_to do |format|\n format.html { redirect_to(incidentes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attendence = Attendence.find(params[:id])\n @attendence.destroy\n\n respond...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
region applies_to_entities GET rules/:rule_id/entities
def show_entities rule = Rule.find_by(id: HASHIDS.decode(params[:rule_id])) return head :not_found if rule.nil? # raise Exceptions::SecurityTransgression unless rule.viewable_by? current_user render json: rule.entities, host: request.host_with_port, include: ['entity_type'], root: false, status: :ok e...
[ "def add_rule(rule)\n @rule_base.add_rule(rule)\n rule.entities.each do |entity|\n @entities[entity.name] ||= entity\n end\n end", "def update_rules\n handle_response_for_request :rules\n end", "def\tprocess\n\t\t@rules.each do |r|\n\t\t\tr.apply\n\t\tend\n\tend", "def fetch_rules\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Initializes with a Grit::Actor. actor Grit::Actor.
def initialize(actor) @actor = actor end
[ "def actor\n Actor.new(Grit::Actor.new(@user, @email))\n end", "def actor\n Grit::Actor.new(@user, @email)\n end", "def new\n # The variable @actor receive the object actor.\n @actor = Actor.new\n end", "def initialize(actor, project)\n @actor = actor\n @project = project\n end",...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Gets the committer of this Entry. In retweets or favorites, this is the author in the current timeline. Returns a Madrox::Actor.
def committer @committer ||= Actor.new(@commit.committer) end
[ "def author\n GitHub::User.new(commit_data.author.login)\n rescue NoMethodError\n GitHub::User.new(GitHub::UNKNOWN_USER)\n end", "def commit_author(commit)\n h commit.author.name\n end", "def author\n owner_name.empty? ? owner_username : owner_name\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
print to out a list of all breweries ""
def breweries_list Brewery.all.each.with_index(1) do |brewery, i| puts "" puts "" puts "#{i}. #{brewery.name}" end brewery_selection end
[ "def breweries_comma_separated\n brewery_names = []\n \n breweries.each do |b| #equivalent to self.breweries.each\n brewery_names << b.place\n end\n \n brewery_names.join(\", \")\n end", "def print_backpack_list\n output = []\n output << \"Melinda, here's your packing list!\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, ..., n] and you...
def bad_version_finder(array) array.each { |version| return version if isBadVersion(version) } nil end
[ "def first_bad_version_one_liner(n)\n (1..n).bsearch(&method(:is_bad_version))\nend", "def is_bad_version(n)\r\n return true if n > 3\r\n false\r\nend", "def first_bad_version(n)\n middle = n / 2\n puts n\n if is_bad_version(middle) == true\n# start here and go backwards until you find t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Method to do a transfer. Returns: true if can do the transfer and false if has a problem.
def transfer return false if @source_account_id == @destination_account_id return false unless @amount > 0 return false unless Account.exists?(@source_account_id) && Account.exists?(@destination_account_id) return false if AccountService.new(@source_account_id).balance < @amount ...
[ "def transfer_success?(source)\n return source.successful? if source.respond_to?(:successful?)\n source.valid? && source.persisted?\n end", "def transfered?\n self.state == TRANSFERED\n end", "def is_transfer?\n case params[:is_transfer]\n when '1', 't', 'true', 'on'\n return true\n whe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get a caller location by Id
def get_caller_location_by_id(account_number, caller_location_id) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/caller_locations/{caller_location_id}' # process optional q...
[ "def get_location(id)\n return @client.raw(\"get\", \"/ecommerce/locations/#{id}\")\n end", "def location(id)\n @client.get(\"/BikePoint/#{id}\")\n end", "def get_location(id, options = nil)\n @client.raw('get', \"/ecommerce/locations/#{id}\", options)\n end", "def get_location(id, m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete all caller locations
def delete_caller_locations(account_number) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/caller_locations' # process optional query parameters query_builder = APIH...
[ "def cleanup_locations\n Location.all.each do |location|\n location.destroy if has_different_location_uid?(location)\n end\n end", "def cleanup_locations\n Location.all.each do |location|\n location.destroy unless @uf2_location_uids.include?(location.uid)\n end\n end", "def clear_locatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a caller location by id
def delete_caller_location_by_id(account_number, caller_location_id) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/caller_locations/{caller_location_id}' # process optiona...
[ "def delete_location(id)\n delete(\"/locations/#{id}\")\n end", "def delete_location(id)\n return @client.raw(\"delete\", \"/ecommerce/locations/#{id}\")\n end", "def delete(id_to_delete)\n DATABASE.execute(\"DELETE FROM locations WHERE id = '#{id_to_delete}'\")\n end", "def deleteLo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allow clients to get the list of caller locations for the specific account.
def get_caller_locations(account_number, page = 1, limit = 10) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/caller_locations' # process optional query parameters q...
[ "def locations()\n get('transactionLocations')\n end", "def get_caller_location_by_id(account_number, caller_location_id)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/accounts/{account_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Update an account by a given account_number
def update_account(account_number, account_form) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}' # process optional query parameters query_builder = APIHelper.append...
[ "def updateAccount(_account)\n\tbegin\n\t\t# Establish connection with database\n\t\tdbc = Mysql.new(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE)\n\n\t\t# Set values from Account object\n\t\tid = _account.getId()\n\t\tscore = _account.getScore()\n\t\tgames_played = _account.getGamesPlayed()\n\t\tgames_won = _accou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes all cdrs requests from customer's account.
def delete_cdrs(account_number) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/cdrs' # process optional query parameters query_builder = APIHelper.append_url_with_te...
[ "def delete_requests\n self.requests.each {|request| request.destroy}\n end", "def delete_all\n error_occurred = false\n Request.all.each do |request|\n request.cancel_reservation\n if request.isReserved\n error_occurred = true\n else\n request.destroy\n end\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes all trunks from customer's account. Numbers on that trunk must be unassigned and returned to Magic stock
def delete_trunks(account_number) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/trunks' # process optional query parameters query_builder = APIHelper.append_url_wit...
[ "def delete_temp_bills\n for temp_bill in self.temp_bills do\n self.temp_bills.delete(temp_bill)\n temp_bill.destroy\n end\n end", "def delete_trunk_by_id(account_number, trunk_id)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allow clients to get the list of trunks for the specific account
def get_trunks(account_number, page = 1, limit = 10, filter = nil) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/trunks' # process optional query parameters query_b...
[ "def index\n @trunks = Trunk.all\n end", "def get_trunk_by_id(account_number, trunk_id)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/accounts/{account_number}/trunks/{trunk_id}'\r\n\r\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Deletes a trunk from customer's account. Numbers on that trunk must be unassigned and returned to Magic stock.
def delete_trunk_by_id(account_number, trunk_id) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/trunks/{trunk_id}' # process optional query parameters query_builder ...
[ "def delete_account_trunk(account_id, trunk_id, opts = {})\n data, _status_code, _headers = delete_account_trunk_with_http_info(account_id, trunk_id, opts)\n data\n end", "def destroy\n @trunk = Trunk.find(params[:id])\n redirect_target = @trunk.snake ? edit_snake_path(@trunk.snake) : trunks_ur...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allow clients to get the a specific trunk
def get_trunk_by_id(account_number, trunk_id) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/trunks/{trunk_id}' # process optional query parameters query_builder = A...
[ "def get_trunk_by_handle(trunk_handle)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/dids/products/trunks/{trunk_handle}'\r\n\r\n # process optional query parameters\r\n query_builde...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allow clients to get a specific cart item.
def get_item(account_number, cart_id, item_id) # the base uri for api requests query_builder = Configuration.base_uri.dup # prepare query string for API call query_builder << '/accounts/{account_number}/carts/{cart_id}/items/{item_id}' # process optional query parameters qu...
[ "def find_cart_item(product)\n cart_items.find_by(product_id: product)\n end", "def fetch_cart_item(current_user)\n user_cart = Cart.find_by(user_id: current_user.id)\n\n if user_cart\n cart_item = CartItem.find_by(cart_id: user_cart.id, menu_item_id: id)\n if cart_item\n return cart_it...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /states/1/municipalities/1 GET /states/1/municipalities/1.json
def show @municipality = Municipality.find(params[:state_id],params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @municipality } end end
[ "def municipal\n # params[:id] is the location.id of the dropdown\n parent_ids = params[:id].include?(\",\") ? params[:id].split(\",\") : params[:id]\n @municipals = Location.where(parent_id: parent_ids).select(\"name, id, parent_id\").order(\"name asc\")\n\n render :json => @municipals\n end", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: The status priority is a simple map between the status and an integer used to sort launched jobs by priority.
def set_status_priority self.status_priority = STATUS_PRIORITY_MAP[self.status] end
[ "def status_priority\n case status_activity\n when 'success' : 1\n when 'success-building' : 2\n when 'failure' : 3\n when 'failure-building' : 4\n end\n end", "def acquire_priority\n case @event['status']\n when '0', '1'\n 'low'\n when '2', '3'\n 'normal'\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Used to get the total run time of the launched job. If the job is currently running, it will return the difference between the start time and the current time. Returns a time value.
def run_time return nil unless self.start_time (self.end_time || Time.now) - self.start_time end
[ "def get_running_time(job)\n case job.status \n when 'running' then ChronicDuration.output((Time.now - job.started_at+1).to_i, :format => :short) \n when 'done' then ChronicDuration.output((job.completed_at - job.started_at+1).to_i, :format => :short)\n else ''\n end\n end", "def running_time_i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Every time the Rufus scheduler executes a job, it calls this method. This method instantiates a new LaunchedJob and calls LaunchedJobrun_job. rjob A Rufus job object that contains various metadata about the status of a job. time The time when the job got cleared for triggering. Returns nothing.
def call(rjob, time) # Since Rufus scheduler starts a new thread for each job, we must manage the connection # pool ourselves. # http://stackoverflow.com/questions/11248808/connection-pool-issue-with-activerecord-objects-in-rufus-scheduler ActiveRecord::Base.connection_pool.with_connection do ...
[ "def job_to_trigger\n\n @mutex.synchronize do\n if @jobs.size > 0 && Time.now.to_f >= @jobs.first.at\n @jobs.shift\n else\n nil\n end\n end\n end", "def run_template\n launched_job.update(status_message: \"Running TplDevTest job\")\n launched_job.job_log.i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Shortcut to get the JobSpecid of this LaunchedJob
def job_spec_id self.job_spec.id end
[ "def getJobId()\n return @helper.getJobId()\n end", "def job_id\n return @job_id\n end", "def job_id\n igetset(:job_id) { env[\"ID\"] }\n end", "def job_spec_name\n self.job_spec.name\n end", "def job_id\n raise NotImplementedError\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: Shortcut to get the JobSpecname of this LaunchedJob
def job_spec_name self.job_spec.name end
[ "def getJobName()\n return @jobName\n end", "def job_name_entry\n if job\n job.to_s\n else\n job_name_override\n end\n end", "def name_with_job\n return name + \"(\" + job.name + \")\"\n end", "def job_name\n \"#{action_name}_#{model_name}_job\"\n end", "def display_n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Public: This method is used to kill a job. It first stops the thread from executing in the JobScheduler and then it closes out the launched job as it would if it exited normally. Returns nothing.
def kill_job raise UnableToKillJobNotRunningError unless self.status == RUNNING begin JobScheduler.find.try(:kill_job, self) raise KilledJobError.new 'Job Killed' rescue => err job_error_handler(err) ensure close_job end end
[ "def kill\n interface.client.kill_job(job_id)\n end", "def stop\n # TODO: can this be elsewhere?\n puts \"Stopping job #{@sandbox.job.id}\"\n\n @thread.kill\n ActiveRecord::Base.clear_active_connections!\n @mutex.synchronize { @thread_status.running = fal...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: This method is run before the specific run_template method is executed. It is used to intialize any instance variables that may need to be set before running the job (at either the launched_job or job_template level). Returns nothing.
def initialize_job launched_job_initializers job_template_initializers end
[ "def pre_initialize\n end", "def job_template_initializers\n job_template = self.job_spec.job_template\n job_template.launched_job = self\n\n job_template.class.job_initializers.each do |job_initializer|\n job_template.send(job_initializer)\n end\n end", "def pre(env_)\n @registry ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Initializes any modules defined at the launched_job level. Any modules included in the LaunchedJob that need initialization should append the name of the initialization method to the job_initializers class variable. Examples module JobLog def self.included(klass) klass.job_initializers << :initialize_job_log e...
def launched_job_initializers self.class.job_initializers.each do |job_initializer| self.send(job_initializer) end end
[ "def initialize_job\n launched_job_initializers\n \n job_template_initializers\n end", "def job_template_initializers\n job_template = self.job_spec.job_template\n job_template.launched_job = self\n\n job_template.class.job_initializers.each do |job_initializer|\n job_template.send(job_initi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Associates the job template instance with this launched_job instance. Initializes any modules defined at the job template level. Any modules included in the job template that need initialization should append the name of the initialization method to tje job_initializers class variable. Examples module BirstSoa...
def job_template_initializers job_template = self.job_spec.job_template job_template.launched_job = self job_template.class.job_initializers.each do |job_initializer| job_template.send(job_initializer) end end
[ "def initialize_job\n launched_job_initializers\n \n job_template_initializers\n end", "def launched_job_initializers\n self.class.job_initializers.each do |job_initializer|\n self.send(job_initializer)\n end\n end", "def initialize\n job_processor\n end", "def job_template_class\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Runs the job specified in the job template. Returns the result of running the job template.
def run_job_template self.job_spec.job_template.run_template end
[ "def run_template\n launched_job.update(status_message: \"Running TplDevTest job\")\n launched_job.job_log.info \"Logging within TplDevTest job\"\n\n sleep self.sleep_seconds\n\n launched_job.status\n end", "def run\n case self[:job]\n when Proc\n self[:job].call\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Log error message to the log, update the status of the launched job, and reraise the error. Also send job notification email Returns nothing.
def job_error_handler(err) UserMailer.job_notification_email(job_spec, @job_log_s3_full_path).deliver self.update(status: ERROR, status_message: error_message(err)) @job_log.error error_message(err) raise err end
[ "def jobfail(log,msg)\n Rails.logger.error(\"#{log} #{self.id}\")\n self.update_attributes(:status =>'error',:errormsg => msg)\n user = User.find_by_email(self.email)\n UserMailer.job_failed(user,self).deliver \n UserMailer.admin_job_failed(self).deliver\n end", "def error(error_recipients, job, e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Private: Performs any tasks needed to close the job, whether it was successful or not. Currently, this is just to set the final status of the job and save the logs. Returns nothing.
def close_job begin set_close_status self.update(log_file: @job_log_s3_full_path) rescue => err @job_log.error error_message(err) raise err ensure close_job_log end nil end
[ "def job_finished(_job, _lints)\n end", "def check_done\n if @exit_status && @audit_closed\n if @audit_close_timeout\n @audit_close_timeout.cancel\n @audit_close_timeout = nil\n end\n if !@exit_status.success?\n RightScale::PolicyManager.fail(@context.payloa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Init list, optionally with a string of serialized events
def init(str = nil) Thread.current[:ga_events] = [] if str.present? raw_events = JSON.parse(str) raw_events.each { |raw_event| GaEvents::Event.from_hash(raw_event) } end rescue JSON::ParserError nil end
[ "def initialize(list, event)\n @list = list.collect do |command|\n EventPrinter::EventCommand.new(command.code, command.indent, command.parameters, event)\n end\n @event = event\n end", "def parse_events(event_list)\n event_list.collect do |event|\n if event.clas...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /attention_centers GET /attention_centers.json
def index @attention_centers = AttentionCenter.all end
[ "def index\n @centers = Center.all\n end", "def index\n @training_centers = TrainingCenter.all\n end", "def index\n @evac_centers = EvacCenter.all\n render json: @evac_centers\n end", "def index\n @treatment_centers = TreatmentCenter.all\n end", "def index\n #@centers = Center.page(par...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /attention_centers POST /attention_centers.json
def create @attention_center = AttentionCenter.new(attention_center_params) respond_to do |format| if @attention_center.save format.html { redirect_to @attention_center, notice: 'Attention center was successfully created.' } format.json { render :show, status: :created, location: @attenti...
[ "def create\n @center_attention = CenterAttention.new(center_attention_params)\n\n respond_to do |format|\n if @center_attention.save\n format.html { redirect_to @center_attention, notice: \"Center attention was successfully created.\" }\n format.json { render :show, status: :created, locat...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /attention_centers/1 PATCH/PUT /attention_centers/1.json
def update respond_to do |format| if @attention_center.update(attention_center_params) format.html { redirect_to @attention_center, notice: 'Attention center was successfully updated.' } format.json { render :show, status: :ok, location: @attention_center } else format.html { ren...
[ "def update\n respond_to do |format|\n if @center_attention.update(center_attention_params)\n format.html { redirect_to @center_attention, notice: \"Center attention was successfully updated.\" }\n format.json { render :show, status: :ok, location: @center_attention }\n else\n form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /attention_centers/1 DELETE /attention_centers/1.json
def destroy @attention_center.destroy respond_to do |format| format.html { redirect_to attention_centers_url, notice: 'Attention center was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @center.destroy\n respond_to do |format|\n format.html { redirect_to centers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attention = Attention.find(params[:id])\n @attention.destroy\n\n respond_to do |format|\n format.html { redirect_to a...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return an array of historic trading values based on a start and finish
def historic_trading_by_range(region, start, finish) region = AEMO::Region.new(region) if region.is_a?(String) required_data = [] (start..finish).map { |d| { year: d.year, month: d.month } } .uniq.each do |period| required_data += historic_trading(region, period...
[ "def chore_occurrences_between(start, finish)\n [].tap do |occurrences|\n chores.each do |chore|\n items = chore.schedule.occurrences_between(start.to_time, finish.advance(:days => 1).to_time)\n occurrences.concat items.collect { |i| { :date => i.to_date, :chore => chore } }\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return an array of historic trading values for a Year, Month and Region As per the historical data from AEMO
def historic_trading(region, year, month) region = AEMO::Region.new(region) if region.is_a?(String) month = Kernel.format('%02d', month) url = 'https://aemo.com.au/aemo/data/nem/priceanddemand/' \ "PRICE_AND_DEMAND_#{year}#{month}_#{region}1.csv" response = HTTParty.get(u...
[ "def historic_trading_by_range(region, start, finish)\n region = AEMO::Region.new(region) if region.is_a?(String)\n\n required_data = []\n (start..finish).map { |d| { year: d.year, month: d.month } }\n .uniq.each do |period|\n required_data += historic_trading(reg...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /digital_objects/1 GET /digital_objects/1.json
def show render json: { digital_object: @digital_object } end
[ "def show\n @digital_object = DigitalObject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @digital_object }\n end\n end", "def index\n puts params.inspect\n @digital_objects = JSON[access_token.get(\"/api/v1/digital_objects/my\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /subcategoria POST /subcategoria.json
def create @subcategorium = Subcategorium.new(subcategorium_params) respond_to do |format| if @subcategorium.save format.html { redirect_to @subcategorium, notice: 'Subcategorium was successfully created.' } format.json { render :show, status: :created, location: @subcategorium } el...
[ "def create\n @subcategoria = Subcategoria.new(params[:subcategoria])\n\n respond_to do |format|\n if @subcategoria.save\n format.html { redirect_to [:admin, @subcategoria], :notice => 'Subcategorias was successfully created.' }\n format.json { render :json => @subcategoria, :status => :cre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /subcategoria/1 DELETE /subcategoria/1.json
def destroy @subcategorium.destroy respond_to do |format| format.html { redirect_to subcategoria_url, notice: 'Subcategorium was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @subcategorium = Subcategorium.find(params[:id])\n @subcategorium.destroy\n\n respond_to do |format|\n format.html { redirect_to subcategoria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subcategoria = Subcategoria.find(params[:id])\n @subcateg...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List all followers for given relation and klass Example:
def all_followers(relation = "follow", klass = nil) all = followers.by_relation(relation) all = all.by_follower(klass) if klass all.collect do |f| f.follower end end
[ "def all_followees(relation = \"follow\", klass = nil)\n all = followees.by_relation(relation)\n all = all.by_followee(klass) if klass\n\n all.collect do |f|\n f.followee\n end\n end", "def followers\n @followers = Follower.where(:friend_id => @current_user.id)\n end", "def fol...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /career_stats GET /career_stats.json
def index @career_stats = CareerStat.all end
[ "def stats\n get 'stats', format: 'json'\n end", "def stats\n request :get, \"_stats\"\n end", "def index\n @careers = Career.all\n\n render json: @careers\n end", "def manager_analysisd_stats\n get '/manager/stats/analysisd'\n end", "def stats\n service = Service.find(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /career_stats POST /career_stats.json
def create @career_stat = CareerStat.new(career_stat_params) respond_to do |format| if @career_stat.save format.html { redirect_to @career_stat, notice: 'Career stat was successfully created.' } format.json { render :show, status: :created, location: @career_stat } else form...
[ "def index\n @career_stats = CareerStat.all\n end", "def stats\n get 'stats', format: 'json'\n end", "def post_stats(server_count, shards: nil, shard_count: nil)\n jsonPost = {\n server_count: server_count,\n shards: shards,\n shard_count: shard_count\n }.to_json\n @conn.post(\"b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /career_stats/1 PATCH/PUT /career_stats/1.json
def update respond_to do |format| if @career_stat.update(career_stat_params) format.html { redirect_to @career_stat, notice: 'Career stat was successfully updated.' } format.json { render :show, status: :ok, location: @career_stat } else format.html { render :edit } forma...
[ "def update\n @career = Career.find(params[:id])\n\n if @career.update(career_params)\n head :no_content\n else\n render json: @career.errors, status: :unprocessable_entity\n end\n end", "def update\n @career_fair = CareerFair.find(params[:id])\n\n respond_to do |format|\n if @ca...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /career_stats/1 DELETE /career_stats/1.json
def destroy @career_stat.destroy respond_to do |format| format.html { redirect_to career_stats_url, notice: 'Career stat was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @soccer_stat = SoccerStat.find(params[:id])\n @soccer_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/stats\", notice: 'Soccer stats deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n\n head :no_content\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /motions/:motion_id/motion_comments POST /motions/:motion_id/motion_comments.xml
def create respond_to do |format| if motion_comment.save format.html { redirect_to( motion_comment.motion, flash: { success: 'Motion comment created.' } ) } format.xml { render xml: motion_comment, status: :created, location: motion_comment } else format.html { render action: "n...
[ "def update\n motion_comment.assign_attributes motion_comment_attributes\n respond_to do |format|\n if motion_comment.save\n format.html { redirect_to motion_comment.motion, flash: { success: 'Motion comment updated.' } }\n format.xml { head :ok }\n else\n format.html { render ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /motion_comments/1 PUT /motion_comments/1.xml
def update motion_comment.assign_attributes motion_comment_attributes respond_to do |format| if motion_comment.save format.html { redirect_to motion_comment.motion, flash: { success: 'Motion comment updated.' } } format.xml { head :ok } else format.html { render action: "edi...
[ "def update\n @comment = Comment.find(params[:id])\n\n respond_to do |format|\n if @comment.update_attributes(params[:comment])\n format.xml { head :ok }\n format.json { head :ok } \n else\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /motion_comments/1 DELETE /motion_comments/1.xml
def destroy motion_comment.destroy respond_to do |format| format.html { redirect_to( motion_url( motion_comment.motion ), flash: { success: "Motion comment destroyed." } ) } format.xml { head :ok } end end
[ "def destroy\n @comment = Comment.find(params[:id])\n @comment.destroy\n \n respond_to do |format|\n format.xml { head :ok }\n format.json { head :ok } \n end\n end", "def destroy\n @ccomment = Ccomment.find(params[:id])\n @ccomment.destroy\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Goes through the list once storing data encountered in a hash table. If data is repeated, then that node is replaced with the following node. This algorithm is O(n), specially since we assume linked list is not sorted.
def remove_duplicates(linked_list) if !linked_list.is_a?(LinkedList) || linked_list.head == nil return nil end hash_table = {} node = linked_list.head while node.next != nil if hash_table[node.data] node.data = node.next.data node.next = node.next.next else hash_table[node.dat...
[ "def remove_linked_list_duplicates(head)\n current_node = head\n previous_node = head\n number_of_repeats = Hash.new(0)\n while current_node != nil\n if number_of_repeats[current_node.value] > 0\n previous_node.next_node = current_node.next_node\n else\n number_of_repeats[current_node.value] += ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
replace a code with an array of new codes. This is what happens in passes all the time
def replace code , new_codes index = @codes.index code raise "Code not found #{code} in #{self}" unless index @codes.delete_at(index) if( new_codes.is_a? Array) new_codes.reverse.each {|c| @codes.insert(index , c)} else @codes.insert(index , new_codes) end end
[ "def simplify(scode)\n scode.map { |elem| replacement(elem) }\n end", "def process_code(data)\n @codemap.each do |id, spec|\n formatted = spec[:output] ||\n begin\n code = spec[:code]\n lang = spec[:lang]\n\n if code.lines.all? { |line| lin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns if this is a block that ends in a call (and thus needs local variable handling)
def call_block? raise "called" return false unless codes.last.is_a?(CallInstruction) return false unless codes.last.opcode == :call codes.dup.reverse.find{ |c| c.is_a? StackInstruction } end
[ "def captured_by_block?; end", "def block_given?() end", "def last_block?\n return @last_block\n end", "def code_block?\n @code_block\n end", "def block?\n !!block\n end", "def call_block\n return if complete?\n \n begin\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }