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
method called when command run is issued
def run installs = [] results = [] users = [] print_status("Enumerating Tomcat Servers on #{sysinfo['Computer']}") if check_tomcat installs += identify_registry if not installs.empty? installs.each do |inst| results += enumerate_tomcat(inst[0],inst[1]) users += enumerate_tomcat_creds(inst[0]) end else print_status("Done, Tomcat Not Found") return end end if results.empty? print_status("Done, Tomcat Not Found") return end print_status("Done, Tomcat Found.") tbl_services = Rex::Text::Table.new( 'Header' => "Tomcat Applications ", 'Indent' => 1, 'Columns' => [ "Host", "Tomcat Version", "Port", "Web Application" ]) results.each { |r| report_service(:host => session.sock.peerhost, :port => r[2], :name => "http", :info => "#{r[0]} Tomcat #{r[1]}, Application:#{r[3]}") tbl_services << r } tbl_users = Rex::Text::Table.new( 'Header' => "Tomcat Server Users ", 'Indent' => 1, 'Columns' => [ "Host", "User", "Password", "Roles" ]) users.each { |u| tbl_users << [ session.sock.peerhost,u[0],u[1],u[2] ] } print_line() print_line(tbl_services.to_s) print_line(tbl_users.to_s) p = store_loot("host.webservers.tomcat", "text/plain", session, tbl_services.to_s + "\n" + tbl_users.to_s, "tomcat.txt", "Tomcat Server Enum") print_good("Results stored in: #{p}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command; end", "def command; end", "def command; end", "def command; end", "def command; end", "def command; end", "def original_run_command; end", "def command_start; end", "def command_start; end", "def command_start; end", "def commands; end", "def cmd; end", "def set_commands; end",...
[ "0.7852016", "0.7852016", "0.7852016", "0.7852016", "0.7852016", "0.7852016", "0.75619966", "0.75288993", "0.75288993", "0.75288993", "0.752495", "0.75088865", "0.7318337", "0.72281665", "0.7097601", "0.706374", "0.7013768", "0.7003385", "0.69767624", "0.69767624", "0.6940068...
0.0
-1
initial identification methods method for checking if webserver is installed on server tomcat
def check_tomcat key = "HKLM\\SOFTWARE\\Apache Software Foundation" if registry_enumkeys(key).include?("Tomcat") print_status("\tTomcat found.") return true end return false rescue return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tomcat?\n system \"ps aux| grep tomcat | grep catalina\"\n end", "def tomcat_installed?(catalina_home)\n get_version = catalina_home + '/bin/version.sh'\n\n begin\n !/^Server version:\\s+Apache Tomcat\\/(\\d+\\.\\d+\\.\\d+)\\s*$/.match(shell_out(get_version).stdout)[1].empty?\n rescue Errno...
[ "0.72469723", "0.69960713", "0.68398166", "0.6532027", "0.6443002", "0.6401938", "0.63498276", "0.6325254", "0.6257632", "0.62368554", "0.6214012", "0.6199543", "0.61000305", "0.6085014", "0.6083288", "0.60750127", "0.60262346", "0.60176605", "0.60033166", "0.59835935", "0.59...
0.7286839
0
deep server enumeration methods enumerate tomcat
def enumerate_tomcat(val_installpath,val_version) results = [] found = false print_good("\t\t+ Version: #{val_version}") print_good("\t\t+ Path: #{val_installpath}") if not exist?(val_installpath + "\\conf\\server.xml") print_error("\t\t! tomcat configuration not found") return results end appname = find_application_name(val_installpath) ports = [] xml_data = read_file(val_installpath + "\\conf\\server.xml") doc = REXML::Document.new(xml_data) doc.elements.each('Server/Service/Connector') do |e| ports << e.attributes['port'] end ports.uniq.each do |p| print_good("\t\t+ Port: #{p}") found = true results << [session.sock.peerhost,"#{val_version}",p,appname] end if found print_good("\t\t+ Application: [#{appname}]") else print_error("\t\t! port not found") end return results rescue print_error("\t\t! could not identify information") return results || [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def web_servers; machines_by_role('web'); end", "def http_servers\r\n HTTPServersController.instance\r\n end", "def run\n\n installs = []\n results = []\n users = []\n print_status(\"Enumerating Tomcat Servers on #{sysinfo['Computer']}\")\n if check_tomcat\n installs += identify_reg...
[ "0.64326626", "0.60362685", "0.59377015", "0.5931608", "0.58357364", "0.5815215", "0.5794107", "0.5774528", "0.57668376", "0.57475555", "0.5616439", "0.5587595", "0.54792386", "0.5468824", "0.5464135", "0.5431755", "0.539432", "0.53930354", "0.53882945", "0.5382646", "0.53735...
0.6836045
0
enumerate tomcat users from its user base
def enumerate_tomcat_creds(val_installpath) users = [] userpath = val_installpath + "\\conf\\tomcat-users.xml" if exist?(userpath) xml_data = read_file(userpath) doc = REXML::Document.new(xml_data) if not doc.elements.empty? doc.elements.each('tomcat-users/user') do |e| e_user=e.attributes['name'] if e_user.length >0 e_user=e.attributes['name'] else e.user=e_user=e.attributes['username'] end users << [ e_user,e.attributes['password'],e.attributes['roles'] ] print_good("\t\t+ User:[#{e_user}] Pass:[#{e.attributes['password']}] Roles:[#{e.attributes['roles']}]") end else print_error("\t\t! No Users Found") return users end end return users rescue print_error("\t\t! could not identify users") return users || [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enum_users\n\tos = @client.sys.config.sysinfo['OS']\n\tusers = []\n\tuser = @client.sys.config.getuid\n\tpath4users = \"\"\n\tsysdrv = @client.fs.file.expand_path(\"%SystemDrive%\")\n\n\tif os =~ /7|Vista|2008/\n\t\tpath4users = sysdrv + \"\\\\users\\\\\"\n\t\tprofilepath = \"\\\\AppData\\\\Local\\\\VMware\\\\...
[ "0.6862172", "0.65575856", "0.65317076", "0.6502708", "0.6494671", "0.6382336", "0.63803416", "0.6372556", "0.63023525", "0.6260465", "0.6241757", "0.6241439", "0.6220845", "0.62082887", "0.6207103", "0.6193129", "0.61923903", "0.61923903", "0.61729777", "0.6164116", "0.61596...
0.76684684
0
helper functions this method identifies the correct registry path to tomcat details, and returns [path,version]
def identify_registry values = [] basekey = "HKLM\\SOFTWARE\\Apache Software Foundation\\Tomcat" instances = registry_enumkeys(basekey) if not instances.nil? and not instances.empty? instances.each do |i| major_version_key = "#{basekey}\\#{i}" services = registry_enumkeys(major_version_key) if services.empty? val_installpath = registry_getvaldata(major_version_key,"InstallPath") val_version = registry_getvaldata(major_version_key,"Version") values << [val_installpath,val_version] else services.each do |s| service_key = "#{major_version_key}\\#{s}" val_installpath = registry_getvaldata(service_key,"InstallPath") val_version = registry_getvaldata(service_key,"Version") values << [val_installpath,val_version] end end end end return values rescue print_error("\t\t! failed to locate install path") return nil || [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enumerate_tomcat(val_installpath,val_version)\n results = []\n found = false\n print_good(\"\\t\\t+ Version: #{val_version}\")\n print_good(\"\\t\\t+ Path: #{val_installpath}\")\n\n if not exist?(val_installpath + \"\\\\conf\\\\server.xml\")\n print_error(\"\\t\\t! tomcat configuration not ...
[ "0.622214", "0.5663957", "0.5573217", "0.55712086", "0.5569116", "0.5569116", "0.5542466", "0.5501462", "0.545338", "0.54269266", "0.53060037", "0.52631706", "0.5259499", "0.5243932", "0.5199581", "0.5195238", "0.5195238", "0.5189552", "0.5184804", "0.5169074", "0.51611453", ...
0.7595177
0
this function extracts the application name from the main page of the web application
def find_application_name(val_installpath) index_file = ['index.html','index.htm','index.php','index.jsp','index.asp'] path = val_installpath + "\\webapps" if not directory?(path + "\\ROOT") print_error("\t\t! expected directory wasnt found") return "Unknown" end index_file.each do |i| if not exist?("#{path}\\ROOT\\#{i}") next end data = read_file(path + "\\ROOT\\#{i}") if data =~ /(?i)<title>([^<]+)<\/title>/ return $1 else #look for redirect as name if data =~ /(?i)onload=\"?document\.location\=['"]?([\/\w\d]+)['"]?\"?/ return $1.gsub("/","") end end end return "Unknown" rescue print_error("\t\t! could not identify application name") return "Unknown" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_application_name\r\n root_info = get_rails_root_info\r\n root_info.split('/').last.capitalize\r\n end", "def appname\n fetch(:appname) || script_name\n end", "def application_name\n Rails.root.to_s.split('/').last.underscore\n end", "def app_name\n return @app_name\n ...
[ "0.7523597", "0.70779747", "0.69166005", "0.6909961", "0.6909961", "0.69086444", "0.6899426", "0.6898249", "0.6807127", "0.68024635", "0.67787886", "0.6753241", "0.674465", "0.6741372", "0.6703353", "0.6682344", "0.6644", "0.66302735", "0.66130155", "0.66077757", "0.6604901",...
0.7601619
0
smaller value goes left, bigger value goes right, equal goes right
def push_node(node, value) new_node = Node.new(value) if node if(value > node.value) if(node.right) push_node(node.right, value) else node.right = new_node end else if(node.left) push_node(node.left, value) else node.left = new_node end end else @root = new_node end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delta_right_top\n\t\tif cl[0] > 1 \n\t\t\t[right_top, @map.grid[cl] - @map.grid[ right_top ]]\n\t\telse\n\t\t\t# give a very large number that will never be chosen\n\t\t\t[right_top, 99999999999]\n\t\tend\n\tend", "def width\n (lhs > rhs) ? lhs - rhs + 1 : rhs - lhs + 1\n end", "def up(side, num)\n...
[ "0.6290224", "0.6281278", "0.62460405", "0.6240728", "0.6233802", "0.62136924", "0.6177372", "0.61235106", "0.60882914", "0.60539263", "0.6036154", "0.60345453", "0.6030147", "0.60084665", "0.6001757", "0.5996854", "0.59952044", "0.5986168", "0.5985295", "0.59825426", "0.5964...
0.0
-1
lightbox where user enters an email in a lightbox to see if the email address has been used
def search markup = render_to_string :partial => "search_lightbox", :layout => false render :json => { :code => 200, :klass => 'success', :markup => markup }.to_json and return end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_email_address\n\t logger.info \"Checking email address\"\n\t logger.info params.inspect\n\t user = OrderUser.find_by_email_address(params[:email_address])\n\t if user\n\t # Show pop window with login page...\n\t render(:update) { |page| page.call('showLoginWin', user.email_address) }\n\t ret...
[ "0.68859005", "0.647342", "0.6197803", "0.59862256", "0.59838855", "0.5957083", "0.5909828", "0.58743834", "0.58735615", "0.5860163", "0.58366066", "0.5836318", "0.5824428", "0.577771", "0.5772673", "0.57675", "0.5753664", "0.5735303", "0.5719504", "0.56913507", "0.5676309", ...
0.0
-1
Get the threshold attribute fro vspecs
def get_threshold d = self.vspecs.select(:value).where(name: 'threshold').first return d != nil ? d.value : d end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def threshold\n @threshold || 95\n end", "def threshold\n @threshold ||= Reputation::Threshold.lookup(self.action, self.sender, :tier => self.tier)\n end", "def alert_threshold\n return @alert_threshold\n end", "def threshold_x\n @zab\n end", "def threshold...
[ "0.6748271", "0.6162388", "0.5883103", "0.57758033", "0.5767091", "0.57268924", "0.5550531", "0.553252", "0.54922795", "0.5489839", "0.54663074", "0.5466053", "0.54520977", "0.54387635", "0.54340863", "0.5424274", "0.53749126", "0.53602225", "0.53415895", "0.5297857", "0.5282...
0.8491369
0
TODO: this may be too strict a policy, consider removing validate :ensure_site_root Validate to ensure this application has one and only one Site object with subdomain = 'www'
def ensure_site_root if Site.all.count == 0 and subdomain != "www" errors.add(:subdomain, "must be 'www' since this is the first site record. Note: the 'www' sudomain will be the site used when a request asks for '' subdomain.") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_client_domain\n subdomain = request.subdomains(0).first\n if false && Rails.env == 'production'\n if current_client and (subdomain.blank? or subdomain != current_client.domain)\n redirect_to root_url(:subdomain => current_client.domain)\n end\n end\n end", "def validate_admi...
[ "0.6721621", "0.660927", "0.6489098", "0.6447754", "0.64194125", "0.635698", "0.63540465", "0.6319016", "0.6315922", "0.63062006", "0.6270873", "0.6240064", "0.62272835", "0.62023914", "0.6194735", "0.6190427", "0.61804736", "0.61507344", "0.6127358", "0.6116581", "0.6109395"...
0.84428966
0
Scopes Helpers Caller for the FLAT (level 1 and 2 combined) page tree creation
def flat_page_tree @flat_tree ||= ([{ :key => "page_#{self.root_page.id}".to_sym, :name => self.root_page.menu_name, :url => self.root_page.url, :options => {:class => "#{self.root_page.page_type} #{self.root_page.displayed ? '' : 'not-displayed'}"}, :items => [] }] + self.root_page.children.collect {|page| page.tree_hash_value } ) @flat_tree end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_tree\n\tend", "def create_basic_menu_tree\n # Instantiate the blogs and calendars pages\n self.errors[:base] << self.root_page.children.create(\n :menu_name => blogs_shortcut.humanize, :title => blogs_shortcut.humanize, :shortcut => blogs_shortcut, :displayed => false, :layout_name => DEFAULT...
[ "0.6186869", "0.61423045", "0.5978832", "0.59569067", "0.5953547", "0.594655", "0.5928279", "0.59175396", "0.5869333", "0.58209926", "0.5783825", "0.57587624", "0.57422435", "0.5704429", "0.56809026", "0.5643737", "0.5631127", "0.5631127", "0.56232095", "0.56147915", "0.56097...
0.6646433
0
Caller for the page tree creation
def page_tree @tree ||= [self.root_page.tree_hash_value] @tree end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_template_pages; end", "def recursive_create_page(page, parent=nil)\n Globalize.locale = @master_locale\n puts \"#{page['title']}\"\n p = Refinery::Page.find_by_title page['title']\n if not p or p.parent != parent\n puts \"+++ Create page #{page['title']} (#{page['type']})\"\n if par...
[ "0.71134233", "0.7024346", "0.6984781", "0.6935168", "0.68640876", "0.6759688", "0.671847", "0.6705994", "0.6661726", "0.6648058", "0.6631179", "0.6544311", "0.64667445", "0.64607036", "0.64607036", "0.6404219", "0.639301", "0.6351574", "0.63514984", "0.63411707", "0.63220596...
0.6310199
22
Get this site's page by the passed in shortcut. NOTE returns the root page if the shorcut is '' (to make site root requests work)
def initialize_requested_page_by_shortcut(shortcut) return root_page if shortcut.blank? pages.where(:shortcut => shortcut).try(:first) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home_shortcut\n (config_params||DEFAULT_CONFIG_PARAMS)[\"Home Shortcut\"]\n end", "def page\n\t\tpage = request.path.split(\"/\")[-1]\n\tend", "def root_page\n sitemap.find_resource_by_path(config.index_file)\n end", "def home_page\n @home_page ||= \"/#{(Page.find_by_title('Home') || Page.firs...
[ "0.56269073", "0.5525106", "0.54464436", "0.53625613", "0.5333561", "0.5324327", "0.5287929", "0.52434486", "0.5215372", "0.5207151", "0.5161987", "0.51554024", "0.51455677", "0.51329124", "0.5119301", "0.51164573", "0.51111746", "0.5101725", "0.51009494", "0.50985265", "0.50...
0.7200968
0
Attempts to create the basic site tree hierarchy
def initialize_site_tree self.errors[:base] << 'Site Tree root already initialized!' if root_page return (create_home_page and create_basic_menu_tree) if errors.empty? return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_basic_menu_tree(site)\n root = site.page; errors = []\n # Instantiate the blogs and calendars pages\n errors = errors + root.children.create(:menu_name => 'Blogs', :title => 'Blogs', :shortcut => site.blogs_shortcut, :displayed => false).errors.full_messages\n errors = errors + root.children....
[ "0.73014075", "0.6922507", "0.6498049", "0.61730295", "0.61114115", "0.61049426", "0.60505414", "0.6020811", "0.598876", "0.59863603", "0.59679407", "0.5930412", "0.59075737", "0.590015", "0.58384275", "0.5834838", "0.5830074", "0.57958466", "0.5792213", "0.57673365", "0.5766...
0.72691214
1
Returns a sorted and indented site pagetree array for populating a element
def site_tree_select pages.order(:names_depth_cache).map { |c| ["--" * c.depth + c.menu_name, c.id] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end", "def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end", "def postorder\n return [] if @root == nil\n return po...
[ "0.61908144", "0.60607404", "0.60182565", "0.6008586", "0.59649575", "0.5927992", "0.5870829", "0.5849596", "0.57829845", "0.57441145", "0.5720621", "0.5720621", "0.5720621", "0.5720621", "0.5720621", "0.5720621", "0.5720621", "0.57176995", "0.5714293", "0.5679933", "0.567993...
0.5925327
6
Site specific methods Returns an array of reserved shortcut strings
def reserved_shortcuts [home_shortcut, items_shortcut, inventory_shortcut, blogs_shortcut, calendars_shortcut, categories_shortcut, items_shortcut].uniq.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortcuts\n these_shortcuts = {}\n ActiveSupport::Notifications.instrument 'add_console_shortcuts.cnfs', { shortcuts: these_shortcuts }\n these_shortcuts\n end", "def default_shortcuts\r\n {\r\n \"Ctrl+Shift+S\" => {\"description\"=>\"Displays Tr8n shortcuts\", \"script\...
[ "0.64448446", "0.6207497", "0.6160049", "0.6155059", "0.59052706", "0.58697176", "0.58693475", "0.585327", "0.58452594", "0.58181727", "0.57916075", "0.57804006", "0.5760081", "0.57489705", "0.5703611", "0.5678195", "0.56532997", "0.5590705", "0.5589265", "0.5586007", "0.5542...
0.7383321
0
Returns all the reserved pages for this site
def reserved_pages [initialize_requested_page_by_shortcut(home_shortcut), initialize_requested_page_by_shortcut(items_shortcut), initialize_requested_page_by_shortcut(inventory_shortcut), initialize_requested_page_by_shortcut(blogs_shortcut), initialize_requested_page_by_shortcut(calendars_shortcut), initialize_requested_page_by_shortcut(categories_shortcut), initialize_requested_page_by_shortcut(items_shortcut)].uniq.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pages\n @pages ||= []\n end", "def pages\n @pages ||= get_pages\n end", "def pages\n return @pages\n end", "def sitemap_pages\n @sitemap_pages ||= proper_pages.excluding_slices.group_by(&:page_id)\n end", "def pages\n @pages.values\n end", "def pa...
[ "0.682728", "0.67691374", "0.6581358", "0.65652275", "0.6508019", "0.6489316", "0.64686054", "0.6441292", "0.6299318", "0.62617207", "0.6261476", "0.6175558", "0.61012775", "0.60433686", "0.59816116", "0.59806746", "0.5978563", "0.59647155", "0.5959312", "0.59564364", "0.5933...
0.7780443
0
Returns this site's Blog shortcut
def blogs_shortcut (config_params||DEFAULT_CONFIG_PARAMS)["Blogs Shortcut"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def blog_feed_url \n if Crunchbase::Company.get(crunchbase_slug).blog_feed_url.nil?\n \" \"\n else\n Crunchbase::Company.get(crunchbase_slug).blog_feed_url\n end\n end", "def bloglink\n @@URL = params[:blog_url]\n end", "def noter_blog_url\n\t\t\"blogs/#{self.noter.main_blog_id}\"...
[ "0.6823278", "0.6809434", "0.6744738", "0.6633761", "0.66084456", "0.6492549", "0.6489949", "0.648176", "0.6412989", "0.63749355", "0.63122386", "0.63122386", "0.62751627", "0.6265129", "0.62632114", "0.6257097", "0.6220066", "0.621505", "0.62106675", "0.620719", "0.6205457",...
0.7854546
0
Returns this site's Calendar shortcut
def calendars_shortcut (config_params||DEFAULT_CONFIG_PARAMS)["Calendars Shortcut"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def simple_day_calendar_path\n request.fullpath.split('?').first\n end", "def simple_calendar_path\n request.fullpath.split('?').first\n end", "def simple_calendar_path\n request.fullpath.split('?').first\n end", "def shared_url\n @calendar_info['{http://calendarserver.org/ns/}...
[ "0.62709016", "0.6191745", "0.6191745", "0.6089647", "0.57848835", "0.57003933", "0.56881857", "0.5605475", "0.5605157", "0.5540235", "0.55364835", "0.5496811", "0.53981", "0.5362459", "0.53427464", "0.5342296", "0.53255486", "0.53197056", "0.5278307", "0.5259168", "0.5212415...
0.78776747
0
Returns this site's Inventory shortcut
def inventory_shortcut (config_params||DEFAULT_CONFIG_PARAMS)["Inventory Shortcut"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def items_shortcut\n (config_params||DEFAULT_CONFIG_PARAMS)[\"Items Shortcut\"]\n end", "def inventory_path\n if config.inventory_path\n config.inventory_path\n else\n @inventory_path ||= generate_inventory\n end\n end", "def hotkey\n @link.HotKe...
[ "0.66064334", "0.6207043", "0.58358854", "0.57684267", "0.5735754", "0.5680048", "0.5659385", "0.5649475", "0.56462747", "0.5632721", "0.5481167", "0.54492444", "0.5407954", "0.540204", "0.53290987", "0.53269935", "0.5302217", "0.5276095", "0.52684784", "0.5251126", "0.524571...
0.7969728
0
Returns this site's Categories shortcut
def categories_shortcut (config_params||DEFAULT_CONFIG_PARAMS)["Categories Shortcut"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def category\n string = Array(@data['categories'])[0]\n return '' if string.to_s.empty?\n\n string.split('/').map { |c|\n Silly::StringFormat.clean_slug_and_escape(c)\n }.join('/')\n end", "def categories\n rpg_shop.handled_categories\n end", "def categories\n category\n ...
[ "0.675686", "0.65229803", "0.64929396", "0.64821535", "0.64154726", "0.6393149", "0.6379505", "0.6310117", "0.6269699", "0.6268353", "0.6260552", "0.6211475", "0.62065685", "0.62065685", "0.62065685", "0.62065685", "0.62065685", "0.62065685", "0.61971265", "0.61845714", "0.61...
0.78812224
0
Returns this site's Items shortcut
def items_shortcut (config_params||DEFAULT_CONFIG_PARAMS)["Items Shortcut"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inventory_shortcut\n (config_params||DEFAULT_CONFIG_PARAMS)[\"Inventory Shortcut\"]\n end", "def get_items\n @items\n end", "def get_item(item_name)\n return @menu[item_name]\n end", "def reserved_shortcuts\n [home_shortcut, items_shortcut, inventory_shortcut, blogs_shortcut, calenda...
[ "0.6317148", "0.6081652", "0.6022729", "0.6014716", "0.6014306", "0.5932579", "0.5891196", "0.58832264", "0.58832264", "0.58832264", "0.58832264", "0.58765763", "0.58297163", "0.58213896", "0.58199954", "0.58140516", "0.58040285", "0.580325", "0.57760644", "0.5772984", "0.576...
0.78081214
0
Returns this site's Root page shortcut
def home_shortcut (config_params||DEFAULT_CONFIG_PARAMS)["Home Shortcut"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def root\n @site.root\n end", "def root_page\n sitemap.find_resource_by_path(config.index_file)\n end", "def root\n self.home\n self\n end", "def get_home_link()\n if current_page?(root_path)\n return '#'\n else\n return root_path\n end\n end", "def root_pat...
[ "0.6940286", "0.6645622", "0.65997475", "0.6537098", "0.65148634", "0.65148634", "0.65148634", "0.64370865", "0.6436839", "0.63663685", "0.6282287", "0.6275377", "0.6235685", "0.6217555", "0.61965716", "0.61794794", "0.6126126", "0.6065756", "0.604577", "0.6004995", "0.600296...
0.6728846
1
True if this site should have a separate categories page
def create_categories_page? categories_shortcut != inventory_shortcut end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def categorizable?\n self.content_type.presence && self.site.has_plugin?(:categories) && self.accept_categories\n end", "def categories?\n false\n end", "def has_categories? \n true\n end", "def is_categories?\n is_entries? && params[:_taxonomies_].present? && params[:_slug_].present? && i...
[ "0.7837745", "0.7730043", "0.7388513", "0.73332804", "0.73292327", "0.70937294", "0.69993454", "0.6832144", "0.67219126", "0.6677543", "0.6549453", "0.6545929", "0.65245324", "0.6517241", "0.65013546", "0.6485441", "0.6456578", "0.64417416", "0.641762", "0.6372931", "0.635612...
0.77614266
1
True if this site should have a separate items page
def create_items_page? items_shortcut != inventory_shortcut end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def item_endpoint?(page)\n page == :item\n end", "def item_layout?\n layout_type == \"item\"\n end", "def include_page?(page)\n if !page.listed? || page.templatized? || !page.published?\n false\n elsif @_options[:exclude]\n (page.fullpath =~ @_options[:ex...
[ "0.725319", "0.6899293", "0.67459786", "0.67224485", "0.6613868", "0.6607695", "0.6576025", "0.6569195", "0.6566888", "0.65428984", "0.64966536", "0.6473393", "0.6416454", "0.63964576", "0.6358193", "0.6335215", "0.6307656", "0.6301841", "0.6293337", "0.6237882", "0.62355924"...
0.7585412
0
Set the config_params to the Application defaults...
def init_default_attributes self.config_params ||= DEFAULT_CONFIG_PARAMS self.has_inventory = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_config\n @config = AppConfig.find(params[:id])\n end", "def set_config(config)\n\t\tend", "def config_params\n app_props.merge(idp_props).merge(custom_props)\n end", "def set_app_config\n @app_config = AppConfig.find(params[:id])\n end", "def set_config(env, override_con...
[ "0.6825517", "0.67612404", "0.6736087", "0.6730498", "0.6700601", "0.6671443", "0.66425085", "0.6614271", "0.6611081", "0.65718645", "0.65504134", "0.65228325", "0.64943117", "0.64943117", "0.64943117", "0.64943117", "0.64943117", "0.6490978", "0.647053", "0.6446415", "0.6433...
0.6121425
42
Creates an array of pages of this site that is suitable for a collection_select
def page_tree_selector pages.order(:names_depth_cache).map { |page| [ "---" * page.depth + (page.displayed ? " " : " (invisible) ") + page.menu_name, page.id ] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_pages\n #find page terminator\n start_line = 0\n current_line = 0\n @lines.each_with_index do |line, i|\n current_line = i\n if end_of_page?(line, i)\n @pages << Page.new(start_line, i) # every page in raw document\n start_line = i + 1 \...
[ "0.6921595", "0.6909491", "0.66014516", "0.65484345", "0.6530353", "0.64637506", "0.64464617", "0.6436662", "0.64326614", "0.6426586", "0.63861537", "0.6380483", "0.6373657", "0.6372531", "0.63339615", "0.630418", "0.6297474", "0.629328", "0.6285694", "0.62725866", "0.6263978...
0.0
-1
Site Building Methods Build the Home page for the passed in site
def create_home_page home_page = self.build_root_page( :title => home_shortcut.humanize, :menu_name => home_shortcut.humanize, :shortcut => home_shortcut, :layout_name => HOME_PAGE_TEMPLATE, :displayed => true, :cachable => true, :total_element_areas => TEMPLATES[HOME_PAGE_TEMPLATE]["total_element_areas"] ) logger.debug "Home Page: #{home_page.inspect}" home_page.save self.errors[:base] << home_page.errors.full_messages.map {|msg| "Error on creating the 'Home' page: " + msg } # Log any errors unless errors.empty? logger.error "*********** site.create_home_page Errors: *************" errors.full_messages.each {|err| logger.error "#{err}" } logger.error "********* End site.create_home_page Errors: ***********" end return errors.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_site_for_user\n #ditinguer nom et url\n create_site(params[:site][:url],params[:user][:site], current_user)\n end", "def template_page(site); end", "def home_page\n @home_page ||= \"/#{(Page.find_by_title('Home') || Page.first(:order => 'position')).title.downcase.parameterize}\"\n end", ...
[ "0.6763356", "0.6698213", "0.653834", "0.65226924", "0.64849746", "0.64759535", "0.64277303", "0.63679016", "0.633144", "0.63158524", "0.63158524", "0.6285372", "0.6280785", "0.62267447", "0.6221897", "0.61532784", "0.61532784", "0.61372995", "0.61336255", "0.6109991", "0.610...
0.6093931
21
Build the basic menu tree. Should be called after the Site and Root page are created
def create_basic_menu_tree # Instantiate the blogs and calendars pages self.errors[:base] << self.root_page.children.create( :menu_name => blogs_shortcut.humanize, :title => blogs_shortcut.humanize, :shortcut => blogs_shortcut, :displayed => false, :layout_name => DEFAULT_TEMPLATE, :total_element_areas => TEMPLATES[DEFAULT_TEMPLATE]["total_element_areas"] ).errors.full_messages.map {|msg| "Error on creating the 'Blogs' page: " + msg } self.errors[:base] << self.root_page.children.create( :menu_name => calendars_shortcut.humanize, :title => calendars_shortcut.humanize, :shortcut => calendars_shortcut, :displayed => false, :layout_name => DEFAULT_TEMPLATE, :total_element_areas => TEMPLATES[DEFAULT_TEMPLATE]["total_element_areas"] ).errors.full_messages.map {|msg| "Error on creating the 'Calendars' page: " + msg } # Instantiate the inventory structure if this site has an inventory if has_inventory self.errors[:base] << self.root_page.children.create( :menu_name => inventory_shortcut.humanize, :title => inventory_shortcut.humanize, :shortcut => inventory_shortcut, :displayed => true, :layout_name => DEFAULT_TEMPLATE, :total_element_areas => TEMPLATES[DEFAULT_TEMPLATE]["total_element_areas"] ).errors.full_messages.map {|msg| "Error on creating the 'Inventory' page: " + msg } # Instantiate the items page if this site has an a specific page for Items self.errors[:base] << self.root_page.children.create( :menu_name => items_shortcut.humanize, :title => items_shortcut.humanize, :shortcut => items_shortcut, :displayed => false, :layout_name => DEFAULT_TEMPLATE, :total_element_areas => TEMPLATES[DEFAULT_TEMPLATE]["total_element_areas"] ).errors.full_messages.map {|msg| "Error on creating the 'Items' page: " + msg } if create_items_page? # Instantiate the categories page if this site has an a specific page for Categories self.errors[:base] << self.root_page.children.create( :menu_name => categories_shortcut.humanize, :title => categories_shortcut.humanize, :shortcut => categories_shortcut, :displayed => false, :layout_name => DEFAULT_TEMPLATE, :total_element_areas => TEMPLATES[DEFAULT_TEMPLATE]["total_element_areas"] ).errors.full_messages.map {|msg| "Error on creating the 'Categories' page: " + msg } if create_categories_page? end # Log any errors unless errors.empty? logger.error "*********** site.create_basic_menu_tree Errors: *************" errors.full_messages.each {|err| logger.error "#{err}" } logger.error "********* End site.create_basic_menu_tree Errors: ***********" end # Return true if there were no errors return errors.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_basic_menu_tree(site)\n root = site.page; errors = []\n # Instantiate the blogs and calendars pages\n errors = errors + root.children.create(:menu_name => 'Blogs', :title => 'Blogs', :shortcut => site.blogs_shortcut, :displayed => false).errors.full_messages\n errors = errors + root.children....
[ "0.779465", "0.7316123", "0.7155567", "0.6716937", "0.6710134", "0.66022736", "0.65789795", "0.6472374", "0.64318466", "0.6425628", "0.6407439", "0.63552433", "0.63501304", "0.62933165", "0.61857754", "0.61788225", "0.61371964", "0.6112141", "0.60888267", "0.6087547", "0.6076...
0.7265325
2
Call the method directors_database to retrieve the NDS
def pretty_print_nds(nds) # Change the code below to pretty print the nds with pp require 'pp' pp directors_database end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @dns = Dn.all\n end", "def db_ddns_access(data={})\n return nil if data.empty? || (!data.has_key?(:id) && !data.has_key?(:device_id) && !data.has_key?(:ip_address) && !data.has_key?(:full_domain))\n \n where_data = data.clone\n\n if data.has_key?(:full_domain) then\n full_domain ...
[ "0.5962282", "0.5917655", "0.573061", "0.573061", "0.5696976", "0.5647392", "0.5623889", "0.56018966", "0.5586423", "0.55815876", "0.55814934", "0.5535011", "0.5483551", "0.54736954", "0.5452035", "0.5441273", "0.5437387", "0.5412612", "0.5402453", "0.5402453", "0.5395019", ...
0.0
-1
TODO create the is_admin? helper to verify if the user is admin before_filter :is_admin?, :change_state
def check_deadline true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_admin?\n is_admin == 1\n end", "def is_admin?\n admin?\n end", "def is_admin\n admin?\n end", "def is_admin?\n admin\n end", "def is_admin?\n admin\n end", "def admin_user?\n self.admin ==true\n end", "def admin_access?\n admin?\n end", "def admin?\n user.a...
[ "0.74286866", "0.7241467", "0.7231316", "0.7218403", "0.7218403", "0.72072315", "0.7205637", "0.71968126", "0.7171461", "0.715694", "0.7140661", "0.7121933", "0.71067506", "0.7103457", "0.7096696", "0.70874465", "0.7074953", "0.70656914", "0.7058699", "0.70514333", "0.7050001...
0.0
-1
Don't let the applicant to edit their account def edit
def step2 # TODO Create current_order helper to access the current_order from the admin config @questions = Question.where(:order => current_order).order("priority asc") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cannot_edit(_t)\n !session[:is_administrator] && !_t.approver_id.blank?\n end", "def prevent_edit\n !can_edit?\n end", "def edit\n if !(current_user.id == @user.id || is_admin?)\n indicate_illegal_request I18n.t('users.not-your-account')\n end\n end", "def cannot_edit(_offer)\n ...
[ "0.782893", "0.763326", "0.7451067", "0.71823436", "0.712579", "0.6990765", "0.68797135", "0.68175304", "0.68055475", "0.6776346", "0.67399275", "0.65835947", "0.65583694", "0.65576094", "0.65515864", "0.6530643", "0.65259594", "0.65259594", "0.65129393", "0.65053225", "0.648...
0.0
-1
Print functionality for the Admin
def print end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print\n end", "def print\n\n end", "def print\n @inv = PurchaseOrder.where(\"invoice_number='#{@inv.invoice_number}' AND is_history IS FALSE\").last\n if @inv.can_print_inv?\n @inv.print_invoice_date = Time.now\n if @inv.print_inv\n PurchaseOrder.send_notifications(@inv)\n ...
[ "0.6820222", "0.680047", "0.6717208", "0.6666957", "0.64095145", "0.64036363", "0.63656014", "0.63296205", "0.6315756", "0.63039994", "0.6280854", "0.62790954", "0.6242604", "0.62378454", "0.62256974", "0.621639", "0.62112176", "0.6208049", "0.61862373", "0.61839265", "0.6183...
0.6655148
6
GET /videos GET /videos.json
def index @videos = Video.where(user_id: current_user.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end", "def index\n @videos = Video.all\n render json: @videos\n end", "def list\n @videos = Video.all\n\n respond_to do |format|\n format.html # list.html.erb\n format.json { render json: @videos }\n e...
[ "0.8300022", "0.7734552", "0.77048963", "0.75849354", "0.74897736", "0.74893093", "0.74893093", "0.74893093", "0.74893093", "0.74756104", "0.73633087", "0.7358063", "0.7357167", "0.730496", "0.72600365", "0.7200847", "0.7194637", "0.71250415", "0.71250415", "0.71250415", "0.7...
0.65740263
68
GET /videos/1 GET /videos/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end", "def index\n @videos = Video.all\n render json: @videos\n end", "def list\n @videos = Video.all\n\n respond_to do |format|\n format.html # list.html.erb\n format.json { render json: @videos }\n e...
[ "0.77855194", "0.7450134", "0.7386234", "0.73798877", "0.73798877", "0.73798877", "0.73798877", "0.73798877", "0.73798877", "0.73798877", "0.73703194", "0.7363398", "0.73398286", "0.7338815", "0.7338815", "0.7338815", "0.7338815", "0.7308188", "0.722379", "0.72142017", "0.720...
0.0
-1
POST /videos POST /videos.json
def create @video = Video.new(video_params) @video.update(user_id: current_user.id) respond_to do |format| if @video.save format.html { redirect_to @video, notice: 'Video was successfully uploaded.' } format.json { render json: { files: [@video.to_jq_upload], url: video_path(@video), message: "Uploaded successfully." }, status: :created, location: @video } else format.html { render :new } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @video = Video.new(video_params)\n @video.save!\n render json: @video\n end", "def create\n @video = @room.videos.new(video_params)\n respond_to do |format|\n if @video.save\n format.html { redirect_to upload_video_path(@video), notice: 'Video was successfully created.' }...
[ "0.7559166", "0.72561485", "0.72147936", "0.72094315", "0.7070432", "0.70647645", "0.70605457", "0.70605457", "0.70605457", "0.70605457", "0.69911706", "0.69875956", "0.69875956", "0.69875956", "0.69875956", "0.69875956", "0.69389236", "0.69220686", "0.69220686", "0.6870992", ...
0.68684244
20
PATCH/PUT /videos/1 PATCH/PUT /videos/1.json
def update respond_to do |format| if @video.update(video_params) format.html { redirect_to @video, notice: 'Video was successfully updated.' } format.json { render json: { files: [@video.to_jq_upload], url: video_path(@video), message: "Uploaded successfully." }, status: :created, location: @video } else format.html { render :edit } format.json { render json: @video.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @video.update(video_params)\n render json: @video\n end", "def update\n @video = Video.find(params[:id])\n\n respond_to do |format|\n if @video.update_attributes(params[:video])\n format.html { redirect_to @video, notice: 'Video was successfully updated.' }\n format.j...
[ "0.7237686", "0.68665653", "0.68665653", "0.68647146", "0.68624663", "0.68624663", "0.68624663", "0.68624663", "0.68624663", "0.68624663", "0.68624663", "0.6819483", "0.6819483", "0.6819483", "0.6819483", "0.6819483", "0.67747194", "0.67690694", "0.672215", "0.6719619", "0.67...
0.67994
16
DELETE /videos/1 DELETE /videos/1.json
def destroy @video.destroy respond_to do |format| format.html { redirect_to videos_url, notice: 'Video was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @video = Video.find(params[:id])\n @video.destroy\n\n respond_to do |format|\n format.html { redirect_to videos_url }\n format.json { head :ok }\n end\n end", "def destroy\n @video = Video.find(params[:id])\n @video.destroy\n\n respond_to do |format|\n format.ht...
[ "0.7782917", "0.7782917", "0.7768144", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.77617705", "0.7723812", "0.77067566", "0.7692495", "0.7692495", "0.7692495", "0....
0.74367225
50
Use callbacks to share common setup or constraints between actions.
def set_video @video = Video.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.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def video_params params.require(:video).permit(:video, :title, :subtitle, :description, :is_published, :is_showed_on_tv, :showed_date) 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
this should add all extra CAS attributes returned by the server to the current session extra var in session: cas_givenname, cas_surname, cas_ugentStudentID, cas_mail, cas_uid (= UGent login)
def cas_extra_attributes=(extra_attributes) extra_attributes.each do |name, value| # I prefer a case over reflection; this is safer if we suddenly get an # extra attribute without column case name.to_sym when :givenname self.cas_givenname = value when :surname self.cas_surname = value when :ugentStudentID self.cas_ugentStudentID = value when :mail self.cas_mail = value when :uid self.cas_uid = value end end self.save! end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cas_extra_attributes=(attributes)\n self.username = attributes['uid']\n self.email = attributes['email']\n self.given_name = attributes['givenName']\n self.surname = attributes['surname']\n self.lnumber = attributes['lnumber']\n\n update_roles_from_attributes(attributes)\n end", "def cas_e...
[ "0.66602504", "0.6546296", "0.6511727", "0.5993609", "0.59289557", "0.5881834", "0.55592775", "0.53417873", "0.5307094", "0.5307068", "0.5245192", "0.52332306", "0.514473", "0.5092795", "0.50722736", "0.505293", "0.49901855", "0.49812922", "0.49759766", "0.49591163", "0.49397...
0.6955808
0
return Givenname + surname or username if these don't exist
def display_name if cas_surname and cas_givenname cas_givenname + ' ' + cas_surname else username end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name\n if first_name.present? || last_name.present?\n [first_name, last_name].join(\" \").strip\n else\n username\n end\n end", "def username_and_first_name\n if first_name.nil?\n username\n else\n \"#{username} (#{first_name})\"\n end\n end", "def find_name_or_email...
[ "0.804325", "0.7884902", "0.7881312", "0.77101576", "0.7545686", "0.7465101", "0.7458541", "0.7457374", "0.74375004", "0.74117345", "0.74073774", "0.7361129", "0.73476", "0.7340567", "0.7312568", "0.7300445", "0.7282839", "0.7229676", "0.72215444", "0.7205949", "0.7205303", ...
0.75126797
5
display_board displays the tictactoe board in its current state
def display_board(board) puts " #{board[0]} | #{board[1]} | #{board[2]} " puts "-----------" puts " #{board[3]} | #{board[4]} | #{board[5]} " puts "-----------" puts " #{board[6]} | #{board[7]} | #{board[8]} " end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_board\n puts \"#{human.name}: #{human.marker}, #{computer.name}: #{computer.marker}\"\n puts \"Round #{@round}.\"\n puts \"Score: #{human.score} - #{computer.score}\"\n puts \"\"\n board.draw\n puts \"\"\n end", "def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@boa...
[ "0.8062544", "0.7983128", "0.7911662", "0.7900051", "0.78805494", "0.7835746", "0.7835213", "0.78253996", "0.7820055", "0.781616", "0.781616", "0.781616", "0.781616", "0.781616", "0.781616", "0.781616", "0.781616", "0.781616", "0.781616", "0.781616", "0.77971554", "0.779715...
0.0
-1
input_to_index converts user_input to a space on the board
def input_to_index(user_input) user_input.to_i - 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input_to_index(user_input)\n user_input.to_1 - 1 #they are entering a number we have to translate that to the board speak\nend", "def input_to_index(user_input)\n index = user_input.to_i - 1\n end", "def input_to_index(user_input)\n index = user_input.to_i - 1\n end", "def input_to_index(user_in...
[ "0.8484308", "0.83467066", "0.83467066", "0.8317365", "0.82850707", "0.81438774", "0.81348085", "0.8089392", "0.80326277", "0.80169487", "0.80169487", "0.80169487", "0.80169487", "0.8000491", "0.79984105", "0.79870486", "0.7959417", "0.79498804", "0.7929427", "0.7929427", "0....
0.7639618
71
move assigns a character to a board position
def move(board, position, char) board[position] = char end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(position, char)\n @board[position] = char\n end", "def move(index, character)\n @board[index] = character\n end", "def move(index, character)\n @board[index] = character\n return @board\n end", "def move (board, position, character = \"X\")\n board[(position.to_i - 1)] = characte...
[ "0.8539179", "0.84773695", "0.82644475", "0.82475615", "0.8207472", "0.8182632", "0.8130658", "0.809876", "0.80756783", "0.8012327", "0.79971933", "0.7994577", "0.7963018", "0.7962876", "0.7945989", "0.7942607", "0.7939912", "0.78921556", "0.7879026", "0.7879026", "0.7875464"...
0.83144844
2
valid_move? determines if 1) the user inputted position is part of the board and 2) if the user inputted position is occupied
def valid_move?(board, index) !position_taken?(board, index) && index.between?(0, 8) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend", "def valid_move?(board, position)\n position_taken?(board, position) == false && position.between?(0, 8) ? true : false\nend", "def valid_move?(board, position)\n !position_taken?(board, position) && posit...
[ "0.8740594", "0.8662444", "0.86260086", "0.8614045", "0.85828763", "0.8581576", "0.8579991", "0.857619", "0.8570465", "0.8566327", "0.8547736", "0.8542373", "0.8529323", "0.85292035", "0.85205", "0.85070395", "0.85011476", "0.84951144", "0.84923464", "0.84833395", "0.8470225"...
0.824862
95
won? returns either 1) false or 2) the winning combination of positions as an array
def won?(board) WIN_COMBINATIONS.each do |win_combination| # get indices of each win_combination win_index_1 = win_combination[0] win_index_2 = win_combination[1] win_index_3 = win_combination[2] # get values from board that map to each index in each win_combination position_1 = board[win_index_1] position_2 = board[win_index_2] position_3 = board[win_index_3] # Are all values X's? if (position_1 == "X" && position_2 == "X" && position_3 == "X") || (position_1 == "O" && position_2 == "O" && position_3 == "O") return win_combination end # else not a win_combination end # WIN_COMBINATIONS.each iteration return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def won?()\n\n # loops through the 2D array WIN_COMBINATIONS\n WIN_COMBINATIONS.each do |combination|\n\n # flags\n x_win = 0\n o_win = 0\n\n combination.each do |index|\n\n # checks if player X wins\n if @board[index] == \"X\"\n x_win += 1\n\n ...
[ "0.78665644", "0.7798424", "0.77421105", "0.7742098", "0.7727999", "0.7722321", "0.771851", "0.7708629", "0.7706023", "0.76972765", "0.76899815", "0.7688086", "0.76735884", "0.76565266", "0.7644631", "0.7641852", "0.7637307", "0.7636378", "0.7625904", "0.7619842", "0.7613176"...
0.7605167
21
winner returns the winning character
def winner(board) winner = won?(board) # if winner is an array, change winner to winning character if winner.class == Array winner = board[winner[0]] end # else winner is nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winner\r\n if self.won? != false\r\n if self.current_player == \"X\"\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end\r\n end", "def winner\n won = won?()\n if won != false\n if @board[won[0]] == \"X\"\n return \"X\"\n elsif @board[won[0]] ...
[ "0.79418296", "0.78804684", "0.78420895", "0.78241485", "0.7747964", "0.7743995", "0.77225894", "0.76964927", "0.7651746", "0.76385146", "0.76327884", "0.7617092", "0.76139945", "0.76117957", "0.76036197", "0.75986654", "0.75942147", "0.7591108", "0.7590491", "0.7582106", "0....
0.71133494
79
play is the main method for tic_tac_toe. It gives players turns until the game is over, and either congratulates the winner or says it's a draw.
def play(board) until over?(board) turn(board) end if won?(board) puts "Congratulations #{winner(board)}!" else # game was a draw puts "Cats Game!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end", "def play\n # Game play asks for players input on a turn of the game\n # Game play checks if the game is over af...
[ "0.815722", "0.81243026", "0.8115979", "0.804436", "0.79358834", "0.7916113", "0.79158455", "0.7915178", "0.79086846", "0.7905732", "0.79029495", "0.7888978", "0.78711045", "0.786793", "0.7858844", "0.784505", "0.7842272", "0.7808849", "0.78057176", "0.7796883", "0.7792233", ...
0.754365
72
The following method is called strong params see google
def listing_params params.require(:listing).permit(:title, :location, :description, :price_per_night, :photo, :nb_rooms, :isSmoker, :hasLatecheckout, :hasKitchen, :hasWifi, :hasSwimmingPool, :user_id, :isPetFriendly,{avatars:[]},:tag_list) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend", "def str...
[ "0.7177035", "0.71179724", "0.71161366", "0.71052426", "0.7099231", "0.7025278", "0.7013166", "0.7012788", "0.69819593", "0.69549894", "0.6897595", "0.68749213", "0.68749213", "0.68749213", "0.68749213", "0.68749213", "0.68749213", "0.68749213", "0.68749213", "0.68749213", "0...
0.0
-1
GET /notices GET /notices.json
def index @notices = current_user.notices.page params[:page] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @notices = Notice.all\n end", "def index\r\n @notices = Notice.all\r\n end", "def show\n @notice = @person.notices.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @notice }\n end\n end", "def show\n @notices = ...
[ "0.7222612", "0.71000004", "0.701604", "0.69339776", "0.68255925", "0.6764979", "0.65924907", "0.65418255", "0.6439317", "0.6424065", "0.6422495", "0.63960874", "0.61991286", "0.6175338", "0.6153071", "0.60381484", "0.60335356", "0.60101646", "0.59414107", "0.5919153", "0.585...
0.69772345
3
GET /notices/1 GET /notices/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @notice = @person.notices.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @notice }\n end\n end", "def index\n @notices = Notice.all\n end", "def show\n @notice = Notice.find(params[:id])\n\n respond_to do |format|...
[ "0.7227371", "0.69997895", "0.6967799", "0.68813264", "0.67949677", "0.6713763", "0.6705518", "0.65215755", "0.6466805", "0.6462293", "0.64482874", "0.6273666", "0.6141478", "0.60934174", "0.6084559", "0.60397226", "0.60207474", "0.59834325", "0.5962585", "0.5954247", "0.5899...
0.0
-1
POST /notices POST /notices.json
def create @notice = Notice.new(notice_params) @notice.user_id = current_user.id respond_to do |format| if @notice.save format.html { redirect_to @notice, notice: 'Notice was successfully created.' } format.json { render :show, status: :created, location: @notice } else format.html { render :new } format.json { render json: @notice.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @notice = Notice.new(notice_params)\n @notice.client = current_client if current_client\n @notice.order_num = 0\n\n shuffle_notices(current_client.id) if current_client\n\n @notices = Notice.all.where(client_id: current_client.id) if current_client\n\n respond_to do |format|\n i...
[ "0.70540506", "0.67937785", "0.669544", "0.6529281", "0.64448655", "0.6443271", "0.63405275", "0.6153747", "0.61272275", "0.6081726", "0.60454494", "0.6000015", "0.5968061", "0.59408754", "0.5903267", "0.589834", "0.5888397", "0.58857256", "0.5846333", "0.58360285", "0.582630...
0.6657025
3
PATCH/PUT /notices/1 PATCH/PUT /notices/1.json
def update respond_to do |format| if @notice.update(notice_params) format.html { redirect_to @notice, notice: 'Notice was successfully updated.' } format.json { render :show, status: :ok, location: @notice } else format.html { render :edit } format.json { render json: @notice.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @notice = @person.notices.find(params[:id])\n\n respond_to do |format|\n if @notice.update_attributes(params[:notice])\n format.html { redirect_to person_notices_path( @person), notice: 'notice was successfully updated.' }\n format.json { head :no_content }\n else\n ...
[ "0.6873917", "0.6842439", "0.6667211", "0.6479373", "0.64173067", "0.63586915", "0.6348861", "0.63381195", "0.62222576", "0.61685324", "0.61670905", "0.61611295", "0.6098392", "0.60831845", "0.6069388", "0.60462886", "0.60388327", "0.6038043", "0.6038043", "0.60267925", "0.59...
0.6500742
4
DELETE /notices/1 DELETE /notices/1.json
def destroy @notice.destroy respond_to do |format| format.html { redirect_to notices_url, notice: 'Notice was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @notice.destroy\n\n reorder_notices(current_client.id, @notice.order_num) if current_client\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n \n @notice = Notice.get(params[:id])\n @notice.destroy\n\n respond_to do |format|\n ...
[ "0.7369538", "0.7294262", "0.7294262", "0.71402365", "0.7024805", "0.69774115", "0.6974915", "0.6923815", "0.69222283", "0.68901795", "0.6877663", "0.6835848", "0.6762244", "0.6755455", "0.6659186", "0.6651999", "0.66516244", "0.6636687", "0.6607979", "0.6606389", "0.66040903...
0.719665
4
Use callbacks to share common setup or constraints between actions.
def set_notice @notice = Notice.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.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def notice_params params.require(:notice).permit(:title, :to, :from, :auther, :greet, :content) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
This method used to be useful for the `shouldAutorotateToOrientation` method, but the iOS 6 update deprecates that method. Instead, use the `supportedInterfaceOrientations` and return `autorotateMask`.
def autorotateToOrientation(orientation) device = UIDevice.currentDevice.userInterfaceIdiom if view.stylesheet and view.stylesheet.is_a?(Teacup::Stylesheet) and view.stylename properties = view.stylesheet.query(view.stylename, self, orientation) # check for orientation-specific properties case orientation when UIInterfaceOrientationPortrait # portrait is "on" by default, must be turned off explicitly if properties.supports?(:portrait) == nil and properties.supports?(:upside_up) == nil return true end return (properties.supports?(:portrait) or properties.supports?(:upside_up)) when UIInterfaceOrientationPortraitUpsideDown if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone # iphone must have an explicit upside-down style, otherwise this returns # false return properties.supports?(:upside_down) else # ipad can just have a portrait style return (properties.supports?(:portrait) or properties.supports?(:upside_down)) end when UIInterfaceOrientationLandscapeLeft return (properties.supports?(:landscape) or properties.supports?(:landscape_left)) when UIInterfaceOrientationLandscapeRight return (properties.supports?(:landscape) or properties.supports?(:landscape_right)) end return false end # returns the system default if device == UIUserInterfaceIdiomPhone return orientation != UIInterfaceOrientationPortraitUpsideDown else return true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def supportedInterfaceOrientations\n UIInterfaceOrientationMaskAll\n end", "def supportedInterfaceOrientations\n UIInterfaceOrientationMaskAll\n end", "def supportedInterfaceOrientations\n UIInterfaceOrientationMaskAll\n end", "def supportedInterfaceOrientations\n UIInterfaceOrientationMaskAll...
[ "0.75289613", "0.75281924", "0.75281924", "0.75281924", "0.75281924", "0.75281924", "0.75281924", "0.75281924", "0.72354394", "0.68504083", "0.6156218", "0.5467761", "0.54245114", "0.54245114", "0.54075915", "0.50808555", "0.5043877", "0.501105", "0.49910054", "0.49910054", "...
0.5666558
11
You can use this method in `supportedInterfaceOrientations`, and it will query the stylesheet for the supported orientations, based on what orientations are defined. At a minimum, to optin to this feature, you'll need to define styles like `style :root, landscape: true`
def autorotateMask device = UIDevice.currentDevice.userInterfaceIdiom if view.stylesheet and view.stylesheet.is_a?(Teacup::Stylesheet) and view.stylename properties = view.stylesheet.query(view.stylename, self, nil) orientations = 0 if properties.supports?(:portrait) or properties.supports?(:upside_up) orientations |= UIInterfaceOrientationPortrait end if device == UIUserInterfaceIdiomPhone # :portrait does not imply upside_down on the iphone if properties.supports?(:upside_down) orientations |= UIInterfaceOrientationPortraitUpsideDown end else # but does on the ipad if properties.supports?(:portrait) or properties.supports?(:upside_down) orientations |= UIInterfaceOrientationPortraitUpsideDown end end if properties.supports?(:landscape) or properties.supports?(:landscape_left) orientations |= UIInterfaceOrientationLandscapeLeft end if properties.supports?(:landscape) or properties.supports?(:landscape_right) orientations |= UIInterfaceOrientationLandscapeRight end if orientations == 0 orientations |= UIInterfaceOrientationPortrait end return orientations end # returns the system default if device == UIUserInterfaceIdiomPhone return UIInterfaceOrientationMaskAllButUpsideDown else return UIInterfaceOrientationMaskAll end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def supportedInterfaceOrientations\n UIInterfaceOrientationMaskLandscape\n end", "def supportedInterfaceOrientations\n UIInterfaceOrientationMaskAll\n end", "def supportedInterfaceOrientations\n UIInterfaceOrientationMaskAll\n end", "def supportedInterfaceOrientations\n UIInterfaceOrientationM...
[ "0.687149", "0.68028075", "0.68028075", "0.68028075", "0.68028075", "0.68028075", "0.68028075", "0.68028075", "0.68019146", "0.6434819", "0.6235272", "0.6227946", "0.5934376", "0.5825171", "0.5821923", "0.5816584", "0.57644564", "0.5740945", "0.5685536", "0.5484045", "0.54586...
0.5976383
12
restyles the view! be careful about putting styles in your stylesheet that you change in your controller. anything that might change over time should be applied in your controller using `style`
def willAnimateRotationToInterfaceOrientation(orientation, duration:duration) view.restyle!(orientation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stylesheet=(new_stylesheet)\n @stylesheet = new_stylesheet\n restyle!\n subviews.each{ |subview| subview.stylesheet = new_stylesheet }\n end", "def style\n end", "def styles; end", "def styles; end", "def styles; end", "def style(new_styles = {})\n @style.merge! new_styles\n end", ...
[ "0.652485", "0.64894974", "0.6315277", "0.6315277", "0.6315277", "0.62498105", "0.61160445", "0.61160445", "0.61160445", "0.6072626", "0.60686016", "0.60306466", "0.6020781", "0.5992316", "0.59923106", "0.5978177", "0.5972042", "0.58891195", "0.5846751", "0.58318686", "0.5812...
0.0
-1
GET /holders GET /holders.json
def index @holders = Holder.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @holders = Holder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @holders }\n end\n end", "def show\n @holder = Holder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json...
[ "0.7639221", "0.7008429", "0.66843307", "0.6676459", "0.6476338", "0.6372876", "0.63153857", "0.61989045", "0.6168195", "0.61374277", "0.61263514", "0.61162466", "0.5870864", "0.58417046", "0.57829195", "0.5721211", "0.5709844", "0.5706777", "0.570013", "0.5697814", "0.568413...
0.7295341
1
GET /holders/1 GET /holders/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @holder = Holder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @holder }\n end\n end", "def index\n @holders = Holder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:...
[ "0.74241346", "0.74129975", "0.7038747", "0.696532", "0.672931", "0.66899955", "0.65522605", "0.649674", "0.6418966", "0.6271987", "0.6235402", "0.6172975", "0.61628366", "0.6143744", "0.60996586", "0.60992175", "0.60849214", "0.6001372", "0.5961101", "0.59502345", "0.5926312...
0.0
-1
POST /holders POST /holders.json
def create @holder = Holder.new(holder_params) @holder.user_id = current_user.id @holder.email = current_user.email @holder.number = current_user.phone respond_to do |format| if @holder.save format.html { redirect_to :back, notice: 'You were successfully assigned.' } format.json { render :show, status: :created, location: @holder } else format.html { redirect_to :back, notice: 'Could not assign you to this group again.' } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @holder = Holder.new(params[:holder])\n\n respond_to do |format|\n if @holder.save\n format.html { redirect_to @holder, notice: 'Holder was successfully created.' }\n format.json { render json: @holder, status: :created, location: @holder }\n else\n format.html { r...
[ "0.73516494", "0.67282265", "0.66376275", "0.65007514", "0.6455488", "0.6278608", "0.6217983", "0.6161071", "0.6063384", "0.6047517", "0.6008328", "0.5989933", "0.598354", "0.59189206", "0.5909271", "0.58967716", "0.5863636", "0.57339996", "0.56348133", "0.56347334", "0.56208...
0.62911445
5
PATCH/PUT /holders/1 PATCH/PUT /holders/1.json
def update respond_to do |format| if @holder.update(holder_params) format.html { redirect_to @holder, notice: 'Holder was successfully updated.' } format.json { render :show, status: :ok, location: @holder } else format.html { render :edit } format.json { render json: @holder.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @holder = Holder.find(params[:id])\n\n respond_to do |format|\n if @holder.update_attributes(params[:holder])\n format.html { redirect_to @holder, notice: 'Holder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ...
[ "0.7385602", "0.6844335", "0.68146425", "0.6651866", "0.6566809", "0.64282453", "0.64206976", "0.63574797", "0.6238019", "0.61848456", "0.6053553", "0.60480756", "0.5981476", "0.59082913", "0.58595246", "0.58241445", "0.57889897", "0.57672673", "0.5731756", "0.5723943", "0.56...
0.7221368
1
DELETE /holders/1 DELETE /holders/1.json
def destroy @holder.destroy respond_to do |format| format.html { redirect_to :back, notice: 'Holder was successfully destroyed.' } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @holder = Holder.find(params[:id])\n @holder.destroy\n\n respond_to do |format|\n format.html { redirect_to holders_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @holder = Holder.find(params[:id])\n @holder.destroy\n\n respond_to do |format|\n...
[ "0.7884411", "0.74699926", "0.71161234", "0.69797343", "0.68391937", "0.6809304", "0.68067807", "0.6781364", "0.67716753", "0.6599269", "0.65802145", "0.65780777", "0.65406686", "0.6519925", "0.65130305", "0.6441466", "0.64279854", "0.64275336", "0.64176863", "0.6408004", "0....
0.6913763
4
Use callbacks to share common setup or constraints between actions.
def set_holder @holder = Holder.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.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def holder_params params.require(:holder).permit(:line_day_time_slot_id, :contact_id) 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
GET /visitante_credenciados/1 GET /visitante_credenciados/1.json
def show @visitante_credenciado = VisitanteCredenciado.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @visitante_credenciado } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @visitante_credenciado = VisitanteCredenciado.new\n @visitante_credenciado.usuario = current_usuario\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @visitante_credenciado }\n end\n end", "def show\n @credito = Credito.find(params[:id])\n\n...
[ "0.6946059", "0.67153335", "0.636153", "0.6358793", "0.6221875", "0.6081284", "0.60226977", "0.60070395", "0.5943565", "0.59431404", "0.59196675", "0.57337505", "0.57046634", "0.56444526", "0.5603245", "0.5603245", "0.5597456", "0.5588283", "0.55670106", "0.55634034", "0.5542...
0.7289569
0
GET /visitante_credenciados/new GET /visitante_credenciados/new.json
def new @visitante_credenciado = VisitanteCredenciado.new @visitante_credenciado.usuario = current_usuario respond_to do |format| format.html # new.html.erb format.json { render json: @visitante_credenciado } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @credito = Credito.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @credito }\n end\n end", "def create\n @visitante_credenciado = VisitanteCredenciado.new(params[:visitante_credenciado])\n @visitante_credenciado.usuario = current_usuar...
[ "0.77401286", "0.74669755", "0.7336427", "0.71760607", "0.7046183", "0.6853597", "0.68401957", "0.68297404", "0.6722135", "0.6721438", "0.66890216", "0.6671469", "0.66681993", "0.6628586", "0.6628586", "0.66258705", "0.6617694", "0.6599563", "0.6596633", "0.65965474", "0.6595...
0.79070866
0
POST /visitante_credenciados POST /visitante_credenciados.json
def create @visitante_credenciado = VisitanteCredenciado.new(params[:visitante_credenciado]) @visitante_credenciado.usuario = current_usuario respond_to do |format| if @visitante_credenciado.save format.html { redirect_to @visitante_credenciado, notice: 'Jogo was successfully created.' } format.json { render json: @visitante_credenciado, status: :created, location: @visitante_credenciado } else format.html { render action: "new" } format.json { render json: @visitante_credenciado.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @credito = Credito.new(credito_params)\n\n respond_to do |format|\n if @credito.save\n format.html { redirect_to @credito, notice: 'Credito was successfully created.' }\n format.json { render :show, status: :created, location: @credito }\n else\n format.html { rend...
[ "0.6811421", "0.67759264", "0.6719624", "0.652328", "0.6106301", "0.60258394", "0.6002551", "0.59114367", "0.58474624", "0.58422244", "0.58051807", "0.5747641", "0.5733372", "0.57184327", "0.5692475", "0.56451166", "0.5617507", "0.5604077", "0.5580342", "0.55541885", "0.55162...
0.75170475
0
PUT /visitante_credenciados/1 PUT /visitante_credenciados/1.json
def update @visitante_credenciado = VisitanteCredenciado.find(params[:id]) respond_to do |format| if @visitante_credenciado.update_attributes(params[:visitante_credenciado]) format.html { redirect_to @visitante_credenciado, notice: 'Jogo was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @visitante_credenciado.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @visitante_credenciado = VisitanteCredenciado.new(params[:visitante_credenciado])\n @visitante_credenciado.usuario = current_usuario\n\n respond_to do |format|\n if @visitante_credenciado.save\n format.html { redirect_to @visitante_credenciado, notice: 'Jogo was successfully creat...
[ "0.68204504", "0.66138774", "0.65627044", "0.6562214", "0.6390967", "0.6275433", "0.6168095", "0.61191964", "0.6076432", "0.6049716", "0.5963033", "0.58708817", "0.5773529", "0.5728092", "0.5726244", "0.5682516", "0.5658721", "0.56450415", "0.56375426", "0.56329036", "0.55191...
0.73315984
0
DELETE /visitante_credenciados/1 DELETE /visitante_credenciados/1.json
def destroy @visitante_credenciado = VisitanteCredenciado.find(params[:id]) @visitante_credenciado.destroy respond_to do |format| format.html { redirect_to visitante_credenciados_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @credito = Credito.find(params[:id])\n @credito.destroy\n\n respond_to do |format|\n format.html { redirect_to creditos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @credito.destroy\n respond_to do |format|\n format.html { redirect_to credi...
[ "0.7305566", "0.7282414", "0.70199573", "0.6994591", "0.69675225", "0.6934073", "0.6913399", "0.68540424", "0.6825695", "0.68024445", "0.67448205", "0.6730061", "0.67175233", "0.67011553", "0.6686962", "0.6684314", "0.66636294", "0.66584283", "0.6653303", "0.6631643", "0.6617...
0.80118793
0
Use callbacks to share common setup or constraints between actions.
def set_book @book = Book.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.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a trusted parameter "white list" through.
def book_params params.require(:book).permit(:title) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Define a getter and a setter method for one or more constant values. The value of the constant itself is not changed, instead a corresponding instance variable is used. Example: module M A = :ma extend ConstReader const_accessor :A end class C include M end c1 = C.new c1.a => :ma c1.a = :ca c1.a => :ca c2 = C.new c2.a => :ma
def const_accessor *consts consts.flatten.each do |c| class_exec(c.to_s, c.to_s.downcase) do |c_name, m_name| define_method m_name do ivar = '@' << m_name if instance_variable_defined? ivar return instance_variable_get(ivar) else val = self.singleton_class.const_get c_name instance_variable_set ivar, val return val end end attr_writer m_name end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def const_set(arg0, arg1)\n end", "def const_set(p0, p1) end", "def const_def(name, value)\n if self.is_a?(Module)\n self.const_set(name, value) unless self.constants.include?(name)\n else\n ::Object.class_eval { self.const_def(name, value) u...
[ "0.6417202", "0.6286734", "0.62161344", "0.6214381", "0.6204583", "0.6036509", "0.5991314", "0.5928847", "0.58448166", "0.58436966", "0.5778076", "0.57545215", "0.57496023", "0.5747154", "0.5681066", "0.56599563", "0.5645485", "0.5606791", "0.55889666", "0.5579073", "0.557821...
0.771841
0
GET /divisions GET /divisions.xml
def index @divisions = Division.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @divisions } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_divisions(search_params = {})\n xml = do_request('getDivisions', search_params)\n DivisionResult.load_from_xml xml\n end", "def division\n @divisions = @company.divisions\n respond_to do |format|\n format.json { render json: @divisions}\n end\n end", "def index\n @divisio...
[ "0.6747079", "0.67209965", "0.668198", "0.64898396", "0.6243201", "0.6221799", "0.58289635", "0.57784", "0.5746005", "0.5737721", "0.57346237", "0.57211465", "0.5720441", "0.5673907", "0.56466466", "0.56353307", "0.55906105", "0.55840266", "0.55840266", "0.55825204", "0.55726...
0.72586393
0
GET /divisions/1 GET /divisions/1.xml
def show @division = Division.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @division } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @divisions = Division.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @divisions }\n end\n end", "def index\n @divisions = Division.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render jso...
[ "0.7212144", "0.64268", "0.6333906", "0.6185104", "0.6087019", "0.6019708", "0.59061617", "0.58890647", "0.58662826", "0.5845285", "0.58220536", "0.5715687", "0.5685984", "0.567977", "0.56744874", "0.5658439", "0.5641318", "0.56380916", "0.56257546", "0.5609925", "0.5583831",...
0.65791327
1
Creates a new tree.
def initialize(&compare_proc) @size = 0 @root = nil @compare_proc = compare_proc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_branch\n @tree_class.new\n end", "def make_tree_for(position)\n root = TreeNode.new(nil, position)\n\n\nend", "def generate_tree\n root =\tTreeNode.new(3)\n root.left =\tTreeNode.new(9)\n right = \t\tTreeNode.new(20)\n right.left = \tTreeNode.new(15)\n right.right = TreeNode.new(7)\n ...
[ "0.7807038", "0.7427922", "0.7376124", "0.7174506", "0.71407753", "0.71060646", "0.70538384", "0.70351934", "0.7018898", "0.70039034", "0.70039034", "0.6933152", "0.68456066", "0.6806244", "0.67527807", "0.67228997", "0.6707447", "0.6705763", "0.6666694", "0.66001207", "0.654...
0.0
-1
swaps one element in the list with the other. accepts arguments in any order. it just figures out which one is in the list and which one is not.
def swap(one, two) if include? one exclude one add two else exclude two add one end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap(a, b)\n\ta, b = [b, a]\n\t[a, b]\nend", "def swap(list, src, dst)\n\t\tswap = list[dst]\n\t\tlist[dst] = list[src]\n\t\tlist[src] = swap\n\tend", "def swap(index1, index2, list)\n temp = list[index1]\n list[index1] = list[index2]\n list[index2] = temp\nend", "def swap_elements(elements)\n hold =...
[ "0.7921268", "0.7900551", "0.782295", "0.780172", "0.7629159", "0.75840515", "0.75188357", "0.75034183", "0.74994946", "0.7477133", "0.74684435", "0.74668515", "0.74668515", "0.74668515", "0.74668515", "0.74668515", "0.74668515", "0.74668515", "0.74668515", "0.74668515", "0.7...
0.7527968
6
called during clone or dup. makes the clone/dup deeper.
def initialize_copy(from) @set = from.instance_variable_get('@set').clone end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deep_dup; end", "def deep_dup\n puts \"warning: #{self.class}: deep_dup not implement\"\n end", "def deep_clone; end", "def deep_dup\n dup\n end", "def clone() end", "def clone; end", "def clone; end", "def clone; end", "def deep_dup\n duplicable? ? dup : self\n end", "def...
[ "0.74872667", "0.72644776", "0.72148097", "0.70911986", "0.6880712", "0.68316126", "0.68316126", "0.68316126", "0.67594814", "0.67594814", "0.6645893", "0.6639884", "0.6561758", "0.6554256", "0.6548361", "0.6548361", "0.6548361", "0.64971554", "0.6486734", "0.64820284", "0.64...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def announcement_params params.require(:announcement).permit(:body) 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
Public: Format a phone number from a model. args[0] Either a Symbol|String country or a String formatting mask. A country must be in ISO 31661alpha2 format, both lower and upper case are valids. block Not used. Signature happy_(country, separator) happy_inter_(country, separator) happy_mask_(mask) field A field name of the model that holds a phone number as a string. country Symbol or String in ISO 31661alpha2 format. separator A String used to separate groups of number. mask A String formatting mask. Returns the String formatted phone number.
def method_missing(meth, *args, &block) if meth.to_s =~ /^happy_inter_(.+)$/ happy_format(:international, $1, *args) elsif meth.to_s =~ /^happy_mask_(.+)$/ happy_format(:mask, $1, *args) elsif meth.to_s =~ /^happy_(.+)$/ happy_format(:national, $1, *args) else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_phone\n if Phoner::Phone.valid? self.phone\n pn = Phoner::Phone.parse phone, :country_code => '1'\n self.phone = pn.format(\"(%a) %f-%l\")\n end\n end", "def format_phone_number(phone)\n parsed_phone = Phonelib.parse(phone)\n\n if parsed_phone.country == Phonelib.default_country...
[ "0.61710936", "0.58451205", "0.5823533", "0.5756655", "0.57004964", "0.56476057", "0.56476057", "0.56476057", "0.56336886", "0.56154007", "0.5534577", "0.5527738", "0.55051607", "0.54599017", "0.5458756", "0.5424795", "0.5412967", "0.53361154", "0.5331979", "0.53233105", "0.5...
0.5220376
25
Public: Make the happy_ methods respond to respond_to?.
def respond_to?(meth, include_private = false) if meth.to_s =~ /^happy_.*$/ true else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def respond_to?(m)\n m || super\n end", "def respond_to_missing?(*_args); super; end", "def respond_to_missing?(*several_variants)\n super\n end", "def respond_to?(*)\n true\n end", "def respond_to?(method)\n return super unless part(method)\n part(method)\n end", "def respond_to? ...
[ "0.6986359", "0.69318163", "0.69024074", "0.68868405", "0.6870764", "0.67932683", "0.6699524", "0.6695635", "0.66894835", "0.6687789", "0.66582316", "0.66520137", "0.6537028", "0.6513873", "0.64906955", "0.64878964", "0.648222", "0.6467301", "0.64467764", "0.6442366", "0.6440...
0.768539
0
Launch the formatting process. type Either :national, :international or :mask. meth The String field from the model. args Argument(s) passed to the formatting method, like a country, a mask string, the separator. Returns the String formatted phone number.
def happy_format(type, meth, *args) Formatter.new(send(meth.to_sym), type, args[0], args[1]).format end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mobile_no_formatting(arg)\n if arg.present? \n if arg.downcase.include?('toll') || arg.downcase.include?('phone') || arg.downcase.include?('direct') || arg.downcase.include?('office')\n return number_to_phone(arg.gsub(/[^\\d,\\.]/, '').to_i, area_code: true)\n ...
[ "0.62967455", "0.62041384", "0.61643094", "0.6129247", "0.6041648", "0.6014528", "0.59928584", "0.59875566", "0.57599795", "0.5740588", "0.56696093", "0.5646784", "0.5643338", "0.56329805", "0.56182235", "0.5603527", "0.5592712", "0.5591469", "0.5567334", "0.5555146", "0.5552...
0.53353494
56
Return parsed json response
def json @json ||= JSON.parse(response.body, symbolize_names: true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json\n response.parsed_body\n end", "def json_response\n JSON.parse(response.body)\n end", "def json_response\n JSON.parse(response.body)\n end", "def json_response response\n JSON.parse response.body\n end", "def json\n JSON.parse(response.body)\n end", "def json\n JSON.parse(...
[ "0.78838176", "0.78728795", "0.78728795", "0.78641516", "0.7716987", "0.7716987", "0.7716987", "0.7716987", "0.77129555", "0.7675962", "0.7610901", "0.7606594", "0.75743", "0.7547967", "0.7542985", "0.75152755", "0.7473246", "0.74411803", "0.73616505", "0.7356769", "0.7346277...
0.75130355
16
Updates the campaign counter
def update_counters ActiveRecord::Base.connection.execute("UPDATE campaigns SET clicks_count = clicks_count + 1 WHERE id = #{tweet.campaign_id}") ActiveRecord::Base.connection.execute("UPDATE tweets SET clicks_count = clicks_count + 1 WHERE id = #{tweet.id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n return if count_delta.zero?\n model.update_counters(id, field => count_delta)\n end", "def update_cache_counters\n target.update_column(:reports_counter, target.reports.count) if target_type == 'Content'\n end", "def _update_counts_after_update\n _wrap_in_counter_culture_acti...
[ "0.70582426", "0.69036806", "0.67891806", "0.67868614", "0.66693974", "0.65142864", "0.65118015", "0.644449", "0.6402098", "0.6375925", "0.63616776", "0.6355536", "0.6355536", "0.6322379", "0.6306029", "0.6246996", "0.62240803", "0.62005633", "0.61546", "0.61474466", "0.61373...
0.7388014
0
you may override default string endcoding
def encoded_string(obj) obj.to_s.encode('utf-8', invalid: :replace, undef: :replace) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_string_ex; end", "def encode_string; end", "def encode(string); end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", ...
[ "0.6728306", "0.6329438", "0.6061868", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.60060734", "0.5972744", "0.5951904", "...
0.0
-1
Shifting the Values in the Array
def shift_val(arr) for i in 0..arr.length - 2 arr[i] = arr[i+1] end arr[-1] = 0 return arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_values(arr)\n for i in 0...arr.length-1\n arr[i] = arr[i + 1]\n end\n arr[arr.length - 1] = 0\n return arr\nend", "def shift\n @arr.shift\n end", "def shift arr\n arr.shift\n arr.push(0)\nend", "def unshift(val)\n if @length < @array.length\n (@length - 1).downto(0)...
[ "0.80505407", "0.78166616", "0.7809253", "0.76185733", "0.76115483", "0.76048654", "0.75816584", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.75236964", "0.750395", ...
0.78384733
1
GET /slides/1 GET /slides/1.xml
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @web_slide = WebSlide.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @web_slide }\n end\n end", "def index\n @slides = Slide.all\n end", "def show\n @title = t('view.slides.show_title')\n @slide = @lesson.slides...
[ "0.6974116", "0.69140625", "0.686322", "0.68444765", "0.6838947", "0.68263906", "0.67839724", "0.6750907", "0.66825485", "0.66825485", "0.66825485", "0.66537654", "0.6455014", "0.6449563", "0.6416596", "0.64136386", "0.64136386", "0.6413545", "0.6228533", "0.62155163", "0.620...
0.0
-1
GET /slides/new GET /slides/new.xml
def new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @slideshow = Slideshow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @slideshow }\n end\n end", "def new\n @slideshow = Slideshow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @...
[ "0.7396352", "0.7396352", "0.73434806", "0.7338678", "0.73070675", "0.72758037", "0.72758037", "0.72758037", "0.7091094", "0.7039641", "0.7004571", "0.6831786", "0.6831786", "0.67566276", "0.6594899", "0.65933836", "0.6570712", "0.65149605", "0.6513772", "0.64840955", "0.6479...
0.0
-1
POST /slides POST /slides.xml
def create newparams = coerce(params) @slide = Slide.new(newparams[:slide]) @slide.name = @slide.image_file_name @slide.position = @slide.presentation.slides.count + 1 if @slide.save flash[:notice] = "Successfully created slide." respond_to do |format| format.html {redirect_to @slide.presentation} format.json { render :json => { :result => 'success', :slide => slide_url(@slide) } } end else render :action => 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @slide = Slide.new(slide_params)\n\n respond_to do |format|\n if @slide.save\n format.html { redirect_to @slide, notice: \"Slide was successfully created.\" }\n format.json { render :show, status: :created, location: @slide }\n else\n format.html { render :new, sta...
[ "0.6834603", "0.68270016", "0.6823437", "0.66408485", "0.6607756", "0.65915304", "0.65805006", "0.6521097", "0.64551836", "0.64549994", "0.63296795", "0.6327963", "0.62902886", "0.6203326", "0.6203326", "0.61550957", "0.61550957", "0.61550957", "0.61317235", "0.6114147", "0.6...
0.6619087
4
PUT /slides/1 PUT /slides/1.xml
def update @slide = Slide.find(params[:id]) @slide.name = params[:slide][:name] unless params[:slide][:name].nil? @slide.position = params[:slide][:position] unless params[:slide][:position].nil? if @slide.update_attributes(params[:slide]) flash[:notice] = "Successfully updated slide." redirect_to @slide.presentation else render :action => 'edit' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @slide = Slide.find(params[:id])\n\n respond_to do |format|\n if @slide.update_attributes(params[:slide])\n format.html { redirect_to \"/slides\", notice: 'slide was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \...
[ "0.68773216", "0.6712871", "0.6687739", "0.65256107", "0.6437946", "0.6425187", "0.6370553", "0.6370553", "0.6344195", "0.631946", "0.6285507", "0.62705463", "0.6269681", "0.6230706", "0.6200014", "0.6197772", "0.61573845", "0.61568016", "0.61118513", "0.6098812", "0.60550296...
0.63143486
10
DELETE /slides/1 DELETE /slides/1.xml
def destroy @slide = Slide.find(params[:id]) @presentation = @slide.presentation @slide.destroy respond_to do |format| format.html { redirect_to(@presentation, :notice => 'Presentation was successfully created.') } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(slide)\n # ./_rels/presentation.xml.rels\n # Update Relationship ids\n # Insert a new one slideRef\n @doc.edit_xml @doc.presentation.rels.path do |xml|\n # Calucate the next id\n # next_id = xml.xpath('//xmlns:Relationship[@Id]').map{ |n| n['Id']...
[ "0.75856405", "0.7382078", "0.7382078", "0.73533976", "0.73297197", "0.7267406", "0.7141743", "0.7128309", "0.7128309", "0.7128309", "0.7113596", "0.7000387", "0.6974351", "0.6974351", "0.69640696", "0.6950955", "0.6917652", "0.69116324", "0.6858363", "0.6818532", "0.67720705...
0.70200706
11
Attaches any unattached members. Deletes those that are marked _delete
def assign_nested_attributes_for_collection(env, attributes_collection) return true unless attributes_collection attributes = extract_attributes(attributes_collection) cast_concern = !env.curation_concern.is_a?(Valkyrie::Resource) resource = cast_concern ? env.curation_concern.valkyrie_resource : env.curation_concern inserts, destroys = split_inserts_and_destroys(attributes, resource) # short circuit to avoid casting unnecessarily return true if destroys.empty? && inserts.empty? # we fail silently if we can't insert the object; this is for legacy # compatibility return true unless check_permissions(ability: env.current_ability, inserts: inserts, destroys: destroys) update_members(resource: resource, inserts: inserts, destroys: destroys) return true unless cast_concern env.curation_concern = Hyrax.metadata_adapter .resource_factory .from_resource(resource: resource) # # checking for existing works to avoid rewriting/loading works that are # # already attached # existing_works = env.curation_concern.member_ids # attributes_collection.each do |attributes| # next if attributes['id'].blank? # if existing_works.include?(attributes['id']) # remove( env, env.curation_concern, attributes['id']) if has_destroy_flag?(attributes) # else # add(env, attributes['id']) # end # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_members(members_to_set, exclude_from_notifications=nil)\n members_to_delete = []\n self.members.each do |member|\n if !members_to_set.include?(member)\n members_to_delete.push member\n end\n end\n self.members -= members_to_delete\n\n self.add_members(members_to_set, exclude...
[ "0.6149218", "0.61226785", "0.61226785", "0.606271", "0.6046451", "0.58437455", "0.5832921", "0.5541665", "0.543931", "0.53946096", "0.5371399", "0.53424615", "0.52726394", "0.5266596", "0.5236802", "0.5216441", "0.51919", "0.5129805", "0.51219094", "0.51177794", "0.5101405",...
0.0
-1
Determines if a hash contains a truthy _destroy key. rubocop:disable Naming/PredicateName
def has_destroy_flag?(hash) ActiveFedora::Type::Boolean.new.cast(hash['_destroy']) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_destroy_flag?( hash )\n ActiveFedora::Type::Boolean.new.cast( hash['_destroy'] )\n end", "def has_destroy_flag?(hash)\n ActiveFedora::Type::Boolean.new.cast(hash['_destroy'])\n end", "def has_destroy_flag?(hash)\n ActiveFedora::Type::Boolean.new.cast(hash['_dest...
[ "0.83332694", "0.8288693", "0.8288693", "0.826199", "0.82463413", "0.7830184", "0.7091375", "0.7091375", "0.7069723", "0.7069723", "0.64439476", "0.63967204", "0.6321761", "0.6228342", "0.62278444", "0.61930364", "0.61298406", "0.61149687", "0.59988934", "0.5991534", "0.59841...
0.827819
3
Create Shipping Create new shipping for an existing orden
def orders_create_shipping(id, shipping_request, opts = {}) data, _status_code, _headers = orders_create_shipping_with_http_info(id, shipping_request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_shipping\n\t\tShipping.create(\n\t\t\tuser_id: params[:user_id],\n\t\t\tcampaign_id: params[:campaign_id],\n\t\t\treward_id: params[:reward_id],\n\t\t\tamount: params[:amount],\n\t\t\tcountry: params[:country]\n\t\t)\n\tend", "def create\n @shipping = Shipping.new(shipping_params)\n if @shipping...
[ "0.816373", "0.75657624", "0.75010484", "0.7428186", "0.73892885", "0.73403436", "0.72546303", "0.71642184", "0.71620625", "0.7118885", "0.7093844", "0.7065646", "0.7054309", "0.69684666", "0.69284445", "0.6927384", "0.6909227", "0.68630624", "0.6849525", "0.6833046", "0.6810...
0.0
-1
Create Shipping Create new shipping for an existing orden
def orders_create_shipping_with_http_info(id, shipping_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ShippingsApi.orders_create_shipping ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ShippingsApi.orders_create_shipping" end # verify the required parameter 'shipping_request' is set if @api_client.config.client_side_validation && shipping_request.nil? fail ArgumentError, "Missing the required parameter 'shipping_request' when calling ShippingsApi.orders_create_shipping" end allowable_values = ["es", "en"] if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language']) fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}" end # resource path local_var_path = '/orders/{id}/shipping_lines'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil? header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(shipping_request) # return_type return_type = opts[:debug_return_type] || 'ShippingOrderResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] new_options = opts.merge( :operation => :"ShippingsApi.orders_create_shipping", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ShippingsApi#orders_create_shipping\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_shipping\n\t\tShipping.create(\n\t\t\tuser_id: params[:user_id],\n\t\t\tcampaign_id: params[:campaign_id],\n\t\t\treward_id: params[:reward_id],\n\t\t\tamount: params[:amount],\n\t\t\tcountry: params[:country]\n\t\t)\n\tend", "def create\n @shipping = Shipping.new(shipping_params)\n if @shipping...
[ "0.816373", "0.75657624", "0.75010484", "0.7428186", "0.73892885", "0.73403436", "0.72546303", "0.71642184", "0.71620625", "0.7118885", "0.7093844", "0.7065646", "0.7054309", "0.69684666", "0.69284445", "0.6927384", "0.6909227", "0.68630624", "0.6849525", "0.6833046", "0.6810...
0.0
-1
Delete Shipping Delete shipping
def orders_delete_shipping(id, shipping_id, opts = {}) data, _status_code, _headers = orders_delete_shipping_with_http_info(id, shipping_id, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @shipping_service.destroy\n redirect_to dashboard_shipping_services_path, notice: 'Shipping service was successfully destroyed.'\n end", "def destroy_shipping_method\n shipping_method = ShippingMethod.find(params[:method_id])\n service_id = shipping_method.shipping_service_id\n ship...
[ "0.7623515", "0.75587934", "0.7470838", "0.7454927", "0.73810583", "0.7281052", "0.7273893", "0.72404104", "0.7230639", "0.7138185", "0.7108606", "0.7087", "0.7072053", "0.70714647", "0.7025314", "0.7005717", "0.6980514", "0.6947225", "0.69400805", "0.68874675", "0.6883677", ...
0.0
-1
Delete Shipping Delete shipping
def orders_delete_shipping_with_http_info(id, shipping_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ShippingsApi.orders_delete_shipping ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling ShippingsApi.orders_delete_shipping" end # verify the required parameter 'shipping_id' is set if @api_client.config.client_side_validation && shipping_id.nil? fail ArgumentError, "Missing the required parameter 'shipping_id' when calling ShippingsApi.orders_delete_shipping" end allowable_values = ["es", "en"] if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language']) fail ArgumentError, "invalid value for \"accept_language\", must be one of #{allowable_values}" end # resource path local_var_path = '/orders/{id}/shipping_lines/{shipping_id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'shipping_id' + '}', CGI.escape(shipping_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json']) header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil? header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ShippingOrderResponse' # auth_names auth_names = opts[:debug_auth_names] || ['bearerAuth'] new_options = opts.merge( :operation => :"ShippingsApi.orders_delete_shipping", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ShippingsApi#orders_delete_shipping\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @shipping_service.destroy\n redirect_to dashboard_shipping_services_path, notice: 'Shipping service was successfully destroyed.'\n end", "def destroy_shipping_method\n shipping_method = ShippingMethod.find(params[:method_id])\n service_id = shipping_method.shipping_service_id\n ship...
[ "0.7623515", "0.75587934", "0.7470838", "0.7454927", "0.73810583", "0.7281052", "0.7273893", "0.72404104", "0.7230639", "0.7138185", "0.7108606", "0.7087", "0.7072053", "0.70714647", "0.7025314", "0.7005717", "0.6980514", "0.6947225", "0.69400805", "0.68874675", "0.6883677", ...
0.0
-1
Update Shipping Update existing shipping for an existing orden
def orders_update_shipping(id, shipping_id, shipping_request, opts = {}) data, _status_code, _headers = orders_update_shipping_with_http_info(id, shipping_id, shipping_request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @shipping.update_attributes(shipping_params)\n redirect_to edit_store_shipping_path(@shipping), notice: 'Dados de envio atualizado com sucesso.'\n else\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @shipping.update(shipping_params)\n for...
[ "0.7307689", "0.71168953", "0.7059553", "0.70098263", "0.69675195", "0.6962991", "0.69517213", "0.69398296", "0.68618286", "0.6843204", "0.68355924", "0.68347645", "0.6826014", "0.6821768", "0.68176854", "0.6810061", "0.67972344", "0.6794585", "0.6787215", "0.6765721", "0.672...
0.0
-1