query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
POST /persona_punto_venta POST /persona_punto_venta.json | def create
@persona_punto_ventum = PersonaPuntoVentum.new(persona_punto_ventum_params)
respond_to do |format|
if @persona_punto_ventum.save
format.html { redirect_to @persona_punto_ventum.punto_venta, notice: 'Persona punto ventum was successfully created.' }
format.json { render :show, s... | [
"def create\n @punto_ventum = PuntoVentum.new(punto_ventum_params)\n respond_to do |format|\n if @punto_ventum.save\n format.html { redirect_to @punto_ventum, notice: 'Punto venta creado.' }\n format.json { render :show, status: :created, location: @punto_ventum }\n else\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /persona_punto_venta/1 PATCH/PUT /persona_punto_venta/1.json | def update
respond_to do |format|
if @persona_punto_ventum.update(persona_punto_ventum_params)
format.html { redirect_to @persona_punto_ventum, notice: 'Persona punto ventum was successfully updated.' }
format.json { render :show, status: :ok, location: @persona_punto_ventum }
else
... | [
"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"
]
]
}
} |
DELETE /persona_punto_venta/1 DELETE /persona_punto_venta/1.json | def destroy
@punto_venta = PuntoVentum.find(@persona_punto_ventum.punto_venta_id)
@persona_punto_ventum.destroy
respond_to do |format|
format.html { redirect_to @punto_venta, notice: 'Persona punto ventum was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end",
"def destroy\n if @api_v1_person.destroy\n render json: 'deletado'\n end\n \n end",
"def destroy\n @persona = Persona.find(params[:i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the float point of the expression, otherwise raise an error | def to_f
if isFloat? then
value = exp.to_f
return value
elsif exp == "Infinity" then return @@MAX_VALUE
elsif exp == "-Infinity" then return @@MIN_VALUE
else
raise "Non-float conversion in expression: " + exp
end
end | [
"def Float(p0) end",
"def to_float!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n type = TO_FLOAT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 313:11: 'float:'\n match( \"float:\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /dom0s GET /dom0s.json | def index
@dom0s = Dom0.all
end | [
"def get_domoticz_json(domoticz_uri)\n uri = URI(domoticz_uri)\n response = Net::HTTP.get(uri)\n JSON.parse(response)\nend",
"def get_json\n html = Nokogiri::HTML(@page)\n text = open(\"https://theintercept.com/api/requestSIDDocuments/?orderBy=publishedTime&orderDirection=desc&perPage=2000\").read\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /dom0s POST /dom0s.json | def create
@dom0 = Dom0.new(dom0_params)
respond_to do |format|
if @dom0.save
format.html { redirect_to @dom0, notice: 'Dom0 was successfully created.' }
format.json { render :show, status: :created, location: @dom0 }
else
format.html { render :new }
format.json { re... | [
"def index\n @dom0s = Dom0.all\n end",
"def destroy\n @dom0.destroy\n respond_to do |format|\n format.html { redirect_to dom0s_url, notice: 'Dom0 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @dominate = Dominate.new(params[:dominate])\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /dom0s/1 PATCH/PUT /dom0s/1.json | def update
respond_to do |format|
if @dom0.update(dom0_params)
format.html { redirect_to @dom0, notice: 'Dom0 was successfully updated.' }
format.json { render :show, status: :ok, location: @dom0 }
else
format.html { render :edit }
format.json { render json: @dom0.errors,... | [
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end",
"def patch *args\n make_request :patch, *args\n end",
"def patch(data, options={})\n raise NotImplementedEr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /dom0s/1 DELETE /dom0s/1.json | def destroy
@dom0.destroy
respond_to do |format|
format.html { redirect_to dom0s_url, notice: 'Dom0 was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @json.destroy\n\n head :no_content\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def http_delete(path)\n with_rack do\n page.driver.submit :delete, path, {}\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert assets into a gallery or uploader | def insert
@fieldname = params[:fieldname]
@uploader_id = params[:uploader_id]
@assets = Assetabler::Asset.find(params[:asset_ids])
end | [
"def add_assets\n num_files = params[:count].to_i\n \n @new_assets = []\n @new_assets_html = []\n num_files.times do |file_num|\n # recreate the file key from the current index\n file = params[\"file-\"+file_num.to_s]\n @asset = Asset.new(:name => file.original_filename)\n @asset.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Edit an asset will return the edit form | def edit
@asset = Assetabler::Asset.find(params[:id])
end | [
"def edit_asset\n @asset = Asset.find(params[:id])\n end",
"def edit\n @asset = Item.find(params[:id])\n end",
"def update\n @eve_asset = EveAsset.find(params[:id])\n\n respond_to do |format|\n if @eve_asset.update_attributes(params[:eve_asset])\n format.html { redirect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Performs a HTTP request method Request method (:get, :post, :put, :delete) url Target URL payload Delivery content format Delivery format | def request(method, url, payload, format)
opts = {
:method => method,
:url => url,
:payload => payload,
:headers => {:content_type => CONTENT_TYPES[format]},
:timeout => TIMEOUT,
:open_timeout => OPEN_TIMEOUT
}
RestCl... | [
"def perform_request(method, url, params={})\n begin\n response = case method\n when :get\n get(url)\n when :post\n post(url, params)\n when :put\n put(url, params)\n when :delete\n delete(url)\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /vitabus GET /vitabus.json | def index
@vitabus = Vitabu.all
end | [
"def index\n @vitals = Vital.all\n render json: @vitals\n end",
"def index\n @uvps = @idea.uvps.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @uvps }\n end\n end",
"def index\n @vampires = Vampire.all\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /vitabus POST /vitabus.json | def create
@vitabus = Vitabu.new(vitabus_params)
respond_to do |format|
if @vitabus.save
format.html { redirect_to @vitabus, notice: 'Vitabu was successfully created.' }
format.json { render action: 'show', status: :created, location: @vitabus }
else
format.html { render act... | [
"def create\n @vitab = Vitab.new(vitab_params)\n\n respond_to do |format|\n if @vitab.save\n format.html { redirect_to @vitab, notice: 'Vitab was successfully created.' }\n format.json { render action: 'show', status: :created, location: @vitab }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /vitabus/1 PATCH/PUT /vitabus/1.json | def update
respond_to do |format|
if @vitabus.update(vitabus_params)
format.html { redirect_to @vitabus, notice: 'Vitabu was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @vitabus.errors, st... | [
"def update\n respond_to do |format|\n if @vitab.update(vitab_params)\n format.html { redirect_to @vitab, notice: 'Vitab was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vitab.errors,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /vitabus/1 DELETE /vitabus/1.json | def destroy
@vitabus.destroy
respond_to do |format|
format.html { redirect_to vitabus_url }
format.json { head :no_content }
end
end | [
"def destroy\n @vitab.destroy\n respond_to do |format|\n format.html { redirect_to vitabs_url }\n format.json { head :no_content }\n end\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @json.destroy\n\n head... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /navigation_entries/new GET /navigation_entries/new.xml | def new
@navigation_entry = NavigationEntry.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @navigation_entry }
end
end | [
"def new\n @navigation = current_cms.navigations.new(:position => current_cms.navigations.size + 1)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @navigation }\n end\n end",
"def new\n @navigation_entry = NavigationEntry.new\n\n respond_to do |for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /navigation_entries POST /navigation_entries.xml | def create
@navigation_entry = NavigationEntry.new(params[:navigation_entry])
respond_to do |format|
if @navigation_entry.save
format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully created.') }
format.xml { render :xml => @navigation_entry, :status =>... | [
"def create\n @navigation_entry = NavigationEntry.new(params[:navigation_entry])\n\n respond_to do |format|\n if @navigation_entry.save\n format.html { redirect_to @navigation_entry, notice: 'Navigation entry was successfully created.' }\n format.json { render json: @navigation_entry, statu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /navigation_entries/1 PUT /navigation_entries/1.xml | def update
@navigation_entry = NavigationEntry.find(params[:id])
respond_to do |format|
if @navigation_entry.update_attributes(params[:navigation_entry])
format.html { redirect_to(@navigation_entry, :notice => 'Navigation entry was successfully updated.') }
format.xml { head :ok }
... | [
"def update\n @navigation_entry = NavigationEntry.find(params[:id])\n\n respond_to do |format|\n if @navigation_entry.update_attributes(params[:navigation_entry])\n format.html { redirect_to @navigation_entry, notice: 'Navigation entry was successfully updated.' }\n format.json { head :no_c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /navigation_entries/1 DELETE /navigation_entries/1.xml | def destroy
@navigation_entry = NavigationEntry.find(params[:id])
@navigation_entry.destroy
respond_to do |format|
format.html { redirect_to(navigation_entries_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @navigation_entry = NavigationEntry.find(params[:id])\n @navigation_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to navigation_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @navigation = current_cms.all_navigations.find{... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the last geometry from the collection. | def last
self.get_geometry_n(self.num_geometries - 1) if self.num_geometries > 0
end | [
"def last\n each {}\n @collection.last\n end",
"def final_geometry\n # ouput is not cached, so we only retrieve it once\n o = self.output\n if o\n o.final_geometry\n else\n nil\n end\n end",
"def lastpoint\n return self.pointlist()[-1]\n end",
"def la... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dumps points similarly to the PostGIS `ST_DumpPoints` function. | def dump_points(cur_path = [])
self.each do |geom|
cur_path << geom.dump_points
end
cur_path
end | [
"def dump_points(cur_path = [])\n points = [ self.exterior_ring.dump_points ]\n\n self.interior_rings.each do |ring|\n points.push(ring.dump_points)\n end\n\n cur_path.concat(points)\n end",
"def dump_points(cur_path = [])\n cur_path.concat(self.to_a)\n end",
"def dump_poin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Obtain IP address from http request header | def src_addr_on_header
request.headers['X-Forwarded-For'] || request.headers['REMOTE_ADDR']
end | [
"def user_ip\n return request.headers[\"X-Forwarded-For\"] if request.headers[\"X-Forwarded-For\"]\n return request.headers[\"REMOTE_ADDR\"] if request.headers[\"REMOTE_ADDR\"]\n end",
"def parse_ip\n @request[FHOST] || BLANK_STR\n end",
"def best_ip_address\n ip_string = headers['X-Forw... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Obtain HOST FQDN from http request header | def host_on_header
request.headers['HTTP_HOST']
end | [
"def requested_http_host\n @client_headers['Host']\n end",
"def host\n @host || @headers['host'].to_s.split(':')[0].to_s\n end",
"def host\n @request['Host']\n end",
"def host\n parse_host_header unless @host_header_parsed\n @host\n end",
"def proxied_host\n\t\theade... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Obtain User Agent from http request header | def user_agent_on_header
request.headers['HTTP_USER_AGENT']
end | [
"def user_agent\n @headers['User-Agent']\n end",
"def user_agent\n headers[\"User-Agent\"]\n end",
"def agent\n default_header['User-Agent']\n end",
"def user_agent\n @data['user_agent']\n end",
"def user_agent\n @opts[:user_agent]\n end",
"def user_agent(agent)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Renders plain text and html to html. If parse_code isn't true, only runs bluecloth on text outside any ... blocks. | def bluecloth(text, parse_code = true, increment_headers = true)
return text if text.nil?
if parse_code
return BlueCloth::new(text).to_html
end
text = text.dup
out = ''
level = 0
until text.empty? do
if level < 1
# Find start of c... | [
"def render_code(code)\n render_block(Pygments.highlight(code, formatter: 'terminal256', lexer: 'ruby', options: {style: 'bw'}))\nend",
"def parse(text)\n text.split(/(<code.*?>.*?<\\/code>)/m).inject(\"\") do |result, piece|\n if piece =~ /^<code/\n result << highlight(piece.gsub(/<code.*?>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Macro substitutions Expands [[type:resource][name]] macros. Right now, resource is just an attachment. Included types are: url: returns the URL to an attachment image: returns an image tag link: returns a link to an attachment page_nav: A list of subpages attachments: A list of attachments The default action is a link,... | def macro(text)
return text if text.nil?
copy = text.dup
# Links
#
# Example [[image:foo.png][name]]
# 1. the prefix image
# 2. the link, with colon :foo.png
# 3. the link itself foo.png
... | [
"def convert_embedded_image_links_to_textile!\n gsub!(%r{!image (?:(\\w+)/)?(\\d+)!}) do\n size = Regexp.last_match[1] || \"thumb\"\n id = Regexp.last_match[2]\n src = Image.url(size, id)\n link = \"#{MO.http_domain}/images/#{id}\"\n \"\\\"!#{src}!\\\":#{link}\"\n end\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Input: List of names(cohort) Output : Groups of no less than 3, no more than 5 made from the list array cohort, ideally 45 per group Steps to complete: See if cohort is divisible by 5 or 4 create a new hash test if group is divisible by 5 and 4 find remainder of group when divided by 4 or 5 go through array and assign ... | def create_groups(cohort)
if cohort.length % 5 == 0
hash = {}
counter = 1
group_count = cohort.length / 5
remainder = cohort.length % 5
# Set to groups(keys) to members(values)
group_count.times do
hash[counter] = cohort.slice!(0..4)
counter += 1
end
else
hash = {}
coun... | [
"def group_create(cohort)\n cohort_new = cohort.dup # Add this code in to make this non destructive\n if cohort_new.length % 5 == 0\n #Write code to split group into even groups of 5, not necessary for our group.\n\n else\n counter = 1\n hash = Hash.new(0) # Create a new hash with default value of 0\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /military_document_types GET /military_document_types.json | def index
@military_document_types = MilitaryDocumentType.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @military_document_types }
end
end | [
"def list\n\n @document_types = DocumentType.find(:all, :order => 'name')\n end",
"def show\n @military_document_type = MilitaryDocumentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @military_document_type }\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /military_document_types/1 GET /military_document_types/1.json | def show
@military_document_type = MilitaryDocumentType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @military_document_type }
end
end | [
"def index\n @military_document_types = MilitaryDocumentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @military_document_types }\n end\n end",
"def show\n @document_type = DocumentType.find(params[:id])\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /military_document_types/new GET /military_document_types/new.json | def new
@military_document_type = MilitaryDocumentType.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @military_document_type }
end
end | [
"def new\n @page_title = 'Create Document Type'\n @document_type = DocumentType.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_type }\n end\n end",
"def new\n @document_type = DocumentType.new\n\n respond_to do |format|\n format.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /military_document_types POST /military_document_types.json | def create
@military_document_type = MilitaryDocumentType.new(params[:military_document_type])
respond_to do |format|
if @military_document_type.save
format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar criado com sucesso.' }
format.json { render :json ... | [
"def create\n @type_document = TypeDocument.new(type_document_params)\n\n respond_to do |format|\n if @type_document.save\n format.html { redirect_to admin_type_documents_path(@type_document), notice: 'Type document was successfully created.' }\n format.json { render :show, status... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /military_document_types/1 PUT /military_document_types/1.json | def update
@military_document_type = MilitaryDocumentType.find(params[:id])
respond_to do |format|
if @military_document_type.update_attributes(params[:military_document_type])
format.html { redirect_to @military_document_type, :notice => 'Tipo de Documento Militar atualizado com sucesso.' }
... | [
"def update\n respond_to do |format|\n if @document_type.update(document_type_params)\n format.html { redirect_to edit_document_type_path(@document_type), notice: 'El tipo de documento ha sido actualizado satisfactoriamente.' }\n format.json { render :edit, status: :ok, location: @document_typ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /military_document_types/1 DELETE /military_document_types/1.json | def destroy
@military_document_type = MilitaryDocumentType.find(params[:id])
@military_document_type.destroy
respond_to do |format|
format.html { redirect_to military_document_types_url, :notice => 'Tipo de Documento Militar excluído com sucesso.' }
format.json { head :no_content }
end
en... | [
"def destroy\n @document_type = DocumentType.find(params[:id])\n @document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to document_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @document_type = DocumentType.find(params[:id])\n @docume... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Inserts a value to the collection. Returns true if the collection did not already contain the specified element. :type val: Integer :rtype: Boolean =end | def insert(val)
hash[val] = Set.new unless hash[val]
hash[val].add(values.size)
values.push(val)
hash[val].size == 1
end | [
"def insert(val)\n return false if includes?(val)\n set[val] = true\n true\n end",
"def insert(num)\n false if include?(num)\n self[num] << num\n true\n end",
"def insert(value)\n if @root[:value].nil?\n @root[:value] = value\n return true\n end\n return false if c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Removes a value from the collection. Returns true if the collection contained the specified element. :type val: Integer :rtype: Boolean =end | def remove(val)
return false if !hash[val] || hash[val].empty?
# Update values array
idx = hash[val].first
last = values[-1]
values[idx] = last
# Remove last from array
values.pop
# Remove val
hash[val].delete(idx)
# Update last
... | [
"def remove(val)\n return false if !includes?(val)\n set.delete(val)\n true\n end",
"def remove(val)\n return false unless @hh.key?(val)\n @hh.delete(val)\n return true\n end",
"def delete(value)\n index = find(value)\n return false if index == -1\n @inner[inde... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Supported values for options: :region AWS region (e.g. uswest1) :secure true or false, default true. :timeout the timeout, in seconds, when making a request to EMR, default 60. | def initialize(options={})
# There is a cryptic error if this isn't set
if options.has_key?(:region) && options[:region] == nil
raise MissingRegionError, 'A valid :region is required to connect to EMR'
end
options[:region] = 'us-east-1' unless options[:region]
@region = options[:re... | [
"def initialize options = {}\n require 'right_aws'\n\n options.each_key do | key |\n raise ArgumentError, \"unrecognized option \\'#{key}\\'\" unless RECOGNIZED_OPTIONS.include? key\n end\n \n @ec2 = op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Enqueues the action for a single resource. | def enqueue_action_single_resource(action, type, id)
raise BadRequestError, "Must specify an id for changing a #{type} resource" unless id
physical_switch = resource_search(id, type, collection_class(type))
api_action(type, id) do
begin
desc = "Performing #{action} for #{physical_s... | [
"def enqueue_action_single_resource(action, type, id)\n raise BadRequestError, \"Must specify an id for changing a #{type} resource\" unless id\n\n resource = resource_search(id, type, collection_class(type))\n\n api_action(type, id) do\n begin\n desc = \"Performing #{action... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Enqueues the action for multiple resources. For multiple resources, when an error occurs, the error messages must be built individually for each resource. Always responding with status 200. | def enqueue_action_multiple_resources(action, type, id)
enqueue_action_single_resource(action, type, id)
rescue ActiveRecord::RecordNotFound => err
action_result(false, _(err.message))
end | [
"def enqueue_action_multiple_resources(action, type, id)\n enqueue_action_single_resource(action, type, id)\n rescue ActiveRecord::RecordNotFound => err\n action_result(false, _(err.message))\n end",
"def index_ok(resources:)\n render json: resources, status: :ok, include: index_inc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /exercise_templates GET /exercise_templates.json | def index
@exercise_templates = ExerciseTemplate.all
render json: @exercise_templates
end | [
"def index\n @exercise_templates = ExerciseTemplate.all\n end",
"def show\n render json: @exercise_template\n end",
"def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end",
"def list\n @client.make_request :get, templates_path\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /exercise_templates/1 GET /exercise_templates/1.json | def show
render json: @exercise_template
end | [
"def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end",
"def index\n @exercise_templates = ExerciseTemplate.all\n end",
"def create\n @exercise_template = ExerciseTemplate.new(exercise_template_params)\n\n if @exercise_template.save\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /exercise_templates POST /exercise_templates.json | def create
@exercise_template = ExerciseTemplate.new(exercise_template_params)
if @exercise_template.save
render json: @exercise_template, status: :created, location: @exercise_template
else
render json: @exercise_template.errors, status: :unprocessable_entity
end
end | [
"def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end",
"def create\n @questionnaire_template = QuestionnaireTemplate.new(questionnaire_template_params)\n\n respond_to do |format|\n if @questionnaire_template.save\n format.html { redirect_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /exercise_templates/1 PATCH/PUT /exercise_templates/1.json | def update
@exercise_template = ExerciseTemplate.find(params[:id])
if @exercise_template.update(exercise_template_params)
head :no_content
else
render json: @exercise_template.errors, status: :unprocessable_entity
end
end | [
"def update\n respond_to do |format|\n if @exercise_template.update(exercise_template_params)\n format.html { redirect_to @exercise_template, notice: 'Exercise template was successfully updated.' }\n format.json { render :show, status: :ok, location: @exercise_template }\n format.whoa {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /exercise_templates/1 DELETE /exercise_templates/1.json | def destroy
@exercise_template.destroy
head :no_content
end | [
"def destroy\n @exercise_template.destroy\n respond_to do |format|\n format.html { redirect_to exercise_templates_url, notice: 'Exercise template was successfully destroyed.' }\n format.json { head :no_content }\n format.whoa { render plain: 'success', status: :ok }\n end\n end",
"def des... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merge the current Hash object (self) cloned with a Hash/Array tree contents (data). 'self' is used as original data to merge to. 'data' is used as data to merged to clone of 'self'. If you want to update 'self', use rh_merge! if 'self' or 'data' contains a Hash tree, the merge will be executed recursively. The current ... | def rh_merge(data)
_rh_merge(clone, data)
end | [
"def rh_merge!(data)\n _rh_merge(self, data)\n end",
"def _rh_merge_recursive(result, key, data)\n return false unless [Array, Hash].include?(data.class)\n\n value = data[key]\n return false unless [Array, Hash].include?(value.class) &&\n value.class == result[key].class\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merge the current Hash object (self) with a Hash/Array tree contents (data). For details on this functions, see rh_merge | def rh_merge!(data)
_rh_merge(self, data)
end | [
"def rh_merge(data)\n _rh_merge(clone, data)\n end",
"def deep_merge(source, hash); end",
"def merge(data)\n if data.is_a?(Hash)\n delete unless @path.directory?\n @path.mkpath\n\n data.each do |name, contents|\n join(name.to_s).merge(contents)\n end\n else\n delete\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal function to execute the merge on one key provided by _rh_merge if refuse_discordance is true, then result[key] can't be updated if stricly not of same type. | def _do_rh_merge(result, key, data, refuse_discordance = false)
value = data[key]
return if _rh_merge_do_add_key(result, key, value)
return if _rh_merge_recursive(result, key, data)
return if refuse_discordance
return unless _rh_struct_changing_ok?(result, key, data)
return unless _rh_merge... | [
"def _rh_merge_recursive(result, key, data)\n return false unless [Array, Hash].include?(data.class)\n\n value = data[key]\n return false unless [Array, Hash].include?(value.class) &&\n value.class == result[key].class\n\n if object_id == result.object_id\n result[key].rh_mer... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Created On: 08/11/2014 Purpose: To get country statistics report ++ | def get_country_statistics_report(country_list, device_access)
@country_hash = {}
country_list.each do |country|
country_count = device_access.where(:access_country => country).count
@country_hash[country] = country_count
end
country_stat = @country_hash.sort_by {|_key, value| value}.revers... | [
"def get_visual_stats_country\n voters = Gamer.joins(:synonyms).where(\"synonym_id = ?\", self.id)\n groups = voters.count(group: :country)\n sum = groups.sum{|v| v.last}\n return groups.map {|key, value| [key,((value.to_f/sum)*100).to_i]}\n end",
"def country_report(date:, country:)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Created On: 08/11/2014 Purpose: To get city statistics report ++ | def get_city_statistics_report(city_list, device_access)
@city_hash = {}
city_list.each do |city|
city_count = device_access.where(:access_city => city).count
@city_hash[city] = city_count
end
city_stat = @city_hash.sort_by {|_key, value| value}.reverse
hash = Hash[*city_stat.flatten]
... | [
"def us_report()\n # display all US\n print \"#{process_time(@city[:iad_offset], @city[:iad_dst], \"IAD\", @city[:iad_variance])} \"\n print \"#{process_time(@city[:ord_offset], @city[:ord_dst], \"ORD\", @city[:ord_variance])} \"\n print \"#{process_time(@city[:den_offset], @city[:den_dst], \"DEN\", @ci... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Created On: 05/01/2014 Purpose: To get listen media count country vice ++ | def play_count_country_vice(country_lists,device_accesses,listen_medias,sorted_array = [])
@device_accesses = device_accesses
@listen_medias = listen_medias
country_lists.each do |country_name|
id_lists = @device_accesses.where(:access_country => country_name).map(&:id)
add_count=[]
id_lis... | [
"def count_media\n general_data['nb_media']\n end",
"def track_count\n\t\t@result['Tracks'].each do\n\t\t\t@song_count +=1\n\t\tend\n\t\t@song_count\n\tend",
"def track_info\n @conference = Conference.find_by_acronym('jct2018')\n @tracks = @conference.tracks\n s = \"\"\n total_count = 0\n @tracks.e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Created On: 05/01/2014 Purpose: To get state from city ++ | def get_city_state(city)
DeviceAccess.where(access_city: city).last.access_state rescue nil
end | [
"def revs_get_city_state(name)\n state_match=name.match(/[(]\\S+[)]/)\n if state_match.nil?\n return false\n else\n first_match=state_match[0]\n state=first_match.gsub(/[()]/,'').strip # remove parens and strip\n city=name.gsub(first_match,'').strip # remove ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /username_cookies/1 GET /username_cookies/1.json | def show
@username_cookie = UsernameCookie.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @username_cookie }
end
end | [
"def fetch_cookies\r\n get\r\n end",
"def get_cookies(user, name=nil)\n @cookies = @session.post( \n 'facebook.data.getCookies', :uid => User.cast_to_facebook_id(user), :name => name) do |response|\n response.map do |hash|\n Cookie.from_hash(hash)\n end\n end\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /username_cookies/new GET /username_cookies/new.json | def new
@username_cookie = UsernameCookie.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @username_cookie }
end
end | [
"def new\n @cookie = Cookie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cookie }\n end\n end",
"def create\n @username_cookie = UsernameCookie.new(params[:username_cookie])\n\n respond_to do |format|\n if @username_cookie.save\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /username_cookies POST /username_cookies.json | def create
@username_cookie = UsernameCookie.new(params[:username_cookie])
respond_to do |format|
if @username_cookie.save
format.html { redirect_to @username_cookie, notice: 'Username cookie was successfully created.' }
format.json { render json: @username_cookie, status: :created, locat... | [
"def write_cookie_auth(username)\n digest = OpenSSL::Digest::SHA1.new\n secret = configatron.secret_token\n hmac = OpenSSL::HMAC.hexdigest(digest, secret, username)\n cookie = \"#{username}--#{hmac}\"\n\n attributes = { path: '/', httponly: true }\n response.set_cookie(auth... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /username_cookies/1 PUT /username_cookies/1.json | def update
@username_cookie = UsernameCookie.find(params[:id])
respond_to do |format|
if @username_cookie.update_attributes(params[:username_cookie])
format.html { redirect_to @username_cookie, notice: 'Username cookie was successfully updated.' }
format.json { head :no_content }
el... | [
"def test_updates_by_cookie_id\n # Step 1\n params = {\n 'first_name' => 'Jack',\n 'last_name' => 'Johnson'\n }\n\n @user = setup_user params\n\n get_user_info(@user.oauth_token)\n assert_equal(@user.first_name, @parsed_response['first_name'])\n assert_equal(@user.last_name, @pars... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /username_cookies/1 DELETE /username_cookies/1.json | def destroy
@username_cookie = UsernameCookie.find(params[:id])
@username_cookie.destroy
respond_to do |format|
format.html { redirect_to username_cookies_url }
format.json { head :no_content }
end
end | [
"def delete_cookie name, path\r\n command 'deleteCookie', name, path\r\n end",
"def delete_cookie name\n @response.delete_cookie name\n end",
"def delete(cookie); end",
"def delete_cookie(name); end",
"def delete_cookie(cookies)\n cookies.delete('token')\n @user.update(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method compare contractor data hashes | def compare_contractor_data(contractor)
message_good = "Each attribute value is equal to the corresponding attributes of a freelancer #{contractor[:name]} on a profile page:\n#{contractor}"
message_bad = "Freelancer attribute values not equal to the corresponding attributes in the shared page. Expected:\n#{co... | [
"def test_same_hashes\r\n\t\ts = \"Addr1<Addr2(100):Addr3<Addr4(500)\"\r\n\t\ttb = Block.new(0,0,s,0.0,\"90a2\")\r\n\t\ttb.set_calculated_hash(\"90a2\")\r\n\t\t\r\n\t\tassert_equal(1, tb.compare_current_hash)\r\n\tend",
"def test_compute_hash_incorrect\n ver = Verifier.new\n\n refute_equal(ver.compute_hash(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method checks contractor data by keyword | def check_contractor_by_keyword(keyword)
match = @hash_contractor.find do |pair|
pair.last.downcase.include? keyword.downcase
end
(match == nil) ? (puts "#{@hash_contractor[:name]} dont have a #{keyword}") : (puts "The #{keyword} was include in #{match}, #{@hash_contractor[:name]}")
end | [
"def check_contractors_by_keyword(keyword)\n\n contractors = @driver.find_elements(:css, '.oSearchResultItem')\n contractors.each do |contractor|\n my_hash = {}\n\n my_hash[:name] = contractor.find_element(:css, '.notranslate').text\n my_hash[:job] = contractor.find_ele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List the sales orders under this account | def index
@sales_orders = @customer.sales_orders
end | [
"def sales\n @orders = Order.all.where(seller: current_user).order(\"created_at DESC\")\n end",
"def list_orders\n Order.list(@current_user)\n end",
"def list_orders()\n get_request('listOrders?'+get_url_parameters({})).body\n end",
"def orders\n params = { command: 'account_orders'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Contact profile Only "Email" of customer account(AX.Customer) is changeable. | def profile
if request.post?
@customer.update_attributes :email => params[:customer][:email], :phone => params[:customer][:phone]
@store_user.my_account_log(@customer,"Update Profile Email: #{@customer.email} Phone: #{@customer.phone}")
@customer.update_ax
end
end | [
"def personal_profile\n RubyRedtail::Query.run(\"contacts/#{self.contact_id}/personalprofile\", @api_hash, \"GET\")\n end",
"def personal_profile\n RubyRedtail::Query.run(\"contacts/#{@id}/personalprofile\", @api_hash, \"GET\")\n end",
"def update_profile_email\n user_profile.update_att... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Order History TODO: Find out the completed orders of current customer account. | def order_history
@orders = @customer.close_orders
end | [
"def order_history\n @orders = @customer.orders\n end",
"def order_history(order_id)\n get(\"order.info\", {order_id: order_id})\n end",
"def get_order_history(login)\n return call_api(:get, ['u', login.email, 'orders'], login)\n end",
"def buying_history\n\tsession[:user_info_id] = current_us... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete sales line of an open order via given id | def delete_sales_line
sales_line = ERP::SalesLine.find( params[:id], :include => "sales_order" )
@store_user.my_account_log(sales_line,"Delete Sales Line: #{sales_line.invent_trans_id} (#{sales_line.item_id})")
if @customer.open_orders.collect{|order| order.id}.include?( sales_line.sales_order.id ) && sa... | [
"def delete_by_id(id)\n delete_order_line_item_by_id(id)\n end",
"def delete_order_line(order_detail_id)\n @db.execute(\"DELETE FROM Order_details WHERE order_detail_id = #{order_detail_id}\")\n end",
"def delete\n self.class.delete_order_line_item_by_id(self.id)\n end",
"def delete_sa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update product quantity of sales line with given id | def update_sales_line_qty
sales_line = ERP::SalesLine.find params[:id]
result = sales_line.update_sales_qty( params[:value].to_i )
@store_user.my_account_log(sales_line,"Update Sales Line Qty: #{sales_line.invent_trans_id} (#{sales_line.item_id}), returns #{result}")
render :text => result
end | [
"def update_quantity line_item_id, num\n line_item_id = line_item_id.to_i\n num = num.to_i\n li = line_items.detect{|x| x.id == line_item_id}\n\n return nil unless li\n\n li = set_quantity_of_line li, num\n return false unless li\n\n if li.quantity == 0\n line_items.delete(li)\n li.de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Move sales line with given id to another open order | def move_sales_line
=begin
sales_line = ERP::SalesLine.find params[:id]
@original_order_id = sales_line.erp_sales_order_id
sales_line.update_attribute :erp_sales_order_id, params[:target]
mark_as_unsync [@original_order_id, params[:target]]
=end
@sales_line = ERP::SalesLine.find params[... | [
"def move_sales_line( sales_line_id, target_order_id )\r\n sales_line = self.sales_lines.find sales_line_id\r\n target_order = self.customer.sales_orders.find target_order_id\r\n\r\n moving_qty = sales_line.remain_sales_physical\r\n if moving_qty.zero?\r\n self.errors.add :sales_lines, \"This sales... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Commit changes of sales order with given id to AX server. | def commit_order
order = @customer.open_orders.find params[:id]
unless !order.commit
headers['Content-Type'] = 'text/plain'
render :text => "Failed to connect with AX server."
end
end | [
"def commit_orders\r\n orders = @customer.open_orders.find_all_by_synchronized( false )\r\n sales_id = \"\"\r\n orders.each do |o| sales_id += \"'#{o.sales_id}', \" end \r\n @store_user.my_account_log(@customer,\"Commit Sales Order Updates: #{sales_id}\")\r\n\r\n if orders.empty? || ERP::SalesOrde... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Commit all changed orders under customer's account | def commit_orders
orders = @customer.open_orders.find_all_by_synchronized( false )
sales_id = ""
orders.each do |o| sales_id += "'#{o.sales_id}', " end
@store_user.my_account_log(@customer,"Commit Sales Order Updates: #{sales_id}")
if orders.empty? || ERP::SalesOrder.commit_orders( orders... | [
"def update_orders\n @data.applied_amounts.each do |order_id, applied|\n applied = unfmt_money(applied)\n if (@data.original_pays[order_id] - applied).abs > 0.001\n update_order(order_id, applied)\n end\n end\n end",
"def commit_order\r\n order = @customer.open_orders.find params[:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return address's JSON for filling address form in "MyAccount / OpenOrders" (while editing a billing / shipping address) | def get_address_json
address = @customer.addresses.find( params[:id] )
render :text => address.attributes.to_json
end | [
"def billing_address\n address.merge('name' => \"#{first_name} #{last_name}\")\n end",
"def shipping_address\n address.merge(\n 'first_name' => first_name,\n 'last_name' => last_name,\n )\n end",
"def billing_address\n Address.new(\n email_address: email_address,\n company: bil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update delivery mode id of sales order with given id | def update_delivery_mode
sales_order = @customer.open_orders.find_by_id( params[:id] )
sales_order.delivery_mode_id = params[:delivery_mode_id]
render :text => sales_order.save
end | [
"def update_order(id, data)\r\n @client.raw('put', \"/ecommerce/orders/#{id}\", nil, data_transform(data), @contact_v1_url)\r\n end",
"def update\n @delivered_order = @order.delivered_order\n\n respond_to do |format|\n if @delivered_order.update_attributes(params[:delivered_order])\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initialize ERPCustomer and ERPContactPerson via logined user's email. | def init_user
#logger.info session.inspect
@store_user = session[:web_user]
@store_user.request_path = request.path + "?" + request.query_string
@customer = ERP::Customer.find_by_account_num @store_user.erp_account_number
if @customer.nil?
render :partial => "unaccessible", :layout... | [
"def setup_email\n self.email = self.user.email if self.user\n end",
"def initialize_email\n with_config do |config, _|\n @email_to = config[\"email\"][\"to\"] rescue nil\n end\n end",
"def after_initialize\n if self.new_record?\n self.author_email_address = 'test@test.com'\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get specified contact person using given name. | def get_contact
@contact = @customer.contact_people.find_by_name params[:id]
end | [
"def find_and_call_contact(name)\n\t @contacts.each do |c|\n\t if c[:name] == name\n\t puts \"I found #{contact[:name].capitalize} in your contacts database\\n\"\n\t puts \"I am dialing the number now. It is #{contact[:telephone]}\"\n\t end\n\t end\n\tend",
"def find_and_call_contact(contacts, n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Mark the sales order(s) with given id(s) as unsynchronized. This method MUST be called after updating anything about these orders ( ERPAddresses, SalesLines, etc. ). | def mark_as_unsync(order_ids)
order_ids = [order_ids] unless order_ids.is_a?(Array)
@customer.sales_orders.update_all "synchronized = false", ["id in (?)", order_ids]
end | [
"def move_sales_line\r\n=begin\r\n sales_line = ERP::SalesLine.find params[:id]\r\n @original_order_id = sales_line.erp_sales_order_id\r\n sales_line.update_attribute :erp_sales_order_id, params[:target]\r\n \r\n mark_as_unsync [@original_order_id, params[:target]]\r\n=end\r\n @sales_line = ERP::S... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
After signed in My Account, start a backend process to synchronize customer's account including orders. Note: Unsaved changes from last login are discarded. | def synchronize_customer_account
return false unless session[:web_user] && request.post?
unless (cust_id = session[:web_user].erp_account_number).blank?
customer = ERP::Customer.find_by_account_num(cust_id) ||
ERP::Customer.new(:account_num => cust_id)
customer.synchronize(true)
... | [
"def after_save_actions\n Logger.d(\"Inside after_save_actions in User\")\n ContactsSync.new(@context, get(:auth_token)).sync if is_user_contacts_syncable? == true # non-blocking\n end",
"def sign_the_customer_in\n transaction = ::Refinery::Transactions::Transaction.find_by_unique_guid(params['REFER... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Formats a datauri based HTML IMG tag for the file. Returns the entire IMG tag as a String. | def as_img_tag()
"<img src='#{self.encode}' />"
end | [
"def data_uri(image)\n mime_type = image.svg? ? 'image/svg+xml' : image.mime_type\n \"'data:#{mime_type};base64,#{Base64.encode64(image.blob).gsub(/\\r?\\n/, '')}'\"\n end",
"def data_uri(image)\n if image.svg?\n %['data:image/svg+xml;base64,#{Base64.encode64(image.blob).gsub(/\\r?\\n/, '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Formats a CSS background image rule for the file, and wraps it in a class definition. klass The name of the class to use for the CSS rule. Optional. If ommitted, the default will the basename of the file path. Returns the class wrapped CSS background rule as a String. | def as_css_background_with_class(klass=nil)
klass=File.basename(@file_path).tr('.','_') unless klass
".#{klass} {\n #{self.as_css_background}\n}"
end | [
"def interval_class_to_style(klass)\n build_css(INTERVAL_CSS_STYLES[klass.to_sym])\n end",
"def rule_class_name\n file_path.split('/').last.classify\n end",
"def as_css_background()\n \"background: url(#{self.encode}) no-repeat;\"\n end",
"def class_file klass_name\n name = klass_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Formats a CSS background image rule for the file. Returns the CSS background rule as a String. | def as_css_background()
"background: url(#{self.encode}) no-repeat;"
end | [
"def custom_background\n css = \"\"\n css += \"background-color: #{self.background_color};\" unless self.background_color.blank?\n if self.background_image_file_name.blank?\n css += \"background-image: none; \"\n else\n css += \"background-image: url('#{self.background_image.url(\"original\", ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Encodes file into a CSS string representation. Returns the Base64 encoded String with filetype information embedded. | def encode()
"data:#{self.filetype};base64," + self.raw_encode
end | [
"def raw_encode()\n return Base64.encode64(File.read @file_path).delete(\"\\n\") if RUBY_VERSION < \"1.9.0\"\n Base64.strict_encode64(File.read @file_path)\n end",
"def encode_file(filename, format, options = T.unsafe(nil)); end",
"def highlight_file filename, options = { :css => :class }, format =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: file into its raw Base64 string representation. Returns the Base64 encoded String. | def raw_encode()
return Base64.encode64(File.read @file_path).delete("\n") if RUBY_VERSION < "1.9.0"
Base64.strict_encode64(File.read @file_path)
end | [
"def base64\n binary = open { |io| io.read }\n result = Base64.encode64(binary).chomp\n binary.clear # deallocate string\n result\n end",
"def file_base64\n f = @file\n\n # ActionDispatch::Http::UploadedFile (get tempfile)\n if defined?(::ActionDispa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Protected: is the file of an image format we support? Returns a Boolean representing image format validity. | def valid_image_format?
VALID_FILE_MIMETYPES.include? self.filetype
end | [
"def goodImageFormat?( path )\n supported = [\"bmp\", \"jpeg\", \"jpg\",\n \"png\", \"tiff\", \"tif\" ]\n supported.include?(path.split(\".\").last.downcase) ? true : false\n end",
"def valid_file?\n if @image.size.zero?\n errors.add_to_base(\"Please enter an image filename\")\n return fa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Like self.find(), but returns nil when a DigitalObject isn't found instead of raising an error | def find_by_pid(pid)
find(pid)
rescue Hyacinth::Exceptions::DigitalObjectNotFoundError
return nil
end | [
"def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def object!\n LOGGER.debug \"Resolving object.\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Overrides the parent method to ensure the current ping node is destroyed | def inherit(node)
ping.remove
super
end | [
"def on_node_destroy( node )\n\t\t\tself.log.debug \"unhandled on_node_destroy for %p\" % [ node ]\n\t\tend",
"def delete_ping\n delete 'ping'\n end",
"def check_out\n @central[\"/node/#{@host}\"].delete\n end",
"def terminate()\n connection.nodes.terminate(uuid).tap{ self.forget }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ping node accessor If a ping node exists it will be returned. Otherwise a new node will be created and returned | def ping
p = find_first 'ns:ping', :ns => self.class.registered_ns
unless p
(self << (p = XMPPNode.new('ping', self.document)))
p.namespace = self.class.registered_ns
end
p
end | [
"def ping\n @rpc.ping_node\n @pingres = @rpc.instance_variable_get(:@pingres)\n end",
"def pingnode(address, interface=nil)\n out = interface ? `ping -I #{interface} -c 5 #{address}` : `ping -c 5 #{address}`\n if $? != 0\n # Ping command failed, return empty hash.\n puts \"Failed to ping #{ad... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /boat_types POST /boat_types.json | def create
@boat_type = BoatType.new(boat_type_params)
respond_to do |format|
if @boat_type.save
format.html { redirect_to edit_boat_type_path(@boat_type)}
format.json { render json: @boat_type.hash_view('control'), status: :created, location: @boat_type }
else
format.html { ... | [
"def create\n @boat_type = BoatType.new(boat_type_params)\n\n respond_to do |format|\n if @boat_type.save\n format.html { redirect_to \"/boat_types\", notice: 'Boat type was successfully created.' }\n format.json { render json: @boat_type, status: :created, location: @boat_type }\n els... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /boat_types/1 PATCH/PUT /boat_types/1.json | def update
prms = @boat_type.is_modification? ? modification_params : boat_type_params
respond_to do |format|
if @boat_type.update(prms)
format.html { redirect_to edit_boat_type_path(@boat_type), notice: 'Тип лодки успешно обновлён' }
format.json { render json: @boat_type.hash_view('contro... | [
"def update\n @boat_type = BoatType.find(params[:id])\n\n respond_to do |format|\n if @boat_type.update_attributes(boat_type_params)\n format.html { redirect_to \"/boat_types\", notice: 'Boat type was successfully updated.' }\n format.json { head :no_content }\n else\n format.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determine available moves receive p1 moves and p2 moves return array of available moves | def open_squares(p1_moves, p2_moves)
avail_moves = Array.new
SQUARES.each { |n| avail_moves << n unless p1_moves.include?(n) || p2_moves.include?(n) }
return avail_moves
end | [
"def open_squares(p1_moves, p2_moves)\n avail_moves = Array.new\n SQUARES.each { |n| avail_moves << n unless p1_moves.include?(n) || p2_moves.include?(n) }\n return avail_moves\nend",
"def avail(x, y)\n\t# holds list of available coordinate pairs\n\tlist_xy = Array.new\n\t\n\t# up to 8 avail moves, so check al... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set columns names . NOTE that we are not clearing chash here. In case, someone changes table and columns. | def columns=(array)
#$log.debug "tabular got columns #{array.count} #{array.inspect} " if $log
@columns = array
@columns.each_with_index { |e,i|
#@chash[i] = ColumnInfo.new(c, c.to_s.length)
c = get_column(i)
c.name = e
c.width = e.to_s.length
#@chash[i] = c
... | [
"def setup_table_columns\n\t\twhile !(columns = @tableContentView.tableColumns).empty?\n\t\t\t@tableContentView.removeTableColumn(columns.first)\n\t\tend\n\t\t\n\t\t@columns.each_with_index do |name, i|\n\t\t\tcolumn = NSTableColumn.alloc.initWithIdentifier(i)\n\t\t\tcolumn.headerCell.setStringValue(name)\n\t\t\tco... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set alignment of given column offset | def column_align colindex, lrc=:NONE
if lrc == :NONE
return get_column(colindex).align
#return @calign[colindex]
end
raise ArgumentError, "wrong alignment value sent" if ![:right, :left, :center].include? lrc
get_column(colindex).align = lrc
self
end | [
"def column_align colindex, align\n get_column(colindex).align = align\n end",
"def align_column colindex, lrc\n raise ArgumentError, \"wrong alignment value sent\" if ![:right, :left, :center].include? lrc\n @calign[colindex] ||= lrc\n if @chash[colindex].nil?\n @chash[colindex] = C... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return an array of visible columns names | def visible_column_names
visible = []
@chash.each_with_index do |c, ix|
if !c.hidden
if block_given?
yield c.name, ix
else
visible << c.name
end
end
end
return visible unless block_given?
end | [
"def get_columns_visible\n if columns_visible\n return JSON.parse columns_visible\n else\n return []\n end\n end",
"def get_columns_visible\n if columns\n return JSON.parse columns\n else\n return []\n end\n end",
"def get_columns_visible\n columns_visible ? JSON.parse... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the count of visible columns based on column names. NOTE: what if no column names gives ??? | def column_count
visible_column_names().count
end | [
"def ncols\r\n @df.keys.length\r\n end",
"def count_columns\n fields.size\n end",
"def count_columns\n return 0 if @raw.empty?\n\n column_counts = Hash.new(0)\n @raw.each { |cols| column_counts[cols.size] += 1 }\n if column_counts.values.max < @raw.size/2\n raise \"Discrepancy... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
yields nonhidden columns (ColumnInfo) and the offset/index This is the order in which columns are to be printed | def each_column
@chash.each_with_index { |c, i|
next if c.hidden
yield c,i if block_given?
}
end | [
"def each_column\n @chash.each_with_index { |c, i|\n next if c.hidden\n yield c,i if block_given?\n }\n end",
"def visible_column_names\n visible = []\n @chash.each_with_index do |c, ix|\n if !c.hidden\n if block_given?\n yield c.name, ix \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
for the given row, return visible columns as an array | def visible_columns(row)
visible = []
row.each_with_index do |e, ix|
hid = @chash[ix].hidden
if !hid
if block_given?
yield e, ix
else
visible << e
end
end
end
return visible if !block_given?
end | [
"def get_columns_visible\n if columns_visible\n return JSON.parse columns_visible\n else\n return []\n end\n end",
"def get_columns_visible\n columns_visible ? JSON.parse(columns_visible) : []\n end",
"def visible\n lines.map { |line| columns(line) }\n end",
"def get_column... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This calculates and stores the offset at which each column starts. Used when going to next column or doing a find for a string in the table. | def _calculate_column_offsets
total = 0
coffsets = []
ctr = 0
## ix will have gaps in between for hidden fields
each_column { | c, ix|
v = c.width
coffsets[ctr] = total
ctr += 1
total += v + 2 ## blank space plus separator
}
... | [
"def _calculate_column_offsets\n @coffsets = []\n total = 0\n\n #@chash.each_pair { |i, c| \n #@chash.each_with_index { |c, i| \n #next if c.hidden\n each_column {|c,i|\n w = c.width\n @coffsets[i] = total\n c.offset = total\n # if you use prepare_format t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Requires session[request.path] to be set to 'shared' or a user to be signed in as same one for which the action is performed. | def correct_user_or_shared_page
if session[request.path] != "shared"
# Run normal callbacks
signed_in_user && correct_user
end
end | [
"def require_session_ownership\r\n if session_user.screen_name == params[:screen_name]\r\n @user = session_user\r\n return true\r\n end\r\n\r\n # wrong screen_name in url doesn't match session_user! redir to the current session\r\n # user's stats page\r\n params[:screen_name] = session_use... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Users don't have a ribbon on their card | def ribbon
end | [
"def test_inactiveBorder\n [@window, @sprite, @bitmap].each{|container|\n uc = UCBar.new(container, Rect.new(200, 24, 100, 24), Color.hp_gauge_color1, \n Color.hp_gauge_color2, Color.gauge_back_color, 10, 100, 1, Color.gauge_border_color)\n uc.active = false\n uc.draw()\n }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Initializes a session on the API server and stores the expiry time and the session_id in instance variables Returns the session_id GUID | def initialize_session
response = @soap_client.call :initialize_session
# Without ActiveSupport
# 1.hour.from_now is 3600 seconds from Time.now
@session_expiry_time = Time.now + 3600
@session_id = response.body[:initialize_session_response][:initialize_session_result]
end | [
"def initialize_session\n response = @savon.call :initialize_session\n # Without ActiveSupport\n # 1.hour.from_now is 3600 seconds from Time.now\n @session_expiry_time = Time.now + 3600\n @session_id = response.body[:initialize_session_response][:initialize_session_result]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Calls the 'SignIn' SOAP action username a String which corresponds to a TranscribeMe Portal account username which can be any valid email address password a String which is the portal account password Returns a GUID of the Customer ID | def sign_in(username, password)
# If #login_with is called before we have a session_id instance variable
# then call initialize_session
initialize_session unless session_valid?
# Use Suds to call the 'SignIn' SOAP action
response = @soap_client.call :sign_in,
... | [
"def sign_in(username, password)\n \n # If #login_with is called before we have a session_id instance variable\n # then call initialize_session\n initialize_session unless session_valid?\n\n # Use Savon to call the 'SignIn' SOAP action\n response = @savon.call :sign_in, \n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Calls the 'GetCustomerRecordings' SOAP Action requires the user to be logged in Returns an Array of Hashes of with the properties of recording objects | def get_recordings
# raise 'Login first!' unless @customer_login_id
response = @soap_client.call :get_customer_recordings,
message: { 'wsdl:sessionID' => session_id }
@recordings = response.body[:get_customer_recordings_response][:get_customer_recordings_result][:rec... | [
"def get_recordings\n # raise 'Login first!' unless @customer_login_id\n\n response = @savon.call :get_customer_recordings, \n message: { 'wsdl:sessionID' => session_id }\n\n # Returns an array of instances of the Recording class\n @recordings = Transcrib... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Calls the 'GetUploadUrl' SOAP Action Returns the upload url as a String | def get_upload_url
# raise 'Login first!' unless @customer_login_id
response = @soap_client.call :get_upload_url,
message: { 'wsdl:sessionID' => @session_id }
@upload_url = response.body[:get_upload_url_response][:get_upload_url_result] ... | [
"def get_upload_url\n # raise 'Login first!' unless @customer_login_id\n\n response = @savon.call :get_upload_url, \n message: { 'wsdl:sessionID' => @session_id }\n \n @upload_url = response.body[:get_upload_url_response][:get_uplo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Calls the 'TranscribeRecording' SOAP Action recording_id a String in GUID format Returns the SOAP response Hash | def transcribe_recording(recording_id)
# initialize_session unless @session.try :valid?
response = @soap_client.call :transcribe_recording,
message: { 'wsdl:sessionID' => @session_id,
'wsdl:recordingId' => recording_id }
respon... | [
"def transcribe_recording(recording_id)\n # initialize_session unless @session.try :valid?\n\n response = @savon.call :transcribe_recording, \n message: { 'wsdl:sessionID' => @session_id, \n 'wsdl:recordingId' => recording_id }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Calls the 'TranscribeRecordingWithPromoCode' SOAP Action recording_id a String in GUID format promocode a String Returns the SOAP response Hash | def transcribe_recording_using_promocode(recording_id, promocode)
# initialize_session unless @session.try :valid?
response = @soap_client.call :transcribe_recording_using_promocode,
message: { 'wsdl:sessionID' => @session_id,
'... | [
"def transcribe_recording_using_promocode(recording_id, promocode)\n # initialize_session unless @session.try :valid?\n \n response = @savon.call :transcribe_using_promo_code, \n message: { 'wsdl:sessionID' => @session_id, \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Calls the 'GetRecordingInfo' SOAP Action recording_id a String in GUID format Returns the SOAP response Hash | def get_recording_info(recording_id)
@soap_client.call :get_recording_info,
message: { 'wsdl:sessionID' => @session_id,
'wsdl:recordingID' => recording_id }
end | [
"def get_recording_info(recording_id)\n response = @savon.call :get_recording_info,\n message: { 'wsdl:sessionID' => @session_id,\n 'wsdl:recordingID' => recording_id }\n response.body[:get_recording_info_response][:get_recording_info_result]\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Calls the 'FinalizeSession' SOAP Action to close the session on the server Returns the SOAP response Hash | def finalize_session
@soap_client.call :finalize_session,
message: { 'wsdl:sessionID' => @session_id }
end | [
"def finalize_session\n @savon.call :finalize_session, \n message: { 'wsdl:sessionID' => @session_id }\n end",
"def session_close\n begin\n auth.globals[:headers]['Cookie'] = \"SID=\\\"#{session_id}\\\"\"\n auth.call(:close_session)\n rescue Savon::SOAPFaul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.