This was tested using Ruby 2.0.0 and Rails 4.0.0.rc1.
-
Set the install directory for Bower components:
// .bowerrc {
"directory": "app/assets/components"
| # One thing I don't know is how to pass @var to template. | |
| def to_html | |
| request = ActionDispatch::Request.new Hash.new | |
| # I am using Gon also. | |
| Gon.clear | |
| Gon::Request.instance_variable_set(:@request_id, request.object_id) | |
| Gon::Request.env = {} | |
| # Assign gon variables | |
| Gon.some_variables = self.some_variables |
| #!/bin/sh | |
| # Optware pre-installation script, Leon Kos 2006, 2008 | |
| # added -verbose_wget to some lines, MrAlvin 2009 | |
| REPOSITORY=http://ipkg.nslu2-linux.org/feeds/optware/ddwrt/cross/stable | |
| TMP=/tmp | |
| PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin | |
| unset LD_PRELOAD | |
| unset LD_LIBRARY_PATH |
| Book.all.each do |book| | |
| next if !book.pages.any? {|p| p.questions.count > 0} | |
| puts "============ #{book.name} ===============" | |
| book.pages.each do |page| | |
| next if page.questions.count == 0 | |
| puts " Page##{page.page_number}" | |
| page.questions.each do |question| | |
| puts " * Question: #{question.content}" | |
| question.question_options.each do |option| | |
| puts " - #{option.content} #{"√" if option.is_correct_answer}" |
| function longRunJob() { | |
| var deferred = $q.defer(); | |
| setTimeout(function(){ | |
| deferred.notify('About to greet ' + name + '.'); | |
| deferred.resolve('Hello, ' + name + '!'); | |
| deferred.reject('Greeting ' + name + ' is not allowed.'); | |
| }, 10000) | |
| return deferred.promise; | |
| } |
| class String | |
| def is_katakana? | |
| (self =~ /^[゠-ヿ -〿]+$/) == 0 | |
| end | |
| def is_half_katakana? | |
| (self =~ /^[⦅-゚ -〿]+$/) == 0 | |
| end |
| # Method 1 ============================================= | |
| class ProjectManagerChecker | |
| def self.matches?(request) | |
| request.env['warden'].user.role == 'project_manager' | |
| end | |
| end | |
| # routes.rb | |
| get '/' => 'project_managers#index', :constraints => ProjectManagerChecker |
| prev_time = Time.now | |
| 100000.times do | |
| request = WifiRequest.where(client_mac_addr: "B0:8E:1A:50:03:ED").last | |
| next if request.request_at == prev_time | |
| puts request.slice(:client_mac_addr, :power, :request_at) | |
| prev_time = request.request_at | |
| sleep 5 | |
| end |
| class Animal(object): | |
| def __init__(self): | |
| self.name = "Animal" | |
| def eat(self, food = "nothing"): | |
| print self.name + " eats " + food | |
| # ================================================== | |
| import animal |
| from fabric.api import * | |
| env.hosts = ["app1", "app2"] | |
| env.use_ssh_config = True | |
| def host_type(): | |
| run('df -h') |