Skip to content

Instantly share code, notes, and snippets.

View contentfree's full-sized avatar

Dave Myron contentfree

View GitHub Profile
@contentfree
contentfree / gist:45659ad8f500787cb247dbb0447be2e2
Last active April 20, 2020 12:41
COVID-19 OoC (Outside of China) Growth
// WHO Reports: https://www.who.int/emergencies/diseases/novel-coronavirus-2019/situation-reports
// Inspired by: https://twitter.com/paulg/status/1235247452145451013
// Note: The growth rate does not seem sustainable.
// The projected OoC infections assumes a constant doubling of roughly every 4 days.
Date Projected-OoC-Infections WHO-Reported-OoC-Infections
2020-02-29 5,629 6,009
2020-03-01 6,755 7,169
2020-03-02 8,106 8,774
2020-03-03 9,727 10,565
2020-03-04 11,673 12,669
@contentfree
contentfree / Different run using gdb to collect some info
Last active October 12, 2015 17:30
Deadlock during Backburner test on OSX
(gdb) call (void) close(1)
(gdb) call (void) close(2)
(gdb) shell tty
/dev/ttys002
(gdb) call (int) open("/dev/ttys002", 1, 0)
$1 = 1
(gdb) call (int) open("/dev/ttys002", 2, 0)
$2 = 2
(gdb) t a
Please specify a thread ID list
@contentfree
contentfree / jobs.rake
Last active December 16, 2015 16:20
Daemonizing DelayedJob from a rake task. Useful for using DelayedJob outside of Rails (Hizzah Padrino!) Note: Requires rake >= 10.1 for TaskArguments#extras
namespace :jobs do
desc <<-EOD
Start delayed_job worker daemon. Requires passing start|stop|restart|reload|run|zap|status
to rake via `rake jobs:daemon[start]`. To pass arguments to Delayed::Command, call rake
like `rake jobs:daemon["--queue=something start"]` (Note the quotes wrapping the arguments!).
Available flags are: queues queue min_priority max_priority number_of_workers pid-dir
identifier monitor sleep-delay read-ahead prefix exit-on-complete
EOD
task :daemon, [:argv] => :environment do |t, args|
# If we have anything in args.extras we need to combined it with args[:argv]
@contentfree
contentfree / gist:1837753
Created February 15, 2012 17:52 — forked from tvandervossen/gist:1231476
Mobile Safari viewport sizes on iOS 4.3 and 5
iPad
1024 × 690 In landscape on iOS 4.3
1024 × 672 In landscape on iOS 5
768 × 946 In portrait on iOS 4.3
768 × 928 In portrait on iOS 5
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3
1024 × 644 Always showing bookmarks bar in landscape on iOS 5
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3
# Wrapper around Rails' compute_public_path for generating fully-qualified URLs to assets
def compute_public_url( filename, dir, ext = filename.split('.').last )
path = compute_public_path(filename, dir, ext)
"#{request.protocol}#{request.host_with_port}#{path}"
end
@contentfree
contentfree / gist:149347
Created July 17, 2009 23:34
Clearfix SASS Macro
=clearfix
* html &
:height 1px
* + html &
:display inline-block
&:after
:content "."
:display block
:height 0
:clear both
#!/usr/bin/env ruby
#
# description: A startup script to automatically start workers for delayed_job
APP_NAME = 'worker_startup_script'
APP_DIR = '<%= @node[:delayed_job][:app_path] %>'
DEFAULT_NUM_WORKERS = 4
unless %w(start stop restart status).include? ARGV.first
puts "Usage: #{APP_NAME} start|stop|status|restart 4 (for 4 workers - start and restart only)"
pool :apache_static_site do
cloud :web do
#keypair 'id_rsa' # Change this to the name of your keypair if it's not id_rsa
instances 1
enable :haproxy # Also sets up Apache2
has_file "/var/www/index.htm" do
content "<h1>Hello world!</h1>"
owner 'www-data'
# The models
class User < ActiveRecord::Base
has_many :things
accepts_nested_attributes_for :things
end
class Thing < ActiveRecord::Base
belongs_to :user
validates_presence_of :user_id
validates_presence_of :name # For clarity below