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 |
|---|---|---|---|---|---|---|
Simple equivalence test for REXML | def equivalent_rexml(other)
begin
require 'active_support'
require 'active_support/core_ext'
rescue LoadError
# string equivalence
end
if Hash.respond_to?(:from_xml)
Hash.from_xml("<root>#{self}</root>") == Hash.from_xml("<root>#{other}</root>")
else
# Poor mans equivalent
value == other.value
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml_should_eql(actual, expected)\n same = xml_cmp(actual, expected)\n actual.should.== expected unless same \nend",
"def xml_compare a, b\n a = REXML::Document.new(a.to_s)\n b = REXML::Document.new(b.to_s)\n\n normalized = Class.new(REXML::Formatters::Pretty) do\n def write_text(node, output... | [
"0.71979046",
"0.70567",
"0.70154643",
"0.69066465",
"0.6902816",
"0.688589",
"0.6804099",
"0.6660397",
"0.6615836",
"0.6555921",
"0.65196425",
"0.636508",
"0.63044393",
"0.62656343",
"0.6247824",
"0.62137634",
"0.6153384",
"0.5979433",
"0.59192795",
"0.5901599",
"0.5901475",... | 0.72662044 | 0 |
output: a series of strings such that they form a right triangle of stars, each side equal inout integer Rules: right justified triangle hypotenuse starts on bottom left and ends on upper right Data Structures: strings Algorithm set counter to 1 begin a loop print (' ' stringlength counter) + ('' counter) increment counter by 1 end loop when counter equals integer | def triangle(integer)
stars = 1
integer.times do
puts " " * (integer - stars) + ("*" * stars)
stars += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triangle(length_of_sides)\n spaces = length_of_sides\n accum_num = 1\n length_of_sides.times do\n puts \"#{' ' * (spaces - accum_num)}#{'*' * accum_num}\"\n accum_num += 1\n end\nend",
"def triangle(integer)\n counter = 0\n until counter > integer\n puts ('*' * counter).rjust(integer)\n cou... | [
"0.74768376",
"0.74747294",
"0.74675643",
"0.74605733",
"0.73616916",
"0.7322541",
"0.7318031",
"0.726027",
"0.7247343",
"0.7150364",
"0.7062362",
"0.7028297",
"0.69837177",
"0.6948676",
"0.68628955",
"0.6858543",
"0.68412024",
"0.68130696",
"0.67976534",
"0.67894334",
"0.678... | 0.70631015 | 10 |
definition d'une methode qui affichera vraie si le nombre 42 existe dans un tableau | def array_42(a)
a.any?{|x| x == 42}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def existent; end",
"def exists?; end",
"def exist?(key)\n raise \"subclass responsibility\"\n end",
"def exist?\n raise NotImplementedError\n end",
"def exist\n\treturn true\n end",
"def existeYa(tabla, id)\r\n\tif tabla.empty?\r\n\t\treturn false\r\n\telse\r\n\t\treturn tabla.has_key?(id... | [
"0.66568416",
"0.6376432",
"0.5918515",
"0.590987",
"0.583833",
"0.58084697",
"0.5792848",
"0.5790661",
"0.57838273",
"0.5777358",
"0.57430226",
"0.57430226",
"0.5725476",
"0.57026935",
"0.5675756",
"0.56644624",
"0.56421083",
"0.5632461",
"0.56090045",
"0.5591018",
"0.559101... | 0.0 | -1 |
1. use two pointers 2. find the index where both array has same the element 3. iterate arrays until two elements are different 4. if different, return false, othwerwise return true | def is_rotation(a, b)
# 1) use two pointers
ptr_a = 0
ptr_b = 0
# 2) find the index where both array has same the element
while ptr_b < b.length
break if a[ptr_a] == b[ptr_b]
ptr_b += 1
end
# 3) iterate arrays until two elements are different
a.each do |num|
# 4) if different, return false
return false if num != b[ptr_b]
ptr_b = (ptr_b + 1) % b.length
end
# othwerwise return true
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_equals(array1, array2)\n #if the arrays are different lengths, will return false\n if array1.length != array2.length\n return false\n end\n\n # compares each element of array, starting at index[0]\n # if they are not equivalent at any point, then it will return false\n # else it will return true... | [
"0.7975948",
"0.7801589",
"0.77483207",
"0.7737447",
"0.7716095",
"0.7706585",
"0.7691893",
"0.7682293",
"0.7671912",
"0.76610506",
"0.76453143",
"0.7636368",
"0.76261395",
"0.7590233",
"0.7588021",
"0.7557551",
"0.7545909",
"0.75346357",
"0.7530717",
"0.7524936",
"0.75050384... | 0.72528565 | 45 |
Affiche en console la liste des instances | def show_list
clear
puts "= LISTE DES INSTANCES #{name} =".bleu
puts "\n\n"
len_delim = defined?(LIST_ENTETE) ? LIST_ENTETE.length + 2 : 80
delim = ("-"*len_delim).bleu
if defined?(LIST_ENTETE)
puts delim
puts LIST_ENTETE
end
puts delim
all.each do |inst|
puts " #{inst.to_console}"
end
puts delim
puts "\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_of_instances\n super\n end",
"def instances; end",
"def instances; end",
"def instances\n end",
"def print_instances_details(only_running=true)\n @groups.values.each_with_index do |instances, i|\n instances.each do |instance|\n if only_running and (not instance.ready?... | [
"0.7148263",
"0.691316",
"0.691316",
"0.68694407",
"0.68495244",
"0.68187",
"0.67520285",
"0.6622422",
"0.64641416",
"0.6419328",
"0.6419328",
"0.6409997",
"0.63860893",
"0.6375767",
"0.6326579",
"0.62862766",
"0.62723833",
"0.6269662",
"0.6263259",
"0.6246511",
"0.6237165",
... | 0.7773426 | 0 |
If the config is the same an environment we can truncate some values production_production is superflous in ids and such | def default_config?
configuration == environment
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_config(untrasted_config)\n untrasted_config.each do |env, config|\n raise MissingConfiguration, \"CassandraModel config is broken, a '#{ENV['RACK_ENV']}' missing 'server' option\" \\\n unless config.keys.include?('server')\n server = config['server']\n\n if server.is... | [
"0.5722308",
"0.55099183",
"0.5409661",
"0.5357589",
"0.53163356",
"0.52056587",
"0.519796",
"0.51763976",
"0.51717883",
"0.50990146",
"0.50011265",
"0.4983575",
"0.48793823",
"0.48767668",
"0.48736015",
"0.48455107",
"0.4841766",
"0.4820523",
"0.48196575",
"0.48183587",
"0.4... | 0.0 | -1 |
A unique id for resources for this node | def resource_id(prefix)
if default_config?
[prefix, project, node_type, node_name]
else
[prefix, project, configuration, node_type, node_name]
end.compact.join("_").tr("-", '_').tr("/", "_")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def physical_resource_id\n \"#{self.class.name.split('::').last}-#{Carnivore.uuid}\"\n end",
"def resource_id\n return \"%s:%s\" % [self.resource_type, self.id]\n end",
"def node_id\n jid.resource\n end",
"def resource_id\n send self.class.resource_id\n end",
... | [
"0.77508366",
"0.7495844",
"0.7364517",
"0.7327797",
"0.7320755",
"0.70693046",
"0.70303994",
"0.7025603",
"0.7025603",
"0.7025603",
"0.70252043",
"0.70105344",
"0.69328177",
"0.68627316",
"0.68627316",
"0.672992",
"0.672992",
"0.6709207",
"0.67071104",
"0.67071104",
"0.67071... | 0.70646626 | 7 |
TO BE IMPLEMENTED BY NODE_TYPES defines the preconditions and defaults fo use of this node | def json_schema
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required_defaults; end",
"def node_type; end",
"def node_type; end",
"def initialize_node(options={})\n raise NotImplementedError\n end",
"def preconditions\n raise NotImplemented\n end",
"def node=(_arg0); end",
"def init_node\n end",
"def init_node\n end",
"def initi... | [
"0.6294588",
"0.6159703",
"0.6159703",
"0.60481805",
"0.5974115",
"0.5894277",
"0.58881605",
"0.58881605",
"0.5883955",
"0.57190776",
"0.5678983",
"0.5678983",
"0.5660285",
"0.5660285",
"0.5660285",
"0.5660285",
"0.5660285",
"0.5660285",
"0.5660285",
"0.5660285",
"0.5660285",... | 0.0 | -1 |
create resources is used to create the resources needed | def create_resources(project)
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(resources) ; end",
"def create(resources)\n #resources[0].model.last_query = resources\n counter = 0\n resources.each do |resource|\n fm_params = prepare_fmp_attributes(resource.dirty_attributes)\n rslt = layout(resource.model).create(fm_params)\n merge_f... | [
"0.7098429",
"0.6946261",
"0.69214714",
"0.687821",
"0.687821",
"0.6748614",
"0.6731864",
"0.6577058",
"0.65576774",
"0.6489712",
"0.6418785",
"0.6398197",
"0.63402456",
"0.63235515",
"0.6282782",
"0.6251337",
"0.62312806",
"0.6201025",
"0.61962813",
"0.61736757",
"0.61672485... | 0.70261425 | 1 |
Defaults fills out some fields that require code not just JSON SCHAME | def defaults!; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_defaults\n self.data = {} if data.blank?\n end",
"def default_data\n end",
"def defaults\n parse({})\n end",
"def default_fields\n # @kase.default_fields_with_name(:kase) if @kase\n defaults = {}\n defaults = defaults.merge(@review.default_fields_with_name(:review)) if @r... | [
"0.65855914",
"0.65551007",
"0.6415006",
"0.639384",
"0.63522315",
"0.63522315",
"0.63522315",
"0.63522315",
"0.63522315",
"0.63522315",
"0.63522315",
"0.63522315",
"0.63522315",
"0.63522315",
"0.6320549",
"0.63172174",
"0.6240433",
"0.62383825",
"0.62134725",
"0.62131286",
"... | 0.5923771 | 57 |
GET /fhir_base_urls GET /fhir_base_urls.json | def index
@fhir_base_urls = FhirBaseUrl.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @fhir_base_urls }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_href\n '/api/v1'\n end",
"def show\n @fhir_base_url = FhirBaseUrl.find(params[:id])\n\n respond_to do |format|\n format.html { redirect_to :action => :edit }\n format.json { render json: @fhir_base_url }\n end\n end",
"def base_url\n return url\n end",
"def base_url\n ... | [
"0.65288126",
"0.644742",
"0.62251186",
"0.6215531",
"0.62133396",
"0.620405",
"0.61742246",
"0.61429673",
"0.6136415",
"0.61359584",
"0.6083833",
"0.608366",
"0.6076272",
"0.6029362",
"0.60067344",
"0.5993861",
"0.59799045",
"0.59788996",
"0.5930055",
"0.5895603",
"0.5895229... | 0.78445756 | 0 |
GET /fhir_base_urls/1 GET /fhir_base_urls/1.json | def show
@fhir_base_url = FhirBaseUrl.find(params[:id])
respond_to do |format|
format.html { redirect_to :action => :edit }
format.json { render json: @fhir_base_url }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end",
"def base_href\n '/api/v1'\n end",
"def base_path\n \"/api/v1\"\n end",
"def new\n @fhir_base_url = FhirBaseU... | [
"0.7718999",
"0.6807459",
"0.6412564",
"0.6359851",
"0.6235135",
"0.6207592",
"0.62033546",
"0.61835504",
"0.61766785",
"0.6166719",
"0.61601555",
"0.61259633",
"0.61185884",
"0.6090367",
"0.60629946",
"0.6042072",
"0.60378283",
"0.60059416",
"0.5987726",
"0.5986979",
"0.5963... | 0.67873996 | 2 |
GET /fhir_base_urls/new GET /fhir_base_urls/new.json | def new
@fhir_base_url = FhirBaseUrl.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @fhir_base_url }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @base_url = BaseUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @base_url }\n end\n\n end",
"def create\n @fhir_base_url = FhirBaseUrl.new(params[:fhir_base_url])\n\n respond_to do |format|\n if @fhir_base_url.save\n for... | [
"0.7343179",
"0.72189087",
"0.66810304",
"0.6576273",
"0.64594054",
"0.63996327",
"0.6364573",
"0.63496935",
"0.627866",
"0.6262519",
"0.62583095",
"0.6251131",
"0.6109657",
"0.6095987",
"0.6078266",
"0.60770625",
"0.60255694",
"0.60255694",
"0.60228497",
"0.5989396",
"0.5967... | 0.7730156 | 0 |
POST /fhir_base_urls POST /fhir_base_urls.json | def create
@fhir_base_url = FhirBaseUrl.new(params[:fhir_base_url])
respond_to do |format|
if @fhir_base_url.save
format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully created.' }
format.json { render json: @fhir_base_url, status: :created, location: @fhir_base_url }
else
format.html { render action: "new" }
format.json { render json: @fhir_base_url.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @fhir_base_urls = FhirBaseUrl.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fhir_base_urls }\n end\n end",
"def create\n @base_url = BaseUrl.new(params[:base_url])\n\n respond_to do |format|\n if @base_url.save\n form... | [
"0.647281",
"0.5907034",
"0.5837732",
"0.5816133",
"0.56918824",
"0.56825995",
"0.56635875",
"0.5544441",
"0.5533057",
"0.5531832",
"0.55203277",
"0.55153286",
"0.54954576",
"0.54795194",
"0.54064965",
"0.54005194",
"0.5389489",
"0.5383957",
"0.5330269",
"0.5329335",
"0.53263... | 0.65894955 | 0 |
PUT /fhir_base_urls/1 PUT /fhir_base_urls/1.json | def update
@fhir_base_url = FhirBaseUrl.find(params[:id])
respond_to do |format|
if @fhir_base_url.update_attributes(params[:fhir_base_url])
format.html { redirect_to @fhir_base_url, notice: 'Fhir base url was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @fhir_base_url.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @base_url = BaseUrl.find(params[:id])\n\n respond_to do |format|\n if @base_url.update_attributes(params[:base_url])\n format.html { redirect_to @base_url, notice: 'Base url was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { rend... | [
"0.60500896",
"0.6005032",
"0.5930877",
"0.57847446",
"0.57821643",
"0.5653477",
"0.55667156",
"0.55542773",
"0.5554221",
"0.55478483",
"0.5534516",
"0.55053484",
"0.54694843",
"0.54195803",
"0.54020816",
"0.5352201",
"0.5344933",
"0.5333442",
"0.53221613",
"0.5319447",
"0.53... | 0.68342924 | 0 |
DELETE /fhir_base_urls/1 DELETE /fhir_base_urls/1.json | def destroy
begin
@fhir_base_url = FhirBaseUrl.find(params[:id])
@fhir_base_url.destroy
rescue ActiveRecord::DeleteRestrictionError
flash[:"alert-danger"] = "Could not delete the URL because there are resources assigned to it."
redirect_to resources_path
return
end
respond_to do |format|
format.html { redirect_to fhir_base_urls_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @base_url = BaseUrl.find(params[:id])\n @base_url.destroy\n\n respond_to do |format|\n format.html { redirect_to base_urls_url }\n format.json { head :no_content }\n end\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"d... | [
"0.7013541",
"0.66653395",
"0.66653395",
"0.658072",
"0.65619445",
"0.64821774",
"0.64821774",
"0.64821774",
"0.64821774",
"0.64769125",
"0.64567477",
"0.6446747",
"0.6429665",
"0.63629025",
"0.63601214",
"0.6324692",
"0.6324058",
"0.6320892",
"0.630077",
"0.6275",
"0.627127"... | 0.7637462 | 0 |
after_create :send_owner_booking_confirmation_email ^here define logic for when link in confirmation email is pressed, it sends a confirmation to OWNER | def send_user_booking_request_confirmation_email
BookingMailer.user_booking_confirmation(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_on_create_confirmation_instructions; end",
"def send_on_create_confirmation_instructions; end",
"def send_on_create_confirmation_instructions\n end",
"def send_on_create_confirmation_instructions\n end",
"def send_confirmation_email\n\t\tRentersConfirmationJob.perform_later self\n O... | [
"0.7424014",
"0.7424014",
"0.71035814",
"0.7043836",
"0.7024249",
"0.6996851",
"0.69920903",
"0.69920903",
"0.68653864",
"0.68459797",
"0.68210423",
"0.6795971",
"0.6778838",
"0.67645955",
"0.673097",
"0.66980124",
"0.6621812",
"0.65859",
"0.6569089",
"0.65497625",
"0.6501754... | 0.6610384 | 17 |
Registers some memory allocated by typelib | def add_allocated_memory(count)
self.allocated_memory += count
if (allocated_memory - last_allocated_memory) > allocated_memory_threshold
GC.start
@last_allocated_memory = allocated_memory
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_memory\n @register_memory ||= Memory.new(256, \"Register Memory\")\n end",
"def register(object); end",
"def register(byte, type)\n MAPPINGS[byte] = type\n end",
"def register(type, cls); end",
"def registers; end",
"def register(hook, obj = T.unsafe(nil), &blk); end",
"def... | [
"0.64769304",
"0.6324642",
"0.61574435",
"0.6124955",
"0.59229004",
"0.5883896",
"0.5860818",
"0.57481414",
"0.5677774",
"0.565187",
"0.5580923",
"0.5542774",
"0.5518699",
"0.5518699",
"0.5518699",
"0.5501037",
"0.54370093",
"0.541992",
"0.5418617",
"0.54041016",
"0.5403011",... | 0.0 | -1 |
PATCH/PUT /products/1 PATCH/PUT /products/1.json | def update
@rto = TrainingOrganization.find(params[:id])
p rto_params
respond_to do |format|
if @rto.update(rto_params)
format.html { redirect_to @rto, notice: 'RTO was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @rto.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @colle... | [
"0.7270251",
"0.6936097",
"0.68689305",
"0.6847095",
"0.6813668",
"0.6768683",
"0.6750446",
"0.6742433",
"0.67160225",
"0.6701455",
"0.66869843",
"0.6660239",
"0.665541",
"0.6654317",
"0.66415375",
"0.66415375",
"0.66390306",
"0.66318524",
"0.66318524",
"0.66281193",
"0.66214... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_rto
@rto = TrainingOrganization.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 rto_params
params.require(:training_organization).permit(:name)
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 |
NOTE: I know that brute forcing it is the wrong approach, but it was easy and I was up late and it worked, so... so, yeah. | def descramble(filename, result)
final = ''
until final == result
temp = result.split('').shuffle.join
final = scramble(filename, temp)
end
temp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def brute_exploit(addrs)\n end",
"def passbf(session,passlist,target,user,opt,logfile)\n\tprint_status(\"Running Brute force attack against #{user}\")\n\tprint_status(\"Successfull Username and Password pairs are being saved in #{logfile}\")\n \tresult = []\n\toutput = []\n\tpassfnd = 0\n \ta = []\n\ti = 0\n\... | [
"0.60361797",
"0.56404847",
"0.56071156",
"0.55794",
"0.55430835",
"0.551515",
"0.5511939",
"0.5508555",
"0.5503879",
"0.54750425",
"0.5429302",
"0.538715",
"0.532938",
"0.532536",
"0.53086025",
"0.5302923",
"0.5292559",
"0.52742636",
"0.52556676",
"0.5249452",
"0.5243619",
... | 0.5110925 | 45 |
GET /reports GET /reports.xml | def index
@reports = Report.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @reports }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reports\n collection(\"reports\")\n end",
"def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end"... | [
"0.75744605",
"0.73578554",
"0.7341337",
"0.721651",
"0.721651",
"0.71889627",
"0.7100547",
"0.70582396",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
"0.7038257",
... | 0.77149165 | 0 |
GET /reports/1 GET /reports/1.xml | def show
@report = Report.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @report }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @reports = Report.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @reports }\n end\n end",
"def report(id)\n get(\"reports/#{id}\")\n end",
"def show\n @report = Report.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.73724204",
"0.7359293",
"0.70133173",
"0.698434",
"0.69629735",
"0.69508386",
"0.6885953",
"0.6882204",
"0.6874107",
"0.6843494",
"0.6843494",
"0.68245757",
"0.67587614",
"0.6729209",
"0.6665831",
"0.66242594",
"0.65976244",
"0.65976244",
"0.65976244",
"0.65976244",
"0.659... | 0.6915653 | 6 |
GET /reports/new GET /reports/new.xml | def new
@report = Report.new
@circoli_a = Array.new
@circoli = Society.find(:all)
@circoli.each do |c|
@circoli_a << c.society
end
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @report }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n @report = Mg::Report.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @report }\n end\n end",
"def new\n... | [
"0.7788002",
"0.7672338",
"0.74192786",
"0.7354779",
"0.7354779",
"0.7220278",
"0.71483624",
"0.70779586",
"0.70662063",
"0.7063311",
"0.70581967",
"0.7047558",
"0.701259",
"0.70107883",
"0.69924396",
"0.69924396",
"0.69924396",
"0.69924396",
"0.69269466",
"0.6923664",
"0.690... | 0.0 | -1 |
POST /reports POST /reports.xml | def create
@report = Report.new(params[:report])
respond_to do |format|
if @report.save
format.html { redirect_to(@report, :notice => 'Report was successfully created.') }
format.xml { render :xml => @report, :status => :created, :location => @report }
else
format.html { render :action => "new" }
format.xml { render :xml => @report.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report\n @report = Report.create(reports_params)\n if @report.valid?\n render json: {}, status: :created\n else\n render json: { error: 'failed to create report' }, status: :internal_server_error\n end\n end",
"def create\n\n\n @report = Report.new(params[:report])\n ... | [
"0.6767336",
"0.67065424",
"0.66361433",
"0.651093",
"0.6493436",
"0.6473774",
"0.6435383",
"0.64126194",
"0.63887656",
"0.6368415",
"0.6368415",
"0.6368415",
"0.6327613",
"0.6327613",
"0.63159525",
"0.63043004",
"0.6265468",
"0.6259001",
"0.62507087",
"0.6229303",
"0.6226678... | 0.667678 | 2 |
PUT /reports/1 PUT /reports/1.xml | def update
@report = Report.find(params[:id])
respond_to do |format|
if @report.update_attributes(params[:report])
format.html { redirect_to(@report, :notice => 'Report was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @report.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @report = Mg::Report.find(params[:id])\n\n respond_to do |format|\n if @report.update_attributes(params[:report])\n format.html { redirect_to(@repor... | [
"0.6636008",
"0.65041757",
"0.64983416",
"0.64934784",
"0.6209521",
"0.6200539",
"0.6200248",
"0.6200248",
"0.61958337",
"0.61544424",
"0.61226845",
"0.6119069",
"0.611681",
"0.61123073",
"0.6112214",
"0.60990727",
"0.6088551",
"0.6043774",
"0.6036607",
"0.60289955",
"0.60289... | 0.6513428 | 1 |
DELETE /reports/1 DELETE /reports/1.xml | def destroy
@report = Report.find(params[:id])
@report.destroy
respond_to do |format|
format.html { redirect_to(reports_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report_delete(id)\r\n\t\tpost= { \"token\" => @token, \"report\" => id } \r\n\t\tdocxml=nessus_request('report/delete', post)\r\n\t\treturn docxml\r\n\tend",
"def report_delete(id)\n\t\t\tpost= { \"token\" => @token, \"report\" => id }\n\t\t\tdocxml = nil\n\t\t\tdocxml=nessus_request('report/delete', post)\n... | [
"0.7864469",
"0.7545729",
"0.7509032",
"0.7509032",
"0.7485339",
"0.74581146",
"0.73497295",
"0.7189994",
"0.7133743",
"0.7112802",
"0.71122026",
"0.7045686",
"0.70348287",
"0.7030788",
"0.69919956",
"0.6975974",
"0.6963122",
"0.6960736",
"0.6951867",
"0.6949705",
"0.6934347"... | 0.74651015 | 6 |
Return dataset by its name | def [](name)
datasets.fetch(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset(name)\n datasets[name] = Dataset.new(connection.fetch(name.to_s))\n end",
"def dataset(name)\n @datasets[name.to_sym] = Dataset.new(session, *split(name))\n end",
"def dataset(name)\n fetch_or_store(name) { Dataset.new(rql.table(name), rql, self) }\n end",
"def dat... | [
"0.84260404",
"0.8333166",
"0.8270753",
"0.8229438",
"0.8157162",
"0.81196225",
"0.8079079",
"0.73446894",
"0.7325566",
"0.72770995",
"0.72770995",
"0.7155278",
"0.71247137",
"0.6987319",
"0.6889249",
"0.6845552",
"0.6840375",
"0.6791701",
"0.6741045",
"0.6727756",
"0.6666998... | 0.81034017 | 7 |
Register a new dataset | def dataset(name)
datasets[name] = Dataset.new(connection.fetch(name.to_s))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_dataset(name)\n unless metadata[:datasets].include? name\n d = MiGA::Dataset.new(self, name)\n @metadata[:datasets] << name\n @dataset_names_hash = nil # Ensure loading even if +do_not_save+ is true\n save\n if d.ref? && d.active?\n recalculate_tasks(\"Reference dataset a... | [
"0.68951255",
"0.661865",
"0.6568996",
"0.6434236",
"0.6394017",
"0.6370177",
"0.6349531",
"0.63259035",
"0.6284516",
"0.62636334",
"0.6248965",
"0.6248965",
"0.6248965",
"0.6248965",
"0.61942303",
"0.60738796",
"0.60738796",
"0.60708773",
"0.6038573",
"0.6025706",
"0.6014487... | 0.6017397 | 20 |
Return if a dataset with provided name exists | def dataset?(name)
datasets.key?(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset?(name)\n self[name] ? true : false\n end",
"def dataset?(name)\n run rql.db(options[:db]).table_list.contains(name.to_s)\n end",
"def dataset?(name)\n connection.query(\"select * from #{name} limit 1\")\n true\n rescue ::InfluxDB::Error\n false\n e... | [
"0.853543",
"0.8333764",
"0.80609053",
"0.7299681",
"0.7186603",
"0.7077373",
"0.7035662",
"0.69494444",
"0.681599",
"0.68006873",
"0.67570317",
"0.6641808",
"0.66224843",
"0.6567562",
"0.653844",
"0.6459573",
"0.6457092",
"0.6434239",
"0.6412482",
"0.64020854",
"0.640058",
... | 0.87435895 | 1 |
Private: Fail the check if ActiveRecord cannot check migration status | def unsupported
mark_failure
mark_message "This version of ActiveRecord does not support checking whether migrations are pending"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def migration_error?\n render :migration_error, status: 500 unless ENV[\"DB_MIGRATE_FAILED\"].blank?\n end",
"def migrate?\n raise NotImplementedError\n end",
"def supports_migrations?\n false\n end",
"def supports_migrations?\n false\n end",
"def integrity_check\n ... | [
"0.7106798",
"0.6724601",
"0.6706887",
"0.6706887",
"0.6653206",
"0.65198195",
"0.65198195",
"0.6516664",
"0.6516664",
"0.6516664",
"0.6452443",
"0.63467443",
"0.631587",
"0.6194073",
"0.608931",
"0.605167",
"0.60339427",
"0.599644",
"0.59961903",
"0.59688634",
"0.5968473",
... | 0.7452502 | 0 |
Using a private method to encapsulate the permissible parameters is just a good pattern since you'll be able to reuse the same permit list between create and update. Also, you can specialize this method with peruser checking of permissible attributes. | def user_params
params.require(:user).permit(:name, :first_name, :title, :current_location, :last_name, :email, :password, :password_confirmation, :type, :bio, :role, :role_id, :days, :headline, :avatar, :avatar_cache, :remove_avatar, :phone_number)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permitted_params\n policy(resource || resource_class.new).send(\"permitted_#{action_name}_attributes\")\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) ... | [
"0.70220745",
"0.70117974",
"0.684321",
"0.68110925",
"0.6693265",
"0.66887414",
"0.66836554",
"0.66696244",
"0.6636198",
"0.661805",
"0.661596",
"0.660481",
"0.65912217",
"0.657594",
"0.65718645",
"0.65321547",
"0.6526882",
"0.65241146",
"0.6517794",
"0.6509739",
"0.6472306"... | 0.0 | -1 |
GET /albums GET /albums.json | def index
@albums = Album.where("kind NOT IN ('status', 'default', 'cover', 'profile')").paginate(page: params[:page], :per_page => 30)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @albums = Album.all\n render json: @albums\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end",
"def get_albums(url)\n # should return albums\n # List o... | [
"0.8048931",
"0.7923151",
"0.79193866",
"0.78014976",
"0.77844",
"0.7780223",
"0.77119625",
"0.7673395",
"0.7659477",
"0.75729513",
"0.75276154",
"0.75228256",
"0.74572295",
"0.74433213",
"0.7395577",
"0.7365708",
"0.73508006",
"0.73417866",
"0.73407245",
"0.73407245",
"0.734... | 0.0 | -1 |
GET /albums/1 GET /albums/1.json | def show
if signed_in?
@upload = current_user.uploads.build
end
@album = Album.find(params[:id])
@user = @album.user
@user_profile_pics = @user.uploads.where(upload_type: 'profile')
impressionist @album, '', unique: [:user_id] if current_user
@likers = @album.likers(User)
@comments = @album.comment_threads.where('parent_id IS NULL').order('created_at desc')
if signed_in?
@new_comment = Comment.build_from(@album, current_user.id, "")
@video = current_user.videos.build
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def album\n album = Album.find(params[:id])\n render json: album\n end",
"def get_album album_id\n get(\"/albums/#{album_id}\")\n end",
"def index\n @albums = Album.all\n render json: @albums\n end",
"def albums\n if params[:artist_id]\n albums = Artist.find(params[:ar... | [
"0.8010893",
"0.79601175",
"0.7838933",
"0.76931643",
"0.7598457",
"0.7579601",
"0.7575355",
"0.75562096",
"0.75089633",
"0.7500134",
"0.74333906",
"0.7426798",
"0.7391768",
"0.73389864",
"0.7287336",
"0.7271081",
"0.72389615",
"0.7209903",
"0.7200635",
"0.7192762",
"0.719262... | 0.0 | -1 |
POST /albums POST /albums.json | def create
@album = Album.new(album_params)
@album.user_id = current_user.id
respond_to do |format|
if @album.save
if @album.user.locations.any?
add_location_to_user_albums(@album.user.locations.where(status: 'current').first) if @album.user.locations.where(status: 'current').any?
end
create_activity(@album.class.name, @album.id, 'create')
format.html {
if album_params.has_key?(:cover)
render 'crop'
else
redirect_to @album, notice: 'Portfolio was successfully created.'
end
}
format.json { render action: 'show', status: :created, location: @album }
else
format.html { render action: 'new' }
format.json { render json: @album.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend",
"def create\n @album = current_user.albums.build(album_params)\n\n res... | [
"0.77528495",
"0.7283492",
"0.7234256",
"0.71961457",
"0.7179153",
"0.70808494",
"0.70808494",
"0.70808494",
"0.7003637",
"0.7003637",
"0.69838834",
"0.6972035",
"0.697075",
"0.6958249",
"0.69494504",
"0.6927158",
"0.68965065",
"0.6890949",
"0.6846395",
"0.6823431",
"0.682324... | 0.0 | -1 |
PATCH/PUT /albums/1 PATCH/PUT /albums/1.json | def update
respond_to do |format|
if album_params.has_key?(:cover_original_w)
#params[:album][:cover_box_w] = 1000
if album_params[:cover_original_w].to_f > 1000
scale_factor = album_params[:cover_original_w].to_f / 1000
album_params[:cover_crop_x] = album_params[:cover_crop_x].to_f * scale_factor
album_params[:cover_crop_y] = album_params[:cover_crop_y].to_f * scale_factor
album_params[:cover_crop_w] = album_params[:cover_crop_w].to_f * scale_factor
album_params[:cover_crop_h] = album_params[:cover_crop_h].to_f * scale_factor
end
end
if @album.update_attributes(album_params)
format.html {
if album_params.has_key?(:cover)
render 'crop'
else
redirect_to @album, notice: 'Portfolio was successfully updated.'
end
}
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @album.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @album = current_user.albums.find(params[:id])\n\n respond_to do |format|\n if @Album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ... | [
"0.6955096",
"0.67836237",
"0.67753136",
"0.677528",
"0.67684835",
"0.67597175",
"0.67597175",
"0.6732082",
"0.6732082",
"0.6732082",
"0.6701589",
"0.6701589",
"0.6701589",
"0.6662536",
"0.6628176",
"0.65705246",
"0.65516347",
"0.65429837",
"0.6537242",
"0.6532796",
"0.650100... | 0.0 | -1 |
DELETE /albums/1 DELETE /albums/1.json | def destroy
@album.multiuploads.each do |multiupload|
multiupload.destroy
end
destroy_all_comments_likes_activities_and_responses_of_obj(@album)
# destroy responses
# Response.where(acted_upon_type: "Album", acted_upon_id: @album.id).each do |album_response|
# album_response.destroy
# end
# #destroy activities
# Activity.where(acted_upon_type: "Album", acted_upon_id: @album.id).each do |album_activity|
# album_activity.destroy
# end
#destroy comments
# Comment.where(commentable_type: 'Album', commentable_id: @album.id).each do |album_comment|
# Like.where(likeable_type: 'Comment', likeable_id: album_comment.id).each do |comment_likes|
# comment_likes.destroy
# end
# Response.where(acted_upon_type: "Comment", acted_upon_id: album_comment.id).each do |comment_response|
# comment_response.destroy
# end
#
# if album_comment.has_children?
# album_comment.children.each do |child|
# child.destroy
# end
# end
# album_comment.destroy
# end
#destroy likes
# Like.where(likeable_type: 'Album', likeable_id: @album.id).each do |album_likes|
# album_likes.destroy
# end
# destroy_activity(@album.class.name, @album.id, 'create')
# destroy_activity(@album.class.name, @album.id, 'like')
@album.destroy
# respond_to do |format|
# format.html { redirect_to albums_url }
# format.json { head :no_content }
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\n @album = @user.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album.destroy\n render json: @album\n end",
"def destroy\n @album = Albu... | [
"0.801051",
"0.79122156",
"0.7840477",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.77915406",
"0.7785304",
"0.7780388",
"0.7775917",
"0.77713436",
"0.77632475",
"0.77632475",
"0.77632475",
"0.7684608",
"0.7640788",
"0.7640206",
"0.76009154",
"0.7557025",
"0.754... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_album
@album = Album.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 album_params
params.fetch(:album, {}).permit!
# params.require(:album).permit(:user_id, :name, :title, :description, :kind, :category_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 |
def weapon_choice puts "Choose your weapon: rock, paper or scissors" | def computer_choice
@computer = ["rock", "paper", "scissors"].shuffle.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_weapons\n puts \"Choose 'r' for rock, 'p' for paper or 's' for scissors\"\n return gets.chomp.downcase\n end",
"def print_winning_message(winning_choice)\n case\n when 'Rock'\n say('Rock smashes scissors!')\n when 'Paper'\n say('Paper covers rock!')\n when 'Scissors'\n say('Sciss... | [
"0.8143034",
"0.7432139",
"0.7429339",
"0.7394063",
"0.7274119",
"0.72526217",
"0.7227061",
"0.72176194",
"0.7204273",
"0.71763754",
"0.71515805",
"0.71512806",
"0.71253586",
"0.7103288",
"0.70655507",
"0.704441",
"0.70342004",
"0.70199716",
"0.7011729",
"0.69204384",
"0.6903... | 0.0 | -1 |
Return true if the key is active. Once activated (by calling on), a key will remain active until it produces output below the inactivity threshold for duration of the inactivity timeout. | def active?
return @active
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active?(key)\n @counter[key] > 0\n end",
"def active?\n return false if status != :active\n !ended?\n end",
"def active?\n if is_active\n return true\n else\n return false\n end\n end",
"def isKeyActive _args\n \"isKeyActive _args;\" \n en... | [
"0.7168802",
"0.7039884",
"0.67177564",
"0.6712046",
"0.6711074",
"0.6608652",
"0.65424615",
"0.6517372",
"0.647058",
"0.6463852",
"0.64272195",
"0.64133286",
"0.64068097",
"0.6385015",
"0.63812315",
"0.6378988",
"0.6363971",
"0.6355046",
"0.6339981",
"0.6320405",
"0.6304371"... | 0.6137625 | 58 |
Return true if the key has been released (by calling release or off). | def released?
return @released
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_released?(key)\n @prev_down.index(key) and @down.index(key).nil?\n end",
"def release? key=:any\n return @data.include? :up if key == :any\n @data[key] == :up\n end",
"def key_held?(key)\n @held_interval[key] == G.kb_held_interval\n end",
"def released_true?\n self.r... | [
"0.8209997",
"0.7825162",
"0.7393747",
"0.70009273",
"0.69763756",
"0.69349414",
"0.6885691",
"0.68635404",
"0.6858544",
"0.67356753",
"0.67356753",
"0.6674242",
"0.664519",
"0.66443205",
"0.6596986",
"0.65843344",
"0.6564157",
"0.6544072",
"0.6518803",
"0.6516688",
"0.650927... | 0.66479146 | 12 |
Activate the key (start playing the note). | def on(attack, sustain, pitch = @current_pitch)
@handler.on(attack,sustain,pitch)
activate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activateKey _args\n \"activateKey _args;\" \n end",
"def activate_tab_with_key_press(key, *modifiers)\n wait_start\n # TODO: FIXME. key_down and up are not yet implemented on mac and windows\n if linux?\n key_down_direct(key,*modifiers)\n key_up_direct(key, *modifiers)\n ... | [
"0.69630414",
"0.6961573",
"0.6936826",
"0.6772868",
"0.6769183",
"0.67214245",
"0.66111314",
"0.62328696",
"0.6216426",
"0.616874",
"0.61584663",
"0.61438274",
"0.60455644",
"0.60190463",
"0.5893018",
"0.5893018",
"0.5885528",
"0.5877533",
"0.5877533",
"0.5848638",
"0.583220... | 0.0 | -1 |
Deactivate the key (stop playing the note altogether and at once). | def off
@handler.off
deactivate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unbind_key keycode\n @_key_args.delete keycode unless @_key_args.nil?\n @_key_map.delete keycode unless @_key_map.nil?\n end",
"def deactivate()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.HotkeySystem_deactivate(@handle.ptr... | [
"0.7009377",
"0.6822615",
"0.67585826",
"0.6701934",
"0.6498792",
"0.64299154",
"0.6315975",
"0.6154377",
"0.6062111",
"0.60566175",
"0.60437834",
"0.60150653",
"0.60150653",
"0.5974488",
"0.5940776",
"0.5926243",
"0.5882624",
"0.5882624",
"0.5849684",
"0.58440036",
"0.581184... | 0.0 | -1 |
Make sure a pitch fits in the key's allowed range. | def check_pitch pitch
raise ArgumentError, "pitch is less than pitch range min" if pitch < @pitch_range.min
raise ArgumentError, "pitch is more than pitch range max" if pitch > @pitch_range.max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_length_valid?(number)\n number >= 1024 && ( number & (number - 1) == 0 )\n end",
"def key_length_valid?(number)\n number >= 1024 && ( number & (number - 1) == 0 )\n end",
"def valid_key?(match_data)\n match_data[:key].to_i == (97 - match_data[1..-2].join.to_i) % 97\nend",
"de... | [
"0.56189775",
"0.56189775",
"0.5522284",
"0.5513022",
"0.5493864",
"0.53659564",
"0.53391254",
"0.52893674",
"0.52798766",
"0.5230192",
"0.5197499",
"0.5140459",
"0.5120379",
"0.50213265",
"0.50053483",
"0.49846",
"0.49839526",
"0.49651346",
"0.495985",
"0.49499112",
"0.49279... | 0.7555697 | 0 |
GET /datasets GET /datasets.xml | def index
request.format = :eml if params[:Dataset]
@keyword_list = params['keyword_list']
@people = Person.find_all_with_dataset(:order => 'sur_name')
@themes = Theme.find(:all, :order => :weight)
@datasets = Dataset.all
@studies = collect_and_normalize_studies(@datasets)
@studies = [@study] if @study
@crumbs = []
respond_to do |format|
format.html # index.rhtml
format.xml { render :xml => @datasets.to_xml }
format.eml { render :eml => @datasets }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_datasets\n authenticate unless authenticated?\n response = RestClient::Request.execute(\n url: @@datasets_endpoint,\n method: :get,\n headers: headers('application/json')\n )\n return response\n end",
"def index\n @datasets = Dataset.all\n end",
"def inde... | [
"0.753298",
"0.6892824",
"0.6892824",
"0.6892824",
"0.6813552",
"0.6754465",
"0.6754465",
"0.6622356",
"0.655275",
"0.655275",
"0.6168882",
"0.6156508",
"0.61541",
"0.6105366",
"0.60999507",
"0.60952085",
"0.6019521",
"0.6001793",
"0.5979236",
"0.59703606",
"0.5948212",
"0.... | 0.55459785 | 48 |
GET /datasets/1 GET /datasets/1.xml GET /dataset/1.eml | def show
@dataset = Dataset.find(params[:id])
@title = @dataset.title
@roles = @dataset.roles
respond_to do |format|
format.html # show.rhtml
format.eml { render :xml => @dataset.to_eml }
format.xml { render :xml => @dataset.to_xml }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @dataset }\n end\n end",
"def show\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.x... | [
"0.6515531",
"0.6515531",
"0.6430059",
"0.6369675",
"0.6369675",
"0.6369675",
"0.63256216",
"0.62667674",
"0.6231876",
"0.60140026",
"0.59460634",
"0.59143174",
"0.5913164",
"0.58865386",
"0.58772343",
"0.587506",
"0.587506",
"0.587506",
"0.587506",
"0.58724594",
"0.58608234"... | 0.6559103 | 0 |
POST /datasets POST /datasets.xml | def create
@dataset = Dataset.new(params[:dataset])
respond_to do |format|
if @dataset.save
flash[:notice] = 'Dataset was successfully created.'
format.html { redirect_to dataset_url(@dataset) }
format.xml { head :created, :location => dataset_url(@dataset) }
else
format.html { render :action => "new" }
format.xml { render :xml => @dataset.errors.to_xml }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @dataset = Dataset.new(params[:dataset])\n\n respond_to do |format|\n if @dataset.save\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully created.') }\n format.xml { render :xml => @dataset, :status => :created, :location => @dataset }\n else\n ... | [
"0.64057773",
"0.63516057",
"0.61581206",
"0.61139226",
"0.60565925",
"0.5844556",
"0.58094054",
"0.5764553",
"0.57569027",
"0.5755463",
"0.57161283",
"0.56881595",
"0.5617457",
"0.56094533",
"0.5606813",
"0.560531",
"0.55948615",
"0.55882657",
"0.555601",
"0.55529916",
"0.55... | 0.6340367 | 2 |
PUT /datasets/1 PUT /datasets/1.xml | def update
@dataset = Dataset.find(params[:id])
respond_to do |format|
if @dataset.update_attributes(params[:dataset])
flash[:notice] = 'Dataset was successfully updated.'
format.html { redirect_to dataset_url(@dataset) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @dataset.errors.to_xml }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @dataset = Dataset.find(params[:id])\n\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to(@dataset, :notice => 'Dataset was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :actio... | [
"0.6526648",
"0.6329613",
"0.6190557",
"0.61218303",
"0.6041167",
"0.5998395",
"0.59983724",
"0.59983724",
"0.59983724",
"0.59983724",
"0.59376717",
"0.59293675",
"0.58789486",
"0.58299065",
"0.5808605",
"0.57836634",
"0.5779558",
"0.568264",
"0.5639311",
"0.5623167",
"0.5608... | 0.6552326 | 0 |
DELETE /datasets/1 DELETE /datasets/1.xml | def destroy
@dataset = Dataset.find(params[:id])
@dataset.destroy
respond_to do |format|
format.html { redirect_to datasets_url }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset = Dataset.find(params[:id])\n @dataset.destroy\n\n respond_to do |format|\n... | [
"0.7611086",
"0.7611086",
"0.7556342",
"0.73045534",
"0.72367954",
"0.7116475",
"0.6968973",
"0.6787735",
"0.6710013",
"0.6688224",
"0.66880995",
"0.66831076",
"0.66492313",
"0.6611187",
"0.6578242",
"0.6491182",
"0.64718854",
"0.64684135",
"0.64354557",
"0.6430135",
"0.64139... | 0.75166965 | 3 |
Construct a new aggregation | def initialize(model, functions)
@model = model
@functions = []
functions.each do |field_name, function|
@functions << function.prepare(@model, field_name)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregation(*args, &block)\n @aggregations ||= AggregationsCollection.new\n @aggregations.update args.first => Aggregation.new(*args, &block)\n self\n end",
"def new_aggregate(type,name, value)\n Models::Aggregate.new(\n :type => type,\n :par... | [
"0.76560813",
"0.7485018",
"0.71006894",
"0.66628075",
"0.66010576",
"0.6544162",
"0.6508941",
"0.6495526",
"0.6376776",
"0.63476384",
"0.6163588",
"0.6055582",
"0.6030893",
"0.601845",
"0.60101026",
"0.5963537",
"0.58111006",
"0.57919693",
"0.5775365",
"0.5760049",
"0.575419... | 0.0 | -1 |
Construct a aggregation function for a field | def initialize(aggregation_path)
@aggregation_path = aggregation_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :count => 0 },\n :reduce => Javascript.aggregate\n )\n end",
"def filter_agg(field:, value:, &block)\r\n agg = { agg: { filter: { term: { field => value }... | [
"0.68445355",
"0.668887",
"0.6611655",
"0.65102667",
"0.6473885",
"0.64478487",
"0.6398687",
"0.63440484",
"0.62880415",
"0.620975",
"0.61713254",
"0.61398405",
"0.6064792",
"0.5941599",
"0.5881734",
"0.587374",
"0.5846559",
"0.5731604",
"0.57174873",
"0.5693342",
"0.56767625... | 0.0 | -1 |
Prepare the aggregation function for a model class and a field | def prepare(model, field_name = nil)
@model = model
@selection = Babik::Selection::Path::Factory.build(model, @aggregation_path)
@field_name = field_name || "#{self.table_alias}__#{SQL_OPERATION.downcase}"
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :count => 0 },\n :reduce => Javascript.aggregate\n )\n end",
"def aggregate_function\n build_function(super, aggregate_constants)\n end",
"def aggregatio... | [
"0.6436133",
"0.60325927",
"0.60008335",
"0.58198863",
"0.5806916",
"0.57832736",
"0.56387854",
"0.54926014",
"0.5471085",
"0.542783",
"0.5389747",
"0.5389257",
"0.5360926",
"0.53440696",
"0.53398246",
"0.532997",
"0.53228843",
"0.52970964",
"0.5285426",
"0.5252935",
"0.52515... | 0.59244156 | 3 |
Return aggregation function SQL | def sql
selected_field_path = "#{@selection.target_alias}.#{@selection.selected_field}"
operation = self.sql_operation.sub('?field', selected_field_path)
"#{operation} AS #{@field_name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate\n klass.collection.group(\n :key => field_list,\n :cond => selector,\n :initial => { :count => 0 },\n :reduce => Javascript.aggregate\n )\n end",
"def build_aggregate_sql(column_mask)\n dimension_column_names = dimensions_to_columns.coll... | [
"0.71016634",
"0.709663",
"0.68281054",
"0.6797009",
"0.67561626",
"0.6698071",
"0.6639238",
"0.65070856",
"0.6394741",
"0.62502927",
"0.62177354",
"0.6209646",
"0.6192367",
"0.61751014",
"0.6126116",
"0.60580623",
"0.6033101",
"0.60283643",
"0.5993157",
"0.59924835",
"0.5990... | 0.0 | -1 |
=begin def PhoneNumberConfirmedButton " id:'settings_text_phone_number_confirmed'" Visible if text is not empty =end | def aboutButton
"* marked:'About'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit_number\n content_tag(\"strong\", configatron.incoming_sms_number.blank? ? \"[\" + t(\"sms_form.guide.unknown_number\") + \"]\" : configatron.incoming_sms_number)\n end",
"def validar_home\n find(@@btn_verMais).displayed?\n end",
"def confirmation_text\n frm.div(:class=>\"portletBody\").di... | [
"0.5954993",
"0.5712688",
"0.5707709",
"0.5707709",
"0.5629218",
"0.5530923",
"0.54843396",
"0.54810303",
"0.5454336",
"0.54094917",
"0.5401517",
"0.53895384",
"0.53320307",
"0.53223765",
"0.5309895",
"0.5284729",
"0.5268197",
"0.5259942",
"0.5255448",
"0.52539283",
"0.524175... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_inspection
@inspection = Inspection.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 |
Only allow a trusted parameter "white list" through. | def inspection_params
params.require(:inspection).permit(:code, :houhou, :houhou_eng, :basho, :basho_eng, :cost)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Is a user currently logged on? | def user_action
if controller.nil? || !controller.respond_to?(:session) || controller.session[:user].nil?
return false
end
return true
rescue
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def is_current_user(user)\n logged_in? && @current_user.id == user.id\n end",
"def logged_in?\n\t\t\tcurrent_user.is_a? User\n\t\tend",
"def user_logged_in?\n current_user.prese... | [
"0.8686961",
"0.85194045",
"0.84652984",
"0.8420208",
"0.8420208",
"0.8411225",
"0.840489",
"0.83832395",
"0.8329196",
"0.83206964",
"0.83206964",
"0.831728",
"0.8312811",
"0.83047986",
"0.82938427",
"0.8292668",
"0.82857966",
"0.82857966",
"0.8273226",
"0.82671106",
"0.82662... | 0.0 | -1 |
GET /dairies GET /dairies.json | def index
@dairies = Dairy.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end",
"def index\n @my_dairies = MyDairy.all\n end",
"def show\n... | [
"0.68365806",
"0.6676271",
"0.6571826",
"0.6405233",
"0.6368298",
"0.62711257",
"0.61993396",
"0.613877",
"0.6069747",
"0.6063064",
"0.6053844",
"0.59664583",
"0.5966046",
"0.595462",
"0.59324247",
"0.5931901",
"0.5925932",
"0.5886758",
"0.5883489",
"0.58756554",
"0.5862489",... | 0.6861026 | 0 |
GET /dairies/1 GET /dairies/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@dairies = Dairy.all\n\tend",
"def index\n @dices = Dice.all\n\n render json: @dices\n end",
"def index\n @diaries = current_user.diaries.all\n respond_to do |format|\n format.html {render :index}\n format.json { render json: @diaries }\n end\n end",
"def show\n @... | [
"0.6429982",
"0.63511264",
"0.62506133",
"0.62188107",
"0.6134505",
"0.6112718",
"0.61031145",
"0.608416",
"0.6053337",
"0.5999819",
"0.594923",
"0.5929707",
"0.59293664",
"0.592666",
"0.58782214",
"0.5851975",
"0.58457065",
"0.58434844",
"0.5842207",
"0.5796763",
"0.5786377"... | 0.0 | -1 |
POST /dairies POST /dairies.json | def create
@dairy = Dairy.new(dairy_params)
for i in 0..10
if params[:repeat][i.to_s].empty?
break
end
@dairy.attempts.build({repeats: params[:repeat][i.to_s],weight: params[:weight][i.to_s]})
end
respond_to do |format|
if @dairy.save
format.html { redirect_to lk_today_url }
format.json { render :show, status: :created, location: @dairy }
else
format.html { render :new }
format.json { render json: @dairy.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @dice = Dice.new(dice_params)\n\n if @dice.save\n render json: @dice, status: :created, location: @dice\n else\n render json: @dice.errors, status: :unprocessable_entity\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def ... | [
"0.63165385",
"0.58797836",
"0.5855163",
"0.57870793",
"0.57219005",
"0.56443614",
"0.5641417",
"0.56361055",
"0.56136733",
"0.56121016",
"0.555067",
"0.5539301",
"0.5532932",
"0.55167055",
"0.5483433",
"0.5480721",
"0.54800874",
"0.54632026",
"0.545548",
"0.54524815",
"0.544... | 0.5455448 | 19 |
PATCH/PUT /dairies/1 PATCH/PUT /dairies/1.json | def update
respond_to do |format|
if @dairy.update(dairy_params)
format.html { redirect_to @dairy, notice: 'Dairy was successfully updated.' }
format.json { render :show, status: :ok, location: @dairy }
else
format.html { render :edit }
format.json { render json: @dairy.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'P... | [
"0.69359714",
"0.6742734",
"0.6708918",
"0.6534313",
"0.6261845",
"0.62511015",
"0.62511015",
"0.6245733",
"0.6235861",
"0.62234163",
"0.61826795",
"0.61779314",
"0.61285806",
"0.6122471",
"0.6111749",
"0.6073099",
"0.6063874",
"0.6053743",
"0.6046176",
"0.60269755",
"0.60134... | 0.0 | -1 |
DELETE /dairies/1 DELETE /dairies/1.json | def destroy
@dairy.destroy
respond_to do |format|
format.html { redirect_to lk_today_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete\n ... | [
"0.73902303",
"0.7062767",
"0.70251817",
"0.69340855",
"0.6829894",
"0.6825659",
"0.68132424",
"0.68074733",
"0.68074733",
"0.68074733",
"0.68074733",
"0.67813975",
"0.6771833",
"0.6742372",
"0.673572",
"0.6735484",
"0.67318314",
"0.6723947",
"0.6712085",
"0.6680543",
"0.6680... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_dairy
@dairy = Dairy.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 dairy_params
params.require(:dairy).permit(:user_id, :exercise_id, :when, :done)
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 |
Clean the changed paths and return only valid PHPUnit tests files. | def clean(paths)
paths.uniq!
paths.compact!
populate_test_files
paths = paths.select { |p| test_file?(p) }
clear_tests_files_list
paths
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_tests\n puts \"Removing generated tests from '#{Settings[:test_dir]}'...\"\n Dir.foreach(Settings[:test_dir]) do |dir|\n path = Pathname.new(Settings[:test_dir]) + dir\n next if dir == '.' or dir == '..' or dir == 'support' or not path.directory?\n FileUtils.rm_rf(path)\n end\nend",
"def re... | [
"0.70650643",
"0.6703281",
"0.63987005",
"0.634393",
"0.6166886",
"0.60558796",
"0.5962308",
"0.5946638",
"0.5909081",
"0.5880959",
"0.5846157",
"0.5843148",
"0.5783122",
"0.5782859",
"0.575021",
"0.5728827",
"0.57137936",
"0.57040197",
"0.56911045",
"0.5689036",
"0.5665183",... | 0.72773135 | 0 |
Checks if the paths is a valid test file. | def test_file?(path)
@tests_files.include?(path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?\n ensure_file_open!\n\n ['Makefile', 'submission/', 'tests/'].all? { |entry| @file.find_entry(entry).present? }\n end",
"def valid_file_path?(path)\n path && File.exist?(path) && File.readable?(path)\n end",
"def valid_file?(path)\n case path\n when %r|/abcdef$|, %r|^\\./tmp/d... | [
"0.70958656",
"0.6820039",
"0.66966206",
"0.6581964",
"0.6551448",
"0.65437734",
"0.65351826",
"0.6528706",
"0.64767516",
"0.6473018",
"0.6456283",
"0.6391489",
"0.6373879",
"0.6336423",
"0.63254166",
"0.6311913",
"0.6297002",
"0.6291849",
"0.629128",
"0.62630975",
"0.6251614... | 0.6956083 | 1 |
Scans the tests path and keeps a list of all tests paths. def tests_files Uses the current path for tests_path when unset. | def clear_tests_files_list
@tests_files = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_files\n files = tests\n files = files.map{ |f| Dir[f] }.flatten\n files = files.map{ |f| File.directory?(f) ? Dir[File.join(f, '**/*.rb')] : f }\n files = files.flatten.uniq\n files = files.map{ |f| File.expand_path(f) }\n files\n end",
"def test_files\n ... | [
"0.8476455",
"0.80244964",
"0.78613293",
"0.77027506",
"0.7448862",
"0.74225575",
"0.7296477",
"0.71977246",
"0.7065644",
"0.68764144",
"0.679065",
"0.6750063",
"0.67442113",
"0.66988975",
"0.6652212",
"0.66474307",
"0.6629163",
"0.658945",
"0.658945",
"0.658945",
"0.658945",... | 0.64865583 | 28 |
A constructor that requires both the IP address of the machine to communicate with as well as the secret (string) needed to perform communication. AppControllers will reject SOAP calls if this secret (basically a password) is not present it can be found in the user's .appscale directory, and a helper method is usually present to fetch this for us. | def initialize(ip, secret)
@ip = ip
@secret = secret
@conn = SOAP::RPC::Driver.new("https://#{@ip}:17443")
@conn.add_method("set_parameters", "djinn_locations", "database_credentials", "app_names", "secret")
@conn.add_method("set_apps", "app_names", "secret")
@conn.add_method("set_apps_to_restart", "apps_to_restart", "secret")
@conn.add_method("status", "secret")
@conn.add_method("get_stats", "secret")
@conn.add_method("update", "app_names", "secret")
@conn.add_method("stop_app", "app_name", "secret")
@conn.add_method("get_all_public_ips", "secret")
@conn.add_method("is_done_loading", "secret")
@conn.add_method("is_done_initializing", "secret")
@conn.add_method("add_role", "new_role", "secret")
@conn.add_method("remove_role", "old_role", "secret")
@conn.add_method("get_queues_in_use", "secret")
@conn.add_method("add_appserver_to_haproxy", "app_id", "ip", "port",
"secret")
@conn.add_method("remove_appserver_from_haproxy", "app_id", "ip", "port",
"secret")
@conn.add_method("add_appserver_process", "app_id", "secret")
@conn.add_method("remove_appserver_process", "app_id", "port", "secret")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(params)\n @ip_address = params[:ip_address]\n @port = params[:port]\n @keystone = params[:keystone]\n end",
"def initialize(user, password, application_name, host=\"192.168.0.8\", port=3790, mode='multiUser')\n @user = user\n @password = password\n @application_name = appl... | [
"0.66503626",
"0.65358144",
"0.6535395",
"0.6480533",
"0.64308",
"0.6396983",
"0.6384762",
"0.63621587",
"0.6292732",
"0.62678444",
"0.62308407",
"0.62217575",
"0.6219481",
"0.62122536",
"0.62012225",
"0.61954975",
"0.6175477",
"0.61457026",
"0.6129223",
"0.61158544",
"0.6096... | 0.6999236 | 0 |
Provides automatic retry logic for transient SOAP errors. Args: time: A Fixnum that indicates how long the timeout should be set to when executing the caller's block. retry_on_except: A boolean that indicates if nontransient Exceptions should result in the caller's block being retried or not. callr: A String that names the caller's method, used for debugging purposes. Raises: FailedNodeException: if the given block contacted a machine that is either not running or is rejecting connections. SystemExit: If a nontransient Exception was thrown when executing the given block. Returns: The result of the block that was executed, or nil if the timeout was exceeded. | def make_call(time, retry_on_except, callr)
refused_count = 0
max = 5
begin
Timeout::timeout(time) {
yield if block_given?
}
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
if refused_count > max
raise FailedNodeException.new("Connection was refused. Is the " +
"AppController running?")
else
refused_count += 1
Kernel.sleep(1)
retry
end
rescue Timeout::Error
Djinn.log_warn("[#{callr}] SOAP call to #{@ip} timed out")
return
rescue OpenSSL::SSL::SSLError, NotImplementedError, Errno::EPIPE,
Errno::ECONNRESET, SOAP::EmptyResponseError
retry
rescue Exception => except
if retry_on_except
retry
else
trace = except.backtrace.join("\n")
HelperFunctions.log_and_crash("[#{callr}] We saw an unexpected error" +
" of the type #{except.class} with the following message:\n" +
"#{except}, with trace: #{trace}")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_call(time, retry_on_except)\n begin\n Timeout::timeout(time) {\n yield if block_given?\n }\n rescue Errno::ECONNREFUSED\n if retry_on_except\n retry\n else\n abort(\"Connection was refused. Is the AppController running?\")\n end\n rescue OpenSSL::SSL:... | [
"0.7141372",
"0.7072266",
"0.61995095",
"0.61632055",
"0.5999939",
"0.5973251",
"0.5835871",
"0.5751888",
"0.5729174",
"0.56570053",
"0.56415325",
"0.55510527",
"0.54901165",
"0.54878",
"0.5485897",
"0.5440209",
"0.54388845",
"0.5421436",
"0.53913474",
"0.5365222",
"0.5322838... | 0.7846086 | 0 |
CGB removed timeout here removing cassandra slave requires it to port the data it owns to somebody else, which takes ~30 seconds in the trivial case | def remove_role(role)
make_call(NO_TIMEOUT, RETRY_ON_FAIL, "remove_role") { @conn.remove_role(role, @secret) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_zzz_shooting_the_other_slave_in_the_head\n $mysql_slave.set_rw(true)\n\n $mysql_slave_2.kill!\n $mysql_slave_2 = nil\n\n UserSlave.connection.reconnect!\n assert port_for_class(UserSlave) == $mysql_slave.port\n end",
"def test_AutoDeleteConnection\n Orocos.run \"port_proxy::Task\"... | [
"0.5972543",
"0.59585834",
"0.5902514",
"0.5902514",
"0.58843553",
"0.5870571",
"0.5870571",
"0.5870571",
"0.58668244",
"0.5797737",
"0.5778219",
"0.57594955",
"0.57062757",
"0.5645544",
"0.5642847",
"0.5621436",
"0.5552942",
"0.5549196",
"0.55490357",
"0.55472666",
"0.552893... | 0.0 | -1 |
Tells an AppController that it needs to restart one or more Google App Engine applications. Args: app_names: An Array of Strings, where each String is an appid corresponding to an application that needs to be restarted. | def set_apps_to_restart(app_names)
make_call(NO_TIMEOUT, RETRY_ON_FAIL, "set_apps_to_restart") {
@conn.set_apps_to_restart(app_names, @secret)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restart_appengine_apps\n # use a copy of @apps_to_restart here since we delete from it in\n # setup_appengine_application\n apps = @apps_to_restart\n apps.each { |app_name|\n if !my_node.is_login? # this node has the new app - don't erase it here\n Djinn.log_info(\"Removing old version... | [
"0.7103693",
"0.638339",
"0.63114",
"0.6247003",
"0.60410404",
"0.5946801",
"0.5723514",
"0.57176965",
"0.5648942",
"0.55736613",
"0.5540254",
"0.54087836",
"0.53502554",
"0.53469425",
"0.5303953",
"0.5221235",
"0.5207263",
"0.5165295",
"0.5155961",
"0.5124913",
"0.5098495",
... | 0.8250547 | 0 |
Tells an AppController to route HAProxy traffic to the given location. Args: app_id: A String that identifies the application that runs the new AppServer. ip: A String that identifies the private IP address where the new AppServer runs. port: A Fixnum that identifies the port where the new AppServer runs at ip. secret: A String that is used to authenticate the caller. | def add_appserver_to_haproxy(app_id, ip, port)
make_call(NO_TIMEOUT, RETRY_ON_FAIL, "add_appserver_to_haproxy") {
@conn.add_appserver_to_haproxy(app_id, ip, port, @secret)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_appserver_to_haproxy(app_id, ip, port, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n if !my_node.is_login?\n return NO_HAPROXY_PRESENT\n end\n\n if @app_info_map[app_id].nil? or @app_info_map[app_id]['appengine'].nil?\n return NOT_READY\n end\n\n ... | [
"0.74140364",
"0.6662897",
"0.6137745",
"0.6115657",
"0.5505296",
"0.5479909",
"0.4881991",
"0.4703085",
"0.4611078",
"0.45304093",
"0.4441691",
"0.4434111",
"0.44225985",
"0.44195324",
"0.44084364",
"0.4382441",
"0.4379882",
"0.43702993",
"0.43689358",
"0.4365874",
"0.436043... | 0.6581175 | 2 |
Tells an AppController to no longer route HAProxy traffic to the given location. Args: app_id: A String that identifies the application that runs the AppServer to remove. ip: A String that identifies the private IP address where the AppServer to remove runs. port: A Fixnum that identifies the port where the AppServer was running. secret: A String that is used to authenticate the caller. | def remove_appserver_from_haproxy(app_id, ip, port)
make_call(NO_TIMEOUT, RETRY_ON_FAIL, "remove_appserver_from_haproxy") {
@conn.remove_appserver_from_haproxy(app_id, ip, port, @secret)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_appserver_from_haproxy(app_id, ip, port, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n if !my_node.is_login?\n return NO_HAPROXY_PRESENT\n end\n\n Djinn.log_debug(\"Removing AppServer for app #{app_id} at #{ip}:#{port}\")\n get_scaling_info_for_app(app... | [
"0.8289475",
"0.7399267",
"0.5790702",
"0.5787291",
"0.57453823",
"0.5711031",
"0.5699406",
"0.5597189",
"0.55916697",
"0.5579129",
"0.5542733",
"0.53383416",
"0.5310369",
"0.5241229",
"0.52137506",
"0.5170206",
"0.51689225",
"0.5160986",
"0.514857",
"0.51254684",
"0.5103936"... | 0.75486976 | 1 |
class variable, scope: class/ anywhere inside of the key words class and end when does initialize get invoked? .new | def initialize(name, age)
@name = name # instance variable, scope: the instance or instance methods
@age = age
save
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class() end",
"def class_variables() end",
"def k_class!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n\n\n type = K_CLASS\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule bl... | [
"0.69177485",
"0.6588786",
"0.6528795",
"0.6454361",
"0.63795733",
"0.63178575",
"0.62983644",
"0.62662154",
"0.62662154",
"0.62662154",
"0.62662154",
"0.62662154",
"0.6264493",
"0.61727667",
"0.6149869",
"0.6146028",
"0.6146028",
"0.6146028",
"0.6146028",
"0.6146028",
"0.614... | 0.0 | -1 |
Show the help/usage message for create. | def usage
puts <<-USAGE
Usage: k9 create <sketch_to_generate> <width> <height> <mode>
mode can be P2D / P3D.
Use --wrap for a sketch wrapped as a class
Use --inner to generated a ruby version of 'java' Inner class
Examples: k9 create app 800 600
k9 create app 800 600 p3d --wrap
k9 create inner_class --inner
USAGE
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_command_help\n puts \"The Ruby Farm - a simple command line animals app\"\n puts\n puts \"Command Usage:\"\n puts \" [create | c] <name=> <type=> creates a animal with name\"\n puts \"\"\n puts \"Examples:\"\n puts \" bin/run [create | c] name=m... | [
"0.72730035",
"0.7071494",
"0.6884468",
"0.6884468",
"0.66499895",
"0.66361403",
"0.65828145",
"0.657463",
"0.65439194",
"0.6534885",
"0.6514648",
"0.6481953",
"0.647876",
"0.6472638",
"0.6472638",
"0.6472638",
"0.6472638",
"0.6472638",
"0.6472638",
"0.6472638",
"0.64618206",... | 0.0 | -1 |
Create a class wrapped sketch, given a path. | def create!(path, args)
return usage if /\?/ =~ path || /--help/ =~ path
main_file = File.basename(path, '.rb') # allow uneeded extension input
# Check to make sure that the main file doesn't exist already
already_exist(path)
@name = StringExtra.new(main_file).camelize
writer = SketchWriter.new(main_file)
@title = StringExtra.new(main_file).titleize
@width, @height = args[0], args[1]
@mode = args[2].upcase unless args[2].nil?
template = @mode.nil? ? class_template : class_template_mode
writer.save(template)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(sketch, args)\n require_relative '../jruby_art/creators/creator'\n return Processing::Inner.new.create!(sketch, args) if @options.inner\n return Processing::ClassSketch.new.create!(sketch, args) if @options.wrap\n return Processing::EmacsSketch.new.create!(sketch, args) if @options.e... | [
"0.6735142",
"0.66171384",
"0.6489489",
"0.61388654",
"0.612821",
"0.59372514",
"0.59039336",
"0.56536794",
"0.5604674",
"0.56000274",
"0.55354565",
"0.5443351",
"0.5440257",
"0.5440257",
"0.5440257",
"0.5440257",
"0.5440257",
"0.5438229",
"0.5413889",
"0.5399615",
"0.5392014... | 0.6114507 | 5 |
Create a class wrapped sketch, given a path. | def create!(path, args)
return usage if /\?/ =~ path || /--help/ =~ path
main_file = File.basename(path, '.rb') # allow uneeded extension input
# Check to make sure that the main file doesn't exist already
already_exist(path)
@name = StringExtra.new(main_file).camelize
writer = SketchWriter.new(main_file)
@title = StringExtra.new(main_file).titleize
@width, @height = args[0], args[1]
@mode = args[2].upcase unless args[2].nil?
template = @mode.nil? ? emacs_template : emacs_template_mode
writer.save(template)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(sketch, args)\n require_relative '../jruby_art/creators/creator'\n return Processing::Inner.new.create!(sketch, args) if @options.inner\n return Processing::ClassSketch.new.create!(sketch, args) if @options.wrap\n return Processing::EmacsSketch.new.create!(sketch, args) if @options.e... | [
"0.6735142",
"0.66171384",
"0.6489489",
"0.61388654",
"0.612821",
"0.6114507",
"0.59372514",
"0.59039336",
"0.56536794",
"0.5604674",
"0.56000274",
"0.55354565",
"0.5443351",
"0.5440257",
"0.5440257",
"0.5440257",
"0.5440257",
"0.5440257",
"0.5438229",
"0.5413889",
"0.5399615... | 0.5299008 | 34 |
Create a pseudo inner class, given a path. | def create!(path, _args_)
return usage if /\?/ =~ path || /--help/ =~ path
main_file = File.basename(path, '.rb') # allow uneeded extension input
# Check to make sure that the main file doesn't exist already
already_exist(path)
@name = main_file.camelize
writer = SketchWriter.new(main_file)
template = inner_class_template
writer.save(template)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_for_path(path)\n path.split('::').inject(Kernel) do |scope, const_name|\n scope.const_get(const_name)\n end\n end",
"def class_for_path(path)\n path.split('::').inject(Kernel) do |scope, const_name|\n scope.const_get(const_name)\n ... | [
"0.58968693",
"0.57687265",
"0.57687265",
"0.55687",
"0.5541463",
"0.55337864",
"0.55337006",
"0.54565966",
"0.5426788",
"0.54192394",
"0.54019046",
"0.5358899",
"0.53290474",
"0.5270519",
"0.5238316",
"0.52199066",
"0.51956886",
"0.5191452",
"0.5188868",
"0.5182477",
"0.5170... | 0.52311194 | 15 |
creates a audit log record instance that each method model will use | def initialize_audit_log
# only save logs for POST,PUT,PATCH and DELETE methods
# creates
if (request.post? || request.patch? || request.put? || request.delete? )
@audit_log = AuditLog.new
@audit_log.ip = request.remote_ip
@audit_log.user_name = current_user.full_name
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audit_log\n AuditLog.new(space_id, store_id)\n end",
"def build_created_audit(rec, eh)\n build_audit_payload(rec, eh[:new], nil, \"#{rec.class.to_s.downcase}_record_add\", \"Record created\")\n end",
"def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_e... | [
"0.7297494",
"0.70551753",
"0.7006811",
"0.68369746",
"0.6808096",
"0.6797971",
"0.6742281",
"0.67354566",
"0.6696821",
"0.6581385",
"0.6576137",
"0.6565416",
"0.6540325",
"0.652979",
"0.64371985",
"0.63804054",
"0.63773644",
"0.63701457",
"0.63411784",
"0.63338846",
"0.63052... | 0.707178 | 1 |
saves the initialzied audit log | def save_audit_log
if (@audit_log && @audit_log.auditable)
if ["update","destroy"].include?(action_name)
update_and_destroy_audit
elsif action_name == "create"
create_audit
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_with_auditing\n with_auditing { save }\n end",
"def initialize_audit_log\n # only save logs for POST,PUT,PATCH and DELETE methods\n # creates\n if (request.post? || request.patch? || request.put? || request.delete? )\n @audit_log = AuditLog.new\n @audit_log.ip = request.re... | [
"0.6781204",
"0.6777003",
"0.65401375",
"0.65389395",
"0.6495411",
"0.6422484",
"0.6408047",
"0.6390071",
"0.636754",
"0.6296661",
"0.6294444",
"0.62675506",
"0.6263227",
"0.6200449",
"0.6181618",
"0.6155426",
"0.6144565",
"0.6141821",
"0.6105673",
"0.60847324",
"0.607508",
... | 0.7843606 | 0 |
Chunks and unused space | def initialize(file_path)
@file_path = file_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def free_chunks(grid)\n grid.flat_map do |row|\n row.chunk(&:free?).select(&:first).map(&:last)\n end\n end",
"def ignore_bad_chunking; end",
"def ignore_bad_chunking; end",
"def validate_parts_full_chunks!(grid_infos)\n grid_infos.each do |grid_info|\n if grid_inf... | [
"0.6403653",
"0.6382119",
"0.6382119",
"0.6279755",
"0.6247524",
"0.6159419",
"0.6159419",
"0.5998616",
"0.5986671",
"0.595625",
"0.58674055",
"0.58674055",
"0.58674055",
"0.58408815",
"0.57547206",
"0.574756",
"0.574756",
"0.5744059",
"0.5722478",
"0.5719607",
"0.5655667",
... | 0.0 | -1 |
Parse locations of chunks Offset: bytes 0 2 Sectors: byte 3 Empty offset, is an empty chunk | def locations
@locations ||= bytes(L_BYTES).each_slice(4).map do |loc_bytes|
{
offset: ByteArray.to_i(loc_bytes[0..2]),
sector_count: loc_bytes[3]
}
end.reject{ |l| l[:offset] == 0 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_line_and_column_from_chunk(offset)\n if offset.zero?\n return [@chunk_line, @chunk_column]\n end\n\n string =\n offset >= @chunk.size ? @chunk : @chunk[0..offset-1]\n\n line_count = string.count(\"\\n\")\n\n column = @chunk_column\n if line_count > 0\n lines = string.split(... | [
"0.606822",
"0.5671967",
"0.5565513",
"0.5539293",
"0.54782075",
"0.546624",
"0.5439181",
"0.54218227",
"0.5415949",
"0.5408346",
"0.5375469",
"0.53612405",
"0.53612405",
"0.5359969",
"0.53538597",
"0.5352803",
"0.53192264",
"0.53177345",
"0.5305644",
"0.5294771",
"0.5294771"... | 0.66109675 | 0 |
Timestamps are 4 bytes read with Timeat | def timestamps
@timestamps ||= bytes[T_BYTES].each_slice(4).map do |t_bytes|
ByteArray.to_i(t_bytes)
end.reject{ |t| t == 0 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamp(time)\n date = @file[/(\\w+ \\d+, \\d+)/]\n ASF::Board::TIMEZONE.parse(\"#{date} #{time}\").to_i * 1000\n end",
"def load_timestamp(fname)\n stamps = []\n File.open(fname).read().each_line do |line|\n parsed = line.strip().split() \n stamps << [parsed[2].to_f, parsed[3].to_f, parsed[... | [
"0.646188",
"0.6248137",
"0.6183079",
"0.6069663",
"0.59347457",
"0.59249425",
"0.58973867",
"0.5881721",
"0.588112",
"0.587202",
"0.5859514",
"0.5834923",
"0.5815452",
"0.5792059",
"0.5770045",
"0.57601553",
"0.57601553",
"0.57601553",
"0.57601553",
"0.57601553",
"0.57601553... | 0.74335706 | 0 |
| 0 3 | 4 | 5... | | length (in bytes) | compression type | compressed data (length1 bytes) | Compression types: "GZip (RFC1952)" : 1 "Zlib (RFC1950)" : 2 | def chunk(location)
offset = C_BYTES + location[:offset]
offset = location[:offset] * (1024 * 4) # 4KiB
chunk_length = ByteArray.to_i(bytes(offset..(offset + 3)))
compression_type = bytes(offset + 4) == [1] ? :gzip : :zlib
compressed_nbt = chars((offset + 5)..(offset + 5 + chunk_length))
raise "Can't uncompress chunk in GZip format" if compression_type == :gzip
return nil if offset == 0 # Not created
Chunk.new(
nbt: Nbt::parse(Zlib::Inflate.inflate(compressed_nbt)),
offset: location[:offset],
byte_offset: offset,
chunk_length: chunk_length,
compression_type: compression_type,
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compression_method; end",
"def compressed_size; end",
"def compressed_size; end",
"def compression_level; end",
"def compressed_size=(_arg0); end",
"def compression; end",
"def decompressed_size; end",
"def compression?; end",
"def default_compression; end",
"def compression_client; end",
"... | [
"0.75652003",
"0.7453638",
"0.7453638",
"0.7440101",
"0.72507614",
"0.72428846",
"0.7148686",
"0.7057147",
"0.70392585",
"0.6931968",
"0.6845821",
"0.682849",
"0.68223125",
"0.6750421",
"0.6686679",
"0.66749305",
"0.6472168",
"0.6441768",
"0.64168423",
"0.63894504",
"0.637750... | 0.0 | -1 |
=============================================== Don't load everything into memory, that's crazy | def bytes(range)
range = (range..range) if range.is_a?(Integer)
file = File.open(@file_path, 'rb')
file.pos = range.first
_bytes = []
range.size.times do
_bytes << file.readbyte
end
file.close
_bytes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_all; end",
"def load_all; end",
"def load_all; end",
"def load; end",
"def load; end",
"def load; end",
"def load!; end",
"def load\r\n \r\n end",
"def memos; end",
"def memos; end",
"def preload; end",
"def preload; end",
"def in_memory\n []\n end",
"def in_memory\n ... | [
"0.71519357",
"0.71519357",
"0.71519357",
"0.6810302",
"0.6810302",
"0.6810302",
"0.67248523",
"0.64359254",
"0.63906217",
"0.63906217",
"0.62049955",
"0.62049955",
"0.6193855",
"0.6193855",
"0.6137165",
"0.6092359",
"0.6076829",
"0.6067026",
"0.6067026",
"0.6052227",
"0.6040... | 0.0 | -1 |
Load up some chars from the file | def chars(range)
range = (range..range) if range.is_a?(Integer)
file = File.open(@file_path, 'r')
file.pos = range.first
_chars = ""
loop do
_chars << file.readchar
break if file.pos >= range.last
end
file.close
_chars
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_file(file)\n file_lines_array = File.readlines(file)\n file_characters_array = []\n file_lines_array.each do |line|\n file_characters_array << line\n end\n file_characters_array.map! do |character|\n character = @dictionary[character]\n end\n morse_code = file_characters_arr... | [
"0.684253",
"0.6768453",
"0.65269077",
"0.6445389",
"0.64031976",
"0.62625116",
"0.6199827",
"0.6198277",
"0.6142762",
"0.6142762",
"0.6078673",
"0.6052096",
"0.604999",
"0.60332793",
"0.60149586",
"0.60149586",
"0.600913",
"0.6007527",
"0.59871703",
"0.5974103",
"0.5916036",... | 0.5787247 | 29 |
////////////////////////////////////////////////////////////////////////// Properties ////////////////////////////////////////////////////////////////////////// Get icon_index of the element GET | def icon_index()
return CORE_CONFIG::ELEMENT_ICONS[self.id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def icon\n self.number\n end",
"def icon_index(item)\n return $data_items[item.item_id].icon_index if item.item?\n return ($data_items.find { |i| !i.nil? && i.subtype_id == item.category_id}).icon_index if item.category?\n end",
"def icon_index(level = @skl_level)\n return @skl_levelcache[level][... | [
"0.7523847",
"0.7255705",
"0.72204465",
"0.7114549",
"0.70309913",
"0.701399",
"0.68072164",
"0.6746772",
"0.66348696",
"0.6561145",
"0.6408674",
"0.6346601",
"0.63315576",
"0.63032377",
"0.6242245",
"0.61814386",
"0.6108079",
"0.60693747",
"0.60654444",
"0.6059303",
"0.60317... | 0.8290366 | 0 |
////////////////////////////////////////////////////////////////////////// Constructors ////////////////////////////////////////////////////////////////////////// Object Initialization | def initialize
@id = 0
@name = ""
@icon_index = 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n \n end",
"def initialize\r\n\r\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initial... | [
"0.8748141",
"0.86548895",
"0.86400115",
"0.86400115",
"0.86400115",
"0.86400115",
"0.86400115",
"0.86400115",
"0.86400115",
"0.86400115",
"0.86400115",
"0.8604853",
"0.858883",
"0.8567256",
"0.8560972",
"0.8560972",
"0.8560972",
"0.8560972",
"0.8560972",
"0.8560972",
"0.8548... | 0.0 | -1 |
Return a PORO that represents this program (for unit tests) | def serialize
{
class: 'Program',
sk_classes: @sk_classes.transform_values(&:serialize),
sk_main: @sk_main.serialize,
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def program\n @@program ||= ATP::Program.new\n end",
"def program\n @@program ||= ATP::Program.new\n end",
"def main\n @app.main\n end",
"def main\n self\n end",
"def new\n @programa = Programa.new\n end",
"def main\n @workspace.main\n end",
"def app\n TicTacT... | [
"0.6249059",
"0.6249059",
"0.6030349",
"0.5853819",
"0.58456194",
"0.5844979",
"0.58396834",
"0.58163434",
"0.5795005",
"0.5709735",
"0.56958",
"0.5665033",
"0.5659486",
"0.5644278",
"0.56155944",
"0.5573469",
"0.5528559",
"0.5522893",
"0.5512547",
"0.5483886",
"0.54835254",
... | 0.0 | -1 |
========================= paul fitz & meads | def first_pos(string)
answer = Hash.new
array = string.split(' ')
array.each do |x|
answer[x] = array.index(x)
end
answer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def malts; end",
"def fit; end",
"def imc \n\t\t@peso/(@talla*@talla)\n\tend",
"def schumann; end",
"def terpene; end",
"def berlioz; end",
"def suivre; end",
"def grasa\n\t\t1.2*imc+0.23*@edad-10.8*@sexo-5.4\n\tend",
"def porcentajegrasa\n\t\t1.2 * imc + 0.23 * @edad - 10.8 * @sexo - 5.4\n\tend",
... | [
"0.6288731",
"0.62502736",
"0.58415574",
"0.57874984",
"0.575387",
"0.57349586",
"0.57138306",
"0.56833225",
"0.56829965",
"0.56572175",
"0.5634504",
"0.5565182",
"0.55556655",
"0.55450606",
"0.55200726",
"0.5499125",
"0.5497195",
"0.5491538",
"0.547041",
"0.54681545",
"0.544... | 0.0 | -1 |
GET /articles GET /articles.json | def index
@articles = Article.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def articles\n @articles = Article.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end",
"def index\n @articles = Article.all\n\n respond_to do |format|\n format.json { render json: @articles }\n end\n end",
... | [
"0.7823242",
"0.7757662",
"0.77491444",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7612499",
"0.75499934",
"0.744125",
"0.73619306",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
... | 0.677967 | 78 |
GET /articles/1 GET /articles/1.json | def show
respond_to do |format|
format.html { render locals: { article: @article } }
format.epub { send_ebook({ article: @article }, :epub, "#{@article.slug}.epub") }
format.mobi { send_ebook({ article: @article }, :mobi, "#{@article.slug}.mobi") }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @article = Article.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articles }\n end\n end",
"def show\n @article = Article.where(id: params[:id]).last\n\n respond_to do |format|\n format.html # show.html.er... | [
"0.7745946",
"0.75169533",
"0.7514653",
"0.7483779",
"0.74794465",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.7427753",
... | 0.0 | -1 |
POST /articles POST /articles.json | def create
@article = Article.new(article_params)
response = RestClient.get 'http://scraper:3000/api/get', { params: { url: @article.url } }
scraped_article = JSON.parse(response.body)
@article.update({
:title => scraped_article['title'],
:byline => scraped_article['byline'],
:excerpt => scraped_article['excerpt'],
:content_html => scraped_article['content'],
:readerable => scraped_article['readerable'],
:scraped_at => DateTime.now
})
respond_to do |format|
if @article.save
format.html { redirect_to @article, notice: 'Article was successfully created.' }
format.json { render :show, status: :created, location: @article }
else
format.html { render :new }
format.json { render json: @article.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @article = Article.new(params[:article])\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, :notice => 'Article was successfully created.' }\n format.json { render :json => @article, :status => :created, :location => @article }\n else\n ... | [
"0.71525854",
"0.7089459",
"0.7089459",
"0.7089459",
"0.7089459",
"0.7089459",
"0.7089459",
"0.7089459",
"0.7089459",
"0.7083744",
"0.70643014",
"0.7055016",
"0.7055016",
"0.7055016",
"0.7055016",
"0.7055016",
"0.7055016",
"0.7055016",
"0.7055016",
"0.7055016",
"0.7055016",
... | 0.6677905 | 47 |
PATCH/PUT /articles/1 PATCH/PUT /articles/1.json | def update
respond_to do |format|
if @article.update(article_params)
format.html { redirect_to @article, notice: 'Article was successfully updated.' }
format.json { render :show, status: :ok, location: @article }
else
format.html { render :edit }
format.json { render json: @article.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @article = article_get(params[:id])\n @article.update(params[:article])\n respond_with(@article)\n end",
"def UpdateArticle id,params = {}\n \n APICall(path: \"help_center/articles/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @... | [
"0.6822808",
"0.67426866",
"0.6710149",
"0.67066306",
"0.66805017",
"0.6678203",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.6654977",
"0.6643167",
"0.6633079",
"0.6614886",
"0.... | 0.6374309 | 59 |
DELETE /articles/1 DELETE /articles/1.json | def destroy
@article.destroy
respond_to do |format|
format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @article = Article.find(params[:id]) \n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to articles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @article = Article.where(id: params[:id]).last\n @article.destroy\n\n res... | [
"0.7844117",
"0.7832465",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
... | 0.7506414 | 79 |
Use callbacks to share common setup or constraints between actions. | def set_article
@article = Article.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 article_params
params.require(:article).permit(:url, :title, :byline, :excerpt, :readerable, :scraped_at, :content_html)
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.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
Allows for purchasing a product. Creates a new transaction with the proper data if the product is in stock. Takes a product and a date argument. The date can be passed as string "20160525" or as a date value type. The date defaults to today's date. | def purchase(product, date = Date.today)
date = date.is_a?(String) ? Date.parse(date) : date
if product.in_stock?
Transaction.new(self, product, date)
else
raise OutOfStockError, "'#{product.title}' is out of stock."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def purchase(product)\n \t\tif product.in_stock?\n \t\t\tTransaction.new(self, product)\n \t\telse\n \t\t\traise OutOfStockError, \"#{product.title} is out of stock\"\n \t\tend\n \tend",
"def create_cart_product_for_new_product(product)\n cp = cart_products.create\n cp.product = product\n cp.quant... | [
"0.7721127",
"0.6255211",
"0.6175181",
"0.6087245",
"0.5956929",
"0.59548867",
"0.58961296",
"0.58674425",
"0.5854622",
"0.585424",
"0.5722002",
"0.5697451",
"0.56728494",
"0.56639904",
"0.5653883",
"0.56465626",
"0.56376",
"0.5628084",
"0.56279325",
"0.56273425",
"0.5623776"... | 0.8818048 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.