start new:
tmux
start new with session name:
tmux new -s myname
| var DateHelper = { | |
| // Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time | |
| // Ruby strftime: %b %d, %Y %H:%M:%S GMT | |
| time_ago_in_words_with_parsing: function(from) { | |
| var date = new Date; | |
| date.setTime(Date.parse(from)); | |
| return this.time_ago_in_words(date); | |
| }, | |
| time_ago_in_words: function(from) { |
| require File.dirname(__FILE__) + '/../../vendor/gems/net-dns-0.4/lib/net/dns/resolver' | |
| # Custom Domain | |
| # A Rack middleware to to resolve the custom domain to original subdomain | |
| # for your multi telent application. | |
| # | |
| # It's all transperant to your application, it performs cname lookup and | |
| # overwrite HTTP_HOST if needed | |
| # | |
| # www.example.org => example.myapp.com |
| when :restrict do | |
| method_name = "has_many_dependent_restrict_for_#{reflection.name}".to_sym | |
| define_method(method_name) do | |
| unless send(reflection.name).empty? | |
| # change to named error... | |
| raise ActiveRecord::StatementInvalid, "can't delete record because of dependent #{reflection.name}" | |
| end | |
| end | |
| before_destroy method_name | |
| end |
| # app:sync | |
| # Local and production synchronization | |
| # - require yaml_db plugin | |
| namespace :app | |
| namespace :sync do | |
| task :all => [:files, :db] | |
| task :files do | |
| `rsync -azv user@host:'/apps/myawesomeapp/shared/files/' #{Rails.root + 'files'}` |
| #include <iostream> | |
| #include <ctime> | |
| #include <string> | |
| using namespace std; | |
| string convert(unsigned long n) { | |
| static char *formats[16] = { | |
| "", "%s%s%s", "%s%s", "%s%s-%s", | |
| "%s hundred", "%s hundred and %s%s", "%s hundred and %s", "%s hundred and %s-%s", |
| $VERBOSE = nil | |
| require File.expand_path('../rooby', __FILE__) | |
| Person = Rooby::Class.new 'Person' do | |
| define :initialize do |name| | |
| @name = name | |
| end | |
| define :name do |
| (evil-define-state god | |
| "God state." | |
| :tag " <G> " | |
| :message "-- GOD MODE --" | |
| :entry-hook (evil-god-start-hook) | |
| :exit-hook (evil-god-stop-hook) | |
| :input-method t | |
| :intercept-esc nil) | |
| (defun evil-god-start-hook () |
| [Unit] | |
| Description=Buildkite Agents | |
| Documentation=https://buildkite.com/agent | |
| Wants[email protected] | |
| Wants[email protected] | |
| # ... | |
| [Service] | |
| Type=oneshot | |
| ExecStart=/bin/true |
| # It requires ACK - http://betterthangrep.com/ | |
| task :find_unused_images do | |
| images = Dir.glob('app/assets/images/**/*') | |
| images_to_delete = [] | |
| images.each do |image| | |
| unless File.directory?(image) | |
| # print "\nChecking #{image}..." | |
| print "." | |
| result = `ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}` |