query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Check if the pwd is zup enabled | def zup_dir_enabled?
if File.exist?('.zup/enabled')
return true
else
return false
end
end | [
"def zypper?\n File.executable? '/usr/bin/zypper'\n end",
"def upstart?\n file_exist?(\"/sbin/initctl\")\n end",
"def is_stub?\n htpasswd.blank?\n end",
"def password?\n FileTest.exist? Puppet[:capass]\n end",
"def password?\n FileTest.exist? Puppet[:capass]\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run unison to sync with remote host if enabled | def sync_zup_dir
if zup_dir_enabled?
local_dir = File.basename(Dir.pwd)
# Output the full unison command if debugging enabled
puts($SYNC_COMMAND + ' . ' + @conf['protocol'] + '://' \
+ @conf['server'] + '/' + @conf['remote_dir'] + '/' \
+ local_dir) if $ZUP_DEBUG
# Run un... | [
"def sync\n # preparation\n check_remote_path_valid\n check_git_repo\n reset_remote_repo\n\n diff_text = local_diff\n apply_diff_to_remote diff_text\n\n # output = @ssh.exec! 'hostname'\n # puts output\n end",
"def exec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tacks the registry behind local_tag | def full_tag(local_tag, registry)
"#{registry}/#{local_tag}"
end | [
"def tag\n @local.tag\n end",
"def register_tags_holder\n @tags_holder_stack.push(TagsHolder.new)\n end",
"def prepare_registry; end",
"def resolve_tagged(tag)\n @container.resolve_tagged tag\n end",
"def local_tags\n @local.tags\n end",
"def current_tags=(_arg0... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate the SHA256 of the concatenated content of the given list of files after line endings have been stripped | def sha256(files)
sha = Digest::SHA2.new
files.each do |f|
next if File.directory?(f)
content = File.binread(f)
# work around possible git checkout issues by removing CR and LF from the file
content.gsub!("\n", "")
content.gsub!("\r", "")
sha << content
end
sha.hexdi... | [
"def checksum_for(*filenames)\n filenames.flatten.map do |filename|\n digest = Digest::SHA2.new\n File.open(filename, 'r') do |io|\n until io.eof\n data = io.readpartial(2**10)\n digest.update(data)\n end\n end\n digest.hexdigest\n end.jo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the value of key and delete the key. This command is similar to GET, except for the fact that it also deletes the key on success. | def getdel(key)
send_command([:getdel, key])
end | [
"def delete(key)\n perform_delete(:delete, key)\n end",
"def delete\n redis.del key\n end",
"def delete(key)\n return Nvmkv::kv_delete(@kv_id, @pool_id, key)\n end",
"def delete(key)\n attribute = key.to_sym\n results.delete(attribute)\n end",
"def delete(key)\n o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The Nth group of the last regexp match. | def nth_ref(n)
if lm = last_match()
return lm[n]
end
return nil
end | [
"def nth_ref(n)\n if lm = @last_match\n return lm[n]\n end\n\n return nil\n end",
"def last_match(index = nil)\n if index\n @@last_match[index]\n else\n @@last_match\n end\n end",
"def group_rindex( regexp, offset = length )\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /clubs/1/join POST /clubs/1/join.json | def join
@club = Club.find(params[:id])
authorize @club
@club.club_memberships.create! user_id: current_user.id
redirect_to action: :show
end | [
"def join\n if user_signed_in?\n # Attempt to grab their membership\n membership = @club.memberships.find_by(user_id: current_user.id)\n if membership\n # User is already a member\n redirect_to @club, notice: 'You are already a member.'\n else\n # Add their membership\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
These defs are made to determine the amount of CP a character needs to level up and if they did level up how much CP they will need for their next level. | def CP(level)
cpNeeded = 0
if level > 0 && level <= 5
cpNeeded + 4
elsif level > 5 && level <= 20
cpNeeded + 8
else
cpNeeded + 0
end
end | [
"def CP(level)\n cpNeeded = 0\n if level > 0 && level <= 5\n cpNeeded + 4\n elsif level > 5 && level <= 20\n cpNeeded + 8\n else\n cpNeeded + 0\n end\n end",
"def get_cr_or_level(num_of_pcs, cr_or_level)\n if num_of_pcs <= 4\n @cr = cr_or_level\n elsif num_of_pcs == 5\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equip Set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def maesb_generate_equip_set
@maesb_belongs_to_sets = []
end | [
"def maesb_generate_equipment_sets\n # Generate Equipment Sets\n ($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }\n # Update items to refer to the set to which they belong\n set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }\n set_items.e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Generate Equipment Sets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | def maesb_generate_equipment_sets
# Generate Equipment Sets
($data_weapons + $data_armors).compact.each { |equip| equip.maesb_generate_equip_set }
# Update items to refer to the set to which they belong
set_items = $data_armors.compact.select {|armor| !armor.maesb_sets.empty? }
set_items.each { |set... | [
"def maesb_generate_equip_set\n @maesb_belongs_to_sets = []\n end",
"def create_permutations\n if @item_sets.length == 1\n SetCreator.create_doubletons(@item_sets.first)\n else\n SetCreator.create_permutations(@item_sets[-1], @item_sets.first)\n end\n end",
"def make_demo_abilities\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if a particular concern exists | def exists? concern
mapper.instance_variable_get('@concerns').include?(concern)
end | [
"def existential?\n @existential\n end",
"def commission_setup?\n %w{agent_commission sales_commission}.inject(true) { |m,e| !self.send(e.intern).nil? }\n end",
"def needs_housing?\n if self.exhibitor? and self.exhibitor_housing == 'on_campus'\n return true\n elsif !self.exhibitor? and se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the `:last_accessed_at` to current time. | def update_limitable_access_at(token_or_object)
record = extract_object_from_options(token_or_object)
record.last_accessed_at = Time.current
record.save(validate: false)
end | [
"def update_access_time\n if current_user\n current_user.update_attribute(:last_accessed_at, Time.now)\n end\n end",
"def last_accessed_time=(value)\n @last_accessed_time = value\n end",
"def set_users_last_access\n if current_user\n current_user.update_attributes(:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Expire session matching the +token_or_object+. | def expire_session_limit(token_or_object)
object = extract_object_from_options(token_or_object)
object && session_limitable_adapter.destroy(object)
end | [
"def expire_session_token(token)\n record = find_traceable_by_token(token)\n return unless record\n record.unique_auth_token_valid = false\n record.save(validate: false)\n end",
"def end_session\n check_access_token\n RedisSessions.redis_connection.delete_access_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /work_orders or /work_orders.json | def create
@work_order = WorkOrder.new(work_order_params)
respond_to do |format|
if @work_order.save
format.html { redirect_to @work_order, notice: "Work order was successfully created." }
format.json { render :show, status: :created, location: @work_order }
else
format.html... | [
"def api_work_orders\n @work_orders = WorkOrder.order(:order_no)\n render json: @work_orders\n end",
"def create\n @work_order = WorkOrder.new(params[:work_order])\n\n respond_to do |format|\n if @work_order.save\n format.html { redirect_to @work_order, notice: 'Work order was succe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /work_orders/1 or /work_orders/1.json | def update
respond_to do |format|
if @work_order.update(work_order_params)
format.html { redirect_to @work_order, notice: "Work order was successfully updated." }
format.json { render :show, status: :ok, location: @work_order }
else
format.html { render :edit, status: :unprocessa... | [
"def update\n @work_order = WorkOrder.find(params[:id])\n\n respond_to do |format|\n if @work_order.update_attributes(params[:work_order])\n format.html { redirect_to @work_order, notice: 'Work order was successfully updated.' }\n format.json { head :no_content }\n else\n format... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Unloads the given classes from CLI::UI, reloads them and stubs the OS to the given one. This is used to run tests on classes with variables that depend on the OS (e.g. Glyph), so that we can mock their state in the context of this block. | def with_os_mock_and_reload(os, class_names = [], files = [])
class_names = Array(class_names)
files = Array(files)
CLI::UI::OS.stubs(:current).returns(os)
class_names.each { |classname| CLI::UI.send(:remove_const, classname) }
files.each { |file| load(file) }
yield
ensure
CLI::UI::OS.unstub(:current)
... | [
"def reload_classes\n klasses = [:Inject]\n\n # unload classes\n Object.class_eval do\n klasses.each do |klass|\n remove_const klass.to_s if const_defined? klass.to_s\n end\n end\n\n # reload classes\n klasses.each do |klass|\n load \"#{klass.to_s.underscore}.rb\"\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /item_rankings GET /item_rankings.json | def index
@item_rankings = ItemRanking.all
end | [
"def ranking(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/IchibaItem/Ranking/20120927\", Rakuten::Api.merge(opts))\r\n end",
"def get_ranks options\n make_request :get, APPS_URL, :ranks, options, [:action, :pn]\n end",
"def get_event_rankings ( event_key )\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /item_rankings POST /item_rankings.json | def create
@item_ranking = ItemRanking.new(item_ranking_params)
respond_to do |format|
if @item_ranking.save
format.html { redirect_to @item_ranking, notice: 'Item ranking was successfully created.' }
format.json { render :show, status: :created, location: @item_ranking }
else
... | [
"def index\n @item_rankings = ItemRanking.all\n end",
"def update\n respond_to do |format|\n if @item_ranking.update(item_ranking_params)\n format.html { redirect_to @item_ranking, notice: 'Item ranking was successfully updated.' }\n format.json { render :show, status: :ok, location: @it... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /item_rankings/1 PATCH/PUT /item_rankings/1.json | def update
respond_to do |format|
if @item_ranking.update(item_ranking_params)
format.html { redirect_to @item_ranking, notice: 'Item ranking was successfully updated.' }
format.json { render :show, status: :ok, location: @item_ranking }
else
format.html { render :edit }
... | [
"def update\n @rankings = Rankings.find(params[:id])\n\n respond_to do |format|\n if @rankings.update_attributes(params[:rankings])\n flash[:notice] = 'Rankings was successfully updated.'\n format.html { redirect_to(@rankings) }\n format.xml { head :ok }\n else\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /item_rankings/1 DELETE /item_rankings/1.json | def destroy
@item_ranking.destroy
respond_to do |format|
format.html { redirect_to item_rankings_url, notice: 'Item ranking was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @rank = Rank.find(params[:id])\n @rank.destroy\n\n respond_to do |format|\n format.html { redirect_to ranks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rankings = Rankings.find(params[:id])\n @rankings.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This allows us to support IE89 and their shimmed pseudoCORS support. This parses the post body as form data, even if the contenttype is text/plain or unknown. The issue is that IE89 will send POST data with an empty ContentType (see: Some Rails servers (Passenger) will treat this as nil, in which case Rack parses the p... | def parse_post_for_pseudo_ie_cors
if(request.post? && request.POST.blank? && request.raw_post.present?)
params.merge!(Rack::Utils.parse_nested_query(request.raw_post))
end
end | [
"def parse_form_data(io, boundary); end",
"def parseBody\n if header?(\"content-type\") == \"application/x-www-form-urlencoded\"\n body.split(\"&\").each do |var|\n vals = var.split(\"=\")\n @post[vals[0]] = vals[1]\n end\n end\n end",
"def decode_as_multipart_form_data( boundary ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def index ar_friendships = current_user.friendships.where(status: 'accepted') friendships = ar_friendships.map do |ar_friend| friend = User.find( ar_friend.friend_id ) data = ar_friend.as_json data['friend_name'] = friend.username data end render json: friendships end | def index
@user = current_user
render json: @user.friends
end | [
"def index\n @friendships = current_friend.friendships.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @friendships }\n end\n end",
"def index\n @friendships = @user.friendships\n\n respond_to do |format|\n format.html # index.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
3. Create a method to see if a particular item (string) is in the zombie_apocalypse_supplies. Do not use any special builtin methods. For instance: are boots in your list of supplies? | def in_supplies?(string, supplies)
supplies.each do |item|
return true if item == string
end
false
end | [
"def on_list(search_item)\n\n zombie_apocalypse_supplies = [\"hatchet\", \"rations\", \"water jug\", \"binoculars\",\n \"shotgun\", \"compass\", \"CB radio\", \"batteries\"]\n item_included = false\n\n zombie_apocalypse_supplies.each do |supply|\n if supply == search_item\n item_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
4. You've heard that the following animals might be extinct, but you're not sure. Check if they're included in extinct_animals, one by one: "Andean Cat" "Dodo" "Saiga Antelope" Do not use any special builtin methods. | def check_extinct(animal, extinct_list)
if extinct_list[animal]
puts "#{animal} is extinct"
else
puts "#{animal} is not extinct"
end
end | [
"def in_extinct_animals(animal, extinct_animals)\n in_extinct = false\n extinct_animals.each do |extinct_animal, extinct_year|\n if(extinct_animal.downcase == animal.downcase)\n in_extinct = true\n end\n end\n return in_extinct\nend",
"def is_extinct_animal(animal)\n extinct_animals = {\n \"Tasma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Colorize the time in red if the bus leaves in 10 or less minutes | def departure_time
text = @transit_details['departure_time']['text']
if @transit_details['departure_time']['value'].to_i - Time.now.to_i <= 600
text.colorize(:red)
else
text
end
end | [
"def format_time( time, expected = 30 )\n timef = time.uncolorize.to_f\n case\n when timef > expected * 2 then time.to_s.uncolorize.red\n when timef > expected then time.to_s.uncolorize.yellow\n else time\n end\n end",
"def colorize(time_line)\n time_line, future = split_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Duplicate underlying table when OpenStruct is duplicated or cloned. | def initialize_copy(original)
super
@table = @table.dup
end | [
"def duplicate\n dup.tap do |c|\n c.page = nil\n columns.each do |column|\n c.columns << column.duplicate\n end\n pictures.each do |picture|\n c.pictures << picture.duplicate\n end\n end\n end",
"def copy \n t = @tab.clone ;\n for i in 0..3\n t[i] = t[i].cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
format = '"Text with yyyy/mm/dd"yyyy[aa.bb][cc.dd.ee][ff]mmdd"Text with [aa.bb]"[]' format_parts(format) => [ '"Text with yyyy/mm/dd"', 'yyyy', '[aa.bb]', '[cc.dd.ee][ff]mmdd', '"Text with [aa.bb]"', '[', '', ']' ] | def format_parts(format)
# Separate format to array
formats = []
split_formats = format.split(/"/)
split_formats.each_with_index do |sf, i|
sf = %("#{sf}") if i % 2 == 1
formats << sf
end
formats.collect! do |f|
if f =~ /"/
f
... | [
"def get_format_from_pieces(pieces, format_list)\n format = nil\n pieces.reverse.each do |piece|\n if ActionView::PathResolver::EXTENSIONS.is_a?(Hash) &&\n ActionView::PathResolver::EXTENSIONS.include?(:variants)\n piece = piece.split(ActionView::PathResolver::EXTENSIONS[:variants], 2).fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
CustomFields::AutoNumbering.increase(Integer) > String Get the next string CustomFields::AutoNumbering.increase(custom_field_id) => 10Text15120143 | def increase(custom_field_id, cells)
ActiveRecord::Base.transaction do
custom_field = CustomFields::AutoNumbering.find(custom_field_id)
if self.unset_cells(custom_field, cells).empty?
value = format_value(custom_field, cells)
key_hash = AutoNumberRunning.k... | [
"def bump_custom_fields_counter(name)\n counter = self.send(:\"#{name}_custom_fields_counter\") || 0\n self.send(:\"#{name}_custom_fields_counter=\", counter + 1)\n end",
"def inc(field, value=1)\n operate :inc, field => value\n retrieve(field)[field]\n end",
"def auto_numb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
custom_field.format_key > string Get format key custom_field.format_key => "yymmdd" | def format_key
formats = CustomFields::AutoNumbering.format_parts(self.format)
formats.select{|f| (f =~ /("|#)/).nil? }.join('-')
end | [
"def key_format(field)\n @formatted_key[field] ||= JSONAPI.configuration\n .key_formatter\n .format(resource_key_for(field))\n .to_sym\n end",
"def date_format_registry_key\n return :date_format\n end",
"def default_key_format(key)\n key\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cutom_field.reference_custom_field_ids > an array Get reference custom field ids custom_field.reference_custom_field_ids => [10,11,12,13] | def reference_custom_field_ids
self[:value] ||= {}
self[:value][:custom_field_ids] ||= []
@custom_field_ids ||= self[:value][:custom_field_ids].collect{|cf_id| cf_id.to_i if CustomField.exists?(cf_id) }.compact
end | [
"def reference_custom_field_ids\n reference_custom_fields.collect{|cf| cf.id }\n end",
"def reference_custom_fields\n @reference_custom_field_ids ||= []\n \n if @reference_custom_field_ids.empty?\n custom_fields = CustomFields::Reference.find(:all)\n\n @reference_custom_field_ids = custom_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cutom_field.reference_custom_fields > an array Get reference custom fields custom_field.reference_custom_fields => [CustomFields::Reference,CustomFields::Reference,CustomFields::Reference,CustomFields::Reference] | def reference_custom_fields
reference_custom_field_ids.collect{|cf_id| CustomFields::Reference.find(cf_id) }
end | [
"def references_custom_fields\n references_custom_fields = []\n self.fields.each do |field|\n if !field.custom_field.nil?\n references_custom_fields << field.custom_field if field.custom_field.is_a?(CustomFields::Reference)\n end\n end\n references_custom_fields\n end",
"def referenc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Consultor del titulo, devuelve nil ya que solo las calles tienen titulo | def titulo
return nil
end | [
"def buscarElementoTextoAtributo(clase, titulo)\n \n end",
"def aviso_titular(aviso)\n if aviso.titular\n aviso.titular.empty? ? t( \"Aviso\" ) : aviso.titular\n else\n t( \"Aviso\" )\n end\n end",
"def titulo_guia\n titulo = []\n\n t = Especie.find(params[:especie_id])\n a ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /draft_investments/1 GET /draft_investments/1.xml | def show
@draft_investment = DraftInvestment.find(params[:id])
respond_to do |format|
format.xml { render :xml => @draft_investment }
end
end | [
"def new\n @draft_investment = DraftInvestment.new\n\n respond_to do |format|\n\n format.xml { render :xml => @draft_investment }\n end\n end",
"def show\n @invest = Invest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @in... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /draft_investments/new GET /draft_investments/new.xml | def new
@draft_investment = DraftInvestment.new
respond_to do |format|
format.xml { render :xml => @draft_investment }
end
end | [
"def new\n @investment = Investment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @investment }\n end\n end",
"def new\n\n @investment = Investment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :x... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /draft_investments/1 PUT /draft_investments/1.xml | def update
@draft_investment = DraftInvestment.find(params[:id])
respond_to do |format|
if @draft_investment.update_attributes(params[:investment])
format.xml
else
format.xml { render :xml => @draft_investment.errors, :status => :unprocessable_entity }
end
end
end | [
"def update\n @invest = Invest.find(params[:id])\n\n respond_to do |format|\n if @invest.update_attributes(params[:invest])\n format.html { redirect_to(@invest, :notice => 'Invest was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /draft_investments/1 DELETE /draft_investments/1.xml | def destroy
@draft_investment = DraftInvestment.find(params[:id])
@draft_investment.destroy
respond_to do |format|
format.xml { head :ok }
end
end | [
"def destroy\n @invest = Invest.find(params[:id])\n @invest.destroy\n\n respond_to do |format|\n format.html { redirect_to(invests_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @investment = Investment.find(params[:id])\n @investment.destroy\n\n respond_to do |form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /relatives GET /relatives.json | def index
@relatives = Relative.includes(:organizations, :representative)
.group_by { |relative| relative.representative }
end | [
"def show\n @relative = Relative.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relative }\n end\n end",
"def common_relatives_with(user)\n self.relatives & user.relatives\n end",
"def add_relatives(relatives,min_distance,max_dist... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /relatives/1 DELETE /relatives/1.json | def destroy
@relative.destroy
respond_to do |format|
format.html { redirect_to [:admin, :relatives], notice: 'Relative was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @relative = Relative.find(params[:id])\n @relative.destroy\n\n respond_to do |format|\n format.html { redirect_to relatives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatory.destroy\n respond_to do |format|\n format.html { redirect_to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates a Ruby Hash containing a configuration compatible with ExtJS Buttonwidget definition, to be used inside an items list of a panel container. Works similarly to ApplicationHelper::create_extjs_button_config, but instead of returning a parsable Javascript string, the result is a plain Ruby Hash. == Params: actio... | def create_button_config( action_title_i19n_sym, action_title_i19n_scope_sym, image_name = "cog.png" )
action_text = I18n.t( action_title_i19n_sym.to_sym, {:scope => [action_title_i19n_scope_sym ? action_title_i19n_scope_sym.to_sym : nil]} )
tooltip_text = I18n.t( "#{action_title_i19n_sym}_tooltip".to_sym, {:s... | [
"def create_extjs_button_config( action_title_i19n_sym, action_title_i19n_scope_sym,\n location_href_path, image_name = \"cog.png\" )\n action_text = I18n.t( action_title_i19n_sym.to_sym, {:scope => [action_title_i19n_scope_sym ? action_title_i19n_scope_sym.to_sym : nil]} )\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The method should mutate the given array by replacing elements with their corresponding values in the hash. The method should return the given array. Note: this method must MUTATE the input array. This means that the object_id of the input array should be identical to the object_id of the returned array. The exact obje... | def ele_replace!(array, hash)
array.map! do |ele| #go through the array
if hash.has_key?(ele) #hash contains a key thats also in the array arr = [4,2,0,2] vs hash = {2=>two, 0 => zero}
hash[ele] #convert array values with corresponding hash values -> [ ... ,two,zero,two]
else
... | [
"def element_replace(array, hash)\n new_array = []\n\n array.each do |ele|\n if hash.keys.include?(ele)\n new_array << hash[ele]\n else\n new_array << ele\n end\n end\n\n new_array\nend",
"def ele_replace!(array, hash)\n array.map! do |ele| # use map! to mutate original arr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return if idx2 >= arr.size block.call(arr[idx1], arr[idx2]) each_cons(arr, idx1 + 1, idx2 + 1, &block) end | def each_cons(arr, &block)
arr.size < 2 ? return : block.call(arr[0, 2])
each_cons(arr.drop(1), &block)
end | [
"def each_cons(arr)\n arr[0..-2].each_with_index { |value, idx| yield(arr[idx..idx+1]) }\n nil \nend",
"def each_cons(arr)\n first = 0\n second = 1\n loop do\n break if second >= arr.size\n yield(arr[first], arr[second])\n first += 1\n second += 1\n end\n nil\nend",
"def each_cons(array)\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
keep only those values in a hash that the particular model can hold | def remove_extras(hash, model)
hash.reject do |key,value|
# puts !(model.column_names.include?(key.to_s))
!(model.column_names.include?(key.to_s))
end
end | [
"def clean_mem_hash(hash)\n hash.except(:org, :primary)\n end",
"def whitelist_redact_hash redact_hash\n \t digest_hash = {}\n \t \n \t \tredact_hash.each do |key,how|\n \t \t if (how.to_sym == :digest)\n \t \t digest_hash[digest_key(key)] = :keep\n \t \t end\n \t \tend\n \t \t\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
checks if a stream contains the same values as a row | def same_stream(row,stream)
stream && row['raw_ip_incoming'] == stream.raw_ip_incoming && row['raw_ip_outgoing'] == stream.raw_ip_outgoing
end | [
"def has_repeated_row?\n counts = Hash.new(0)\n # convert hash to array\n # go through each; count occurrence \n row_of_sticks.to_a.each{|e|\n counts[e[1]] +=1 unless e[1]==0\n }\n array_of_pairs=row_of_sticks.select{|k,v| counts[v]>=2}.sort_by {|k,v| v}\n\n # if array_of_pairs not empty r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /portfolio_sections or /portfolio_sections.json | def index
@portfolio_sections = PortfolioSection.all
end | [
"def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end",
"def index\n \n @sections = @day.sections.all\n\n respond_to do |f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /portfolio_sections or /portfolio_sections.json | def create
@portfolio_section = PortfolioSection.new(portfolio_section_params)
respond_to do |format|
if @portfolio_section.save
format.html { redirect_to @portfolio_section, notice: "Portfolio section was successfully created." }
format.json { render :show, status: :created, location: @p... | [
"def update\n respond_to do |format|\n if @portfolio_section.update(portfolio_section_params)\n format.html { redirect_to @portfolio_section, notice: \"Portfolio section was successfully updated.\" }\n format.json { render :show, status: :ok, location: @portfolio_section }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /portfolio_sections/1 or /portfolio_sections/1.json | def update
respond_to do |format|
if @portfolio_section.update(portfolio_section_params)
format.html { redirect_to @portfolio_section, notice: "Portfolio section was successfully updated." }
format.json { render :show, status: :ok, location: @portfolio_section }
else
format.html ... | [
"def update\n respond_to do |format|\n if @portfolio.update(portfolio_params)\n format.html { redirect_to portfolios_path, notice: 'Portfolio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /portfolio_sections/1 or /portfolio_sections/1.json | def destroy
@portfolio_section.destroy
respond_to do |format|
format.html { redirect_to portfolio_sections_url, notice: "Portfolio section was successfully destroyed." }
format.json { head :no_content }
end
end | [
"def destroy\n @portfolio.destroy\n respond_to do |format|\n format.html { redirect_to portfolios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @section.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provides for mapping model attributes to attributes of the returned amazonecs result object. An optional parameter allows for certain attributes which may occur multiple times (eg. the authors of a book) to be returned as a single string joined with a provided parameter eg. maps_to_amazon_attribute :authorlist => 'auth... | def maps_to_amazon_attribute(args = {})
if @amazon_mappings.nil?
@amazon_mappings = Hash.new
@amazon_join_mappings = Hash.new
end
joiner = args.delete(:combine) if args[:combine]
args.each do |key, value|
if joiner
@amazon_join_mappings[key] = [... | [
"def build_attribute_list#:nodoc:\r\n if options[:only]\r\n options[:attributes] = Array(options[:only])\r\n else\r\n options[:attributes] = @klass.column_names - Array(options[:except]).collect { |e| e.to_s }\r\n end\r\n \r\n options[:attributes] = options[:attributes].collect{|attr| \"#... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Model.load_from_amazon!(asin_value, dev_key, associates_id) will load the model from an amazon result (or return empty if the product couldn't be found) and call the save method on the model object. | def load_from_amazon!(asin_value, dev_key = '1MZTQGBA4YWAFHSTG4R2', associates_id = 'thirddayweb-20')
result = self.load_from_amazon(asin_value, dev_key, associates_id)
if result
result.save
return result
end
end | [
"def fetch_product(asin)\n result = product_stored?(asin)\n return result if result.present?\n \n result = @conn.get asin\n return nil unless result.status == 200\n\n product = parse_product(result, asin)\n product = AmazonProduct.new(product)\n return product if product.save... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /holiday_exceptions GET /holiday_exceptions.json | def index
@holiday_exceptions = HolidayException.all
end | [
"def calendar_exceptions\n get '/gtfs/calendarDate'\n end",
"def calendar_service_exceptions(service_id)\n get \"/gtfs/calendarDate/serviceId/#{service_id}\"\n end",
"def index\n @holidays = Holiday.all\n\n respond_with(@holidays)\n end",
"def index\n @holidays = Holiday.all\n ren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /holiday_exceptions/1 PATCH/PUT /holiday_exceptions/1.json | def update
respond_to do |format|
begin
status = @holiday_exception.update(holiday_exception_params)
rescue => e
status = false
customer_holiday_ids = CustomersHoliday.where(customer_id: @holiday_exception.customer_id).pluck(:holiday_id)
@holidays = Holiday.where(global:tru... | [
"def update\n @holiday = Holiday.find(params[:id])\n\n @holiday.update_attributes(params[:holiday])\n respond_with(@holiday) do |format|\n if @holiday.errors.blank?\n format.all { redirect_to admin_holidays_path }\n else\n format.all { render 'edit' }\n end\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /holiday_exceptions/1 DELETE /holiday_exceptions/1.json | def destroy
@holiday_exception.destroy
respond_to do |format|
format.html { redirect_to projects_url, notice: 'Holiday exception was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @holiday.destroy\n respond_to do |format|\n format.html { redirect_to setting_holidays_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @holiday.destroy\n respond_to do |format|\n format.html { redirect_to holidays_url }\n format.json { head ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate video for a slide by combining the image and audio | def video_gen(slide)
term = slide['term']
kind = slide['kind']
index = slide['index']
audio = slide['audio']
image = slide['image']
raise "audio is required fof #{term}" unless audio
raise "image is required fof #{term}" unless image
file_name = file_name_gen(slide, ".mpg")
audio = command_arg(slide['... | [
"def combine_video(presentation)\n term = presentation['term']\n args = []\n for slide in presentation['slides']\n args.push command_arg(slide['video'])\n end\n args = args.join(' ')\n combined_arg = command_arg(\"#{BUILD_DIR}/#{term}/#{term}-combined.mpg\")\n final = \"#{DIST_DIR}/#{term}/#{term}.avi\"\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Concatenate slide videos together into one video | def combine_video(presentation)
term = presentation['term']
args = []
for slide in presentation['slides']
args.push command_arg(slide['video'])
end
args = args.join(' ')
combined_arg = command_arg("#{BUILD_DIR}/#{term}/#{term}-combined.mpg")
final = "#{DIST_DIR}/#{term}/#{term}.avi"
final_arg = comm... | [
"def mergeVideos()\n pathToIntermediates=\"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n vidList=\"#{pathToIntermediates}/vidList.txt\"\n # Create a txt file with the lists of all videos to concatenate\n system \"echo >#{vidList}\"\n (0...@objects.length).each do |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Basecamp helper method returns an instance specific basecamp object if valid connection credentials exist. Otherwise, returns nil. | def basecamp
return nil unless establish_connection!
@basecamp ||= Basecamp.new
end | [
"def basecamp_connection\n return unless establish_connection!\n Basecamp.connection\n end",
"def authenticate\n session[:bc] = nil\n \n begin\n BasecampWrapper.basecamp = Basecamp.new(params[:url].gsub(/http:\\/\\//, ''), params[:username], params[:password])\n\n # Test the login detail... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a basecamp connection object. Ensures that a connection is established first, otherwise returns nil | def basecamp_connection
return unless establish_connection!
Basecamp.connection
end | [
"def basecamp\n return nil unless establish_connection!\n @basecamp ||= Basecamp.new\n end",
"def connection\n return nil unless has_connection?\n ActiveRecord::Base.connection\n end",
"def aquire_connection\n conn = if @connection_pool\n @connection_pool.aquire_connection\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of todos for the given account and project_id. TODO: Can we return a blank project id and get all todo lists for all objects??? | def todos(project_id)
return [] if project_id.blank? || !basecamp
@todos[project_id] ||= Basecamp::TodoList.all(project_id, false)
end | [
"def find_project_todo_lists(project_id)\n BasecampAPI::TodoList.find(\n :all,\n :params => {\n :project_id => project_id,\n :responsible_party => ''\n }\n )\n end",
"def todo_list todo_list_id\n TodoList.new Basecampx.reques... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new time entry for a todo item | def create_todo(fact, todo_id = nil)
response = basecamp_connection.post("/todo_items/#{todo_id}/time_entries.xml",
"<time-entry>
<person-id>#{fact.activity.category.account.user_id}</person-id>
<date>#{fact.start_time... | [
"def create\n @time_entry = TimeEntry.new(params[:time_entry])\n\n respond_to do |format|\n if @time_entry.save\n format.html { redirect_to @time_entry, notice: 'Time entry was successfully created.' }\n format.json { render json: @time_entry, status: :created, location: @time_entry }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Destroy a time entry | def destroy_time_entry(time_entry_id)
response = basecamp_connection.delete("/time_entries/#{time_entry_id}.xml")
if response.code == '200'
return true
else
return false
end
end | [
"def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to home_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_entry = TimeEntry.find(params[:id])\n @time_entry.destroy\n\n resp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /icomes/1 GET /icomes/1.json | def show
@icome = Icome.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @icome }
end
end | [
"def index\n @things = Thing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @things }\n end\n end",
"def index\n @iacs = Iac.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @iacs }\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /icomes/new GET /icomes/new.json | def new
@icome = Icome.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @icome }
end
end | [
"def new\n @thing = Thing.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing }\n end\n end",
"def new\n @stuff = Stuff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stuff }\n end\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /icomes POST /icomes.json | def create
@icome = Icome.new(params[:icome])
respond_to do |format|
if @icome.save
format.html { redirect_to @icome, notice: 'Icome was successfully created.' }
format.json { render json: @icome, status: :created, location: @icome }
else
format.html { render action: "new" }... | [
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion In... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /icomes/1 PUT /icomes/1.json | def update
@icome = Icome.find(params[:id])
respond_to do |format|
if @icome.update_attributes(params[:icome])
format.html { redirect_to @icome, notice: 'Icome was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
fo... | [
"def update\n spice = Spice.find_by(id: params[:id])\n spice.update(spice_params)\n render json: spice\nend",
"def put *args\n make_request :put, *args\n end",
"def update_mobile_carrier(args = {}) \n put(\"/mobile.json/#{args[:carrierId]}\", args)\nend",
"def update_aos_version(args = {}) \n put... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /icomes/1 DELETE /icomes/1.json | def destroy
@icome = Icome.find(params[:id])
@icome.destroy
respond_to do |format|
format.html { redirect_to icomes_url }
format.json { head :no_content }
end
end | [
"def destroy\n @json.destroy\n\n head :no_content\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def delete_json(path)\n url = [base_url, path]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called from current_user. First attempt to login by the user id stored in the session. | def login_from_session
self.current_user = User.find_by_id(session[:user_id]) if session[:user_id]
end | [
"def try_login_from_session\n self.current_user = User.find_by_id(session[:user_id]) if session[:user_id]\n end",
"def login_from_session\n self.current_user = User.find(session[:user_id]) if session[:user_id]\n end",
"def login_from_session\n self.current_account = Account.find(session[:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /comments/watch?commentable_type=&commentable_id= DELETE /comments/watch?commentable_type=&commentable_id= | def watch
klass = params[:commentable_type].constantize
@commentable = klass.find(params[:commentable_id])
authorize! :read, @commentable
if request.post?
User.create_action(:watch_comment, target: @commentable, user: current_user, action_option: "watch")
else
User.create_action(:watch... | [
"def destroy\n @my_watch = MyWatch.find(params[:id])\n @my_watch.destroy\n\n respond_to do |format|\n format.html { redirect_to my_watches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commentable_content.destroy\n respond_to do |format|\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve latest gem metadata and contents from rubygems.org | def retrieve_latest(name)
client.url = "https://rubygems.org/api/v1/gems/#{name}.json"
client.http_get
spec = client.body_str
gem = parse spec
gem
end | [
"def information\n @information ||= JSON.parse( open( \"https://rubygems.org/api/v1/gems/#{@gem_name}.json\" ).read )\n end",
"def download_gem\n gem_path = \"https://rubygems.org/gems/#{@name}-#{@version}.gem\"\n curl = Curl::Easy.new(gem_path)\n curl.follow_location = true\n curl.htt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve latest version of gem matching dep | def latest_matching(dep)
version = latest_version_matching(dep)
raise RuntimeError, "no version found" if version.nil?
retrieve dep.name, version
end | [
"def latest_version_matching(dep)\n version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.max\n version.nil? ? nil : version.to_s\n end",
"def latest_version\n gem['version']\n end",
"def get_latest(gem)\n versions_dataset.join(:gems, :gems__id => :versions_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve earliest version of gem matching dep | def earliest_matching(dep)
version = earliest_version_matching(dep)
raise RuntimeError, "no version found" if version.nil?
retrieve dep.name, version
end | [
"def earliest_version_matching(dep)\n version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.min\n version.nil? ? nil : version.to_s\n end",
"def latest_version_matching(dep)\n version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.max\n version.nil? ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve latest version of gem in target | def latest_in_target(name, target)
version = latest_version_in_target(name, target)
raise RuntimeError, "no matching version" if version.nil?
retrieve name, version
end | [
"def latest_version\n gem['version']\n end",
"def latest_version_in_target(name, target)\n versions_in_target(name, target).collect { |v| ::Gem::Version.new v }.max\n end",
"def latest_version(module_name)\n versions(module_name).last\n end",
"def gem_latest_version(gem_name, args = {}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
module ClassMethods Download the local gem and return it as a string | def download_gem
self.class.download_gem @name, @version
end | [
"def download_gem\n gem_path = \"https://rubygems.org/gems/#{@name}-#{@version}.gem\"\n curl = Curl::Easy.new(gem_path)\n curl.follow_location = true\n curl.http_get\n gemf = curl.body_str\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def ge... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return path to downloaded gem | def downloaded_gem_path
self.class.downloaded_gem_path @name, @version
end | [
"def gem_path\n @path || downloaded_gem_path\n end",
"def gem_path\n @path || downloaded_gem_path\n end",
"def full_gem_path\n File.join(installation_path, \"gems\", full_name)\n end",
"def install_path\n File.join(Config.gems_path, @gem_spec.gem_dirname)\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This only formats MMYYYY | def format_month_year(date)
date.strftime("%Y-%b")
end | [
"def format_db_date_YYYY_MM(arg_date)\n\t\tif arg_date.present?\n\t\t\targ_date.strftime(\"%Y/%m\")\n\t\tend\n\n\tend",
"def format_month_dd_yyyy\n self.strftime(\"%B %d, %Y\")\n end",
"def format_date(month, year)\n \"#{format(month,:two_digits)}/#{format(year, :two_digits)}\"\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the date / time value from config/locale/sitemap.yml associated with the current controller / action. The static date/times are actual timestamps extracted from the date of the view on disk and from a .git repository if used. Be sure to run the generator or rake task: duck_map:sync to populate the locale file a... | def sitemap_static_lastmod(my_controller_name = nil, my_action_name = nil)
value = nil
unless my_controller_name.blank? || my_action_name.blank?
unless my_controller_name.blank?
my_controller_name = my_controller_name.underscore
my_controller_name = my_controller_name.gsub("/",... | [
"def deployed_at() ; info_time(:deployed_datetime) ; end",
"def deployed_at() ; info_time(:deployed_datetime) ; end",
"def get_request_timestamp\n\t\treturn @transport.get_path(\"meta\",\"datetime\")\n\tend",
"def yaml_time\n modification_time(Table.table_path(slug))\n end",
"def syst... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
copy from the key's data using the glob pattern | def nuspec_copy(key, glob)
puts "key: #{key}, glob: #{glob}, proj dir: #{PROJECTS[key][:dir]}"
FileList[File.join(FOLDERS[:binaries], PROJECTS[key][:dir], glob)].collect{ |f|
to = File.join( FOLDERS[:"#{key}"][:nuspec], "lib", FRAMEWORK )
FileUtils.mkdir_p to
cp f, to
# return the file name an... | [
"def copy_tree_to(key, source_root, source_key)\n source_root.unprefixed_subtree_keys(source_key).each do |unprefixed_key|\n copy_content_to(File.join(key, unprefixed_key), source_root, File.join(source_key, unprefixed_key))\n end\n end",
"def nuspec_copy(key, glob)\r\n puts \"key: #{key}, glob: #{... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
API methods api/campaigns (all campaigns) api/campaigns/active (all active campaigns) api/:country/campaigns (campaigns in country) api/:country/campaigns/active (active campaigns in country) | def api_index
campaigns = Campaign.all
campaigns = campaigns.for_country(params[:country].presence) if params[:country]
campaigns = campaigns.active if 'active' == params[:status]
respond_to do |format|
format.json { render json: campaigns }
end
end | [
"def all\n get(\"#{domain}/campaigns\")\n end",
"def get_campaigns\n get('/fcb30500-7b98-476f-810d-463a0b8fc3df')\n end",
"def campaign_find_active\n call_api(:campaign_find_active)\n end",
"def campaign_stat_by_countries(id)\n return handle_error('Empty campaign id') unless... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the both Event and Idea/Transportation/Notes models. Idea model's title is copied from Event model. | def update
@event = Event.find(params[:id])
if @event.eventable_type == "Activity" or @event.eventable_type == "Hotel" or @event.eventable_type == "Foodanddrink"
@idea = Idea.find(@event.eventable_id)
respond_to do |format|
if @event.update_attributes(params[:event]) and @... | [
"def update\n @idea_event = IdeaEvent.find(params[:id])\n\n respond_to do |format|\n if @idea_event.update_attributes(params[:idea_event])\n format.html { redirect_to @idea_event, notice: 'Idea event was successfully updated.' }\n format.json { head :ok }\n else\n format.html { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This will read a given test case and pass that into the test_case_processor. A test case is defined as the number of lines_per_test_case Can optionally pass in a line_processor that will process a line before adding it to the buffer. Will stop reading after we hit the number of test cases defined in the file Assumption... | def parse(test_case_processor, line_processor = nil)
(raise ArgumentError.new('Missing input filename to parse')) unless @filename
line_counter = -1
test_cases_read = 0
test_cases = 0
line_buffer = []
IO.foreach(@filename) do |line|
line.strip!
# read number of case... | [
"def process_testcase(line_buffer)\n line_buffer\n end",
"def process_block(line_buffer, test_number)\n if (@custom_processor && @custom_processor.class.method_defined?(:process_testcase))\n @custom_processor.process_testcase line_buffer\n else\n line_buffer\n end\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove pfda admin from orgs Skip if the host user is actual ADMIN_USER | def remove_pfda_admin_user(orgs_dxs)
return if user.dxid == ADMIN_USER
orgs_dxs.each { |dxorg| papi.call(dxorg, "removeMember", user: ADMIN_USER) }
end | [
"def remove_pfda_admin_user(space, space_form)\n return if user.dxid == ADMIN_USER\n\n unless space_form.host_admin.dxid == ADMIN_USER\n admin_api.org_remove_member(space.host_dxorg, ADMIN_USER)\n end\n\n return if space_form.guest_admin.nil? || space_form.guest_admin&.dxid == ADMIN_USER\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send an activation email to all space leads | def send_emails(space)
space.leads.find_each do |lead|
notification_mailer.space_activation_email(space, lead).deliver_now!
end
end | [
"def send_activation_notification\n deliver_activation_email(:activation, :subject => (MaSA[:welcome_subject] || \"Welcome\" ))\n end",
"def send_activation_notification\n deliver_email(:activation, :subject => (MaSM[:welcome_subject] || \"Welcome\" ))\n end",
"def send_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a project of a cooperative review space. | def create_reviewer_cooperative_project(space)
if ADMIN_USER != user.dxid
papi.call(
space.host_dxorg, "invite",
invitee: user.dxid,
level: "ADMIN",
suppressEmailNotification: true
)
end
project_dxid = api.call(
"project", "new",
... | [
"def create_reviewer_cooperative_project(space)\n if ADMIN_USER != user.dxid\n papi.org_invite(\n space.host_dxorg,\n user.dxid,\n level: DNAnexusAPI::ORG_MEMBERSHIP_ADMIN,\n suppressEmailNotification: true,\n )\n end\n\n project_dxid = api.project_ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO: to be refactored Apply space_template to the space if space_template exists | def apply_space_template(space)
parent_space = space.space
return if parent_space.blank?
template = parent_space.space_template
return if template.blank?
template.space_template_nodes.each do |n|
node = n.node
case node
when UserFile
copy_service.copy(no... | [
"def add_space_type(template, clim, building_type, spc_type)\n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding space type: #{template}-#{clim}-#{building_type}-#{spc_type}\")\n\n # Get the space type data\n data = self.find_object(self.standards['space_types'], {'template'=>te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ins_co_offices/1 GET /ins_co_offices/1.xml | def show
@ins_co_office = InsCoOffice.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @ins_co_office }
end
end | [
"def index\n @offices = current_user.offices\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @offices }\n end\n end",
"def index\n @offres = Offre.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ins_co_offices/new GET /ins_co_offices/new.xml | def new
@ins_co_office = InsCoOffice.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @ins_co_office }
end
end | [
"def new\n @office = Office.new\n\t\t\n\t\t\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @office }\n end\n end",
"def new\n @officer = Officer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @off... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /ins_co_offices POST /ins_co_offices.xml | def create
@ins_co_office = InsCoOffice.new(params[:ins_co_office])
respond_to do |format|
if @ins_co_office.save
format.html { redirect_to(@ins_co_office, :notice => 'Office was successfully created.') }
format.xml { render :xml => @ins_co_office, :status => :created, :location => @ins_... | [
"def create\n @office = current_user.offices.build(params[:office])\n\n respond_to do |format|\n if @office.save\n flash[:notice] = 'Office was successfully created.'\n format.html { redirect_to(root_path) }\n format.xml { render :xml => @office, :status => :created, :location => @o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /ins_co_offices/1 PUT /ins_co_offices/1.xml | def update
@ins_co_office = InsCoOffice.find(params[:id])
respond_to do |format|
if @ins_co_office.update_attributes(params[:ins_co_office])
format.html { redirect_to(@ins_co_office, :notice => 'Office was successfully updated.') }
format.xml { head :ok }
else
format.html {... | [
"def update\n respond_to do |format|\n if @offiz.update(offiz_params)\n format.html { redirect_to @offiz, notice: 'Office was successfully updated.' }\n format.json { render :show, status: :ok, location: @offiz }\n else\n format.html { render :edit }\n format.json { render j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /ins_co_offices/1 DELETE /ins_co_offices/1.xml | def destroy
@ins_co_office = InsCoOffice.find(params[:id])
@ins_co_office.destroy
respond_to do |format|
format.html { redirect_to(ins_co_offices_url) }
format.xml { head :ok }
end
end | [
"def del\n @office1 = Office1.find(params[:id])\n @office1.destroy\n\n respond_to do |format|\n format.html { redirect_to(office1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @office = Office.find(params[:id])\n @office.destroy\n\n respond_to do |format|\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /online_judges POST /online_judges.json | def create
@online_judge = OnlineJudge.new(online_judge_params)
@online_judge.user = current_user
respond_to do |format|
if @online_judge.save
format.html { redirect_to current_user, notice: 'Online judge was successfully created.' }
format.json { render :show, status: :created, locat... | [
"def create\n @judge = @competition.judges.build(judge_params)\n authorize @judge\n if @judge.save\n flash[:notice] = 'Association was successfully created.'\n else\n index\n end\n respond_with(@judge, location: competition_judges_path(@competition), action: \"index\")\n end",
"def ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /online_judges/1 PATCH/PUT /online_judges/1.json | def update
respond_to do |format|
if @online_judge.update(online_judge_params)
format.html { redirect_to current_user, notice: 'Online judge was successfully updated.' }
format.json { render :show, status: :ok, location: @online_judge }
else
format.html { render :edit }
f... | [
"def update\n @badge = Badge.find(params[:id])\n\n if @badge.update(badge_params)\n head :no_content\n else\n render json: @badge.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_badge.update(api_v1_badge_params)\n format.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This method is used to return portable data, which describes some attribute of an Invoice == Outputs Returns a hash value with all concrete_charges | def portable_format
# an invoice basic information
invoice_hash = {}
invoice_hash[:id] = self.id
invoice_hash[:start_date] = self.start_date
invoice_hash[:end_date] = self.end_date
invoice_hash[:issue_date] = self.issue_date
invoice_hash[:total_charges] = self.total
invoice_hash[:distributio... | [
"def generateConcreteCharges\r\n\t\t#For each charge factories asscociated with retail plans, generate concrete charge and total them\r\n\t self.retail_plan.charge_factories.each do |charge_factory| \r\n\t predicted_concrete_charges = charge_factory.specific.concreteCharge(self)\r\n\t #Put each generat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /firms/new GET /firms/new.json | def new
@title = t('view.firms.new_title')
@firm = Firm.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @firm }
end
end | [
"def new\r\n @firm = Firm.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @firms }\r\n end\r\n\r\n end",
"def new\n @firm = Firm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @firm }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /firms POST /firms.json | def create
@title = t('view.firms.new_title')
@firm = Firm.new(params[:firm])
respond_to do |format|
if @firm.save
format.html { redirect_to @firm, notice: t('view.firms.correctly_created') }
format.json { render json: @firm, status: :created, location: @firm }
else
form... | [
"def create\n @firm = Firm.new(firm_params)\n\n respond_to do |format|\n if @firm.save\n flash[:type] = 'success'\n format.html { redirect_to @firm, notice: t('view.firms.correctly_created') }\n format.json { render :show, status: :created, location: @firm }\n else\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /firms/1 DELETE /firms/1.json | def destroy
@firm = Firm.find(params[:id])
@firm.destroy
respond_to do |format|
format.html { redirect_to firms_url }
format.json { head :ok }
end
end | [
"def destroy\n @firearm = Firearm.find(params[:id])\n @firearm.destroy\n\n respond_to do |format|\n format.html { redirect_to firearms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @firm = Firm.find(params[:id])\n @firm.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sample names Get sample names containing a substring | def get_sample_names(substring)
inputs = Dir.glob("inputs/#{$jobid}/*.txt")
inputs = inputs.select {|x| x.include? substring}
inputs = inputs.map{|x| File.basename(x).sub(".txt", "")}
return inputs
end | [
"def get_sample_names(substring)\n inputs = Dir.glob(\"inputs/#{$jobid}/*.txt\").select {|x| x.include? substring}\n inputs = inputs.map{|x| File.basename(x).sub(\".txt\", \"\")}\n return inputs\nend",
"def possible_sample_name(filename)\n\t\tfilename.split('/').last.split('.').first\n\tend",
"def two_word_n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recipes for adding stat. error shapes. Makes a new file task: input_file_stat_errors.root => input_file.root | def add_fake_errors(input_file, channel, prefix)
output_file = "#{File.dirname(input_file)}/#{channel}_shapes_#{prefix}_statshapes.root"
output_sys_list = output_file.sub('.root', ".txt")
file output_file => [input_file] do |t|
sh "add_stat_shapes.py #{input_file} #{output_file} --filter '#{prefix}/fakes' --... | [
"def add_fake_errors(input_file, prefix)\n output_file = input_file.sub('.root', '_statshapes.root')\n output_sys_list = input_file.sub('.root', '_statshapes.txt')\n file output_file => [input_file] do |t|\n sh \"$CMSSW_BASE/src/HiggsAnalysis/HiggsToTauTau/scripts/add_stat_shapes.py #{input_file} #{output_fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_groups/new GET /user_groups/new.json | def new
@user_group = UserGroup.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user_group }
end
end | [
"def new\n @usergroup = Usergroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usergroup }\n end\n end",
"def new\n @add_group_to_user = AddGroupToUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /user_groups/1 PUT /user_groups/1.json | def update
@user_group = UserGroup.find(params[:id])
respond_to do |format|
if @user_group.update_attributes(params[:user_group])
format.html { redirect_to @user_group, notice: 'User group was successfully updated.' }
format.json { head :ok }
else
format.html { render action... | [
"def update\n respond_to do |format|\n if @api_v1_user_group.update(api_v1_user_group_params)\n format.html { redirect_to @api_v1_user_group, notice: 'User group was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_user_group }\n else\n format.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /user_groups/1 DELETE /user_groups/1.json | def destroy
@user_group = UserGroup.find(params[:id])
@user_group.destroy
respond_to do |format|
format.html { redirect_to user_groups_url }
format.json { head :ok }
end
end | [
"def destroy\n @user_group = UserGroup.find_by_id(params[:id])\n @user_group.destroy\n render :json=>{:status =>t('users.destroy.success')}\n end",
"def destroy\n @api_v1_user_group.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_user_groups_url, notice: 'User group was su... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /machine_total_owners/1 GET /machine_total_owners/1.xml | def show
@machine_total_owner = MachineTotalOwner.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @machine_total_owner }
end
end | [
"def owners\n api_path = '/users'\n @resp = self.class.get(api_path, default_request_data)\n resp_parsing\n end",
"def new\n @machine_total_owner = MachineTotalOwner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @machine_total_owner }\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /machine_total_owners/new GET /machine_total_owners/new.xml | def new
@machine_total_owner = MachineTotalOwner.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @machine_total_owner }
end
end | [
"def create\n @machine_total_owner = MachineTotalOwner.new(params[:machine_total_owner])\n\n respond_to do |format|\n if @machine_total_owner.save\n format.html { redirect_to(@machine_total_owner, :notice => 'Machine total owner was successfully created.') }\n format.xml { render :xml => @... | {
"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.