query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
para almacenar la tarea, se debe validar si ya existe o no, se debe utililzar un match porque en la base de datos las tareas estan con el nombre mas el nombre del usuario si la tarea no existe se crea la tarea con el nombre de la tarea y el nombre del usuario, para poder luego sacar las tareas correspondientes al usuar...
def almacenar(nombre) array = Tarea.all @@existente = false array.each{|x| @@existente = true if /#{nombre}/.match(x["title"])} unless @@existente Tarea.create("#{nombre} #{@@usuario}") end @@existente end
[ "def obtener\narray = Tarea.all\n \n @@tareas = Array.new\n array.each{|x| @@tareas.push(x) if /#{@@usuario}/.match(x[\"title\"])}\n\n @@tareas.each do |x|\nstring = x[\"title\"].split\n string.pop\nx[\"title\"] = string.join(\" \")\n\n\n end\n #esto es para que no quede una tarea vacia al princip...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
obtiene las tareas correspondientes a cada usuario para mostrarla en la vista, como en la base de datos el nombre de la tarea esta con el nombre mas el usuario se debe quitar el usuario para poder mostrar solo el nombre de la tarea
def obtener array = Tarea.all @@tareas = Array.new array.each{|x| @@tareas.push(x) if /#{@@usuario}/.match(x["title"])} @@tareas.each do |x| string = x["title"].split string.pop x["title"] = string.join(" ") end #esto es para que no quede una tarea vacia al principio, la cual es la correspo...
[ "def alta_profesores_lista\n\t\t@profesores = []\n\t\t@tab = \"admin\"\n\t\tusuarios = User.select('id, matricula, nombre, apellido, admin, profesor').order(:matricula)\n\t\tusuarios.each do |usuario|\n\t\t\tif (usuario.matricula[0].chr == \"l\") || (usuario.matricula[0].chr == \"L\")\n\t\t\t#se checa primero que l...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
valida si una tarea existe, si lo esta la elimina
def eliminar(id) @@encontrada = false array = Tarea.all array.each{|x| @@encontrada = true if x["id"] == id.to_i} if @@encontrada Tarea.destroy(id) end @@encontrada end
[ "def eliminar\n titulo(\"Eliminar estudiante\")\n estudiante = Estudiante.return_estudiante\n if estudiante.borrar\n puts \"Estudiante eliminado correctamente :)\\n\\n\"\n else\n puts \"Error al borrar estudiante\\n\\n\"\n end\n end", "def almacenar(nombre)\n\t\narray = Tarea.all\n@@exis...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Render the error message with a status of 404 and a message letting the user know the resource does not exist.
def render_404 render( json: { error_messages: ['Resource does not exist'], error_code: 'NOT_FOUND' }, status: 404 ) end
[ "def render_404\n error(\n {\n error_messages: [t(\"api.error_messages.not_found\")],\n error_code: t(\"api.error_codes.not_found\"),\n },\n 404\n )\n end", "def entry_not_found\r\n\t\t\t\tmessage = \r\n\t\t\t\t[\r\n\t\t\t\t\tstatus: 404,\r\n\t\t\t\t\tuser_message: 'The resourc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
points are 2d with as in [x,y] example invocation: closest_pair([[2,3], [1,4], [3,5], [2,2]]) approach: brute force complexity: O(nn)
def closest_pair1(points) min_distance = Float::MAX best_pair = nil (0...points.length).each do |i| (i...points.length).each do |j| if i != j curr_distance = distance1(points[i], points[j]) if curr_distance < min_distance min_distance = curr_distance best_pair = [poin...
[ "def closest_house(points)\n xp = points.sort_by(&:x)\n yp = points.sort_by(&:y)\n closest_pair(xp,yp)\nend", "def find_closest(a, points)\n # distance => [all points at that distance from a]\n distances = Hash.new { |h, dist| h[dist] = [] }\n\n points.each.with_index do |pt, i|\n dist = find_distance(a,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns if account number is already present, else continues to generate a token
def generate_account_number return if account_number.present? self.account_number = generate_account_number_token end
[ "def generate_account_number\n return if account_number.present?\n self.account_number = generate_account_token\n end", "def generate_account_number\n rand_num = SecureRandom.hex(3).upcase\n self.account_number = admin? ? 'EGYPT' + rand_num : retailer? ? 'RET-NJ' + rand_num : supplier? ? 'SUP-N...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /meetings GET /meetings.xml
def index @meetings = Meeting.recent @past_meetings = Meeting.recent.past @upcoming_meetings = Meeting.upcoming respond_to do |format| format.html # index.html.erb format.xml { render :xml => @meetings } format.atom end end
[ "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @meetings }\n end\n end", "def get_list\n @meetings = Meeting.get_list(params, current_user.id)\n end", "def index\n @meetings_results = MeetingsResult.all\n\n respond_to do |format|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /meetings POST /meetings.xml
def create @meeting = Meeting.new(params[:meeting]) respond_to do |format| if @meeting.save flash[:notice] = 'Meeting was successfully created.' format.html { redirect_to(@meeting) } format.xml { render :xml => @meeting, :status => :created, :location => @meeting } else ...
[ "def create\n @meetup = Meetup.new(params[:meetup])\n @meetup.staff_id = current_staff\n @meetup.status = PLANNED\n\n respond_to do |format|\n if @meetup.save\n format.html { redirect_to meetups_path }\n format.xml { render :xml => @meetup, :status => :created, :location => @meetup }...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add top tweets data onto feeds GET /feeds_with_top_tweets
def feeds_with_top_tweets end
[ "def most_recent_tweets\n if tweets_are_stale?\n tweets.destroy_all\n fetch_tweets!\n end\n\n tweets.limit(10)\n end", "def recent_tweets(count)\n start(\"/recent/tweets/#{count}\")\n end", "def fetch_tweets\n fetch_new_tweets_from_twitter.sort_by { |tweet| tweet.twitter_id }.tap do |...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Symlink the dynamic linker, ld.so
def symlink_ld_so ld_so = HOMEBREW_PREFIX/"lib/ld.so" return if ld_so.readable? sys_interpreter = [ "/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3", "/lib/ld-linux-aarch64.so.1", "/system/bin/linker",...
[ "def post_link_hook(linker)\n basic_name = get_basic_name(linker)\n soname = get_soname(linker)\n symlink_lib_to basic_name\n symlink_lib_to soname\n end", "def link\n throw 'Invalid linker' unless @ld.is_a?(Linker)\n throw 'One or more source files are required' unless @sources.lengt...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Symlink the host's compiler
def symlink_host_gcc version = DevelopmentTools.non_apple_gcc_version "/usr/bin/gcc" return if version.null? suffix = (version < 5) ? version.to_s[/^\d+\.\d+/] : version.to_s[/^\d+/] return if File.executable?("/usr/bin/gcc-#{suffix}") || File.executable?(HOMEBREW_PREFIX/"bin/gcc-#{suffix}") ...
[ "def link(filename, outdir, platform='linux')\n f = base(filename)\n cmd, args = *case platform\n when 'darwin'\n ['gcc', '-arch i386']\n when 'linux'\n ['ld', '']\n else\n raise \"unsupported platform: #{platform}\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
given a dropdown list, return the list items as an array of strings with symbols for header or divider
def dropdown_list_items(list) css_select(list, "li").map do |item| if item['class'] && item['class'].include?("divider") :divider elsif item['class'] && item['class'].include?("dropdown-header") { :header => item.text.strip } else item.text.strip end end end
[ "def format_for_dropdown(collection)\n collection.map { |o| [o.title, o.id] }\n end", "def menu_items\n elements = []\n\n if display_parent_work && display_parent_work.rights.present?\n elements << \"<h3 class='dropdown-header'>Rights</h3>\".html_safe\n elements << rights_statement_item\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /inversions GET /inversions.json
def index permission_denied and return if current_user.cannot 'read_inversion' @inversions = Inversion.all @new_inversion = Inversion.new end
[ "def versions\n JSON.parse(RestClient.get(\"#{VERSION_URL}/.json\", self.default_headers))[\"versions\"].collect { |v| v[\"id\"] }.uniq\n end", "def index\n @projects_inversions = ProjectsInversion.all\n end", "def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /inversions POST /inversions.json
def create permission_denied and return if current_user.cannot 'create_inversion' @inversion = Inversion.new(inversion_params) respond_to do |format| if @inversion.save format.html { redirect_to inversions_url, success: @inversion.table_name_to_show.concat( ' fue creada satisfactoriamente.')...
[ "def index\n permission_denied and return if current_user.cannot 'read_inversion'\n @inversions = Inversion.all\n @new_inversion = Inversion.new\n end", "def add_aos_version(args = {}) \n post(\"/aosversions.json/\", args)\nend", "def create\n version_attributes = params.require(:version).permit(:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /inversions/1 PATCH/PUT /inversions/1.json
def update permission_denied and return if current_user.cannot 'update_inversion' respond_to do |format| if @inversion.update(inversion_params) format.html { redirect_to inversion_url, success: @inversion.table_name_to_show.concat( ' fue actualizado satisfactoriamente.') } format.json { r...
[ "def update_aos_version(args = {}) \n put(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def update\n @version = Version.find(params[:id])\n\n respond_to do |format|\n if @version.update_attributes(params[:version])\n format.html { redirect_to(@version, :notice => t('versions.update...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns my accounts as Padma::Account objects
def padma_accounts return nil if self.accounts.nil? self.accounts.map{|a|PadmaAccount.new(a)} end
[ "def accounts\n get_collection 'accounts', :class => Buxfer::Account\n end", "def accounts\n Management::Account.all(self)\n end", "def accounts\n []\n end", "def get_accounts\n @accounts = Account.all\n end", "def accounts\n return @accounts if @accounts\n @acc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns me enabled accounts as Padma::Account objects
def enabled_accounts return [] if self.accounts.nil? self.accounts.reject{|a|!a['enabled']}.map{|a|PadmaAccount.new(a)} end
[ "def enabled_accounts\n self.padma.try(:enabled_accounts)\n end", "def padma_accounts\n return nil if self.accounts.nil?\n self.accounts.map{|a|PadmaAccount.new(a)}\n end", "def accounts\n Management::Account.all(self)\n end", "def accounts\n []\n end", "def all\n @...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writes the chunk to the IO stream. It will call the +content+ method to get the content for this chunk, and will calculate and append the checksum automatically.
def write(io) write_with_crc(io, content || '') end
[ "def write(chunk)\n @size += chunk.bytesize\n # Worth noting that size always appears larger during this check than it\n # is in reality since the size is updated prior to writing out the data to\n # ensure that the amount of data stored in RAM doesn't exceed the maximum\n # in memory size....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
fetch details and create/update model for a particular DC title
def fetch_title_dc(publisher, title, url, date = nil) log("retrieving title information for [#{title}]", :debug) doc = Hpricot(open(url)) # span.display_talent = "Written by, Art by... " # span.display_copy = "A final confrontation pits..." # span.display_data = "DC Universe &nbsp;|...
[ "def create\n self.model = find_models.build(params[model_slug])\n model.save\n respond_with_contextual model\n end", "def fetch_title_marvel(publisher, title, url, date = nil) \n log(\"retrieving title information for [#{title}]\", :debug)\n doc = Hpricot(open(url))\n \n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
fetch details and create/update model for a particular DC title
def fetch_title_marvel(publisher, title, url, date = nil) log("retrieving title information for [#{title}]", :debug) doc = Hpricot(open(url)) display_description = (doc/"font[@class=plain_text]").innerHTML title = RubyPants.new(title, -1).to_html display_name, display_number ...
[ "def fetch_title_dc(publisher, title, url, date = nil)\n log(\"retrieving title information for [#{title}]\", :debug)\n doc = Hpricot(open(url))\n \n # span.display_talent = \"Written by, Art by... \"\n # span.display_copy = \"A final confrontation pits...\"\n # span.display_data = \"D...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
replace name with the converted value in TITLE_CONVERSION_LIST if it's been flagged for modification (due to an improper solicitation, etc)
def check_title(name) # titleize without the botched 'S (apostrophe-s) issue name = name.humanize.strip.squeeze(' ').gsub(/\b([a-z])/) { $1.capitalize }.gsub(/\'S/, '\'s') match = TITLE_CONVERSION_LIST.keys.select { |t| name.match(/#{Regexp.escape(t)}/i) } unless match.empty? match = ma...
[ "def change_name_to(new_title)\n replacement = { @current_list => new_title }\n # Renaming Solution for hash keys from Stackoverflow: http://stackoverflow.com/questions/4137824/how-to-elegantly-rename-all-keys-in-a-hash-in-ruby\n self.hash_tag.keys.each { |k| self.hash_tag[replacement[k]] = self.hash...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Manufacture an EC2 security group. The second parameter, rules, is an "ingress_rules" structure parsed and validated by MU::Config.
def setRules(rules, add_to_self: false, ingress: true, egress: false) return if rules.nil? or rules.size == 0 if add_to_self rules.each { |rule| if rule['sgs'].nil? new_rule = rule.clone new_rule.delete('hosts') rule['sgs'] =...
[ "def convertToEc2(rules)\n ec2_rules = []\n if rules != nil\n rules.each { |rule|\n ec2_rule = Hash.new\n rule['proto'] = \"tcp\" if rule['proto'].nil? or rule['proto'].empty?\n ec2_rule[:ip_protocol] = rule['proto']\n\n p_start = nil\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Convert our config languages description of firewall rules into Amazon's. This rule structure is as defined in MU::Config.
def convertToEc2(rules) ec2_rules = [] if rules != nil rules.each { |rule| ec2_rule = Hash.new rule['proto'] = "tcp" if rule['proto'].nil? or rule['proto'].empty? ec2_rule[:ip_protocol] = rule['proto'] p_start = nil p...
[ "def convertToEc2(rules)\n return [] if rules.nil?\n ec2_rules = []\n\n rules.uniq!\n\n rules.each { |rule|\n ec2_rule = {}\n rule[\"comment\"] ||= \"Added by Mu\"\n\n\n rule['proto'] ||= \"tcp\"\n ec2_rule[:ip_protocol] = rule['proto']...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
=begin :type prefix: String :type suffix: String :rtype: Integer =end
def f(prefix, suffix) @hash[prefix].nil? || @hash[prefix][suffix].nil? ? -1 : @hash[prefix][suffix] end
[ "def f(prefix, suffix)\n \n end", "def suffix_number(prefix_to_strip, text)\n return nil if text.nil?\n val = text.downcase.gsub(prefix_to_strip.downcase, '')\n val.to_i if positive_integer(val)\n end", "def prefix_size(i)\n prefix = i.split('/')[1]\n prefix.nil? ? 32 : pre...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return the chef config files dir or fail hard
def chef_config_path if Chef::Config['config_file'] ::File.dirname(Chef::Config['config_file']) else raise("No chef config file defined. Are you running \ chef-solo? If so you will need to define a path for the ohai_plugin as the \ path cannot be determined") end end
[ "def chef_dir\n knife_config == '' ? File.join(File.expand_path('~'), '.chef') : File.dirname(knife_config)\n end", "def config_directory\n \"C:\\\\chef\"\n end", "def find_config_path\n path = Pathname(Pathname.pwd).ascend{|d| h=d+config_filename; break h if h.file?}\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
is the desired plugin dir in the ohai config plugin dir array?
def in_plugin_path?(path) # get the directory where we plan to stick the plugin (not the actual file path) desired_dir = ::File.directory?(path) ? path : ::File.dirname(path) case node['platform'] when 'windows' ::Ohai::Config.ohai['plugin_path'].map(&:downcase).include?(desired_dir.downcase) ...
[ "def plugin?\n @root.parent.basename.to_s == 'plugins'\n end", "def some_plugins?\n Dir.glob(File.join('plugins', '*')).select{|record| File.directory?(record)}.any?\n end", "def maybe_plugin_dir(path:)\n path and plugin_dir path: path or self\n end", "def plugins_dir\n resource[:plugin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
we need to warn the user that unless the path for this plugin is in Ohai's plugin path already we're going to have to reload Ohai on every Chef run. Ideally in future versions of Ohai /etc/chef/ohai/plugins is in the path.
def plugin_path_warning Chef::Log.warn("The Ohai plugin_path does not include #{desired_plugin_path}. \ Ohai will reload on each chef-client run in order to add this directory to the \ path unless you modify your client.rb configuration to add this directory to \ plugin_path. The plugin_path can be set via the chef...
[ "def ohai_plugin_path\n \"/etc/chef/ohai_plugins\"\n end", "def bcpc_ohai_reload(plugin_name)\n require 'ohai'\n\n ohai = ::Ohai::System.new\n ohai.all_plugins(plugin_name.to_s)\n\n #\n # This is not a \"deep\" merge.\n #\n # Subtrees under matching keys are replaced, not merged.\n #\n node.autom...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a frame to the message (positioning it at the end of message). Any ZMQ::Message automatically gets copied out to a ruby string (user still responsible for original ZMQ::Message), strings are added directly.
def add(frame) msg_frame = convert_frame(frame) return nil if msg_frame.nil? @msg_frames << msg_frame self end
[ "def push(frame)\n msg_frame = convert_frame(frame)\n return nil if msg_frame.nil?\n @msg_frames.unshift(msg_frame)\n self\n end", "def duplicate\n dup_frames = @msg_frames.map {|frame| frame.dup}\n ZMQ::StringMultipartMessage.new(dup_frames)\n end", "def add_message(message,...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add a frame to the front of the message. Frame can be either a string or a ZMQ::Message. The method copies out any string given in a ZMQ::Message (and the user is still in charge of properly closing such a message).
def push(frame) msg_frame = convert_frame(frame) return nil if msg_frame.nil? @msg_frames.unshift(msg_frame) self end
[ "def add(frame)\n msg_frame = convert_frame(frame)\n return nil if msg_frame.nil?\n @msg_frames << msg_frame\n self\n end", "def duplicate\n dup_frames = @msg_frames.map {|frame| frame.dup}\n ZMQ::StringMultipartMessage.new(dup_frames)\n end", "def enqueue(queue_name, frame)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a duplicate of the message.
def duplicate dup_frames = @msg_frames.map {|frame| frame.dup} ZMQ::StringMultipartMessage.new(dup_frames) end
[ "def set_duplicate_message(message, clone)\n if message.request?\n if message.from_user_info == @from && message.to_user_info == @to\n if clone.outgoing? && message.incoming?\n clone.duplicate = true\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Decrypts a block of data (encrypted_data) given an encryption key and an initialization vector (iv). Keys, iv's, and the data returned are all binary strings. Cipher_type should be "AES256CBC", "AES256ECB", or any of the cipher types supported by OpenSSL. Pass nil for the iv if the encryption type doesn't use iv's (lik...
def decrypt(encrypted_data, key, iv, cipher_type) aes = OpenSSL::Cipher::Cipher.new(cipher_type) aes.decrypt aes.key = key aes.iv = iv if iv != nil aes.update(encrypted_data) + aes.final end
[ "def decrypt_data(encrypted_data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.decrypt\n aes.key = key\n aes.padding = 0\n aes.iv = iv if iv != nil\n aes.update(encrypted_data) + aes.final\n end", "def aes_cbc_decrypt(data, key, iv)\n key_arr = key.unpack(\"C*...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Encrypts a block of data given an encryption key and an initialization vector (iv). Keys, iv's, and the data returned are all binary strings. Cipher_type should be "AES256CBC", "AES256ECB", or any of the cipher types supported by OpenSSL. Pass nil for the iv if the encryption type doesn't use iv's (like ECB). :return: ...
def encrypt(data, key, iv, cipher_type) aes = OpenSSL::Cipher::Cipher.new(cipher_type) aes.encrypt aes.key = key aes.iv = iv if iv != nil aes.update(data) + aes.final end
[ "def encrypt_data(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.encrypt\n aes.key = key\n aes.iv = iv if iv != nil\n aes.update(data) + aes.final\n end", "def aes_encrypt(data, key, iv, cipher_type)\n aes = OpenSSL::Cipher::Cipher.new(cipher_type)\n aes.e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs a program locally.
def run(program,*args) system(program,*args) end
[ "def run program\n exec read program\n end", "def run_locally(cmd)\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n `#{cmd}`\nend", "def run_program(exe_file, args = [])\n\tstr = exe_file + args.join(' ')\n\treturn system str.strip\nend", "def local_sh(cmd)\n say_formatted(\"executi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /efforts GET /efforts.json
def index @efforts = Effort.all respond_to do |format| format.html # index.html.erb format.json { render json: @efforts } end end
[ "def show\n @effort = Effort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @effort }\n end\n end", "def show\n @effort = Effort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /efforts/1 GET /efforts/1.json
def show @effort = Effort.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @effort } end end
[ "def show\n @effort = Effort.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @effort }\n end\n end", "def index\n @efforts = Effort.all\n\n respond_to do |format|\n format.html # index.html.erb\n fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /efforts/new GET /efforts/new.json
def new @effort = Effort.new respond_to do |format| format.html # new.html.erb format.json { render json: @effort } end end
[ "def new\n @effort = Effort.new(user_id: spree_current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @effort }\n end\n end", "def new\n\t\t@effort = Effort.new({task_id: params[:task_id], user_id: present_user.id})\n\t\t\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /efforts POST /efforts.json
def create @effort = Effort.new(params[:effort]) respond_to do |format| if @effort.save format.html { redirect_to @effort, notice: 'Effort was successfully created.' } format.json { render json: @effort, status: :created, location: @effort } else format.html { render action:...
[ "def create\n @effort = Effort.new(effort_params)\n\n respond_to do |format|\n if @effort.save\n format.html { redirect_to @effort, notice: 'Effort was successfully created.' }\n format.json { render :show, status: :created, location: @effort }\n else\n format.html { render :new...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /efforts/1 PUT /efforts/1.json
def update @effort = Effort.find(params[:id]) respond_to do |format| if @effort.update_attributes(params[:effort]) format.html { redirect_to @effort, notice: 'Effort was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } form...
[ "def update\n respond_to do |format|\n if @effort.update(effort_params)\n format.html { redirect_to @effort, notice: 'Effort was successfully updated.' }\n format.json { render :show, status: :ok, location: @effort }\n else\n format.html { render :edit }\n format.json { rend...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /efforts/1 DELETE /efforts/1.json
def destroy @effort = Effort.find(params[:id]) @effort.destroy respond_to do |format| format.html { redirect_to efforts_url } format.json { head :ok } end end
[ "def destroy\n @effort = Effort.find(params[:id])\n @effort.destroy\n\n respond_to do |format|\n format.html { redirect_to(efforts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @effort = Effort.find(params[:id])\n @effort.destroy\n\n respond_to do |form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Saves the current state of all merged entities. For more complete error reporting, this method attempts to save all entities regardless of whether or not a previous entity or set of entities failed to save. However, it will return true if and only if all entities were saved. When data dependencies exist, this can lead ...
def save collections = [participants, people, contacts, events, instruments, response_sets, question_response_sets ].map { |c| current_for(c).compact } ActiveRecord::Base.transaction do collections.map { |c| save_col...
[ "def committed?\n @saved\n end", "def multi_save(objs)\n # First let's be sure the objects are in good shape.\n return false unless objs.all?(&:valid?)\n\n # Let's start a transaction and save the objects.\n objs.first.transaction do\n objs.each(&:save!)\n end\n rescue\n # This is ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Search gem data paths.
def data_path(match, options={}) specs = specifications(options) matches = [] specs.each do |spec| list = [] glob = File.join(spec.full_gem_path, 'data', match) list = Dir[glob] #.map{ |f| f.untaint } list = list.map{ |d| d.chomp('/') } matches....
[ "def gem_paths\n raise NotImplementedError\n end", "def resolve_paths\n [dataset_dir]\n end", "def paths_from_software_gems\n @paths_from_software_gems ||=\n Array(Config.software_gems).inject([]) do |array, name|\n if (spec = Gem::Specification.find_all_by_name(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /problems/1 DELETE /problems/1.json
def destroy @problem.destroy respond_to do |format| format.html { redirect_to problems_url } format.json { head :ok } end end
[ "def destroy\n @problem = Problem.find(params[:id])\n @problem.destroy\n\n render json: { text: \"success\"}\n end", "def destroy\n @problem = Problem.find(params[:id])\n @problem.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_problems_url }\n format.json { head ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Scales a primitive rect by a percentage.
def scale_rect percentage, *anchors Geometry.scale_rect self, percentage, *anchors end
[ "def scaled_by(other)\n other = Geometry.new(\"#{other}%\") unless other.is_a? Geometry\n if other.height > 0\n Geometry.new(self.width * other.width / 100, self.height * other.height / 100)\n else\n Geometry.new(self.width * other.width / 100, self.height * other.width / 100)\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the angle to one primitive from another primitive.
def angle_from other_point Geometry.angle_from self, other_point end
[ "def angle_with(other)\n\t\tMath.acos( self.udot(other) )\n\tend", "def angle(other)\n return nil unless other.is_a?(Topolys::Vector3D)\n prod = magnitude * other.magnitude\n return nil if prod.zero?\n Math.acos(dot(other) / prod)\n end", "def other_angle(a, b)\n 180 - (a + b)\nend", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /party_approvals or /party_approvals.json
def index @party_approvals = PartyApproval.all end
[ "def approvals\n approvals_list = []\n if params[:count]\n if params[:skip]\n approvals_list = current_user.db_user.approval_approvers.order('created_at desc').offset(params[:skip].to_i).take(params[:count].to_i)\n else\n approvals_list = current_user.db_user.approval_approvers.order('...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /party_approvals or /party_approvals.json
def create @party_approval = PartyApproval.new(party_approval_params) respond_to do |format| if @party_approval.save format.html { redirect_to @party_approval, notice: 'Party approval was successfully created.' } format.json { render :show, status: :created, location: @party_approval } ...
[ "def update\n respond_to do |format|\n if @party_approval.update(party_approval_params)\n format.html { redirect_to @party_approval, notice: 'Party approval was successfully updated.' }\n format.json { render :show, status: :ok, location: @party_approval }\n else\n format.html { re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /party_approvals/1 or /party_approvals/1.json
def update respond_to do |format| if @party_approval.update(party_approval_params) format.html { redirect_to @party_approval, notice: 'Party approval was successfully updated.' } format.json { render :show, status: :ok, location: @party_approval } else format.html { render :edit,...
[ "def update\n @party = current_user.parties.find(params[:id])\n\n respond_to do |format|\n if @party.update_attributes(params[:party])\n format.html { redirect_to @party, notice: 'Party was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /party_approvals/1 or /party_approvals/1.json
def destroy @party_approval.destroy respond_to do |format| format.html { redirect_to party_approvals_url, notice: 'Party approval was successfully destroyed.' } format.json { head :no_content } end end
[ "def remove_approver\n\n # get the client\n @client = Client.find(params[:client_id])\n\n # get the contract\n @contract = Contract.find(params[:id])\n\n # find the approver\n @approver = User.find(params[:user_id])\n\n # double check use is an approver\n if @contract.is_approver?(@approver)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /pro_asphalts POST /pro_asphalts.json
def create @pro_asphalt = ProAsphalt.new(pro_asphalt_params) respond_to do |format| if @pro_asphalt.save format.html { redirect_to pro_asphalts_path(@pro_asphalt), notice: 'Pro asphalt was successfully created.' } format.json { render :show, status: :created, location: @pro_asphalt } ...
[ "def create\n @pro_asphalt_type = ProAsphaltType.new(pro_asphalt_type_params)\n\n respond_to do |format|\n if @pro_asphalt_type.save\n format.html { redirect_to @pro_asphalt_type, notice: 'Pro asphalt type was successfully created.' }\n format.json { render :show, status: :created, location...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /pro_asphalts/1 PATCH/PUT /pro_asphalts/1.json
def update respond_to do |format| if @pro_asphalt.update(pro_asphalt_params) format.html { redirect_to pro_asphalts_path(@pro_asphalt), notice: 'Pro asphalt was successfully updated.' } format.json { render :show, status: :ok, location: @pro_asphalt } else format.html { render :e...
[ "def update\n @prospy = Prospy.find(params[:id])\n\n respond_to do |format|\n if @prospy.update_attributes(params[:prospy])\n format.html { redirect_to @prospy, notice: 'Prospy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /pro_asphalts/1 DELETE /pro_asphalts/1.json
def destroy @pro_asphalt.destroy respond_to do |format| format.html { redirect_to pro_asphalts_url, notice: 'Pro asphalt was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @json.destroy\n\n head :no_content\n end", "def destroy\n @healthpro.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @pro_asphalt_sub.destroy\n respond_to do |format|\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if the current user is reviewing the other user
def reviewing?(other_user) reviewing.include?(other_user) end
[ "def current_user_can_see_their_reviews?\n current_user_admin? || current_user_customer?\n end", "def current_user_created_given_review?(review)\n review.user_id == current_user.read_attribute(\"id\")\n end", "def reviewable_by?(user_id)\n reviewer = User.find(user_id)\n feedback_requested? &&\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /veiculo_motoristas/1 PATCH/PUT /veiculo_motoristas/1.json
def update respond_to do |format| if @veiculo_motorista.update(veiculo_motorista_params) format.html { redirect_to @veiculo_motorista, notice: 'Veiculo motorista was successfully updated.' } format.json { render :show, status: :ok, location: @veiculo_motorista } else format.html ...
[ "def update\n respond_to do |format|\n if @motorista.update(motorista_params)\n format.html { redirect_to @motorista, notice: 'Motorista was successfully updated.' }\n format.json { render :show, status: :ok, location: @motorista }\n else\n format.html { render :edit }\n for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /veiculo_motoristas/1 DELETE /veiculo_motoristas/1.json
def destroy @veiculo_motorista.destroy respond_to do |format| format.html { redirect_to veiculo_motoristas_url, notice: 'Veiculo motorista was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @motorista.destroy\n respond_to do |format|\n format.html { redirect_to motoristas_url, notice: 'Motorista was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reputacao_motoristum = ReputacaoMotoristum.find(params[:id])\n @reputa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
==== Parameters: +options+:: Hash of options ==== Options: +access_key_id+:: access key id +secret_access_key+:: secret access key +use_ssl+:: optional, defaults to false +debug+:: optional, defaults to false +timeout+:: optional, for Net::HTTP
def initialize(options = {}) @access_key_id = options[:access_key_id] @secret_access_key = options[:secret_access_key] @use_ssl = options[:use_ssl] || false @debug = options[:debug] @timeout = options[:timeout] end
[ "def initialize(options)\n @access_key_id = options[:access_key_id] or raise ArgumentError, \"No access key id given\"\n @secret_access_key = options[:secret_access_key] or raise ArgumentError, \"No secret access key given\"\n @use_ssl = options[:use_ssl]\n @timeout = options[:timeout]\n @d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create a new Redirect instance if the fields have been changed
def create_redirect_if_permalink_fields_changed former = send(self.class.permalink_field) current = PermalinkFu.escape(create_permalink_for(self.class.permalink_attributes)) attributes = {:model => self.class.name, :former_permalink => former, :current_permalink => current} if !former.nil? && f...
[ "def redirect\n @redirect = RedirectFollower.new(original_url) \n end", "def create\n @redirect_url = RedirectUrl.new(params[:redirect_url])\n\n respond_to do |format|\n if @redirect_url.save\n flash[:notice] = 'RedirectUrl was successfully created.'\n format.html { redirect_to(@re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an empty or existing array of abilities
def abilities @abilities ||= {} end
[ "def abilities_to_register\n []\n end", "def abilities_to_register\n []\n end", "def abilities_to_register\n []\n end", "def abilities\n (read_attribute(:abilities) || '').split(' ')\n end", "def abilities\n abilities = DB[:conn].execute(\n \"SELECT abilities.* ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Registers a new Girlfriend ability Girlfriend.register_ability :talk do |girl| Girlfriend::Ability::Talk.new(girl) end
def register_ability(name, &block) abilities[name] = block end
[ "def register(instance)\n name = instance.name\n self.abilities[name] = instance\n self.roles << name unless self.roles.include?(name)\n end", "def add_ability(func_name, timeout=nil, &block)\n @abilities[func_name] = Ability.new(func_name, block, timeout)\n @connection_pool.wi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns TRUE if the given ability exists, otherwise FALSE
def can?(name) abilities.include? name end
[ "def ability?\n self.__ability.present?\n end", "def ability?\n self.ability.present?\n end", "def can?(ability, resource)\n abilities.can?(ability, resource)\n end", "def satisfied_by?(course_user)\n course_user.achievements.exists?(achievement)\n end", "def has_achievement?(name)\n ac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Interact with Girlfriend name name of an ability input text input (default: '') if name is :interactive then it enters interactive mode, otherwise executes and returns immediately Returns the result of the interaction.
def interact?(name, input='') if name == :interactive interactive(input) else if can? name ability = abilities[name].call(self) ability.try? name, input else reply end end end
[ "def call_name\n $game_temp.name_calling = false\n $game_player.straighten\n Graphics.freeze\n window_message_close(false)\n actor = $game_actors[$game_temp.name_actor_id]\n if $game_temp.name_actor_id == 1\n character = $game_player.character_name\n else\n character = actor.character...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /api/bikes/reserve/:id Dont let a user reserve a bike unless they have a payment method added and are in good standing Expected params: XApiKey: api_key
def reserve # Start Ride return render json: { error: "This bike is not available to reserve" }, status: :forbidden unless @bike.available? begin ActiveRecord::Base.transaction do @bike.current_ride = Ride.build_from_user_bike(@user, @bike) @bike.reserved! case params[:payment_type...
[ "def bike_params\n params.require(:bike).permit(:bikeid, :serialnumber, :rating, :condition, :maintenance, :style, :size, :color, :availability, :lastcheck, :location, :fare, :accessories, :picture)\n end", "def create\n\n # Get the bike associated with this sighting\n @bike = Bike.find_by...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return view page create a slide
def create @mode = 'I' render 'admin/slides/slide' end
[ "def new\n @page_slide = Slide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_slide }\n end\n end", "def load_slide\n end", "def show_slide\n @slideshow = session[:slideshow]\n session[:slide_index] += 1\n @slide = @slideshow.slides[s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
return view page edit a slide
def edit @data = SlidesHlp.getSlide(params[:id]) if @data['slide_vi'] == nil @mode = 'I' else @slide = @data['slide_vi'] @slide_ja = @data['slide_ja'] @lang = @data['lang'] @mode = 'U' ...
[ "def create\n @mode = 'I'\n render 'admin/slides/slide'\n end", "def edit\n render view(params[:step])\n end", "def show_slide\n @slideshow = session[:slideshow]\n session[:slide_index] += 1\n @slide = @slideshow.slides[session[:slide_index]]\n if @slide == nil\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
update data translate of slide
def updateSlideTrans result = Hash.new result['status'] = true begin # try if !SlidesHlp.updateSlideTrans(params[:slide]) result['status'] = false end rescue # catch result['status'] = false ...
[ "def change_slide_position\n if @ok\n @replaced_slide = Slide.find_by_lesson_id_and_position(@lesson_id, @position)\n @slide.change_position(@position)\n @slides = @lesson.slides.order(:position)\n @current_slide = @slide\n end\n end", "def update_translations(locale, data)\n set_tra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
update show status of slide
def updateShowSlide result = Hash.new result['status'] = true begin # try result['status'] = Slide.where(id: params[:id]) .update_all('slides.show = NOT slides.show, updated_by = ' + $user_id.to_s + ', updated_at = \''...
[ "def show_slide\n @slideshow = session[:slideshow]\n session[:slide_index] += 1\n @slide = @slideshow.slides[session[:slide_index]]\n if @slide == nil\n session[:slide_index] = 0\n @slide = @slideshow.slides[session[:slide_index]]\n end\n render :partial => \"show_slide\"\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initialize CWLSLas object passing las file as argument Example: >> my_well = CWLSLas.new('my_well.las') => Arguments: las_file_name: (String) file_options: (Hash) options: encoding
def initialize(filename=nil, file_options={}) load_file(filename, file_options) if not filename.nil? end
[ "def initialize(path = nil, options = {})\n raise 'expected options hash' if options && !options.is_a?(Hash)\n raise t('file.unsupported', file: path) unless self.class.enabled?\n initialize_attributes(path, options)\n update_locale\n init\n try_load\n end", "def ini...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return a list of mnemonics representing the curve names Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.curve_names => ["ILD", "ILM", "DT", "NPHI", "RHOB", "SFLA", "SFLU", "DEPT"]
def curve_names self.curves.keys end
[ "def split_curve_name(name)\n name.include?('/') ? name.split('/', 2) : [nil, name]\n end", "def names\n @mplab_pin.names\n end", "def name_parts\n if license_type == 'cc'\n short_name.split('-').select { |p| License.is_text_part?(p) }\n else\n []\n end\n end", "def get...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an object representing the curve selected Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.curve('ILD')
def curve(curve_name) self.curves[curve_name] end
[ "def add_curve(*args)\n end", "def usingCurves\n\tend", "def load_curve\n @load_curve ||= demand_curve - supply_curve\n end", "def curve(base)\n if base.respond_to?(:to_curve) && base.length == Fever::FRAMES\n return base.to_curve\n end\n\n case base\n when Numeric then curve_from_nu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the company name tha owns the well Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.company_name => "ANY OIL COMPANY LTD."
def company_name self.well_info.company_name end
[ "def company_name\n return @company_name\n end", "def company_name\n @company_name\n end", "def getCompanyName\r\n\t\t\t\t\treturn @companyName\r\n\t\t\t\tend", "def name\n latest_ccla_signature.company\n end", "def company_name\n return @children['company-na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the province described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.province => "RIO DE JANEIRO"
def province self.well_info.province end
[ "def province\n @province ||= Search.province_from_istat(province_istat)\n end", "def province_from_name # :doc:\n data.provinces.find do |p|\n name_set = p.name.downcase.gsub(/[^a-z]/, '')\n term_set = term.downcase.gsub(/[^a-z]/, '')\n name_set =~ Regexp.new(term_set) && term_s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the service company that performed the log acquisition Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.service_company => "ANY LOGGING COMPANY LTD."
def service_company self.well_info.service_company end
[ "def commercial_company_name\n self.dig_for_string(\"companySummary\", \"commercialCompanyName\")\n end", "def company\n production_companies.first\n end", "def name\n latest_ccla_signature.company\n end", "def getcompany\n Company.company_than(need_calc_company)\n end", "def compa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the API () described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.api => "1513120205"
def api self.well_info.api end
[ "def api_path\n \"/api/v#{@api_version}/\"\n end", "def api\n\t\t@api\n\tend", "def api_base\n self.class.name.split('::').last.downcase\n end", "def api_version\n self.class.get('/api')['api_ver']\n end", "def parse_api api_yaml\n api = ::Google::Protobuf::Api.new\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the UWI (UNIQUE WELL ID) described in the file Returns API if UWI not found (for locations outside Canada) Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.uwi => "100091604920W300"
def uwi self.well_info.uwi || self.well_info.api end
[ "def name_of_uvhw(well)\n plate, r, c = find_uvhw(well)\n return \"Well #{plate.id}(#{'ABCD'[r]}#{c+1})\"\n end", "def wpi\n data[:wpi]\n end", "def generate_wesabe_id\n if country && wesabe_id.nil? && id != UNKNOWN_FI_ID\n if last_id = FinancialInst.where([\"wesabe_id LIKE ?\", \"#{count...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the county described in the file Example: >> my_well = CWLSLas.new('my_well.las') => >> my_well.county => "KENAI"
def county self.well_info.county end
[ "def uk_county(city = nil)\n if city.blank?\n fetch('address.uk_county')\n else\n index = I18n.translate(:faker)[:address][:uk_city].index(city)\n county = I18n.translate(:faker)[:address][:uk_county][index] if index\n county ? county : fetch('address.uk_county')\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
if eresource put catalog link in coverage else put in url field.
def generate_rdf_catlink(b,ty) ul = "http://catalog.library.cornell.edu/catalog/#{id}" # if no elect access data, 'description' field. b.dc(:description,ul) end
[ "def add_url_to_pr\n return unless update_pr && ci_provider\n\n ci_provider.add_report_url\n end", "def supplier_detail_link\n if supplier.product_base_url.blank? or self.supplier_product_code.blank?\n return nil\n else\n return \"#{supplier.product_base_url}#{self.supplier_prod...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns all repos as pythonlike generators
def all_repos_as_generator Enumerator.new do |enum| each do |repo| enum.yield repo end end end
[ "def for_each_github_repo\n @github_repos.each do |repo_info|\n Octokit.configure do |c|\n c.api_endpoint = repo_info[:url]\n end\n Credentials.with_credentials_for(:github, @logger, @logger_stderr, url: repo_info[:url]) do |_github_user, github_token|\n clien...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /feed_entries/1 DELETE /feed_entries/1.json
def destroy @feed_entry = FeedEntry.find(params[:id]) @feed_entry.destroy respond_to do |format| format.html { redirect_to feed_entries_url } format.json { head :no_content } end end
[ "def destroy\n @feed_entry.destroy\n respond_to do |format|\n format.html { redirect_to feed_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @entry = FeedEntry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
add screener to playlist
def add_screener @screener_playlist = ScreenerPlaylist.find(params[:id]) @screener_playlist_item_position = ScreenerPlaylistItem.where("screener_playlist_id=?", params[:id]) .order("position ASC") ...
[ "def add_screener\n\n @screener_playlist = ScreenerPlaylist.find(params[:id])\n @screener_playlist_item = ScreenerPlaylistItem.new(:screener_playlist_id => params[:id], :screener_id => params[:screener_id], :position => @screener_playlist.screener_playlist_items.count + 1)\n\n @notice=\"\"\n\n @screener...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /extractions_extraction_forms_projects_sections_type1/1 DELETE /extractions_extraction_forms_projects_sections_type1/1.json
def destroy @extractions_extraction_forms_projects_sections_type1.destroy respond_to do |format| format.html do redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1 .extractions_extraction_forms_projects_secti...
[ "def destroy\n @extractions_extraction_forms_projects_sections_type1.destroy\n respond_to do |format|\n format.html { redirect_to work_extraction_path(@extractions_extraction_forms_projects_sections_type1\n .extractions_extraction_forms_projects_secti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /extractions_extraction_forms_projects_sections_type1s/1/add_population POST /extractions_extraction_forms_projects_sections_type1s/1/add_population.json
def add_population authorize(@extractions_extraction_forms_projects_sections_type1) @extractions_extraction_forms_projects_sections_type1.extractions_extraction_forms_projects_sections_type1_rows.each do |eefpst1r| eefpst1r.extractions_extraction_forms_projects_sections_type1_row_columns.create end ...
[ "def add_population\n @extractions_extraction_forms_projects_sections_type1.extractions_extraction_forms_projects_sections_type1_rows.each do |eefpst1r|\n eefpst1r.extractions_extraction_forms_projects_sections_type1_row_columns.create\n end\n\n redirect_to edit_populations_extractions_extraction_form...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set a random variate as the arrival rate.
def with_arrival_rate(species, *args) @arrival_rate = RandomVariate.send(species, *args) end
[ "def random= rnd\n @sampling.random = rnd\n end", "def random= rnd\n @roulette.random = rnd\n end", "def set_rate(rate)\n ra_rate(rate)\n dec_rate(rate)\n end", "def _randomize(delay)\n (delay * (1.0 + 0.5 * rand)).round\n end", "def random_multiplier\n (rand(1..12) *...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Have an item arrive from the population.
def arrive! raise(DSQ::PopulationError, "You can not produce an arrival while the Population is waiting.", caller) if waiting? @waiting = true return Item.new end
[ "def pick_up(item)\n if items_weight + item.weight <= CAPACITY \n if item.is_a?(Weapon)\n @equipped_weapon = item \n elsif item.is_a?(BoxOfBolts) && health <= 80\n item.feed(self) \n else items << item\n end\n end\n end", "def pick_up(item)\n return false if items_we...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send an email after the app has been redeployed
def redeploy setup_email @@to_emails @subject = "[#{Rails.env.titleize}] BestDebates redeployed (#{Time.now.to_s})" @body = @subject end
[ "def email_notification\n return unless app.emailable? && should_email?\n Mailer.err_notification(self).deliver_now\n rescue => e\n HoptoadNotifier.notify(e)\n end", "def app_confirmation_email(updated, rushee, rush_app)\n @rushee = rushee\n @rush_application = rush_app\n @subject = \"#{AKPSI_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /setquestionlinks GET /setquestionlinks.json
def index @setquestionlinks = Setquestionlink.all end
[ "def questions\n self.class.get('/2.2/questions', @options)\n end", "def linking\n result = @test.link_questions(test_params)\n if result\n return render json: { message: 'Error: Question was not created succesfully', error: true }\n else\n return render json: { message: 'Question...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /setquestionlinks/1 PATCH/PUT /setquestionlinks/1.json
def update respond_to do |format| if @setquestionlink.update(setquestionlink_params) format.html { redirect_to @setquestionlink, notice: 'Setquestionlink was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json {...
[ "def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /setquestionlinks/1 DELETE /setquestionlinks/1.json
def destroy @setquestionlink.destroy respond_to do |format| format.html { redirect_to setquestionlinks_url } format.json { head :no_content } end end
[ "def destroy\n @questionset = Questionset.find(params[:id])\n @questionset.destroy\n\n respond_to do |format|\n format.html { redirect_to questionsets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @has_answers_set.destroy\n respond_to do |format|\n format....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This augments the time_ago_in_words method adding the word. Usage: time_ago_in_words_with_word(object.created_at)
def time_ago_in_words_with_word(date, word = "ago") "#{time_ago_in_words(date)} #{word}" end
[ "def time_since_created_at_in_words\n time_ago_in_words(self.created_at) + \" ago\"\n end", "def time_ago_in_words(from_time, options = {})\n distance_of_time_in_words(from_time, Time.now, options)\n end", "def on_words_add(words, word); end", "def on_words_add(words, word)\n Words.new(\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The original purpose of this method is to split paragraphs, but our formatter only works on paragraphs that have been presplit. Therefore, we just need to wrap the fragments in a singleelement array (representing a single paragraph) and return them.
def array_paragraphs fragments [fragments] end
[ "def commontator_split_paragraphs(text)\n return [] if text.blank?\n\n text.to_str.gsub(/\\r\\n?/, \"\\n\").gsub(/>\\s*</, \">\\n<\").split(/\\s*\\n\\s*/).reject(&:blank?)\n end", "def paragraphs(to_wrap = nil, split_on = /(#{$/}){2}/o)\n to_wrap = @text if to_wrap.nil?\n if to_wrap.respond_to?(:...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fights GET /fights.json
def index @fights = Fight.all respond_to do |format| format.html # index.html.erb format.json { render json: @fights.to_json( :include => { :field_initial => { :only => [:name] }, :field_actual => { :only => [:name] }, :category => { :only => [:name] }, :competitor_blue => { :only => [:last_name, :...
[ "def index\n @fights = Fight.all\n end", "def index\n @nights = Night.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @nights }\n end\n end", "def index\n @sightings = Sighting.all\n render json: @sightings\n end", "def index\n sight...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /fights/new GET /fights/new.json
def new @fight = Fight.new respond_to do |format| format.html # new.html.erb format.json { render json: @fight } end end
[ "def new\n @night = Night.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @night }\n end\n end", "def new_stories\n get('/newstories.json')\n end", "def new\n @fighter = Fighter.new\n\n respond_to do |format|\n format.html # new.html.er...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /boat_cover_image_names/1 GET /boat_cover_image_names/1.xml
def show @boat_cover_image_name = BoatCoverImageName.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @boat_cover_image_name } end end
[ "def show\n @boat_cover_image_uid = BoatCoverImageUid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @boat_cover_image_uid }\n end\n end", "def show\n @cover_image_name = CoverImageName.find(params[:id])\n\n respond_to do |format...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /boat_cover_image_names/new GET /boat_cover_image_names/new.xml
def new @boat_cover_image_name = BoatCoverImageName.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @boat_cover_image_name } end end
[ "def new\n @boat_cover_image_uid = BoatCoverImageUid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @boat_cover_image_uid }\n end\n end", "def new\n @cover_image_name = CoverImageName.new\n\n respond_to do |format|\n format.html # new.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /boat_cover_image_names POST /boat_cover_image_names.xml
def create @boat_cover_image_name = BoatCoverImageName.new(params[:boat_cover_image_name]) respond_to do |format| if @boat_cover_image_name.save format.html { redirect_to(@boat_cover_image_name, :notice => 'Boat cover image name was successfully created.') } format.xml { render :xml => @...
[ "def create\n @cover_image_name = CoverImageName.new(params[:cover_image_name])\n\n respond_to do |format|\n if @cover_image_name.save\n format.html { redirect_to(@cover_image_name, :notice => 'Cover image name was successfully created.') }\n format.xml { render :xml => @cover_image_name, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /boat_cover_image_names/1 PUT /boat_cover_image_names/1.xml
def update @boat_cover_image_name = BoatCoverImageName.find(params[:id]) respond_to do |format| if @boat_cover_image_name.update_attributes(params[:boat_cover_image_name]) format.html { redirect_to(@boat_cover_image_name, :notice => 'Boat cover image name was successfully updated.') } for...
[ "def update\n @cover_image_name = CoverImageName.find(params[:id])\n\n respond_to do |format|\n if @cover_image_name.update_attributes(params[:cover_image_name])\n format.html { redirect_to(@cover_image_name, :notice => 'Cover image name was successfully updated.') }\n format.xml { head :o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /boat_cover_image_names/1 DELETE /boat_cover_image_names/1.xml
def destroy @boat_cover_image_name = BoatCoverImageName.find(params[:id]) @boat_cover_image_name.destroy respond_to do |format| format.html { redirect_to(boat_cover_image_names_url) } format.xml { head :ok } end end
[ "def destroy\n @boat_cover_image_uid = BoatCoverImageUid.find(params[:id])\n @boat_cover_image_uid.destroy\n\n respond_to do |format|\n format.html { redirect_to(boat_cover_image_uids_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @cover_image_name = CoverImageName.find(p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /subscription_lists GET /subscription_lists.json
def index @subscription_lists = SubscriptionList.all end
[ "def get_subscription_list(options = {})\n options = argument_cleaner(required_params: %i( subscriberid ), optional_params: %i( entityid ), options: options )\n authenticated_get cmd: \"getsubscriptionlist\", **options\n end", "def list_subscriptions(list_id)\n get(\"contactList/#{...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /subscription_lists/1 DELETE /subscription_lists/1.json
def destroy @subscription_list.destroy respond_to do |format| format.html { redirect_to subscription_lists_url, notice: 'La Lista de Entrega se borró exitosamente.' } format.json { head :no_content } end end
[ "def delete_list(list)\n api_delete(:list, {:list => list})\n end", "def destroy\n @sub_list.destroy\n respond_to do |format|\n format.html { redirect_to sub_lists_url, notice: 'Sub list was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_list(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs the RPC server until a SIGINT signal.
def run raise 'Server has shutdown.' unless @server @server.run_till_terminated @server = nil end
[ "def sigint_handler(queue)\n exit unless server_process?\n return unless ready?\n\n queue.puts(SIGINT_MESSAGE)\n end", "def start_sigint_handler\n Signal.trap 'INT' do\n if self.interrupt_received\n exit 0\n else\n self.interrupt_received = true\n puts \"\\nInte...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
the creation of a custom node definition or use the 'default' node definition. ==== Attributes +master_certname+ Certificate name of Puppet master. +manifest+ A Puppet manifest to inject into the node definition. +node_def_name+ A node definition pattern or name. ==== Returns +string+ A combined manifest with node defi...
def create_site_pp(master_certname, manifest='', node_def_name='default') default_def = <<-MANIFEST node default { } MANIFEST node_def = <<-MANIFEST node #{node_def_name} { #{manifest} } MANIFEST if node_def_name != 'default' node_def = "#{default_def}\n#{node_def}" end site_pp = <<-MANIFEST filebucke...
[ "def create_site_pp(master_host, opts = {})\n opts[:manifest] ||= ''\n opts[:node_def_name] ||= 'default'\n master_certname = on(master_host, puppet('config print certname')).stdout.rstrip\n\n default_def = <<-MANIFEST\nnode default {\n}\nMANIFEST\n\n node_def = <<-MANIFEST\nnode #{opts[:no...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Read a Puppet manifest file and inject the content into a "default" node definition. (Used mostly to overide site.pp) ==== Attributes +manifest_path+ The file path to target manifest. +master_certname+ Certificate name of Puppet master. ==== Returns +string+ A combined manifest with node definition containg input manif...
def create_node_manifest(manifest_path, master_certname, node_def_name='default') manifest = File.read(manifest_path) site_pp = <<-MANIFEST filebucket { 'main': server => '#{master_certname}', path => false, } File { backup => 'main' } node default { #{manifest} } MANIFEST return site_pp end
[ "def create_site_pp(master_host, opts = {})\n opts[:manifest] ||= ''\n opts[:node_def_name] ||= 'default'\n master_certname = on(master_host, puppet('config print certname')).stdout.rstrip\n\n default_def = <<-MANIFEST\nnode default {\n}\nMANIFEST\n\n node_def = <<-MANIFEST\nnode #{opts[:no...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }