This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validates_presence_of :first_name, :last_name, :email | |
| validates_uniqueness_of :email, :case_sensitive => false | |
| validates_format_of :email, :with => /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | |
| validates_length_of :first_name, :last_name, :minimum => 2, :maximum => 50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validates :first_name, :presence => true, :length => { :minimum => 2, :maximum => 50 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sinatra' | |
| require 'builder' | |
| require 'nokogiri' | |
| require 'uri' | |
| require 'open-uri' | |
| $: << File.join(File.dirname(__FILE__), '..', 'app') | |
| configure do | |
| set :root, File.join(File.dirname(__FILE__), '..') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var request = require('request'), http = require('http'), $ = require('jquery'), querystring = require('querystring'); | |
| http.createServer(function (req, res) { | |
| var q = querystring.parse(req.url); | |
| var locations = {'deurne': 0, 'machelen': 1, 'alleur': 2, 'eke': 3, 'sint-pieters-leeuw': 4}; | |
| request({uri: 'http://www.makro.be/Content/assortiment/benzinestation/benzineprijzen/1/index.jsp?stat=' + locations[q.l]}, function (error, response, body) { | |
| res.writeHead(200, {'Content-Type': 'text/xml'}); | |
| var fuel_types = ['diesel', 'eurosuper', 'superplus']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Album < ActiveRecord::Base | |
| has_many :content, :dependent => :destroy | |
| accepts_nested_attributes_for :content, :allow_destroy => true | |
| end | |
| class Content < ActiveRecord::Base | |
| belongs_to :album | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Album < ActiveRecord::Base | |
| has_many :content, :dependent => :destroy | |
| accepts_nested_attributes_for :content, :allow_destroy => true | |
| attr_accessible :content_attributes | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set :rails_env, "test" | |
| set :rack_env, rails_env | |
| task :setup_env do | |
| run "RACK_ENV=#{rails_env}" | |
| run "RAILS_ENV=#{rails_env}" | |
| run "echo 'RackEnv #{rails_env}' >> #{File.join(current_path, '.htaccess')}" | |
| run "echo 'RailsEnv #{rails_env}' >> #{File.join(current_path, '.htaccess')}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set :stages, %w(testing staging production) | |
| set :default_stage, "testing" | |
| require 'capistrano/ext/multistage' | |
| task :protect do | |
| # http://www.htaccesstools.com/htaccess-authentication/ | |
| run "echo 'username:$apr1$gT8Ap...$3f8RadFS7xottW8AYVX5b0' >> #{File.join(current_path, '.htpasswd')}" | |
| run "echo 'AuthType Basic' >> #{File.join(current_path, '.htaccess')}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'nokogiri' | |
| require 'open-uri' | |
| doc = Nokogiri::HTML(open("http://www.makro.be/public/site/be/node/65832/Lnl_BE/index.html")) | |
| doc.css('#content .Box div.Table table tr:last-child').each do |tr| | |
| p tr.html | |
| end |