query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Matches based on type and the attribute "name" | def has_entity? entity
return true if (self.entities.select {|e| e.match? entity}).length > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match\n @matches = attributes_enumerator.map do |(type, value), index|\n attribute_name = self.class.names[index]\n attributes.store(\n attribute_name, type.match(value, context: @context.dup)\n )\n end\n return if (failures = @matches.select(&:invalid?)).empty?\n ... | [
"0.6814561",
"0.64792734",
"0.63851696",
"0.6329348",
"0.6288657",
"0.6288657",
"0.60846406",
"0.6063161",
"0.59595025",
"0.59595025",
"0.59453565",
"0.5945343",
"0.5878931",
"0.5815252",
"0.57918143",
"0.5788455",
"0.57733727",
"0.57680345",
"0.5726944",
"0.5698773",
"0.5688... | 0.0 | -1 |
Displays the scribd object for the attachment on the given +object+. If +alt_text_or_attribute+ is given, then it will be used as the alternate text for an Attachment_fu model, or as the attribute name for a Paperclip model. If you want to specify alternate text for a Paperclip model, use the last parameter, +alt_text_if_paperclip+. If you are using Paperclip, you _must_ specify +alt_text_or_attribute+ as the attribute on which the scribd object exists. For example, using Attachment_fu: Using Paperclip: | def display_scribd(object, alt_text_or_attribute = '', alt_text_if_paperclip = nil)
# Resolve the right scribd ID, access key, and alt text.
if object.respond_to?("scribd_id")
scribd_id = object.scribd_id
scribd_ak = object.scribd_access_key
alt_text = alt_text_or_attribute
else
scribd_id = object.send "#{alt_text_or_attribute}_scribd_id"
scribd_ak = object.send "#{alt_text_or_attribute}_scribd_access_key"
alt_text = alt_text_if_paperclip
end
begin
# Collect a set of addParam statements to set up JS parameters for the scribd document
# (only if they are valid).
param_includes = options[:params].collect do |param, value|
"scribd_doc.addParam('#{param}', '#{value}');" if AVAILABLE_JS_PARAMS.include?(param)
end.compact.join("\n")
rescue
# Where is 'options' coming from???
end
<<-END
<script type="text/javascript" src="http://www.scribd.com/javascripts/view.js"></script>
<div id="embedded_flash">#{alt_text}</div>
<script type="text/javascript">
var scribd_doc = scribd.Document.getDoc(#{scribd_id}, '#{scribd_ak}');
#{param_includes}
scribd_doc.write("embedded_flash");
</script>
END
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_text(object)\n if object.file_content_type =~ /image/i\n image_tag( object.file.url(:icon) ) +\n \"<br /><br />\".html_safe +\n object.file_file_name.truncate(80)\n else\n object.file_file_name.truncate(80)\n end\n end",
"def display_scribd(object, options = {})\n # ... | [
"0.6317333",
"0.63163006",
"0.5272131",
"0.5244327",
"0.5149271",
"0.5125431",
"0.51200473",
"0.5104697",
"0.5065838",
"0.50314456",
"0.50314456",
"0.5027112",
"0.49728572",
"0.49695325",
"0.49054572",
"0.4870794",
"0.485829",
"0.4846694",
"0.48453587",
"0.48191634",
"0.48138... | 0.68144256 | 0 |
Checks equality by comparing each attribute. | def ==(o)
return true if self.equal?(o)
self.class == o.class &&
compute == o.compute &&
group_by == o.group_by &&
index == o.index &&
multi_compute == o.multi_compute &&
search == o.search
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n attributes == other.attributes\n end",
"def ==(other) # :nodoc:\n @attrs == other.attrs\n end",
"def eql?(other)\n return true if self == other\n @@ATTRIBUTES.each do |att|\n return false unless self.send(att).eql?(other.send(att))\n end\n true\n en... | [
"0.7291717",
"0.7188103",
"0.70395297",
"0.7007927",
"0.68874705",
"0.6861532",
"0.6707156",
"0.6660597",
"0.66147524",
"0.658478",
"0.6584619",
"0.6580019",
"0.65543133",
"0.6543933",
"0.65068495",
"0.6479513",
"0.6456241",
"0.6415999",
"0.6412208",
"0.6412208",
"0.6412208",... | 0.0 | -1 |
Calculates hash code according to all attributes. | def hash
[compute, group_by, index, multi_compute, search].hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_hash\n Digest::MD5.hexdigest(\"#{@name}:#{@ruby_type}\")\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n ... | [
"0.7118691",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.70400536",
"0.68960655",
"0.67847186",
"0.6707762",
"0.670052",
"0.6688737",
"0.66705376",
"0.6489735",
"0.6462376",
"0.6462376",
"0.64444333",
"0.6413127",
"0.6395483",
"0.638... | 0.0 | -1 |
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge [by myself, with: ]. 1. Pseudocode What is the input? INPUT = array of test scores, with each number being between 0100 What is the output? (i.e. What should the code return?) The code should return a letter grade What are the steps needed to solve the problem? add all numbers in array divide result by number of elements in array if the number is greater than 90 return A elseif the number greater than 80 but less than 90 return B elseif the number is greater than 70 but less than 80 return C elseif the number is greater than 60 but less than 70 return D elseif the number is greater than 50 but less than 60 return F ENDIF BE A RUBYIST AND USE CASE 2. Initial Solution | def get_grade(array)
avg = ((array.inject(:+)) / array.length)
case avg
when 90..100
'A'
when 80..89
'B'
when 70..79
'C'
when 60..69
'D'
else
'F'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_grade scores\n average = 0\n scores.each do |num|\n if num < 0 || num > 100\n p \"Please input a list of valid scores (0-100).\"\n else\n average += num\n end\n end\n average /= scores.length\n if average >= 90\n \"A\"\n elsif average >= 80\n \"B\"\n elsif average >= 70\n ... | [
"0.76199627",
"0.75283074",
"0.73928136",
"0.7391813",
"0.73766506",
"0.7324099",
"0.7286977",
"0.72730374",
"0.72667235",
"0.71902114",
"0.7159162",
"0.7153093",
"0.71524936",
"0.7061703",
"0.70279425",
"0.7021161",
"0.69911283",
"0.6933251",
"0.69283557",
"0.6888661",
"0.68... | 0.6754546 | 30 |
Check if the checksum is valid for the parameters received from PayTm. This is requrired to make sure that the request is received from PayTm. | def is_checksum_valid?(received_params)
paytmparams = Hash.new
keys = received_params.keys
keys.each do |k|
paytmparams[k] = received_params[k]
end
checksum_hash = paytmparams["CHECKSUMHASH"]
paytmparams.delete("CHECKSUMHASH")
Rails.logger.debug "HERE"
Rails.logger.debug "paytmparams #{paytmparams}"
Rails.logger.debug "checksum_hash #{checksum_hash}"
Rails.logger.debug "PAYTM_MERCHANT_KEY #{ENV["PAYTM_MERCHANT_KEY"]}"
return new_pg_verify_checksum(paytmparams, checksum_hash, ENV["PAYTM_MERCHANT_KEY"])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_checksum?\n self[:checksum] !~ /time/\n end",
"def checksum_invalid?\n !checksum_valid?\n end",
"def valid_checksum?(checksum_value)\n checksum_value == checksum\n end",
"def can_validate_checksums?\n true\n end",
"def checksum_specified?\n ! specified_checksum.nil?\n e... | [
"0.71006435",
"0.70919",
"0.7065961",
"0.7008394",
"0.6920952",
"0.6899585",
"0.6891384",
"0.6876482",
"0.66040856",
"0.654032",
"0.6517509",
"0.6491426",
"0.64816785",
"0.64471596",
"0.64413416",
"0.6267287",
"0.626018",
"0.62368596",
"0.6198484",
"0.61699873",
"0.6169147",
... | 0.75292414 | 0 |
out the current state. | def display_board(xox)
line = "-----------"
puts " #{xox[0]} | #{xox[1]} | #{xox[2]} "
puts line
puts " #{xox[3]} | #{xox[4]} | #{xox[5]} "
puts line
puts " #{xox[6]} | #{xox[7]} | #{xox[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_state; end",
"def write_state; end",
"def state_out(path:)\n add option: \"-state-out=#{path}\"\n end",
"def pop_state\t\n\t\t\t@state_buffer = Proc.new do\n\t\t\t\t@objs2 = []\n\t\t\t\t@current_state = @states.pop\n\t\t\tend\n\t\tend",
"def final_state(state)\n final_states(state)\n ... | [
"0.72624224",
"0.72624224",
"0.67279774",
"0.6647568",
"0.6577878",
"0.6515",
"0.6501546",
"0.6501546",
"0.64870685",
"0.64463556",
"0.64091253",
"0.63802713",
"0.6377393",
"0.6373034",
"0.6373034",
"0.6373034",
"0.6373034",
"0.6373034",
"0.6373034",
"0.6373034",
"0.6373034",... | 0.0 | -1 |
Creates a new S2A_LOGSTRING object based on the given data | def initialize(data)
super S2A_LOGSTRING_HEADER, data
@content_data.getbyte
@message = @content_data.string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initLog(data)\n n = data[:names].join(\"; \")\n l = data[:data].length\n p = (l === 1) ? \"y\" : \"ies\"\n return %Q_- NAME: #{n}\\n #{l} matching entr#{p}\\n_\nend",
"def log_str_maker\n @@log_str_maker ||= AlertLogStrMaker.new(self, :success_str, :failure_str)\n end",
"def make_log_entry\n ... | [
"0.5981822",
"0.59422815",
"0.59411216",
"0.58958536",
"0.5474789",
"0.5334136",
"0.53320813",
"0.51495135",
"0.5142855",
"0.5090526",
"0.507921",
"0.5049602",
"0.5017595",
"0.50128037",
"0.49949268",
"0.49845773",
"0.4971564",
"0.489397",
"0.48847336",
"0.48843402",
"0.48620... | 0.7354118 | 0 |
def get_ed_by_user(username, filename) return get_path_for_library_resource(username, 'eds', filename); end def get_sysimage_by_user(username, filename) return get_path_for_library_resource(username, 'sysimages', filename); end | def order_by(column, order)
return resource().order(column.to_s + " " + order)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fedora_name\n 'image_file'\n end",
"def filename\n\t\tif @user.class == User \n\t\t\t\"#{@user.screen_name}.png\"\n\t\telsif @user.class == Libitem\n\t\t\t\"#{@user.title}_#{@user.id}.png\"\n\t\tend\n\tend",
"def get_path\n if self.presentation.user.role==\"guest\"\n \"#{Rails.root}/public/... | [
"0.5886672",
"0.5852624",
"0.5821087",
"0.5776561",
"0.57591534",
"0.5708265",
"0.56854784",
"0.56761855",
"0.55911434",
"0.55773944",
"0.55017877",
"0.5488013",
"0.54403967",
"0.5439745",
"0.5404713",
"0.53787476",
"0.53765905",
"0.5350666",
"0.5345617",
"0.5343209",
"0.5318... | 0.0 | -1 |
Only the owner or the admins can write/edit resource | def has_resource_permission()
resource = resource().find(params[:id])
unless (current_user.admin? or current_user == resource.user)
render 'shared/403', :status => 403
return false
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_permitted?\n return (acting_user.administrator? || users.member?(acting_user))\n end",
"def write_permitted?\n return acting_user.administrator?\n end",
"def can_edit?\n can_write? && (account_is_owner? || account_is_collaborator?)\n end",
"def permits_write_access_for(user)\n... | [
"0.7610858",
"0.75862336",
"0.74433035",
"0.73032486",
"0.72686577",
"0.72354984",
"0.72194344",
"0.72117645",
"0.71982783",
"0.7133172",
"0.7125148",
"0.70796776",
"0.70743805",
"0.70692796",
"0.706876",
"0.70595676",
"0.7051957",
"0.70394737",
"0.7023243",
"0.7019938",
"0.7... | 0.67154676 | 82 |
For now everyone has read permissions | def read_resource(resource, content, extension="")
path = get_path(resource, extension)
return File.open(path, 'r')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def everyone(read, write)\n apply(PUBLIC, read, write)\n permissions[PUBLIC]\n end",
"def permits_read_acccess_for(user)\n end",
"def accountant_allow_read(permission)\n return accountant_right(permission) > 0\n end",
"def read_permissions\n can :read, String do |pid|\n Rails.... | [
"0.7983518",
"0.7854978",
"0.7605439",
"0.75593567",
"0.7539112",
"0.7460687",
"0.74394804",
"0.7396087",
"0.72901314",
"0.7273031",
"0.7175359",
"0.7175359",
"0.7175359",
"0.71175104",
"0.70989335",
"0.70816123",
"0.70763105",
"0.70763105",
"0.7072368",
"0.7058766",
"0.70567... | 0.0 | -1 |
this saves the resulting image and map under an unique identifier which can be used subsequently to fetch them parameters: uuid: string; an unique identifier, e.g. generated by UUID.random_create.to_s filename: string seq_id: string range: a ruby Range object config_obj: a GT::Style object width: integer (width in pixel) add_introns: boolean (activate add introns mode?) config_override: an array of options that will override the options in the config object each option in config_override is an array: [gt_ruby_type, section, attribute, value] if value.nil? the attribute will be unset, otherwise set to the given value returns true if the image and map could be successfully generated, false if any exception was raised during the generation | def img_and_map_generate(uuid,
filename,
seqid,
range,
config_obj,
width,
add_introns,
config_override = [])
log "generating img/map #{uuid}"
log filename, 2
log "#{seqid}, #{range.inspect}", 2
time = Benchmark.measure do
config_copy = config_obj.clone
config_override.each do |option|
gt_ruby_type, section,
attribute, value = option
if value.nil?
config_copy.unset(section, attribute)
else
config_copy.send("set_#{gt_ruby_type}", section, attribute, value)
end
end
mode = add_introns ? :on : :off
fix = feature_index(filename, mode)
gtrange = fix.get_range_for_seqid(seqid)
gtrange.start = range.first
gtrange.end = range.last
diagram = GT::Diagram.new(fix, seqid, gtrange, config_copy)
info = GT::ImageInfo.new
canvas = GT::CanvasCairoFile.new(config_copy, width, info)
diagram.sketch(canvas)
lock(:map) do
@cache[:map][uuid] = info
end
lock(:img) do
@cache[:img][uuid] = canvas.to_stream
end
end
log "done (%.4fs)" % time.real, 3
return true
rescue => err
log "ERROR: #{err}", 3
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n\n properties = {}\n # exif = {}\n # KCGImagePropertyExifDictionary\n # exif[KCGImagePropertyExifUserComment] = 'Image downloaded from www.sheetmusicplus.com'\n # exif[KCGImagePropertyExifAuxOwnerName] = 'www.sheetmusicplus.com'\n if @filetype == :pdf\n CGPDFContextEndPa... | [
"0.6412728",
"0.6265939",
"0.5874996",
"0.5832062",
"0.5786266",
"0.56935513",
"0.5686197",
"0.56834835",
"0.56694216",
"0.56247234",
"0.56147957",
"0.5576001",
"0.5547012",
"0.55414295",
"0.55283135",
"0.5489715",
"0.5457729",
"0.5440662",
"0.5424576",
"0.5424166",
"0.541790... | 0.7198929 | 0 |
returns the image saved under the specified uuid or nil | def img(uuid, delete = true)
log("image #{uuid}")
lock(:img) do
delete ? @cache[:img].delete(uuid) : @cache[:img].fetch(uuid, nil)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_image_by_uuid\n @command = :get_image_by_uuid\n # the UUID was the last \"previous argument\"\n image_uuid = @prev_args.peek(0)\n # setup the proper URI depending on the options passed in\n uri = URI.parse(@uri_string + '/' + image_uuid)\n # and get the results of ... | [
"0.6988191",
"0.6555032",
"0.6350709",
"0.6243749",
"0.6214191",
"0.6208049",
"0.6194305",
"0.614937",
"0.6033725",
"0.601058",
"0.6001908",
"0.59772223",
"0.5961583",
"0.5940609",
"0.5919519",
"0.5916181",
"0.58808535",
"0.58259624",
"0.5822619",
"0.5811064",
"0.578597",
"... | 0.63052535 | 3 |
returns the image map saved under the specified uuid or nil | def map(uuid, delete = true)
log("image map #{uuid}")
lock(:map) do
delete ? @cache[:map].delete(uuid) : @cache[:map].fetch(uuid, nil)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_mapimage\n @mapimage = Mapimage.find(params[:id])\n end",
"def image\n [:MANAGED_MAP, :UNMANAGED_MAP].each do |map|\n unless self.class.const_defined?(map)\n raise MapUndefined, \"Const #{map} is undefined; maps appear unbuilt\"\n end\n end\n\n map = @managed ? self.clas... | [
"0.6164865",
"0.6089394",
"0.59918785",
"0.59374624",
"0.59203553",
"0.58081836",
"0.5790462",
"0.56078404",
"0.5569806",
"0.55532616",
"0.5513124",
"0.547374",
"0.54605734",
"0.5450366",
"0.5420104",
"0.53998977",
"0.53943",
"0.5390379",
"0.53817886",
"0.5367847",
"0.536705"... | 0.69627327 | 0 |
Yield each nonblank row; they are all different lengths | def each
CSV.foreach(@file, :encoding => 'iso-8859-1:utf-8') do |row|
# File has a footer - truncate at the last valid line
break if row.empty?
yield row
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_blank_rows\n end",
"def compact_rows!\n @data.delete_if { |ar| ar.all? { |el| el.to_s.empty? } || ar.empty? }\n calc_dimensions\n end",
"def empty_cells\n cells.values.select {|cell| cell.empty? }\n end",
"def get_empty_cells(cells)\r\n arr = []\r\n cells.each_with_in... | [
"0.6627949",
"0.63568354",
"0.6320663",
"0.62763554",
"0.62660825",
"0.61946607",
"0.61208427",
"0.60748535",
"0.6023632",
"0.5935646",
"0.59237176",
"0.5899757",
"0.5879568",
"0.5830335",
"0.57989776",
"0.5741107",
"0.5701283",
"0.56865484",
"0.5677947",
"0.56634873",
"0.565... | 0.0 | -1 |
GET /tracks GET /tracks.json | def index
@tracks = Track.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tracks }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tracks = Track.all\n render json: {tracks: @tracks}\n end",
"def index\n @tracks = Track.all\n render json: serialize(@tracks)\n end",
"def index\n @tracks = @disc.tracks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: ... | [
"0.78725123",
"0.7769212",
"0.7667833",
"0.7409376",
"0.7394941",
"0.7289515",
"0.72646934",
"0.7206294",
"0.7166112",
"0.71176875",
"0.71015567",
"0.71015567",
"0.71015567",
"0.7085675",
"0.7073675",
"0.7060078",
"0.7060078",
"0.7060078",
"0.70300114",
"0.702769",
"0.6978795... | 0.76302665 | 3 |
GET /tracks/1 GET /tracks/1.json | def show
@track = Track.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @track }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tracks = Track.all\n render json: {tracks: @tracks}\n end",
"def index\n @tracks = @disc.tracks.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tracks }\n end\n end",
"def index\n @tracks = Track.all\n\n respond_to do |fo... | [
"0.75889766",
"0.7498456",
"0.7458582",
"0.7445238",
"0.7380093",
"0.7349825",
"0.7288537",
"0.7225473",
"0.7132551",
"0.70929277",
"0.7000335",
"0.6996552",
"0.6996552",
"0.6996552",
"0.6980478",
"0.6965107",
"0.6867316",
"0.6856186",
"0.68027264",
"0.6795485",
"0.6767859",
... | 0.73781186 | 6 |
GET /tracks/new GET /tracks/new.json | def new
@track = Track.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @track }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @track = current_user.tracks.new\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render json: @track }\n end\n end",
"def new\n @track = @disc.tracks.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @... | [
"0.8121653",
"0.7695223",
"0.7359535",
"0.72580326",
"0.7241356",
"0.72306585",
"0.72306585",
"0.7191415",
"0.7111606",
"0.7050196",
"0.7050196",
"0.7050196",
"0.7050196",
"0.7049092",
"0.7042483",
"0.7032633",
"0.70020515",
"0.70020515",
"0.6917835",
"0.69078636",
"0.6907863... | 0.80285686 | 3 |
POST /tracks POST /tracks.json | def create
@track = Track.new(params[:track])
respond_to do |format|
if @track.save
format.html { redirect_to @track, notice: 'Track was successfully created.' }
format.json { render json: @track, status: :created, location: @track }
else
format.html { render action: "new" }
format.json { render json: @track.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @track = Track.new(track_params)\n if @track.save\n render json: @track, status: :created, location: @track\n else\n render json: @track.errors, status: :unprocessable_entity\n end\n end",
"def create\n @track = @playlist.tracks.new(track_params)\n if @track.save\n ... | [
"0.7535381",
"0.7336944",
"0.7166981",
"0.7149771",
"0.7149771",
"0.7048305",
"0.7039093",
"0.69347566",
"0.684075",
"0.6781175",
"0.67042935",
"0.66893363",
"0.663725",
"0.6627018",
"0.6607706",
"0.6585348",
"0.6574254",
"0.65344644",
"0.6529343",
"0.6516317",
"0.6509962",
... | 0.7229849 | 2 |
PUT /tracks/1 PUT /tracks/1.json | def update
@track = Track.find(params[:id])
if params[:rules]
rules = params[:rules][:names].collect.with_index { |name, i| {:name => name, :track_id => params[:rules][:track_ids][i], :body => params[:rules][:bodies][i] } }
rules.each do |r|
if not @track.rules.find_by_name(r[:name])
@track.rules.build(r)
end
end
end
if params[:factors]
factors = params[:factors][:names].collect.with_index { |name, i| {:name => name, :track_id => params[:factors][:track_ids][i], :factoree_type => params[:factors][:factoree_type][i], :factoree_id => params[:factors][:factoree_ids][i]} }
factors.each do |f|
if not @track.factors.find_by_name(f[:name])
@track.factors.build(f)
end
end
end
respond_to do |format|
if @track.update_attributes(params[:track])
format.html { redirect_to @track, notice: 'Track was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @track.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @track.update(track_params)\n render json: @track\n else\n render json: { error: @track.errors }, status: :unprocessable_entity\n end\n end",
"def update\n if @track.update(edit_track_params)\n render json: @track\n else\n render json: @track.errors... | [
"0.71953523",
"0.6987985",
"0.6968533",
"0.6790461",
"0.6766328",
"0.67422295",
"0.67422295",
"0.67422295",
"0.65930414",
"0.65774435",
"0.6519559",
"0.6480467",
"0.6475292",
"0.64746577",
"0.6467702",
"0.6394803",
"0.6326845",
"0.6297955",
"0.6297955",
"0.6252831",
"0.619782... | 0.5849801 | 54 |
DELETE /tracks/1 DELETE /tracks/1.json | def destroy
@track = Track.find(params[:id])
@track.destroy
respond_to do |format|
format.html { redirect_to tracks_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @track = Track.find(params[:id])\n @track.destroy\n\n respond_to do |format|\n format.html { redirect_to tracks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @track.destroy\n respond_to do |format|\n format.html { redirect_to tracks_url }\n ... | [
"0.783509",
"0.77724564",
"0.77185786",
"0.76134396",
"0.7600066",
"0.7583743",
"0.7579974",
"0.75128955",
"0.75128955",
"0.750961",
"0.7469969",
"0.7455386",
"0.745172",
"0.7422452",
"0.7381274",
"0.73347914",
"0.7296304",
"0.72338164",
"0.72317976",
"0.72081035",
"0.7083868... | 0.7869887 | 0 |
add colon seperator to mac address | def add_mac_colon!
unless mac.include? ':'
self.mac = mac.to_s.chars.each_slice(2).map(&:join).join(':')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def macify\n split(\":\").map {|a| a[0].chr == \"0\" ? a[1].chr : a}.join(\":\")\n end",
"def format_mac_address\n self.mac_address = self.mac_address.to_s.upcase.gsub(/[^A-F0-9]/,'')\n end",
"def format_mac_address\n\t\tself.mac_address = self.mac_address.to_s().upcase().gsub( /[^A-F0-9]/, '' )\n\tend... | [
"0.767821",
"0.75181",
"0.7291812",
"0.70046186",
"0.6903953",
"0.652185",
"0.6519542",
"0.642931",
"0.642931",
"0.6372422",
"0.6372422",
"0.62451327",
"0.6222167",
"0.62015545",
"0.6163365",
"0.6123741",
"0.6051091",
"0.60508335",
"0.59860754",
"0.59672433",
"0.59672433",
... | 0.8748151 | 1 |
Draws the metres per second screen on the Shoes app window. | def metres_per_second_screen
@heading = 'Metres per second = (velocity × 1000) / 3600'
background('images/conversions_large.png')
# Metres per second screen header
ScreenHeader.new(self, '/title_screen/conversions_screen', @@font, @heading)
# Metres per second screen content
flow(:height => 640, :width => 1080, :scroll => true) do
# Left margin offset
stack(:height => 640, :width => 80) do
end
# Content column
stack(:height => 640, :width => 1000) do
ScreenLabel.new(self, @@font, @heading, 'Velocity')
flow do
@velocity = ScreenEditLine.new(self, @@font, @heading)
@velocity_unit = para(strong(' kmh'), strong(sup('-1')))
@velocity_unit.style(@@screen_unit_text_styles)
end
@calculate = button('Calculate')
@result_display = flow
@error_display = flow
@calculate.click do
@result_display.clear do
@result = Joules.to_metres_per_second(@velocity.text.to_f)
@metres_per_second = para(@result.to_s)
@metres_per_second_unit = para(' ms', sup('-1'))
@metres_per_second.style(@@screen_result_text_styles)
@metres_per_second_unit.style(@@screen_result_text_styles)
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_powerup_slots\n 10.times do |i|\n x = @scene.width * 0.01 + i * @scene.width * 0.07\n y = @scene.width * 0.01\n j = @scene.player.powerups[i] ? 1 : 0\n draw_powerup_slot(x, y, @powerups_imgs[i][j], img_color: Gosu::Color.rgba(255, 255, 255, 100))\n @numbers[i].draw(\n @s... | [
"0.62269336",
"0.60541815",
"0.6005243",
"0.598462",
"0.5922862",
"0.5915031",
"0.59049004",
"0.5881287",
"0.58711034",
"0.5847755",
"0.58349603",
"0.58322984",
"0.57867515",
"0.57775575",
"0.57611966",
"0.5729625",
"0.57250834",
"0.57250834",
"0.5684782",
"0.5660428",
"0.565... | 0.70512617 | 0 |
Method that will find total cost of an order and add tax (Wave 1) | def total
if @products.empty?
return 0
else
total = (@products.values.sum * 1.075).round(2)
end
return total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tax\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.tax_amount }\n end",
"def total\n total_cost = 0\n \n # Summing up the product cost\n @products.each do |item, cost|\n total_cost += cost\n end\n \n # Calculate a 7.5% tax\n total_ord... | [
"0.78233796",
"0.776539",
"0.7762385",
"0.75294805",
"0.7501145",
"0.74529886",
"0.73976743",
"0.73939544",
"0.73676056",
"0.7350388",
"0.7292043",
"0.72769564",
"0.72755927",
"0.726773",
"0.72506976",
"0.7222082",
"0.7218978",
"0.72047305",
"0.7177929",
"0.71737546",
"0.7167... | 0.0 | -1 |
Method that will add products to order, and check for duplicates | def add_product(product_name,price)
if @products.has_key?(product_name)
raise ArgumentError, "#{product_name} has already been added"
end
return @products[product_name] = price
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_products()\n \t#we validate if we have products in the array, if so we check if the product\n \t#that we want to add is already there\n if @@products.count >0\n begin\n \tif Product.product_include_by_title?(self.title)\n raise DuplicateProductError.new()\n \telse\n \t\... | [
"0.77197534",
"0.76214135",
"0.73204696",
"0.71659404",
"0.71066445",
"0.7096579",
"0.70058763",
"0.6884589",
"0.684214",
"0.68332213",
"0.68297553",
"0.68220043",
"0.6818361",
"0.68087924",
"0.67904645",
"0.6766854",
"0.6757525",
"0.67365026",
"0.66966736",
"0.6644398",
"0.6... | 0.6412725 | 36 |
def get_page(url) agent = Mechanize.new agent.user_agent_alias = 'Mac Safari' agent.get(url) end def get_apps(page, category) puts 'get apps start' apps = page.parser.css('.sitemcontainer') apps.each do |app| name = app.css('h2').text dev = app.css('.arow.aspacingnone>span').text desc = app.css('.aunorderedlist>span').text rating = app.css('.aicon.aiconstar').text number_of_rating = app.css('.asizesmall.alinknormal.atextnormal').text skill = Skill.find_or_initialize_by(name: name) skill.update_attributes(name: name, dev: dev, desc: desc, category: category, rating: rating, number_of_rating: number_of_rating) skill.save! puts skill.inspect end end | def random_user_agent
agent_version = ['Chrome/43.0.2357', 'Chrome/44.0.2403', 'Chrome/45.0.2454', 'Chrome/46.0.2490', 'Chrome/47.0.2526', 'Chrome/48.0.2564', 'Chrome/49.0.2623', 'Chrome/50.0.2661', 'Chrome/51.0.2704', 'Chrome/52.0.2743', 'Chrome/53.0.2785', 'Chrome/54.0.2840', 'Chrome/55.0.2883', 'Chrome/56.0.2924', 'Chrome/57.0.2987', 'Chrome/58.0.3029', 'Chrome/59.0.3071', 'Chrome/61.0.3163', 'Chrome/62.0.3202', 'Chrome/64.0.3282']
index_number = rand(0...agent_version.length)
agent_version[index_number]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p link\n page = @agent.get(link)\n\n # get all categories\n get_items_with_all_category(page)\nend",
"def scrap_data_from_page link\n p ... | [
"0.6525521",
"0.6525521",
"0.6525521",
"0.6525521",
"0.6389039",
"0.6302074",
"0.6175482",
"0.61276966",
"0.60865456",
"0.60865456",
"0.60865456",
"0.60865456",
"0.60703695",
"0.59575725",
"0.59490436",
"0.5934929",
"0.593285",
"0.593285",
"0.59296566",
"0.59296566",
"0.59296... | 0.0 | -1 |
GET /slots/1 GET /slots/1.xml | def show
@slot = Slot.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @slot }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @time_slot = TimeSlot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @time_slot }\n end\n end",
"def show\n @timeslot = current_event.timeslots.find(params[:id])\n\n respond_to do |format|\n format.html # show.ht... | [
"0.6821123",
"0.6602497",
"0.6251822",
"0.619962",
"0.6129881",
"0.6111407",
"0.6106511",
"0.5933489",
"0.5898343",
"0.58713585",
"0.58581305",
"0.58569545",
"0.5853768",
"0.5834255",
"0.5798053",
"0.57666826",
"0.5745348",
"0.5735325",
"0.564209",
"0.56380665",
"0.563461",
... | 0.71735495 | 0 |
GET /slots/new GET /slots/new.xml | def new
@slot = Slot.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @slot }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @slot = Slot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slot }\n end\n end",
"def new\n @time_slot = TimeSlot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @time_slot }\n e... | [
"0.74923635",
"0.74367446",
"0.7416437",
"0.6737871",
"0.6639137",
"0.66164666",
"0.64942634",
"0.6435043",
"0.6418814",
"0.641313",
"0.6403495",
"0.6375571",
"0.6375571",
"0.6375571",
"0.63736445",
"0.63661915",
"0.63463235",
"0.6342432",
"0.632959",
"0.63186485",
"0.6308651... | 0.78836596 | 0 |
POST /slots POST /slots.xml | def create
error = false
msg = ""
@slot = Slot.new
shelf = Shelf.find_by_number(params[:slot][:shelf])
unless shelf
error = true
msg << "Shelf does not exist"
else
box = shelf.boxes.find_by_number(params[:slot][:box])
unless box
error = true
msg << "Box does not exist, Please create box first"
#redirect_to new_box_path
#flash[:notice] = msg
#return
else
slot = box.slots.find_by_number(params[:slot][:number])
if slot
error = true
msg << "Slot already exists, Please edit/update"
redirect_to edit_slot_path(slot)
flash[:notice] = msg
return
else
@slot.box = box
@slot.number = params[:slot][:number]
end
end
end
respond_to do |format|
if !error and @slot.save
flash[:notice] = 'Slot was successfully created.'
format.html { redirect_to(@slot) }
format.xml { render :xml => @slot, :status => :created, :location => @slot }
else
flash[:notice] = msg
format.html { render :action => "new" }
format.xml { render :xml => @slot.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_slots(params = {})\n scope 'user_schedule'\n post('/schedule/slots/', params)\n end",
"def create\n @slot = @calendar.slots.create(slot_params)\n\n respond_to do |format|\n if @slot.save\n format.html { redirect_to hairdresser_calendar_slot_path(@hairdresser,@calendar,... | [
"0.74817264",
"0.6598603",
"0.65235317",
"0.64884144",
"0.64678806",
"0.6404547",
"0.6375955",
"0.6347318",
"0.628331",
"0.62639856",
"0.6251608",
"0.6202767",
"0.61762834",
"0.617276",
"0.61683416",
"0.6164765",
"0.6148854",
"0.61402994",
"0.6127283",
"0.6056663",
"0.601718"... | 0.5879413 | 27 |
PUT /slots/1 PUT /slots/1.xml | def update
@slot = Slot.find(params[:id])
error = false
msg = ""
shelf = Shelf.find_by_number(params[:slot][:shelf])
unless shelf
error = true
msg << "Shelf does not exist"
else
box = shelf.boxes.find_by_number(params[:slot][:box])
unless box
error = true
msg << "Box does not exist, Please create box first"
else
slot = box.slots.find_by_number(params[:slot][:number])
msg << "New Slot created" if slot
@slot.box = box
@slot.number = params[:slot][:number]
end
end
respond_to do |format|
if !error and @slot.update_attributes(params[:slot])
flash[:notice] = 'Slot was successfully updated.'
format.html { redirect_to(@slot) }
format.xml { head :ok }
else
flash[:notice] = msg
format.html { render :action => "edit" }
format.xml { render :xml => @slot.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @slot.update(slot_params)\n format.html { redirect_to \"/slots\", notice: 'Slot was successfully updated.' }\n format.json { render :show, status: :ok, location: @slot }\n else\n format.html { render :edit }\n format.json { render js... | [
"0.6834601",
"0.67173296",
"0.65733546",
"0.6432688",
"0.6379027",
"0.6379027",
"0.6323132",
"0.6323132",
"0.6323132",
"0.6321841",
"0.6321841",
"0.63125277",
"0.6290492",
"0.62641305",
"0.6254882",
"0.62439394",
"0.62433785",
"0.6179645",
"0.6177824",
"0.6128423",
"0.6077744... | 0.68275243 | 1 |
DELETE /slots/1 DELETE /slots/1.xml | def destroy
@slot = Slot.find(params[:id])
@slot.destroy
respond_to do |format|
format.html { redirect_to(slots_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_slots\n\t\tbegin\n\t\t\tclear_this_week_slots\n\t\t\trender :nothing => true, :status => 200, :content_type => 'text/html'\n\t\trescue\n\t\t\trender :nothing => true, :status => 500, :content_type => 'text/html'\n\t\tend\n\tend",
"def delete_slots\n\t\tbegin\n\t\t\tclear_this_week_slots\n\t\t\trender ... | [
"0.6875624",
"0.6875624",
"0.67429847",
"0.6599753",
"0.656365",
"0.6544957",
"0.6483742",
"0.64493614",
"0.64493614",
"0.64493614",
"0.6439119",
"0.643675",
"0.643356",
"0.6332758",
"0.6328593",
"0.62841046",
"0.6268517",
"0.6243602",
"0.6204356",
"0.61346483",
"0.6125209",
... | 0.7371398 | 0 |
special sum set problems n=7 : 20, 31, 38, 39, 40, 42, 45 | def verify_no_sum(sums, val)
unless sums[val].nil?
puts "ERROR: sum #{val} already exists"
return false
end
sums[val] = true
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(n=16) end",
"def sum(n)\n end",
"def sum_of_3_or_5_multiples(n)\n n = n.to_i\n #compteur de boucle\n i = 0\n #tableu incluant les multiple de 3 et 5\n result_array = []\n while i < n\n a = i%3\n b = i%5\n if a == 0 || b == 0\n result_array << i\n i+=1\n ... | [
"0.7369723",
"0.72293794",
"0.71957844",
"0.71124274",
"0.7074046",
"0.6991422",
"0.6955885",
"0.6942705",
"0.6866138",
"0.68459463",
"0.68305606",
"0.6828927",
"0.6828378",
"0.68110305",
"0.67804164",
"0.67758757",
"0.67371917",
"0.6734064",
"0.6733151",
"0.67129046",
"0.668... | 0.0 | -1 |
LATER: still need to check if B.size > C.size => S(B) > S(C) | def check_special_sum(set)
sums = Array.new
# initialize the sums array with the set elements
#set.each { |i| verify_no_sums(sums, i) }
max = 2**set.size-1
(1..max).each do |i|
subset = generate_subset(set, i)
puts "subset: " + subset.join(' ')
sum = subset.inject(0) { |sum,j| sum += j }
unless verify_no_sum(sums, sum)
return false
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution(arr)\n arr_size = arr.size\n\n arr.any? { |el| el > arr_size } || arr.uniq.size < arr_size ? 0 : 1\nend",
"def solution(a, b)\n a.size > b.size ? b+a+b : a+b+a\nend",
"def problem_106\n a = [1,2,3,4]\n a = [1,2,3,4,5,6,7]\n a = [1,2,3,4,5,6,7,8,9,10,11,12] \n \n num = 0\n seen = {}\n # D... | [
"0.6085659",
"0.6010867",
"0.5899111",
"0.58746535",
"0.5837003",
"0.5687605",
"0.5678357",
"0.56720716",
"0.56529105",
"0.5620506",
"0.5620506",
"0.5618508",
"0.560624",
"0.5584562",
"0.5575547",
"0.55649817",
"0.55462354",
"0.5542409",
"0.5515691",
"0.5497058",
"0.548618",
... | 0.0 | -1 |
Attempts to merge an event with the previously occurring one, as in the case of a 2+ hour lecture | def attempt_merge(event, week, day, time)
merged = false
# Retrieve the events in the previous timeslot
previous = previous_events(event)
previous.each do |prev|
if prev.summary == event.summary
# If the two events have the same summary merge them
# into a single event spanning multiple hours
prev.end = event.end
register_event(event.start, prev)
merged = true
break
end
end
# If we couldn't find a previous event to merge with,
# add the event to the calendar the normal way
unless merged
@events << event
register_event(event.start, event)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(event)\n @total_time += event.total_time\n end",
"def merge(event, destroy = true)\n begin\n #merge scores\n raise if !self.scores.empty? && !event.scores.empty?\n event.scores.each do |score|\n score.update(event_id: self.id)\n end\... | [
"0.6672891",
"0.6623762",
"0.6309457",
"0.6010809",
"0.5999068",
"0.59929574",
"0.59780246",
"0.5722754",
"0.56469476",
"0.5622929",
"0.56161004",
"0.56128895",
"0.561032",
"0.5579705",
"0.5556244",
"0.5553702",
"0.54911625",
"0.5484712",
"0.5457265",
"0.539498",
"0.539301",
... | 0.71362364 | 0 |
Adds event to the hash table that associates a timeslot with the events occurring during it | def register_event(datetime, event)
@dups[datetime] << event
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_event(e, task_id)\n @events[task_id] ||= []\n @events[task_id] << e\n end",
"def make_new_event\n event = Hash.new\n event[:event_game_type] = 2 # 1=Pairs, 2=Teams.\n event\nend",
"def manage_time_slots\n @time_slot = TimeSlot.new\n\n end",
"def create\n @event = Event.find(pa... | [
"0.6333638",
"0.6000756",
"0.5943554",
"0.59239984",
"0.5885866",
"0.58299613",
"0.5803311",
"0.57810146",
"0.57657474",
"0.5755346",
"0.57308596",
"0.5688654",
"0.5657044",
"0.56565386",
"0.564965",
"0.5583454",
"0.55367684",
"0.55268115",
"0.5506775",
"0.5491755",
"0.547194... | 0.59403443 | 3 |
Finds all events occurring 1 hour before the given event | def previous_events(event)
# Initialise the hash to use an empty array as default value
@dups ||= Hash.new { |h, k| h[k] = [] }
one_hour_earlier = event.start.advance(:hours => -1)
@dups[one_hour_earlier]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hour_events(selected_day, hour, events)\n h = hour.split(\":\")\n hour_end = \"#{h[0]}:59\"\n events.select { |e| e.start_time.to_date == selected_day && (e.start_time.to_time.strftime(\"%H:%M\") >= hour) && (e.start_time.to_time.strftime(\"%H:%M\") < hour_end) }\n end",
"def future_events\... | [
"0.6659516",
"0.5983867",
"0.59466106",
"0.59415716",
"0.5928976",
"0.5882568",
"0.58676803",
"0.5864357",
"0.58511597",
"0.58473015",
"0.5818018",
"0.58180034",
"0.58030826",
"0.5744969",
"0.5742501",
"0.5724377",
"0.570908",
"0.5703657",
"0.5702966",
"0.5702966",
"0.5694436... | 0.6650012 | 1 |
GET /books GET /books.json | def index
@books = Book.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n ... | [
"0.79133517",
"0.7684243",
"0.7639073",
"0.7625297",
"0.7578786",
"0.7543612",
"0.7535015",
"0.7458293",
"0.7415717",
"0.73161376",
"0.7246593",
"0.7246593",
"0.723858",
"0.72362983",
"0.72362983",
"0.72362983",
"0.72362983",
"0.72362983",
"0.72362983",
"0.72362983",
"0.72362... | 0.0 | -1 |
GET /books/1 GET /books/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n ... | [
"0.763825",
"0.7443726",
"0.74420583",
"0.7336092",
"0.73146033",
"0.72982717",
"0.7227251",
"0.7227251",
"0.7222778",
"0.72097474",
"0.72097474",
"0.72097474",
"0.72097474",
"0.72097474",
"0.72097474",
"0.72097474",
"0.72097474",
"0.72097474",
"0.7158527",
"0.71442556",
"0.7... | 0.0 | -1 |
POST /books POST /books.json | def create
@book = Book.new(book_params)
respond_to do |format|
if @book.save
format.html { redirect_to @book, notice: 'Book was successfully created.' }
format.json { render :show, status: :created, location: @book }
else
format.html { render :new }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @book = Book.new(book_params)\n\n if @book.save\n render json: @book, status: :created, location: @book\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end",
"def create\n\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @b... | [
"0.7260979",
"0.7052168",
"0.6990385",
"0.69234765",
"0.6920176",
"0.68718755",
"0.68718755",
"0.68718755",
"0.68718755",
"0.68718755",
"0.685515",
"0.6847371",
"0.67841905",
"0.6777309",
"0.67586553",
"0.67586553",
"0.6756703",
"0.6698212",
"0.66888076",
"0.6679647",
"0.6679... | 0.67478836 | 29 |
PATCH/PUT /books/1 PATCH/PUT /books/1.json | def update
respond_to do |format|
if @book.update(book_params)
format.html { redirect_to @book, notice: 'Book was successfully updated.' }
format.json { render :show, status: :ok, location: @book }
else
format.html { render :edit }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n... | [
"0.7048773",
"0.688817",
"0.68527925",
"0.68271405",
"0.6824262",
"0.6821144",
"0.6802083",
"0.6802083",
"0.6802083",
"0.6802083",
"0.6802083",
"0.6802083",
"0.6802083",
"0.6802083",
"0.6802083",
"0.6800069",
"0.67871505",
"0.67303824",
"0.67264384",
"0.6724246",
"0.67084",
... | 0.65435743 | 51 |
DELETE /books/1 DELETE /books/1.json | def destroy
@book.destroy
respond_to do |format|
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n \n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n form... | [
"0.7483369",
"0.74432313",
"0.74432313",
"0.7437104",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74332035",
"0.74191445",
"0.7401149",
"0.7401149",
"0.7401149",
"... | 0.7147981 | 61 |
Use callbacks to share common setup or constraints between actions. | def set_book
@book = Book.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def book_params
params.require(:book).permit(:title, :author_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /customer_infos GET /customer_infos.xml | def index
@customer_infos = CustomerInfo.paginate :page => params[:page], :order => "cust_id asc", :per_page => 10
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @customer_infos }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @customer_info = CustomerInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @customer_info }\n end\n end",
"def show\n\t\tshow_\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xm... | [
"0.75976616",
"0.71137524",
"0.7109898",
"0.7050556",
"0.7050556",
"0.68926185",
"0.6881126",
"0.6760966",
"0.665416",
"0.6546796",
"0.6540915",
"0.65347326",
"0.65347326",
"0.65314627",
"0.65314627",
"0.65314627",
"0.65314627",
"0.65314627",
"0.65314627",
"0.65219593",
"0.65... | 0.6978109 | 5 |
GET /customer_infos/1 GET /customer_infos/1.xml | def show
@customer_info = CustomerInfo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @customer_info }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @self_service_customer = SelfService::Customer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @self_service_customer }\n end\n end",
"def show\n @customer = Customer.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.7261446",
"0.714433",
"0.714433",
"0.7091037",
"0.70083773",
"0.68137616",
"0.6666594",
"0.66285115",
"0.6618032",
"0.6598853",
"0.659086",
"0.659086",
"0.6557537",
"0.64941466",
"0.64761776",
"0.6474688",
"0.6423447",
"0.6393918",
"0.63766646",
"0.63766646",
"0.63766646",... | 0.75974226 | 0 |
GET /customer_infos/new GET /customer_infos/new.xml | def new
@customer_info = CustomerInfo.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @customer_info }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @customer = @representative.customers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { rend... | [
"0.76945466",
"0.76748556",
"0.76748556",
"0.7456731",
"0.7413088",
"0.7207032",
"0.71271276",
"0.70671886",
"0.70663524",
"0.6993345",
"0.69812065",
"0.697047",
"0.6968489",
"0.6968489",
"0.69619256",
"0.69619256",
"0.69619256",
"0.69619256",
"0.69619256",
"0.6829766",
"0.68... | 0.79555357 | 0 |
POST /customer_infos POST /customer_infos.xml | def create
@customer_info = CustomerInfo.new(params[:customer_info])
respond_to do |format|
if @customer_info.save
format.html { redirect_to(@customer_info, :notice => 'Customer info was successfully created.') }
format.xml { render :xml => @customer_info, :status => :created, :location => @customer_info }
else
format.html { render :action => "new" }
format.xml { render :xml => @customer_info.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @customer_info = CustomerInfo.new(customer_info_params)\n\n respond_to do |format|\n if @customer_info.save\n format.html { redirect_to @customer_info, notice: 'Customer info was successfully created.' }\n format.json { render :show, status: :created, location: @customer_info ... | [
"0.7040139",
"0.6568712",
"0.6558975",
"0.64750993",
"0.6456543",
"0.64337444",
"0.64111096",
"0.63241106",
"0.6276429",
"0.622718",
"0.6196296",
"0.61898845",
"0.61860275",
"0.6171015",
"0.6168529",
"0.61649346",
"0.6162858",
"0.6160718",
"0.6150525",
"0.6147185",
"0.6147185... | 0.72703505 | 0 |
PUT /customer_infos/1 PUT /customer_infos/1.xml | def update
@customer_info = CustomerInfo.find(params[:id])
respond_to do |format|
if @customer_info.update_attributes(params[:customer_info])
format.html { redirect_to(@customer_info, :notice => 'Customer info was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @customer_info.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_customer(id, data)\n put(\"customers/#{id}\", { body: data })\n end",
"def update\n respond_to do |format|\n if @customer_info.update(customer_info_params)\n format.html { redirect_to @customer_info, notice: 'Customer info was successfully updated.' }\n format.json { render :... | [
"0.6853658",
"0.66951996",
"0.66615885",
"0.66289353",
"0.6461773",
"0.644054",
"0.6438453",
"0.64271456",
"0.6340429",
"0.63093203",
"0.62132376",
"0.6190709",
"0.61719567",
"0.6168597",
"0.61665386",
"0.61665386",
"0.61665386",
"0.61665386",
"0.61665386",
"0.61665386",
"0.6... | 0.7069811 | 0 |
DELETE /customer_infos/1 DELETE /customer_infos/1.xml | def destroy
@customer_info = CustomerInfo.find(params[:id])
@customer_info.destroy
respond_to do |format|
format.html { redirect_to(customer_infos_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n find_customer\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to('/customers/overview') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n form... | [
"0.7027337",
"0.6993546",
"0.6993546",
"0.6993546",
"0.69323224",
"0.6589288",
"0.6531271",
"0.6517812",
"0.64967686",
"0.64804983",
"0.6444663",
"0.64406925",
"0.64406925",
"0.6440298",
"0.64154166",
"0.63980323",
"0.6394103",
"0.63924533",
"0.6391912",
"0.63662684",
"0.6363... | 0.737141 | 0 |
phase 2 time: O(n), memory: O(1) | def largest_contigous_subsum_ii(list)
current_sum = list.first
max = list.first
(1..-1).each do |i|
current_sum += list[i]
current_sum = 0 if current_sum < 0
max = current_sum if max < current_sum
end
current_sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lcs_phase_two(arr)\n return arr.max if arr.max < 0 #edge case\n\n current = 0\n largest = 0\n\n arr.each do |ele|\n current += ele\n current = 0 if current < 0 #bookmark\n largest = current if largest < current\n end\n\n largest\nend",
"def phase_two(arr)\n min = arr[0]\n arr.each do |ele|\n... | [
"0.6081175",
"0.59422666",
"0.5844237",
"0.58413947",
"0.58065695",
"0.57572216",
"0.5723019",
"0.56053114",
"0.5598041",
"0.55522966",
"0.5529185",
"0.5504703",
"0.5486851",
"0.5465692",
"0.5458168",
"0.5413797",
"0.5401369",
"0.53594524",
"0.5358836",
"0.5342424",
"0.534039... | 0.0 | -1 |
Size of the database (number of docs) | def size
reader.doccount
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dbsize; end",
"def dbsize; end",
"def database_size\n _, conf = @db.uri.split(\":\", 2)\n size = case @db.adapter_scheme\n when :sqlite\n File.size(@db.opts[:database])\n when :postgres\n @db.fetch(\"select pg_database_size('#{@db.opts[:database]}')\").... | [
"0.83391416",
"0.83391416",
"0.7859399",
"0.7808499",
"0.77897614",
"0.7615546",
"0.76124144",
"0.7361322",
"0.7300285",
"0.7300285",
"0.7252181",
"0.7252181",
"0.7218405",
"0.7201208",
"0.7201121",
"0.71247756",
"0.7031502",
"0.69972104",
"0.6982206",
"0.6982206",
"0.6937468... | 0.7443275 | 7 |
Delete a document identified by a unique term; this method is used by the orm adapters | def delete_doc_with_unique_term(term)
writer.delete_document("Q#{term}")
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_term(params)\n send_get \"delete_term\", params\n end",
"def cloud_search_delete_document(doc)\n doc.version += 1\n self.cloud_search_batcher_command(:delete_document, doc)\n end",
"def unindex(obj)\n XapianDb.database.delete_doc_with_unique_term(obj.xapian_id... | [
"0.7139517",
"0.70760864",
"0.69910145",
"0.69217944",
"0.69153166",
"0.67901236",
"0.6720881",
"0.67172384",
"0.67172384",
"0.67154527",
"0.6700994",
"0.6660996",
"0.66535676",
"0.66498435",
"0.66439533",
"0.6623229",
"0.6606348",
"0.65628064",
"0.6528635",
"0.64888257",
"0.... | 0.8506329 | 0 |
Get the writer to write to the database | def writer
@writer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writer\n @writer ||= Xapian::WritableDatabase.new(@path, @db_flag)\n end",
"def writer\n @writer ||= ThreadSettings.current.writer || Kithe.indexable_settings.writer_instance!\n end",
"def writer\n @writer ||= lookup_operation_handler(:write_register)\n end",
"def writer_... | [
"0.81011266",
"0.679186",
"0.65793276",
"0.6562886",
"0.6505344",
"0.6490499",
"0.6490499",
"0.63508517",
"0.62860996",
"0.6197298",
"0.618087",
"0.61259955",
"0.6046188",
"0.5976383",
"0.59684646",
"0.5962035",
"0.5962035",
"0.5959467",
"0.5933248",
"0.5933248",
"0.59016347"... | 0.72526234 | 1 |
Commit all pending changes | def commit
# Nothing to do for an in memory database
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commit_if_dirty\n # no op\n end",
"def commit!\n _commit( false )\n end",
"def commit\n # no op\n end",
"def commit\n submissions.each(&:commit)\n end",
"def commit\n sanity_check\n @handle.commit\n end",
"def commit()\n #This is a stub, use... | [
"0.7283836",
"0.72704214",
"0.7214347",
"0.7139845",
"0.6937748",
"0.68931866",
"0.6811416",
"0.67850447",
"0.67572963",
"0.6718459",
"0.6715804",
"0.6694903",
"0.66698915",
"0.66603565",
"0.6642117",
"0.6576609",
"0.6576609",
"0.6576609",
"0.6575766",
"0.6563224",
"0.6499691... | 0.63039017 | 35 |
Get the readable instance of the database. On each access this method reopens the readable database to make sure you get the latest changes to the index | def reader
# Always reopen the readable database so we get live index data
# TODO: make this configurable
@reader.reopen
@reader
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def database\n database = @writable_database || (@database ||= Xapian::Database.new(path))\n \n if self.expired?\n puts 'reloaded'\n database.reopen \n end\n \n database\n end",
"def db\n @db ||= new_connection\n end",
"def database\n... | [
"0.7522448",
"0.69429696",
"0.68941253",
"0.6833955",
"0.6807773",
"0.67366314",
"0.6722325",
"0.6679491",
"0.66558605",
"0.6606345",
"0.6578292",
"0.65393466",
"0.6513222",
"0.6499299",
"0.6499299",
"0.64990187",
"0.6482177",
"0.6475319",
"0.64637464",
"0.63869876",
"0.63408... | 0.79070175 | 0 |
The writer is instantiated layzily to avoid a permanent write lock on the database. Please note that you will get locking exceptions if you open the same database multiple times and access the writer in more than one instance! | def writer
@writer ||= Xapian::WritableDatabase.new(@path, @db_flag)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writable_database\n @writable_database ||= generate_database\n end",
"def writable_database\n FileUtils.mkdir_p(File.dirname(path)) unless File.exist?(File.dirname(path))\n @writable_database ||= Xapian::WritableDatabase.new(path, Xapian::DB_CREATE_OR_OPEN)\n end",
"def datab... | [
"0.6629145",
"0.6359041",
"0.6311209",
"0.61853904",
"0.6019001",
"0.60075796",
"0.59698385",
"0.595926",
"0.59259725",
"0.5909628",
"0.5841156",
"0.5818848",
"0.57639503",
"0.5746456",
"0.5729205",
"0.57176244",
"0.5546069",
"0.5545563",
"0.5540651",
"0.5538902",
"0.5500846"... | 0.782754 | 0 |
Commit all pending changes | def commit
writer.commit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commit_if_dirty\n # no op\n end",
"def commit!\n _commit( false )\n end",
"def commit\n # no op\n end",
"def commit\n submissions.each(&:commit)\n end",
"def commit\n sanity_check\n @handle.commit\n end",
"def commit()\n #This is a stub, use... | [
"0.7283836",
"0.72704214",
"0.7214347",
"0.7139845",
"0.6937748",
"0.68931866",
"0.6811416",
"0.67850447",
"0.67572963",
"0.6718459",
"0.6715804",
"0.6694903",
"0.66698915",
"0.66603565",
"0.6642117",
"0.6576609",
"0.6576609",
"0.6576609",
"0.6575766",
"0.6563224",
"0.6499691... | 0.62403136 | 38 |
method is the method to call to update all records filter_param is the value to test "all" against. If the filter is all, the paging sequence changes per_page is the number of records to process at one time. | def pager(method,filter_param,per_page=500)
session[:ooc_deviation_search][:row_from]=0
session[:ooc_deviation_search][:row_to]=per_page
deviations = OocDeviationSearch.search(session[:ooc_deviation_search])
count = deviations.size == 0 ? 0 : deviations.first.count
if count > 0
pages = (count / per_page.to_f).ceil
if count < per_page
per_page=count
end
pages.times do |page|
page +=1
session[:ooc_deviation_search][:row_from]=0
session[:ooc_deviation_search][:row_to]=per_page
if filter_param.downcase=='all'
row_to=per_page*page
row_from=(row_to-per_page)+1
session[:ooc_deviation_search][:row_from]=row_from
session[:ooc_deviation_search][:row_to]=row_to
end
#$stderr.puts "pager: #{page} | #{pages} | #{session[:ooc_deviation_search][:row_from]} |\
##{session[:ooc_deviation_search][:row_to]} | #{count}"
unless page==1
SwareBase.uncached do
deviations = OocDeviationSearch.search(session[:ooc_deviation_search])
count = deviations.size == 0 ? 0 : deviations.first.count
end
end
send(method, deviations)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n @page_size = args[:page_size] if args.key?(:page_size)\n @page_token = args[:page_token] if args.key?(:page_token)\n end",
"def update!(**args)\n @filter = args[:filter] if args.key?(:filter)\n ... | [
"0.62587106",
"0.62587106",
"0.62587106",
"0.62507826",
"0.6012233",
"0.600588",
"0.5893161",
"0.5761188",
"0.56847054",
"0.5677778",
"0.5661644",
"0.56604224",
"0.56316286",
"0.55564535",
"0.55521804",
"0.5537817",
"0.54833746",
"0.5471604",
"0.5450214",
"0.54492825",
"0.543... | 0.5489862 | 16 |
GET /users GET /users.json | def index
#This clamps the offset and limit values between 0 and Event.count-1, since there isnt a clamp function in ruby
offset = [0, params[:offset].to_i, User.count-1].sort[1]
#This also clamps, between 1 and 5
limit = [1, params[:limit].to_i, 5].sort[1]
#Sort asc since that means start from id 1 and work upwards
@users = User.all.offset(offset).limit(limit)
count = @users.count
#If the offset + limit selects higher items than there is, no next_link
if offset+limit >= User.count
next_link = nil
elsif count < User.count
next_link = "http://localhost:3000/api/v1/users/?offset=#{offset+limit}&limit=#{limit}"
else
next_link = nil
end
#If the offset is larger than 0, there must be atleast 1 item before
if offset > 0 && User.count > 0
#Do note that offset - limit can become negative, but since offset gets clamped, it doesn't really matter
previous = "http://localhost:3000/api/v1/users/?offset=#{offset-limit}&limit=#{limit}"
else
previous = nil
end
respond_with users: @users, total: User.count, limit: limit, offset: offset, next: next_link, previous: previous
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users(args = {})\n get(\"/users.json\",args)\n end",
"def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end",
"def GetUsers params = {}\n\n para... | [
"0.82109934",
"0.7873764",
"0.7860689",
"0.78108346",
"0.78067017",
"0.7678852",
"0.76586664",
"0.76318866",
"0.7582366",
"0.75291824",
"0.7487637",
"0.74485743",
"0.7439024",
"0.7437192",
"0.7427442",
"0.73978853",
"0.73978853",
"0.73978853",
"0.73978853",
"0.7377353",
"0.73... | 0.0 | -1 |
GET /users/1 GET /users/1.json | def show
respond_with @user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ... | [
"0.81046426",
"0.7703556",
"0.77011716",
"0.76262826",
"0.7582106",
"0.74818",
"0.7461394",
"0.7446168",
"0.730656",
"0.7300699",
"0.72902125",
"0.72781444",
"0.72358584",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.72335744",
"0.722... | 0.0 | -1 |
POST /users POST /users.json | def create
@user = User.new(user_params)
@user.is_administrator = false
respond_to do |format|
if @user.save
format.html { redirect_to login_url, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: login_url }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end",
"def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end",
"def post b... | [
"0.77179813",
"0.75206673",
"0.73831296",
"0.72405374",
"0.719841",
"0.7140812",
"0.71038526",
"0.7058827",
"0.7041636",
"0.70236504",
"0.7003128",
"0.70021695",
"0.70021695",
"0.70021695",
"0.69936967",
"0.6990463",
"0.6980393",
"0.6979075",
"0.69788617",
"0.69788617",
"0.69... | 0.0 | -1 |
PATCH/PUT /users/1 PATCH/PUT /users/1.json | def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { render :show, status: :ok, location: @user }
else
format.html { render :edit }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end",
"def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end",
"def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end",
"de... | [
"0.7225313",
"0.7128968",
"0.70038134",
"0.690346",
"0.68215525",
"0.6815542",
"0.6708435",
"0.66934186",
"0.6681013",
"0.6674042",
"0.6672844",
"0.6665153",
"0.6665153",
"0.6659798",
"0.6659798",
"0.6655773",
"0.66492975",
"0.6643141",
"0.664204",
"0.6635185",
"0.66182256",
... | 0.0 | -1 |
DELETE /users/1 DELETE /users/1.json | def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end",
"def delete\n render json: User.delete(params[\"id\"])\n end",
"def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end",
"def delete\n render json: Users.delete(params[\"id\... | [
"0.78750724",
"0.77518034",
"0.7713981",
"0.7610077",
"0.747295",
"0.74073994",
"0.74073994",
"0.7369968",
"0.7346072",
"0.7340465",
"0.7328618",
"0.7309635",
"0.73095363",
"0.7306841",
"0.7297868",
"0.72917855",
"0.7291585",
"0.7289111",
"0.7284347",
"0.7250935",
"0.7250935"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:username, :password, :password_confirmation, :email)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Send a 404 ("not found") page. Inspired by: This is intentionally short and does NOT use the standard layout, to minimize CPU and bandwidth use during an attack. Note that due to skip_before_action we don't redirect the URL, as there's no need to do so and skipping a redirect will save a roundtrip. We do try to guess the locale, since we can then provide a localespecific error message. | def error_404
# The default router already logs things, so we don't need to do more.
# You can do something like this to log more information, but be sure
# to escape attacker data to counter log forging:
# logger.info 'Page not found'
render(
template: 'static_pages/error_404',
formats: [:html], layout: false,
status: :not_found
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_not_found\n render 'shared/http_status', formats: [:html], locals: { code: '404', message: HttpStatusHelper::ERROR_CODE['message']['404'] }, status: 404, layout: false\n end",
"def not_found\n logger.error \"404 from #{request.referer}\"\n render :template => 'errors/404', :status => 404\n en... | [
"0.77349645",
"0.76929003",
"0.74906284",
"0.7445539",
"0.7395798",
"0.7395798",
"0.7395798",
"0.7365492",
"0.7365445",
"0.7360561",
"0.73314106",
"0.7316851",
"0.7218317",
"0.7217471",
"0.7207052",
"0.72027093",
"0.71856046",
"0.7182817",
"0.7171309",
"0.7155146",
"0.7133686... | 0.7381409 | 7 |
Weird special case: For David A. Wheeler to get log issues from Google, we have to have a special file to let Google verify access. | def google_verifier
render(
template: 'static_pages/google_verifier',
layout: false,
status: :ok
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_file; end",
"def log_file\n end",
"def localCheckFileExist(file, logkey='')\n fileexist = Mcmlln::Tools.checkFileExist(file)\n logstring = fileexist\n return fileexist\nrescue => logstring\n return ''\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def log_contents\n ... | [
"0.5594839",
"0.5403525",
"0.5383053",
"0.5216521",
"0.5204515",
"0.51384616",
"0.51384616",
"0.5133561",
"0.5130757",
"0.5117848",
"0.51108044",
"0.5088296",
"0.5065374",
"0.50345236",
"0.5023033",
"0.50080585",
"0.4980151",
"0.49612117",
"0.49598265",
"0.49542183",
"0.49302... | 0.0 | -1 |
We are not implementing full comparison, just an adequate subset for easy cases (a table with a trustworthy primary key, and constant columns). Make sure we are not trying to do something we're not ready for. | def validate_schema
all_cols1 = @db1.column_names(@table1)
all_cols2 = @db2.column_names(@table2)
if all_cols1 != all_cols2
raise "Columns do not match, please use full coopy toolbox"
end
key_cols1 = @db1.primary_key(@table1)
key_cols2 = @db2.primary_key(@table2)
if key_cols1 != key_cols2
raise "Primary keys do not match, please use full coopy toolbox"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def natural_key_equality_for_row(row)\n statement = []\n values = []\n natural_key.each do |nk|\n statement << \"#{nk} = ?\"\n values << row[nk]\n end\n statement = statement.join(\" AND \")\n ActiveRecord::Base.send(:sanitize_sql, [statement, *values])\n... | [
"0.64757264",
"0.6157762",
"0.60876185",
"0.57649916",
"0.5756951",
"0.5748112",
"0.57109255",
"0.57028127",
"0.5689319",
"0.56701475",
"0.56457174",
"0.55566436",
"0.55522656",
"0.555172",
"0.5522209",
"0.54885685",
"0.5466421",
"0.540768",
"0.5402286",
"0.53932357",
"0.5376... | 0.59363675 | 4 |
When working within a single database, we can delegate more work to SQL. So we specialize this case. | def apply_single
validate_schema
# Prepare some lists of columns.
key_cols = @db1.primary_key(@table1)
data_cols = @db1.except_primary_key(@table1)
all_cols = @db1.column_names(@table1)
# Let our public know we are beginning.
@patch.begin_diff
# Advertise column names.
@rc_columns = DiffColumns.new
@rc_columns.title_row = all_cols
@rc_columns.update(0)
cells = all_cols.map{|v| { :txt => v, :value => v, :cell_mode => "" }}
rc = RowChange.new("@@",cells)
@patch.apply_row(rc)
# If requested, we will be providing context rows around changed rows.
# This is not a natural thing to do with SQL, so we do it only on request.
# When requested, we need to buffer row changes.
@pending_rcs = []
# Prepare some useful SQL fragments to assemble later.
sql_table1 = @db1.quote_table(@table1)
sql_table2 = @db1.quote_table(@table2)
sql_key_cols = key_cols.map{|c| @db1.quote_column(c)}.join(",")
sql_all_cols = all_cols.map{|c| @db1.quote_column(c)}.join(",")
sql_key_match = key_cols.map{|c| @db1.quote_column(c)}.map{|c| "#{sql_table1}.#{c} IS #{sql_table2}.#{c}"}.join(" AND ")
sql_data_mismatch = data_cols.map{|c| @db1.quote_column(c)}.map{|c| "#{sql_table1}.#{c} IS NOT #{sql_table2}.#{c}"}.join(" OR ")
# For one query we will need to interleave columns from two tables. For
# portability we need to give these columns distinct names.
weave = all_cols.map{|c| [[sql_table1,@db1.quote_column(c)],
[sql_table2,@db2.quote_column(c)]]}.flatten(1)
dbl_cols = weave.map{|c| "#{c[0]}.#{c[1]}"}
sql_dbl_cols = weave.map{|c| "#{c[0]}.#{c[1]} AS #{c[0].gsub(/[^a-zA-Z0-9]/,'_')}_#{c[1].gsub(/[^a-zA-Z0-9]/,'_')}"}.join(",")
# Prepare a map of primary key offsets.
keys_in_all_cols = key_cols.each.map{|c| all_cols.index(c)}
keys_in_dbl_cols = keys_in_all_cols.map{|x| 2*x}
# Find rows in table2 that are not in table1.
sql = "SELECT #{sql_all_cols} FROM #{sql_table2} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table1} WHERE #{sql_key_match})"
apply_inserts(sql,all_cols,keys_in_all_cols)
# Find rows in table1 and table2 that differ while having the same primary
# key.
sql = "SELECT #{sql_dbl_cols} FROM #{sql_table1} INNER JOIN #{sql_table2} ON #{sql_key_match} WHERE #{sql_data_mismatch}"
apply_updates(sql,dbl_cols,keys_in_dbl_cols)
# Find rows that are in table1 but not table2
sql = "SELECT #{sql_all_cols} FROM #{sql_table1} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table2} WHERE #{sql_key_match})"
apply_deletes(sql,all_cols,keys_in_all_cols)
# If we are supposed to provide context, we need to deal with row order.
if @patch.want_context
sql = "SELECT #{sql_all_cols}, 0 AS __coopy_tag__ FROM #{sql_table1} UNION SELECT #{sql_all_cols}, 1 AS __coopy_tag__ FROM #{sql_table2} ORDER BY #{sql_key_cols}, __coopy_tag__"
apply_with_context(sql,all_cols,keys_in_all_cols)
end
# Done!
@patch.end_diff
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sql_modes; end",
"def select(db); end",
"def select(db); end",
"def target_sql_mode=(_arg0); end",
"def subscribe_sql_active_record; end",
"def execute sql\n db[sql]\n end",
"def orm; end",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n... | [
"0.67429376",
"0.66871613",
"0.66871613",
"0.6553068",
"0.6479085",
"0.639683",
"0.6382744",
"0.6317526",
"0.62225294",
"0.61815304",
"0.61454505",
"0.6135748",
"0.6120637",
"0.61160046",
"0.6085051",
"0.6072461",
"0.60159373",
"0.60036105",
"0.60010076",
"0.59938884",
"0.598... | 0.0 | -1 |
Do the context dance. | def apply_with_context(sql,all_cols,keys_in_all_cols)
hits = {}
@pending_rcs.each do |rc|
hits[rc.key] = rc
end
hist = []
n = 2
pending = 0
skipped = false
noted = false
last_row = nil
@db1.fetch(sql,all_cols + ["__coopy_tag__"]) do |row|
tag = row.pop.to_i
k = keyify(row.values_at(*keys_in_all_cols))
if hits[k]
emit_skip(row) if skipped
hist.each do |row0|
cells = row0.map{|v| { :txt => v, :value => v, :cell_mode => "" }}
rc = RowChange.new("",cells)
rc.columns = @rc_columns
@patch.apply_row(rc)
end
hist.clear
pending = n
@patch.apply_row(hits[k])
hits.delete(k)
skipped = false
noted = true
elsif tag == 1
# ignore redundant row
elsif pending>0
emit_skip(row) if skipped
cells = row.map{|v| { :txt => v, :value => v, :cell_mode => "" }}
rc = RowChange.new("",cells)
rc.columns = @rc_columns
@patch.apply_row(rc)
pending = pending-1
skipped = false
else
hist << row
if hist.length>n
skipped = true
last_row = row
hist.shift
end
end
end
emit_skip(last_row) if skipped and noted
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_context; end",
"def ensure_clean_context!\n return unless configuration[:tracer].call_context.current_span\n configuration[:tracer].provider.context = Context.new\n end",
"def ensure_clean_context!\n return unless configuration[:tracer].call_context.curren... | [
"0.7239195",
"0.7080514",
"0.7080514",
"0.6959988",
"0.6939338",
"0.6895339",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0... | 0.0 | -1 |
copy the structure of an attached table, along with any indexes | def copy_table_structure(rdb,tbl)
template = "SELECT sql, type from X.sqlite_master WHERE tbl_name = ? ORDER BY type DESC"
lsql = template.gsub('X',"main")
rsql = template.gsub('X',quote_with_dots(rdb))
args = [quote_with_dots(tbl)]
lschema = sqlite_execute(lsql,args)
rschema = sqlite_execute(rsql,args)
if lschema.length>0
return false
end
rschema.each{ |row| sqlite_execute(row[0],[]) }
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_structure\n logger.info \"Copying structure for table #{name} from watched to audit database\"\n db.query(\"CREATE TABLE #{audit} LIKE #{watched}\")\n add_copied_at_field\n add_has_delta_field\n add_last_version_field\n add_has_violation_field\n add_deletion_flag\n en... | [
"0.71946454",
"0.6521952",
"0.649078",
"0.6262572",
"0.62434936",
"0.61201864",
"0.61195266",
"0.603655",
"0.6017377",
"0.59772307",
"0.5921113",
"0.59018046",
"0.5887744",
"0.5873437",
"0.5843929",
"0.5838268",
"0.5811328",
"0.5796456",
"0.5782667",
"0.5771281",
"0.56829625"... | 0.6626185 | 3 |
We are not implementing full comparison, just an adequate subset for easy cases (a table with a trustworthy primary key, and constant columns). Make sure we are not trying to do something we're not ready for. | def validate_schema
all_cols1 = @db1.column_names(@table1)
all_cols2 = @db2.column_names(@table2)
if all_cols1 != all_cols2
raise "Columns do not match, please use full coopy toolbox"
end
key_cols1 = @db1.primary_key(@table1)
key_cols2 = @db2.primary_key(@table2)
if key_cols1 != key_cols2
raise "Primary keys do not match, please use full coopy toolbox"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def natural_key_equality_for_row(row)\n statement = []\n values = []\n natural_key.each do |nk|\n statement << \"#{nk} = ?\"\n values << row[nk]\n end\n statement = statement.join(\" AND \")\n ActiveRecord::Base.send(:sanitize_sql, [statement, *values])\n... | [
"0.64757264",
"0.6157762",
"0.60876185",
"0.57649916",
"0.5756951",
"0.5748112",
"0.57109255",
"0.57028127",
"0.5689319",
"0.56701475",
"0.56457174",
"0.55566436",
"0.55522656",
"0.555172",
"0.5522209",
"0.54885685",
"0.5466421",
"0.540768",
"0.5402286",
"0.53932357",
"0.5376... | 0.59363675 | 5 |
When working within a single database, we can delegate more work to SQL. So we specialize this case. | def apply_single
validate_schema
# Prepare some lists of columns.
key_cols = @db1.primary_key(@table1)
data_cols = @db1.except_primary_key(@table1)
all_cols = @db1.column_names(@table1)
# Let our public know we are beginning.
@patch.begin_diff
# Advertise column names.
@rc_columns = DiffColumns.new
@rc_columns.title_row = all_cols
@rc_columns.update(0)
cells = all_cols.map{|v| { :txt => v, :value => v, :cell_mode => "" }}
rc = RowChange.new("@@",cells)
@patch.apply_row(rc)
# If requested, we will be providing context rows around changed rows.
# This is not a natural thing to do with SQL, so we do it only on request.
# When requested, we need to buffer row changes.
@pending_rcs = []
# Prepare some useful SQL fragments to assemble later.
sql_table1 = @db1.quote_table(@table1)
sql_table2 = @db1.quote_table(@table2)
sql_key_cols = key_cols.map{|c| @db1.quote_column(c)}.join(",")
sql_all_cols = all_cols.map{|c| @db1.quote_column(c)}.join(",")
sql_key_match = key_cols.map{|c| @db1.quote_column(c)}.map{|c| "#{sql_table1}.#{c} IS #{sql_table2}.#{c}"}.join(" AND ")
sql_data_mismatch = data_cols.map{|c| @db1.quote_column(c)}.map{|c| "#{sql_table1}.#{c} IS NOT #{sql_table2}.#{c}"}.join(" OR ")
# For one query we will need to interleave columns from two tables. For
# portability we need to give these columns distinct names.
weave = all_cols.map{|c| [[sql_table1,@db1.quote_column(c)],
[sql_table2,@db2.quote_column(c)]]}.flatten(1)
dbl_cols = weave.map{|c| "#{c[0]}.#{c[1]}"}
sql_dbl_cols = weave.map{|c| "#{c[0]}.#{c[1]} AS #{c[0].gsub(/[^a-zA-Z0-9]/,'_')}_#{c[1].gsub(/[^a-zA-Z0-9]/,'_')}"}.join(",")
# Prepare a map of primary key offsets.
keys_in_all_cols = key_cols.each.map{|c| all_cols.index(c)}
keys_in_dbl_cols = keys_in_all_cols.map{|x| 2*x}
# Find rows in table2 that are not in table1.
sql = "SELECT #{sql_all_cols} FROM #{sql_table2} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table1} WHERE #{sql_key_match})"
apply_inserts(sql,all_cols,keys_in_all_cols)
# Find rows in table1 and table2 that differ while having the same primary
# key.
sql = "SELECT #{sql_dbl_cols} FROM #{sql_table1} INNER JOIN #{sql_table2} ON #{sql_key_match} WHERE #{sql_data_mismatch}"
apply_updates(sql,dbl_cols,keys_in_dbl_cols)
# Find rows that are in table1 but not table2
sql = "SELECT #{sql_all_cols} FROM #{sql_table1} WHERE NOT EXISTS (SELECT 1 FROM #{sql_table2} WHERE #{sql_key_match})"
apply_deletes(sql,all_cols,keys_in_all_cols)
# If we are supposed to provide context, we need to deal with row order.
if @patch.want_context
sql = "SELECT #{sql_all_cols}, 0 AS __coopy_tag__ FROM #{sql_table1} UNION SELECT #{sql_all_cols}, 1 AS __coopy_tag__ FROM #{sql_table2} ORDER BY #{sql_key_cols}, __coopy_tag__"
apply_with_context(sql,all_cols,keys_in_all_cols)
end
# Done!
@patch.end_diff
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sql_modes; end",
"def select(db); end",
"def select(db); end",
"def target_sql_mode=(_arg0); end",
"def subscribe_sql_active_record; end",
"def execute sql\n db[sql]\n end",
"def orm; end",
"def execute(sql)\n raise NotImplementedError, \"#execute should be overridden by adapters\"\n... | [
"0.67429376",
"0.66871613",
"0.66871613",
"0.6553068",
"0.6479085",
"0.639683",
"0.6382744",
"0.6317526",
"0.62225294",
"0.61815304",
"0.61454505",
"0.6135748",
"0.6120637",
"0.61160046",
"0.6085051",
"0.6072461",
"0.60159373",
"0.60036105",
"0.60010076",
"0.59938884",
"0.598... | 0.0 | -1 |
Do the context dance. | def apply_with_context(sql,all_cols,keys_in_all_cols)
hits = {}
@pending_rcs.each do |rc|
hits[rc.key] = rc
end
hist = []
n = 2
pending = 0
skipped = false
noted = false
last_row = nil
@db1.fetch(sql,all_cols + ["__coopy_tag__"]) do |row|
tag = row.pop.to_i
k = keyify(row.values_at(*keys_in_all_cols))
if hits[k]
emit_skip(row) if skipped
hist.each do |row0|
cells = row0.map{|v| { :txt => v, :value => v, :cell_mode => "" }}
rc = RowChange.new("",cells)
rc.columns = @rc_columns
@patch.apply_row(rc)
end
hist.clear
pending = n
@patch.apply_row(hits[k])
hits.delete(k)
skipped = false
noted = true
elsif tag == 1
# ignore redundant row
elsif pending>0
emit_skip(row) if skipped
cells = row.map{|v| { :txt => v, :value => v, :cell_mode => "" }}
rc = RowChange.new("",cells)
rc.columns = @rc_columns
@patch.apply_row(rc)
pending = pending-1
skipped = false
else
hist << row
if hist.length>n
skipped = true
last_row = row
hist.shift
end
end
end
emit_skip(last_row) if skipped and noted
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_context; end",
"def ensure_clean_context!\n return unless configuration[:tracer].call_context.current_span\n configuration[:tracer].provider.context = Context.new\n end",
"def ensure_clean_context!\n return unless configuration[:tracer].call_context.curren... | [
"0.7239195",
"0.7080514",
"0.7080514",
"0.6959988",
"0.6939338",
"0.6895339",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0.68459934",
"0... | 0.0 | -1 |
copy the structure of an attached table, along with any indexes | def copy_table_structure(rdb,tbl)
template = "SELECT sql, type from X.sqlite_master WHERE tbl_name = ? ORDER BY type DESC"
lsql = template.gsub('X',"main")
rsql = template.gsub('X',quote_with_dots(rdb))
args = [quote_with_dots(tbl)]
lschema = sqlite_execute(lsql,args)
rschema = sqlite_execute(rsql,args)
if lschema.length>0
return false
end
rschema.each{ |row| sqlite_execute(row[0],[]) }
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_structure\n logger.info \"Copying structure for table #{name} from watched to audit database\"\n db.query(\"CREATE TABLE #{audit} LIKE #{watched}\")\n add_copied_at_field\n add_has_delta_field\n add_last_version_field\n add_has_violation_field\n add_deletion_flag\n en... | [
"0.71946454",
"0.6521952",
"0.649078",
"0.6262572",
"0.62434936",
"0.61201864",
"0.61195266",
"0.603655",
"0.6017377",
"0.59772307",
"0.5921113",
"0.59018046",
"0.5887744",
"0.5873437",
"0.5843929",
"0.5838268",
"0.5811328",
"0.5796456",
"0.5782667",
"0.5771281",
"0.56829625"... | 0.6626185 | 1 |
Never trust parameters from the scary internet, only allow the white list through. | def level_source_params
params.require(:level_source).permit(:hidden)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Default method, subclasses must override this | def run
super
begin
# Make sure the key is set
api_key = _get_task_config "whoisology_api_key"
entity_name = _get_entity_name
case _get_entity_type_string
when "EmailAddress"
entity_type = "email"
when "DnsRecord"
## When we have a host, we need to do a lookup on the current record,
## grab the email address, and then do the search based on that email
_log "Looking up contacts for domain"
begin
# We're going to pull the domain's email address....
whois = ::Whois::Client.new(:timeout => 20)
answer = whois.lookup(entity_name)
# Run through the contacts and pick the first one
contact_emails = answer.parser.contacts.map{ |contact| contact.email }
_log "Got contact_emails: #{contact_emails}"
rescue Timeout::Error => e
_log_error "Unable to lookup #{entity_name}... try a manual lookup"
return nil
end
entity_name = contact_emails.first
entity_type = "email"
end
_log "Got entity: #{entity_type} #{entity_name}"
unless entity_name
# Something went wrong with the lookup?
_log "Unable to get a current email address"
return
end
unless api_key
_log_error "No api_key?"
return
end
# Attach to the whoisology service & search
whoisology = Whoisology::Api.new(api_key)
# Run a PING to see if we have any results
result = whoisology.ping entity_type, entity_name
_log "Got #{result}"
_log "Got #{result["count"]} results"
return if result["count"].to_i == 0
# do the actual search with the FLAT command
result = whoisology.flat entity_type, entity_name
_log_good "Creating entities for #{result["count"]} results."
if result["domains"]
result["domains"].each {|d| _create_entity "DnsRecord", {"name" => d["domain_name"]} }
else
_log_error "No domains, do we have API credits?"
end
rescue RuntimeError => e
_log_error "Runtime error: #{e.inspect}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overrides; end",
"def custom; end",
"def custom; end",
"def default; end",
"def default; end",
"def private; end",
"def special\n override\n end",
"def defaults\n super\n end",
"def implementation; end",
"def implementation; end",
"def default\n end",
"def defaults; end",
... | [
"0.7415348",
"0.73554313",
"0.73554313",
"0.6991004",
"0.6991004",
"0.69613177",
"0.69572926",
"0.6824949",
"0.6801543",
"0.6801543",
"0.67361915",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0.66934764",
"0... | 0.0 | -1 |
GET /qualificacaos GET /qualificacaos.json | def index
@qualificacaos = Qualificacao.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def index\n @qualifications = Qualification.all\n\n respond_to do |format|\n format.html # inde... | [
"0.67964506",
"0.6738028",
"0.6512611",
"0.6447033",
"0.6358366",
"0.62296844",
"0.6209755",
"0.61903524",
"0.61224204",
"0.6102071",
"0.6100322",
"0.5987769",
"0.5907986",
"0.58968383",
"0.58945644",
"0.58945644",
"0.58945644",
"0.5893211",
"0.5890619",
"0.5883403",
"0.58788... | 0.70743996 | 0 |
GET /qualificacaos/1 GET /qualificacaos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def index\n @qualificacaos = Qualificacao.all\n end",
"def show\n @qualification = Qualification.... | [
"0.7108381",
"0.68158144",
"0.67043203",
"0.6594064",
"0.6588705",
"0.6443188",
"0.64308524",
"0.63515776",
"0.6336245",
"0.6336245",
"0.6336245",
"0.6287738",
"0.6221737",
"0.622139",
"0.6220447",
"0.6218888",
"0.621527",
"0.6159071",
"0.61559033",
"0.6152497",
"0.6144989",
... | 0.0 | -1 |
POST /qualificacaos POST /qualificacaos.json | def create
@qualificacao = Qualificacao.new(qualificacao_params)
respond_to do |format|
if @qualificacao.save
format.html { redirect_to @qualificacao, notice: 'Qualificacao do usuario inserida com sucesso.' }
format.json { render action: 'show', status: :created, location: @qualificacao }
else
format.html { render action: 'new' }
format.json { render json: @qualificacao.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @agronomiaquimica = Agronomiaquimica.new(params[:agronomiaquimica])\n\n respond_to do |format|\n if @agronomiaquimica.save\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully created.' }\n format.json { render json: @agronomiaquimica, stat... | [
"0.65041965",
"0.63399464",
"0.60086656",
"0.59358895",
"0.5861501",
"0.5857845",
"0.5800656",
"0.5767114",
"0.57096314",
"0.56988186",
"0.5692759",
"0.5676298",
"0.56729305",
"0.5670811",
"0.5663104",
"0.56480855",
"0.5642775",
"0.56228435",
"0.56213087",
"0.56063557",
"0.55... | 0.6558367 | 0 |
PATCH/PUT /qualificacaos/1 PATCH/PUT /qualificacaos/1.json | def update
respond_to do |format|
if @qualificacao.update(qualificacao_params)
format.html { redirect_to @qualificacao, notice: 'Qualificacao do usuario foi alterada.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @qualificacao.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n if @agronomiaquimica.update_attributes(params[:agronomiaquimica])\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully updated.' }\n format.json { head :no_... | [
"0.6357459",
"0.61339337",
"0.6128393",
"0.6114372",
"0.6095782",
"0.60812825",
"0.6046132",
"0.60344887",
"0.6030758",
"0.60291153",
"0.60221165",
"0.60170674",
"0.6006959",
"0.5989634",
"0.5989413",
"0.59760475",
"0.5960813",
"0.5955778",
"0.5954404",
"0.59295493",
"0.59256... | 0.6669854 | 0 |
DELETE /qualificacaos/1 DELETE /qualificacaos/1.json | def destroy
@qualificacao.destroy
respond_to do |format|
format.html { redirect_to qualificacaos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aquarium = Aquarium.find(params[:id])\n @aq... | [
"0.7294669",
"0.70631087",
"0.6908474",
"0.68684924",
"0.68511826",
"0.6840599",
"0.68323153",
"0.6802773",
"0.67514986",
"0.67437273",
"0.672184",
"0.6713656",
"0.67126524",
"0.66756076",
"0.66756076",
"0.66756076",
"0.6651624",
"0.66503733",
"0.66496307",
"0.66496307",
"0.6... | 0.73244554 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_qualificacao
@qualificacao = Qualificacao.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def qualificacao_params
params.require(:qualificacao).permit(:linguagem, :nivelConhecimento, :user_id, :os, :ide, :repositorio, :database, :outros)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Add the current treated data to the returnhash. | def finish_data
if @headers.empty? and @data_written == 0
@data.close(true) if @data.is_a?(Tempfile)
self.reset_data
return nil
end
if @data.is_a?(Tempfile)
@data.close(false)
@files_arr << @data.path if @data.respond_to?(:path)
end
raise "No 'content-disposition' was given (#{@headers}) (#{@data})." if !@name
if @fname
obj = Hayabusa::Http_session::Post_multipart::File_upload.new(
:fname => @fname,
:headers => @headers,
:data => @data
)
@return[@name] = obj
else
@return[@name] = @data
end
self.reset_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(hash); end",
"def with_tag_data( newhash={} )\n\t\traise LocalJumpError, \"no block given\" unless block_given?\n\t\t# self.log.debug \"Overriding tag state with: %p\" % [ newhash ]\n\n\t\tbegin\n\t\t\t@tag_data.push( @tag_data.last.merge(newhash) )\n\t\t\tyield( self )\n\t\tensure\n\t\t\t@tag_data.pop\n... | [
"0.5760121",
"0.536029",
"0.5277278",
"0.52416927",
"0.5180361",
"0.51120675",
"0.51039386",
"0.49847582",
"0.49631566",
"0.49586588",
"0.4951397",
"0.49393868",
"0.49282467",
"0.49265227",
"0.4922339",
"0.48968107",
"0.4877081",
"0.48595008",
"0.4848705",
"0.484756",
"0.4839... | 0.0 | -1 |
Returns the size of the upload. | def size
return @args[:data].length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_size\n stream.size\n end",
"def size\n file.content_length\n end",
"def size\n file.size\n end",
"def size\n @size ||= @request[FSIZE].to_i\n end",
"def size\n instance_read(:file_size) || (@queued_for_write[:original] && @queued_for_write[:... | [
"0.8168387",
"0.8144016",
"0.80696195",
"0.7972265",
"0.79640466",
"0.79062545",
"0.7868697",
"0.7847698",
"0.7838841",
"0.7782856",
"0.7765132",
"0.7752734",
"0.77455145",
"0.7706746",
"0.76542646",
"0.7648872",
"0.7613663",
"0.76009375",
"0.756575",
"0.7546556",
"0.7546556"... | 0.0 | -1 |
Returns the size of the fileupload. | def length
return @args[:data].length
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_size\n stream.size\n end",
"def size\n file.content_length\n end",
"def size\n file.size\n end",
"def file_size\n self.file_file_size\n end",
"def size\n file.try(:size) || 0\n end",
"def getFileSize\r\n\t\t\t\t\treturn @fileSize\r\n\t\t\t\... | [
"0.8319753",
"0.8273982",
"0.826391",
"0.82453287",
"0.8101127",
"0.80924124",
"0.8058012",
"0.8007431",
"0.79977775",
"0.798315",
"0.7945206",
"0.7848654",
"0.77709943",
"0.77566016",
"0.7731035",
"0.76794165",
"0.7662525",
"0.7662525",
"0.76520514",
"0.76520514",
"0.7652051... | 0.0 | -1 |
Returns the filename given for the fileupload. | def filename
return @args[:fname]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_name\n uploaded_file_file_name\n end",
"def filename\n @file.basename.to_s\n end",
"def filename\n unless @filename\n @filename = @path.basename.to_s\n end\n\n @filename\n end",
"def get_filename (file)\n\t\tif file.is_a? File\n\t\t\tfile = file.path\n\t\... | [
"0.8200251",
"0.8038789",
"0.76697916",
"0.7667224",
"0.7640703",
"0.76286215",
"0.76286215",
"0.7586155",
"0.75448143",
"0.75386155",
"0.74979734",
"0.74884397",
"0.74819523",
"0.74819523",
"0.7397479",
"0.7395923",
"0.73889565",
"0.7378872",
"0.7378487",
"0.73413944",
"0.73... | 0.0 | -1 |
Returns the headers given for the fileupload. Type and more should be here. | def headers
return @args[:headers]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def headers_for_direct_upload(key, filename:, content_type:, content_length:, checksum:, custom_metadata: {})\n {}\n end",
"def headers_for_direct_upload(key, filename:, content_type:, content_length:, checksum:)\n {}\n end",
"def headers_for_direct_upload(key, filename:, content_type:, con... | [
"0.7307857",
"0.7202337",
"0.71900356",
"0.7065862",
"0.70582557",
"0.70490116",
"0.69843185",
"0.68891174",
"0.6826668",
"0.68241256",
"0.68241256",
"0.6803842",
"0.680217",
"0.68017644",
"0.67767096",
"0.67605263",
"0.67516005",
"0.67516005",
"0.67516005",
"0.67516005",
"0.... | 0.65798366 | 42 |
Returns the content of the fileupload as a string. | def to_s
if @args[:data].is_a?(StringIO)
return @args[:data].string
else
return File.read(@args[:data].path)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contents\n file_upload.read\n end",
"def to_s\n @file_text\n end",
"def to_s\n @file_text\n end",
"def to_s\n @file.to_s\n end",
"def uploaded_data\n return \"\"\n end",
"def get_upload_text(upload)\n render_to_string( :partial => 'uploads/upload_row', :object => up... | [
"0.80602777",
"0.76047945",
"0.76047945",
"0.7153963",
"0.7032397",
"0.68382776",
"0.6801023",
"0.676932",
"0.67643535",
"0.66840863",
"0.6671161",
"0.6658976",
"0.6658976",
"0.6590017",
"0.65334284",
"0.65334284",
"0.65250576",
"0.65234905",
"0.6497452",
"0.6480756",
"0.6466... | 0.5920975 | 72 |
Returns an IO to read from the upload wherever it is a temporary file or a string. | def io(&blk)
if @args[:data].is_a?(StringIO)
return @args[:data]
else
return File.open(@args[:data].path, "r", &blk)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read\n File.read(uploaded.path)\n end",
"def get\n uploaded_file(read) if read\n end",
"def io\n @io ||= StringIO.new(blob, 'r+b')\n end",
"def contents\n file_upload.read\n end",
"def quick_read (io_or_path, mode='r')\n\t\t\t\trdr = Reader.new(io_or_path, mo... | [
"0.6598324",
"0.6542418",
"0.65022403",
"0.63857",
"0.6385136",
"0.6334926",
"0.6334926",
"0.6328226",
"0.6286692",
"0.62703836",
"0.6109236",
"0.60921514",
"0.60751414",
"0.60533786",
"0.60054463",
"0.597558",
"0.5975288",
"0.59540904",
"0.5947979",
"0.5910459",
"0.5909535",... | 0.6657207 | 0 |
Saves the content of the fileupload to a given path. | def save_to(filepath)
File.open(filepath, "w") do |fp|
if @args[:data].is_a?(StringIO)
fp.write(@args[:data].string)
else
#Stream output to avoid using too much memory.
self.io do |fp_read|
fp_read.lines do |line|
fp.write(line)
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n repository.create_contents(path, \"Upload #{path}\", content)\n end",
"def save_to_file(path = nil)\n content\n file = Store::File.find_by(id: store_file_id)\n if !file\n raise \"No such file #{store_file_id}!\"\n end\n\n if !path\n path = Rails.root.join('tmp', filename)\... | [
"0.766105",
"0.72579885",
"0.7083797",
"0.70508045",
"0.6943637",
"0.6907325",
"0.69006",
"0.6894708",
"0.6852768",
"0.6827155",
"0.6741398",
"0.67412335",
"0.6714693",
"0.6696737",
"0.65873384",
"0.6539384",
"0.653397",
"0.65001154",
"0.6452476",
"0.64441544",
"0.64272237",
... | 0.0 | -1 |
This methods prevents the object from being converted to JSON. This can make some serious bugs. | def to_json(*args)
raise "File_upload-objects should not be converted to json."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_unprocessable_entity(obj)\n render json: nil_protection(obj), status: :unprocessable_entity\n end",
"def serialize(object)\n raise_or_return(object)\n end",
"def plain_old_ruby_object\n\t\treturn false\n\tend",
"def to_json_raw_object()\n #This is a stub,... | [
"0.68479323",
"0.67439705",
"0.6558231",
"0.65239286",
"0.6467689",
"0.6467689",
"0.6412639",
"0.63742936",
"0.6314382",
"0.6307977",
"0.6307977",
"0.62278944",
"0.62178653",
"0.62146795",
"0.61910474",
"0.61475927",
"0.61421704",
"0.60493624",
"0.6036243",
"0.60036755",
"0.5... | 0.57966626 | 33 |
setup a payment and get a payment_url to redirect to required keys: :amount, :bank_id, :returnurl, :reporturl optional keys: :profile_key, :description | def setup_payment(options = {})
raise ArgumentError.new("Amount should be at least 1,80EUR") if options[:amount] && options[:amount] < 180
response = Hashie::Mash.new(self.class.get('',
:query => merge_options!(options.merge(:a => 'fetch')),
:format => :xml
)).response
if response.order
return response.order
else
raise MollieException.new(response.item.code, response.item.message, response.item.type)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payment\n mp_payment = @order.current_payment\n\n if mp_payment.source.nil? or mp_payment.source.redirect_url.nil?\n response = create_preferences mp_payment\n if response\n point_key = provider.sandbox ? 'sandbox_init_point' : 'init_point'\n redirect_url =... | [
"0.7280635",
"0.7031158",
"0.68987125",
"0.6836107",
"0.67529243",
"0.6739036",
"0.67204523",
"0.67163765",
"0.66435367",
"0.66417205",
"0.66042924",
"0.65950805",
"0.65539306",
"0.6547286",
"0.65294415",
"0.64866793",
"0.6451857",
"0.6450336",
"0.64471674",
"0.6437373",
"0.6... | 0.0 | -1 |
merge options in query | def merge_options!(hash)
hash.merge!(@options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combined_options(options)\n resp = @options\n resp[:query].merge! options\n resp\n end",
"def merge_query_options(opts)\n # return nil if opts is empty, else concat\n opts.blank? ? nil : '?' + opts.to_a.map {|k,v| \"#{k}=#{v}\"}.join(\"&\")\n end",
"def merge_finder_options_with_or... | [
"0.70871425",
"0.69309396",
"0.67783904",
"0.67725545",
"0.67642385",
"0.6740885",
"0.672127",
"0.67057383",
"0.66013265",
"0.6562798",
"0.6503298",
"0.64749706",
"0.6448734",
"0.64072394",
"0.6405352",
"0.6391919",
"0.6389244",
"0.63571995",
"0.63543844",
"0.62992525",
"0.62... | 0.57842505 | 39 |
Function for attempting the directory traversal | def get_file_function(file_path, opts = {})
begin
res = send_request_cgi(
{
'uri' => normalize_uri("/cgi-bin/login.cgi?lang=en&src=../../../../../../../../../../../../../../../../../../../..", file_path),
'method' => 'GET',
'ssl' => true,
'port' => rport
}
)
return res
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
print_error("#{rhost}:#{rport} - HTTP(S) Connection Failed...")
return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walk(path); end",
"def GetLevelDirs()\n directories = Dir.entries($level_folder)\n\n for i in 0...directories.length do\n\n if not directories[i].include? \".\" then\n $current_folder = $level_folder + directories[i] + \"/\"\n GetLevels($current_folder)\n end\n\n ... | [
"0.6530004",
"0.64903957",
"0.6440895",
"0.6412013",
"0.63738793",
"0.63177806",
"0.6313209",
"0.6301021",
"0.62467206",
"0.62364155",
"0.6227754",
"0.6197874",
"0.6185322",
"0.61298513",
"0.6098968",
"0.6096509",
"0.6083015",
"0.6068683",
"0.60595155",
"0.6026309",
"0.602630... | 0.0 | -1 |
GET /galleries GET /galleries.xml | def index
@galleries = Gallery.find_all_by_private(:false)
@galleries.sort! { |a,b| b.created_at<=>a.created_at }
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @galleries }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @galleries = Gallery.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @galleries }\n end\n end",
"def show\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xm... | [
"0.7454129",
"0.7192484",
"0.7142821",
"0.7142821",
"0.6867545",
"0.6867545",
"0.6867545",
"0.68627447",
"0.68283397",
"0.6824072",
"0.6799042",
"0.67812353",
"0.67600805",
"0.6752206",
"0.6742076",
"0.6706764",
"0.6704053",
"0.66906863",
"0.66906863",
"0.66906863",
"0.669068... | 0.0 | -1 |
GET /galleries/1 GET /galleries/1.xml | def show
@gallery = Gallery.find(params[:id])
@pictures = Picture.find_all_by_gallery_id(@gallery.id)
# Set the title
@title = @gallery.title
render :action => 'show', :layout => @gallery.layout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @galleries = Gallery.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @galleries }\n end\n end",
"def show\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xm... | [
"0.74621606",
"0.7345072",
"0.7302853",
"0.7302853",
"0.6878787",
"0.67584044",
"0.67584044",
"0.67309666",
"0.6711974",
"0.67047167",
"0.6703387",
"0.6701945",
"0.6693566",
"0.6693566",
"0.6693566",
"0.6689444",
"0.668834",
"0.6627411",
"0.66259325",
"0.6601045",
"0.65934575... | 0.5927482 | 79 |
GET /galleries/new GET /galleries/new.xml | def new
@gallery = Gallery.new
# The current logged in user will be creating this gallery
@gallery.user_id = current_user.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery }\n end\n end",
"def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @gallery }\... | [
"0.7850063",
"0.7850063",
"0.7507494",
"0.7480553",
"0.7467785",
"0.7388278",
"0.7202182",
"0.7202182",
"0.7139021",
"0.71374816",
"0.7132775",
"0.7091671",
"0.7091671",
"0.7091671",
"0.70434976",
"0.69186074",
"0.691163",
"0.69035983",
"0.68803453",
"0.6878531",
"0.6866058",... | 0.0 | -1 |
POST /galleries POST /galleries.xml | def create
@gallery = Gallery.new(params[:gallery])
respond_to do |format|
if @gallery.save
flash[:notice] = 'Gallery was successfully created.'
format.html { redirect_to(@gallery) }
format.xml { render :xml => @gallery, :status => :created, :location => @gallery }
else
format.html { render :action => "new" }
format.xml { render :xml => @gallery.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @gallery = Gallery.new(params[:gallery])\n\n respond_to do |format|\n if @gallery.save\n flash[:notice] = 'Gallery was successfully created.'\n format.html { redirect_to(admin_galleries_url) }\n format.xml { render :xml => @gallery, :status => :created, :location => @g... | [
"0.6737928",
"0.6572633",
"0.64290684",
"0.63641024",
"0.62585336",
"0.6220852",
"0.62147677",
"0.62147677",
"0.62072307",
"0.6200849",
"0.6187273",
"0.61539465",
"0.6132204",
"0.61271536",
"0.6053597",
"0.6011275",
"0.6009392",
"0.5989799",
"0.5961309",
"0.5951852",
"0.59518... | 0.660411 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.