query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Add `hostname` to `line` from `/etc/hosts` The hostname is put into the first position. | def add_host(line, hostname)
return if line !~ /^([^\s]+)(\s+)/
i = $~.end(2)
"#{$1}#{$2}#{hostname.fqdn} #{line[i..-1]}"
end | [
"def replace_host(line, old_hostname, new_hostname)\n line.sub(\n /(\\s)#{Regexp.escape(old_hostname.fqdn)}(\\s|$)/,\n \"\\\\1#{new_hostname.fqdn}\\\\2\"\n )\n end",
"def hosts_line!(url,ip)\n File.open(\"#{ENV['SystemRoot']}/System32/drivers/etc/hosts\",'r+') do |hosts|\n lines,fou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove `hostname` from `line` read from `/etc/hosts` | def replace_host(line, old_hostname, new_hostname)
line.sub(
/(\s)#{Regexp.escape(old_hostname.fqdn)}(\s|$)/,
"\\1#{new_hostname.fqdn}\\2"
)
end | [
"def fix_line\n el = @l.split(\" \")\n\n u = URI(el[1])\n\n disable = false\n\n case u.host\n when \"releases.ubuntu.com\"\n c = u.host\n u.host = \"archive.ubuntu.com\"\n if self.uri_exists(self.get_url(u.to_s)) == false\n u.host = c\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the file at `path` si writable by its user If the file doesn't exist, we take it as writable. If a block is given, it is called if `path` is writable. | def writable?(path)
begin
return if (File.stat(path).mode & 0200) != 0200
rescue Errno::ENOENT
# pass
end
yield(path) if block_given?
true
end | [
"def check_writable(path)\n raise Error, \"The path '#{path}' is not writable\" if (path.exist? && !path.writable?) || !path.parent.writable?\n end",
"def writable_file(path)\n path = File.expand_path(path)\n begin\n FileUtils.mkdir_p(File.dirname(path), :mode => 0755)\n FileUtils.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Upload copy of latest run | def upload_latest_copy
upload_to_s3(report_files, prefix)
end | [
"def upload_latest_copy\n raise(\"Not implemented!\")\n end",
"def upload_latest_copy\n upload_to_gcs(report_files, prefix)\n end",
"def upload_manifest; end",
"def deploy!\n write_previous_revision\n update_repository\n write_revision\n end",
"def d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /bairro_micros/1 GET /bairro_micros/1.xml | def show
@bairro_micro = BairroMicro.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @bairro_micro }
end
end | [
"def index\n @micros = Micro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @micros }\n end\n end",
"def index\n @micros = Micro.all\n end",
"def get_xml(api_call)\n xml = ''\n http = Net::HTTP.new('api.pinboard.in', 443)\n http.use_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /bairro_micros/new GET /bairro_micros/new.xml | def new
@bairro_micro = BairroMicro.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @bairro_micro }
end
end | [
"def new\n @binary = Binary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @binary }\n end\n end",
"def new\n @lb202555 = Lb202555.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lb202555 }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /bairro_micros POST /bairro_micros.xml | def create
@bairro_micro = BairroMicro.new(params[:bairro_micro])
respond_to do |format|
if @bairro_micro.save
flash[:notice] = 'BairroMicro was successfully created.'
format.html { redirect_to(@bairro_micro) }
format.xml { render :xml => @bairro_micro, :status => :created, :loca... | [
"def create(bin_params)\n @rest.post('save', bin_params)\n end",
"def create\n @inform = Inform.find(params[:inform_id])\n @micro = @inform.micros.build(micro_params)\n @micro.user_id = current_user.id\n\n @micro.save\n\n get_automatics\n\n end",
"def create\n @saprfc_mb1b = SaprfcMb1b.ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /bairro_micros/1 PUT /bairro_micros/1.xml | def update
@bairro_micro = BairroMicro.find(params[:id])
respond_to do |format|
if @bairro_micro.update_attributes(params[:bairro_micro])
flash[:notice] = 'BairroMicro was successfully updated.'
format.html { redirect_to(@bairro_micro) }
format.xml { head :ok }
else
... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end",
"def update_aos_versio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /bairro_micros/1 DELETE /bairro_micros/1.xml | def destroy
@bairro_micro = BairroMicro.find(params[:id])
@bairro_micro.destroy
respond_to do |format|
format.html { redirect_to(bairro_micros_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @bairro = Bairro.find(params[:id])\n @bairro.destroy\n\n respond_to do |format|\n format.html { redirect_to(bairros_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @genbank_file.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Formats song information to send tweet | def format(song)
artist_name = format_artist_name(song["artist"]["content"])
song_name = format_song_name(song["name"])
hashtag = format_hashtag(song["nowplaying"])
return "#{song_name} - #{artist_name} ##{hashtag}"
end | [
"def format_for_twitter(message)\n url = shorten_url \"http://#{URL_BASE}/track/show/#{id}\"\n message[0, 140 - 1 + url.length] + ' ' + url\n end",
"def write_tweet(item)\n prefix = @recipient ? \"@#{@recipient} \" : \"\"\n\n source_title = item.source_title\n title = item.title\n link ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Formats artist name for tweet | def format_artist_name(artist_name)
if(artist_name.length > 52)
return artist_name[0 .. 48] + "..."
else
return artist_name
end
end | [
"def full_name\n\t\ts = title\n\t\ts = \"#{artist.name} - #{s}\" if artist\n\t\treturn s\n\tend",
"def format_tweet(tweet)\r\n \"#{Format(:green, '[')}%s %s#{Format(:green, ']')} %s\" % [Format(:bold, Format(:blue, '@' + tweet.user.screen_name)),\r\n Format(:blue, tweet.user.name)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
4. block_fork : if opponent can create 2 win threats, play block_fork | def block_fork(board)
return fork(board, opponent_symbol(@symbol))
end | [
"def fork_check(wins, player, opponent)\n block_fork = find_fork(wins, opponent, player)\n get_fork = find_fork(wins, player, opponent)\n if get_fork.size > 0 # if possible to create fork, do it\n move = get_fork.sample\n elsif block_fork.size > 0 # otherwise if opponent can create fork, block it... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
6. opposite_corner : if the opponent is on a corner, play the opposite corner | def opposite_corner(board)
CORNERS.each do |corner|
if board[corner] == opponent_symbol(@symbol)
move = opposite(corner)
return move if board[move] == " "
end
end
return false
end | [
"def opposite_corner(grid, opponent_id)\n spaces = grid.all_marked_spaces(opponent_id)\n\n moves = spaces.collect {|space|\n if Grid.corner?(space)\n opposite = Grid.opposite_corner(space)\n opposite if grid.state[opposite].nil?\n end\n }.compact\n end",
"def opposite_corner\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Explicitly disallow phi access in a specific area of code. This does not play nicely with the mutating versions of `allow_phi!` and `disallow_phi!` At the moment, this doesn't work at all, as the instance won't necessarily look at the classlevel stack when determining if PHI is allowed. &block [block] The block in whic... | def disallow_phi
raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?
__phi_stack.push({
phi_access_allowed: false
})
yield if block_given?
__phi_stack.pop
end | [
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access_for = self.class.__user_id_string(@__phi_access_stack)\n\n revoke_extended_phi!\n @__phi_access_stack = []\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Revoke last PHI access for this class, if enabled by PhiRecordallow_phi! | def disallow_last_phi!
raise ArgumentError, 'block not allowed' if block_given?
removed_access = __phi_stack.pop
message = removed_access.present? ? "PHI access disabled for #{removed_access[:user_id]}" : 'PHI access disabled. No class level access was granted.'
PhiAttrs::Logger.tagged... | [
"def revoke_extended_phi!(relations = nil)\n relations ||= @__phi_relations_extended\n relations.each do |relation|\n relation.disallow_last_phi! if relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)\n end\n @__phi_relations_extended.subtract(relations)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether PHI access is allowed for this class | def phi_allowed?
__phi_stack.present? && __phi_stack[-1][:phi_access_allowed]
end | [
"def phi_allowed?\n !phi_context.nil? && phi_context[:phi_access_allowed]\n end",
"def permit_access?\n !!@person\n end",
"def require_phi!\n raise PhiAccessException, 'PHI Access required, please call allow_phi or allow_phi! first' unless phi_allowed?\n end",
"def one_click_access_gen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Revoke all PHI access for a single instance of this class. | def disallow_phi!
raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?
PhiAttrs::Logger.tagged(*phi_log_keys) do
removed_access_for = self.class.__user_id_string(@__phi_access_stack)
revoke_extended_phi!
@__phi_access_stack = []
message = r... | [
"def revoke\n @auth.revoke(@access)\n @access = nil\n end",
"def revoke_registration\n @id = nil\n end",
"def revoke_extended_phi!(relations = nil)\n relations ||= @__phi_relations_extended\n relations.each do |relation|\n relation.disallow_last_phi! if relation.pre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The unique identifier for whom access has been allowed on this instance. This is what was passed in when PhiRecordallow_phi! was called. | def phi_allowed_by
phi_context[:user_id]
end | [
"def publicID\n return @trainerID&0xFFFF\n end",
"def privacy_object_id\r\n\t\t\treturn self.id\r\n\t\tend",
"def claimed_id; end",
"def permission_id\n return @permission_id\n end",
"def recip\n\t\tself.identity\n\tend",
"def unique_id\n return @unique_id\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The access reason for allowing access to this instance. This is what was passed in when PhiRecordallow_phi! was called. | def phi_access_reason
phi_context[:reason]
end | [
"def access\n\t\treturn self.access_level\n\tend",
"def access\n return @access\n end",
"def required_access_level\n @@required_access_levels[self.class.name]\n end",
"def hyves_access_denied\n access_denied\n end",
"def phi_allowed?\n !phi_context.nil? && phi_cont... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Whether PHI access is allowed for a single instance of this class | def phi_allowed?
!phi_context.nil? && phi_context[:phi_access_allowed]
end | [
"def phi_allowed?\n __phi_stack.present? && __phi_stack[-1][:phi_access_allowed]\n end",
"def one_click_access_generation_allowed?\n logged_in? and (@pallet.one_click_access_generation_by_users? or \n current_user.has_role? 'admin')\n end",
"def permit_access?\n !!@person... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Require phi access. Raises an error preemptively if it has not been granted. | def require_phi!
raise PhiAccessException, 'PHI Access required, please call allow_phi or allow_phi! first' unless phi_allowed?
end | [
"def phi_allowed?\n !phi_context.nil? && phi_context[:phi_access_allowed]\n end",
"def phi_allowed?\n __phi_stack.present? && __phi_stack[-1][:phi_access_allowed]\n end",
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a disallow phi flag to instance internal stack. | def add_disallow_flag!
@__phi_access_stack.push({
phi_access_allowed: false
})
end | [
"def disallow_phi\n raise ArgumentError, 'block required. use disallow_phi! without block' unless block_given?\n\n __phi_stack.push({\n phi_access_allowed: false\n })\n\n yield if block_given?\n\n __phi_stack.pop\n end",
"def disal... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Entry point for wrapping methods with PHI access logging. This is called by an `after_initialize` hook from ActiveRecord. | def wrap_phi
# Disable PHI access by default
@__phi_access_stack = []
@__phi_methods_extended = Set.new
@__phi_relations_extended = Set.new
# Wrap attributes with PHI Logger and Access Control
__phi_wrapped_methods.each { |m| phi_wrap_method(m) }
__phi_extended_methods.each { ... | [
"def after_initialize\n self.class.after_initialize_hooks.each{ |hook| instance_exec(&hook) }\n end",
"def initialize\n Logging.setup(Logger::INFO)\n end",
"def logger; end",
"def around_hooks; end",
"def log\n\t\t\t@log_proxy ||= ClassNameProxy.new( self.class )\n\t\tend",
"def configure_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Core logic for wrapping methods in PHI access logging and access restriction. This method takes a single method name, and creates a new method using define_method; once this method is defined, the original method name is aliased to the new method, and the original method is renamed to a known key. | def phi_wrap_method(method_name)
unless respond_to?(method_name)
PhiAttrs::Logger.warn("#{self.class.name} tried to wrap non-existant method (#{method_name})")
return
end
return if self.class.__phi_methods_wrapped.include? method_name
wrapped_method = :"__#{method_name}_phi_wrap... | [
"def create_alias_for_existing_method(method_name)\n new_alias = new_name(method_name)\n unless @obj.respond_to?(new_alias)\n safe_alias_method(new_alias, method_name)\n end\n new_alias\n end",
"def create_alias_for_existing_method(method_name)\n begin\n new_alias = new_n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Revoke PHI access for all `extend`ed relations (or only those given) | def revoke_extended_phi!(relations = nil)
relations ||= @__phi_relations_extended
relations.each do |relation|
relation.disallow_last_phi! if relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)
end
@__phi_relations_extended.subtract(relations)
end | [
"def drop_related!\n ActiveRecord::Base.transaction do\n PgTools.drop_schema_if(tenant)\n User.where(id: links.map(&:user_id)).destroy_all\n self.destroy\n end\n end",
"def add_disallow_flag_to_extended_phi!(relations = nil)\n relations ||= @__phi_relations_extended\n relations.eac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a disallow PHI access to the stack for block syntax for all `extend`ed relations (or only those given) | def add_disallow_flag_to_extended_phi!(relations = nil)
relations ||= @__phi_relations_extended
relations.each do |relation|
relation.add_disallow_flag! if relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)
end
end | [
"def disallow_phi!\n raise ArgumentError, 'block not allowed. use disallow_phi with block' if block_given?\n\n PhiAttrs::Logger.tagged(*phi_log_keys) do\n removed_access_for = self.class.__user_id_string(@__phi_access_stack)\n\n revoke_extended_phi!\n @__phi_access_stack = []\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=> instance method to add up the mass of all bodies in bodies and return it | def total_mass
mass = 0
@bodies.each do |body|
mass += body.mass
end
return mass
end | [
"def total_mass\n total_mass = 0\n @bodies.each do |body|\n total_mass += body.mass\n end\n total_mass\n end",
"def total_mass\n sum = 0\n @bodies.each{ |body| body[:mass] += sum}\n sum\n end",
"def total_mass\n total_mass=0\n @bodies.each do |body|\n total_mass += body.ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /matter_products GET /matter_products.json | def index
@matter_products = MatterProduct.all
end | [
"def get_product_list\n request_path = \"/products\"\n return RestClient.get(@api+request_path)\n end",
"def index\n @products = Product.all\n render json: @products\n end",
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def get_products(rest_url)\n rest_output = Rest... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /matter_products POST /matter_products.json | def create
@matter_product = MatterProduct.new(matter_product_params)
respond_to do |format|
if @matter_product.save
format.html { redirect_to @matter_product, notice: 'Matter product was successfully created.' }
format.json { render :show, status: :created, location: @matter_product }
... | [
"def create\n if params[:products]\n params[:products].each do |product|\n @product = Product.new(name: product[:name],\n brand: product[:brand],\n model: product[:model],\n sku: product[:sku],\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /matter_products/1 PATCH/PUT /matter_products/1.json | def update
respond_to do |format|
if @matter_product.update(matter_product_params)
format.html { redirect_to @matter_product, notice: 'Matter product was successfully updated.' }
format.json { render :show, status: :ok, location: @matter_product }
else
format.html { render :edit ... | [
"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 uri = \"#{API_BASE_URL}/products/#{params[:id]}\"\n payload = params.to_json\n rest_resou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /matter_products/1 DELETE /matter_products/1.json | def destroy
@matter_product.destroy
respond_to do |format|
format.html { redirect_to matter_products_url, notice: 'Matter product was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @productos_json.destroy\n respond_to do |format|\n format.html { redirect_to productos_jsons_url }\n format.json { head :no_content }\n end\n end",
"def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end",
"def delete(options = nil)\n request = Requ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
launch: Pass either params or hardcoded server and client data to the auth_url via redirection | def launch
# Get a completely fresh session for each launch. This is a rails method.
reset_session
cookies.clear
redirect_to home_path, alert: "Please provide the server_url, client_id, and client_secret." and return if !all_credentials_provided?
# Set auth sessions with params values
session[... | [
"def auth\n authorization_url = WorkOS::SSO.authorization_url(\n domain: params[:domain],\n client_id: CLIENT_ID,\n redirect_uri: ENV['WORKOS_REDIRECT_URI'],\n )\n\n redirect_to authorization_url\n end",
"def authproxy\n @auth_info = env[\"omniauth.auth\"][\"info\"]\n\t @log... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes the given object from the dispatcher queue of the message +msgName+. | def del_msg_listener( msgName, object )
@msgNames[msgName].delete object if defined? @msgNames
end | [
"def del_msg_name( msgName )\n @msgNames.delete msgName if defined? @msgNames\n end",
"def remove_message(name)\n\t\tend",
"def remove_dispatcher(name)\n\t\tself.dispatcher_stack.delete_if { |inst|\n\t\t\t(inst.name == name)\n\t\t}\n\tend",
"def remove_dispatcher(name)\n self.dispatcher_stack.delete_if... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new message target called +msgName+ | def add_msg_name( msgName )
@msgNames = {} unless defined? @msgNames
@msgNames[msgName] = [] unless @msgNames.has_key? msgName
end | [
"def add_message(name, message)\n\t\tend",
"def addTarget(name=nil, note=nil)\n @addTargetBtn.click\n return EditTarget.new.enterTargetInformation(name)\n end",
"def add_target(target_name, target_type, options={})\n targets[target_name.to_sym] = Target.new(target_name.to_sym,\n target_type... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes the message target +msgName+. | def del_msg_name( msgName )
@msgNames.delete msgName if defined? @msgNames
end | [
"def delete_message(msg, queue_name)\n @sqs.delete_message(\n queue_url: get_queue_url(queue_name),\n receipt_handle: msg.original_msg.receipt_handle\n )\n end",
"def remove_message(name)\n\t\tend",
"def del_msg_listener( msgName, object )\n @msgNames[msgName].delete object if defi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dispatches the message +msgName+ to all listeners for this message, providing the given arguments | def dispatch_msg( msgName, *args )
if defined? @msgNames and @msgNames.has_key? msgName
@msgNames[msgName].each do |obj|
obj.call( *args )
end
end
end | [
"def dispatch name, msg = nil\n return unless self.has_key? name\n\n $log.debug(\"events.run\") { name }\n\n self[name].each do |event|\n begin\n unless msg == nil\n next unless Bot::Flags.permit_message? event.owner, msg\n\n event.owner.send event.func, msg\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Log websocket level errors | def on_error(env, error)
logger.debug "Websocket error: #{error.message}"
end | [
"def setup_error_handler\n EM.error_handler do |e|\n print \"Websocket Error: #{e.message} - #{e.backtrace.join(\"\\n\")}\"\n end\n end",
"def fail_websocket(e)\n debug [:error, e]\n close_websocket(e.code, e.message)\n @connection.close_connection_after_writing\n @connecti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO: more than one bullet? | def bullet
@bullet ||= load_data.first.bullet
end | [
"def bullet_class\n end",
"def add_bullet(bullet)\n @bullets << bullet\n end",
"def bullet(name, options={}, &block)\n cur_page.bullet(name, options, &block)\n end",
"def prepare_bullet_data\n if length < 2\n [\"*\", self[0]]\n else\n self\n end\n end",
"def boostbullets... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns joke from ICNDB | def icndb_joke
url = "http://api.icndb.com/jokes/random"
begin
joke = open(url).read()
hash = JSON.parse joke
joke_string = hash['value']['joke']
rescue
joke_string=''
end
end | [
"def get_login(nick)\n db_connect do |db|\n doc = db[$login_collection].find_one({_id: nick_parse(nick)})\n doc['login'] if doc\n end\nend",
"def joke(id)\n path = id.nil? ? \"/\" : \"/j/#{id}\"\n resp = http.get(path).tap do |resp|\n if resp.body.status == 404\n raise FunnyGuy::HTTPErro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Construtor Cria um programa de shaders | def initialize
@id = glCreateProgram
@shaders = []
@linked = false
end | [
"def init_shaders(widget)\n context = widget.context\n\n if context.use_es?\n vertex_path = \"/glarea/glarea-gles.vs.glsl\"\n fragment_path = \"/glarea/glarea-gles.fs.glsl\"\n else\n vertex_path = \"/glarea/glarea-gl.vs.glsl\"\n fragment_path = \"/glarea/glarea-gl.fs.glsl\"\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adiciona um shader de fragmento ao programa a partir de um arquivo | def add_fragment_shader name
raise 'O programa já está linkado, não é possível adicionar mais shaders' if @linked
file = File.open "shaders/#{name}.frag"
source = file.read
file.close
shader = glCreateShader GL_FRAGMENT_SHADER
glShaderSource shader, 1, [source.cptr].pack("L").cptr, 0
glCompileShader... | [
"def make_shader_program(vs_text, fs_text) # (const char* vs_text, const char* fs_text)\n\n program = 0\n program_ok = 0\n program_ok_buf = ' ' * 4\n vertex_shader = 0\n fragment_shader = 0\n log_length = 0\n log_length_buf = ' ' * 4\n info_log = ' ' * 8192\n\n vertex_shader = make_shader(GL_VERTEX_SHADER,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register plugin with name in internal array | def register(name, plugin = false)
return unless plugin && !loaded?(name)
@plugins << plugin
end | [
"def register(name, plugin = false)\n Vedeu.log(type: :debug,\n message: \"Attempting to register plugin: #{name}\")\n\n plugins << plugin if plugin && not_loaded?(name)\n end",
"def register(name, plugin = false)\n if plugin && !loaded?(name)\n plugins << plugin\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Loads gemspec from a file and registers gems matching pattern. | def load_from(gemspec_path, pattern)
Gem.refresh
spec = Gem::Specification.load(gemspec_path)
dependencies = spec.runtime_dependencies.concat(spec.development_dependencies)
dependencies.each do |gem|
gem_name = gem.name[pattern]
next if gem_name.to_s.empty?
register(gem_n... | [
"def load_gemspec!\n @gemspec = eval(File.read(@gemspec_file))\n end",
"def load_gemspec!(gemspec=nil)\n case gemspec\n when ::Gem::Specification\n spec = gemspec\n else\n file = Dir[root + \"{*,}.gemspec\"].first\n return unless file\n text = File.read(file)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Include an Octicon! (see | def octicon(name)
%(<span class="octicon octicon-#{name}"></span>)
end | [
"def octicon(name, options)\n content_tag :svg, options do\n content_tag :use, '', 'xlink:href' => \"#icon-#{name}\"\n end\n end",
"def fancy_output(text)\n simple_format(add_icons(text))\n end",
"def octave notes, nombre_octaves = 1\n \"\\\\ottava ##{nombre_octaves}\\n#{notes}\"\nend",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the directoryTree from the root of the repo | def tree_root
repo.tree
end | [
"def repository_root\n return unless available?\n root = Licensed::Shell.execute(\"git\", \"rev-parse\", \"--show-toplevel\", allow_failure: true)\n return nil if root.empty?\n root\n end",
"def git_tree\n repo = Grit::Repo.new(\"#{Rails.root}/repositories/#{self.path}\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
URL helper for the History page of a document | def history_path(path)
url('/h/' + path)
end | [
"def history_url\n end",
"def history_url\n history_question_answer_path(question.id, @target.id)\n end",
"def redirection_history; end",
"def add_to_history(page); end",
"def history\n @page = Page.find_by_title(title_param)\n if @page.nil?\n render(:file => \"#{RAILS_ROOT}/public/404.html\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
URL helper for the Edit page of a document | def edit_path(path)
url('/e/' + path)
end | [
"def edit_url\n self.url + \"/edit\"\n end",
"def url_edit\n cname = self.class.classname.to_s.downcase\n return \"?show=#{cname}_edit&#{cname}_id=#{self.id}\"\n end",
"def edit_url(page)\n \"#{page_url(page)}?action=edit\"\n end",
"def edit_resource_link(document)\n active_fedora_mode... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
CSS class for a diff line | def class_for_diff(line)
case line[0]
when '+'
'addition'
when '-'
'removal'
end
end | [
"def diff_line_class(line)\n case line[0, 1]\n when '+' then 'added'\n when '-' then 'deleted'\n end\n end",
"def colorized_diff\n return unless diff\n\n diff.lines.map(&self.class.method(:colorize_line)).join\n end",
"def line_diff(old, new)\n RailsDiff.diff(old,new)\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /commands GET /commands.json | def index
@commands = Command.all
render :json => @commands
end | [
"def index\n @commands = Command.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commands }\n end\n end",
"def get_a_page_of_cli_command_execution_history(args = {}) \n get(\"/commands.json/\", args)\nend",
"def commands\n version = invoke_and... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /commands POST /commands.json | def create
@command = Command.new(command_params)
respond_to do |format|
if @command.save
format.json { render json: @command }
else
format.json { render json: @command.errors, status: 401 }
end
end
end | [
"def submit(params = {})\n parse(params)\n response = Qubole.post('/commands', self.to_h)\n parse(response)\n end",
"def execute_readonly_commands(args = {}) \n post(\"/commands.json/readonly\", args)\nend",
"def create\n @user_command = UserCommand.new(params[:user_command])\n\n respond... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /commands/1 PATCH/PUT /commands/1.json | def update
respond_to do |format|
if @command.update(command_params)
format.json { render :json => @command }
else
format.json { render json: @command.errors, status: 401 }
end
end
end | [
"def update\n @command = Command.find(params[:id])\n\n respond_to do |format|\n if @command.update_attributes(params[:command])\n format.html { redirect_to @command, notice: 'command was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /commands/1 DELETE /commands/1.json | def destroy
@command.destroy
respond_to do |format|
msg = { :status => 'ok', message: 'Deleted Successfully'}
format.json { render json: msg }
end
end | [
"def destroy\n @command = Command.find(params[:id])\n @command.destroy\n\n respond_to do |format|\n format.html { redirect_to commands_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @command.destroy\n respond_to do |format|\n format.html { redirect_to comma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the latest level checked into git | def git_level
# Assumes PWD is a valid git repo
return nil unless File.exists? ".git/current_cmvc_level"
return File.read(".git/current_cmvc_level").chomp
end | [
"def get_tree_sha\n sha = nil\n trees = open('https://api.github.com/repos/twitter/bootstrap/git/trees/master').read\n trees = JSON.parse trees\n trees['tree'].find{|t| t['path'] == 'less'}['sha']\n end",
"def git_tree\n repo = Grit::Repo.new(\"#{Rails.root}/repositories/#{self.path}\")\n last_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an rmap, extract the changed or created files, and delete any deleted files | def cmvc_extract_changed rmap
raise "oops, not done"
end | [
"def run_on_removals(paths); end",
"def file_path_scheduled_for_deletion?( map , path )\n parts = path.split('/')\n if parts.size == 1\n deletions = map.keys.select { |k| !map[k] }\n deletions.any? { |d| d == parts.first }\n else\n part = parts.shift\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Stick the rmap onto disk | def write_rmap rmap
end | [
"def save_vrouter_map\n File.open(resource[:path], 'w', MODE) do |file|\n file.write vrouter_map\n end\n end",
"def nmap_save()\n print_status \"Nmap: saving nmap log file\"\n fh = self.nmap_log[0]\n nmap_data = fh.read(fh.stat.size)\n saved_path = store_local(\"nmap.scan.xml\", \"text/xml\", nmap... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
User defines a platform block | def platform(platform_name, &block)
SupportedPlatforms.verify!platform_name
@current_platform = platform_name
block.call
@current_platform = nil
end | [
"def platform(&block)\n Loquacious::Configuration.for :platform, &block\n end",
"def for_platform(platform_name, &block)\n raise \"Configuration for platform '#{platform_name}' is defined multiple times!\".red if blocks[platform_name]\n blocks[platform_name.to_s] = block\n end",
"def platfo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is the given key a platform block or a lane? | def is_platform_block?(key)
raise 'No key given'.red unless key
return false if (self.runner.blocks[nil][key.to_sym] rescue false)
return true if self.runner.blocks[key.to_sym].kind_of?Hash
raise "Could not find '#{key}'. Available lanes: #{self.runner.available_lanes.join(', ')}".red
end | [
"def is_platform_block?(key)\n raise 'No key given'.red unless key\n\n return false if self.runner.lanes.fetch(nil, {}).fetch(key.to_sym, nil)\n return true if self.runner.lanes[key.to_sym].kind_of? Hash\n\n raise \"Could not find '#{key}'. Available lanes: #{self.runner.available_lanes.join(', ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves list of supported file formats. | def get_supported_file_formats(request)
begin
data, _status_code, _headers = get_supported_file_formats_with_http_info(request)
rescue ApiError => e
if e.code == 401
request_token
data, _status_code, _headers = get_supported_file_formats_with_http_info(reque... | [
"def get_supported_file_types\n response = api.get(url_misc('supported-file-types'))\n response\n end",
"def formats\n @formats ||= Dir[File.join(path, \"#{name}.{otf,svg,ttf,woff,woff2,eot}\")].map {|file| File.extname(file)[1..-1] }.sort\n end",
"def supported_formats\n output = `vips --li... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets device data from backend service and updates its color and ALS state. Params: +info+:: +DeviceInfo+ object. +state+:: +DeviceState+ object which will be updated with data from backend. Returns true if devState has been changed, false otherwise. | def getDeviceState(info, state)
res = apiGet("devices/#{info.deviceId}")
succeed = false
if res.status == 200
response = nil
begin
response = JSON.parse(res.body)
rescue Exception => e
$LOG.warn("Invalid body received! Err: #{e.message}")... | [
"def device_state_correct?\n case device_state\n when \"enabled\"\n return true if need_activation?\n\n when \"disabled\"\n return true if need_deactivation?\n\n when \"reactivation\"\n return false\n\n when \"quaranteed\"\n return true if need_quaranteeing?\n end\n return f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send device SW version and serial number to backend service. Params: +info+:: +DeviceInfo+ object. | def putDeviceInfo(info)
params = {
:software_version => info.swVersion,
:serial_number => info.serialNb
}
res = apiPut("devices/#{info.deviceId}", params)
if res.status != 200
$LOG.warn("Failed to put device info to backend! Status: #{res.status}, Response: #{res.... | [
"def sendInfo(devInfo)\r\n msg = {\r\n :type => \"info\",\r\n :version => devInfo.swVersion\r\n }\r\n sendMsg(msg)\r\n end",
"def change_device serial\n logger.debug \"Updating to device serial number #{serial}\"\n @comm_log = \"\"\n @comm_log_timestamp = false\n @resul... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send device color to backend service. Params: +info+:: +DeviceInfo+ object. +color+:: HSV collor array. | def putColor(info, color)
params = {
:color_hue => color[0].to_s,
:color_saturation => color[1].to_s,
:color_value => color[2].to_s
}
res = apiPut("devices/#{info.deviceId}", params)
if res.status != 200
$LOG.warn("Failed to put color to backend! Status: ... | [
"def sendUserColor(devInfo, color)\r\n msg = {\r\n :type => \"user-color\", \r\n :device_id => devInfo.deviceId,\r\n :user_color => {\r\n :hue => color[0],\r\n :saturation => color[1],\r\n :value => color[2]\r\n }\r\n }\r\n sendMsg(msg)\r\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send device readings (temp. and humid.) to backend service. Params: +info+:: +DeviceInfo+ object. +state+:: +DeviceState+ object. | def postReadings(info, state)
params = {
:device_id => info.deviceId,
:sensor_data => [
{
:type => "Temperature",
:value => state.temperature,
:time => Time.now.to_i
},
{
:type => "Humidity",
:valu... | [
"def sendStreaming(devInfo, devState)\r\n msg = {\r\n :type => \"streaming\", \r\n :version => devInfo.swVersion,\r\n :sensor_data => [\r\n {\r\n :type => \"Temperature\", \r\n :value => devState.temperature,\r\n :time => Time.now.to_i\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Triggers new alarm upload sound file to S3 (if given), update storage url and post new alarm. Finally +alarm+ is updated with posted alarm Id. Params: +info+:: +DeviceInfo+ object. +alarm+:: +DeviceAlarms::State+ object. +type+:: Given alarm type. | def triggerAlarm(info, alarm, type)
uploadSoundFile(info, alarm, type)
params = {
:device_id => info.deviceId,
:alarm_type => type,
:storage_url => alarm.storageUrl
}
res = apiPost("alarms", params)
if res.status == 201
begin
res... | [
"def uploadSoundFile(info, alarm, type)\r\n if !alarm.sound.nil?\r\n # reset storageUrl\r\n alarm.storageUrl = nil\r\n\r\n # get new urls\r\n params = {\r\n :device_id => info.deviceId,\r\n :alarm_type => type\r\n }\r\n res = apiPost(\"storage/alarm\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tries to upload associated sound, if given, and update storageUrl. | def uploadSoundFile(info, alarm, type)
if !alarm.sound.nil?
# reset storageUrl
alarm.storageUrl = nil
# get new urls
params = {
:device_id => info.deviceId,
:alarm_type => type
}
res = apiPost("storage/alarm", params)
... | [
"def upload\n\t\tfull_path = \"#{Dir.pwd}/uploads/#{params[:file].original_filename}\" \n\t\t`cp #{params[:file].path} #{full_path}` \n\t\t`chmod 777 #{full_path}` # file is owned by root because we are running on port 80.\t\n\t\tSound.create({\n\t\t\t:path => full_path,\n\t\t\t:label => params[:label],\n\t\t\t:fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a registration key for use with the course. | def generate_registration_key
self.registration_key = 'C'.freeze + SecureRandom.base64(8)
end | [
"def generate_registration_key\n @current_course.generate_registration_key\n end",
"def generate_registration_key\n self.registration_key = \"C#{SecureRandom.base64(8)}\"\n end",
"def generate_registration_key(components)\n string_to_encode = components.join('|')\n\n Digest::MD5.hexdigest(stri... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test if the course has a root folder. | def root_folder?
if new_record?
material_folders.find(&:root?).present?
else
material_folders.find_by(parent: nil).present?
end
end | [
"def root?\n @root_folder\n end",
"def root?\n !!(chop_basename(@path) == nil && @path.include?('/'))\n end",
"def root?\n \tfolder_id.nil?\n end",
"def root?\n parent_folder_id.nil?\n end",
"def root?\n !self.hier? || self.path == '/' || self.path.to_s.empty?\n end",
"def root?... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register a record with the current transaction so that its after_commit and after_rollback callbacks can be called. | def add_transaction_record(record)
current_transaction.add_record(record)
end | [
"def add_transaction_record(record)\n self.current_transaction.add_record(record)\n end",
"def after_commit(&blk)\n ActiveRecord::Base.connection.add_transaction_record(\n AfterCommitWrapper.new(&blk)\n )\n end",
"def register_record(record)\n @identity_map[record.id] = record\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validate and submit the request | def submit!
raise InvalidRequest.new(self) unless valid?
command.call(self)
end | [
"def submit(_params)\n raise UnsubmittableForm\n end",
"def validate_request\n return unless request.post? || request.patch?\n return unless self.class.openapi_enabled\n\n api_version = self.class.send(:api_version)[1..-1].sub(/x/, \".\")\n\n self.class.send(:ap... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Triangulation subroutine Takes as input vertices in array vertices Returned is a list of triangular faces in the array tris These triangles are arranged in a consistent clockwise order. | def triangulate(vertices)
edges = []
tris = []
# sort by X coord
vertices = vertices.sort_by {|p|p.x}
# center/radius cache used by circum_circle
cc_cache = {}
# Set up the supertriangle
# This is a triangle which encompasses all the sample points.
# The supertriangle coordinates are ... | [
"def add_triangles(pbar, ents, points, triangles, start, count)\r\n mesh = Geom::PolygonMesh.new(points.size, count)\r\n points.each{ |pt| mesh.add_point(Geom::Point3d.new(pt[0..2])) }\r\n (start..(start + count - 1)).each { |i|\r\n k = i * 3\r\n break if k + 3 > triangles.siz... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return TRUE if a point p is inside the circumcircle made up of the points p1, p2, p3 The circumcircle center is returned in (xc,yc) and the radius r The return value is an array [ inside, xc, yc, r ] Takes an optional cache hash to use for radius/center caching NOTE: A point on the edge is inside the circumcircle | def circum_circle(p, p1, p2, p3, cache = nil)
dx,dy,rsqr,drsqr = []
cached = cache && cache[[p1, p2, p3]]
xc, yc, r = []
rsqr = 0
if cached
xc, yc, r, rsqr = cached
else
# Check for coincident points
if (points_are_coincident(p1,p2) || points_are_coincident(p2,p3) || points_are_c... | [
"def circum_circle(p, p1, p2, p3, cache = nil)\n dx,dy,rsqr,drsqr = []\n cached = cache && cache[[p1, p2, p3]]\n xc, yc, r = []\n rsqr = 0\n\n if cached\n xc, yc, r, rsqr = cached\n else\n # Check for coincident points\n if (points_are_coincident(p1,p2) || points_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The token_type of the token_permission_type Returns String | def to_s
token_type
end | [
"def permission_type\n return @permission_type\n end",
"def getTokenType\n token = getToken()\n return token ? token.type : nil\n end",
"def token_type; end",
"def get_token(type)\n form_data = {\"action\" => \"tokens\", \"type\" => type}\n res = make_api_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /prd_attributes/new GET /prd_attributes/new.xml | def new
@prd_attribute = PrdAttribute.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @prd_attribute }
format.json { render :json => @prd_attribute }
end
end | [
"def new\n @prd_attribute_device = PrdAttributeDevice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prd_attribute_device }\n end\n end",
"def new\n @attr_type = AttrType.new\n\n respond_to do |format|\n format.html # new.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /prd_attributes POST /prd_attributes.xml | def create
@prd_attribute = PrdAttribute.new
@prd_attribute.bill_type_id = params[:prd_attribute]['bill_type'].to_i
@prd_attribute.name = params[:prd_attribute]['name']
@prd_attribute.rollover = params[:prd_attribute]['rollover']
@prd_attribute.code = params[:prd_attribute]['code']
@prd_attrib... | [
"def create\n @prd_attribute_device = PrdAttributeDevice.new(params[:prd_attribute_device])\n\n respond_to do |format|\n if @prd_attribute_device.save\n format.html { redirect_to(@prd_attribute_device, :notice => 'PrdAttributeDevice was successfully created.') }\n format.xml { render :xml ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /prd_attributes/1 PUT /prd_attributes/1.xml | def update
@prd_attribute = PrdAttribute.find(params[:id])
@prd_attribute.code = params[:prd_attribute]['code']
@prd_attribute.name = params[:prd_attribute]['name']
@prd_attribute.rollover = params[:prd_attribute]['rollover']
@prd_attribute.description = params[:prd_attribute]['description']
@p... | [
"def update\n @catalog_product_attributes = CatalogProductAttributes.find(params[:id])\n\n respond_to do |format|\n if @catalog_product_attributes.update_attributes(params[:catalog_product_attributes])\n flash[:notice] = 'CatalogProductAttributes was successfully updated.'\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /prd_attributes/1 DELETE /prd_attributes/1.xml | def destroy
@prd_attribute = PrdAttribute.find(params[:id])
@prd_attribute.destroy
#delete_rules()
respond_to do |format|
format.html { redirect_to(prd_attributes_url) }
format.xml { head :ok }
format.json { head :ok }
end
end | [
"def destroy\n @prd_attribute_device = PrdAttributeDevice.find(params[:id])\n @prd_attribute_device.destroy\n\n respond_to do |format|\n format.html { redirect_to(prd_attribute_devices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @catalog_product_attributes = CatalogPro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if the given node is valid | def is_valid(node = @current_node)
return node != nil
end | [
"def is_valid_node?(node)\n # SchemaFieldValidators can never determine if they can handle\n # a node, since they use a sub validator for work.\n true\n end",
"def is_node_valid(node)\n\t\tis_node(node) && is_node_in_graph(node)\n\tend",
"def valid_node?(node_path, ctype=nil)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current node. | def set_current(node)
@current_node = node
end | [
"def set_node(node)\n @node = node\n end",
"def process(node)\n self.current_node = node\n super\n ensure\n self.current_node = nil\n end",
"def node=(val)\n attributes['node'] = val\n end",
"def node=(node)\n retract[:node] = node\n end",
"def set_root... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the root node of the current xml document | def root
return @doc == nil ? nil : @doc.root;
end | [
"def root_node\n if @root_node.nil?\n # TODO: Fix this so that added content at the end of the file doesn't\n # break this stuff.\n # E.g.: http://smogzer.tripod.com/smog.rdf\n # ===================================================================\n begin\n if self.xm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the line of the given node | def line(node = @current_node)
return is_valid(node) ? node.line : nil
end | [
"def line_number(node)\n node.loc.line\n end",
"def line\n @line ||= Line.get(@attrs['LineCode'])\n end",
"def following_node_line(node)\n [\n [node.children.first, next_node(node)].compact.map(&:line),\n @document.source_lines.count + 1,\n ].flatten.min\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of children of the current node | def children
return children_of @current_node
end | [
"def children\n (0...@node.children.length).map {|i| get_subnode(i) }\n end",
"def children\n node.children\n end",
"def children\n node.children\n end",
"def childNodes\n children\n end",
"def child_nodes\n each_child_node.to_a\n end",
"def get_children\n retu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract children from an object into an array. Intended for use with Node and NodeSet objects | def extract_children_from(obj)
if obj.nil? then
return []
end
output = []
set = obj.children
set.each do |node|
output << node
end
return output
end | [
"def node_children(node); node.to_a; end",
"def children\n (0...@node.children.length).map {|i| get_subnode(i) }\n end",
"def get_children\n return @children\n end",
"def children\n ary = normal_children.dup\n ary << fallback_child if fallback_child\n ary\n end",
"def getObject... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the attribute keys of the current node | def attr_keys
return attr_keys_in @current_node
end | [
"def attr_keys_in(node)\n\t\treturn is_valid(node) ? node.keys : nil\n\tend",
"def keys\n @attributes.keys\n end",
"def attribute_keys\n @attributes.keys\n end",
"def keys\n getAttributeNames.to_a\n end",
"def get_attributes node\n if node.attributes\n return node.attributes.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the attribute keys of the given node | def attr_keys_in(node)
return is_valid(node) ? node.keys : nil
end | [
"def attr_keys\n\t\treturn attr_keys_in @current_node\n\tend",
"def attributes_of(node)\n\t\tmap = Hash.new\n\t\t\n\t\tif !is_valid node then\n\t\t\treturn map\n\t\tend\n\t\t\n\t\tvarKeys = attr_keys_in node\n\t\tif !varKeys.nil? then\n\t\t\tvarKeys.each do |key|\n\t\t\t\tmap[key] = node[key]\n\t\t\tend\n\t\tend\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a hash of attributes for the current node | def attributes
return attributes_of @current_node
end | [
"def attributes\n attribute_nodes.each_with_object({}) do |node, hash|\n hash[node.node_name] = node\n end\n end",
"def attributes\n node.attributes[key]\n end",
"def to_hash\n { self.class.root_node.to_sym => attributes }\n end",
"def get_attributes node\n if node... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a hash of attributes for a given node | def attributes_of(node)
map = Hash.new
if !is_valid node then
return map
end
varKeys = attr_keys_in node
if !varKeys.nil? then
varKeys.each do |key|
map[key] = node[key]
end
end
return map
end | [
"def get_attributes(node)\n attributes = {}\n node.attributes.each { |n,v| attributes[n] = v }\n attributes\n end",
"def attributes\n attribute_nodes.each_with_object({}) do |node, hash|\n hash[node.node_name] = node\n end\n end",
"def get_attributes node\n if node... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the parent of the current node | def parent
return parent_of @current_node
end | [
"def parent_node\n return if document_location.root?\n\n relative_node(\"#..\")\n end",
"def parent\n unless @node.send(@parent).nil?\n @node = @node.send(@parent)\n end\n end",
"def parent_node(node)\n return node.respond_to?(:parent) ? node.parent : node\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the parent of the given node | def parent_of node
return is_valid(node) ? node.parent : nil
end | [
"def parent_node(node)\n return node.respond_to?(:parent) ? node.parent : node\n end",
"def parent\n unless @node.send(@parent).nil?\n @node = @node.send(@parent)\n end\n end",
"def parent_node\n return if document_location.root?\n\n relative_node(\"#..\")\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the previous element of the current node | def prev_element
return prev_element_of @current_node
end | [
"def get_prev()\n return @prev_node\n end",
"def previous_element\n node = self\n\n while node = node.previous\n return node if node.is_a?(Element)\n end\n\n return\n end",
"def prev_element_of(node)\n\t\treturn valid(node) ? node.previous_element : nil\n\tend",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the previous element of the given node | def prev_element_of(node)
return valid(node) ? node.previous_element : nil
end | [
"def get_prev()\n return @prev_node\n end",
"def prev_element\n\t\treturn prev_element_of @current_node\n\tend",
"def previous_element\n node = self\n\n while node = node.previous\n return node if node.is_a?(Element)\n end\n\n return\n end",
"def previous_element\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the previous sibling of the current node | def prev_sibling
return prev_sibling_of @current_node
end | [
"def sibling_prev\n @parent.get(index - 1) unless is_first_sibling?\n end",
"def previous_sibling\n return nil if is_root?\n\n myidx = parent.children.index(self)\n parent.children.at(myidx - 1) if myidx && myidx > 0\n end",
"def prev_sibling_of(node)\n\t\treturn valid(node) ? node.pre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the previous sibling of the given node | def prev_sibling_of(node)
return valid(node) ? node.previous_sibling : nil
end | [
"def prev_sibling\n\t\treturn prev_sibling_of @current_node\n\tend",
"def sibling_prev\n @parent.get(index - 1) unless is_first_sibling?\n end",
"def previous_sibling\n return nil if is_root?\n\n myidx = parent.children.index(self)\n parent.children.at(myidx - 1) if myidx && myidx > 0\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the next element of the current node | def next_element
return next_element_of @current_node
end | [
"def get_next()\n return @next_node\n end",
"def get_next()\r\n return @next_node\r\n end",
"def next_element\n node = self\n\n while node = node.next\n return node if node.is_a?(Element)\n end\n\n return\n end",
"def next_node\n @current_node = @current_no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the next element of the given node | def next_element_of(node)
return valid(node) ? node.next_element : nil
end | [
"def next_element\n\t\treturn next_element_of @current_node\n\tend",
"def next_element\n node = self\n\n while node = node.next\n return node if node.is_a?(Element)\n end\n\n return\n end",
"def get_next()\n return @next_node\n end",
"def get_next()\r\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the next sibling of the current node | def next_sibling
return next_sibling_of @current_node
end | [
"def next_sibling\n return nil if root?\n\n myidx = parent.children.index(self)\n parent.children.at(myidx + 1) if myidx\n end",
"def next_sibling\n return nil if is_root?\n\n myidx = parent.children.index(self)\n parent.children.at(myidx + 1) if myidx\n end",
"def next_sibling\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the next sibling of the current node. | def next_sibling_of(node)
return valid(node) ? node.next_sibling : nil
end | [
"def next_sibling\n\t\treturn next_sibling_of @current_node\n\tend",
"def next_sibling\n return nil if is_root?\n\n myidx = parent.children.index(self)\n parent.children.at(myidx + 1) if myidx\n end",
"def next_sibling\n return nil if root?\n\n myidx = parent.children.index(self)\n pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns set of elements by type | def elements_by_type(type)
return xpath('//' + type)
end | [
"def find_all_by_type(type)\n find_all { |r| r.type == type }\n end",
"def allType(type)\n newArr = []\n @arr.each do |value|\n if (value.instance_of? type)\n newArr.push(value)\n end\n end\n return newArr\n end",
"def find_all(type)\n points = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes a new keychain from the specified keychain file | def initialize(options={})
unless options.has_key?(:keychain_file) || options.has_key?(:keychain_data)
raise ArgumentError, 'Either a keychain_file or keychain_data is required to create a new keychain class'
end
@keychain = options[:keychain_data] || JSON.parse(IO.read(options[:keychain_file... | [
"def open(path)\n raise ArgumentError unless path\n out_buffer = FFI::MemoryPointer.new(:pointer)\n status = Sec.SecKeychainOpen(path,out_buffer);\n Sec.check_osstatus(status)\n Keychain.new(out_buffer.read_pointer).release_on_gc\n end",
"def keychain\n @keychain ||= SimCtl::Keych... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lists the names of all keys in the keychain | def list
@keychain.keys
end | [
"def list_keys\n client.make_request('/list-keys', 'get')\n end",
"def list_keys()\n # TODO\n end",
"def list_keys(*keys)\n list_public_keys(*keys)\n end",
"def stored_keychain_lists\n @stored_keychain_lists ||= `security -q list-keychains |grep Boom.list` \\\n .split(/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Index action to render all companies | def index
@companies = Company.all
end | [
"def index\n @companions = Companion.all\n end",
"def index\n @about_companies = AboutCompany.all\n end",
"def index\n @main_companies = MainCompany.all\n end",
"def index\n @companies = Company.all\n respond_to do |format|\n format.json { render :json => @companies }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /proposals/passed GET /proposals/passed.json | def passed
# the non-preliminary ones go first
@proposals = Proposal.select{ |p| p.committee.preliminary == false and p.status == 'Passed'}
@proposals += Proposal.select{ |p| p.committee.preliminary == true and p.status == 'Passed'}
respond_to do |format|
format.html # passed.html.erb
forma... | [
"def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end",
"def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json... | {
"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.