query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
DELETE /accession_location_entries/1 DELETE /accession_location_entries/1.json | def destroy
@accession_location_entry = AccessionLocationEntry.find(params[:id])
@accession_location_entry.destroy
respond_to do |format|
format.html { redirect_to accession_location_entries_url }
format.json { head :no_content }
end
end | [
"def destroy\n @collection_location_entry = CollectionLocationEntry.find(params[:id])\n @collection_location_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_location_entries_url }\n format.json { head :no_content }\n end\n end",
"def delete_location(id)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Require attribute to be set. Return attribute value. | def require_attr(name)
send(name).tap do |_|
raise AttributeError, "Attribute must be set: #{name}" if _.nil?
end
end | [
"def require_attr(name)\n send(name).tap do |_|\n raise \"Attribute must be set: #{name}\" if _.nil?\n end\n end",
"def require_attr(name)\n send(name).tap do |_|\n if _.respond_to?(:body)\n raise AttributeError, \"Attribute must be set: #{name}\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A bigram is a pair of consecutive words. Given a string, return the longest bigram in that string. Include the space between the words. Assume there will be no punctuation. In the case of a tie, return the earlier bigram. | def longest_bigram(str)
bigram_hash = Hash.new
bigram_str = str.split(" ")
bigram_str.each_with_index do |word, i|
if i == bigram_str.length - 1
next
else
bigram_hash[word + " " + bigram_str[i + 1]] = (word + " " + bigram_str[i + 1]).length
end
end
temp_str = ""
temp_str_length = 0
... | [
"def longest_bigram(sentence)\n sentence_array = Array.new\n sentence.split(\" \").each_index do |idx|\n if idx != sentence.split(\" \").length - 1\n sentence_array.push(sentence.split(\" \")[idx] + \" \" + sentence.split(\" \")[idx + 1])\n end\n end\n # find longest Bigram\n bigram_length = 0\n bi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve one API Secret. | def get(secret_id)
request('/accounts/' + account_id + '/secrets/' + secret_id)
end | [
"def get_secret(secret_name, vault_name, resource_group = configuration.resource_group)\n url = build_url(resource_group, vault_name, 'secrets', secret_name)\n model_class.new(rest_get(url))\n end",
"def secretkey(apikey)\n get 'secretkey', {apikey: apikey} { |x| x['secretkey'] }\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Revoke an API Secret. | def revoke(secret_id)
request('/accounts/' + account_id + '/secrets/' + secret_id, type: Delete)
end | [
"def revoke\n post('/api/revoke')\n end",
"def revoke_token\n prepare_and_invoke_api_call 'auth/v1/keys/token', :method=>:delete\n @api_token = nil\n end",
"def revoke\n @auth.revoke(@access)\n @access = nil\n end",
"def revoke\n Lib.keyctl_revoke id\n self\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Execute the statement. This creates a new ResultSet object for the statement's virtual machine. If a block was given, the new ResultSet will be yielded to it; otherwise, the ResultSet will be returned. Any parameters will be bound to the statement using bind_params. Example: stmt = db.prepare( "select from table" ) stm... | def execute( *bind_vars )
reset! if active? || done?
bind_params(*bind_vars) unless bind_vars.empty?
@results = ResultSet.new(@connection, self)
step if 0 == column_count
yield @results if block_given?
@results
end | [
"def execute( *bind_vars )\n bind_params *bind_vars unless bind_vars.empty?\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Performs a sanity check to ensure that the statement is not closed. If it is, an exception is raised. | def must_be_open! # :nodoc:
if closed?
raise Thredis::Exception, "cannot use a closed statement"
end
end | [
"def must_be_open! # :nodoc:\n if @closed\n raise SQLite3::Exception, \"cannot use a closed statement\"\n end\n end",
"def must_be_open! # :nodoc:\n if closed?\n raise SQLite3::Exception, \"cannot use a closed statement\"\n end\n end",
"def check_statement(stmt)\n ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Adds a Line and returns it. Also sets the parent on the line and for simplicity adds the current_line number. Returns the line that was added. | def add_line(line)
@lines << line
line
end | [
"def add(context, line)\n\t\t\t@lines << @line.new(context, line)\n\t\tend",
"def add_line(al)\n @asset_location_lines.add al.merge!({parent: self.asset_location_lines})\n end",
"def add_line\n @layout.add_widget(HLine.new)\n end",
"def add_line(line)\n\t\t@lines << line\n\tend",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Given an array of parsed blocks, converts the properties within the blocks into a single hash. Returns a hash. | def blocks_to_hash(blocks)
blocks.each_with_object({}) do |block, hash|
hash.merge!(block.to_hash)
end
end | [
"def object_properties_hash\n h = {}\n File.readlines(File.join(@path, CONFIG.dig('bag', 'item', 'object_properties_file'))).each do |line|\n key, *rest = line.split(' ')\n h[key] = rest.map { |e| e.split(',') }.flatten\n end\n h\n end",
"def to_hash(prop_headings)\n h = {\n man... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write encoded record to the handle | def write(record)
@fh.puts(encode(record))
self
end | [
"def write(record)\n @fh.write(self.class.encode(record))\n end",
"def write(record)\n @fh.write(MARC::Writer.encode(record))\n end",
"def write(handle, offset, data); end",
"def writeencoding; end",
"def write(record)\n @worker.enqueue record\n end",
"def _write(obj)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
combine bishop and rook for queen moves | def bishop_moves(x, y, game)
own_spaces = game[game[:turn]].keys
opponent_spaces = game[@opp_turn[game[:turn]]].keys
moves = []
# up right
temp_x = x + 1
temp_y = y + 1
while temp_x < 5 && temp_y < 5 && !own_spaces.include?([temp_x, temp_y])
moves.push([temp_x, temp_y])
break if opponent_spaces.in... | [
"def moves_queen(color, a, b)\n\t\t_moves = []\n\t\t(continue_left(color, a, b)).each{|move| _moves << move}\n\t\t(continue_right(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up(color, a, b)).each{|move| _moves << move}\n\t\t(continue_down(color, a, b)).each{|move| _moves << move}\n\t\t(continue_up_left... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
need to order through the hash according to the assigned key in the point_values method hash | def point_values
{
"A"=>1, "B"=>3, "C"=>3, "D"=>2,
"E"=>1, "F"=>4, "G"=>2, "H"=>4,
"I"=>1, "J"=>8, "K"=>5, "L"=>1,
"M"=>3, "N"=>1, "O"=>1, "P"=>3,
"Q"=>10, "R"=>1, "S"=>1, "T"=>1,
"U"=>1, "V"=>4, "W"=>4, "X"=>8,
"Y"=>4, "Z"=>10
}
end | [
"def hash_point(point)\n @group.generator * hash_array(point.coords)\n end",
"def ordered_teachers_hash\n @teachers_hash = @teachers_hash.sort_by { |teacher_name, points| points }.reverse.to_h\n # puts \"xxx\"\n # p teachers_hash\n end",
"def in_order_of(key, series); end",
"def point_keys\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
multiply that sum by the provided 3rd argument multiplier | def multiply_sum_by_3rd_argument
end | [
"def mult(*args)\n\tprod = 1\n\targs.each do |arg|\n\t\tprod *= arg\n\tend\n\tprod\nend",
"def mult_then_add(n_1, n_2, n_3)\n\tn_1 * n_2 + n_3\nend",
"def mul(*args)\n\t\targs.inject(:*)\n\tend",
"def multiply\n match '*'\n factor\n emit_ln 'MULS (SP)+,D0'\nend",
"def mod_mul(p0, p1) end",
"def Multipl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
directories and files from /home/account_name/www/project_name folder (using ex. FileZilla) but it left some folders with symlinks, such as: www ` project_name | current > /home/account_name/www/project_name/releases/20131014083207 ` releases | 20131014081055 | | log > /home/account_name/www/project_name/shared/log | |... | def cleanup
# ----------------------------------------------
account_name = 'your account name' # <-- change this!
project_name = 'your project name' # <-- change this!
# ----------------------------------------------
project_dir = "/home/#{account_name}/www"
Dir.chdir(project_dir)
Dir.entries(project_... | [
"def tidy_up\n return if DEBUG\n\n puts heading(\"Tidying up PWD\")\n\n FileUtils.remove(Dir[\"#{FileUtils.pwd}/bugsnag-*.tgz\"])\nend",
"def remove_dead_symlinks\n base_paths.each do |path|\n command = \"find #{path} -xtype l -delete\"\n Pkg::Util::Net.remote_execute(Pkg::Config.staging_server, c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an erased flash. | def createflashimage
flashdata = "\xff" * FLASHSIZE
Flashimage.write(flashdata)
end | [
"def initialize_flash_types\n flash.clear\n end",
"def flash_destroyed_message\n flash_message_builder(:destroy, flash_status_type, 'destroyed')\n end",
"def keep_flash\n @keep_flash = true\n end",
"def flash_clear\n flash.clear\n end",
"def _roda_after_40__flash(_)\n if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Split flash image in partitions. | def splitflashimage
flashdata = Flashimage.read
size = flashdata.size
puts("Flash image size: #{size / MiB} MiB = #{size} B.")
raise('Flash size is unexpected.') if (size != FLASHSIZE)
baseaddress = PARTITIONS['boot'][START]
PARTITIONS.each { |label, partition|
first = partition[START] - baseaddress
last = fi... | [
"def mergepartitions\n\tflashdata = \"\\xff\" * FLASHSIZE\n\tbaseaddress = PARTITIONS['boot'][START]\n\tPARTITIONS.each { |label, partition|\n\t\tfirst = partition[START] - baseaddress\n\t\tlast = first + partition[SIZE]\n\t\tfilename = \"#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}\"\n\t\tpartdata = Flashimage.r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make flash image from partitions. | def mergepartitions
flashdata = "\xff" * FLASHSIZE
baseaddress = PARTITIONS['boot'][START]
PARTITIONS.each { |label, partition|
first = partition[START] - baseaddress
last = first + partition[SIZE]
filename = "#{File.dirname(FLASHIMAGE)}/#{partition[FILE]}"
partdata = Flashimage.read(filename)
size = partd... | [
"def splitflashimage\n\tflashdata = Flashimage.read\n\tsize = flashdata.size\n\tputs(\"Flash image size: #{size / MiB} MiB = #{size} B.\")\n\traise('Flash size is unexpected.') if (size != FLASHSIZE)\n\tbaseaddress = PARTITIONS['boot'][START]\n\tPARTITIONS.each { |label, partition|\n\t\tfirst = partition[START] - b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Change partition (configuration, web or code). | def changepartition(partition, filename)
baseaddress = PARTITIONS['boot'][START]
size = partition[SIZE]
partdata = Flashimage.read(filename)
length = partdata.size
last = partition[SIZE]
raise('Input file too large.') if length + 12 > last
crc32 = Zlib.crc32(partdata)
partdata[length ... last - 12] = "\xff" * ... | [
"def setPartitionType(settings)\n settings = deep_copy(settings)\n tm = Storage.GetTargetMap\n settings = Builtins.maplist(settings) do |d|\n if Ops.get_symbol(d, \"type\", :x) == :CT_DISK\n mp = Ops.get_integer(\n tm,\n [Ops.get_string(d, \"device\", \"xxx\"), \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load partition file (code, web or configuration). | def loadpart(partname, filename)
flashimage = Flashimage.new
firmware = Flashimage.read(filename)
size = firmware.size
offset_signature = size - 10
signature = firmware[offset_signature .. -1]
puts("signature: #{signature.inspect}")
length, magic, crc32, offset = getblock(partname, firmware, offset_signature)
p... | [
"def getPartition(driveId, partitionIdx)\n currentDrive = getDrive(driveId)\n Builtins.y2milestone(\"Loaded drive '%1'\", currentDrive)\n AutoinstDrive.getPartition(currentDrive, partitionIdx)\n end",
"def load(path); end",
"def preload_firmware(filename, board_class=Boards::Basys2)\n\n #Co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load firmware file (code and web). | def loadfw(filename)
flashimage = Flashimage.new
firmware = Flashimage.read(filename)
size = firmware.size
offset_signature = size - 10
signature = firmware[offset_signature .. -1]
puts("signature: #{signature.inspect}")
length, magic, crc32, offset_code = getblock('code', firmware, offset_signature)
code = Par... | [
"def preload_firmware(filename, board_class=Boards::Basys2)\n\n #Compute the relative path to the specified piece of firmware...\n path = File.expand_path(\"#{FirmwarePath}/#{filename}.bit\", __FILE__)\n\n #... read the bitstream file at that path...\n bitfile = DataFormats::Bitstream.from_file(path)\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /boots/1 GET /boots/1.json | def show
@boot = Boot.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @boot }
end
end | [
"def show\n @boot_size = BootSize.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boot_size }\n end\n end",
"def index\n @boots = Boot.all\n end",
"def new\n @boot = Boot.new\n\n respond_to do |format|\n format.html # ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /boots/new GET /boots/new.json | def new
@boot = Boot.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @boot }
end
end | [
"def new\n @boot_size = BootSize.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boot_size }\n end\n end",
"def create\n @boot = Boot.new(boot_params)\n\n respond_to do |format|\n if @boot.save\n format.html { redirect_to @boot, notic... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /boots/1 PUT /boots/1.json | def update
@boot = Boot.find(params[:id])
respond_to do |format|
if @boot.update_attributes(params[:boot])
flash[:success] = "Updated successfully "
format.html { redirect_to boots_path, notice: 'Boot was successfully updated.' }
format.json { head :no_content }
else
... | [
"def update\n respond_to do |format|\n if @boot.update(boot_params)\n format.html { redirect_to @boot, notice: 'Boot was successfully updated.' }\n format.json { render :show, status: :ok, location: @boot }\n else\n format.html { render :edit }\n format.json { render json: @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /boots/1 DELETE /boots/1.json | def destroy
@boot = Boot.find(params[:id])
@boot.destroy
respond_to do |format|
flash[:success] = "Deleted successfully "
format.html { redirect_to boots_url }
format.json { head :no_content }
end
end | [
"def destroy\n @boot.destroy\n respond_to do |format|\n format.html { redirect_to boots_url, notice: 'Boot was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boot = Boot.find(params[:id])\n @boot.destroy\n\n respond_to do |format|\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /daw_promos GET /daw_promos.json | def index
@daw_promos = DawPromo.all
end | [
"def show\n @promocion = Promocion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @promocion }\n end\n end",
"def show\n @promocion = Promocion.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /daw_promos POST /daw_promos.json | def create
@daw_promo = DawPromo.new(daw_promo_params)
respond_to do |format|
if @daw_promo.save
format.html { redirect_to @daw_promo, notice: 'Daw promo was successfully created.' }
format.json { render :show, status: :created, location: @daw_promo }
else
format.html { rend... | [
"def create\n @daw_matricula_promo = DawMatriculaPromo.new(daw_matricula_promo_params)\n\n respond_to do |format|\n if @daw_matricula_promo.save\n format.html { redirect_to @daw_matricula_promo, notice: 'Daw matricula promo was successfully created.' }\n format.json { render :show, status: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove an attribute for the given key. | def delete(key)
removeAttribute(key.to_s)
end | [
"def delete_attribute(key)\n attr = @attributes.get_attribute(key)\n attr.remove unless attr.nil?\n end",
"def unset_attribute (key)\n OpenWFE.unset_attribute(@attributes, key)\n end",
"def removeAttribute(key)\n\t\tif hasAttribute(key)\n\t\t\t@attributes.delete(key)\n\t\t\treturn 1\n\t\tel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all the attribute names (keys) from the servlet request. like Hashkeys | def keys
getAttributeNames.to_a
end | [
"def attribute_keys\n @attributes.keys\n end",
"def attr_keys\n attributes.keys[0..-3]\n end",
"def attribute_names\n result = attribute_declarations.keys.collect{|sym| sym.to_s}\n end",
"def keys\n @attributes.keys\n end",
"def allattrs\n raise NotImplementedError, \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterate over every attribute name/value pair from the servlet request. like Hasheach | def each
getAttributeNames.each { |name| yield(name, getAttribute(name)) }
end | [
"def each\n if block_given?\n attribute_names.each {|a|\n attr_name,values = a,self[a]\n yield attr_name, values\n }\n end\n end",
"def each # :yields: attribute-name, data-values-array\n if block_given?\n attribute_names.each {|a|\n attr_name,values = a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all the attribute names (keys) from the session. like Hashkeys | def keys
getAttributeNames.to_a
end | [
"def keys\n @attributes.keys\n end",
"def attribute_keys\n @attributes.keys\n end",
"def attr_keys\n attributes.keys[0..-3]\n end",
"def attribute_names\n result = attribute_declarations.keys.collect{|sym| sym.to_s}\n end",
"def attr_keys\n\t\treturn attr_keys_in @current... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterate over every attribute name/value pair from the session. like Hasheach | def each
getAttributeNames.each { |name| yield(name, getAttribute(name)) }
end | [
"def each_attr_value # :yields: attr_name, attr_value\n values = _dump_data\n self.class.shadow_attrs.each_with_index do |attr, i|\n yield attr.var.to_s, values[i]\n end\n instance_variables.each do |ivar|\n yield ivar[1..-1], instance_variable_get(ivar)\n end\n end",
"def each_persisten... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
codewars kata: colour association | def colour_association(array)
array.map{|pair| Hash[pair.first, pair.last]}
end | [
"def vary_colors; end",
"def scan_for_colors; end",
"def colour_changer(key)\n @@colours = [key]\n end",
"def color_id; end",
"def insert_color_flip\n if @left.red? and @right.red?\n color_flip\n else\n self\n end\n end",
"def colour_graoh(colors, graph)\n graph.nodes.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
codewars kata: matrix addition | def matrixAddition(a, b)
c = [] << a << b
c.transpose.map{ |i| i.transpose }.map{ |s|
s.map{ |p| p.reduce(&:+)}}
end | [
"def matrix_addition(m1, m2)\n height = m1.length\n width = m1[0].length\n result = Array.new(height) { [0] * width }\n\n (0...height).each do |row|\n (0...width).each do |col|\n result[row][col] = m1[row][col] + m2[row][col]\n end\n end\n\n result\nend",
"def matrix_addition(matrx_1, matrx_2)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert a set into the search dictionary | def add_search_set( search_set, number_to_transpose = 0 )
@search_sets << Set.new( MiltonsMachine::Core::ForteSet.new(search_set).transpose_mod12(number_to_transpose) )
end | [
"def add_to_sets\n self[\"$addToSet\"] ||= {}\n end",
"def insert(val)\n return false if includes?(val)\n set[val] = true\n true\n end",
"def addSet(synset_id, nouns)\n\t\n\tif (synset_id > -1) && (!nouns.empty?) && (!@hash.has_key? synset_id) \n\t\t@hash[synset_id] = nouns\n\t\tre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run the rotation_analysis and print out the results | def run_rotation_analysis
initialize_run
rotate_group
print_summary
end | [
"def print_rotation_count\n @rotation_count += 1\n print \"\\r\\e#{@rotation_count} of #{@maximum_rotations} processed...\"\n $stdout.flush\n end",
"def test_correct_rotation\r\n actual_test([\"PLACE 0,0,SOUTH\",\r\n \"LEFT\",\r\n \"REPORT\"],\"0,0,EAST... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A recursive routine that rotates a group of voices in the horizontal matrix. If it is at depth, performs the final vertical analysis for the current rotations; otherwise, just calls itself to process the next group in the hierarchy. | def rotate_group( level = -1 )
level += 1
if level == 0 # First group always remains static
rotate_group(level) # Recursive call to process next group of rows
else
# Rotate each pitch to the right for each r... | [
"def run_rotation_analysis\n initialize_run\n rotate_group\n print_summary\n end",
"def rotate\n # Rotated room\n @rotated = Array.new(@height) do |l|\n Array.new(@width) do |c|\n nil\n end\n end\n \n @squares.each do |line|\n line.each do |sq|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Accumulate current permutation search result counts into the reports summary totals. For example: if the total column score was 9 for the current rotation of the rows, summary_totals[9] would be incremented to reflect that a matrix solution was found with score = 9 | def accumulate_summary_totals( score )
@summary_totals[score] ||= 0
@summary_totals[score] += 1
end | [
"def total_search_results(summary_details)\n total_count = 0\n\n summary_details.map do |sequence|\n total_count += sequence.matches.count\n end\n\n total_count\n end",
"def comp_add_total(view)\n row = {\n :col0 => \"<span class='cell-effort-driven cell-plain'>\" + _(\"Total Matches\")... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Print out a progress indicator of how many rotations / permutations have been processed and how many are remaining. | def print_rotation_count
@rotation_count += 1
print "\r\e#{@rotation_count} of #{@maximum_rotations} processed..."
$stdout.flush
end | [
"def print_progress_bar_finish\n puts(NL) unless amount_mutation_results.zero?\n end",
"def show_progress\n\t\t\t# bar_size is between 0 and 30\n finish_size = (((@top_card-12).to_f / (@deck.length-11).to_f) * 30).to_i\n\t\t\tremain_size = 30 - finish_size\n\t\t\tprint \"\\nProgress: \"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints a summary section for the entire report | def print_summary
puts "\n\nScore : # Instances\n" << ("=" * 19)
@summary_totals.each_with_index { |value, index| puts " %5d:%8d\n" % [index, value] unless value.nil? }
puts "\n** End of Report"
end | [
"def generate_summary_report\n Formatter.info 'Spec coverage summary:'\n\n puts ''\n\n `#{coverage_bin} report --root #{ coverage_root } text-summary #{ coverage_file }`.each_line do |line|\n puts line.sub(/\\n$/, '') if line =~ /\\)$/\n end\n\n puts ''\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a chromosome object | def chromosome(id=nil)
return if id.nil?
begin
self.chromosomes[id.intern]
rescue
end
end | [
"def get_chromosome\n self\n end",
"def copy\n Chromosome.new(map(&:copy))\n end",
"def find_chromosome(id)\n @chromosomes.select { |ch| ch.id == id }.first\n end",
"def chromosomes\n # Cache for performance\n if @chromosomes.nil?\n index() if not indexed?\n @chromoso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if a user is defined. | def user_defined?
!@user.nil? || !@user['userId'].nil?
end | [
"def user_in_system\n\t\t# seems risky, but will be caught by numericality validations and if this isn't here it blows up\n\t\t# my shoulda matchers in attendance_test.rb\n\t\treturn true if self.user_id.nil?\n\t\tuser_ids = User.all.map { |user| user.id }\n\t\tunless user_ids.include?(self.user_id)\n\t\t\terrors.a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /favorite_tweets POST /favorite_tweets.json | def create
@favorite_tweet = FavoriteTweet.new(favorite_tweet_params)
respond_to do |format|
if @favorite_tweet.save
format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully created.' }
format.json { render action: 'show', status: :created, location: @favorite_t... | [
"def create_favorite_tweet tweet\n response = client.favorite tweet.id\n if response.first.is_a? Twitter::Tweet\n FavoriteTweet.create tweet_id: tweet.id,\n tweeted_by_username: tweet.user.screen_name,\n tweeted_by_user_picture: tweet.user.p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /favorite_tweets/1 PATCH/PUT /favorite_tweets/1.json | def update
respond_to do |format|
if @favorite_tweet.update(favorite_tweet_params)
format.html { redirect_to @favorite_tweet, notice: 'Favorite tweet was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { ren... | [
"def update\n @favtweet = Favtweet.find(params[:id])\n\n respond_to do |format|\n if @favtweet.update_attributes(params[:favtweet])\n format.html { redirect_to @favtweet, notice: 'Favtweet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /favorite_tweets/1 DELETE /favorite_tweets/1.json | def destroy
TwitterSyncWorker.new.delete(session[:user_id], @favorite_tweet.id)
@favorite_tweet.destroy
respond_to do |format|
format.html { redirect_to request.referer }
format.json { head :no_content }
end
end | [
"def destroy\n @favtweet = Favtweet.find(params[:id])\n @favtweet.destroy\n\n respond_to do |format|\n format.html { redirect_to favtweets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n user = user_from_token\n user.tweets.destroy(params[:id])\n head :no_cont... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
jobs:stop JOB_ID Stop a running job. | def stop
job_id = shift_argument
unless job_id
error("Usage: mortar jobs:stop JOB_ID\nMust specify JOB_ID.")
end
response = api.stop_job(job_id).body
#TODO: jkarn - Once all servers have the additional message field we can remove this check.
if response['message'].nil?
display("S... | [
"def stop\n job_id = shift_argument\n unless job_id\n error(\"Usage: mortar jobs:stop JOB_ID\\nMust specify JOB_ID.\")\n end\n validate_arguments!\n\n response = api.stop_job(job_id).body \n\n #TODO: jkarn - Once all servers have the additional message field we can remove this check.\n if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /favourite_foods/1 GET /favourite_foods/1.json | def show
@favourite_food = FavouriteFood.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @favourite_food }
end
end | [
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n end",
"def index\n @favourites = Favourite.all\n render json: @favourites\n end",
"def index\n @favourite_foods = FavouriteFood.all\n end",
"def show\n render json: @favourites\n end",
"def show\n @favourite... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /favourite_foods/new GET /favourite_foods/new.json | def new
@favourite_food = FavouriteFood.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @favourite_food }
end
end | [
"def new\n @favourite = Favourite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @favourite }\n end\n end",
"def new\n @fav = Fav.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fav }\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /favourite_foods/1 PUT /favourite_foods/1.json | def update
@favourite_food = FavouriteFood.find(params[:id])
respond_to do |format|
if @favourite_food.update_attributes(params[:favourite_food])
format.html { redirect_to @favourite_food, notice: 'Favourite food was successfully updated.' }
format.json { head :no_content }
else
... | [
"def update\r\n @fav = Fav.find(params[:id])\r\n\r\n if @fav.update(fav_params)\r\n render json: @fav\r\n else\r\n render json: { error: \"Fav updating error\" }, status: :unprocessable_entity\r\n end\r\n end",
"def favorite_foods\n get(\"/user/#{@user_id}/foods/log/favorite.json\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /favourite_foods/1 DELETE /favourite_foods/1.json | def destroy
@favourite_food = FavouriteFood.find(params[:id])
@favourite_food.destroy
respond_to do |format|
format.html { redirect_to favourite_foods_url }
format.json { head :no_content }
end
end | [
"def delete_food(food_id)\n delete(\"user/#{user_id}/foods/#{food_id}.json\")\n end",
"def delete_favorite_food(food_id)\n delete(\"user/#{user_id}/foods/log/favorite/#{food_id}.json\")\n end",
"def destroy\n @dish_food.destroy\n respond_to do |format|\n format.html { redirect_to dish... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /shops/1 DELETE /shops/1.xml | def destroy
@shop = Shop.find(params[:id])
@shop.destroy
respond_to do |format|
format.html { redirect_to(admin_shops_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { redirect_to(shops_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shops_visit = ShopsVisit.find(params[:id])\n @shops_visit.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compiles all routes into regexps. | def compile!
return if compiled?
@routes.each_with_index do |route, index|
route.index = index
route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/
end
@compiled = true
end | [
"def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end",
"def precompile_all_route... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds routes by using request or env. | def find_by(request_or_env)
request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env
pattern = decode_pattern(request.path_info)
verb = request.request_method
rotation { |offset| match?(offset, pattern) }.select { |route| route.verb == verb }
... | [
"def find_by(request_or_env)\n request = request_or_env.is_a?(Hash) ? Sinatra::Request.new(request_or_env) : request_or_env\n pattern = encode_default_external(request.path_info)\n verb = request.request_method\n rotation { |offset| match?(offset, pattern) }.select { |route| route.ver... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Encode string with Encoding.default_external | def encode_default_external(string)
string.encode(Encoding.default_external)
end | [
"def encode(string); end",
"def encode_string_ex; end",
"def force_encoding(str)\n encoding = ::Rails.application.config.encoding if defined? ::Rails\n encoding ||= DEFAULT_ENCODING\n str.force_encoding(encoding).encode(encoding)\n end",
"def encode_utf8 string\n (string.respond_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds an emoji by its name. | def find_emoji(name)
LOGGER.out("Resolving emoji #{name}")
emoji.find { |element| element.name == name }
end | [
"def find(symbol)\n return symbol if (symbol.is_a?(Emoji::Character))\n symbol = emoticons[symbol].to_s if emoticons.has_key?(symbol)\n Emoji.find_by_alias(symbol) || Emoji.find_by_unicode(symbol) || nil\n end",
"def valid_emoji?(emoji)\n Emoji.find_by_name emoji\n end",
"def find_character_by... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The bot's OAuth application. | def bot_application
return unless @type == :bot
response = API.oauth_application(token)
Application.new(JSON.parse(response), self)
end | [
"def oauth_application(auth)\n request(\n :oauth2_applications_me,\n nil,\n :get,\n \"#{APIBASE_URL}/oauth2/applications/@me\",\n Authorization: auth\n )\n end",
"def oauth_application(token)\n request(\n __method__,\n :get,\n \"#{api_base}/oauth2/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates an OAuth invite URL that can be used to invite this bot to a particular server. | def invite_url(server: nil, permission_bits: nil)
@client_id ||= bot_application.id
server_id_str = server ? "&guild_id=#{server.id}" : ''
permission_bits_str = permission_bits ? "&permissions=#{permission_bits}" : ''
"https://discord.com/oauth2/authorize?&client_id=#{@client_id}#{server_id_str... | [
"def invite_url(server = nil)\n raise 'No application ID has been set during initialization! Add one as the `application_id` named parameter while creating your bot.' unless @application_id\n\n guild_id_str = server ? \"&guild_id=#{server.id}\" : ''\n \"https://discordapp.com/oauth2/authorize?&client... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends a text message to a channel given its ID and the message's content, then deletes it after the specified timeout in seconds. | def send_temporary_message(channel, content, timeout, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil)
Thread.new do
Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg"
message = send_message(channel, content, tts, embed, ... | [
"def send_temporary_message(channel_id, content, timeout, tts = false, server_id = nil)\n Thread.new do\n message = send_message(channel_id, content, tts, server_id)\n\n sleep(timeout)\n\n message.delete\n end\n\n nil\n end",
"def send_temporary_message(content, timeout, tts... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends a file to a channel. If it is an image, it will automatically be embedded. | def send_file(channel, file, caption: nil, tts: false, filename: nil, spoiler: nil)
if file.respond_to?(:read)
if spoiler
filename ||= File.basename(file.path)
filename = "SPOILER_#{filename}" unless filename.start_with? 'SPOILER_'
end
# https://github.com/rest-client/r... | [
"def send_file(channel_id, file)\n response = API.send_file(token, channel_id, file)\n Message.new(JSON.parse(response), self)\n end",
"def send_file(token, channel_id, file, caption: nil, tts: false)\n request(\n __method__,\n :post,\n \"#{api_base}/channels/#{channel_id}/messages\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a server on Discord with a specified name and a region. | def create_server(name, region = :'eu-central')
response = API::Server.create(token, name, region)
id = JSON.parse(response)['id'].to_i
sleep 0.1 until (server = @servers[id])
debug "Successfully created server #{server.id} with name #{server.name}"
server
end | [
"def create_server(name, region = :london)\n response = API.create_server(token, name, region)\n id = JSON.parse(response)['id'].to_i\n sleep 0.1 until @servers[id]\n server = @servers[id]\n debug \"Successfully created server #{server.id} with name #{server.name}\"\n server\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new application to do OAuth authorization with. This allows you to use OAuth to authorize users using Discord. For information how to use this, see the docs: | def create_oauth_application(name, redirect_uris)
response = JSON.parse(API.create_oauth_application(@token, name, redirect_uris))
[response['id'], response['secret']]
end | [
"def create_oauth_application(auth, name, redirect_uris)\n request(\n :oauth2_applications,\n nil,\n :post,\n \"#{APIBASE_URL}/oauth2/applications\",\n { name: name, redirect_uris: redirect_uris }.to_json,\n Authorization: auth,\n content_type: :json\n )\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current listening status to the specified name. | def listening=(name)
gateway_check
update_status(@status, name, nil, nil, nil, 2)
end | [
"def watching=(name)\n gateway_check\n update_status(@status, name, nil, nil, nil, 3)\n end",
"def name=(name)\n @name = name\n update_channel_data\n end",
"def name=(name)\n update_server_data(name: name)\n end",
"def name=(name)\n update_channel_data(name: name)\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current watching status to the specified name. | def watching=(name)
gateway_check
update_status(@status, name, nil, nil, nil, 3)
end | [
"def set_status(task_name, status)\n command = Command::SetStatus.new(task_name, status)\n Client.run(command)\n end",
"def competing=(name)\n gateway_check\n update_status(@status, name, nil, nil, nil, 5)\n end",
"def listening=(name)\n gateway_check\n update_status(@status,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the currently online stream to the specified name and Twitch URL. | def stream(name, url)
gateway_check
update_status(@status, name, url)
name
end | [
"def stream(name, url)\n gateway_check\n update_status(@idletime, name, url)\n name\n end",
"def update_stream(name, params={})\n stream = Stream.new(@client, self, {\"name\" => name})\n stream.update!(params)\n end",
"def stream(name)\n self.redis_publisher_stream = name.to_s\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the currently competing status to the specified name. | def competing=(name)
gateway_check
update_status(@status, name, nil, nil, nil, 5)
end | [
"def set_status(task_name, status)\n command = Command::SetStatus.new(task_name, status)\n Client.run(command)\n end",
"def watching=(name)\n gateway_check\n update_status(@status, name, nil, nil, nil, 3)\n end",
"def set_status\n self.status = \"pending\"\n end",
"def set_st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets status to idle. | def idle
gateway_check
update_status(:idle, @activity, nil)
end | [
"def idle\n set_state :idle\n @start_time = nil\n end",
"def idle\n update_profile_status_setting('idle')\n end",
"def idle\n log 'Force transition to Run-Test/Idle...'\n # From the JTAG2IPS block guide holding TMS high for 5 cycles\n # will force it to reset regardless of the stat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the bot's status to DnD (red icon). | def dnd
gateway_check
update_status(:dnd, @activity, nil)
end | [
"def drb_status!\n Vedeu.bind(:_drb_status_) { Vedeu::Distributed::Server.status }\n end",
"def set(status, msg=nil)\n status = :ready unless Statuses.include? status\n @image.stock = Statuses[status]\n @label.text = msg.to_s\n end",
"def set_offline\n\tself.status = \"offline\"\ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the bot's status to invisible (appears offline). | def invisible
gateway_check
update_status(:invisible, @activity, nil)
end | [
"def invisible\n update_profile_status_setting('invisible')\n end",
"def set_offline\n\tself.status = \"offline\"\nend",
"def make_inactive\n self.status = \"I\"\n end",
"def to_hide\n self.status = 3\n end",
"def set_online_status\n self.online_status = \"offline\"\n end",
"def se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the logging mode | def mode=(new_mode)
LOGGER.mode = new_mode
end | [
"def setWithLevel(flag=true)\n logger().setWithLevel(flag) ;\n end",
"def set_logger_level\n case @options[:verbose]\n when 0\n @logger.level = Logger::Severity::WARN\n when 1\n @logger.level = Logger::Severity::INFO\n when 2..5\n @logger.level = Logger::Severity::... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prevents the READY packet from being printed regardless of debug mode. | def suppress_ready_debug
@prevent_ready = true
end | [
"def debug_off\n @debug_socket = false\n end",
"def silence_ready; end",
"def print_non_dev_warning\n puts \"\\e[31m\"\n puts non_dev_warning_message\n puts \"\\e[0m\"\n end",
"def print_blocked\n return @print_blocked\n end",
"def blockdev?() end",
"def chk... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a user to the list of ignored users. Those users will be ignored in message events at event processing level. | def ignore_user(user)
@ignored_ids << user.resolve_id
end | [
"def add_user_ids(user_ids) # :nodoc:\n user_ids.each do |id|\n @context.add_user(:id => id) unless @context.users[id]\n end\n end",
"def addWorkingUser user\n @workingUsers << user\n @workingUsers.uniq!\n end",
"def add(user)\n users << user\n # equivalents.each {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove a user from the ignore list. | def unignore_user(user)
@ignored_ids.delete(user.resolve_id)
end | [
"def ignore_user(user)\n @ignored_ids << user.resolve_id\n end",
"def remove(user)\r\n @users.delete(user)\r\n end",
"def removeWorkingUser user\n @workingUsers.delete user\n end",
"def remove(user)\n users.delete(user)\n # equivalents.each { |event| event.users.delete(user) }\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks whether a user is being ignored. | def ignored?(user)
@ignored_ids.include?(user.resolve_id)
end | [
"def ignored?(who)\n if rec = @store.get_user(who)\n rec['ignored']\n else\n nil\n end\n end",
"def ignored?(key)\n get_user(key)['ignored']\n end",
"def ignore?\n @should_ignore\n end",
"def i_dont_own?(object)\n if(current_user.present? ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Raises a heartbeat event. Called by the gateway connection handler used internally. | def raise_heartbeat_event
raise_event(HeartbeatEvent.new(self))
end | [
"def handle_heartbeat(_payload)\n send_packet(OPCODES[:HEARTBEAT], @session.seq)\n end",
"def sendHeartbeat()\n if NodeAgent.instance.connected?\n send!(:HB, -1, -1, -1, -1)\n else\n # haven't heard from nodeHandler yet, resend initial message\n sendWHOAMI\n end\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Makes the bot leave any groups with no recipients remaining | def prune_empty_groups
@channels.each_value do |channel|
channel.leave_group if channel.group? && channel.recipients.empty?
end
end | [
"def ungroup\n send_transport_message('BecomeCoordinatorOfStandaloneGroup')\n end",
"def leave_memberships\n all_groups do |g|\n g.resources.membership = { leave: g.address }\n end\n end",
"def leave()\n\t\treturn if !@group\n\t\tcpg_name = Corosync::CpgName.new\n\t\tcpg_name[:va... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get all application commands. | def get_application_commands(server_id: nil)
resp = if server_id
API::Application.get_guild_commands(@token, profile.id, server_id)
else
API::Application.get_global_commands(@token, profile.id)
end
JSON.parse(resp).map do |command_data|
Applic... | [
"def all_commands\n storage[:commands]\n end",
"def commands\n unless defined? @commands\n @commands = []\n end\n return @commands\n end",
"def get_global_commands(token, application_id)\n Discordrb::API.request(\n :applications_aid_commands,\n nil,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get an application command by ID. | def get_application_command(command_id, server_id: nil)
resp = if server_id
API::Application.get_guild_command(@token, profile.id, server_id, command_id)
else
API::Application.get_global_command(@token, profile.id, command_id)
end
ApplicationCommand.ne... | [
"def get_global_command(token, application_id, command_id)\n Discordrb::API.request(\n :applications_aid_commands_cid,\n nil,\n :get,\n \"#{Discordrb::API.api_base}/applications/#{application_id}/commands/#{command_id}\",\n Authorization: token\n )\n end",
"def view_command(command... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Throws a useful exception if there's currently no gateway connection. | def gateway_check
raise "A gateway connection is necessary to call this method! You'll have to do it inside any event (e.g. `ready`) or after `bot.run :async`." unless connected?
end | [
"def gateway_check\n return if connected?\n\n raise \"A gateway connection is necessary to call this method! You'll have to do it inside any event (e.g. `ready`) or after `bot.run :async`.\"\n end",
"def verify_gateway\n cidr = NetAddr::CIDR.create(\"#{self.network}#{self.netmask}\")\n if not c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Logs a warning if there are servers which are still unavailable. e.g. due to a Discord outage or because the servers are large and taking a while to load. | def unavailable_servers_check
# Return unless there are servers that are unavailable.
return unless @unavailable_servers&.positive?
LOGGER.warn("#{@unavailable_servers} servers haven't been cached yet.")
LOGGER.warn('Servers may be unavailable due to an outage, or your bot is on very large serv... | [
"def check_monitoring\n @servers.each do |server|\n transaction { server.settings }\n response = nil\n count = 0\n until response || count > 20 do\n begin\n response = transaction { server.monitoring }\n rescue\n response = n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for VOICE_STATE_UPDATE | def update_voice_state(data)
@session_id = data['session_id']
server_id = data['guild_id'].to_i
server = server(server_id)
return unless server
user_id = data['user_id'].to_i
old_voice_state = server.voice_states[user_id]
old_channel_id = old_voice_state.voice_channel&.id if ... | [
"def state_changed\n\t\tend",
"def state_changed(state)\n\t\tdebug state\n\t\t@last_state = @mpd.status['state']\n\t\tnow_playing if state == 'play' and @song\n\tend",
"def update_voice_state(data)\n user_id = data['user_id'].to_i\n\n if data['channel_id']\n unless @voice_states[user_id]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for VOICE_SERVER_UPDATE | def update_voice_server(data)
server_id = data['guild_id'].to_i
channel = @should_connect_to_voice[server_id]
debug("Voice server update received! chan: #{channel.inspect}")
return unless channel
@should_connect_to_voice.delete(server_id)
debug('Updating voice server!')
toke... | [
"def cmdh_update_resp2(msg_details)\n @log.debug \"UPDATERESPTWO handler\"\n info = YAML::load(msg_details)\n case info[:type] \n when :platf_update\n # need a platform update\n @log.debug \"Platform update is needed\"\n str = \"ATTENZIONE: questo client necessita di un aggiorn... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for CHANNEL_RECIPIENT_ADD | def add_recipient(data)
channel_id = data['channel_id'].to_i
channel = self.channel(channel_id)
recipient_user = ensure_user(data['user'])
recipient = Recipient.new(recipient_user, channel, self)
channel.add_recipient(recipient)
end | [
"def channel_recipient_add(attributes = {}, &block)\n register_event(ChannelRecipientAddEvent, attributes, block)\n end",
"def add_recipient(p0) end",
"def add_channel channel\n join(channel)\n self\n end",
"def radioChannelAdd _obj, _args\n \"_obj radioChannelAdd _args;\" \n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for GUILD_MEMBER_UPDATE | def update_guild_member(data)
server_id = data['guild_id'].to_i
server = self.server(server_id)
member = server.member(data['user']['id'].to_i)
member.update_roles(data['roles'])
member.update_nick(data['nick'])
member.update_boosting_since(data['premium_since'])
member.update... | [
"def update_guild_member(data)\n server_id = data['guild_id'].to_i\n server = self.server(server_id)\n\n member = server.member(data['user']['id'].to_i)\n member.update_roles(data['roles'])\n member.update_nick(data['nick'])\n end",
"def member_update(attributes = {}, &block)\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for GUILD_MEMBER_DELETE | def delete_guild_member(data)
server_id = data['guild_id'].to_i
server = self.server(server_id)
return unless server
user_id = data['user']['id'].to_i
server.delete_member(user_id)
rescue Discordrb::Errors::NoPermission
Discordrb::LOGGER.warn("delete_guild_member attempted to ac... | [
"def destroy\n service = Fl::Framework::Service::Actor::GroupMember.new(current_user, params, self)\n @group_member = service.get_and_check(Fl::Framework::Access::Permission::Delete)\n if @group_member && service.success?\n title = @group_member.title\n fingerprint = @group_member.fingerprint\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for GUILD_EMOJIS_UPDATE | def update_guild_emoji(data)
server_id = data['guild_id'].to_i
server = @servers[server_id]
server.update_emoji_data(data)
end | [
"def update_emoji_data(new_data)\n @emoji = {}\n process_emoji(new_data['emojis'])\n end",
"def server_emoji_update(attributes = {}, &block)\n register_event(ServerEmojiUpdateEvent, attributes, block)\n end",
"def update\n respond_to do |format|\n if @emoji.update(emoji_params)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for MESSAGE_CREATE | def create_message(data); end | [
"def create_message(schema_id = nil)\n\t\tend",
"def create_message(current_user, msg_for, open_msg_tag = nil, entry = nil, order = nil)\n self.user_company_id = current_user.company.id\n self.user_type = current_user.roles.first.name\n self.entry_id = entry.id unless entry.blank?\n self.order_id = or... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for TYPING_START | def start_typing(data); end | [
"def typing\n @omegle.post '/typing', \"id=#{@id}\"\n end",
"def begin_typing(&block)\n with_keyboard_focus do\n application.keyboard.when_element(:visible?) do\n yield application.keyboard if block_given?\n end\n end\n end",
"def typing(reducer = nil, &block)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for MESSAGE_UPDATE | def update_message(data); end | [
"def update_message args = {}\n msg = args[:msg]\n perc_finished = args[:perc_finished]\n\n self.update_attribute :message, msg if msg\n self.update_attribute :perc_finished, perc_finished if perc_finished\n end",
"def update( msg )\n typed_message('update', msg, (colorize ? :y... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for MESSAGE_DELETE | def delete_message(data); end | [
"def delete_msg()\n MsgUtil.delete_msg(params[:ch])\n end",
"def chmessagedelete\n TChannelMessage.where(\"chmsg_id=?\", params[:messagedelete]).delete_all\n TMention.where(\"mention_message=?\", params[:mentionmsg]).delete_all\n redirect_back(fallback_location: chmessage_path)\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for MESSAGE_REACTION_ADD | def add_message_reaction(data); end | [
"def add(reaction)\n if reaction[:action] and reaction[:test] and reaction[:reaction] #validate\n reaction[:test] = RProc.new(reaction[:test])\n reaction[:reaction] = RProc.new(reaction[:reaction])\n\n if reaction[:action].is_a? Enumerable\n actions = reaction[:action]\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for MESSAGE_REACTION_REMOVE | def remove_message_reaction(data); end | [
"def remove_message(name)\n\t\tend",
"def remove_all_message_reactions(data); end",
"def delete_message(data); end",
"def on_removing_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n # From UploadController#delete:\n # ids = Upload.expand_ids(@item_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for MESSAGE_REACTION_REMOVE_ALL | def remove_all_message_reactions(data); end | [
"def remove_message_reaction(data); end",
"def _remove_all_method\n :\"_remove_all_#{self[:name]}\"\n end",
"def remove_all\n @message_ids.each do |msg_id|\n @@statusbar.remove(@context_id, msg_id)\n end\n @message_ids.clear\n end",
"def reaction_remove_all(attributes = {}, &blo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for GUILD_BAN_ADD | def add_user_ban(data); end | [
"def add_ban(mask, type)\n b = parse_ban(mask)\n\n if type == 'b'\n @bans.push(b)\n elsif type == 'e'\n @exempts.push(b)\n else\n raise(ArgumentError, \"Invalid ban type #{type}, expected b or e.\")\n end\n end",
"def addHandgunItem _obj, _args\n \"_obj addHandgunItem _args;\" ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal handler for GUILD_BAN_REMOVE | def remove_user_ban(data); end | [
"def removeHandgunItem _obj, _args\n \"_obj removeHandgunItem _args;\" \n end",
"def removeBackpack _args\n \"removeBackpack _args;\" \n end",
"def removeItemFromBackpack _obj, _args\n \"_obj removeItemFromBackpack _args;\" \n end",
"def unban_user(auth, server_id, user_id, reason = ni... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tiendas_clientes POST /tiendas_clientes.json | def create
@tienda_cliente = @cliente.tiendas_clientes.build(tienda_cliente_params)
respond_to do |format|
if @tienda_cliente.save
format.html { redirect_to @tienda_cliente, notice: 'La tienda se creó exitosamente.' }
format.json { render :show, status: :created, location: @tienda_client... | [
"def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_url, notice: 'El cliente se creó correctamente' }\n format.json { render :index, status: :created, location: @client }\n else\n format.html { render... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
hour specified hour minute specified minute second specified second interval how fast the second hand advances in real time. | def initialize(hour, minute, second, interval)
@hour = hour
@minute = minute
@second = second
@interval = interval
end | [
"def rational_hour(seconds); end",
"def end_of_hour\n change(min: 59, sec: 59, usec: Rational(999999999, 1000))\n end",
"def end_of_hour\n change(\n :min => 59,\n :sec => 59,\n :usec => Rational(999999999, 1000)\n )\n end",
"def timestamp(hour1,minute1,second1,hour2,minute2,second2)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tick will now increment the second value. | def tick
@second += 1
need_tock?
end | [
"def tick\n @tick += 1\n end",
"def tick(seconds)\n\t\t@time += seconds\n\tend",
"def tick\n @time = next_time(true)\n end",
"def tick\n\t\n\t\t@secs +=1\n\t\t\n\t\tif @secs == 60\n\t\t\tthen\n\t\t\t@mins += 1\n\t\t\t@secs = 0\n\t\t\tif @mins == 60\n\t\t\t\tthen\n\t\t\t\t@hours += 1\n\t\t\t\t@mins... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If the second value == 60, then it will commit a tock | def need_tock?
if @second == 60
@second = 0
tock
end
end | [
"def cheat\n if @score >= 60 and !@cheating and !@cheating_two\n @cheating = true\n @score -= 60\n end\n end",
"def verify_score(score)\n decimal = (score * 60) % 1\n [decimal, 1 - decimal].min < 0.03\nend",
"def commit\n return false unless committable?\n result = vote_frequency.reject... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If minute value == 60, then it will commit a ticktock | def need_tick_tock?
if @minute == 60
@minute = 0
tick_tock
end
end | [
"def need_tock?\n if @second == 60\n @second = 0\n tock\n end\n end",
"def tick\n\t\tif @sec > 0\n\t\t\t@sec -= 1\n\t\telse\n\t\t\t@sec = 59\n\t\t\tif min > 0\n\t\t\t\t@min -= 1\n\t\t\telse\n\t\t\t\t@min = 59\n\t\t\t\tif @hr > 0\n\t\t\t\t\t@hr -= 1\n\t\t\t\telse\n\t\t\t\t\t@hr = 23\n\t\t\t\tend\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
5 Cases (1) First install, anything goes => OK (2) An old storage type was not set and the new_storage_type is :filesystem => OK (3) An old storage type was not set and the new_storage_type is :sql => NOT_OK (4) An old storage type was set and is not equal to the new storage type => NOT_OK (5) An old storage type was s... | def verify_storage_type_unchanged
if previous_run.nil? # case (1)
true
else
previous_value = previous_run['bookshelf']['storage_type']
current_value = (user_attrs['storage_type'] || 'filesystem').to_s
if previous_value.nil? && current_value == 'filesystem' # case (2)
true
... | [
"def ensure_correct_derivatives_storage_after_change\n if derivative_storage_type_previously_changed? && file_derivatives.present?\n EnsureCorrectDerivativesStorageJob.perform_later(self)\n end\n end",
"def transform_to_consistent_types\n if PrivateChef['bookshelf']['storage_type']\n Priva... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Encode the temporal expression into +codes+. | def encode(codes)
encode_list(codes, @days)
codes << encoding_token
end | [
"def encode(codes)\n @base_date.nil? ? (codes << 0) : encode_date(codes, @base_date)\n codes << encoding_token\n end",
"def encode(codes)\n encode_list(codes, @years)\n codes << encoding_token\n end",
"def encode(ary)\n ary.map { |(code, argument)| [INSTRUCTIONS[code], argument] }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.