query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Timecode TC helper: parse both hh:mm:ss:ttt and hh:mm:ss.sss TC formats used in DCSubtitle | def parse_dcsubtitle_tc_string( tc_string, fps )
case tc_string
when /\d\d:\d\d:\d\d:\d\d\d/ # hh:mm:ss:ttt
Timecode.parse_with_ticks( tc_string, fps )
when /\d\d:\d\d:\d\d\.\d\d\d/ # hh:mm:ss.sss
Timecode.parse( tc_string, fps )
else
nil
end
end | [
"def parse_srt_time(time)\n time =~ /^(\\d+):(\\d+):(\\d+),(\\d{3})$/\n hh, mm, ss, ms = [$1, $2, $3, $4].map(&:to_i)\n hh*3600 + mm*60 + ss + ms/1000.0\n end",
"def interpret_time\n a_b = /^(\\d{1,4})(am|pm)?$/ # handles cases (a) and (b)\n c_d_e = /^(\\d{1,2}):(\\d{1,2}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check_compliance Verify a sorted certificate chain | def verify_cert_chain( certs, context_errors )
certs = certs.reverse
verification = Array.new
certs.each_with_index do |cert, index|
if index == 0 then issuer = cert else issuer = certs[ index - 1 ] end
begin
check = cert.verify issuer.public_key
context_errors[ cert.subject.to_s... | [
"def verify_cert_chain( certs, context_errors )\n certs = certs.reverse\n verification = Array.new\n certs.each_with_index do |cert, index|\n if index == 0 then issuer = cert else issuer = certs[ index - 1 ] end\n begin\n check = cert.verify issuer.public_key\n context_errors[ cert.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Puts current version of the file to items. | def put!(method)
# If necessary, creates the state record
if not self.file.state.exists?
self.file.state.create(@file)
end
# Rotates other items
new_list = { }
self.each_item do ... | [
"def update_version_file(version)\n if File.exists?('VERSION')\n File.open('VERSION', 'w') { |f| f << version.to_s }\n modified_files << 'VERSION'\n end\n end",
"def push_item(item)\n enable_write\n abs_path = full_path(item.path)\n parent_id = get_parent_id(abs_path)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /entries GET /entries.xml | def index
@entries = Entry.all;
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @entries }
end
end | [
"def index\n @entries = Entry.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entries }\n end\n end",
"def index_rest\n @entry_items = EntryItem.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Methods relating to updating Bibl records with metadata from an external source, namely U.Va. Library catalog / Blacklight Looks up (via Ajax request) a record in the external metadata source (U.Va. Library catalog / Blacklight) based on externalrecordID and populates the HTML form fields on the page with corresponding... | def external_lookup
# look up catalog ID (passed as a parameter) in external metadata source,
# getting back a Bibl object with the values from the external source
begin
# Note: The Bibl object (variable "bibl") here is just a convenient
# carrier for the metadata values gleaned from t... | [
"def update\n respond_to do |format|\n if @record_library.update(record_library_params)\n format.html { redirect_to @record_library, notice: 'Record library was successfully updated.' }\n format.json { render :show, status: :ok, location: @record_library }\n else\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Algolia Faroo Web Search Get top 5 search results for topic name and save to resource table. | def scrape_resources(topic)
#The query parameters: (update according to your search query)
q = "#{topic.name}"; #the search query
pageNumber = 1 #the number of requested page
pageSize = WebScraperOptions[:numSearchResults] #the size of a page
autoCorrect = false #autoCorrectspelling
safeSe... | [
"def popular_topics(limit = 10)\n Entity.joins(:document).where(:documents => {:municipality_id => self.id}).where(:kind => \"IndustryTerm\").limit(limit).group_by(&:name)\n end",
"def suggestions\n render json: Query.suggest_most_frequent(params[:query].downcase).limit(5)\n end",
"def top5\n results... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
send buy order to Kraken | def order_to_kraken
kraken = Kraken::Client.new(ENV['KRAKEN_PUBLIC_KEY'], ENV['KRAKEN_SECRET_KEY'])
origin_price = cal_origin_price
Process.fork do
txid = kraken.buy_sell(amount, origin_price, "buy", currency+payment_type, "+3600")
MyLog.kraken("#{Process.pid}")
if txid.is_a?(Hash)
... | [
"def order_to_kraken\n kraken = Kraken::Client.new(ENV['KRAKEN_PUBLIC_KEY'], ENV['KRAKEN_SECRET_KEY'])\n origin_price = cal_origin_price\n Process.fork do\n txid = kraken.buy_sell(amount, origin_price, \"sell\", currency+payment_type, \"+3600\")\n MyLog.kraken(\"#{Process.pid}\")\n if txid.i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
trust price on server | def trust_buy_price
setting_price = get_setting_price('TradeBid')
if setting_price.activate_price
setting_price.price
else
Rails.cache.read("kraken-price-#{currency}#{payment_type}")[:buy_order_price]
end
end | [
"def trust_sell_price\n setting_price = get_setting_price('TradeAsk')\n if setting_price.activate_price\n setting_price.price\n else\n Rails.cache.read(\"kraken-price-#{currency}#{payment_type}\")[:sell_order_price]\n end\n end",
"def silver_upgrade_price\n upgrade_price(SILVER)\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TEST 10 def find_pet_by_name(pet_shop, name) for pet in pet_shop[:pets][:name] if pet[:name] == pet end end end TEST 11 | def find_pet_by_name(pet_shop, name)
for pet in pet_shop[:pets]
if pet[:name] == pet
return pet
else return nil
end
end
end | [
"def find_pet_by_name(pet_shop, pet_name)\n\n for pets in pet_shop[:pets]\n\n if pets[:name] == pet_name\n\n\n return pets\n\n end\n end\n\n return\n end",
"def find_pet_by_name(unit, name)\n for pet in unit[:pets]\n return pet i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TEST 20 + 21 + 22 Separate function to test pet_found def sell_pet_to_customer(pet_shop, pet, customer) if pet != nil customer[:pets].push(pet) customer[:cash] = pet[:price] end end | def sell_pet_to_customer(pet_shop, pet, customer)
if pet != nil && customer[:cash] >= pet[:price]
customer[:pets].push(pet)
pet_shop[:admin][:pets_sold] += 1
customer[:cash] -= pet[:price]
pet_shop[:admin][:total_cash] += pet[:price]
end
end | [
"def sell_pet_to_customer(petshop_hash, pet, customer)\n\n # if (petshop_hash[:pets].include?(pet)) && (customer_can_afford_pet == true)\n\n customer[:pets] << pet\n\n petshop_hash[:admin][:pets_sold] += 1\n\n customer[:cash] -= pet[:price]\n\n petshop_hash[:admin][:total_cash] += pet[:price]\n # else\n # ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The database column currently associated with the workflow state of the record. | def state_column(*)
STATE_COLUMN
end | [
"def workflow_column\n self.class.workflow_column\n end",
"def column\n klass.columns_hash[field.to_s]\n end",
"def state_column(name = :process_status)\n @state_column ||= name\n end",
"def current_column; end",
"def status_column\n status = Status.find_by(id: @status_id)\n re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Workflow state table associated with item. | def state_table(item)
get_state_table(item) || {}
end | [
"def state\n @state_wrapper ||= ActionItemInternal::ActionItemStateWrapper.new(@item)\n end",
"def wf_set_records_state(*items, state: nil)\n items = succeeded if items.blank?\n items.each do |item|\n next unless item.is_a?(Upload)\n state ||= current_state\n item.set_phase(workflow_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the group of the given state. | def state_group(item)
if item.is_a?(String) || item.is_a?(Symbol)
state = item.to_sym
else
state = state_value(item)
end
REVERSE_STATE_GROUP[state] || :all
end | [
"def state_group(target_state = nil)\n target_state ||= active_state\n Upload::WorkflowMethods.state_group(target_state)\n end",
"def state_group\n state = @current_policy ? @current_policy.tax_state_abbr : @company_info.hq_state\n case state\n when nil\n 'All'\n when 'CA'\n 'Californ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the label for the given state group. | def state_group_label(group)
if group.is_a?(String) || group.is_a?(Symbol)
group = group.to_sym
else
group = state_group(group)
group = nil if group == :all
end
# noinspection RubyMismatchedArgumentType
STATE_GROUP.dig(group, :label)
end | [
"def state_group_label(group = nil)\n # noinspection RubyMismatchedArgumentType\n super(item || self)\n end",
"def label(state)\n \" \" + I18n.t(\"state.#{state}.desc\")\n end",
"def rs_group_label\n CFR_RS_GROUP_LABELS[ rs_group ] unless rs_group.nil?\n end",
"def step_label\n if ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Indicate whether this record is involved in a workflow step related to the modification of an existing EMMA entry. | def being_modified?(item)
state_group(item) == :edit
end | [
"def modified?\n new_record? || original_attributes.substantial_difference_to?(attributes)\n end",
"def modified?\n @modified\n end",
"def modified?\r\n @modified\r\n end",
"def modification?\n @git_change.change_type.include?(:modified)\n end",
"def modified?\n\t\treturn sel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Indicate whether this record is involved in a workflow step related to the removal of an existing EMMA entry. | def being_removed?(item)
state_group(item) == :remove
end | [
"def removed?\n @removed\n end",
"def is_removed?\n self.has_current_status_of?(ArticleSubmission::ADMIN_REMOVED) || self.has_current_status_of?(ArticleSubmission::REMOVED)\n end",
"def on_removed_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validate state table definitions and interconnections. | def validate_state_table(table = nil)
table ||= get_state_table(no_raise: false)
meths = self.is_a?(Module) ? instance_methods : self.class.methods
states = table.keys
errors = []
table.each_pair do |state, config|
# === Check optional note
if config.key?(:note)
... | [
"def validate_states(lexer)\n if !lexer.state_info.respond_to?(:each_pair)\n complain(\"States must be defined as a hash\")\n end\n\n lexer.state_info.each do |state_name, state_type|\n if ![:inclusive, :exclusive].include?(state_type)\n complain(\"State type for state #{state_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an ActiveJob serializer for the given Record class if it does not already exist. | def generate_job_serializer(base)
unless model_class?(base)
return Log.debug { "#{__method__}: ignoring #{base.class} argument" }
end
base_name = base.name
serializer = "#{base_name}::Serializer"
return if safe_const_get(serializer)
base.module_eval <<~HERE_DOC
cla... | [
"def instantiate_and_register_record(record_json)\n record = model_class.new(@client, record_json)\n register_record(record)\n record\n end",
"def serializer_class(base = nil)\n base ||= self_class\n serializer = base.safe_const_get(:Serializer, false)\n unless serializer\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the label for the state group of the record. | def state_group_label(group = nil)
# noinspection RubyMismatchedArgumentType
super(item || self)
end | [
"def state_group_label(group)\n if group.is_a?(String) || group.is_a?(Symbol)\n group = group.to_sym\n else\n group = state_group(group)\n group = nil if group == :all\n end\n # noinspection RubyMismatchedArgumentType\n STATE_GROUP.dig(group, :label)\n end",
"def label(state)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the next legal state(s). If "emma.state_table.[...].next" is false, nil or missing, the result is an empty array (indicating a terminal state). | def transitions(curr_state = nil, **)
curr_state = state_value(curr_state)
next_states = state_table.dig(curr_state, :next)
Array.wrap(next_states).compact_blank
end | [
"def next_from_state_e\n if value.zero?\n [0, 1, A]\n else\n [1, 1, C]\n end\n end",
"def next_state_at(state)\n @state_at[state+1..-1].detect{ |time| !time.nil? }\n end",
"def next_state_at(state)\n @state_at[state+1..-1].inspect\n @state_at[state+1..-1].detect{ |time| !ti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Login a user for a new session /api/v1/auth/login ==== Attributes +username+ (required) A valid username (String) +password+ (required) A valid password (String) +device_id+ (required) Device ID (String) +push_token+ Push token (String) | def login(username, password, device_id, push_token = '')
values = {
username: username,
password: password,
device_id: device_id,
push_token: push_token
}
@client.make_request :post, auth_path('login'), values
end | [
"def login\n client.login(\n params[:user],\n params[:password],\n authParams: {\n scope: 'openid name email'\n },\n connection: 'Username-Password-Authentication'\n )\n end",
"def login(username, password)\n opts = @options.merge({\n headers: headers,\n b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Login a user for a new session using token and secret. Endpoint for third party clients. /api/v1/auth/login_token ==== Attributes +token+ (required) A user token (String) +secret+ (required) A user secret (String) ==== Examples client.auth.login_with_token('token', 'secret') | def login_with_token(token, secret)
values = {
token: token,
secret: secret
}
@client.make_request :post,
auth_path('login_token'),
values
end | [
"def login\n data = post_request(\"/users/token\", User.new(@user, @pass)._serialize)\n @token = data[\"access_token\"]\n @user_id = data[\"user_id\"]\n end",
"def login_with_token(bot, name, token)\n send Common::Login.new(bot, name, nil, token)\n end",
"def login\n user = User.f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Logout a user session /api/v1/auth/logout ==== Examples client.auth.logout | def logout
@client.make_request :post,
auth_path('logout')
end | [
"def logout\n raise \"not logged in\" unless @logged_in\n call_api('/Users/logout')\n @logged_in = nil\n end",
"def user_logout\n res = http_delete(:uri=>\"/session\", :fields=>x_cookie)\n return res.code\n end",
"def logout!\n session[:auth_token] = nil\n cookies[:auth_token... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Logout a user session by device id only /api/v1/auth/logout_device ==== Attributes +device_id+ (required) Device ID (String) | def logout_device(device_id)
values = {
device_id: device_id
}
@client.make_request :post,
auth_path('logout_device'),
values
end | [
"def logout_user\n if !current_user.nil?\n \t token = User.new_token\n \t current_user.update_attribute(:remember_token, User.hash(token))\n \t cookies.delete(:current_user_token)\n current_user.remove_device_token(params['device_token']) if params.has_key?('device_token')\n \t current_user = nil\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Request a new password, given a user name or email address /api/v1/auth/request_new_password ==== Attributes +name+ (required) A valid user name or email address (String) ==== Examples client.auth.request_new_password('John') | def request_new_password(name)
values = {
name: name
}
@client.make_request :post,
auth_path('request_new_password'),
values
end | [
"def change_user_password(user, pass)\n request({req: 'changeuserpassword', username: user, newpassword: pass})\n end",
"def set_password(new_password)\n UserPassword.new(:id => id, :new_password => new_password).post\n end",
"def new_password(account, new_password)\n @new_password = new_pass... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Login by PIN and Device ID /api/v1/auth/login_pin ==== Attributes +pin+ (required) PIN code (String) +device_id+ (required) Device ID (String) +push_token+ (required) Push Token (String) | def login_by(pin, device_id, push_token)
values = {
pin: pin,
device_id: device_id,
push_token: push_token
}
@client.make_request :post,
auth_path('login_pin'),
values
end | [
"def login(username, password, device_id, push_token = '')\n values = {\n username: username,\n password: password,\n device_id: device_id,\n push_token: push_token\n }\n\n @client.make_request :post, auth_path('login'), values\n end",
"def login\n params = {\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set user pin /api/v1/auth/pin ==== Attributes +pin+ (required) PIN code (String) | def update_user_pin(pin)
values = {
pin: pin
}
@client.make_request :post,
auth_path('pin'),
values
end | [
"def set_pin(pin)\n VacmanController::LowLevel.set_token_pin(@token_hash, pin.to_s)\n end",
"def pin=(pin)\n if pin.match(/\\d{4}/)\n self.pin_salt = Digest::SHA1.hexdigest([Time.now, rand].join)\n self.pin_hash = encrypt_pin(pin)\n end\n end",
"def reset_user_pin(new_pin)\n # gene... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get token (Refresh token) /api/v1/auth/token ==== Attributes +pin+ (required) PIN code (String) +device_id+ (required) Device ID (String) | def refresh_token(pin, device_id)
values = {
pin: pin,
device_id: device_id
}
@client.make_request :post,
auth_path('token'),
values
end | [
"def get_token(integrator_key, email, password)\n content_type = { 'Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' }\n uri = build_uri('/oauth2/token')\n\n request = Net::HTTP::Post.new(uri.request_uri, content_type)\n request.body = \"grant_type=password&cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Process one time login link and return the pass_reset /api/v1/auth/user_pass_reset ==== Attributes +uid+ (required) The uid of the user in the operation. (Number) +timestamp+ (required) The timestamp value from the reset password link. (Number) +hashed_pass+ (required) The hashed pass value from the reset password link... | def pass_reset_token(uid, timestamp, hashed_pass)
values = {
uid: uid,
timestamp: timestamp,
hashed_pass: hashed_pass
}
@client.make_request :post,
auth_path('user_pass_reset'),
values
end | [
"def reset_password\n self.password = Digest::SHA1.hexdigest(email + last_login_at.to_i.to_s)[0..8]\n end",
"def send_reset_password_link\n service_response = UserManagement::SendResetPasswordLink.new(params).perform\n render_api_response(service_response)\n end",
"def password_reset_hash\n db.get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set push token api/v1/auth/push_token ==== Attributes +token+ (required) Push token (String) +os_type+ (required) OS type (String) | def update_push_token(token, os_type)
values = {
token: token,
os: os_type
}
@client.make_request :post,
auth_path('push_token'),
values
end | [
"def push_notification_token\n username = params[:user][:username]\n token = params[:token][:value]\n\n user = User.find_by(username: username)\n user.push_notification_token = token\n\n if user.save\n render json: { }, status: 204\n else\n render json: { error: I18n.t('push_notification... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Password reset /api/v1/auth/uid/password_reset ==== Attributes +uid+ (required) The id of the user (Number) | def reset_password(uid)
values = {
uid: uid
}
@client.make_request :post,
auth_path("#{uid}/password_reset"),
values
end | [
"def reset_password(userId, model, options={}) path = \"/api/v2/passwords/#{userId}/reset\"\n post(path, model, options, AvaTax::VERSION) end",
"def request_password_reset(email)\n post(\"/v1/password_resets\", email: email)\n end",
"def pass_reset_token(uid, timestamp, hashed_pass)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
What replies did this user write? | def authored_replies
Replies.find_by_user_id(@id)
end | [
"def reply_count\n replies.size\n end",
"def get_replies_to_conversation\n screen_name_of_mentions = self.mentions.map(&:screen_name)\n mentions_as_users = User.where(\"screen_name IN (?)\", self.mentions.map(&:screen_name)) \n Status.where(\"in_reply_to_status_id = ? AND user_id IN (?)\",\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
What questions does this user follow? | def followed_questions
QuestionFollower.followed_questions_for_user_id(@id)
end | [
"def question\n # get the question for every user\n end",
"def followed_questions\n QuestionFollower.followed_questions_for_user_id(self.id)\n end",
"def show_user_questions\n\t\tif logged_in?\n\t\t\t@user_questions = @current_user.question\n\t\tend\n\tend",
"def followed_questions\n QuestionFo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
callseq: sym.capitalize > symbol Same as sym.to_s.capitalize.intern. | def capitalize
(self.to_s.capitalize! || self).to_sym
end | [
"def capitalize!() end",
"def titleize_symbol symbol\n title = symbol.to_s.split('_')\n title.each { |word| word.capitalize! }.join(' ')\nend",
"def downcase\n (self.to_s.downcase! || self).to_sym\n end",
"def upcase\n (self.to_s.upcase! || self).to_sym\n end",
"def capitalize(input); end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
callseq: sym.downcase > symbol Same as sym.to_s.downcase.intern. | def downcase
(self.to_s.downcase! || self).to_sym
end | [
"def canonical(string_or_symbol)\n string_or_symbol.to_s.downcase.to_sym\n end",
"def symbolize(string)\n string.split.map(&:downcase).map(&:to_sym)\n end",
"def symbolize(s)\n s.to_s.gsub(/\\s+/,\"_\").gsub(/\\W+/,\"\").downcase.to_sym\n end",
"def method_missing sym\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
callseq: sym.upcase > symbol Same as sym.to_s.upcase.intern. | def upcase
(self.to_s.upcase! || self).to_sym
end | [
"def canonical(string_or_symbol)\n string_or_symbol.to_s.downcase.to_sym\n end",
"def downcase\n (self.to_s.downcase! || self).to_sym\n end",
"def upcase!() end",
"def downcase!() end",
"def upcase() end",
"def name_upcase\n name.upcase\n end",
"def swapcase!() end",
"def downc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
callseq: sym.casecmp(other) > 1, 0, +1 or nil Caseinsensitive version of Symbol. | def casecmp(other)
return nil unless other.kind_of?(Symbol)
lhs = self.to_s; lhs.upcase!
rhs = other.to_s.upcase
lhs <=> rhs
end | [
"def casecmp?(sym)\n c = self.casecmp(sym)\n return nil if c.nil?\n return c == 0\n end",
"def irccmp(name1, name2)\n if name1 && name2\n irccase(name1) == irccase(name2)\n end\n end",
"def casecmp(str)\n self.downcase <=> str.downcase\n end",
"def canonical(string_or_symbol)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
callseq: sym.casecmp?(other) > true, false, or nil Returns true if sym and other_sym are equal after case folding, false if they are not equal, and nil if other_sym is not a string. | def casecmp?(sym)
c = self.casecmp(sym)
return nil if c.nil?
return c == 0
end | [
"def casecmp(other)\n return nil unless other.kind_of?(Symbol)\n lhs = self.to_s; lhs.upcase!\n rhs = other.to_s.upcase\n lhs <=> rhs\n end",
"def irccmp(name1, name2)\n if name1 && name2\n irccase(name1) == irccase(name2)\n end\n end",
"def casecmp(str)\n self.downcase <=> ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this should redirect to the show_by_text so that from an FB ad ID, we can get to the show_by_text. | def show
if params[:archive_id]
@some_kind_of_ad = Ad.find_by(archive_id: params[:archive_id])
elsif params[:ad_id]
@some_kind_of_ad = FbpacAd.find_by(id: params[:ad_id])
end
raise ActiveRecord::RecordNotFound if @some_kind_of_ad.nil?
ad_text = @some_ki... | [
"def perform_show(show)\n nonce = _get_form_nonce 'shows.php', :promote => '', :cat => '11'\n page = _get_page show[:page], :formNonce => nonce\n _page_indicates_success? page\n end",
"def link_to_aid_funded(text)\n link = ''\n if opportunity.types.aid_funded.any?\n link = h.link_to 'https://... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /child_dupa2s/1 GET /child_dupa2s/1.xml | def show
@child_dupa2 = ChildDupa2.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @child_dupa2 }
end
end | [
"def show\n @child_dupa = ChildDupa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @child_dupa }\n end\n end",
"def new\n @child_dupa2 = ChildDupa2.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /child_dupa2s/new GET /child_dupa2s/new.xml | def new
@child_dupa2 = ChildDupa2.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @child_dupa2 }
end
end | [
"def new\n @child_dupa = ChildDupa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @child_dupa }\n end\n end",
"def create\n @child_dupa2 = ChildDupa2.new(params[:child_dupa2])\n\n respond_to do |format|\n if @child_dupa2.save\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /child_dupa2s POST /child_dupa2s.xml | def create
@child_dupa2 = ChildDupa2.new(params[:child_dupa2])
respond_to do |format|
if @child_dupa2.save
format.html { redirect_to(@child_dupa2, :notice => 'Child dupa2 was successfully created.') }
format.xml { render :xml => @child_dupa2, :status => :created, :location => @child_dupa... | [
"def create\n @child_dupa = ChildDupa.new(params[:child_dupa])\n\n respond_to do |format|\n if @child_dupa.save\n format.html { redirect_to(@child_dupa, :notice => 'Child dupa was successfully created.') }\n format.xml { render :xml => @child_dupa, :status => :created, :location => @child_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /child_dupa2s/1 PUT /child_dupa2s/1.xml | def update
@child_dupa2 = ChildDupa2.find(params[:id])
respond_to do |format|
if @child_dupa2.update_attributes(params[:child_dupa2])
format.html { redirect_to(@child_dupa2, :notice => 'Child dupa2 was successfully updated.') }
format.xml { head :ok }
else
format.html { ren... | [
"def update\n @child_dupa = ChildDupa.find(params[:id])\n\n respond_to do |format|\n if @child_dupa.update_attributes(params[:child_dupa])\n format.html { redirect_to(@child_dupa, :notice => 'Child dupa was successfully updated.') }\n format.xml { head :ok }\n else\n format.htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /child_dupa2s/1 DELETE /child_dupa2s/1.xml | def destroy
@child_dupa2 = ChildDupa2.find(params[:id])
@child_dupa2.destroy
respond_to do |format|
format.html { redirect_to(child_dupa2s_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @child_dupa = ChildDupa.find(params[:id])\n @child_dupa.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupas_url) }\n format.xml { head :ok }\n end\n end",
"def delete_child(child); end",
"def delete_all(xpath); end",
"def destroy\n @child = Chil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use hardcoded endpoint (default) AWS::SQS::Client.new(XXXXXXXXXXXXXX,XXXXXXXXXXXXXXXXXXXXX) Specify endpoint AWS::SQS::Client.new(XXXXXXXXXXXXXX,XXXXXXXXXXXXXXXXXXXXX, :endpoint => ' | def initialize( aws_access_key_id, aws_secret_access_key, options = {} )
@aws_access_key_id, @aws_secret_access_key = aws_access_key_id, aws_secret_access_key
opts = DEFAULT_SQS_OPTIONS.merge(options)
@endpoint = opts[:endpoint]
end | [
"def create_endpoint\n \"\"\n end",
"def sqs_client_config\n params = {\n region: options[:mq_aws_region],\n endpoint: options[:mq_aws_sqs_endpoint],\n access_key_id: options[:mq_aws_access_key_id],\n secret_access_key: options[:mq_aws_secret_access_key... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Same as +render_to_string+ but writes the processed template to +output_path+. | def render_to_file(output_path, context, properties = {})
File.open(output_path, 'wb') do |f|
f.write render_to_string(context, properties)
end
end | [
"def render(template, output = nil)\n result = ERB.new(File.read(template), 0, '-').result(binding)\n if !output.nil?\n File.open(output, \"w\") do |file|\n file.write(result)\n end\n else\n puts result\n end\n end",
"def render_template( templatefile, context,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
process the sablon xml template with the given +context+. IMPORTANT: Open Office does not ignore whitespace around tags. We need to render the xml without indent and whitespace. | def process(content, context, *args)
document = Nokogiri::XML(content)
Processor.process(document, context, *args).to_xml(indent: 0, save_with: 0)
end | [
"def render_process_variables_xml (variables)\n\n OpenWFE::Xml.to_xml(variables, :indent => 2)\n end",
"def render(context)\n @template.render(get_properties(context, @tag, @markup))\n end",
"def render(context)\n @template.render(get_properties(context, @tag, @markup, super))\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Terminate an instance by id | def terminate_instance!(id=nil)
raise RemoteException.new(:method_not_defined, "terminate_instance!")
end | [
"def destroy instance_id\n params = {\n \"InstanceId.1\" => instance_id\n }\n\n response = @client.action \"TerminateInstances\", params\n\n Response::Return.new response.body['TerminateInstancesResponse']\n end",
"def stop_instance(instance_id)\n instance_action :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get a list of the pending instances | def list_of_pending_instances(list = list_of_nonterminated_instances)
list.select {|a| a.pending? }
end | [
"def list_of_pending_instances(list = list_of_nonterminated_instances)\n list.select {|a| a[:status] =~ /pending/}\n end",
"def list_of_pending_instances(list = list_of_nonterminated_instances)\n list.select {|a| a if a.pending? }\n end",
"def not_created_instances\n pending_instances_cou... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
list of shutting down instances | def list_of_terminating_instances(list = remote_instances_list)
list.reject {|i| true if !i.terminating? }
end | [
"def list_of_terminating_instances(list = list_of_nonterminated_instances)\n list.select {|a| a[:status] =~ /shutting/}\n end",
"def list_of_terminating_instances(list = remote_instances_list)\n list.reject {|i| true if !i.terminating? }\n end",
"def request_termination_of_all_instances\n l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the instances that are nonmaster instances | def nonmaster_nonterminated_instances(list = list_of_nonterminated_instances)
list_of_nonterminated_instances.reject {|i| i.master? }
end | [
"def nonmaster_nonterminated_instances(list = list_of_nonterminated_instances)\n list_of_nonterminated_instances.reject {|i| i.master? }\n end",
"def active_instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving running instances\"\n []\n end",
"def instances\n Egi::Fedcloud... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
list all the nonterminated instances | def list_of_nonterminated_instances(list = remote_instances_list)
list.reject {|i| i.terminating? || i.terminated? }
end | [
"def list_of_nonterminated_instances(list = remote_instances_list)\n list.reject {|i| i.terminating? || i.terminated? }\n end",
"def list_of_nonterminated_instances(list = list_of_instances)\n list.reject {|a| a[:status] =~ /terminated/}\n end",
"def list_of_terminating_instances(list = list_of_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get instance by number | def get_instance_by_number(i=0, list = remote_instances_list)
name = (i.zero? ? "master" : "node#{i}")
list.select {|i| i.name == name }.first
end | [
"def get_instance_by_number(i=0, list = remote_instances_list) \n name = ((i.nil? || i.zero?) ? \"master\" : \"node#{i}\")\n list.select {|i| i.name == name }.first\n end",
"def get_instance(payload)\n NumberInstance.new(@version, payload, )\n end",
"def get_instance(pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List the instances for the current key pair, regardless of their states If no keypair is passed, select them all | def list_of_instances(keyp=nil)
key = keyp ? keyp : keypair
describe_instances.select {|a| key ? a[:keypair] == key : true } if describe_instances
end | [
"def list_of_instances(keypair = Application.keypair)\n get_instances_description.select {|a| a[:keypair] == keypair}\n end",
"def list_of_instances(keyp=nil)\n tmp_key = (keyp ? keyp : keypair).to_s\n unless @describe_instances\n tmpInstanceList = describe_instances.select {|a| a i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Instances Get the master from the cloud | def master
# remote_instances_list.select {|a| a.master }.first
@list = list_from_remote
@list.reject {|a| a unless a.name =~ /master/ }.first if @list.class != String
end | [
"def get_instances\n\t\t\t@cluster.getInstances()\n\t\tend",
"def instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving active instances\"\n fetch_instances\n end",
"def get_instances\n instances = [ ]\n get_clouds.each do |cloud|\n instances += cloud.instances.index(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Custom installation tasks Allow the remoter bases to attach their own tasks on the installation process | def custom_install_tasks_for(a=nil)
[]
end | [
"def default_install_tasks\n [\n \"#!/usr/bin/env sh\",\n upgrade_system,\n install_rubygems,\n make_logger_directory,\n install_puppet,\n fix_rubygems,\n custom_install_tasks\n ] << install_tasks\n end",
"def custom_install_tasks\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert command index : index to add the command command : command to add resize : resize flag to resize window | def insert_command(index, command, resize=true)
@commands.insert(index, command)
@item_max = @commands.size
refresh_command(resize)
end | [
"def create_command_window\n create_old_command\n create_new_viewport\n create_new_command\n create_press_start\n select_command\n end",
"def refresh_command(resize)\n if resize\n self.height = [self.height, row_max * WLH + 32].max\n end\n create_contents\n refresh\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove command command : command to remove resize : resize flag to resize window | def remove_command(command, resize=true)
@commands.delete(command)
@item_max = @commands.size
refresh_command(resize)
end | [
"def refresh_command(resize)\n if resize\n self.height = [self.height, row_max * WLH + 32].max\n end\n create_contents\n refresh\n end",
"def toggle_size\n w, h = Graphics.width, Graphics.height\n @tiny_window ? resize_window(w, h) : resize_window(w / 2, h / 2)\n @tiny_window = !@... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
////////////////////////////////////////////////////////////////////////// Private Methods ////////////////////////////////////////////////////////////////////////// Refresh command resize : resize flag to resize window | def refresh_command(resize)
if resize
self.height = [self.height, row_max * WLH + 32].max
end
create_contents
refresh
end | [
"def window_resize new_width, new_height\n end",
"def resize()\n\t\t@widget.pixbuf = choosePixbufState\n\t\treturn self\n\tend",
"def resize new_width, new_height\n win.resize new_width, new_height\n end",
"def resize width, height\n @widgets[@index].width = width\n @widgets[@index].h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ask question with using return to exit the loop and removing answer variable | def ASK question
while true
puts question
reply = gets.chomp.downcase
if reply == "yes"
return true
end
if reply == "no"
return false
end
puts "Please answer yes or no !"
end
end | [
"def ask(question)\n loop do\n puts question\n answer = gets.chomp\n\n return 'We can be friends!' if answer == 'y' || answer == 'yes'\n return 'Get out of my sight!' if answer == 'n' || answer == 'no'\n\n puts 'Try again'\n end\nend",
"def ask(question)\n loop do\n puts question # outputting... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
client.abandon_results! When using MULTI_STATEMENTS support, calling this will throw away any unprocessed results as fast as it can in order to put the connection back into a state where queries can be issued again. | def abandon_results!()
#This is a stub, used for indexing
end | [
"def discard_results\n self.current.discard = true if current\n end",
"def discard_results; end",
"def cancel_all\n @queries.each do |query|\n cancel_query(query)\n end\n @queries.clear\n end",
"def clear_result; end",
"def abandon\n send \"<abandon/>\"\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
client.async_result Returns the result for the last async issued query. | def async_result()
#This is a stub, used for indexing
end | [
"def async_result(url:)\n AsyncResult.new(url: url)\n end",
"def get_last_result( )\n #This is a stub, used for indexing\n end",
"def result\n wait_for\n # If the task threw an exception during execution we raise that here.\n @task_error ? raise(@task_error) : @t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
client.select_db(name) Causes the database specified by +name+ to become the default (current) database on the connection specified by mysql. | def select_db(name)
#This is a stub, used for indexing
end | [
"def db_select name, create=false\n orig_select 0\n if hexists 'ReDBis::databases', name\n @dbid, @dbname = hget('ReDBis::databases', name), name\n orig_select @dbid\n elsif !create\n orig_select @dbid # go back\n raise \"Unknown database name '#{name}'!\"\n else # re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
client.more_results? Returns true or false if there are more results to process. | def more_results?()
#This is a stub, used for indexing
end | [
"def has_more_results?\n\t\treturn true unless self.done_paging?\n\tend",
"def more_results_available\n return @more_results_available\n end",
"def more_after_limit?\n more_results == :MORE_RESULTS_AFTER_LIMIT\n end",
"def more_after_limit?\n more_results... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
client.next_result Fetch the next result set from the server. Returns nothing. | def next_result()
#This is a stub, used for indexing
end | [
"def nextResults\n # Update results\n updateResults(@nextURI)\n\n # Update nextURI\n updateNextURI\n end",
"def next\n block_start if !@block_started\n return @yielder.get_result\n end",
"def next\n @options[:start] = @options[:start] + @options[:results]\n @options[:results] =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Last chance to put things into the Makefile | def makefile_hook(makefile)
# STUB
end | [
"def pre_install; end",
"def setup\n add_pub_key\n set_git\n set_www_dir\n\n puts \"\\nCreate essential files...\"\n \n if not File.exists? \"#{@home}/.bashrc\"\n `touch #{@home}/.bashrc`\n `sudo rm /root/.bashrc`\n `sudo ln -s #{@home}/.bashrc /root/.bashrc`\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Configure the server's SSLContext to require a client certificate. The `client_ca` setting allows the server to advertise which client CAs it will accept. | def require_client_certs(ctx)
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
ctx.client_ca = [cert_fixture('ca.pem')]
end | [
"def client_tls_certificate_ca\n @client_tls_certificate_ca || ENV['CLIENT_TLS_CERTIFICATE_CA']\n end",
"def set_ssl_client_certificate(opts)\n opts = check_params(opts,[:certificates])\n super(opts)\n end",
"def set_client_certificate_ca_file(opts)\n opts = check_params(opts,[:client_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
new_maildir Recursively create directories for a new Maildir mail store. | def new_maildir(target, source, name)
x = name.sub(/Messages$/, "").sub(/\.mbox\/?.*/, "")
x = x.sub(Regexp.new(source), "").sub(/^\//, "")
d = ""
x.split("/").each do |comp|
d << "/" + comp.delete(" ")
unless FileTest.directory?(target + "/" + d)
FileUtils.mkdir(target + "/" + d)
end
end
... | [
"def setup_directories\n require 'fileutils'\n\n path = File.join(homedir, maildir)\n create_maildir path\n create_maildir File.join(path, '.Trash')\n create_maildir File.join(path, '.Sent')\n create_maildir File.join(path, '.Drafts')\n create_maildir File.join(path, '.Spam')\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set? Test a number against a bitmask to see if bits are set or cleared. | def set?(num, mask)
(num & mask) != 0
end | [
"def bit_set? num, bit\n (num >> bit) % 2 == 1\n end",
"def bit_set?(p0) end",
"def set?(bit)\n false\n end",
"def constraint_match? bitmask, bit\n bitmask.nil? || bitmask == 0 || bit_set?(bitmask, bit)\n end",
"def checkBitSet( i, bitfield )\n bitfield & (1<<i)\n end",
"def se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Got this off of jwz's blog in reference to what the bits in the flags parameter in Mail.app message files mean Update: An anonymous benefactor has the goods: 0 read 1 Also, see for information on how to formulate a proper Maildir file name. maildirname Create a proper Maildir filename for this message. | def maildirname(deliveries, flags)
s = ""
s << Time.now.to_i.to_s
s << "."
s << "P" + Process.pid.to_s
s << "Q" + deliveries.to_s
s << "R" + rand(2147483648).to_s
s << "."
s << Socket.gethostname.sub(/\//, "\\057").sub(/:/, "\\072")
# if this is a new message, we don't add the third part of the
# f... | [
"def set_read\n if self.is_new_mail?\n File.mv(\"#{NEW_FOLDER}/#{self.file_name}\", \"#{CUR_FOLDER}/#{self.file_name}:2,S\")\n end\n end",
"def ftp_notification(message, ftp_notification)\n\n design_review = ftp_notification.design.get_design_review(\"Final\")\n\n to_list = MailerMethods.r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Shows Moneydance IRB console, starts new one if necessary. Moneydance URI: moneydance:fmodule:ruby:irb | def irb
if @console
@console.show
else
# We need to address compiled RubyConsole via full java name... Why?
@console ||= com.moneydance.modules.features.ruby.rb.RubyConsole.new self
end
end | [
"def console\n system \"irb -I #{File.dirname(__FILE__)} -r biotcm -r irb/completion --simple-prompt\"\n end",
"def console\n if RUBY_PLATFORM =~ /mswin32/\n irb_name = \"irb.bat\"\n else\n irb_name = 'RUBYOPT=\"-rubygems -Ilib\"; irb'\n end\n\n if f = application_file\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parse actual student id from University of Helsinki's format: urn:mace:terena.org:schac:personalUniqueCode:int:studentID:helsinki.fi:165934 Returns the number value of the last URN attribute: raw "urn:schac:personalUniqueCode:fi:yliopisto.fi:x8734" will return: "x8734" Student number may be a multivalue array such as "... | def parse_student_number(raw)
value = nil
if raw.is_a?(Array)
raw.each do |v|
value = v if v.starts_with?(Vaalit::Haka::HAKA_STUDENT_NUMBER_KEY)
end
elsif raw.is_a?(String)
if raw.starts_with?(Vaalit::Haka::HAKA_STUDENT_NUMBER_KEY)
value = raw
else
Rails.logg... | [
"def parse_student_number(raw)\n if raw.blank?\n errors.add :student_number, \"SAML student number value missing\"\n return nil\n end\n\n value = nil\n\n if raw.is_a?(Array)\n value = parse_student_number_from_array(raw)\n elsif raw.is_a?(String)\n value = parse_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /feedstocks/1 GET /feedstocks/1.json | def show
@feedstock = Feedstock.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @feedstock }
end
end | [
"def show\n @feedstock_stock = FeedstockStock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feedstock_stock }\n end\n end",
"def index\n @stocks = Stock.all\n json_response(@stocks)\n end",
"def index\n @stocks = Stock.all\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /feedstocks/new GET /feedstocks/new.json | def new
@feedstock = Feedstock.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @feedstock }
end
end | [
"def new\n @feedstock_stock = FeedstockStock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feedstock_stock }\n end\n end",
"def new\n @stock = Stock.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /feedstocks POST /feedstocks.json | def create
@feedstock = Feedstock.new(params[:feedstock])
respond_to do |format|
if @feedstock.save
format.html { redirect_to @feedstock, notice: 'Estoque criado.' }
format.json { render json: @feedstock, status: :created, location: @feedstock }
else
format.html { render act... | [
"def create\n \n params[:feedstock].each do |f|\n if (f[:feedstock_id] && f[:quantity] != \"\")\n feedstock = FeedstockByProduct.new\n feedstock.product_id = params[:product_id]\n feedstock.feedstock_id = f[:feedstock_id]\n feedstock.quantity = f[:quantity]\n feedstock.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /feedstocks/1 PUT /feedstocks/1.json | def update
@feedstock = Feedstock.find(params[:id])
respond_to do |format|
if @feedstock.update_attributes(params[:feedstock])
format.html { redirect_to @feedstock, notice: 'Estoque atualizado.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
... | [
"def update\n @stock = Stock.find(params[:id])\n\n if @stock.update(stock_params)\n head :no_content\n else\n render json: @stock.errors, status: :unprocessable_entity\n end\n end",
"def update\n render json: @stock.errors unless @stock.update(stock_params)\n end",
"def update\n @s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /feedstocks/1 DELETE /feedstocks/1.json | def destroy
@feedstock = Feedstock.find(params[:id])
@feedstock.destroy
respond_to do |format|
format.html { redirect_to feedstocks_url }
format.json { head :no_content }
end
end | [
"def destroy\n @feedstock_stock = FeedstockStock.find(params[:id])\n @feedstock_stock.destroy\n\n respond_to do |format|\n format.html { redirect_to feedstock_stocks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock.destroy\n respond_to do |format|\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return string at index | def [](index)
to_s[index]
end | [
"def character_at(text, index)\n return text[index]\nend",
"def [](i)\n super :get_string, i\n end",
"def subject_string_by_index(index)\n\t\tcase index\n\t\t\twhen 0\n\t\t\t\treturn \"ma\"\n\t\t\twhen 1\n\t\t\t\treturn \"sc\"\n\t\t\twhen 2\n\t\t\t\treturn \"ss\"\n\t\t\twhen 3\n\t\t\t\treturn \"la\"\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds and loads mutations | def load_mutation(attrs)
type = attrs.fetch('type')
raise "Mutation type invalid: #{type}" unless /\A[a-z_]+\Z/.match(type)
require "data_generator/mutation/#{type}"
"DataGenerator::Mutation::#{type.camelize}".constantize.new(attrs)
end | [
"def changes_to_save\n mutations_from_database.changes\n end",
"def mutations(create: true, copy: true, update: true, destroy: true)\n scoped_self = self\n if create\n mutation_klasses[\"create_#{graphql_name.underscore}\"] = build_create\n # new_resource query ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The allimportant method that takes our animation and turns it into a series of canvases | def rasterise
@frames.each do |frame|
printf '.';
canvas = Canvas.new(@width, @height);
@canvases.push(canvas);
if frame.pixmaps.length == 0 then next; end;
frame.pixmaps.each do |pixmap|
img = pixmap.sprite.getImage(pixmap.frame);
... | [
"def update_animation\n @frame_count = (@frame_count + 1) % @frame_interval\n if @frame_count == 0\n @frame = (@frame + 1) % 3\n if @frame > 2\n @layers[0].bitmap = @layer_bitmaps[1]#.clone\n else\n @layers[0].bitmap = @layer_bitmaps[@frame]#.clone\n end \n end \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Load a series of sprites from a file | def loadSprites(filename)
lines = [];
sprite = nil;
IO.foreach(filename) do |line|
line.chomp!
if line =~ /^(\w+):/ then
# We've named a new sprite
if lines.length > 0 then
# We've finished a sprite
sprite.addIm... | [
"def load_sprites\n\n # And the start button\n @button_sprite = TintedSprite.new(w: 256, h: 64, path: 'adrift/sprites/start.png')\n @button_sprite.movable_location((@args.grid.center_x - 128), 350)\n @button_sprite.colourable_cycle(\n [\n [255, 255, 255, 255],\n [128, 12... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves the pagination "per_page" attribute for a given element (passed in as a prefix uniq identifyer) | def get_per_page(prefix="")
(@search_params[prefix + "per_page"] || 10).to_i
end | [
"def per_page_param\n :per_page\n end",
"def pagination\n element_text 'Pagination'\n end",
"def per_page\n @per_page ||= if (v = env[\"PER_PAGE\"])\n Integer(v)\n else\n 1000\n end\n end",
"def per_page; @opts['per_page']; end",
"def item_page\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a Location Object based on the zip code entered. | def initialize(zip = DEFAULT_ZIP)
address = (!Geocoder.search(zip).empty? ? Geocoder.search(zip) : Geocoder.search(DEFAULT_ZIP))
@city = address[0].data["standard"]["city"]
@state = address[0].data["standard"]["prov"]
@zip = address[0].data["standard"]["postal"]
@confidence = address[0].data["standard"]["c... | [
"def create\n @zip_loc = ZipLoc.new(params[:zip_loc])\n\n respond_to do |format|\n if @zip_loc.save\n format.html { redirect_to admin_zip_loc_path(@zip_loc), notice: 'Zip loc was successfully created.' }\n format.json { render json: @zip_loc, status: :created, location: @zip_loc }\n el... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if the AMI is bootstrapped | def ami_bootstrapped?
version = ''
bootstrapped_file = '/opt/parallelcluster/.bootstrapped'
current_version = "aws-parallelcluster-cookbook-#{node['cluster']['parallelcluster-cookbook-version']}"
if ::File.exist?(bootstrapped_file)
version = IO.read(bootstrapped_file).chomp
Chef::Log.info("Detected boo... | [
"def bootstrapped?\n # @bootstrapped ||= !run('if [ -f /var/poolparty/bootstrapped ]; then echo \"YES\"; fi').match(/YES/).nil?\n @bootstrapped ||= !run('if [ -f /var/poolparty/bootstrapped ]; then echo \"YES\"; fi').chomp.empty? || false\n end",
"def ami_bootstrapped?\n version = ''\n bootst... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Version bulk_exports of preview | def bulk_exports
@bulk_exports ||= BulkExports.new self
end | [
"def bulkexports; end",
"def edit_exports\r\n delete_list\r\n export_edits = delete_export\r\n end",
"def export\n\n end",
"def pre_export\n end",
"def index\r\n params[:page] = params[:page].blank? ? 1 : params[:page]\r\n @exports = current_admin.exports.page(params[:page]).per(20)\r\n\r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Version hosted_numbers of preview | def hosted_numbers
@hosted_numbers ||= HostedNumbers.new self
end | [
"def hosted_numbers; end",
"def url_desktop_revisions\n\t\t\t@data[\"content_urls\"][\"desktop\"][\"revision\"]\n\t\tend",
"def cache_version\n if Page.current_preview == id\n updated_at.to_s\n else\n published_at.to_s\n end\n end",
"def previews\n @previews ||= ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /quality_histories GET /quality_histories.json | def index
qualities_viewed = QualityHistory.where(:user_id => current_user.id, :action_type => 'view').group(:quality_id)
@quality_histories = qualities_viewed.page(params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @quality_histories }
format.js... | [
"def show\n @quality_history = QualityHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quality_history }\n end\n end",
"def index\n @housing_qualities = HousingQuality.all\n end",
"def index\n @histories = History.all\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /quality_histories/1 GET /quality_histories/1.json | def show
@quality_history = QualityHistory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @quality_history }
end
end | [
"def index\n @histories = History.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @histories }\n end\n end",
"def new\n @quality_history = QualityHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /quality_histories/new GET /quality_histories/new.json | def new
@quality_history = QualityHistory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @quality_history }
end
end | [
"def create\n @quality_history = QualityHistory.new(params[:quality_history])\n\n respond_to do |format|\n if @quality_history.save\n format.html { redirect_to @quality_history, notice: 'Quality history was successfully created.' }\n format.json { render json: @quality_history, status: :cre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /quality_histories POST /quality_histories.json | def create
@quality_history = QualityHistory.new(params[:quality_history])
respond_to do |format|
if @quality_history.save
format.html { redirect_to @quality_history, notice: 'Quality history was successfully created.' }
format.json { render json: @quality_history, status: :created, locat... | [
"def create\n @quality_history = QualityHistory.new(quality_history_params)\n\n respond_to do |format|\n if @quality_history.save\n format.html { redirect_to @quality_history, notice: 'Quality history was successfully created.' }\n format.json { render json: @quality_history, status: :creat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /quality_histories/1 PUT /quality_histories/1.json | def update
@quality_history = QualityHistory.find(params[:id])
respond_to do |format|
if @quality_history.update_attributes(params[:quality_history])
format.html { redirect_to @quality_history, notice: 'Quality history was successfully updated.' }
format.json { head :no_content }
el... | [
"def update\n @quality_history = QualityHistory.find(params[:id])\n\n respond_to do |format|\n if @quality_history.update_attributes(quality_history_params)\n format.html { redirect_to @quality_history, notice: 'Quality history was successfully updated.' }\n format.json { head :no_content }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /quality_histories/1 DELETE /quality_histories/1.json | def destroy
@quality_history = QualityHistory.find(params[:id])
@quality_history.destroy
respond_to do |format|
format.html { redirect_to quality_histories_url }
format.json { head :no_content }
end
end | [
"def destroy\n @pur_hist = PurHist.find(params[:id])\n @pur_hist.destroy\n\n respond_to do |format|\n format.html { redirect_to pur_hists_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @harajs_history = HarajsHistory.find(params[:id])\n @harajs_history.destroy\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Minimum and maximum values in a tree All minimum values are in the left side of the tree All maximum values are in the right side of the tree def find_minimum | def find_minimum
current = @root
while current.left && !current.nil?
current = current.left
return current.value if current.left.nil?
end
end | [
"def s_min\n return nil if @root.nil?\n\n current_node = @root\n current_node = current_node.left until current_node.left.nil?\n current_node.value\n end",
"def min\n val = min_node(@root).data if @root\n val\n end",
"def minimum_value(node)\n node = node.left until node.left.nil?\n no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /microplsts/1 GET /microplsts/1.json | def show
@microplst = Microplst.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @microplst }
end
end | [
"def show\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microposst }\n end\n end",
"def show\n @microposr = Microposr.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /microplsts/new GET /microplsts/new.json | def new
@microplst = Microplst.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @microplst }
end
end | [
"def create\n @microplst = Microplst.new(params[:microplst])\n\n respond_to do |format|\n if @microplst.save\n format.html { redirect_to @microplst, notice: 'Microplst was successfully created.' }\n format.json { render json: @microplst, status: :created, location: @microplst }\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /microplsts POST /microplsts.json | def create
@microplst = Microplst.new(params[:microplst])
respond_to do |format|
if @microplst.save
format.html { redirect_to @microplst, notice: 'Microplst was successfully created.' }
format.json { render json: @microplst, status: :created, location: @microplst }
else
form... | [
"def create\n @microposst = Microposst.new(params[:microposst])\n\n respond_to do |format|\n if @microposst.save\n format.html { redirect_to @microposst, notice: 'Microposst was successfully created.' }\n format.json { render json: @microposst, status: :created, location: @microposst }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /microplsts/1 PUT /microplsts/1.json | def update
@microplst = Microplst.find(params[:id])
respond_to do |format|
if @microplst.update_attributes(params[:microplst])
format.html { redirect_to @microplst, notice: 'Microplst was successfully updated.' }
format.json { head :no_content }
else
format.html { render act... | [
"def update\n @microposst = Microposst.find(params[:id])\n\n respond_to do |format|\n if @microposst.update_attributes(params[:microposst])\n format.html { redirect_to @microposst, notice: 'Microposst was successfully updated.' }\n format.json { head :no_content }\n else\n forma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /microplsts/1 DELETE /microplsts/1.json | def destroy
@microplst = Microplst.find(params[:id])
@microplst.destroy
respond_to do |format|
format.html { redirect_to microplsts_url }
format.json { head :no_content }
end
end | [
"def destroy\n @microposst = Microposst.find(params[:id])\n @microposst.destroy\n\n respond_to do |format|\n format.html { redirect_to micropossts_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /program_roles GET /program_roles.json | def index
@program_roles = ProgramRole.all
end | [
"def list\n get('roles')['roles']\n end",
"def get_user_roles\n @roles = @user.roles.pluck(:name)\n render json: @roles\n end",
"def roles\n self.dig_for_array(\"roles\")\n end",
"def get_external_roles\n get(\"#{url_base}/external_role_map/all?#{dc}\")[\"data\"]\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /program_roles/1 DELETE /program_roles/1.json | def destroy
@program_role.destroy
respond_to do |format|
format.html { redirect_to program_roles_url, notice: 'Program role was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete(id)\n request(:delete, \"/roles/#{id}.json\")\n end",
"def delete_roles\n delete(roles_path)\n end",
"def destroy\n @app_role = AppRole.find(params[:id])\n @app_role.destroy\n\n respond_to do |format|\n format.html { redirect_to app_roles_url }\n format.jso... | {
"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.