query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Submit a timesheet for approval. | def submitForApproval(period=nil, comment='', name=@username)
if period.nil? then
# First day of work week
cur = currentApprovalStatus(nil, name)
period = cur.access 'period.dateFrom'
end
verbose "Submitting timesheet for #{period}"
post('times... | [
"def approve_deny_timesheets\n\n # set the default status\n status = 'DENIED'\n\n # set status to approve if button clicked!\n if params[:commit] == 'Approve'\n\n status = 'APPROVED'\n \n end\n\n # get the ids of the selected timesheets\n ids = params[:ids]\n\n # set the date and t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lookup IpRec containing ip. Exception is raised if not found. | def search(ip)
ip_value = self.class.ip_to_int(ip)
find_rec(ip_value)
end | [
"def cidr_lookup (ip)\n\t\tputs \"Lookup the CIDR name from the known CIDR list for the IP: #{ip}\" if @verbose\n\t\treturn nil if @known_cidr_blks==nil\n\t\tputs \"CIDR Lookup: #{ip} ...\" if @verbose\n\t\t@known_cidr_blks_desc_index.each do |line|\n\t\t\tfirst_octet_ip = ip.split('.').first.to_i\n\t\t\tfirst_octe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Binary search through sorted IP database. The search uses nonrecordaligned byte offsets into the file, but always scans forward for the next parsable record from a given offset. It keeps track of the | def find_rec(ip_value)
lower, upper = 0, @db_size - 1
prev_rec = nil
loop do
ofst = lower + ((upper - lower) / 2)
rec = next_rec_from_ofst(ofst)
if rec == prev_rec
# We have narrowed the search to where we're hitting
# the same record each time. Can't get any narrower.
# But... | [
"def binary_seek(ip_addr_num)\n low = 0\n high = File.size(Filename)\n fp = File.open(Filename) \n \n # Find first line of real data and set \"low\" placeholder accordingly\n line = fp.gets\n while line.strip.size == 0 or line[0].chr == \"#\"\n line = fp.gets\n low = low + line.size\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply a list of selects to the list of activities | def apply_selects(activities, selects, grouped = false)
return activities if selects.empty?
# We use map+reject(blank) so that we can modify the activities in the
# groups
activities = activities.lazy.map do |act|
if act['activities'] # recurse into activity groups
... | [
"def select_activity_multiple(menu)\n activities_selected = []\n TTY::Prompt.new.multi_select(\"Please select your actiities to book in:\", menu, cycle: true, marker: '>', echo: false, per_page: 5).each do |activity|\n \n # pushing a activity object to the activities_selected arr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply a list of maps to the list of activities | def apply_maps(activities, maps)
return activities if maps.empty?
activities.map do |act|
if act['activities'] # Recurse into activity groups
act['activities'] = apply_maps(act['activities'], maps)
act
else
maps.reduce(act) { |acc, elem| elem.call(... | [
"def get_activity_by_map(activities, by=\"goal_id\")\n keys = activities.pluck(by).uniq\n return_hash = Hash.new\n keys.each do |key|\n g = Goal.find_by_id key\n return_hash[g] = activities.find_all {|a| a[by] == key}\n end\n return_hash\n end",
"def wrap(activities)\n activities.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For performance, we drop older activities on groups where we only need one. These groups are identified by verb (comment, post, review, follow) | def strip_unused(activity_groups)
activity_groups.each do |group|
return activity_groups unless group['activities']
next unless STRIPPED_VERBS.include?(group['verb'])
group['activities'] = [group['activities'].first]
end
activity_groups
end | [
"def before_destroy_group\n controller = PublicActivity.get_controller\n\n # Return if seeding or nothing changes\n return if !controller\n\n current_user = PublicActivity.get_controller.current_user\n\n self.create_activity :destroy, owner: current_user,organization_id: self.organization_id, params:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wrap activities in Feed::Activity and Feed::ActivityGroup instances | def wrap(activities)
activities.map do |act|
if act['activities']
# Feed::ActivityGroup automatically converts activites in it
Feed::ActivityGroup.new(opts[:feed], act)
else
Feed::Activity.new(opts[:feed], act)
end
end
end | [
"def activities_for(filter: nil, type: _feed_type)\n Feed::ActivityList.new(self).filter(filter).with_type(type)\n end",
"def add_activity\n # if !self.commentable.is_a?(Activity) # don't add comments to the activity feed that are comments on the items in the activity feed.\n content = I18n.t('muck.comm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clear the history buffer. | def clear_history
if @args[0] == 'clear'
@history.clear
else
false
end
end | [
"def clear_history\n Readline::HISTORY.clear\n end",
"def clear_history\n while ! Readline::HISTORY.empty? do\n Readline::HISTORY.pop\n end\n end",
"def clearHistory\r\n\t\tFile.truncate(\"history.txt\",0)\r\n\tend",
"def clear_history\n #TODO: Use Delete Private Data Dialog?\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Just show the history. | def show_history
pattern = Regexp.new(@args[0] || /./)
@history.each_with_index do |item, index|
puts "#{index+1}: #{item}" if item =~ pattern
end
end | [
"def history; end",
"def show_history\n pos = @line.position\n text = @line.text\n max_index_width = history.length.to_s.length\n history.each_with_index do |item, i|\n @terminal.puts sprintf(\"%-#{max_index_width}d %s\\n\", i+1, item)\n end\n render(reset: true)\n overwr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
public static boolean createUser(String userName, String password, boolean isAdminUser, String webGroups[], String adminGroup, String fName, String lName, String email, Properties additionalUserInformation) | def createUser(userName, password, isAdminUser, webGroups, adminGroup, fName, lName, email, additionalUserInformation)
@ACCESS_CONTROL.createNewUser(userName, webGroups[0], email, fName, lName, password)
at = 0
webGroups.each{ |group|
@ACCESS_CONTROL.setUserField(userName, "group#{at}... | [
"def addUser name, pass, mail, site = \"\", *groupnames\n groupnames = groupnames.flatten\n userGroup = Modeles::Group.find_by_name name\n if userGroup.nil?\n userGroup = Modeles::Group.new :name => name\n else\n return nil\n end\n groups = [ userGroup ]\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all the variables and setup as a hash for doing a POST | def get_post_variables
@data = {}
@response_text.scan(/NAME=(\w+) TYPE=hidden VALUE="([^"]*)/) do |name, value|
@data[name] = value
end
end | [
"def get_post_variables\r\n\t\t\t@data = {}\r\n\t\t\t@response_text.scan(/NAME=(\\w+) TYPE=hidden VALUE=\"([^\"]*)/) do |name, value|\r\n\t\t\t\t@data[name] = value\r\n\t\t\tend\r\n\t\tend",
"def post_parameters\n request.POST\n end",
"def get_form_variables\n var = @options[:default_values] || {}\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create verify xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount. It returns xml format in string. | def verifyXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',
'i:type' =>"AuthorizeTransaction" ) {
xml.Ap... | [
"def make_xml(params)\n\n @xml = \"<?xml version=\\\"1.0\\\" ?><methodCall><methodName>#{@method}</methodName><params>\"\n\n unless params.empty?\n params.each do |i|\n @xml << \"<param><value>\"\n @xml << make_xml_value(i)\n @xml << \"</value></param>\"\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create Authorize xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount, P2PETransactionData,PaymentAccountDataToken. It returns xml format in string. | def authorizeXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.AuthorizeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',
'i:type' =>"AuthorizeTra... | [
"def authorizeAndCaptureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance', \n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create AuthorizeCapture xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount, P2PETransactionData,PaymentAccountDataToken. It returns xml format in string. | def authorizeAndCaptureXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.AuthorizeAndCaptureTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',
... | [
"def captureXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',\n 'i:type' =>\"Capture\" ) {\n xml.App... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create Capture xml as per the api format . "params" is collection keyvalues, in this "params" holds Amount, TransactionId. It returns xml format in string. | def captureXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.ChangeTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest',
'i:type' =>"Capture" ) {
xml.ApplicationProfi... | [
"def capture(params)\n begin\n trid = params[:TransactionId].to_s\n response_xml = HTTParty.put( URL+\"#{work_flow_id}\"+\"/\"+trid,\n body: xmlbody.captureXML(params),\n headers: {\"Authorization\" => \"Basic #{session_token.signOn}\"},\n verify: false,:timeout => 60)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create Undo xml as per the api format . "params" is collection keyvalues, in this "params" hold TransactionId. It returns xml format in string. | def undoXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.Undo('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"Undo" ) {
xml.ApplicationProfileId application_profile_i... | [
"def undo(params)\n begin\n trid = params[:TransactionId].to_s\n response_xml = HTTParty.put( URL+\"#{work_flow_id}\"+\"/\"+trid,\n body: xmlbody.undoXML(params),\n headers: {\"Authorization\" => \"Basic #{session_token.signOn}\"},\n verify: false,:timeout => 60)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create Adjust xml as per the api format . "params" is collection keyvalues, in this "params" holds adjusted Amount, TransactionId. It returns xml format in string. | def adjustXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.Adjust('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"Adjust" ) {
xml.ApplicationProfileId application_profile_... | [
"def adjust(params)\n begin\n trid = params[:TransactionId].to_s\n response_xml = HTTParty.put( URL+\"#{work_flow_id}\"+\"/\"+trid,\n body: xmlbody.adjustXML(params),\n headers: {\"Authorization\" => \"Basic #{session_token.signOn}\"},\n verify: false,:timeout => 60)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create ReturnById xml as per the api format . "params" is collection keyvalues, in this "params" holds Amount, TransactionId. It returns xml format in string. | def returnByIdXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"ReturnById" ) {
xml.ApplicationProfileId applicat... | [
"def make_xml(params)\n\n @xml = \"<?xml version=\\\"1.0\\\" ?><methodCall><methodName>#{@method}</methodName><params>\"\n\n unless params.empty?\n params.each do |i|\n @xml << \"<param><value>\"\n @xml << make_xml_value(i)\n @xml << \"</value></param>\"\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create ReturnUnlinked xml as per the api format . "params" is collection keyvalues, in this "params" holds CardData, AVSData, Amount, P2PETransactionData,PaymentAccountDataToken. It returns xml format in string. | def returnUnlinkedXML(params)
begin
Nokogiri::XML::Builder.new do |xml|
xml.ReturnTransaction('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"ReturnTransaction" ) {
xml.Application... | [
"def returnByIdXML(params)\n begin\n Nokogiri::XML::Builder.new do |xml|\n xml.ReturnById('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',\n 'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>\"ReturnById\" ) {\n xml.ApplicationProfil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create CaptureAll xml as per the api format . "params" is collection keyvalues, in this "params" holds list of Capture transactions. It returns xml format in string. | def captureAllXML()
begin
Nokogiri::XML::Builder.new do |xml|
xml.CaptureAll('xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Rest', 'i:type' =>"CaptureAll" ) {
xml.ApplicationProfileId... | [
"def make_xml(params)\n\n @xml = \"<?xml version=\\\"1.0\\\" ?><methodCall><methodName>#{@method}</methodName><params>\"\n\n unless params.empty?\n params.each do |i|\n @xml << \"<param><value>\"\n @xml << make_xml_value(i)\n @xml << \"</value></param>\"\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create QueryTransactionsDetail JSON as per the api format . "params" is collection keyvalues, in this "params" holds query information. It returns JSON format in string. | def queryTransactionsDetailJSON(params)
begin
{
:TransactionDetailFormat => 'CWSTransaction',
:PagingParameters => {
:Page => 0,
:PageSize => 10
},
:QueryTransactionsParameters => {
:Amounts => nil,
... | [
"def queryTransactionsDetail(params)\n begin\n response_xml = HTTParty.post( QTD_URL,\n :body => xmlbody.queryTransactionsDetailJSON(params),\n :headers => {\"Authorization\" => \"Basic #{session_token.signOn}\", 'Content-Type' => 'application/json'},\n verify: false,:timeo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of organizations based on the access_type parameter The default access_type is RESTRICTED | def organizations_with_access(access_type = ACCESS_STATES[:RESTRICTED])
subscribed_organizations.includes(teams: :subscriptions).where("subscriptions.access_type = ?", access_type)
end | [
"def organizations(params = {})\n request('organizations', CollegiateLink::Organization, params)\n end",
"def organizations\n raw_organizations = GitHub::API.json(\"/user/show/#{self.login}/organizations\")['organizations']\n organizations = []\n\n raw_organizations.each do |organization|\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Increment a metric for the client. metric The String name of the metric to increment. value The Integer value to increment by. Returns nothing. | def increment(metric, value = 1)
@adapter.increment metric, value
end | [
"def increment(metric, value = 1)\n @client.increment prepare(metric), value\n end",
"def increment(metric, value = 1, tags = [], sample_rate = 1)\n report(metric, 'c', value, tags, sample_rate)\n end",
"def increment(metric, value = 1, time = Time.now, count = 1)\n if valid?(metric, value,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Track the timing of a metric for the client. metric The String name of the metric. value The Integer duration of the event in milliseconds. Returns nothing. | def timing(metric, value)
@adapter.timing metric, value
end | [
"def timing(metric, duration)\n @client.timing prepare(metric), duration\n end",
"def timing(metric, duration)\n @client.gauge prepare(metric), duration\n end",
"def record_value(metric, value, opts = {})\n record_internal({metric => value.round}, opts)\n end",
"def observe_val... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array of elements from the sorted set using ZRANGE. range receives 2 integers, start and stop Example: class CreditRecord 1) c2 = CreditRecord.create(:credits => 2) c3 = CreditRecord.create(:credits => 3) event = CreditEvent.create event.records.add(c1) event.records.add(c2) event.records.add(c3) [c1, c2] ==... | def range(start, stop)
fetch(redis.zrange(key, start, stop))
end | [
"def zrange(key, start, stop, byscore: T.unsafe(nil), by_score: T.unsafe(nil), bylex: T.unsafe(nil), by_lex: T.unsafe(nil), rev: T.unsafe(nil), limit: T.unsafe(nil), withscores: T.unsafe(nil), with_scores: T.unsafe(nil)); end",
"def get_range(from, to, options = {})\n if options.delete(:include_boundaries)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reversely keep the sorted set to the specified length | def keep_tail(length)
rank = size - length
drop_above(rank)
end | [
"def reverse!(start, length)\n length = length - 1\n (0..length / 2).each do |i|\n left = self[start + i]\n right = self[start + length - i]\n\n self[start + i] = right\n self[start + length - i] = left\n end\n\n self\n end",
"def clearbyrev rev #(const rev: int64)\n (size-1)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
parse_address scans the provided configuration block and extracts the interface address, if configured, and returns it. If there is no IP address configured, then this method will return the DEFAULT_ADDRESS. The return value is intended to be merged into the ipaddress resource hash. | def parse_address(config)
mdata = /(?<=^\s{3}ip\saddress\s)(.+)$/.match(config)
{ address: mdata.nil? ? DEFAULT_ADDRESS : mdata[1] }
end | [
"def ipaddress\n block = /\\d{,2}|1\\d{2}|2[0-4]\\d|25[0-5]/\n re = /\\A#{block}\\.#{block}\\.#{block}\\.#{block}\\z/\n if info[1]['host'] && re =~ info[1]['host']\n info[1]['host']\n else\n address(info[1]['http_address']).split(':')[0] \n end\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
parse_mtu scans the provided configuration block and extracts the IP interface MTU value. The MTU value is expected to always be present in the configuration blcok. The return value is intended to be merged into the ipaddress resource hash. | def parse_mtu(config)
mdata = /(?<=mtu\s)(\d+)$/.match(config)
{ mtu: mdata.nil? ? '' : mdata[1] }
end | [
"def mtu=(value)\n @mtu = value\n end",
"def mtu\n @mtu\n end",
"def retrieve_vswitch_mtu\n vswitchspec = retrieve_vswitch_spec\n return vswitchspec.mtu\n end",
"def parse_mac_address(config)\n # ip virtual-router mac-address value will always\n # be stored in aa:bb:cc:d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
parse_helper_addresses scans the provided configuration block and extracts any configured IP helper address values. The interface could be configured with one or more helper addresses. If no helper addresses are configured, then an empty array is set in the return hash. The return value is intended to be merged into th... | def parse_helper_addresses(config)
helpers = config.scan(/(?<=\s{3}ip\shelper-address\s).+$/)
{ helper_addresses: helpers }
end | [
"def set_helper_addresses(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n end\n end\n\n c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
parse_load_interval scans the provided configuration block and parse the loadinterval value. If the interface loadinterval value is not configured, then this method will return the value of DEFAULT_LOAD_INTERVAL. The hash returned is intended to be merged into the interface resource hash. | def parse_load_interval(config)
mdata = /load-interval (\w+)$/.match(config)
{ load_interval: mdata.nil? ? DEFAULT_LOAD_INTERVAL : mdata[1] }
end | [
"def port_channel_load_balance\n lb = config_get('portchannel_global',\n 'port_channel_load_balance')\n hash = {}\n lb.each do |line|\n next if line[/(internal|resilient|module|fex|hash)/]\n params = line.split\n lb_type = config_get('portchannel_global', 'lo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
delete will delete an existing IP interface in the node's current configuration. If the IP interface does not exist on the specified interface, this method will still return success. This command will default the interface back to being a switchport. | def delete(name)
configure(["interface #{name}", 'no ip address', 'switchport'])
end | [
"def destroy\n requires :network_interface_id\n\n service.delete_network_interface(network_interface_id)\n true\n end",
"def delete\n client_opts = {}\n client_opts[:network_interface_id] = network_interface_id\n client.delete_network_interface(client_opts)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set_address configures a logical IP interface with an address. The address value must be in the form of A.B.C.D/E. If the enable keyword is false, then the interface address is negated using the config no keyword. If the default option is set to true, then the ip address value is defaulted using the default keyword. Th... | def set_address(name, opts = {})
cmds = command_builder('ip address', opts)
configure_interface(name, cmds)
end | [
"def set_addresses(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n cmds = [\"interface #{name}\"]\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set_mtu configures the IP mtu value of the ip interface in the nodes configuration. If the enable option is false, then the ip mtu value is configured using the no keyword. If the default keyword option is provided and set to true then the ip mtu value is configured using the default keyword. The default keyword has pr... | def set_mtu(name, opts = {})
cmds = command_builder('mtu', opts)
configure_interface(name, cmds)
end | [
"def mtu=(value)\n @mtu = value\n end",
"def SetMtu(node)\n\t@interfaces.each do |ifn|\n\t self.GetGroupInterface(node, ifn).mtu=\"1528\"\n\tend\n end",
"def set_mtu(opts)\n opts = check_params(opts,[:mtus])\n super(opts)\n end",
"def mtu_ignore=(enable)\n config_set('interface_osp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set_helper_addresses configures the list of helper addresses on the ip interface. An IP interface can have one or more helper addresses configured. If no value is provided, the helper address configuration is set using the no keyword. If the default option is specified and set to true, then the helper address values ar... | def set_helper_addresses(name, opts = {})
value = opts[:value]
enable = opts.fetch(:enable, true)
default = opts[:default] || false
if value
unless value.is_a?(Array)
raise ArgumentError, 'value must be an Array'
end
end
case default
... | [
"def set_addresses(name, opts = {})\n value = opts[:value]\n enable = opts.fetch(:enable, true)\n default = opts[:default] || false\n cmds = [\"interface #{name}\"]\n\n if value\n unless value.is_a?(Array)\n raise ArgumentError, 'value must be an Array'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set_load_interval is a convenience function for configuring the value of interface loadinterval | def set_load_interval(name, opts = {})
cmds = command_builder('load-interval', opts)
configure_interface(name, cmds)
end | [
"def set_load_interval(name, opts = {})\n commands = command_builder('load-interval', opts)\n configure_interface(name, commands)\n end",
"def SetInterval(interval)\n @iperfInterval=interval\n end",
"def SetInterval(interval)\n @iperfInterval=interval\n end",
"def interval=(va... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If we are just being created and have a USER, but no PHONE NUMBER, then use the users phone number! | def copy_phone_if_user
self.phone_number = user.phone_number if user && !phone_number
end | [
"def user_phone\n if update_phone && user.completed_sign_up?\n user.unverified_phone\n else\n user.phone\n end\n end",
"def add_phone(user, phonenumber)\n phone1 = Phone.new\n !phonenumber.empty? ? phone1.phonenumber = phonenumber : phone1.phonenumber = \"No Phone\"\n # add phone to u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The opposite of +assert_queued+. | def assert_not_queued(klass, args = nil, message = nil)
queue = Resque.queue_for(klass)
assert_block (message || "#{klass}#{args ? " with #{args.inspect}" : ""} should not have been queued in #{queue}.") do
!in_queue?(queue, klass, args)
end
end | [
"def assert_nothing_queued(message = nil, &block)\n snapshot = Resque.size\n yield\n present = Resque.size\n assert_equal snapshot, present, message || \"No jobs should have been queued\"\n end",
"def assert_no_enqueued_jobs(only: T.unsafe(nil), except: T.unsafe(nil), queue: T.unsafe(nil), &block); e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
tried to reuse my sorted item list, but i dont think i want my keys in my inventory hash to be in alphabetical order, according to the interaction pattern def total_inventory inventory = Hash.new sorted_item_list.each do |item| inventory[item] = 0 end inventory end | def total_inventory
inventory = Hash.new(0)
@vendors.each do |vendor|
vendor.inventory.keys.each do |item|
inventory[item] += vendor.inventory[item]
end
end
inventory
end | [
"def inventory_hash\n @inventory.group_by(&:make)\n end",
"def group_not_shipped_inventory_units\n retHash = Hash.new\n self.inventory_units.each do |unit|\n if unit.state == 'sold' || unit.state == 'backordered' \n if retHash.has_key?(unit.variant_id)\n retHash[unit.variant_id][\"q... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method only partly works. It is able to return true or false deplending on if the item is in stock. And it is able to change the stock of the vendor. If the vendor does not have enough of that stock tho, I was unable to figure out how to move to the next vendor, and subtract the difference from their stock. Spent ... | def sell(item, quantity)
if total_inventory.has_key?(item) && quantity < total_inventory[item]
@vendors.each do |vendor|
if vendor.inventory.has_key?(item)
if vendor.inventory[item] >= quantity
vendor.inventory[item] -= quantity
else
vendor.inventory[item] -... | [
"def update_tobuy\n\n # we computed how many each univ needs elsewhere\n total = num_needed = [0, univ_inventory_infos.last.shortfall_one_week.to_f].max.to_i\n\n # only try to buy from good vendors\n prods = products.reject(&:hostile?)\n num_prods = prods.size.to_f\n num_good = prods.map { |p| p.n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /attachments GET /attachments.json | def index
@attachments = Attachment.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @attachments }
end
end | [
"def attachment(aid)\n resp = @server[\"ticket/1/attachments/#{aid}/\"].get\n return process_response(resp, 's', true) \n end",
"def find_attachments(options = {})\n validate_presence_of [:document_id], options\n get_resource \"/attachment/#{options[:document_id]}\", options\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor Params: +color+:: the color of the player +display+:: the object of a class encapsulating | def initialize(color, display)
@color = color
@display = display
end | [
"def initialize(color)\r\n @colour = color\r\n end",
"def initialize(name, color) \n @name = name \n @color = color \n end",
"def initialize(color = COLOR_CLEAR)\n @color = color\n end",
"def initialize(name, color) \r\n @name = name \r\n @color = color \r\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /spots POST /spots.xml | def create
@spot = Spot.new(params[:spot])
respond_to do |format|
if @spot.save
flash[:notice] = 'Spot was successfully created.'
format.html { redirect_to(@spot) }
format.xml { render :xml => @spot, :status => :created, :location => @spot }
else
format.html { rende... | [
"def create\n @spot = Spot.new(params[:spot])\n\n respond_to do |format|\n if @spot.save\n format.html { redirect_to(spots_url, :notice => 'Spot was successfully created.') }\n format.xml { render :xml => @spot, :status => :created, :location => @spot }\n else\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /spots/1 PUT /spots/1.xml | def update
@spot = Spot.find(params[:id])
respond_to do |format|
if @spot.update_attributes(params[:spot])
flash[:notice] = 'Spot was successfully updated.'
format.html { redirect_to(@spot) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
... | [
"def update\n @spot = Spot.find(params[:id])\n @tags = @spot.items\n\n respond_to do |format|\n if @spot.update_attributes(params[:spot])\n format.html { redirect_to(spots_url, :notice => 'Spot was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /spots/1 DELETE /spots/1.xml | def destroy
@spot = Spot.find(params[:id])
@spot.destroy
respond_to do |format|
format.html { redirect_to(spots_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { redirect_to(spots_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @spot = Spot.find(params[:id])\n @spot.destroy\n\n respond_to do |format|\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /declaration_containers GET /declaration_containers.json | def index
@declaration_containers = @declaration.declaration_containers.page(params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @declaration_containers }
end
end | [
"def running_containers\n request do\n get(path: '/containers/json')\n end\n end",
"def index\n @containers = Container.all\n end",
"def show\n @container.json = Docker::Container.get(@container.cid)\n end",
"def containers\n TestLab::Container.all\n end",
"def create\n @d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /declaration_containers/new GET /declaration_containers/new.json | def new
@declaration_container = DeclarationContainer.new(:declaration_id => @declaration.id)
respond_to do |format|
format.html # new.html.erb
format.json { render json: @declaration_container }
end
end | [
"def new\n @container = Container.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @container }\n end\n end",
"def new\n @container_stack = ContainerStack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /declaration_containers POST /declaration_containers.json | def create
@declaration_container = DeclarationContainer.new(params[:declaration_container])
respond_to do |format|
if @declaration_container.save
format.html { redirect_to new_declaration_container_url(:declaration_id => @declaration_container.declaration_id), notice: 'Declaration container was ... | [
"def create params = {}, body = {}\n @connection.request(method: :post, path: build_path(\"/containers/create\", params), headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def create\n @container = Container.new(params[:container])\n\n @container.tenant_id = params[:t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /declaration_containers/1 PUT /declaration_containers/1.json | def update
respond_to do |format|
if @declaration_container.update_attributes(params[:declaration_container])
format.html { redirect_to @declaration_container, notice: 'Declaration container was successfully updated.' }
format.json { head :no_content }
else
format.html { render a... | [
"def update\n respond_to do |format|\n if @container.update(container_params)\n format.json { render :show, status: :ok, location: @container }\n else\n format.json { render json: @container.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @container... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /declaration_containers/1 DELETE /declaration_containers/1.json | def destroy
@declaration_container.destroy
respond_to do |format|
format.html { redirect_to declaration_containers_url(:declaration_id => @declaration_container.declaration_id) }
format.json { head :no_content }
end
end | [
"def destroy\n @container.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the weight of a given node | def set(node, weight)
change_by node, nil, weight
end | [
"def increase_weight(node, dw)\n node = find(node)\n node.update_weight(node.weight + dw) unless node.nil?\n end",
"def setWeight(weight)\n @weight = weight\n end",
"def weight=(value)\n @weight = value\n end",
"def weight_node(node, weight)\n @edges.each do |source, de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Increment a node by 1 | def increment(node)
change_by node, 1
end | [
"def increment_node_count\n @node_count = 0 if @node_count.nil?\n @node_count += 1\n end",
"def node_counter_increment\n @node_counter += 1\n end",
"def incr_node(nodeName)\n Netica::NeticaLogger.info \"Incrementing #{nodeName} for #{token}, object_id: #{self.object_id}.\"\n if ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Decrement a node by 1 | def decrement(node)
change_by node, -1
end | [
"def decrement\n @value -= 1\n end",
"def decrement!\n @value -= @increment\n \n self\n end",
"def decrease(counter)\r\n counter - 1\r\nend",
"def decrement(decr = 1)\n @count.update { |v| v - decr }\n end",
"def decrease(counter)\n counter -= 1\nend",
"def incremen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Place a given link in the set just before the dest | def place_link(link, dest, last_link)
# If there is no dest, we are meant to be
if dest.nil?
# If we have no last link, we are alone - and are head
# and link's prev remains nil
if last_link.nil?
self[:head_id] = link.id
# If we have the last link, we want to be af... | [
"def link_from(src)\n swap(src)\n end",
"def link(src, dst)\n assign(src, dst)\n end",
"def move(set, mailbox); end",
"def link_entry(src, dest, dereference_root = false, remove_destination = false)\n Entry_.new(src, nil, dereference_root).traverse do |ent|\n destent = Entry_.new(d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove a given link entirely The link MUST exist in the set | def remove_link(link)
# If the_link is head, set head to nil
if self[:head_id] == link.id
self[:head_id] = link.next_id
end
if link.prev
# If things on both sides, link them
if link.next
link.prev.next_id = link.next_id
link.next.prev_id = link.prev_id... | [
"def remove_link(link)\n links.delete(link)\n end",
"def remove(link)\n _link = find(link)\n return if _link.nil?\n _link.before.next = _link.next\n @tail = _link.before if @tail == link\n end",
"def remove_link(link)\n raise Occi::Core::Errors::MandatoryArgumentError, 'Cannot remove... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates the authentication link for a given provider service | def auth_link
::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,
::Deepblue::LoggingHelper.called_from,
"provider=#{provider}",
"" ] if browse_everything_controller_de... | [
"def auth_link\n @auth_link ||= if provider.present?\n link, data = provider.auth_link(connector_response_url_options)\n provider_session.data = data\n link = \"#{link}&state=#{provider.key}\" unless link.to_s.include?('state')\n lin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate the provider name from the Rails session state value | def provider_name_from_state
::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,
::Deepblue::LoggingHelper.called_from,
"" ] if browse_everything_controller2_debug_verbose
rv = params[:state].to_s.split(/\|/... | [
"def provider_name\n params[:provider] || provider_name_from_state || browser.providers.each_key.to_a.first\n end",
"def provider_name\n provider.titleize\n end",
"def provider_name\n self.dig_for_string(\"providerName\")\n end",
"def state_session_name\n (session_state_data_prefix + @flow_id).... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs a browser manager Object Browser state cannot persist between requests to the Controller Hence, a Browser must be reinstantiated for each request using the state provided in the Rails session | def browser
::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,
::Deepblue::LoggingHelper.called_from,
"" ] if browse_everything_controller2_debug_verbose
rv = BrowserFactory.build(session: session, url_opti... | [
"def browser\n BrowserFactory.build(session: session, url_options: url_options)\n end",
"def browser\n @_browser ||= Browser.new\n end",
"def initialize browser\n @browser = browser\n end",
"def create(*args)\n return Browser.new(*args)\n end",
"def browser\n @options[:browser] ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes the focus. If the specified area doesn't exist, the focus is set to nil. | def change_focus(area_name, configuration)
@focus = if !area_name.nil? && configuration.areas.key?(area_name)
configuration.areas[area_name]
else
# This is a 'null' area, used when the focus is empty or invalid
{
key: 'null',
... | [
"def change_focus(area)\n @state.change_focus(area[:key], @configuration)\n @state.persist\n @area = @state.focus\n end",
"def set_focus\n `#{element}.focus()`\n end",
"def focus(locator)\n do_command(\"focus\", [locator,])\n end",
"def focus\n assert... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /thing_lists GET /thing_lists.xml | def index
@thing_lists = ThingList.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @thing_lists }
end
end | [
"def show\n @thing_list = ThingList.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @thing_list }\n end\n end",
"def index\n @lists = List.find(:all)\n\n respond_to do |format|\n format.html\n format.xml { render :xml =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /thing_lists/1 GET /thing_lists/1.xml | def show
@thing_list = ThingList.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @thing_list }
end
end | [
"def index\n @thing_lists = ThingList.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @thing_lists }\n end\n end",
"def index\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(:all)\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /thing_lists/new GET /thing_lists/new.xml | def new
@thing_list = ThingList.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @thing_list }
end
end | [
"def new\n @title = \"New Listing\"\n @list = List.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @list }\n end\n end",
"def create\n @thing_list = ThingList.new(params[:thing_list])\n\n respond_to do |format|\n if @thing_list.save\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /thing_lists POST /thing_lists.xml | def create
@thing_list = ThingList.new(params[:thing_list])
respond_to do |format|
if @thing_list.save
format.html { redirect_to(@thing_list, :notice => 'Thing list was successfully created.') }
format.xml { render :xml => @thing_list, :status => :created, :location => @thing_list }
... | [
"def create_list(name:)\n JSON.parse(api_request(method: :post, path: \"lists\", params: list_params(name)))\n end",
"def post(list, message)\n http, response = form_response(list)\n if Net::HTTPSuccess === response\n response = post_request(list, message, response,http)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /thing_lists/1 PUT /thing_lists/1.xml | def update
@thing_list = ThingList.find(params[:id])
respond_to do |format|
if @thing_list.update_attributes(params[:thing_list])
format.html { redirect_to(@thing_list, :notice => 'Thing list was successfully updated.') }
format.xml { head :ok }
else
format.html { render :a... | [
"def update_list(list_id:, name:)\n api_request(method: :patch, path: \"lists/#{list_id}\", params: list_params(name))\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def test_update_list\n remote_fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /thing_lists/1 DELETE /thing_lists/1.xml | def destroy
@thing_list = ThingList.find(params[:id])
@thing_list.destroy
respond_to do |format|
format.html { redirect_to(thing_lists_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @mylist = Mylist.find(params[:id])\n @mylist.destroy\n\n respond_to do |format|\n format.html { redirect_to(mylists_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @checklist = Checklist.find(params[:id])\n @checklist.destroy\n\n respond_to do |format|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to return the firmware_revision and environment | def firmware_and_environment
'#{firmware_revision}' + '--' + '#{environment}'
end | [
"def firmware_version\n return @firmware_version unless @firmware_version.nil?\n\n # Request firmware version number\n send_command( 0x36 )\n\n # Read back one byte\n value = getc\n major = (value & 0xF0) >> 4\n minor = value & 0x0F\n return @firmware_version = \"#{major}.#{minor}\"\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method retrieves the requested place (if it exists) and also pulls the reviews associated with the place | def show
@place = Place.find_by(:id => params["id"])
@reviews = Review.where(:place_id => params["id"]).order(id: :desc)
if @place != nil
render "show"
else
redirect_to "/", notice: "Place not found in this app!"
end
end | [
"def find_place\n\t @place = Place.get(params[:place_id]) unless params[:place_id].nil?\n\tend",
"def create\n @place_review = @place.reviews.build(place_review_params)\n\n respond_to do |format|\n if @place_review.save\n format.html { redirect_to @place, notice: 'Place review was successfull... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Populate the tiles of our world | def populate!()
tile_factory = TileFactory.new()
livingbeing_factory = LivingBeingFactory.new()
@m.times do |y|
@n.times do |x|
# Water vs Ground
location = Location.new(@n, @m, x, y)
wg = tile_factory.create(Utils.generate_random_percentage(), loc... | [
"def build_tiles\n @tiles = Array.new(@y_size) { |y| Array.new(@x_size) { |x| Tile.new(x, y) } }\n end",
"def gen_tiles\n @grid.each_with_index do |row, row_id|\n row.each_with_index do |tile, col_id|\n value = count_bombs([row_id, col_id])\n @grid[row_id][col_i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method, given a Redis command, will try to guess the right slot. It does not need to return the right slot, as redirection will fix that automatically. | def guess_hashslot(args)
cmd = args[0].to_s.downcase
case cmd
when "incr"
return slot_from_key(args[1])
when "get"
return slot_from_key(args[1])
when "set"
return slot_from_key(args[1])
... | [
"def found_cmd( command )\n dbg 'found_cmd b4 ', command, @cmd_found.join(','), '|', @cmd_left.join(',')\n @cmd_found.push command\n @cmd_left.shift\n dbg 'found_cmd aft', command, @cmd_found.join(','), '|', @cmd_left.join(',')\n end",
"def fetch_command(command); end",
"def execute_command(command... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return highest game ID in saved game database | def get_game_id()
res = @db.query("SELECT MAX(GameID) FROM SavedGames;");
row = res.fetch_row
row[0].to_i
end | [
"def max_event_id; $game_map.max_id; end",
"def last_game\n set_games.last\n end",
"def maxIDFootballTeam\n\t\tresults = @client.query(\"SELECT max(id_team) as max from football_tearm\")\t\n\t\treturn results.first[\"max\"].to_i\n\tend",
"def find_max_id(db, table)\r\n\t# Get list of ids\r\n\tid_array = d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return array of user stats | def get_stats()
result = Array.new()
res = @db.query("SELECT * FROM UserStats;")
while row = res.fetch_row do
result.push(UserInfo.new(row[0], row[1], row[2], row[3]))
end
result
end | [
"def get_user_stat\n response = self.get(\"/v1/stats/users.json?auth_token=#{@auth_token}\")\n JSON.parse response.body if response and response.body\n end",
"def user_stats(user)\n request(\"users/#{user}/stats\")[\"stats\"]\n end",
"def user_stats\n generate 'sufi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get number of games played for a particular user | def get_game_count(username)
get_count(username, 'Played')
end | [
"def get_game_count( user_id )\n return Game.count(:conditions => [\"user_id = ?\", user_id])\n end",
"def get_count( user_id )\n return Game.count(:conditions => [\"user_id = ?\", user_id])\n end",
"def get_total_games_played\n return games.size\n end",
"def get_total_games_played\n\t\tretu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get number of wins for a particular user | def get_win_count(username)
get_count(username, 'Wins')
end | [
"def get_game_count(username)\n get_count(username, 'Played')\n end",
"def get_wins(user_id, friend_id, game_id)\n Match.where(winner_id: user_id, loser_id: friend_id, game_id: game_id).count(:winner_id)\n end",
"def update_user_game_result_count(user, winner_team)\n if winner_team.users.include? use... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get number of losses for a particular user | def get_loss_count(username)
get_count(username, 'Losses')
end | [
"def get_loss_count\n losses = Matchup.where({\"loser_competitor_id\" => self.id})\n loss_count = losses.count\n return loss_count.to_f\n end",
"def count_losses\n loss_no = 0\n Battle.where(\"movie_loser\" => self.id).each do\n loss_no += 1 \n end\n return loss_no\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
print out stats table, for debugging | def print_stats_table()
res = @db.query("SELECT * FROM UserStats;")
while row = res.fetch_row do
printf "%s %s\n", row[0], row[1], row[2], row[3]
end
end | [
"def print_table\n puts\n\n data = get_total_data\n puts(\"Metrics for: \" +\"'\" + data[0] + \"', \" + data[1] + \" Requests, \" + data[2] + \"MB downloaded. \" + \"Load time: \" + data[3] + \"s\")\n\n puts\n print_rows\n puts\n end",
"def print_stats\n puts \"===============... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get list of saved games for a particular user | def get_saved_games_list(username)
result = Array.new()
res = @db.query("SELECT DISTINCT GameID, User1, User2, GameType FROM SavedGames WHERE User1 = '#{username}' OR User2 = '#{username}';")
while row = res.fetch_row do
result.push(GameListElement.new(row[0], row[1], row[2], row[3]))
end
resu... | [
"def saved_game_list(user_name)\n db = Database.new\n result = db.get_saved_games_list(user_name)\n db.close\n result\n end",
"def games(username)\n raise UserDoesNotExist unless user_exists?(username)\n games = []\n query(load_query('user_games'), username, username).each do |row|\n ro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a generic lens key based on the nature of the provided document. | def key_for_doc(doc, default = true)
=begin # TODO: If Blacklight::Document responded to :lens_key
if doc.respond_to?(:lens_key)
doc.lens_key
elsif doc.to_s.include?('__')
Config::Articles.key
elsif doc.is_a?(String)
Config::Catalog.key
elsif default.is_a?(TrueClass)
... | [
"def key_for_doc(doc, default = true)\n if doc.respond_to?(:lens) && doc.lens\n doc.lens\n elsif doc\n doc_id = doc.respond_to?(:id) ? doc.id : doc.to_s\n doc_id.include?('__') ? :articles : :catalog\n elsif default.is_a?(TrueClass)\n default_lens_key\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Translate a named item to a lens key. If the name is derived from the current controller then the method will attempt to strip off name variations to find the core name (for example, 'video_advanced' will result in 'video'; 'articles_suggest' will result in 'articles', etc). | def key_for_name(name, default = true)
name = name.to_s.strip
result =
case name
when KEY_PATH_HINT
name.underscore
.sub(%r{^.*/([^/]+)$}, '\1') # "devise/catalog" -> "catalog"
.sub(/^config/, '') # "config_video" -> "_video"
.... | [
"def key_for_name(name, default = true)\n name = name.to_s.strip\n result =\n case name\n when KEY_PATH_HINT\n name.underscore\n .sub(%r{^.*/([^/]+)$}, '\\1') # 'devise/catalog' -> 'catalog'\n .sub(/^config/, '') # 'config_video' ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests whether the matcher matches the +rendered+ string. It delegates matching to its matchers. It returns true if all of its matchers return true. It returns false if any of its matchers return false. | def matches?(rendered)
@rendered = rendered
@failures = matchers.reject do |matcher|
matcher.matches?(rendered)
end
@failures.empty?
end | [
"def matches?(rendered)\n @rendered = rendered\n matches = Nokogiri::HTML::Document.parse(@rendered.to_s).css(@name).select do |element|\n matches_attributes?(element) && matches_content?(element) && matches_criteria?(element)\n end\n matches_count?(matches)\n end",
"def matches_cont... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the negative failure messages from every matcher. | def negative_failure_message
matchers.map(&:negative_failure_message).join(" and ")
end | [
"def negative_failure_message\n \"Expected not to match against <#{@name} #{@attrs.map{ |a,v| \"#{a}=\\\"#{v}\\\"\" }.join(\" \")}> tag, but it matched\"\n end",
"def failure_message\n actual = prettify_args(@actual)\n matcher = prettify_matcher(@expected.metadata[:name])\n\n if @expe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
runs benchmark comparing an array of methods | def benchmark(methods)
Benchmark.ips do |x|
x.config(time: 5, warmup: 2)
methods.each do |name, method|
x.report(name) { method }
end
x.compare!
end
end | [
"def compare_run_times(tests, method1, method2)\n total_time_map_reduce = 0\n total_time_regex = 0\n\n tests.each do |test|\n map_reduce_time = time_method(method1, test[:text])\n regex_time = time_method(method2, test[:text])\n\n total_time_map_reduce += map_reduce_time\n total_time_regex += regex_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This pre setup method for case. It will be executed before each case is executed | def pre_setup_case()
return "pre_setup_for_case"
end | [
"def before_setup\n # do nothing by default\n end",
"def setup\n setup! unless setup?\n end",
"def setup\n setup! unless setup?\n end",
"def before_setup(&block)\n pre_setup_actions.unshift block\n end",
"def setup\n end",
"def preRun\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This tear down method for case. It will be executed after each case is executed | def tear_down_case()
return "tear_down_for_case"
end | [
"def teardown\n end",
"def teardown; cleanup; super; end",
"def teardown\n cleanup_tables\n cleanup_caches\n end",
"def cleanup_machine; end",
"def after_teardown; end",
"def teardown\n Process.kill('KILL',@pid)\n end",
"def teardown\n @motor_controllers.each {|k, mc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The content of the email to send, include the headers and the body. Takes the same argument as error_email. | def error_email_content(exception)
email_opts = self.class.opts[:error_email]
headers = email_opts[:default_headers].call(email_opts, exception)
headers = headers.merge(email_opts[:headers])
headers = headers.map{|k,v| "#{k}: #{v.gsub(/\r?\n/m, "\r\n ")}"}.sort.join("\r\n")
... | [
"def error_mail_content(exception)\n _error_mail(exception).to_s\n end",
"def generate_error_email_body\n error_contents = self.read_parse_logfile(self.error_filepath)\n warning_contents = self.read_parse_logfile(self.warning_filepath)\n message_body = \"<p>'#{self.study_file.upload_file_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Limit kind MicroLimits, LowLimits, AverageLimits, HighLimits, UltrahighLimits | def limit_kind
case @limit
when 'NL', 'PL' then
case buy_in
when 0..1 then 'NanoLmimits'
when 2..19 then 'MicroLimits'
when 20..199 then 'LowLimits'
when 200..999 then 'AverageLimits'
when 1000..9999 then 'HighLimits'
when 1... | [
"def limits\n version_guard(29.0) { api_get(\"limits\").body }\n end",
"def get_limits\n # code\n end",
"def limits\n login\n\n uri = @services['compute'] + 'limits'\n\n body = request Net::HTTP::Get, uri\n\n limits = body['limits']\n\n @rate_limits = limits['rate']\n @abso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
generate positions names for players | def generate_positions!
position_names = Utils::Rules.position_names(players_count)
sorted_players = players.sort_by(&:seat)
# Find the button and name the seats after the button
sorted_players.each do |player|
player.position_name = 'BTN' if player.seat == @button_seat
... | [
"def name_all_players\n (0..num_players - 1).each { |i| @players[i].name_player('Player' + i.to_s)}\n end",
"def std_player_names\n\t\tnames = []\n\t\tfor i in 1..Constants::MAX_PLAYERS\n\t\t\tnames << \"Player\" + i.to_s\n\t\tend\n\t\tnames\n\tend",
"def generate_players\n (1..(@N).to_i).each do |pl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return array containing absolute values of original | def abs()
self.map{ |v| v.abs }
end | [
"def abs\n self.map { |e| e.abs }\n end",
"def abs!\n @data = @data.map {|x| x.abs }\n return self\n end",
"def abs\n abs_img = self.copy\n abs_img.bitmap.rows.each do\n |r|\n r.collect!{|e| e.abs}\n end\n return abs_img\n end",
"def abs\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return sum of absolute values of numbers within array | def abs_sum()
self.abs().sum()
end | [
"def get_abs_sum(arr)\n\tsum = 0;\n\tarr.each { |n| sum += n.abs}\n\tsum\nend",
"def abs_sum\n self.compact.map{|i| i.respond_to?(:abs) ? BigDecimal.new(i.abs.to_s) : 0}.sum\n #values are converted into BigDecimals so as not to be summing floats\n #which goes wrong in C based languages (and others) 0.2+0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /autos/1 GET /autos/1.xml | def show
@auto = Auto.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @auto }
end
end | [
"def show\n @auto_id = AutoId.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @auto_id }\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /autos/new GET /autos/new.xml | def new
@auto = Auto.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @auto }
end
end | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @newstuff = Newstuff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newstuff }\n end\n end",
"def n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /autos POST /autos.xml | def create
@auto = Auto.new(params[:auto])
respond_to do |format|
if @auto.save
format.html { redirect_to(@auto, :notice => 'Auto was successfully created.') }
format.xml { render :xml => @auto, :status => :created, :location => @auto }
else
format.html { render :action => ... | [
"def create\n @note = Note.new(params[:note])\n\n=begin\n $ curl -H 'Content-Type: application/xml' -X POST -d '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<note>\n <content>note from api 2</content>\n <course_id>2</course_id>\n <tag>api</tag>\n</note> http://notility.herokuapp.com/notes\n=end\n\n res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /autos/1 PUT /autos/1.xml | def update
@auto = Auto.find(params[:id])
respond_to do |format|
if @auto.update_attributes(params[:auto])
format.html { redirect_to(@auto, :notice => 'Auto was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xm... | [
"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\n @auto... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /autos/1 DELETE /autos/1.xml | def destroy
@auto = Auto.find(params[:id])
@auto.destroy
respond_to do |format|
format.html { redirect_to(autos_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @auto_id = AutoId.find(params[:id])\n @auto_id.destroy\n\n respond_to do |format|\n format.html { redirect_to(auto_ids_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @auto = Auto.find(params[:id])\n @auto.destroy\n\n respond_to do |format|\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a URL for a thumbnail for this model's attachment. | def thumbnail_url
(ipaper_document && ipaper_document.thumbnail_url) || public_filename(:thumb)
end | [
"def thumbnail_url\n return self.endpoint.thumbnail_url(self.id)\n end",
"def thumbnail_url\n return @thumbnail_url\n end",
"def url\n thumbnail_reference || generated_thumbnail\n end",
"def thumbnail_url(attribute)\n doc = scribd_document_for(attribute)\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the content type for this model's attachment. | def get_content_type
self.content_type
end | [
"def attachment_type()\n self.class.attachment_type\n end",
"def content_type\n @instance.send(self.content_type_field)\n end",
"def attachment_type\n return if attachments.nil?\n\n attachments.first['type']\n end",
"def content_type\n return @content_ty... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /city_bs GET /city_bs.json | def index
@city_bs = CityB.all
end | [
"def cities\n self.class.get(\"/v1/cities\")\n end",
"def index\n if params.has_key?(\"state_id\")\n @db_state = DbState.find_by_id(params[:state_id])\n @db_cities = @db_state.try(:cities)\n else\n @db_cities = DbCity.all\n end\n render json: @db_cities\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /city_bs POST /city_bs.json | def create
@city_b = CityB.new(city_b_params)
respond_to do |format|
if @city_b.save
format.html { redirect_to @city_b, notice: 'City b was successfully created.' }
format.json { render :show, status: :created, location: @city_b }
else
format.html { render :new }
for... | [
"def create\n @api_city = Api::City.new(api_city_params)\n\n if @api_city.save\n render json: @api_city, status: :created, location: @api_city\n else\n render json: @api_city.errors, status: :unprocessable_entity\n end\n end",
"def create\n @city = City.new(city_params)\n\n if @city.s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /city_bs/1 PATCH/PUT /city_bs/1.json | def update
respond_to do |format|
if @city_b.update(city_b_params)
format.html { redirect_to @city_b, notice: 'City b was successfully updated.' }
format.json { render :show, status: :ok, location: @city_b }
else
format.html { render :edit }
format.json { render json: @ci... | [
"def update\n respond_to do |format|\n if @city.update(city_params)\n format.json { head :no_content }\n else\n format.json { render json: @city.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_city = Api::City.find(params[:id])\n\n if @api_c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /city_bs/1 DELETE /city_bs/1.json | def destroy
@city_b.destroy
respond_to do |format|
format.html { redirect_to city_bs_url, notice: 'City b was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @api_city.destroy\n\n head :no_content\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @city.destroy\n respond_to do |format|\n format.html { redirect_to cities_url }\n format.json ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /threds GET /threds.xml | def index
@threds = Thred.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @threds }
end
end | [
"def index\n @thres = Thre.all\n end",
"def index\n @therapists = do_index(Therapist, params)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @therapists }\n end\n end",
"def index\n @thoughts = Thought.all\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /threds/new GET /threds/new.xml | def new
@thred = Thred.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @thred }
end
end | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @threat = Threat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @threat }\n end\n end",
"def new\n ... | {
"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.