query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Paste data from clipboard into text_area and update documents in destination database. This action is called twice. First time for displaying text_area field and second time ajax call for processing data.
def paste_clipboard # Only administrators can perform this operation return render(text: t('drgcms.not_authorized') ) unless dc_user_has_role('admin') result = '' respond_to do |format| # just open new window to same url and come back with html request format.html { return render('paste_clipboard', layout: 'cms') } format.json { table, id, ids = nil params[:data].split("\n").each do |line| line.chomp! next if line.size < 5 # empty line. Skip begin if line[0] == '[' # id(s) result << "<br>#{line}" line = line[/\[(.*?)\]/, 1] # just what is between [] table, id, ids = line.split(',') elsif line[0] == '{' # document data result << process_document(line, table, id, ids) end rescue Exception => e result << " Runtime error. #{e.message}\n" break end end } end dc_render_ajax(div: 'result', value: result ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paste_clipboard\r\n # Only administrators can perform this operation\r\n return render(plain: t('drgcms.not_authorized') ) unless dc_user_can(DcPermission::CAN_ADMIN,'dc_site')\r\n\r\n result = ''\r\n respond_to do |format|\r\n # just open new window to same url and come back with html request\r\n f...
[ "0.6940014", "0.6300451", "0.62851685", "0.6256926", "0.6134019", "0.60812545", "0.6001184", "0.5991647", "0.59278405", "0.5848881", "0.58273697", "0.57580703", "0.57208323", "0.56754756", "0.5573386", "0.55658126", "0.55145067", "0.5464325", "0.5414632", "0.5395405", "0.5368...
0.69390106
1
Update some anomalies in json data on paste_clipboard action.
def update_json(json, is_update=false) #:nodoc: result = {} json.each do |k,v| if v.class == Hash result[k] = v['$oid'] unless is_update #TODO Double check if unless works as expected elsif v.class == Array result[k] = [] v.each {|e| result[k] << update_json(e, is_update)} else result[k] = v end end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_clipboard_paste\n dat = if Wx::PLATFORM == \"WXMAC\" \n # XXX i feel dirty\n `pbpaste`\n else\n dobj=RawDataObject.new\n Wx::Clipboard.open {|clip| clip.fetch dobj}\n dobj.raw_data\n end\n\n self.gui_set_value(self.cur_pos, dat) if dat and da...
[ "0.6556504", "0.6266512", "0.6260949", "0.6010856", "0.5838971", "0.565641", "0.5603806", "0.5584658", "0.55414116", "0.5447438", "0.5418756", "0.5350992", "0.53120136", "0.5266666", "0.5259538", "0.5197974", "0.5162856", "0.51485205", "0.5080953", "0.5080953", "0.5080953", ...
0.0
-1
Processes one document. Subroutine of paste_clipboard.
def process_document(line, table, id, ids) if params[:do_update] == '1' doc = dc_find_document(table, id, ids) # document found. Update it and return if doc doc.update( update_json(ActiveSupport::JSON.decode(line), true) ) msg = dc_check_model(doc) return (msg ? " ERROR! #{msg}" : " UPDATE. OK.") end end # document will be added to collection if ids.to_s.size > 5 #TODO Add embedded document " NOT SUPPORTED YET!" else doc = table.classify.constantize.new( update_json(ActiveSupport::JSON.decode(line)) ) doc.save end msg = dc_check_model(doc) msg ? " ERROR! #{msg}" : " NEW. OK." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process!(document); end", "def migrate_document(document, dest)\n index = index_of_document(document)\n return if index.nil? or not dest.is_a? Notebook\n\n drag_stop\n Gtk::grab_remove(self)\n remove_document(document)\n\n dest.instance_eval do\n add_documen...
[ "0.6454161", "0.58620805", "0.5738688", "0.5667096", "0.56233996", "0.5582197", "0.55490196", "0.5460744", "0.54331607", "0.54311657", "0.5428034", "0.54224175", "0.5403478", "0.54030055", "0.5364919", "0.53569734", "0.5316535", "0.52958083", "0.52769715", "0.5230709", "0.523...
0.46077505
82
Clears all session data related to login.
def clear_login_data session[:edit_mode] = 0 session[:user_id] = nil session[:user_name] = nil session[:user_roles] = nil cookies.delete :remember_me end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_session\n @session = @login_info = nil\n end", "def clear_session\n\t\tsession[:email] = nil \n\t\tsession[:player_id] = nil\n\t\tsession[:admin] = nil\n\t\tsession[:login_time] = nil \n\tend", "def clear_any_logged_in_session\n if logged_in?\n session[:user] = nil\n session[:...
[ "0.8568118", "0.8056482", "0.78624153", "0.77697676", "0.7748444", "0.76843065", "0.7662799", "0.76477534", "0.7492621", "0.74533963", "0.74317443", "0.74027437", "0.74027437", "0.73829645", "0.7325849", "0.71922666", "0.71912503", "0.71812296", "0.7180784", "0.71724325", "0....
0.8069562
1
Fills session with data related to successful login.
def fill_login_data(user, remember_me) session[:user_id] = user.id session[:user_name] = user.name session[:edit_mode] = 0 session[:user_roles] = [] # special for SUPERADMIN sa = DcPolicyRole.find_by(system_name: 'superadmin') if sa and (role = user.dc_user_roles.find_by(dc_policy_role_id: sa.id)) session[:user_roles] << role.dc_policy_role_id session[:edit_mode] = 2 return end # read default policy from site default_policy = dc_get_site().dc_policies.find_by(is_default: true) # load user roles user.dc_user_roles.each do |role| next unless role.active next if role.valid_from and role.valid_from > Time.now.end_of_day.to_date next if role.valid_to and role.valid_to < Time.now.to_date # check if role is active in this site policy_role = default_policy.dc_policy_rules.find_by(dc_policy_role_id: role.dc_policy_role_id) next unless policy_role # set edit_mode # session[:edit_mode] = 1 if policy_role.has_cms_menu session[:edit_mode] = 1 if policy_role.permission > 1 session[:user_roles] << role.dc_policy_role_id end # Add default guest role if no role set # This was previously in dc_user_can. I belive it should be here. #TODO This might not be the best idea. Check in the future. if session[:user_roles].size == 0 guest = DcUserRole.find_by(:system_name => 'guest') session[:user_roles] << guest.id if guest end # Save remember me cookie if not CMS user and remember me is selected if session[:edit_mode] == 0 and remember_me cookies.signed[:remember_me] = { :value => user.id, :expires => 180.days.from_now} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_session\n\t #no idea why I need this, but login form seems to break otherwise\n\t session[:email] = session[:email]\n\t session[:password] = session[:password]\n\t end", "def login\n # delete the session from their last login attempt if still there\n session.delete(:auth) unless s...
[ "0.7181392", "0.682048", "0.6730298", "0.6672402", "0.6672402", "0.6549236", "0.64867586", "0.64846075", "0.6483432", "0.64822835", "0.64597243", "0.6448087", "0.6446174", "0.64352417", "0.63875884", "0.63813376", "0.6333131", "0.6320547", "0.6310362", "0.6299219", "0.6297992...
0.0
-1
Initializes various variables when a new Crawler object is instantiated
def initialize(site) puts "Rcrawl Version #{VERSION} initializing..." @links_to_visit = Array.new @visited_links = Array.new @external_links = Array.new @raw_html = Hash.new @rules = RobotRules.new('Rcrawl') @user_agent = "Rcrawl/#{VERSION} (http://rubyforge.org/projects/rcrawl/)" @sites = Hash.new @errors = Hash.new @meta = Hash.new @site = URI.parse(site) || raise("You didn't give me a site to crawl") @links_to_visit << site puts "Ready to crawl #{site}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(title, url) # from first scrape data initialize == Lifecycle method in Ruby\n @title = title\n @url = url\n @@all << self if @@all.none?(self)\n end", "def initialize (params = {})\t\t\n\t\t@verbose=params.fetch(:verbose, false)\n\t\t@http_timeout=params.fetch(:http_timeout, 5000)\n\t\t@...
[ "0.7178817", "0.71490777", "0.709987", "0.6904131", "0.67465186", "0.66765857", "0.6645099", "0.6625878", "0.656214", "0.653998", "0.65359765", "0.65270984", "0.6518336", "0.65163743", "0.65112466", "0.6502881", "0.64959514", "0.6487032", "0.6482146", "0.64784795", "0.6458494...
0.72382843
0
Coordinates the whole crawling process
def crawl until @links_to_visit.empty? do begin # Get link url_server next unless robot_safe? @url if @url.include? '#' print "... Anchor link found, skipping..." next end # Parse robots.txt, then download document if robot_safe fetch_http(@url) # Store raw HTML in variable to read/reread as needed # Then call any processing modules you need for the current document ris(@document) rescue puts "" puts "I died on #{@url}" $stderr.puts $! @errors[@url] = $! next ensure # Stuff you want to make sure gets printed out puts " done!" end end puts "Visited #{@visited_links.size} links." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crawl\n recursive_explore([@origin_url],1)\n end", "def run\n getPage\n getLocations\n printLocations\n end", "def crawl\n if not @crawling\n @completed = false\n @located_products = []\n \n @thread = Thread.new { \n traverse(@base_u...
[ "0.62187535", "0.60555804", "0.60081893", "0.5854296", "0.5789269", "0.576842", "0.57567817", "0.57545316", "0.56965464", "0.5645524", "0.5638336", "0.56190753", "0.5605434", "0.5588099", "0.55690336", "0.55631924", "0.5541345", "0.5541345", "0.54846895", "0.5465554", "0.5440...
0.5527353
18
Authoritative list of URLs to be processed by Rcrawl
def url_server unless @links_to_visit.empty? @url = @links_to_visit.pop end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def urls\n (url.split(\",\") rescue []) + [cran_url]\n end", "def urls\n @urls ||= extract_urls('url')\n end", "def urls\n each_url.to_set\n end", "def urls\n @urls ||= all_urls(sitemap)\n end", "def all_urls\n urls = NG_URL.all.collect {|n| n.url}\n urls.sort!\n end", "def...
[ "0.753609", "0.7512041", "0.7365178", "0.7319558", "0.70718795", "0.69079643", "0.6902058", "0.6862422", "0.68256235", "0.6758606", "0.6742965", "0.6725288", "0.6719128", "0.6669686", "0.66685915", "0.6663371", "0.6606148", "0.6563594", "0.6552189", "0.6527387", "0.6510926", ...
0.0
-1
Rewind Input Stream, for storing and reading of raw HTML
def ris(document) print "." # Store raw HTML into local variable # Based on MIME type, invoke the proper processing modules case document.content_type when "text/html" link_extractor(document) process_html(document) page_meta(document) else print "... not HTML, skipping..." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rewind!\n io.rewind\n end", "def rewind\n io.rewind\n end", "def rewind\n file_handle.rewind\n file_handle.gets # skip past header\n nil\n end", "def rewind\n r = @io.rewind\n @buffer = ''\n r\n end", "def read(input)\n Extractor.input_ca...
[ "0.62076455", "0.6198451", "0.6188288", "0.6146501", "0.5969952", "0.5936916", "0.5858021", "0.5824216", "0.5824216", "0.5824216", "0.5824216", "0.580384", "0.5760445", "0.57491976", "0.57135445", "0.57079893", "0.5705736", "0.5704819", "0.56996053", "0.56901866", "0.56901866...
0.0
-1
HTML processing module for extracting links
def link_extractor(document) print "." # Parse all links from HTML into an array # Set up the scrAPI (http://labnotes.org) links = Scraper.define do array :urls process "a[href]", :urls => "@href" result :urls end urls = links.scrape(document) urls.each { |url| uri = URI.parse(url) # Derelativeize links if necessary if uri.relative? url = @site.merge(url).to_s uri = URI.parse(url) end # Check domain, if in same domain, keep link, else trash it if uri.host != @site.host @external_links << url @external_links.uniq! next end # Find out if we've seen this link already if (@visited_links.include? url) || (@links_to_visit.include? url) next end @links_to_visit << url } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_anchor_tags(html)\n content = Nokogiri::HTML::DocumentFragment.parse(html)\n anchors = content.css(\"a[href]\")\n anchors.each do |item|\n if processable_link?(item)\n add_target_blank_attribute(item)\n add_rel_attributes(item)\n add_css_cl...
[ "0.74354184", "0.74105966", "0.73053753", "0.727113", "0.727113", "0.727113", "0.702365", "0.70177704", "0.70006067", "0.69689614", "0.69501626", "0.6882448", "0.6838537", "0.6778576", "0.6771203", "0.67581487", "0.6747276", "0.6723644", "0.66953576", "0.66859794", "0.6667067...
0.6877886
12
HTML processing module for raw HTML storage
def process_html(document) # Add link and raw HTML to a hash as key/value # for later storage in database unless @raw_html.has_value?(document) print "." @raw_html[@document.base_uri.to_s] = document end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_parser; end", "def html_markup_html(text); end", "def html_markup_textile(text); end", "def preprocess!\n input_html\n nil\n end", "def content_from(html, url)\n \n def extract_pre_from(html)\n regex = /<pre.*?>.*?<\\/pre>/m\n pre_list = html.scan regex\n html.gsu...
[ "0.72275674", "0.7037976", "0.6898776", "0.6856065", "0.6822643", "0.67134655", "0.67065716", "0.66989154", "0.66362983", "0.6617293", "0.66110164", "0.65809214", "0.65735453", "0.6573088", "0.65580565", "0.65563947", "0.65555423", "0.65246415", "0.65094733", "0.6453285", "0....
0.7170976
1
we need a place to store some metadata, it needed for :apply_once and versioning
def marks_dir dir "/tmp/marks" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metadata=(_); end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata; end", "def metadata\n @metadata ||= {}\n end", "def metadata=(_arg0); end", "def metadata\n @metadata ||= {}\n end...
[ "0.7778093", "0.7708252", "0.7708252", "0.7708252", "0.7708252", "0.7708252", "0.7708252", "0.7708252", "0.7504455", "0.7282838", "0.7217583", "0.71995866", "0.71995866", "0.7145831", "0.6879168", "0.68028706", "0.6786339", "0.6771308", "0.6762995", "0.6750898", "0.6750898", ...
0.0
-1
find_followers method is a way of getting an array of all the followers to use in other methods
def find_followers bloodoath_cults = BloodOath.all.select do |bloodoath_instance| bloodoath_instance.cult == self end bloodoath_cults.map do |cult| cult.follower end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def followers\n list = service.find_followers(user).map {|data| build_object(data)}\n followers = list.map {|follower| follower.login}\n end", "def get_all_followers\n followers = []\n self.follower_ids.each do |id|\n unless Person.find_by_twitter_id(id).nil?\n followers << Person.find_b...
[ "0.84282106", "0.8039795", "0.79742193", "0.7815741", "0.77850556", "0.77472174", "0.77142555", "0.7689529", "0.7676293", "0.76397306", "0.76339966", "0.7622467", "0.7615512", "0.75408906", "0.75274915", "0.75239307", "0.7515676", "0.7493646", "0.7436206", "0.7430507", "0.742...
0.684728
63
GET /resource Lists all records for an invoice.
def index filter_params = params["#{model.name.underscore}_filter"].try(:first) @records = process_filters(model, filter_params) # page resources if the request is for html. For JSON and XML we will # return the entire recordset @records = @records.page(get_page) respond_with(@records) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invoices\n @invoices ||= new_resource(self, :invoice, :invoices)\n end", "def index\n @invoices = Invoice.all\n end", "def index\n @invoices = Invoice.all\n end", "def index\n @invoices = Invoice.all\n end", "def index\n @invoices = Invoice.all\n end", "def index\n @invoice...
[ "0.6929624", "0.67074436", "0.67074436", "0.67074436", "0.67074436", "0.67074436", "0.67074436", "0.67074436", "0.67074436", "0.67074436", "0.6649003", "0.6635887", "0.659044", "0.64210886", "0.638531", "0.63782907", "0.63680494", "0.63589543", "0.6334913", "0.630763", "0.630...
0.0
-1
GET /resource/new Renders new form for a given resource.
def new @record = model.new # call before actions created in the DSL if resource.before_actions[:new] resource.before_actions[:new].call(@record) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @resource = Resource.new\n respond_to do |format|\n format.html {render action: :new} # new.html.erb\n format.json { render json: @resource }\n end\n end", "def new\n @resource = Resource.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml {...
[ "0.83946455", "0.8377171", "0.83353156", "0.83353156", "0.83353156", "0.8201608", "0.8201608", "0.80742204", "0.7988833", "0.7868805", "0.7811344", "0.78016216", "0.77994597", "0.76069725", "0.75253797", "0.7460319", "0.7458082", "0.740963", "0.73679894", "0.7352423", "0.7352...
0.0
-1
POST /resource Creates a new resource record if valid, renders new form if not.
def create @record = model.new(record_params) # call before actions created in the DSL if resource.before_actions[:create] resource.before_actions[:create].call(@record) end if @record.save redirect_to polymorphic_path([app_kit, @record]) else puts @record.errors.full_messages.inspect render 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @resource = Resource.new(params[:resource])\n\n if @resource.save\n flash[:notice] = 'Resource was successfully created.'\n redirect_to @resource\n else\n render :action => \"new\"\n end\n end", "def create\n @resource = Resource.new(params[:resource])\n \...
[ "0.8001278", "0.7871537", "0.77772963", "0.77472854", "0.7677641", "0.751872", "0.7480964", "0.74090236", "0.7389203", "0.73819405", "0.73690444", "0.7322071", "0.7269238", "0.72418463", "0.72392714", "0.722324", "0.71908724", "0.71668154", "0.7114352", "0.70960605", "0.70873...
0.0
-1
GET /resource/:id Shows the details of a given resource.
def show instance_exec(&resource.before_actions[:show]) if resource.before_actions[:show] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @resource = Resource.find(params[:id])\n end", "def show\n @resource = Resource.find(params[:id])\n render json: @resource, status: 200\n end", "def show\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.js...
[ "0.8344011", "0.8089747", "0.7892635", "0.7892635", "0.7863478", "0.7803588", "0.77688307", "0.7751274", "0.77166134", "0.7705468", "0.75930876", "0.75930876", "0.75930876", "0.75930876", "0.7563204", "0.75505793", "0.74804467", "0.73774374", "0.73635393", "0.7337798", "0.721...
0.0
-1
GET /resource/:id/edit Shows the edit form for a given resource.
def edit resource.before_actions[:edit].call(@record) if resource.before_actions[:edit] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n respond_with(resource)\n end", "def edit\n @resource = Resource.find(params[:id])\n \n respond_to do |format|\n # format.html { render :layout => false }\n format.html\n format.any(:xml, :json) { render request.format.to_sym => @resource }\n end\n end", "def edit\...
[ "0.81530017", "0.80632085", "0.7988659", "0.76717377", "0.7587856", "0.74893147", "0.734522", "0.73220915", "0.70905155", "0.7080319", "0.7054478", "0.7025939", "0.70181113", "0.7002776", "0.6987925", "0.6958665", "0.6958578", "0.6944532", "0.6944532", "0.6944532", "0.6943242...
0.7123236
8
PATCH /resource/:id Updates a given resource if valid, renders the edit form if not.
def update flash[:success] = "Record updated successfully." # call before actions created in the DSL if resource.before_actions[:update] resource.before_actions[:update].call(@record) end if @record.update(record_params) redirect_to polymorphic_path([app_kit, @record]) else render 'edit' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @resource = Resource.find(params[:id])\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren...
[ "0.7944114", "0.7944114", "0.77376175", "0.7732011", "0.7689528", "0.7689528", "0.7688384", "0.7648771", "0.7583841", "0.7541427", "0.75396734", "0.7493346", "0.74921936", "0.74921936", "0.7474121", "0.74263287", "0.73892045", "0.7380047", "0.73798347", "0.73692834", "0.72600...
0.0
-1
DELETE /resource/:id Deletes a given resource and redirects to index.
def destroy if @record.destroy flash[:success] = "Record deleted successfully." redirect_to polymorphic_path([app_kit, model]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to...
[ "0.787997", "0.787997", "0.787997", "0.787997", "0.78293556", "0.7810878", "0.7810878", "0.7810878", "0.77103215", "0.756483", "0.75303745", "0.7520097", "0.7520097", "0.7463083", "0.74271554", "0.7335851", "0.7293264", "0.7270342", "0.7270342", "0.7270342", "0.7270342", "0...
0.0
-1
GET /resource/:id/:action_name A catchall action for any custom actions defined in the DSL. The action name is passed by the route as a param and a block given in the DSL is called (with the record instance). Actions can be defined using blocks are a symbol name of a method in the model.
def perform_action action_name = params[:action_name].to_sym action = resource.member_actions[action_name] if action.is_method_action? @record.send(action.method_name) end if action.is_block_action? action.block.call(@record) end return redirect_to([app_kit, @record]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action(name, &block)\n action = Moonrope::Action.new(@controller, name)\n action.dsl.instance_eval(&block) if block_given?\n @controller.actions[name] = action\n action\n end", "def action(method, route, &block)\n @actions << [method.to_s, build_route(@with * \"/\" + route...
[ "0.71991855", "0.67685616", "0.65737814", "0.65059793", "0.64639795", "0.6398905", "0.6396041", "0.6387927", "0.62770796", "0.62770796", "0.62753904", "0.6228625", "0.61968166", "0.61686945", "0.6122601", "0.61145", "0.60955393", "0.6072529", "0.6015088", "0.6015088", "0.6015...
0.6447129
5
Whitelisting for all fields marked as +editable+ in the dsl.
def record_params fields = resource.editable_fields.map(&:name) params.require(model.model_name.param_key.underscore.to_sym).permit(fields) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fields_need_editing(obj) \n \teditable_fields(obj).select {|k,v| v == true }\n end", "def editable_fields(obj)\n \tobj.attributes.select {|key| key.start_with? \"need_to_edit_\"}\n end", "def ensure_editable; return false unless editable? end", "def is_not_editable!\n update_attribute :is_editable, fa...
[ "0.7276025", "0.7209332", "0.6696453", "0.64862096", "0.6436252", "0.6381625", "0.62937015", "0.6201889", "0.6183682", "0.6165825", "0.6144892", "0.6139132", "0.6139132", "0.6139132", "0.60667497", "0.6063348", "0.6060603", "0.6007224", "0.59708637", "0.5936698", "0.5869888",...
0.0
-1
A generic before_action method to set an instance variable for the current record.
def find_record @record ||= model.find_by_id(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_controller_object context\n if action_name == 'edit' || action_name == 'destroy' || action_name == 'update'\n super\n else\n @student ||= begin\n id = params[find_first_parent.is_a?(Student) ? :student_id : :id ]\n Student.find(id)\n end\n @test_score = TestScore.ne...
[ "0.6095011", "0.6002556", "0.58737755", "0.58520097", "0.5793733", "0.5775685", "0.5732505", "0.57300466", "0.57300466", "0.5727094", "0.5672847", "0.5664108", "0.5664108", "0.5664108", "0.5664108", "0.5664108", "0.5664108", "0.56483215", "0.55832434", "0.5570724", "0.5561645...
0.0
-1
A helper method that returns the AppKit::Resource object tied to the current controller.
def resource self.class.resource end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_resource_to_use\n return @resources.first\n end", "def resource\n instance_variable_get(resource_name) || params[:id] && set_resource(controller_model.find(params[:id]))\n end", "def current_resource\n @current_resource ||= @item\n end", "def resource\n return @resource\n ...
[ "0.70348805", "0.6945915", "0.6910271", "0.67771924", "0.67771924", "0.67771924", "0.67771924", "0.67771924", "0.67771924", "0.67329735", "0.6724415", "0.6724227", "0.6724227", "0.6724013", "0.67166543", "0.66663843", "0.66630954", "0.6624227", "0.6596519", "0.6590118", "0.65...
0.6864856
3
A helper method to retrieve the model classs based on the current controller's class name.
def model @model ||= resource.model end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def model_class\n @model_class ||= controller_path.classify.constantize\n end", "def model\n\t\tObject.const_get(controller_name.classify)\n\tend", "def model\n controller_name.classify.constantize\n end", "def model_klass\n controller_name.classify.constantize\n end", "def mode...
[ "0.7949385", "0.78231573", "0.7802869", "0.7772767", "0.7616944", "0.76159006", "0.747919", "0.74691695", "0.74691695", "0.7464456", "0.7413922", "0.74115515", "0.73858213", "0.73046136", "0.7235639", "0.721952", "0.7215014", "0.7201145", "0.71951294", "0.71559626", "0.714807...
0.0
-1
helper method to resolve the url for forms, between edit and new
def form_url(record) if has_namespace? [app_kit, model.name.deconstantize.underscore.to_sym, record] else [app_kit, record] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_form_url\n if params[:firm_id]\n @information[:form_url] = firm_trade_path(@parent, @trade)\n @information[:back_path] = firm_path(@parent)\n elsif params[:product_id]\n @information[:form_url] = product_trade_path(@parent, @trade)\n @information[:back_path] = product...
[ "0.7248085", "0.6922437", "0.6794932", "0.6480749", "0.6380478", "0.6303315", "0.62862873", "0.6261315", "0.6220261", "0.62176377", "0.62161535", "0.61732805", "0.61220753", "0.6101607", "0.60459787", "0.59946734", "0.59738326", "0.59689283", "0.5966618", "0.59653884", "0.594...
0.6226147
8
A helper method to display the current resource name.
def resource_name controller_name.humanize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_name\n current_definition.resource_name\n end", "def resource_name\n @resource_name ||= plural_name\n end", "def resource_name\n @resource_name ||= get_resource_name\n end", "def resource_name\n return @resource_name\n end", "de...
[ "0.7829923", "0.7779805", "0.7727322", "0.762417", "0.762417", "0.762417", "0.7577831", "0.75712234", "0.7522107", "0.7501367", "0.74937254", "0.7473984", "0.7470612", "0.7434005", "0.7431524", "0.7431524", "0.7400592", "0.73914146", "0.73914146", "0.7386099", "0.7386099", ...
0.7400736
16
handles record filtering passed by the filter panel
def process_filters(records,filter_params) return records unless filter_params filter_params.each do |field,filter_param| if filter_param.has_key?("value") value = filter_param["value"] next unless value.present? condition = filter_param["condition"] || 'eq' case condition when "eq" value = true if value == 'true' value = [false, nil] if value == 'false' records = records.where(field.to_sym => value) when "cont" records = records.where("#{field} LIKE '%#{value}%'") when "ncont" records = records.where("#{field} NOT LIKE '%#{value}%'") when "gt" records = records.where("#{field} > ?", value) when "lt" records = records.where("#{field} < ?", value) end end end return records end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter(record)\n true\n end", "def filter\n end", "def apply_filter\n end", "def filters\n end", "def filters; end", "def filters; end", "def Filter=(arg0)", "def filter\n @filter\n end", "def filter; end", "def filter; end", "def filter; end", "def filters=(_arg0); end",...
[ "0.7283907", "0.7018895", "0.6920807", "0.6869866", "0.67705315", "0.67705315", "0.6573756", "0.6464857", "0.645357", "0.645357", "0.645357", "0.6358367", "0.6358367", "0.62640107", "0.622986", "0.6165329", "0.614962", "0.61202306", "0.61147594", "0.61147594", "0.61136955", ...
0.6388001
11
METHODE SUR LA PYRAMIDE
def full_pyramid #On salut notre visiteur puts "Salut, bienvenue dans ma super pyramide ! Combien d'etages veux-tu ?" print "> " #On demande le nombre d'étages steps = gets.chomp.to_i #On affiche la pyramide puts "Voici la pyramide :" steps.times do |i| puts " " * (steps - ( i + 1 )) + "#" * ( 2 * i + 1) + " " * (steps - ( i + 1 )) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def omega() \r\n # delta_equinox()[ 3 ]\r\n Celes.faom03(@ta) \r\n end", "def bradypode_paracephalus()\n end", "def mo_Earth() \r\n# [ -0.0000000434, -0.000000576, 0.00200340, \r\n# -0.0001831, -46.836769, 84381.406 ].inject(0.0) {|p, a| p * @ta + a} * DAS2R\r\n Celes.obl06(...
[ "0.6433862", "0.63774604", "0.611768", "0.59624994", "0.58883876", "0.5875904", "0.5850625", "0.57859325", "0.57650757", "0.5754465", "0.5752421", "0.5748166", "0.5733992", "0.57115173", "0.5692534", "0.5646327", "0.5612971", "0.5604526", "0.5581214", "0.55786115", "0.5544658...
0.0
-1
METHODE SUR LE LOSANGE
def wtf_pyramid #On salut notre visiteur puts "Salut, bienvenue dans ma super pyramide ! Combien d'etages veux-tu ?" print "> " #On demande le nombre d'étages steps = gets.chomp.to_i #On teste si le nombre est pair if steps % 2 != 0 #S'il est impair, on affiche la pyramide puts "Voici la pyramide :" steps.times do |i| #Partie haute du losange if i < steps / 2 puts " " * (steps - ( i + 1 )) + "#" * ( 2 * i + 1) + " " * (steps - ( i + 1 )) #Partie basse du losange else puts " " * i + "#" * (2 *steps - (2 *i + 1)) + " " * i end end #S'il est pair, on envoie l'utilisateur bouler else puts "NON NON! Tu dois saisir un nombre impair, donc tu dégages et tu relances le programme !" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gml_Sun() \r\n #total = [ 1.0/-19880000.0, 1.0/-152990.0, 1.0/499310.0,\r\n #\t\t 0.0003032028, 36000.76982779, 280.4664567 ] \r\n # mod_360(total.inject(0.0) {|p, a| p * @ta + a}) * D2R\r\n ml(@ta)\r\n end", "def omega() \r\n # delta_equinox()[ 3 ]\r\n Celes.faom03(@ta) \r\n e...
[ "0.62021905", "0.6001425", "0.599777", "0.575671", "0.57272774", "0.5725249", "0.57087594", "0.5695702", "0.56768763", "0.56428194", "0.5630614", "0.55977595", "0.5592741", "0.55814606", "0.555696", "0.5552175", "0.55311406", "0.5514243", "0.55119264", "0.5494177", "0.5484732...
0.0
-1
this function check if user didn't complete his profile and show a red warning on the top of the page exept in the edit user page and adding details page rubocop:disable Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity
def checkaccount(user) return unless user link = user.service if (link == 'Both' && !user.sel_detail && !current_page?('/both_details/new') && !current_page?("/users/edit.#{user.id}")) || (link == 'customer' && !user.cus_detail && !current_page?('/cus_details/new') && !current_page?("/users/edit.#{user.id}")) render 'layouts/checkaccount' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def completed_profile\n if user_signed_in?\n if (current_user.soi_number.blank? || current_user.phone_number.blank? || current_user.diploma.blank?)\n redirect_to edit_user_path(current_user), alert: \"Votre profil doit être complété\"\n end\n end\n end", "def confirm!\n # add if else h...
[ "0.73241484", "0.7171193", "0.70734787", "0.69517475", "0.6765289", "0.6620307", "0.65615195", "0.6508264", "0.648597", "0.6478431", "0.6460957", "0.64560604", "0.6445923", "0.64417803", "0.64356035", "0.6406159", "0.6400417", "0.6363789", "0.63624805", "0.63624364", "0.63567...
0.6099234
53
Allows config options to be read like a hash
def [](option) send(option) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configuration_from_options(options); end", "def config\n options.to_smash.deep_merge(opts.to_smash)\n end", "def config\n options.to_smash.deep_merge(opts.to_smash)\n end", "def options\n Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end", "def opt...
[ "0.7428699", "0.7322754", "0.7322754", "0.71972054", "0.71972054", "0.7061942", "0.7031077", "0.7031077", "0.70282495", "0.69660544", "0.69483906", "0.6948274", "0.6910803", "0.68589896", "0.6834923", "0.67487586", "0.66545624", "0.66460735", "0.66447747", "0.6629105", "0.659...
0.0
-1
Returns a hash of all configurable options
def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option.name.to_sym => option.value})\n end\n opts\n end", "def options\n Hash[ *Configuration::VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]\n end", "def options\n Hash[ * VALID_CONF...
[ "0.81051826", "0.79412043", "0.7936926", "0.7936926", "0.79214734", "0.76402825", "0.7612969", "0.75011855", "0.7470861", "0.7470861", "0.7449152", "0.7343231", "0.72712165", "0.72595704", "0.7201305", "0.7170099", "0.71684414", "0.7116154", "0.7044288", "0.7044288", "0.70442...
0.70420045
26
Returns a hash of all configurable options merged with +hash+
def merge(hash) to_hash.merge(hash) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_options!(hash)\n hash.merge!(@options)\n end", "def options\n opts = {}\n self.configuration_options.each do |option|\n opts.merge!({option.name.to_sym => option.value})\n end\n opts\n end", "def options(hash)\n @options.merge! hash\n end", "def config\n opt...
[ "0.7066515", "0.7010312", "0.69971776", "0.68802094", "0.68802094", "0.68278396", "0.68278396", "0.67177135", "0.671008", "0.65878105", "0.65763277", "0.6574067", "0.64783263", "0.64783263", "0.6456929", "0.6450672", "0.64291453", "0.6426914", "0.6426914", "0.6426914", "0.642...
0.0
-1
Tests that instructor is not linked to any courses in the semester and returns true or false.
def can_be_deleted? !has_courses? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CA_only?\n course_assistant? && (not instructor?)\n end", "def ensure_not_referenced_by_any_course\n if courses.empty?\n return true\n else\n errors.add(:base, 'Courses present')\n return false\n end\n end", "def CA_only?\n course_assistant? && !instructor?\n ...
[ "0.73541886", "0.7337089", "0.71748334", "0.7002359", "0.68986166", "0.6887246", "0.68693465", "0.6683787", "0.66521895", "0.66521895", "0.66248304", "0.6586162", "0.6479973", "0.6479973", "0.6428055", "0.6418216", "0.63731784", "0.6359968", "0.6353222", "0.6328268", "0.62843...
0.60180664
42
Returns last_name, first_name or just first_name if no last_name exists
def full_name_last_first return self.first_name unless (self.last_name.length > 0) return (self.last_name + ", " + self.first_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_full_name\n [first_name, last_name].select(&:present?).join(' ')\n end", "def full_name_first_last\n return self.first_name unless (self.last_name.length > 0)\n return (self.first_name + \" \" + self.last_name)\n end", "def full_name\n if first_name.blank?\n last_name\n else\n ...
[ "0.82630426", "0.8230351", "0.8187526", "0.8098964", "0.80962664", "0.794671", "0.79358965", "0.79339486", "0.7903188", "0.7893612", "0.7880249", "0.7859064", "0.7847392", "0.7846149", "0.7835837", "0.7759763", "0.77378917", "0.77253187", "0.7711071", "0.7708167", "0.7700223"...
0.8495747
0
Returns first_name, last_name or just first_name if no last_name exists
def full_name_first_last return self.first_name unless (self.last_name.length > 0) return (self.first_name + " " + self.last_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_name_last_first\n return self.first_name unless (self.last_name.length > 0)\n return (self.last_name + \", \" + self.first_name)\n end", "def get_full_name\n [first_name, last_name].select(&:present?).join(' ')\n end", "def full_name\n if first_name.blank?\n last_name\n else\n ...
[ "0.84432447", "0.8328628", "0.81748474", "0.8164338", "0.81598985", "0.7848116", "0.78479123", "0.7814771", "0.78054965", "0.7801327", "0.7771904", "0.7745265", "0.7733534", "0.77279496", "0.7683226", "0.76826966", "0.7671234", "0.76451296", "0.76350147", "0.76350147", "0.763...
0.81253034
5
"Sand", "Water", "Fish", and "Sun" appear without overlapping (regardless of the case). Examples sum_of_a_beach("WAtErSlIde") ==> 1 sum_of_a_beach("GolDeNSanDyWateRyBeaChSuNN") ==> 3 sum_of_a_beach("gOfIshsunesunFiSh") ==> 4 sum_of_a_beach("cItYTowNcARShoW") ==> 0
def sum_of_a_beach (beach) (beach.scan(/sand|water|fish|sun/i) || []).length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_jewels_in_stones(j, s)\n hash_table = {}\n (0..s.length-1).each do |i|\n if hash_table.include? s[i]\n hash_table[s[i]] = hash_table[s[i]] + 1\n else\n hash_table[s[i]] = 1\n end\n end\n\n count = 0\n (0..j.length-1).each do |i|\n if hash_table.include? (j[i])\n if hash_tabl...
[ "0.60254127", "0.6016107", "0.59957707", "0.5989535", "0.5769685", "0.57247835", "0.5718512", "0.57029873", "0.57012963", "0.56898737", "0.5672843", "0.565716", "0.5641401", "0.5635661", "0.55931747", "0.5568826", "0.55572534", "0.55544806", "0.5545501", "0.5528204", "0.55245...
0.6820596
0
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.contact_mailer.contact_me.subject
def contact_me(params) @params = params @greeting = "Hi" #mail to: "to@example.org" mail(:from => @params.personal_email,:to =>@params.personal_email, :subject => "- EJJE -Gracias Por tu ayuda") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_details(recipient))\n subject = \"#{I18n.t(\"#{recipient_type.to_s}_subject_#{alert_name.to_s}\", subject_variables)}\"\n subject\n end", "def message_subject=(value)\n ...
[ "0.7420738", "0.7318224", "0.7236737", "0.72360134", "0.7096663", "0.70165634", "0.68761426", "0.68317133", "0.6831157", "0.67721164", "0.6770582", "0.67114264", "0.67067504", "0.66979164", "0.6675767", "0.66593754", "0.66515046", "0.6641414", "0.6595883", "0.65678054", "0.65...
0.0
-1
here all actions on going to active you can run sql commands like this: results = ActiveRecord::Base.connection.execute(query); plugin: plugin model
def cama_external_menu_on_active(plugin) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute()\n\n end", "def execute()\n\n end", "def execute\n ActiveRecord::Base.connection.execute(source)\n end", "def execute()\r\n\tend", "def execute; end", "def execute; end", "def execute\n\n end", "def execute\n end", "def execute\n end", "def execute_sql\n Activ...
[ "0.70241666", "0.70241666", "0.700345", "0.69346076", "0.6863836", "0.6863836", "0.68599904", "0.6821906", "0.6821906", "0.67889315", "0.6739621", "0.67228895", "0.66985303", "0.66153866", "0.6525782", "0.6518682", "0.6518682", "0.6475485", "0.6459327", "0.64522785", "0.64313...
0.0
-1
here all actions on going to inactive plugin: plugin model
def cama_external_menu_on_inactive(plugin) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gallery_on_inactive(plugin)\n end", "def camaleon_spree_on_inactive(plugin)\n end", "def plugin\n\t\t\t\t\tPlugin.where(:id => Item.first.attributes[\"plugin_id\"])\n\t\t\t\tend", "def contact_form_on_inactive(plugin)\n\n end", "def plugin_manager; end", "def set_plugin\n @plugin = Plugin.fin...
[ "0.6669169", "0.6559678", "0.6381096", "0.6271562", "0.61708516", "0.60598594", "0.60571194", "0.60280657", "0.59986067", "0.59957856", "0.59957856", "0.59957856", "0.59957856", "0.59669757", "0.59572273", "0.592916", "0.59050167", "0.58284307", "0.5826014", "0.5793883", "0.5...
0.65550953
2
removed authentication; don't need it for public repositories
def send_request(uri, params, user, password) request = Net::HTTP::Get.new(uri) request.basic_auth(user, password) req_options = { use_ssl: uri.scheme == "https", } params.each_pair do |key, val| request[key] = val end response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(request) end return JSON.parse(response.body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def http_auth?; end", "def repo; end", "def repo; end", "def repo; end", "def repo; end", "def skip_authorization; end", "def project_unauthorized_proc\n # no-op\n end", "def repository; end", "def auth\n end", "def auth\n end", "def host_authorization; end", "def host_authorization; en...
[ "0.6540841", "0.6418639", "0.6418639", "0.6418639", "0.6418639", "0.6410345", "0.63189554", "0.62235415", "0.62200016", "0.62200016", "0.6134423", "0.6134423", "0.6072045", "0.60674673", "0.6064831", "0.6039415", "0.60346127", "0.60346127", "0.60346127", "0.60346127", "0.6034...
0.0
-1
2.Get all windmill id for a given wind Form.
def getmill formid = Windmill.where(windformid: params[:id]) if formid.present? render json: formid.as_json(only:[:no]) else render json: {massage: 'Windform not found'} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getform\n\tgetform = Windmill.where(no: params[:no])\n\tif getform.present?\n render json: getform.as_json(only: [:windformid])\n\telse\n\t\trender json: {massage: 'No windfrom available in this id'}\n\tend\nend", "def form_ids\n forms.collect{|f| f.id}.sort\n end", "def form_ids\n forms.collect...
[ "0.6425715", "0.6211666", "0.62067705", "0.60876197", "0.57503605", "0.55311996", "0.54089653", "0.537362", "0.53451985", "0.5297192", "0.5282358", "0.52794325", "0.5251241", "0.52483505", "0.52100426", "0.5203082", "0.51838595", "0.5178811", "0.51776016", "0.51733357", "0.51...
0.65941966
0
3.Get a location for a given wind mill id
def getlocation locafid = Windmill.where(no: params[:no]) if locafid.present? locafid = Windmill.find_by(no: params[:no]) render json: [locafid.as_json(only: [:no, :latitude, :londitude,:location])] else render json: {massage: 'windmill not found'} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def location(id)\n @client.get(\"/BikePoint/#{id}\")\n end", "def get_location(location)\n client = Weatherman::Client.new\n client.lookup_by_location(location)\nend", "def location\n fetch('rick_and_morty.locations')\n end", "def get_location(user_location)\n\tclient=Weatherman...
[ "0.67797107", "0.64473814", "0.6305792", "0.6266786", "0.6212447", "0.62123996", "0.61723906", "0.6151979", "0.6082059", "0.60444397", "0.60444397", "0.6038972", "0.59529644", "0.5952639", "0.5950307", "0.5947981", "0.5945268", "0.59133595", "0.59132504", "0.58959365", "0.585...
0.6326181
2
4.Get a wind form for a given wind mill id
def getform getform = Windmill.where(no: params[:no]) if getform.present? render json: getform.as_json(only: [:windformid]) else render json: {massage: 'No windfrom available in this id'} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getmill\n\tformid = Windmill.where(windformid: params[:id])\n\tif formid.present?\n render json: formid.as_json(only:[:no])\n\telse\n\t\trender json: {massage: 'Windform not found'}\n\tend\nend", "def form\n\tform = Windmill.all\n\t#form = Windmill.where(windformid: params[:id])\n\t#if form.present?\n...
[ "0.70188755", "0.69844186", "0.6163385", "0.6037567", "0.59459174", "0.59080905", "0.58822536", "0.58781534", "0.56679285", "0.56117207", "0.5533566", "0.54399055", "0.5417854", "0.5362818", "0.53531736", "0.533231", "0.5286203", "0.5242859", "0.5233617", "0.52308726", "0.523...
0.727166
0
it displays all the value for the given no
def form form = Windmill.all #form = Windmill.where(windformid: params[:id]) #if form.present? render json: form.as_json(only: [:no]) #else #render json: {massage: 'No windfrom available in this id'} # #end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display(number)\n display_each([number])\n end", "def show_all_values my_array\n puts \"\\nAll Values: \"\n puts \"-----------\"\n my_array.each do |value| \n puts \"Name: \" + value.get_name.to_s\n puts \" Area: \" + value.get_area.to_s\n puts \" Temperature: \" + value.get_tem...
[ "0.6501059", "0.6495188", "0.6407713", "0.6407713", "0.63913995", "0.6331037", "0.6119649", "0.61172926", "0.6095494", "0.60821795", "0.6061574", "0.6047005", "0.60405606", "0.60279125", "0.6002495", "0.5999851", "0.59909844", "0.5969238", "0.5961776", "0.5958758", "0.5945336...
0.0
-1
executes easy_install command with the passed arguments
def ezy_install(*args) easy_install *args rescue NoMethodError => e if pathname = which('easy_install') self.class.commands :easy_install => pathname easy_install *args else raise e end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dist_install_s( *args )\n if args.last.is_a?( Hash )\n args = args.dup\n opts = args.pop\n else\n opts = {}\n end\n\n args = dist_map_packages( args )\n\n if opts[ :succeed ]\n \"yum install -q -y #{args.join ' '} || true\"\n else\n \"yum install -q -y #{args.join ' '...
[ "0.68979686", "0.67946815", "0.6308114", "0.6296184", "0.62498754", "0.62241715", "0.6200244", "0.61983836", "0.61692244", "0.6168601", "0.6148906", "0.61445975", "0.6132253", "0.61254644", "0.61213946", "0.60783046", "0.60333896", "0.6031039", "0.6027059", "0.5995982", "0.59...
0.76981574
0
executes pip command with the passed arguments
def PiP(*args) pip *args rescue NoMethodError => e if pathname = which('pip') self.class.commands :pip => pathname pip *args else raise e end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pip_command\n %w(pipenv run pip)\n end", "def lazy_pip(*args)\n pip2 *args \n rescue NoMethodError => e\n self.class.commands :pip => pip2_cmd\n pip *args\n end", "def lazy_pip(*args)\n pip(*args)\n rescue NoMethodError => e\n if which(self.class.cmd)\n # @note From prov...
[ "0.6875272", "0.65148634", "0.62955606", "0.62605983", "0.62236756", "0.5959701", "0.5856561", "0.57957506", "0.5756658", "0.57522005", "0.57299125", "0.56577927", "0.55657095", "0.5563142", "0.5540965", "0.55380595", "0.5515961", "0.5505535", "0.547428", "0.5466009", "0.5457...
0.6454224
2
Use callbacks to share common setup or constraints between actions.
def set_appointment @appointment = Appointment.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def appointment_params params.require(:appointment).permit(:start_time, :end_time, :first_name, :last_name, :comments) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
ruby macro: creates getters and setters for the symbols listed.
def initialize(n='', i='', v='lampooning authority') # variadic @name = n @instrument = i @vice = v end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_getters\n instance_variables.each do |v|\n define_singleton_method(v.to_s.tr('@','')) do\n instance_variable_get(v)\n end\n end\n end", "def create_accessors!\n self.each do |key,val|\n create_accessor_for(key)\n end\n end", "def create_setters\n schema_field...
[ "0.7392179", "0.7259517", "0.70115954", "0.68677133", "0.67719114", "0.668616", "0.6665547", "0.66524863", "0.659165", "0.6499498", "0.6380969", "0.6320153", "0.6286636", "0.62355715", "0.6227264", "0.6183111", "0.61600566", "0.6125002", "0.612461", "0.6116803", "0.6110519", ...
0.0
-1
initializer method for CSVFile
def initialize(file_name: nil, file_extension: DefaultConstants::EXTENSION, convert: false, output: DefaultConstants::FILE_PATTERN) @file_name = file_name ### source file name (full path should be provided) @file_extension = file_extension ### file extension @data = [] ### file rows data @smart_convert = convert ### convert readed data in array of hashes with file headers keys - false by default @file_headers = nil ### file headers array @read_flag = false ### service flag @output = output ### write file name with extension end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(csv_in_filename)\n @in_file = csv_in_filename\n @csv_out_headers = nil\n @index = nil\n @csv_out_data = nil\n convert\n end", "def initialize(csv_source)\n @csv_source = csv_source\n end", "def initialize(csv_filename)\n LOGGER.info 'Konvertierung Commerzbank .csv-Ko...
[ "0.74810904", "0.7463454", "0.7332542", "0.7300936", "0.7221388", "0.72051495", "0.7198484", "0.7182711", "0.71602803", "0.70697606", "0.6987281", "0.69835466", "0.69002545", "0.6884036", "0.6871319", "0.6816416", "0.6797937", "0.6765835", "0.67487735", "0.67158645", "0.66580...
0.5912538
96
Show some useful info about working file
def info @encoding = find_enoding puts "INFO:" print 'File name '; print "#{@file_name}\n".colorize(:green) print 'File headers '; print "#{@file_headers}\n".colorize(:green) print 'File rows number '; print "#{@data.size}\n".colorize(:green) print 'File encoding '; print "#{@encoding}\n".colorize(:green) ## temp decision if @output_file_name print 'Output File '; print "#{@output_file_name || 'nil'}\n".colorize(:green) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def describe\n f = file!\n puts \"Current target: #{f.basename}\"\n puts '*' * 70\n File.open(f).each do |line|\n puts \" #{line}\"\n end\n puts '*' * 70\n end", "def describe\n f = file!\n puts \"Current environment: #{f.basename}\"\n ...
[ "0.7140719", "0.7116872", "0.67332524", "0.66440094", "0.66355795", "0.6399413", "0.6399413", "0.6352219", "0.6204606", "0.614999", "0.6129707", "0.60903585", "0.6085597", "0.60323995", "0.6001724", "0.60008115", "0.59845006", "0.5981177", "0.5955703", "0.5954945", "0.5945678...
0.6885069
2
Read dta from file Param :only can define limit of readed lines from file not implemented yet
def read return if @read_flag process_reading end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_dta_files(fh, num_files, unpack_35)\n dta_files = Array.new(num_files)\n start = dta_start_byte\n fh.pos = start\n\n header.num_dta_files.times do |i|\n dta_files[i] = Mspire::Sequest::Srf::Dta.from_io(fh, unpack_35) \n end\n dta_files\n end", "def read_data_file(path); end", "...
[ "0.6773155", "0.6330076", "0.6018883", "0.5952914", "0.58885807", "0.5849608", "0.5846505", "0.58419204", "0.5794437", "0.578502", "0.57768464", "0.57430184", "0.57319385", "0.57277215", "0.5713827", "0.57098323", "0.567283", "0.5653069", "0.5643832", "0.56415826", "0.5620287...
0.0
-1
Write data in file (named by pattern may be found in DefaultConstants::FILE_PATTERN) Will write data every time it calles to ensure that all current data writed in file may occurs duplicate if used more than once If data_to_write is array of hashes will use first hash keys as headers, else headers that provided by :header key in method call
def write(data_to_write:, headers: [], encoding: DefaultConstants::ENCODING) data_prepared, headers_prepared = prepare_data_for_writing(data_to_write, headers) begin process_writing(data_prepared, headers_prepared, encoding) puts "Writed in #{@output}".colorize(:cyan) rescue StandardError => e2 e2.message end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write data, path\n\t\t\tcontent = \"\"\n\t\t\tfile_type = data.class.to_s\n\n\t\t\tif file_type == 'Array'\n\t\t\t\tdata.each do | line |\n\t\t\t\t\tline.each do | key, val |\n\t\t\t\t\t\tcontent << \"#{key.to_s}=#{val}\\n\"\n\t\t\t\t\tend\n\t\t\t\t\tcontent << \"\\n\"\n\t\t\t\tend\n\n\t\t\telsif file_type == ...
[ "0.62339437", "0.6176751", "0.60550696", "0.60320926", "0.58295375", "0.5793967", "0.5793069", "0.57755715", "0.57734215", "0.57725453", "0.5715384", "0.5707582", "0.5707582", "0.5707582", "0.5707582", "0.56196207", "0.5612801", "0.55998194", "0.559728", "0.55437374", "0.5520...
0.60161734
4
Only for string row values will be improved to be able to handle more complex selecting like SQL does > multiple select
def select(opts = {}) return @data.select { |row| row[opts[:where]] =~ /#{opts[:like]}/ } if opts[:like] return @data.select { |row| row[opts[:where]] !~ /#{opts[:not_like]}/ } if opts[:not_like] @data.select { |row| row[opts[:where]] == opts[:equals] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_values\n value = nil\n assert_nothing_raised do\n value = ActiveRecord::Base.connection.send(:select_rows, \"VALUES('ur', 'doin', 'it', 'right')\")\n end\n assert_equal [['ur', 'doin', 'it', 'right']], value\n end", "def map_values(row, columns)\n values = columns.map do |v|\n ...
[ "0.6084503", "0.60602933", "0.5909822", "0.5886812", "0.5829639", "0.58140266", "0.57646626", "0.56675726", "0.5663689", "0.5651938", "0.5639019", "0.5573033", "0.5564032", "0.5547336", "0.5544435", "0.5531182", "0.5513427", "0.54980457", "0.54804426", "0.54800713", "0.545435...
0.50609624
78
Convert readed data to hash with headers keys Need to prevent reading only in one format and to give opportunity to choose data presentation
def smart_convert! if @file_headers.any? @data = @data.map { |d_arr| @file_headers.each_with_object({}).with_index { |(h_name, h_hash), ind| h_hash[h_name] = d_arr[ind] } } @smart_convert = true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def header_to_hash data\n header = {}\n data = data.split(@opts[:delimiter])\n self.req[\"Verb\"], self.req[\"Url\"], self.req[\"Version\"] = data.shift.split(\" \", 3)\n data.each do |line|\n k,v = line.split(\":\", 2)\n if !@opts[:header_bl] || !(HEADER_BLACKLIST.include? k)\n header...
[ "0.7607961", "0.6793278", "0.67569", "0.6631557", "0.6587677", "0.6570619", "0.6563308", "0.64562136", "0.6435142", "0.64004", "0.64004", "0.6339961", "0.63252276", "0.63063955", "0.6298083", "0.62965083", "0.6285503", "0.6276126", "0.6275561", "0.62542313", "0.61937106", "...
0.6127311
27
service methods that not need to be opened for usage outside if need more contact please me or contribute yourself by merge request
def prepare_data_for_writing(data_to_write, headers) if data_to_write.first.class.to_s.downcase =~ /hash/ prepared_headers = data_to_write.first.keys.map(&:to_s) prepared_data_to_write = data_to_write.map { |data_h| data_h.values } return prepared_data_to_write, prepared_headers elsif data_to_write.first.class.to_s.downcase =~ /array/ raise "No headers provided for writing" if !headers or headers.empty? return data_to_write, headers end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service; end", "def bi_service\n end", "def service; raise NotImplementedError; end", "def service_request(service); end", "def services\n\n end", "def apis; end", "def services\n end", "def api; end", "def api; end", "def services\n\tend", "def response_from_service\n\n end", ...
[ "0.7737704", "0.7351209", "0.7225053", "0.702254", "0.68654746", "0.68396556", "0.6827828", "0.66029984", "0.66029984", "0.6549432", "0.63603586", "0.63320774", "0.63320774", "0.63320774", "0.63320774", "0.6331718", "0.62942153", "0.62758154", "0.6270298", "0.6270298", "0.623...
0.0
-1
find out file encoding
def find_enoding scmdlog = `file -I #{@file_name}`.strip scmdlog[/charset=(.+?)$/, 1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_encoding(file)\n output = %x{file --mime-encoding #{file} 2>&1}.chomp\n regexp = Regexp.new(\"#{file}: (\\\\S+)\")\n matched = output.match(regexp)\n encoding = matched[1] if matched\n encoding = begin Encoding.find(encoding) rescue nil end\n end", "def found_encodi...
[ "0.8069067", "0.769913", "0.769913", "0.7376027", "0.72158855", "0.72158855", "0.70100343", "0.6678872", "0.6678872", "0.66581994", "0.66434723", "0.6579416", "0.65448093", "0.65448093", "0.6530589", "0.6450764", "0.64201695", "0.63622296", "0.6355989", "0.6354602", "0.635460...
0.697007
7
read data from file
def process_reading begin open_and_read_file @read_flag = true puts 'Success. Check instance fields'.colorize(:green) rescue StandardError => e puts e.message end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_data_file(path); end", "def read file\n File.open file\n end", "def read\n return unless ::File.exist?(@file)\n\n @data = Bencode.decode(::File.read(@file))\n end", "def read\n\t\t@file_content = File.open(\"/home/calin/football/football.dat\",\"r\")\n\tend", "def read\n ...
[ "0.80181766", "0.7729118", "0.7604488", "0.75958073", "0.7583198", "0.74269825", "0.735359", "0.73248494", "0.7311742", "0.722713", "0.72068393", "0.7166236", "0.7149558", "0.7088047", "0.70837516", "0.7029586", "0.6998808", "0.6998808", "0.69640386", "0.69637156", "0.6962746...
0.0
-1
write data into file (upstream in write method)
def process_writing(data_to_write, headers, encoding) begin open_and_write_data(data_to_write, headers, encoding) @write_flag = true puts 'Success. Check file with new data' rescue StandardError => e puts e.message rescue CSV::MalformedCSVError => e2 puts e2.message end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(data); end", "def write(data); end", "def write(data); end", "def write(data); end", "def write data\n _data[:out].write data\n _data[:out].flush\n end", "def write(data)\n end", "def write(data)\n # black hole, because we don't actually care about what gets written\n...
[ "0.8352205", "0.8352205", "0.8352205", "0.8352205", "0.80332655", "0.802342", "0.7896684", "0.77450144", "0.771225", "0.7676903", "0.76766723", "0.76339376", "0.75983137", "0.75894976", "0.7513029", "0.7460712", "0.7460712", "0.7460712", "0.7413541", "0.7413541", "0.74087346"...
0.64700663
81
copy the structure of an attached table, along with any indexes
def copy_table_structure(rdb,tbl) template = "SELECT sql, type from X.sqlite_master WHERE tbl_name = ? ORDER BY type DESC" lsql = template.gsub('X',"main") rsql = template.gsub('X',quote_with_dots(rdb)) args = [quote_with_dots(tbl)] lschema = sqlite_execute(lsql,args) rschema = sqlite_execute(rsql,args) if lschema.length>0 return false end rschema.each{ |row| sqlite_execute(row[0],[]) } true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_structure\n logger.info \"Copying structure for table #{name} from watched to audit database\"\n db.query(\"CREATE TABLE #{audit} LIKE #{watched}\")\n add_copied_at_field\n add_has_delta_field\n add_last_version_field\n add_has_violation_field\n add_deletion_flag\n en...
[ "0.71946454", "0.6521952", "0.649078", "0.6262572", "0.62434936", "0.61201864", "0.61195266", "0.603655", "0.6017377", "0.59772307", "0.5921113", "0.59018046", "0.5887744", "0.5873437", "0.5843929", "0.5838268", "0.5811328", "0.5796456", "0.5782667", "0.5771281", "0.56829625"...
0.6626185
2
PATCH/PUT /users/1 PATCH/PUT /users/1.json
def create respond_to do |format| if @user.save(account_update_params) format.html { redirect_to @user, notice: 'User was successfully created.' } format.json { render :show, status: :ok, location: @user } else format.html { render :edit } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "de...
[ "0.7225568", "0.7129473", "0.70036036", "0.6903525", "0.6821961", "0.68157715", "0.6708618", "0.66936064", "0.66810983", "0.6673763", "0.6672601", "0.6664346", "0.6664346", "0.6659468", "0.6659468", "0.6654875", "0.66486204", "0.66436917", "0.6641295", "0.6635214", "0.6618464...
0.0
-1
Write a method that returns a list of all substrings of a string that start at the beginning of the original string. The return value should be arranged in order from shortest to longest substring.
def substrings_at_start(string) results = [] string.length.times do results << string string = string.chop end results.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def substrings_at_start(string)\n string.size <= 1 ? [string] : [substrings_at_start(string.chop), string].flatten\nend", "def substrings_at_start(string)\n result = []\n 1.upto(string.size) do |substring|\n result << string.slice(0, substring)\n end\n result\nend", "def substrings_at_start(string)\n ...
[ "0.8325489", "0.8155206", "0.8155206", "0.812128", "0.8113986", "0.80989605", "0.80890393", "0.80890393", "0.80863243", "0.805721", "0.805721", "0.8045335", "0.80292356", "0.8026634", "0.8019423", "0.8019423", "0.8014547", "0.80064577", "0.8000202", "0.7994773", "0.79933316",...
0.7683622
66
GET /albums/1 GET /albums/1.json
def show @album = @user.albums.find(params[:id]) respond_to do |format| format.html # show.html.erb format.js { render 'show'} format.json { render json: @album } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def album\n album = Album.find(params[:id])\n render json: album\n end", "def get_album album_id\n get(\"/albums/#{album_id}\")\n end", "def index\n @albums = Album.all\n render json: @albums\n end", "def albums\n if params[:artist_id]\n albums = Artist.find(params[:ar...
[ "0.8009467", "0.7959881", "0.78372234", "0.7691804", "0.7597149", "0.7578913", "0.7575133", "0.75557536", "0.7509159", "0.7499277", "0.74331", "0.7425575", "0.7392072", "0.73376465", "0.72854936", "0.7269928", "0.7238321", "0.7209099", "0.7199257", "0.71921223", "0.7189279", ...
0.7192076
20
GET /albums/new GET /albums/new.json
def new @album = @user.albums.new respond_to do |format| format.js { render 'new' } format.html # show.html.erb end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n ...
[ "0.8188422", "0.79822683", "0.79822683", "0.788069", "0.78131187", "0.7684299", "0.75881", "0.75813186", "0.7565208", "0.7560758", "0.7540226", "0.7530166", "0.7487129", "0.7453177", "0.74511963", "0.7413497", "0.7364595", "0.73290884", "0.7294432", "0.7257032", "0.7257032", ...
0.7486999
13
POST /albums POST /albums.json
def create @album = @user.albums.new(params[:album]) if @album.save flash[:notice] = 'User was successfully created.' if params[:album][:avatar].blank? redirect_to @album else render :action => 'cropping' end else render :action => 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend", "def create\n @album = current_user.albums.build(album_params)\n\n res...
[ "0.77528495", "0.7283492", "0.7234256", "0.71961457", "0.7179153", "0.70808494", "0.70808494", "0.70808494", "0.7003637", "0.7003637", "0.69838834", "0.6972035", "0.697075", "0.6958249", "0.69494504", "0.6927158", "0.68965065", "0.6890949", "0.6846395", "0.6823431", "0.682324...
0.61339444
95
PUT /albums/1 PUT /albums/1.json
def update @album = @user.albums.find(params[:id]) respond_to do |format| format.js { render 'new' } format.html{ if @album.update_attributes params[:album] @album.avatar.reprocess! flash[:notice] = 'User was successfully updated.' if params[:album][:avatar].blank? redirect_to @album else render :action => 'cropping' end else render :action => "edit" end} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @album = current_user.albums.find(params[:id])\n\n respond_to do |format|\n if @Album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ...
[ "0.68898857", "0.6792222", "0.6670106", "0.6660307", "0.6606993", "0.6606993", "0.65957916", "0.6580667", "0.6580667", "0.6580667", "0.6578174", "0.6538606", "0.6499689", "0.64891946", "0.64501524", "0.64501524", "0.64501524", "0.6420907", "0.64052725", "0.64043105", "0.63698...
0.0
-1
DELETE /albums/1 DELETE /albums/1.json
def destroy @album = @user.albums.find(params[:id]) @album.destroy respond_to do |format| format.html { redirect_to albums_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @album.destroy\n render json: @album\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id...
[ "0.79129416", "0.7841086", "0.77922285", "0.77922285", "0.77922285", "0.77922285", "0.77922285", "0.7786131", "0.77811533", "0.7776723", "0.7772079", "0.77639914", "0.77639914", "0.77639914", "0.7685881", "0.7641379", "0.7640984", "0.76020396", "0.7557685", "0.75472915", "0.7...
0.8011329
0
def reverse_sentence(string) return string.split.reverse.join(" ") end
def reverse_sentence(str) sent_out = [] str.split.each { |word| sent_out.unshift(word) } sent_out.join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_sentence(string)\n \n string.split.reverse.join(' ')\n \nend", "def reverse_sentence(string)\n string.split.reverse.join(' ')\nend", "def reverse_sentence(string)\n string.split.reverse.join(' ')\nend", "def reverse_sentence(string)\n string.split.reverse.join(' ')\nend", "def reverse_sen...
[ "0.9722934", "0.9716321", "0.9716321", "0.9716321", "0.9716321", "0.9716321", "0.9715754", "0.96540797", "0.96519816", "0.96519816", "0.96519816", "0.957925", "0.957925", "0.95757717", "0.95520675", "0.95494825", "0.9548157", "0.9524697", "0.951481", "0.9493014", "0.9395695",...
0.9073781
30
The array will never be empty and the numbers will always be positive integers. Your result should also be an integer.
def average(arr) arr.sum / arr.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_only_numbers(array)\n ll_sum = 0.0\n if array.length > 0\n for idx in array do\n if idx.is_a?(Numeric)\n ll_sum += idx\n end\n end\n end\n return ll_sum\nend", "def sum(array)\n\n rais...
[ "0.7417678", "0.74021983", "0.72484815", "0.7217035", "0.7144029", "0.70300347", "0.70143604", "0.6995353", "0.6950198", "0.69414586", "0.6934746", "0.6897065", "0.6882831", "0.6862095", "0.6861659", "0.6860734", "0.68400455", "0.68379444", "0.68257815", "0.6823499", "0.68140...
0.0
-1
Returns server hostnames and IDs, suitable for caching.
def card_tags select('id, hostname').inject({}) do |hash, s| hash[s.hostname] = { server_id: s.id } hash end.with_indifferent_access end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_server_hosts\n [server_host]\n end", "def servers\n @servers.keys\n end", "def server_structs\n array = []\n if @struct.hosts\n @struct.hosts.count.times do |i|\n array << Lib.memcached_select_server_at(@struct, i)\n end\n end\n array\n end", "def servers\n ...
[ "0.71656597", "0.7109295", "0.7089845", "0.69327396", "0.6888951", "0.67374986", "0.6675617", "0.66313446", "0.662831", "0.6616807", "0.6510707", "0.6510707", "0.64835477", "0.64835477", "0.6445302", "0.6426511", "0.6417283", "0.6411443", "0.64056474", "0.63945854", "0.636955...
0.6065139
39
Returns absolute and movingaverage values of time to repair ()complete unplanned cards) since supplied time.
def time_to_repair(since_time, unit: :second) total_repair_time = 0 total_repairs = 0 ttr = { point_values: {}, moving_averages: {} } # Unplanned cards created after since_time, in order of creation. cards.where('cards.created_at > ?', since_time).where('cards.label = ?', Card::LABEL_UNPLANNED).order('cards.created_at DESC').map do |unplanned_card| lead_time = unplanned_card.lead_time if lead_time > 0 total_repairs += 1 total_repair_time += time_in_unit(lead_time, unit) ttr[:point_values][unplanned_card.created_at] = time_in_unit(lead_time, unit) ttr[:moving_averages][unplanned_card.created_at] = total_repair_time / total_repairs end end ttr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def at_time(time)\n resource = @initial\n\n puts \"[START] initial: #{initial}\" if COPIOUS_DEBUGGING\n puts \"[START] time: #{time}\" if COPIOUS_DEBUGGING\n\n if intervals_at_time(@harvesters, time).size > 1\n generate_pairs(intervals_at_time(@harvesters, time)).each_with_index do |pair, index|\n...
[ "0.5869817", "0.58603567", "0.56355774", "0.5614027", "0.5604639", "0.5559245", "0.55308306", "0.54630786", "0.5405201", "0.5365227", "0.5290069", "0.5286041", "0.52774304", "0.52488804", "0.5222357", "0.5212122", "0.5208633", "0.5184622", "0.5179051", "0.51691294", "0.516448...
0.6589963
0
Returns absolute and movingaverage values of time between failures (creation of unplanned card and completion of last unplanned card) since supplied time.
def time_between_failures(since_time, unit: :second) total_uptime = 0 total_failures = 0 tbf = { point_values: {}, moving_averages: {} } # Unplanned cards created after since_time, in order of creation. unplanned_cards = cards.where('cards.created_at > ?', since_time).where('cards.label = ?', Card::LABEL_UNPLANNED).order('cards.created_at DESC') unplanned_cards.each_with_index do |unplanned_card, index| previous_unplanned_card = unplanned_cards[index + 1] if previous_unplanned_card && previous_unplanned_card.completed_at uptime = unplanned_card.created_at - previous_unplanned_card.completed_at total_failures += 1 total_uptime += time_in_unit(uptime, unit) tbf[:point_values][unplanned_card.created_at] = time_in_unit(uptime, unit) tbf[:moving_averages][unplanned_card.created_at] = total_uptime / total_failures end end tbf end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_to_repair(since_time, unit: :second)\n total_repair_time = 0\n total_repairs = 0\n ttr = { point_values: {}, moving_averages: {} }\n\n # Unplanned cards created after since_time, in order of creation.\n cards.where('cards.created_at > ?', since_time).where('cards.label = ?', Card::LABEL_UNP...
[ "0.59466237", "0.5944881", "0.5944881", "0.5897146", "0.57786214", "0.55632937", "0.5487752", "0.5487752", "0.5437157", "0.540516", "0.5381568", "0.53214526", "0.52549005", "0.5250814", "0.5245481", "0.5217097", "0.5204357", "0.5204357", "0.51853985", "0.5181975", "0.5174489"...
0.664568
0
Returns hash containing timestamp and details from ServerLog and Card
def logs_and_cards_with_timestamp(since_time) required_logs = server_logs.where('server_logs.created_at > ?', since_time).order('server_logs.created_at DESC') required_cards = cards.where('cards.created_at > ?', since_time).order('cards.created_at DESC') formatted_logs_info = required_logs.inject({}) do |specific_log_info, required_log| specific_log_info[required_log.timestamp] = required_log.log.join(',') specific_log_info end if required_logs.count > 0 formatted_cards_info = required_cards.inject({}) do |specific_card_info, required_card| specific_card_info[required_card.created_at.to_i.to_s] = "<a href=#{required_card.url}>Trello URL</a>" specific_card_info end if required_cards.count > 0 { logs: formatted_logs_info, cards: formatted_cards_info } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash(ts)\n sig = [\n Rackspace::Email::Api.configuration.user_key,\n Rackspace::Email::Api.configuration.user_agent,\n ts,\n Rackspace::Email::Api.configuration.api_key\n ].join('')\n\n Base64.encode64(Digest::SHA1.digest(sig))\n end...
[ "0.6000593", "0.5935062", "0.5913583", "0.58834237", "0.5822245", "0.58120126", "0.578311", "0.56563985", "0.56487066", "0.5637914", "0.5631631", "0.55961853", "0.5559007", "0.55397695", "0.55334884", "0.5509347", "0.5508729", "0.548707", "0.5477845", "0.5406288", "0.5386556"...
0.639813
0
GET /places/1 GET /places/1.xml
def show @place = Place.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @place } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @places = Place.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @places }\n end\n end", "def index\n @places = Place.lookfor(params[:q])\n @places = @places.map{|p| {:tag=>p.tag,:id=>p.id,:name=>p.name}}\n respond_to do |format...
[ "0.70868665", "0.6749994", "0.6707183", "0.66383576", "0.660664", "0.6579932", "0.6579619", "0.6539432", "0.6347312", "0.6338752", "0.6288413", "0.6238508", "0.6133827", "0.6062072", "0.60595745", "0.60522354", "0.60425276", "0.59225714", "0.5920716", "0.59172386", "0.5905921...
0.67937523
5
GET /places/new GET /places/new.xml
def new @place = Place.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @place } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @place = @event.places.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @place }\n end\n end", "def new\n @travel_place = TravelPlace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml =...
[ "0.71660686", "0.70630187", "0.69331986", "0.69331986", "0.69331986", "0.69331986", "0.69331986", "0.6907546", "0.68690354", "0.679841", "0.67375517", "0.6726614", "0.6693176", "0.6676003", "0.6676003", "0.667547", "0.66647315", "0.6628229", "0.6614093", "0.6614093", "0.65887...
0.76149035
6
POST /places POST /places.xml
def create @place = Place.new(params[:place]) respond_to do |format| if @place.save flash[:notice] = 'Place was successfully created.' format.html { redirect_to(@place) } format.xml { render :xml => @place, :status => :created, :location => @place } else format.html { render :action => "new" } format.xml { render :xml => @place.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @place = Place.new(params[:place])\n\n respond_to do |format|\n if @place.save\n format.html { redirect_to(@place, :notice => 'Place was successfully created.') }\n format.xml { render :xml => @place, :status => :created, :location => @place }\n else\n format.html...
[ "0.6196169", "0.61007696", "0.6077837", "0.60313135", "0.5999693", "0.5840869", "0.58246005", "0.5755907", "0.5734695", "0.5729121", "0.57287043", "0.57287043", "0.57287043", "0.5716145", "0.57081753", "0.57081574", "0.57081574", "0.57081574", "0.57081574", "0.56898564", "0.5...
0.61501765
2
PUT /places/1 PUT /places/1.xml
def update @place = Place.find(params[:id]) respond_to do |format| if @place.update_attributes(params[:place]) flash[:notice] = 'Place was successfully updated.' format.html { redirect_to(@place) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @place.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end", "def update\n @place = @event.places.find(params[:id])\n\n respond_to do |format|\n if @place.update_attributes(params[:place])\n ...
[ "0.6674657", "0.64221364", "0.63929063", "0.63915205", "0.63915205", "0.636533", "0.62242603", "0.61510205", "0.6067097", "0.6041314", "0.6041314", "0.6041314", "0.6041314", "0.6041314", "0.60403854", "0.5966747", "0.5951642", "0.588858", "0.5887603", "0.5852387", "0.5844916"...
0.64036614
4
DELETE /places/1 DELETE /places/1.xml
def destroy @place = Place.find(params[:id]) @place.destroy respond_to do |format| format.html { redirect_to(places_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @place = Place.find(params[:id])\n @place.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_places_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @place = @event.places.find(params[:id])\n @place.destroy\n\n respond_to do |format|\n...
[ "0.7019525", "0.67803085", "0.6702724", "0.67005825", "0.66454726", "0.6605662", "0.6551402", "0.6547136", "0.65405244", "0.65173507", "0.6481668", "0.64708424", "0.6451609", "0.64098465", "0.64006424", "0.6367989", "0.6366349", "0.63611084", "0.6348793", "0.6348793", "0.6348...
0.7032682
6
Provides a default configuration
def initialize @codice_fiscale = CodiceFiscaleConfiguration.new @cap_lookup = CapLookupConfiguration.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_config\n {}\n end", "def default_configuration\n {}\n end", "def default_config\n self.class.default_config\n end", "def default_configuration\n configuration[:_default] || {}\n end", "def default_config\n <<~CONFIG\n defaults: &defaults\n ...
[ "0.8807638", "0.86508226", "0.8470093", "0.832503", "0.82438046", "0.8194717", "0.811372", "0.78117883", "0.7711394", "0.76459974", "0.75989085", "0.75989085", "0.7532349", "0.7494192", "0.7470694", "0.7448921", "0.74468434", "0.7420179", "0.7369174", "0.7354674", "0.73447245...
0.0
-1
TODO: cache the eth block number with expiration in 10 sec?
def confirmed_blocks eth_client.eth_block_number.to_i - self.block_number end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def block_number\n request('getblocknumber')\n end", "def getblocknumber\n request :getblocknumber\n end", "def getblocknumber\n @api.request 'getblocknumber'\n end", "def getblocknumber\n coind.getblocknumber\n end", "def add_block(amount, payer, payee, miner, timestamp, signature, pre...
[ "0.7329643", "0.71780944", "0.70912856", "0.68424726", "0.66567653", "0.6545536", "0.64524627", "0.63939327", "0.63720405", "0.63670194", "0.6334744", "0.6300179", "0.6294749", "0.627423", "0.6254718", "0.6190706", "0.6181141", "0.6137486", "0.61327815", "0.6107315", "0.61069...
0.59889466
25
parse the command line arguments example 'c 23 f text.csv' = :count = 23 and :path = text.csv
def parse_arguments OptionParser.new do |parser| # parser.banner = "Usage: init.rb -c <integer>" parser.on("-c", "--count COUNT", Integer, "Specify number of uuid's to generate") do |c| @options[:count] = c end parser.on("-f", "--file FILE", "Specify path to save csv file example -f '/path/to/file.csv'") do |path| @options[:path] = path end end.parse! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_args()\n opts = GetoptLong.new(\n ['--host', GetoptLong::OPTIONAL_ARGUMENT],\n ['--port', GetoptLong::OPTIONAL_ARGUMENT],\n ['--columns', GetoptLong::OPTIONAL_ARGUMENT],\n ['--index', GetoptLong::REQUIRED_ARGUMENT],\n ['--type', GetoptLong::REQUIRED_ARGUMENT]\n )\n\n opts.each do |opt, ...
[ "0.6028493", "0.5696837", "0.5345504", "0.5277444", "0.5276807", "0.5252528", "0.5217761", "0.5186166", "0.51670563", "0.5155809", "0.51500833", "0.5144254", "0.5134379", "0.51314235", "0.51246405", "0.5122422", "0.51139", "0.5082428", "0.50822866", "0.5046602", "0.5024367", ...
0.6839619
0
Converts account to a Struct::Account and sets it.
def account=(account) @account = account ? Struct::Account.new(account) : account end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def account=(val)\n @account = val\n @base.accountRef = val.ref\n end", "def account=(value)\n @account = value\n end", "def account= val\n @account = val\n self.source_account = val.address\n end", "def set_account\n @account = current_user.ac...
[ "0.7619571", "0.7449623", "0.7309978", "0.7229922", "0.7229922", "0.69726574", "0.6969836", "0.69493276", "0.6892448", "0.68204236", "0.67833364", "0.6741396", "0.6741261", "0.67404133", "0.6725098", "0.6725098", "0.6725098", "0.6725098", "0.6725098", "0.6725098", "0.6725098"...
0.84498876
0
Converts user to a Struct::User and sets it.
def user=(user) @user = user ? Struct::User.new(user) : user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_user\n @user = User.find(user_id)\n end", "def user=(user)\n check_user(user)\n set_user(user)\n # returns user\n end", "def user=(value)\n @user = value\n end", "def user=(value)\n @user = value\n end", "def user=(usr)\n...
[ "0.7312901", "0.72290397", "0.72104454", "0.72104454", "0.71981764", "0.71824837", "0.71824837", "0.70357496", "0.7028903", "0.70286804", "0.69824094", "0.6982281", "0.6982281", "0.6965168", "0.69562954", "0.6934402", "0.6932778", "0.6912967", "0.6912967", "0.6911703", "0.690...
0.82027197
0
used for industry header
def name title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def industry; end", "def header_style(header); end", "def header; end", "def header; end", "def header; end", "def header_build\n header = \"customer name\" + @delimiter + \"gender\" + @delimiter\n header += \"age\" + @delimiter + \"birthday\" + @delimiter + \"cpf\" + @delimiter + \"id\" + @delimiter\n...
[ "0.7279813", "0.63672966", "0.62308156", "0.62308156", "0.62308156", "0.6222337", "0.62171245", "0.6211658", "0.6193455", "0.61454743", "0.61344755", "0.6118997", "0.61154854", "0.6097585", "0.60963506", "0.6076977", "0.6048664", "0.60416675", "0.6034486", "0.60245526", "0.60...
0.0
-1
Save a certificate to a file. Remove all the content in the file if there is any before.
def load_x509_cert(cert_file, key_store) input_stream = java.io.BufferedInputStream.new(java.io.FileInputStream.new(cert_file)) cert_factory = java.security.cert.CertificateFactory.get_instance('X.509') cert_count = 0 #The file might contain multiple certs while input_stream.available > 0 begin cert = cert_factory.generate_certificate(input_stream) cert_count = cert_count + 1 # load_x509_cert(cert, 'neo4j.javadriver.trustedcert.', cert_count, key_store) rescue java.security.cert.CertificateException => e # This happens if there is whitespace at the end of the certificate - we load one cert, and then try and load a # second cert, at which point we fail return if !e.get_cause.nil? && e.get_cause.get_message == 'Empty input' raise java.io.IOException.new("Failed to load certificate from `#{cert_file.get_absolute_path}`: #{cert_count} : #{e.get_message}", e) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sync\n @certificates.each do |certificate|\n certificate_path = File.join(@path, \"#{certificate.serial_number}.crt\")\n unless File.exist?(certificate_path)\n certificate.write_to(certificate_path)\n end\n end\n end", "def cert_file\n write_file(\"request-#{do...
[ "0.6537741", "0.6527521", "0.64083874", "0.631505", "0.6059651", "0.60592175", "0.6056657", "0.58367133", "0.5643589", "0.5643589", "0.5616639", "0.5603262", "0.5585423", "0.5552489", "0.5541129", "0.5497912", "0.5449088", "0.5433572", "0.5429138", "0.5413541", "0.5351649", ...
0.49588385
61
This sets the mode so OpenSSL knows to encrypt or decrypt, etc.
def initialize_cipher_for(mode) @cipher.send mode @cipher.key = @config['key'] @cipher.iv = @config['iv'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mode\n attributes.fetch(:mode) do\n Ably::Util::Crypto::DEFAULTS.fetch(:mode)\n end.downcase\n end", "def _setup(action)\n @cipher ||= OpenSSL::Cipher.new(@options[:cipher]) \n # Toggles encryption mode\n @cipher.send(action)\n @cipher.padding = @options[:paddi...
[ "0.6709338", "0.65460825", "0.6397773", "0.635467", "0.61822665", "0.61617327", "0.61496496", "0.6148367", "0.60943794", "0.60300434", "0.59287816", "0.57963926", "0.57963926", "0.57930976", "0.57873386", "0.5780654", "0.57656914", "0.57390237", "0.57379", "0.5712116", "0.570...
0.7027253
0
get every test to pass before coding runner below
def runner welcome game = initial_round until game > 21 do game = hit?(game) display_card_total(game) end end_game(game) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if no...
[ "0.7275367", "0.72012377", "0.7191292", "0.71326625", "0.7128869", "0.7035493", "0.68615764", "0.6822212", "0.6807081", "0.6791164", "0.6791164", "0.67651623", "0.6570472", "0.6553684", "0.65485567", "0.65461046", "0.6529981", "0.6459336", "0.64472514", "0.64472514", "0.64417...
0.0
-1
Runs the commandline utility, parsing arguments and displaying a list of objects
def run(*args) prepare_codebase(*args) context = API::List.new(codebase, @options) Output::List.new(@options, context.objects, context.grade_lists) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(args)\n if args.size > 0\n # show details of given commands\n show_details(args)\n else\n # print full list of commands\n list_commands\n end\n end", "def run(*args)\n optparse(*args)\n\n if ::RbConfig::CONFIG['host_os'] =~ /mingw|win32/\n @serializer ...
[ "0.69529134", "0.6587462", "0.6411123", "0.6406293", "0.64051896", "0.6287235", "0.62726074", "0.61937386", "0.61896104", "0.6184226", "0.614026", "0.6097653", "0.6094382", "0.60925066", "0.6060161", "0.6041509", "0.6038415", "0.60354155", "0.5993843", "0.5983719", "0.5981085...
0.6394929
5
Initialize a new entity Provide the entity's attributes as key/value pairs in +kwargs+. Any attributes you provide will be duplicated and frozen, so you need not worry about later modifications to any values passed in.
def initialize(**kwargs) assert_required_attributes(kwargs) assert_no_extra_attributes(kwargs) @attributes = Valuables::DeepFreeze.deep_freeze(kwargs) @hash = self.class.hash ^ @attributes.hash freeze end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new(attrs = {})\n instance = super()\n instance.load_attributes!\n instance.update(attrs)\n instance\n end", "def new_entity(options, &b)\n @entity_class.new(self, options, &b)\n end", "def initialize(*args)\n @args = args\n assign_attributes\n end", ...
[ "0.6690786", "0.6681181", "0.647689", "0.63971376", "0.6360924", "0.63492763", "0.6345636", "0.63408333", "0.63069004", "0.62994134", "0.625711", "0.6253319", "0.6234773", "0.6233987", "0.62219816", "0.62080634", "0.61976314", "0.61968935", "0.6192983", "0.61902946", "0.61750...
0.64567107
3
Compare two objects Two entities are considered equal if they are instances of the same class and their internal attributes are equal.
def ==(other) self.class == other.class && attributes == other.attributes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(other)\n @klass == other.class && @attributes == strip_active_record(other)\n end", "def ==(other)\n self.class == other.class &&\n self.attributes == other.attributes\n end", "def eql?(other)\n return true if equal?(other)\n\n # two instances for different models cannot b...
[ "0.75393826", "0.75390065", "0.74138546", "0.72987914", "0.7130778", "0.71167606", "0.7114481", "0.70684105", "0.70654154", "0.7048141", "0.7005528", "0.69997495", "0.69993824", "0.69993824", "0.699171", "0.69691557", "0.695095", "0.6949943", "0.6941152", "0.6933629", "0.6930...
0.73919934
3
Get a Hash representation of this entity.
def to_h @attributes.dup end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash\n to_h.hash ^ self.class.hash\n end", "def to_hash\n @hash\n end", "def hash\n return to_s.hash\n end", "def hash\n @hash ||= self.to_a.hash\n end", "def to_hash\n @hash\n end", "def to_hash\n @hash\n end", "def hash\n to_s.hash\n end...
[ "0.73462594", "0.7314015", "0.7289408", "0.7273738", "0.7247071", "0.7247071", "0.7187254", "0.7167623", "0.71173775", "0.71070355", "0.7053994", "0.70317984", "0.7020842", "0.70050204", "0.70035464", "0.6988443", "0.690898", "0.69039774", "0.6900695", "0.6895311", "0.6895311...
0.0
-1
def set_defaults self.badge ||= " end we can call the concern here
def set_defaults self.badge ||= Placeholder.image_generator(height: '150', width: '150') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_defaults\n self.badge ||= Placeholder.image_generator(height: '250', width: '250') \n end", "def defaults!\n @badge_enabled = true\n @badge_position = 'top-left'\n @page_size = 25\n @webpacker_enabled = true\n end", "def set_default_values_skill\n self.badge ||= P...
[ "0.7531255", "0.7097636", "0.6680987", "0.6666321", "0.6666321", "0.6666321", "0.6666321", "0.6666321", "0.6666321", "0.66328174", "0.6608102", "0.6608102", "0.6511401", "0.65053445", "0.64164084", "0.6379893", "0.62925607", "0.62925607", "0.628346", "0.628346", "0.62681466",...
0.75497967
0
Agrega enlaces de notas
def enlaces_notas resumen mensaje = "" notas = resumen.notas.order "updated_at DESC" if notas.count > 0 notas.each_with_index do |nota,i| mensaje += link_nota nota mensaje += "-" if i < resumen.notas.count-1 end end return mensaje end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comisiones_asignadas\n asunto.comisiones if asunto\n end", "def notificaciones\n end", "def solicitudes_atrasadas\n end", "def incluir_inicial\n ['casoid', 'fecha', 'ubicaciones', 'presponsables',\n 'tipificacion', 'victimas', 'memo']\n end", "def guarda_nombres_c...
[ "0.6699505", "0.65446395", "0.60493153", "0.5985316", "0.5908733", "0.57849526", "0.57509387", "0.57341427", "0.57105327", "0.5666349", "0.5615516", "0.5561488", "0.5508755", "0.5471767", "0.5462504", "0.5449848", "0.5427775", "0.54254746", "0.54253733", "0.5424888", "0.54212...
0.74527264
0
Init params Author: Aniket Date: 06/07/2018 Reviewed By:
def init_params(parmas) @client_id = parmas[:client_id] @client = Client.get_from_memcache(@client_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @params = {}\n end", "def initialize params = nil\n \n end", "def initialize(params)\n @params = params \n end", "def initialize_parameters\n @omdb_params = [:i, :t, :type, :y, :plot, :r, :tomates, :callback, :v, :s] \n end", "def initialize(title, author)\n# stores tit...
[ "0.706322", "0.70498246", "0.69087195", "0.68912333", "0.68797237", "0.6858602", "0.67866516", "0.67726153", "0.67726153", "0.6769008", "0.6738238", "0.66774255", "0.66774255", "0.66774255", "0.66774255", "0.66749775", "0.6651916", "0.6651916", "0.6651916", "0.66503996", "0.6...
0.0
-1
Trigger auto_approve_update rescue task for users Author: Tejas Date: 12/07/2018 Reviewed By:
def process_user_kyc_details UserKycDetail.using_client_shard(client: @client). where(client_id: @client_id, status: GlobalConstant::UserKycDetail.active_status, admin_status: GlobalConstant::UserKycDetail.unprocessed_admin_status). order({id: :desc}). find_in_batches(batch_size: 100) do |ukds| ukds.each do |ukd| if (!ukd.has_been_auto_approved?) trigger_auto_approve_update_rescue_task(ukd.user_extended_detail_id) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trigger_auto_approve_update_rescue_task(user_extended_details_id)\n BgJob.enqueue(\n AutoApproveUpdateJob,\n {\n client_id: @client_id,\n reprocess: 1,\n user_extended_details_id: user_extended_details_id\n }\n )\n Rails.logger.info(\"---- enqueue_...
[ "0.705809", "0.70130646", "0.6508065", "0.6465678", "0.6300665", "0.6278232", "0.6221501", "0.6195856", "0.6142169", "0.6118958", "0.60702586", "0.60666263", "0.60202366", "0.60108733", "0.6000856", "0.59855175", "0.5981225", "0.59782726", "0.595893", "0.588726", "0.5870462",...
0.5436844
60
Trigger auto approve update rescue task Author: Aniket Date: 06/07/2018 Reviewed By:
def trigger_auto_approve_update_rescue_task(user_extended_details_id) BgJob.enqueue( AutoApproveUpdateJob, { client_id: @client_id, reprocess: 1, user_extended_details_id: user_extended_details_id } ) Rails.logger.info("---- enqueue_job AutoApproveUpdateJob for ued_id-#{user_extended_details_id} done") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auto_approve!\n update_attribute(:approved_at,DateTime.now)\n update_attribute(:approved_by, User.APPLICATION)\n write_key!\n end", "def auto_approve\n if !self.auto_approved && self.approval_status.nil?\n UserMailer.auto_approved_email(self).deliver\n self.auto_approved = true\n ...
[ "0.7300589", "0.6860544", "0.66208094", "0.6579514", "0.6537604", "0.64907944", "0.6414515", "0.6392691", "0.63433105", "0.63322794", "0.63170993", "0.6307723", "0.6301542", "0.62309974", "0.62107265", "0.61708796", "0.61656624", "0.6159551", "0.6159291", "0.61283183", "0.611...
0.73774314
0
Force UTF16 string encoding when anonymous bytes are naively read in, then encode for UTF8, which the user expects
def get self.data.force_encoding(Encoding::UTF_16BE).encode(Encoding::UTF_8) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend", "def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end", "def fix_encoding!(str)\n\t#str.force...
[ "0.78899014", "0.74937373", "0.7480982", "0.7220402", "0.70552665", "0.7027902", "0.7014402", "0.69959253", "0.6959735", "0.6914557", "0.691258", "0.68998337", "0.68998337", "0.68998337", "0.68809843", "0.68669957", "0.6855419", "0.68419796", "0.68244076", "0.68205", "0.68205...
0.6335779
51
Expect to receive UTF8 string when setting
def set(string) self.data = string.encode(Encoding::UTF_16BE) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end", "def utf8(string)\n string.force_encoding(Encoding::UTF_8)\n end", "def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end", ...
[ "0.6913763", "0.67741346", "0.67557776", "0.6625959", "0.66149884", "0.66134", "0.6578945", "0.65160954", "0.6487461", "0.64853054", "0.6475338", "0.6475338", "0.6475338", "0.6475338", "0.6475338", "0.64747447", "0.64747447", "0.6444483", "0.64355934", "0.64279175", "0.641866...
0.6561136
7