query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Checks if a network exists or not | def network_exists?(name)
net_obj = Com::Vmware::Vcenter::Network.new(vapi_config)
filter = Com::Vmware::Vcenter::Network::FilterSpec.new(names: Set.new([name]))
net = net_obj.list(filter)
raise format("Unable to find target network: %s", name) if net.empty?
end | [
"def network_exists?(network_name)\n networks_list.include?(network_name)\n end",
"def network_exists?(network_name,network_addr=nil)\n network_names = list_objtype(\"ent\")\n if network_names.include?(network_name)\n return true\n end\n network_names.each do |net_name|\n a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get location of lookup service | def lookup_service_host
# Allow manual overrides
return config[:lookup_service_host] unless config[:lookup_service_host].nil?
# Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service.
vim = RbVmomi::VIM.connect @connection_options
vim_settings = vim... | [
"def service_location\n return @service_location\n end",
"def lookup\n if !options[:street_address] and (options[:ip_address] or ip_address?)\n name = options[:ip_lookup] || Configuration.ip_lookup || Geocoder::Lookup.ip_services.first\n else\n name = options[:loo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== GET /about/list/:topic An informational listing on a given subject. == GET /about/list/library == GET /about/list/libraries == GET /about/list/location == GET /about/list/locations | def list
@topic = get_topic(params)
@topic_list = get_topic_list(@topic)
respond_to do |format|
format.html
format.xml { render xml: @topic_list.to_xml }
format.json { render json: @topic_list.to_json }
end
end | [
"def list\n\t\t@notes = Note.where(topic: params[:topic])\n\tend",
"def index\n joins = {:user_id => doorkeeper_token.resource_owner_id, :slug => params[:topic_id]}\n joins.merge!(:application_id => doorkeeper_token.application_id) unless has_scope?(\"read_any_publications\")\n @publications = Topi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== GET /about/solr == GET /about/solr?lens=:lens Administratoronly Solr information. | def solr
@solr_fields = get_solr_fields
@solr_info = get_solr_information
end | [
"def solr_stats\n @solr_stats = get_solr_statistics\n render 'about/solr'\n end",
"def url\n \"http://127.0.0.1:#{port}/solr/\"\n end",
"def solr\n @solr ||= RSolr.connect(url: solr_url)\n end",
"def url\n \"http://#{host}:#{port}/solr/\"\n end",
"def search_solr( solr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== GET /about/solr_stats Administratoronly Solr information. | def solr_stats
@solr_stats = get_solr_statistics
render 'about/solr'
end | [
"def solr\n @solr_fields = get_solr_fields\n @solr_info = get_solr_information\n end",
"def stats\n perform_get('/stats', Neows::Models::Stat)\n end",
"def stats\n request :get, \"_stats\"\n end",
"def solr_status\n show_environment_info\n log_block('get server status') ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
== DELETE /about/log Administratoronly command to wipe the application log. | def log_wipe
lines = wipe_log
respond_with(lines, template: 'about/log')
end | [
"def clear_log\n request('clearLog')\n end",
"def rm_log\n FileUtils.rm_rf( logfile_path ) \n end",
"def delete_log\n unless UserSession.find == nil\n Log.create(user_id: self.user.id, message: \"#{UserSession.find.user.name} har slettet kortet til #{self.user.name}.\", logtyp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override __prefix__ class method to have better prefixes for some of these longer vocabulary names. | def __prefix__
__name__.demodulize.underscore.dasherize.to_sym
end | [
"def __prefix__=(prefix)\n params = RDF::Vocabulary.vocab_map[__prefix__]\n @__prefix__ = prefix.to_sym\n RDF::Vocabulary.register(@__prefix__, self, **params)\n @__prefix__\n end",
"def name_prefix; end",
"def words_with_prefix(prefix, words)\n raise NotImplementedError # TODO... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make department requirement junction when new requirement is made. Also serves as a Model.within(dept), minus foreign key injection | def core(d)
dept = Department.search!(d)
raise "[Requirement.core] Error: core already declared for department #{dept.name}" unless dept.core_requirements.empty?
requirement = make "#{dept.abbreviation}"
# make junctions
mk = self.method(:make)
se... | [
"def add_department(valid_department)\n departments << valid_department\n end",
"def department=(new_department) \n\n @department.users.delete(self) \n\n @department = new_department \n\n @department.users << self \n\n end",
"def belongs_to_sublease(tenant, options = {})\n belongs_to tenant... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Configure the isaac backend for basic functions | def configure
# Give the bot a handle to config and handler
conf = @config
# Configure the bot
@bot = Isaac::Bot.new
@bot.configure{|c|
c.server = conf[:server]
c.port = conf[:port]
c.ssl = conf[:ssl]
c.nick = conf[:... | [
"def main_audio ; end",
"def backends=(_arg0); end",
"def enable_backend\n add option: \"-backend=true\"\n end",
"def convert_audio_to_aac(stream, index)\n disposition = (index == 0) ? 'default' : 'none'\n return [ \"-map 0:a:#{stream[:index]}\",\n \"-metadata:s:a:#{index} title='Stereo T... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run the bot This can be done in a blocking or nonblocking way if verify is true and threaded is true, the bot will sit and check that it has successfully connected before continuing (and raise an exception on connection failure). | def run(threaded=true, verify=true)
$log.info "Starting IRC Bot..."
if threaded then
# Run the bot.
@thread = Thread.new do
$log.info "Bot thread started."
@bot.start
end
# Wait for it to connect
if verify then
delay = 0
... | [
"def run\n # Jabber::debug = true\n @client = Jabber::Client.new(@jid)\n @client.allow_tls = false\n @client.connect\n @client.auth(@password)\n @client.send(Presence.new.set_type(:available))\n\n @room = Jabber::MUC::SimpleMUCClient.new(@client)\n\n # SimpleMUCClient callback-blocks\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is the bot currently connected? Falls through to Isaac. | def connected?
@bot.connected?
end | [
"def is_connected?\n if @client.is_connected?\n @log.info \"Asked if bot is connected: YES it is\"\n return true\n else\n @log.info \"Asked if bot is connected: NO it isn't\"\n return false\n end\n end",
"def is_connected?\n return @status == CONNECTED\n end",
"def is_conne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Which server is the bot connected to? | def server
@bot.server
end | [
"def current_remote_server; end",
"def current_server\n @_current_server\n end",
"def server\n object.player_server_id\n end",
"def bot_mode\n self['BOT']\n end",
"def nick\n @bot.nick\n end",
"def server\n Whois::Server.list[@server_tld_key] rescue nil\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Which nick does the bot currently have? | def nick
@bot.nick
end | [
"def nick\r\n return for_context(nil, false) { |c| c.nick }\r\n end",
"def nickname\n @nick\n end",
"def context_nick nick\n case nick.downcase\n when \"you\"; server.current_nick\n when \"me\" ; sender.nick\n else ; nick\n end\n end",
"def nick_name\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tell the bot to join a channel | def join(channel)
@bot.join(channel)
end | [
"def join(channel)\n send \"JOIN #{channel}\"\n end",
"def irc_send_join(channel)\n # We send an IRC message that joins a channel\n irc_send(\"JOIN #{channel}\")\nend",
"def join(channel)\n self.class.post('/channels.join', body: {name: channel, token: @token}).tap do |response|\n raise \"erro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register a command, only invoked when COMMAND_RX is triggered. mod A link to the module object, used in tracking threads name A name for this command, for unregistering later trigger A regex which, if the command matches (see COMMAND_RX), will cause the callback to fire types The types of message to respond to. p A pro... | def register_command(mod, name, trigger, types = /channel/, &p)
raise "Please define a block" if not block_given?
raise "That command is already hooked." if @cmds[name]
raise "The module given is not a module" if not mod.is_a?(HookService)
# Ensure types is an array and is ... | [
"def register_hook(mod, name, trigger = nil, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @hooks[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n trigger ||= lamb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register a hook to be run on any message. mod A link to the module object, used in tracking threads name A name for this hook, for unregistering later trigger A procedure to run. If this returns true, it will cause the callback to fire. types The types of message to respond to. p A procedure to run when all the checks ... | def register_hook(mod, name, trigger = nil, types = /channel/, &p)
raise "Please define a block" if not block_given?
raise "That command is already hooked." if @hooks[name]
raise "The module given is not a module" if not mod.is_a?(HookService)
trigger ||= lambda{|*| return t... | [
"def dispatch_hooks(msg, type, bot)\n return if @hooks.length == 0\n\n @hooks_mutex.synchronize{\n @hooks.each{|name, hook|\n types, trigger, p, mod, mod_info = hook[:types], hook[:trigger], hook[:proc], hook[:module], @modules[hook[:module]]\n\n # Go through and kill any old thre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove a selection of hooks by name If the first argument is a number, it will be used as the timeout when waiting for any threads to end. If no timeout is given, it will wait indefinitely for threads to end. | def unregister_hooks(*names)
# Load a timeout if one is given
names.delete(nil)
timeout = nil
if names and names[0].is_a?(Numeric) then
timeout = names[0].to_f
names = names[1..-1]
end
# Then unhook things
@hooks_mutex.synchronize{
names.each{|name|
... | [
"def unregister_commands(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # And then unhook things\n @hooks_mutex.synchronize{\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove cmd by name If the first argument is a number, it will be used as the timeout when waiting for any threads to end. If no timeout is given, it will wait indefinitely for threads to end. | def unregister_commands(*names)
# Load a timeout if one is given
names.delete(nil)
timeout = nil
if names and names[0].is_a?(Numeric) then
timeout = names[0].to_f
names = names[1..-1]
end
# And then unhook things
@hooks_mutex.synchronize{
names.each{|na... | [
"def remove_timeout id\n @queue[:timeouts].reject! do |timeout|\n next timeout[:id] == id\n end\n end",
"def remove(name)\n Monitor.new(name).remove\n end",
"def remove_command(name)\n @commands ||= {}\n @commands.delete name\n end",
"def remove_command(name)\n @embedde... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register a module by calling hook_thyself. Since modules should extend HookService, they should implement hook_thyself in order to make initial hooks. | def register_module(mod)
$log.debug "Registering module: #{mod.class}..."
mod.hook_thyself
end | [
"def register_hooks; end",
"def hook(name)\n @hook_name = name\n Container::Hook.register(name, self)\n end",
"def register_hook(mod, name, trigger = nil, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hoo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unregister all hooks and commands by unloading all modules. | def unregister_all(timeout = nil)
$log.debug "Unregistering all modules..."
# clone to avoid editing whilst iterating
unregister_modules(timeout, *@modules.keys.clone)
end | [
"def unregister_modules(timeout, *mods)\n @hook_manager.unregister_modules(timeout, *mods)\n end",
"def unregister\n\n # Commands...\n klass = self.class\n @commands.each do |k,v|\n\n # Remove method.\n name = case v[0]\n when CmdFlag_Normal: 'cmd_'\n when CmdFlag_Channel: 'c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Join all threads of a given module with an overall timeout | def join_module_threads(threads, timeout = nil)
return if not threads
threads.each{|t|
# Keep track of time
start = Time.now
# Allow the thread to close for up to timeout seconds
t.join(timeout)
# Then subtract how long it took for the next one
timeout -= (T... | [
"def join_all_threads\n\n #Wait for test threads to complete\n Thread.list.each {|t|\n if t != Thread.current\n $test_logger.log(\"Waiting for thread '#{t}' to completed\")\n t.join\n end\n }\n end",
"def join_threads(sleep_seconds_before_join: 1)\n # wait some... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dispatch things to hooks | def dispatch_hooks(msg, type, bot)
return if @hooks.length == 0
@hooks_mutex.synchronize{
@hooks.each{|name, hook|
types, trigger, p, mod, mod_info = hook[:types], hook[:trigger], hook[:proc], hook[:module], @modules[hook[:module]]
# Go through and kill any old threads,
... | [
"def perform_hooks!\n @perform_hooks = true\n end",
"def register_hooks; end",
"def hook1; end",
"def pre_hook_send(handler); end",
"def action_hook; end",
"def around_hooks; end",
"def call_hooks(*args, **kwargs)\n Hooks.call_for(self.to_s, *args, **kwargs)\n end",
"def call_h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
converts amount in float or integer into Money object | def money(amount)
Money.new((amount * 100).to_i)
end | [
"def coerce_money(v)\n SpookAndPuff::Money.new(v.to_s)\n end",
"def return_money(amount,currency)\n return Money.new(amount*100,currency)\n end",
"def instantiate amount, currency\n if amount.is_a?(BigDecimal)\n amount\n else\n BigDecimal(amount.to_s, precision_for(amount... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
UNIT TESTS FOR METHOD connect_angels_with_other(cities) | def test_angel_camp_connections
map = Map.new
# checking if Angel camp on index @cities[1]
# is connected with......
#
# First: with Nevada, it should be on index 0 of array connections
# checking Angel camp is connected with Nevada
# checking by name
assert_equal 'Nevada City', map.citi... | [
"def connect_virginia_with_other(cities)\n cities[3].connect cities[1]\n cities[3].connect cities[4]\n cities[3].connect cities[5]\n cities[3].connect cities[6]\n end",
"def test_travel_to_random_connecting_city\n test_prospector = Prospector.new 'p1'\n options = test_prospector.map.get_city(te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
UNIT TESTS FOR METHOD connect_sutter_with_other(cities) | def test_connect_sutter
map = Map.new
# testing connect with Coloma
assert_equal 4, map.cities[2].connections[1].id
# testing connect angel camp
assert_equal 1, map.cities[2].connections[0].id
end | [
"def connect_virginia_with_other(cities)\n cities[3].connect cities[1]\n cities[3].connect cities[4]\n cities[3].connect cities[5]\n cities[3].connect cities[6]\n end",
"def test_coloma_to_suttercreek_virginia_city\n test_map = Map.new\n test_city = test_map.get_city('Coloma')\n test_connect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /workout_templates/1 PUT /workout_templates/1.json | def update
@workout_template = WorkoutTemplate.find(params[:id])
respond_to do |format|
if @workout_template.update_attributes(params[:workout_template])
format.html { redirect_to @workout_template, notice: 'Workout template was successfully updated.' }
format.json { head :no_content }
... | [
"def update\n @workout_template = WorkoutTemplate.find(params[:id])\n\n respond_to do |format|\n if @workout_template.update_attributes(params[:workout_template])\n format.html { redirect_to(@workout_template, :notice => 'Workout template was successfully updated.') }\n format.xml { head :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /workout_templates/1 DELETE /workout_templates/1.json | def destroy
@workout_template = WorkoutTemplate.find(params[:id])
@workout_template.destroy
respond_to do |format|
format.html { redirect_to workout_templates_url }
format.json { head :no_content }
end
end | [
"def destroy\n @workout_template = WorkoutTemplate.find(params[:id])\n @workout_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(workout_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @customtemplate.destroy\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this could be optimized a tiny bit by only calling superclass.build_xray but i am le tired | def build_xray
@build_xray ||= begin
retval = Hash.new { |hash,key| hash[key] = {} }
klasses = []
klass = self
while klass && klass <= UIView
klasses.unshift(klass)
klass = klass.superclass
end
klasses.each do |klass|
xray_props = klas... | [
"def build_xml(builder)\n super(builder)\n builder.Type { |b| self.object_type.build_xml(b) } if object_type\n end",
"def inherited(subclass)\n\t\t\t# Attach instance variables to the metaclasses of newly formed child classes\n\t\t\t# clone from the root, which should always remain pristine\n\t\t\t\n\t\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
fetch currency rates from application configuration file config/currency_rate.yml will return currency rates along with it's type | def currency_rates
@currency_rates = fetch_currency_rates
end | [
"def currency_rates\n response['rates'][currency.target_currency.to_s]\n end",
"def currencies\n @client.make_request :get, settings_path('currencies')\n end",
"def update_rates\n clear_rates\n add_currency_rate(\"EUR\", 1)\n add_currency_rates(config[\"exchange_rates\"]) # rates from... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /trust_moneys GET /trust_moneys.json | def index
@trust_moneys = TrustMoney.all
end | [
"def show\n @trust = Trust.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trust }\n end\n end",
"def new\n @trust = Trust.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trust }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /trust_moneys/1 DELETE /trust_moneys/1.json | def destroy
@trust_money.destroy
respond_to do |format|
format.html { redirect_to trust_moneys_url, notice: 'Trust money was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @trust = Trust.find(params[:id])\n @trust.destroy\n\n respond_to do |format|\n format.html { redirect_to trusts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @trust\n @trust.destroy\n respond_to do |format|\n format.html { redir... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /alumni_news_items POST /alumni_news_items.json | def create
@alumni_news_item = AlumniNewsItem.new(alumni_news_item_params)
respond_to do |format|
if @alumni_news_item.save
format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully created.' }
format.json { render action: 'show', status: :created, location: @alum... | [
"def create\n @newsitem = current_user.newsitems.build(newsitem_params)\n @newsitem.agreed = false\n\n respond_to do |format|\n if @newsitem.save\n format.html { redirect_to @newsitem, notice: 'Newsitem was successfully created. Please wait for the moderators to agree on you... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /alumni_news_items/1 PATCH/PUT /alumni_news_items/1.json | def update
respond_to do |format|
if @alumni_news_item.update(alumni_news_item_params)
format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { ... | [
"def update\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n format.html { redirect_to @news_item, :notice => 'News item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: 'edit' }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /alumni_news_items/1 DELETE /alumni_news_items/1.json | def destroy
@alumni_news_item.destroy
respond_to do |format|
format.html { redirect_to alumni_news_items_url }
format.json { head :no_content }
end
end | [
"def delete_news_item(org_unit_id, news_item_id)\n path = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}/news/#{news_item_id}\"\n _delete(path)\nend",
"def destroy\n @news_item.destroy\n respond_to do |format|\n format.html { redirect_to news_items_url }\n format.json { head :no_content }\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Callback called after initialization. | def after_initialize
end | [
"def post_init\n end",
"def callback; end",
"def during_after_load; end",
"def on_setup_callbacks; end",
"def after_generate_callbacks; end",
"def postReady()\n\t\t\t#does nothing. extend in subclasses\n\t\tend",
"def after_pin_initialization\n end",
"def after_initialize\n configuratio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Callback before begin assertions. | def before_assert
end | [
"def before_assert(symbol=nil, &block)\n if block_given?\n @before_assert_callbacks << block\n elsif symbol\n @before_assert_callbacks << symbol\n end\n end",
"def before_assert(*symbols, &block)\n if block_given?\n @befor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The list of attributes that are permitted to be used as data attributes in tables and in the tag on show pages. | def html_data_attributes
data_attributes = record.class.columns.select do |column|
column.type.in?(%i[integer boolean datetime float uuid interval]) && !column.array?
end.map(&:name).map(&:to_sym)
api_attributes & data_attributes
end | [
"def attributes\n attrs = sort_members(@context.attributes).find_all{|a| @options.show_all || a.visibility == :public || a.visibility == :protected}\n attrs.collect{|a| {:name=>a.name, :visibility=>a.visibility, :rw=>a.rw, :description=>markup(a.comment, true)}}\n end",
"def attributes\n m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Executes a command in the Heroku Toolbelt | def heroku(command)
system("GEM_HOME='' BUNDLE_GEMFILE='' GEM_PATH='' RUBYOPT='' /usr/local/heroku/bin/heroku #{command}")
end | [
"def heroku(command, options = {}, &block)\n run \"heroku #{command} -a #{app}\", options, &block\n end",
"def cmd(app_name, args)\n execute \"heroku #{args} --app #{Shellwords.escape app_name}\"\n end",
"def deploy!\n puts \"Adding and committing compiled output for deployment..\"\n puts %x[git a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /flickr_accounts GET /flickr_accounts.json | def index
@flickr_accounts = FlickrAccount.all
end | [
"def index\n @accounts = current_user.person.facebook_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end",
"def social_accounts_for_a_project\n uri = \"#{@api_url}/#{@project_id}/accounts?access_token=#{@access_token}\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /flickr_accounts POST /flickr_accounts.json | def create
@flickr_account = FlickrAccount.new(flickr_account_params)
if @flickr_account.save
redirect_to flickr_accounts_path
else
render :new
end
# respond_to do |format|
# if @flickr_account.save
# format.html { redirect_to @flickr_account, notice: 'Flickr account was ... | [
"def add_social_account(social_account = {}); JSON[Api::post_social_accounts(social_account, self)]; end",
"def create\n @account = current_user.accounts.new(account_params)\n\n if @account.save\n render json: @account, status: :created, location: @account\n else\n render json: @account.errors,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /flickr_accounts/1 PATCH/PUT /flickr_accounts/1.json | def update
# respond_to do |format|
# if @flickr_account.update(flickr_account_params)
# format.html { redirect_to @flickr_account, notice: 'Flickr account was successfully updated.' }
# format.json { render :show, status: :ok, location: @flickr_account }
# else
# format.html { r... | [
"def update\n respond_to do |format|\n if @flickr_photo.update(flickr_photo_params)\n format.html { redirect_to @flickr_photo, notice: 'Flickr photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /flickr_accounts/1 DELETE /flickr_accounts/1.json | def destroy
# @flickr_account.destroy
# respond_to do |format|
# format.html { redirect_to flickr_accounts_url, notice: 'Flickr account was successfully destroyed.' }
# format.json { head :no_content }
# end
end | [
"def destroy\n @flickr_photo.destroy\n respond_to do |format|\n format.html { redirect_to flickr_photos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flickr_photo = FlickrPhoto.find(params[:id])\n @flickr_photo.destroy\n\n respond_to do |format|\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is a special version of popen which captures stdout, stdin and stdout and the PID of the executing process | def custom_popen(*cmd)
pw = IO::pipe # pipe[0] for read, pipe[1] for write
pr = IO::pipe
pe = IO::pipe
pid_pipe = IO::pipe # pipe for communicating the process id of the started process
executing_proc_pid = nil
pid = fork{
# child
executing_proc_pid = fork{
... | [
"def to_stdout_from_any_process; end",
"def spawn_process(command_line)\n host_stdout, cmd_stdout = IO.pipe\n host_stderr, cmd_stderr = IO.pipe\n\n pid = Process.spawn(command_line.command_environment, command_line.command, :out => cmd_stdout, :err => cmd_stderr)\n cmd_stdout.close\n cmd_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
does crazy things on arrays : The magic_array function takes an array of number or an array of array of number as parameter and return the same array : flattened (i.e. no more arrays in array) reversed with each number multiplicated by 2 with each multiple of 3 removed with each number duplicate removed (any number sho... | def magic_array(array)
array.flatten.reverse.map! {|i| i = i*2}.delete_if {|i| i.modulo(3) == 0}.uniq.sort
end | [
"def magic_array(array)\n return array.flatten.sort.map { |i| i*2 }.delete_if { |i| i % 3 == 0}.uniq\nend",
"def double_array(array)\n result = []\n 2.times { result << array }\n result.flatten\nend",
"def double_array(arr)\n arr_div_three = []\n arr_not_div_three = []\n arr.each do |number|\n if div_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
merges sections by prefering other's attributes FIXME: needs specing | def +(other)
fail "Unmergable sections:\n1) #{self.inspect}\n2) #{other.inspect}\nReason: values must differ." unless self.value == other.value
@attrs.each do |a|
case a
when Attribute
other.attrs << a unless other.attrs.map(&:name).include?(a.name)
when Section... | [
"def merge_metadata(existing_metadata, section, new_metadata); end",
"def merge_attributes\n attrs = self.attributes.dup.reject{ |k,v| ignored_merge_attributes.include?(k) }\n attrs.merge!(address_attributes) # we want addresses to be shown in the UI\n sorted = attrs.sort do |a,b|\n (ordered... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /facility_items GET /facility_items.json | def index
@facility_items = FacilityItem.where("true").order(:facility_name).page params[:page]
end | [
"def index\n if facility_params[:facility_id]\n @facility_items = FacilityItem.where(facility_id: @facility.id).order(:name).page params[:page]\n else \n @facility_items = [] \n for value in @template.template_facility_item do\n @facility_items.push(FacilityItem.find(value.facility_it... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /facility_items POST /facility_items.json | def create
@facility_item = FacilityItem.new(facility_item_params)
respond_to do |format|
if @facility_item.save
format.html { redirect_to @facility_item, notice: 'Facility item was successfully created.' }
format.json { render :show, status: :created, location: @facility_item }
els... | [
"def create\n @facility_item = FacilityItem.new(facility_item_params)\n\n respond_to do |format|\n if @facility_item.save\n format.html { redirect_to '/facilities/'+@facility_item.facility_id.to_s+'/facility_items', notice: 'Facility item was successfully created.' }\n format.json { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /facility_items/1 PATCH/PUT /facility_items/1.json | def update
respond_to do |format|
if @facility_item.update(facility_item_params)
format.html { redirect_to @facility_item, notice: 'Facility item was successfully updated.' }
format.json { render :show, status: :ok, location: @facility_item }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @facility_item.update(facility_item_params)\n format.html { redirect_to facility_facility_items_path(@facility_item.facility_id), notice: 'Facility item was successfully updated.' }\n format.json { render :show, status: :ok, location: @facility_item }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /facility_items/1 DELETE /facility_items/1.json | def destroy
@facility_item.destroy
respond_to do |format|
format.html { redirect_to facility_items_url, notice: 'Facility item was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @facility_item.destroy\n respond_to do |format|\n format.html { redirect_to facility_facility_items_path(facility_params), notice: 'Facility item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @facility = Facility.find(params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This should contain expected class of the returning message. Might be overwritten in child class | def expected_messages_class
self.class.name.sub("Lookups", "Messages").constantize
end | [
"def message_expectation_class; end",
"def message_class\n return Scene_Battle::Message\n end",
"def message_class\n @message_class || get_model_class(:Message)\n end",
"def message_for(test); end",
"def validates_type_error_message(m, klass)\n # SEQUEL6: Make this the defau... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate the last part of the breadcrumb for a static page within a unit | def getPageBreadcrumb(unit, pageName)
(!pageName || pageName == "home" || pageName == "campus_landing") and return []
pageName == "search" and return [{ name: "Search", id: unit.id + ":" + pageName}]
pageName == "profile" and return [{ name: "Profile", id: unit.id + ":" + pageName}]
pageName == "sidebar" and re... | [
"def extract_breadcrumb\n end",
"def max_breadcrumbs; end",
"def extract_breadcrumb\n\n end",
"def breadcrumbs\n breadcrumbs = link_to this_webapp.webapp_name, root_path, :class => 'first-breadcrumb'\n unless @breadcrumb.nil?\n breadcrumbs += content_tag(:label, \" > \")\n if @breadcrumb.kin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get recent items (with author info) for a unit, by most recent eschol_date | def getRecentItems(unit)
items = Item.join(:unit_items, :item_id => :id).where(unit_id: unit.id)
.where(Sequel.lit("attrs->\"$.suppress_content\" is null"))
.reverse(:eschol_date).limit(5)
return items.map { |item|
{ id: item.id, title: item.title, authors: getItemAuthors(item.id) }
... | [
"def getRecentItems(unitID, limit=5, item_id=nil)\n items = item_id ? Item.join(:unit_items, :item_id => :id).where(unit_id: unitID)\n .where(status: 'published')\n .exclude(id: item_id)\n .reverse(:added).limit(limit)\n : Item.j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Traverse the nav bar, including subfolders, yielding each item in turn to the supplied block. | def travNav(navBar, &block)
navBar.each { |nav|
block.yield(nav)
if nav['type'] == 'folder'
travNav(nav['sub_nav'], &block)
end
}
end | [
"def bootstrap_nav(*args, &block)\n levels = { :primary => 1, :secondary => 2, :tertiary => 3 }\n options = args.extract_options!\n level = levels[options[:level]] || (options[:level] || 1).to_i\n\n\n # If there are no arguments, use the current page\n args.unshift page if args.empty? && !p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For Displaying all The Shop Profiles | def index
@shops = current_user.shop_profiles
end | [
"def index\n @shopper_profiles = ShopperProfile.all\n end",
"def index\n @shop_profiles = ShopProfile.all\n end",
"def index\n @product_profiles = ProductProfile.all\n end",
"def index\n @professional_profiles = ProfessionalProfile.all\n end",
"def index\n @profs = Prof.all\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For Displaying all the Shop Products for a particular Shop Profile | def show
@shop_profile = ShopProfile.find(params[:id])
@items = @shop_profile.shop_products.where(shop_profile_id: @shop_profile.id)
.paginate(page: params[:page], per_page: 6).search(params[:search])
if !params[:category_id].nil?
@items = @shop_profile.shop_products.where(category_id: params[:category_id])
... | [
"def index\n @shopper_profiles = ShopperProfile.all\n end",
"def index\n @shop_profiles = ShopProfile.all\n end",
"def index\n @product_profiles = ProductProfile.all\n end",
"def index\n\t\t@shops = current_user.shop_profiles\n\tend",
"def shop_products\n products.shop_products\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For Creating a New Shop Profile for a Shopkeeper | def create
authorize ShopProfile
@shop = ShopProfile.new(shop_params)
@shop.build_address(address_params_shopkeeper)
if @shop.valid? and ! current_user.user_profile.nil?
current_user.shop_profiles << @shop
flash[:success] = 'Shop Details added'
redirect_to root_path
elsif current_user.user_profile.ni... | [
"def create\n @shopper_profile = ShopperProfile.new(shopper_profile_params)\n\n respond_to do |format|\n if @shopper_profile.save\n format.html { redirect_to @shopper_profile, notice: 'Shopper profile was successfully created.' }\n format.json { render action: 'show', status: :created, loca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For Updating a Shop Profile Details | def update
@shop = current_user.shop_profiles.find(params[:id])
authorize @shop
if @shop.update_attributes(shop_params) and @shop.address.update_attributes(address_params_shopkeeper)
flash[:success] = 'Updated Successfully'
redirect_to shop_profiles_path
else
flash[:danger] = 'Shop Details not Updated... | [
"def update\r\n respond_to do |format|\r\n if @shop_profile.update(shop_profile_params)\r\n format.html { redirect_to @shop_profile, notice: \"Shop profile was successfully updated.\" }\r\n format.json { render :show, status: :ok, location: @shop_profile }\r\n else\r\n format.html ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changing Status of a Shop Profile to Approved or Disapproved | def change_status
authorize ShopProfile
@shop = ShopProfile.find(params[:shop_profile_id])
#Calling method approve_shop from Model
ShopProfile.approve_shop(@shop, flash)
redirect_to request.referrer || root_path
end | [
"def change_status\n self.status = USER_STATUS_ACTIVE if (self.status == USER_STATUS_PENDING && self.confirmed?)\n end",
"def check_status\n\t\t@shop = ShopProfile.find_by(id: params[:shop_profile_id])\n\t\tif @shop.is_approved == false\n\t\t\tflash[:danger] = 'You are not approved to add products'\n\t\t\tre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns next wednesday from current date | def next_wednesday
date = self
while !date.wednesday?
date = date.next
end
date
end | [
"def next_weekday(weekday = 2)\n date = Date.today\n unless date.strftime(\"%w\") == weekday.to_s\n date += 1 + ((weekday -1 -date.wday) % 7)\n end\n date\n end",
"def next_weekday\n if next_day.on_weekend?\n next_week(:monday, same_time: true)\n else\n next_day\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Store data to memcache using the specified key ==== Parameters key:: The key identifying the cache entry data:: The data to be put in cache from_now:: The number of minutes (from now) the cache should persist | def cache_set(key, data, from_now = nil)
_expire = from_now ? from_now.minutes.from_now.to_i : 0
@memcache.set(key, data, _expire)
cache_start_tracking(key)
Merb.logger.info("cache: set (#{key})")
true
end | [
"def cache_set(key, data, from_now = nil)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n cache_directory = File.dirname(cache_file)\n FileUtils.mkdir_p(cache_directory)\n _expire = from_now ? from_now.minutes.from_now : nil\n cache_write(cache_file, Marshal.dump([data, _expire]))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Expire the cache entries matching the given key ==== Parameter key:: The key matching the cache entries ==== Additional info In memcache this requires to keep track of all keys (on by default). If you don't need this, set :no_tracking => true in the config. | def expire_match(key)
if @tracking_key
for _key in get_tracked_keys
expire(_key) if /#{key}/ =~ _key
end
else
Merb.logger.info("cache: expire_match is not supported with memcache (set :no_tracking => false in your config")
end
true
end | [
"def expire_cached(key:)\n Stockpile::CachedValueExpirer.expire_cached(key: key)\n end",
"def expire_cache!(key)\n raise 'The expire_cache method must be implemented'\n end",
"def cache_expire(key:)\n begin\n CACHE.delete(key)\n rescue Redis::CannotConnectError || Redis::ConnectionE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gives info on the current cache store ==== Returns The type of the current cache store | def cache_store_type
"memcache"
end | [
"def type\n @config[:caching][:type]\n end",
"def retrieve_store_class(store)\n require \"active_support/cache/#{store}\"\n rescue LoadError => e\n raise \"Could not find cache store adapter for #{store} (#{e})\"\n else\n ActiveSupport::Cache.const_get(store.to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Store the tracked keys in memcache (used by expire_match) ==== Parameter keys:: The keys to keep track of | def set_tracked_keys(keys)
@memcache.set(@tracking_key, keys)
end | [
"def expire_cache_keys *keys\r\n keys.each { |k| @cache.delete k.to_sym }\r\n end",
"def cache_all(keys, values, options = {})\n keys.zip(values) { |k, v| @cache.write(cache_key(k), v, options) }\n end",
"def _store(*key_elements, value)\n cache.put(_key(*key_elements), value)\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve tracked keys from memcache ==== Returns keys:: The tracked keys | def get_tracked_keys
@memcache.get(@tracking_key) || []
end | [
"def keys\n cache.keys\n end",
"def keys\n redis.hkeys(key)\n end",
"def getallkeys\t\t\t\t\n\t\t\treturn $redis.keys\"*\"\n\t\tend",
"def cache_objects_keys\n @object_data[].keys\n end",
"def key_ids\n @keys.keys\n end",
"def keys\n db = open_db\n begin\n ke... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Seed an image by passing its file name, imageable type (e.g. Banner, Product) and imageable id (the id of the object being the image belongs to) | def seed_image(filename, imageable_type, imageable_id)
Picture.create!(
:id => $image_id,
:image => image(filename),
:imageable_type => imageable_type,
:imageable_id => imageable_id
)
$image_id += 1
end | [
"def create(image)\n @image = image # Image\n end",
"def load_imageable\n klass = [Entree, Review].detect { |c| params[\"#{c.name.underscore}_id\"] }\n @imageable = klass.find(params[\"#{klass.name.underscore}_id\"])\n end",
"def add_sponsor_covenant_image(candidate)\n filename = 'actions.png'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
recipient (string) sms recipient in general format; e.g. '+886912345678' message (string) message content options (hash) optional config options.ignore_cert (boolean) Ignore SSL certificate or not options.insecure (boolean) Use plain HTTP or HTTPS options.mode (string) delivery mode 'bit' instant delivery (default) 'bu... | def deliver(recipient, message, options={})
protocol = options[:insecure] ? "http" : "https"
uri = URI.parse "#{protocol}://#{API_HOST}"
uri.path = case (options[:mode].to_sym rescue nil)
when nil, :bit
SMS_ENDPOINT
when :bulk
BULK_SMS_ENDPOINT
else
raise StandardError... | [
"def deliver_sms(params)\n#puts \"**** Message#deliver_sms; params=#{params}\"\n sms_gateway = params[:sms_gateway]\n phone_number_array = @contact_info.map {|c| c[:phone]}.compact.uniq\n phone_numbers = phone_number_array.join(',')\n assemble_sms()\n#puts \"**** sms_gateway.deliver #{sms_gateway} w #{p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET Modifies the starting location passed via URL (QR Codes) Passes starting location as the room number Redirects immediately to Map | def start
unless params[:origin].blank?
params[:origin].slice!(0) if params[:origin][0].upcase == "R" # Remove proceeding R if present
origin = params[:origin].to_s.rjust(4, '0').prepend("R") # Add zero padding and Prepend R
session[:start] = origin.upcase
end
redirect_to "/map"
end | [
"def qr\n @qrLink = nil\n @targetURL = nil\n\n room = Room.find(params[:originID]).first\n if room == nil\n raise ActionController::RoutingError.new('Origin Room Not Found')\n #render :status => 404, :layout => false\n else\n originRoom = room.room_number\n\n unless params[:destin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /logvisitor Logs a visitor. Called from redirect.js, which redirects to home after 2 minutes of inactivity. Logs a visitor after one minute of inactivity. | def logvisitor
@visitor.end = DateTime.current
@visitor.save
render :nothing => true
end | [
"def log_visit\n session_id = request.session_options[:id]\n client = DeviceDetector.new(request.env[\"HTTP_USER_AGENT\"])\n client_os = client.os_name\n if !VisitorLog.find_by_session_id(session_id)\n VisitorLog.create(:session_id => session_id, :logged_in => false, :device_type => client_os)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST Upload an SVG map | def map_upload
unless params[:uploaded_map].blank?
require 'fileutils'
# Ensure public/maps exists
FileUtils::mkdir_p "public/maps"
directory = "public/maps.tmp"
# Ensure a blank maps.tmp directory exists
FileUtils.rm_rf directory
FileUtils::mkdir_p directory
# Cop... | [
"def map=(svg)\n svg_to_img_to_s3 \"tripmap/#{self.id}.jpg\", svg\n map # return value is map, see below\n# rescue\n# map\n end",
"def export\n\t\t# create the file name: map title - indicator - event\n\t\tfilename = params[:hidden_form_map_title].clone()\n\t\tfilename << \"-\"\n\t\tfilename << params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
currently a noop method. If a format other than mongo query format is used for prefilters, this method would do the appropriate conversion | def convert_filter_to_mongo_query(filter)
filter
end | [
"def queryAndConvert() \n\t\tres = self.query()\n\t\treturn res.convert()\n end",
"def mongoize(object)\n case object\n when AnyType then object.mongoize\n when Hash \n v = object[:value]\n case object[:type].downcase\n when 'integer', 'decimal', 'boolean'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves the git channel for the specific IRC channel | def git_channel(channel)
return @channels[channel] if @channels[channel]
@channels[channel] = Git::Channel.new(@config[channel.server.name][channel.nname])
end | [
"def get_channel(build)\n channel = ''\n if build.is_branch_build\n channel = get_slack_channel(build.project)\n elsif !build.username.blank?\n channel = \"@#{build.username}\"\n end\n channel\n end",
"def get_channel(arg)\n server.get_channel(arg)\n end",
"def get_channel_by_n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Simply make sure that `opts` can be converted into a Hash, then does so. Then returns `opts` as a HashWithIndifferentAccess. | def sanitize_options(opts)
opts = opts.to_hsh rescue opts.to_h
HashWithIndifferentAccess.new(opts)
end | [
"def convert_options(options)\n\t\tHashWithIndifferentAccess.new(options)\n\tend",
"def to_hash_opts_with_defaults(opts, defaults = nil)\n if opts.is_a?(Hash)\n opts.dup\n elsif opts.is_a?(ActionController::Parameters)\n opts.to_h\n elsif defaults.is_a?(Hash)\n defa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Raises an error if `opts` does not contain the `key` | def validate_option_key(opts, key)
raise "opts[:#{key}] or opts['#{key}'] must be given" unless opts.has_key?(key)
end | [
"def check_keys(*args)\n options = args.shift\n args.each do |key|\n raise MissingParameter.new(key) unless options.key?(key)\n end\n end",
"def required_option(options, key)\n result = get_option(options, key)\n raise ArgumentError, \"Missing required option: #{key}\" if result == \"\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts the input entertrack (probably from barcode scanner) into the computer_id | def track_to_id
self.computer_id = (entertrack - 10000000)
end | [
"def rom_id\n read_bytes(0x3C, 2)\n end",
"def device_id\n response = meta(nil,:info).first\n manufacturer = response[/^Manufacturer: (.*)/,1].strip\n model = response[/^Model: (.*)/,1].strip\n revision = response[/^Revision: (.*)/,1].strip\n imei = response[/^IMEI: (.*)/,1].strip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensures that a computer's status can only be either scrapped or sold | def scrapped_or_sold
if (scrapped.blank? and sold.blank?)
# Do nothing
elsif !(scrapped.blank? ^ sold.blank?)
errors.add(:base, "Please indicate whether a computer has been scrapped or sold, not both.")
end
end | [
"def can_be_assigned?\n\t\t(!status.include? STATUS[\"Assigned\"]) && (!status.include? STATUS[\"Repair\"])\n\tend",
"def check_book_availability\n if self.book.book_copies.unassigned_copies.where(is_active: true).count < 1\n errors.add(:base, \"Book out of stock\")\n end\n end",
"def player_1_wins_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensures that a customer and price can only be assigned for sold computers | def been_sold
if (customer.present? or price.present?) and sold != true
errors.add(:base, "Only sold computers can have customers or prices.")
end
end | [
"def customer_can_afford_pet(customer, new_pet)\n customer[:cash] >= 100\nend",
"def customer_can_afford_pet(customer, cost_of_pet)\n customer[:cash] >= cost_of_pet[:price] ? true : false\nend",
"def customer_can_afford_pet(customer, new_pet)\nreturn customer[:cash] >= new_pet[:price]\nend",
"def restrict... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns boolean for user being/not being considered a military person, by eMIS, based on their Title 38 Status Code. | def military_person?
title38_status == 'V3' || title38_status == 'V6'
end | [
"def status\n return :not_authorized unless user_loa3\n\n mvi_response&.status\n end",
"def status\n return MVI::Responses::FindProfileResponse::RESPONSE_STATUS[:not_authorized] unless user.loa3?\n\n mvi_response.status\n end",
"def status\n return MPI::Responses::FindProfileResponse::RESPONSE_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This action is used to retrieve data to be display on the IDSR MONTHLY REPORT Is called by Ajax and renders results in json | def idsr_monthly_report_summary
date = params[:year_month].split('-')
@start_date = Date.new(date[0].to_i,date[1].to_i)
@end_date = @start_date + 1.month - 1.day
@disaggregated_diagnosis = {}
idsr_monthly_set = ConceptName.where(["name IN (?)",["Idsr Monthly Summary"]]).map(&:concept_id)... | [
"def index\n @monthly_details = MonthlyDetail.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @monthly_details }\n end\n end",
"def get_month\n @by_months = ByMonth.where(initials: params[:initials])\n render json: @by_months\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This action is used to display form content on the IDSR MONTHLY REPORT | def idsr_monthly_summary
@report_name = 'IDSR Monthly Summary'
@logo = CoreService.get_global_property_value('logo').to_s
@current_location_name =Location.current_health_center.name
@obs_start_year = Observation.first.obs_datetime.year
render :layout => 'report'
end | [
"def index\n\t\tcollaborator_ids = User.get_collaborator_ids(current_user.id)\n\t\t@my_forms = ExtractionFormTemplate.get_user_forms(current_user.id)\n\t\t@collab_forms = ExtractionFormTemplate.get_collaborator_forms(current_user.id, collaborator_ids)\n\t\t@world_forms = ExtractionFormTemplate.get_world_forms(curr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse out a teamweek file and return an array of players | def get_team_for_week(team, week)
file = "#{@teamweek_dir}/#{team}_#{week}.html"
n = Nokogiri.HTML(File.open(file))
players = []
[0,1,2].each do |i|
t0 = n.css("#statTable#{i}")
t0.css('tr').each do |tr|
opts = {}
next unless tr.css('t... | [
"def by_season_team_parser\n by_season_team_data = []\n target_dir = by_season_team_dir\n Dir.foreach(target_dir) do |file|\n next if file == '.' or file == '..'\n json_file = File.open(target_dir + file)\n parsed_file = JSON.parse(File.read(json_file))\n pla... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
reset session and other | def reset
reset_session
redirect_to root_path
end | [
"def reset_session!; end",
"def reset\n @session = nil\n end",
"def session_reset!\n session[:file_id] = nil\n session[:row_error] = nil\n session[:file_error] = nil\n session[:sr_error] = nil\n session[:mp_error] = nil\n session[:mp_warning] = nil\n end",
"def sessions_reset\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For example: the summation of 3 is 6 because 1 + 2 + 3 = 6, the summation of 6 is 21 because 1 + 2 + 3 + 4 + 5 + 6 = 21. Write a method summation_sequence that takes in a two numbers: start and length. The method should return an array containing length total elements. The first number of the sequence should be the sta... | def summation_sequence(start, length)
arr = [start]
i = 1
while i < length
arr << summation(arr[i-1])
i += 1
end
return arr
end | [
"def summation_sequence(start, length)\n array = [start]\n (length - 1).times do |i|\n current_element = array[-1]\n next_element = summation(current_element)\n array << next_element\n end\n\n array\nend",
"def summation_sequence(start, length)\n summation = [start]\n (length - 1).times { summation... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve the RASD item that specifies memory properties of a VM. | def get_memory_rasd_item(id)
request(
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => "vApp/#{id}/virtualHardwareSection/memory"
)
end | [
"def memory\n get_memory_info\n end",
"def read_mem addr\n @mem[addr]\n end",
"def determine_memory\n result = @info[:memory] = {}\n\n free_cmd = \"free -m|awk '$1 ~ /Mem/ {print $2, $2-$6-$7}; $1 ~ /Swap/ \" \\\n \"{print $3}'|xargs\"\n mem = @shell.query('MEMORY'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /skill_user_profiles GET /skill_user_profiles.json | def index
@skill_user_profiles = SkillUserProfile.all
render json: @skill_user_profiles
end | [
"def show\n render json: @skill_user_profile\n end",
"def profiles\n hash = {:username => @username}\n @api.request(\"users/profiles/?#{build_query_string(hash)}\")\n end",
"def get_profile_skills\n profile_skills = find_elements PROFILE_SKILLS_LOCATOR\n get_skills profile_skills\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /skill_user_profiles/1 GET /skill_user_profiles/1.json | def show
render json: @skill_user_profile
end | [
"def index\n @skill_user_profiles = SkillUserProfile.all\n\n render json: @skill_user_profiles\n end",
"def profiles\n hash = {:username => @username}\n @api.request(\"users/profiles/?#{build_query_string(hash)}\")\n end",
"def getMyProfile\n if(request.post?)\n cSocialID = self.find... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /skill_user_profiles POST /skill_user_profiles.json | def create
byebug
@skill_user_profile = SkillUserProfile.new(skill_user_profile_params)
if @skill_user_profile.save
render json: @skill_user_profile, status: :created, location: @skill_user_profile
else
render json: @skill_user_profile.errors, status: :unprocessable_entity
end
end | [
"def create\n user_skill_params[:skill_ids].map do |skill_id|\n @user_skill = UserSkill.create(user_id: params[:user_id], skill_id: skill_id)\n unless @user_skill.save\n json_response(@user_skill.errors, 422) and return\n end\n end\n json_response(\"Skills added\".to_json, 200)\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /skill_user_profiles/1 PATCH/PUT /skill_user_profiles/1.json | def update
@skill_user_profile = SkillUserProfile.find(params[:id])
if @skill_user_profile.update(skill_user_profile_params)
head :no_content
else
render json: @skill_user_profile.errors, status: :unprocessable_entity
end
end | [
"def update\n respond_to do |format|\n if @skills_to_profile.update(skills_to_profile_params)\n format.html { redirect_to @skills_to_profile, notice: 'Skills to profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @skills_to_profile }\n else\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /skill_user_profiles/1 DELETE /skill_user_profiles/1.json | def destroy
@skill_user_profile.destroy
head :no_content
end | [
"def destroy\n @user_skill = UserSkill.find(params[:id])\n @user_skill.destroy\n\n respond_to do |format|\n format.html { redirect_to user_skills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @skills_to_profile.destroy\n respond_to do |format|\n format.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Invokes the view for the given model, passing the assigns as instance variables. | def view( model, view, assigns = {} )
self << Waves.main::Views[ model ].process( request ) do
send( view, assigns )
end
end | [
"def view(model_name, *args)\n orange[model_name].view(self, *args)\n end",
"def evaluate\n @view.evaluate if @view\n end",
"def _evaluate_assigns(object)\n view_assigns.each { |k,v| object.instance_variable_set(k, v) }\n end",
"def method_missing(method, *args, &block)\n @vie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Take a number of server/detail records for hosts, then format it into a data structure with standardized fields for display. | def convert_yaml(servers)
serverdata = {}
servers.each do |server|
hostname = server.hostname
# Initialize our root fields so that there won't be any surprises from
# hosts that don't have data.
serverdata[hostname] = {}
fields = %w(general netdb puppetfacts puppetstatus advisorie... | [
"def hosts\n out = []\n out << \"group {\"\n out << ' filename \"deezy\";'\n Host.find_all_by_enabled(true).each do |host|\n out << [\n \" host #{host.hostname} { hardware ethernet #{host.mac}; \",\n \"#{\"fixed-address #{host.ip};\" unless host.ip.blank?}\",\n \"}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
converts a JDBC recordset to an array of hashes, with one hash per record | def rs_to_array(rs)
# creates an array of hashes from a jdbc record set
arr = []
# get basic metadata for the recordset
meta = rs.getMetaData
cols = meta.getColumnCount.to_i
# loop through the records to add them into hash
while rs.next do
# r is a temporary hash for ... | [
"def nicefy_resultset( resultset )\r\n array_of_hashes = []\r\n resultset.each_hash do |row_hash|\r\n array_of_hashes << row_hash\r\n end\r\n array_of_hashes\r\n end",
"def resultset_to_hash(resultset)\n meta = resultset.meta_data\n rows = []\n\n while resultset.next\n row = {}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
converts a JDBC recordset to an array of hashes, with one hash per record creates a hash from a jdbc record set index_key_field is the field you want to use as the top level hash key... and should exist in the record set multi_val=true will create an array below each index_key_filed, false will create a hash as the chi... | def rs_to_hash(rs, index_key_field, multi_val)
# setting default hash value is necessary for appending to arrays
hash=Hash.new{ |h, k| h[k] = [] }
# get basic metadata for the recordset
meta = rs.getMetaData
cols = meta.getColumnCount.to_i
# loop through the records to add them int... | [
"def build_record_set(records)\n \n #columns = {}\n record_set = {}\n \n records.each do |record|\n \n #If the record with the given id does not exsits, \n # create it\n record_set[record[:id]] = {} if !record_set[record[:id]]\n \n # Create the hash for the field if it d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
outputs a JDBC result set to a formatted file formatter defaults to JSON output unless you provide your own proc | def rs_to_json_file(rs, file_object, formatter)
# default formatter outputs json objects for each row
formatter = json_formatter unless formatter
# get basic metadata for the recordset
meta = rs.getMetaData
cols = meta.getColumnCount.to_i
record_count = 0
# loop through the r... | [
"def print_query_result(result) \n puts result.columns.to_s\n result.each do |record|\n puts record.to_s\n end\nend",
"def output_query_to_file(sql, fn, header = true)\n hdout = Hathidata::Data.new(fn).open('w');\n rows(sql) do |row|\n if header then\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Input: (2 > 4 > 3) + (5 > 6 > 4) Output: 7 > 0 > 8 Input: (2 > 4 > 3) + (1 > 1) Output: (... | def add_two_numbers(head1, head2)
result_dummy = ListNode.new(nil)
current, current1, current2 = result_dummy, head1, head2
tens = 0
while current1 && current2
sum = current1.val + current2.val + tens
tens = sum > 9 ? 1 : 0
current.next = ListNode.new(sum % 10)
current, current1, current2 = cur... | [
"def sum_lists(node1, node2)\n result = LinkedList.new\n carry = 0\n\n until node1.nil? && node2.nil?\n digit1, digit2 = ((!node1.nil? && node1.data) || 0), ((!node2.nil? && node2.data) || 0)\n\n sum_digits = digit1 + digit2 + carry\n result.append(sum_digits % 10)\n\n carry = sum_digits / 10\n no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The Order Books channel allow you to keep track of the state of the Bitfinex order book. It is provided on a price aggregated basis, with customizable precision. | def books(symbol="btcusd", precision="P0", params = {})
check_params(params, %i{len})
get("book/#{symbol}/#{precision}", params: params).body
end | [
"def apply_orderbook_snapshot\n client.orderbook(level: 3) do |resp|\n @bids = resp['bids'].map { |b| order_to_hash(*b) }\n @asks = resp['asks'].map { |a| order_to_hash(*a) }\n @snapshot_sequence = resp['sequence']\n @last_sequence = resp['sequence']\n end\n end",
"def app... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get active positions return [Array] | def active_positions
authenticated_post("auth/positions").body
end | [
"def active_positions\n authenticated_post(\"auth/r/positions\").body\n end",
"def get_available_positions\n @state.each.with_index(1).select { |mark, index| mark.nil? }.map { |mark, index| index }\n end",
"def joined_positions()\n return [] unless defined?(@joined_positions)\n retur... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
array = [] if array.size == 1 return array[0] elsif array.size == 2 return array.join(" and ") else return array[0..2].join(", ") + ", and " + array[1] end end | def oxford_comma(array)
case array.length
when 1
"#{array[0]}"
when 2
array[0..1].join(" and ")
else
array[0...-1].join(", ") << ", and #{array[-1]}"
end
end | [
"def format_comma_and(array)\n return array.join if array.length <= 1\n array[0..-2].join(', ') + \" and #{array[-1]}\"\nend",
"def oxford_comma(array)\n if array.length == 1\n array.join\n elsif array.length == 2\n array.join(\" and \")\n else\n tempvar = array.pop\n returnvar = array.join(\", \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all nodes which the FE will identify as a metrics embed placeholder element Removes any nodes beyond the first 100 | def nodes
strong_memoize(:nodes) do
nodes = doc.xpath(XPATH)
nodes.drop(EMBED_LIMIT).each(&:remove)
nodes
end
end | [
"def all_nodes_used_by_barclamp(role)\n role.elements.values.flatten.compact.uniq\n end",
"def all_nodes\n get(\"/production/facts_search/search?facts.processorcount.ge=0\",false)\n end",
"def free_nodes\n nodes.select(&:is_free?)\n end",
"def generate_blank_nodes(amount)\n response = @re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Maps a node to key properties of an embed. Memoized so we only need to run the regex to get the project full path from the url once per node. | def embeds_by_node
strong_memoize(:embeds_by_node) do
nodes.each_with_object({}) do |node, embeds|
embed = Embed.new
url = node.attribute('data-dashboard-url').to_s
permissions_by_route.each do |route|
set_path_and_permission(embed, url, route.regex, ... | [
"def key_to_node; end",
"def prepare_key(node)\n node = node.name if node.is_a? Deployment::Node\n node.to_s.to_sym\n end",
"def get_key_to_pmid(entry_node)\n hash = {}\n entry_node.xpath('./evidence').each do |node| \n pubmed_id = \n if att = node['attribute']\n if md = att.match(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempts to determine the path and permission attributes of a url based on expected dashboard url formats and sets the attributes on an Embed object | def set_path_and_permission(embed, url, regex, permission)
return unless path = regex.match(url) do |m|
"#{$~[:namespace]}/#{$~[:project]}"
end
embed.project_path = path
embed.permission = permission
end | [
"def parse_url\n set_url_type_and_command\n generate_field\n set_domain\n end",
"def set_embed\n if self.category == 'youtube'\n code = self.link.split('=')[1]\n self.embed = \"<iframe width='700' height='400' src='http://www.youtube.com/embed/#{code}' frameborder='0' allowfullscreen... | {
"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.