Skip to content

Instantly share code, notes, and snippets.

View millisami's full-sized avatar
🎯
Focusing on landing a Web3 Job

Sachin Sagar Rai millisami

🎯
Focusing on landing a Web3 Job
View GitHub Profile
@millisami
millisami / gist:3798773
Created September 28, 2012 09:04 — forked from juanje/gist:3797297
Mount apt cache of a Vagrant box in the host to spin up the packages installation

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(box_name)
  cache_dir = File.join(File.expand_path(Vagrant::Environment::DEFAULT_HOME),
                        'cache',
                        'apt',
                        box_name)
# Today's little useless tidbit converts a url's query string into a hash
# set of k/v pairs in a way that merges duplicates and massages empty
# querystring values
def qs_to_hash(query_string)
keyvals = query_string.split('&').inject({}) do |result, q|
k,v = q.split('=')
if !v.nil?
result.merge({k => v})
elsif !result.key?(k)
@millisami
millisami / brew --config
Created June 23, 2011 11:30
brew install ffmpeg
HOMEBREW_VERSION: 0.8
HEAD: 57338d3c6763f2d0b5a91091baf973e407c35034
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: dual-core 64-bit penryn
OS X: 10.6.7
Kernel Architecture: i386
Ruby: 1.8.7-174
abstract attribute_normalizer authlogic authlogic_rpx autotest-rails aws aws_cloud_map aws_credentials aws-ext aws-s3 aws-sdb bcrypt-ruby blueprints bmabey-email_spec
builder bundler cancan capistrano cgi_multipart_eof_fix compass chronic classifier closure-compiler colored columnize compass-960-plugin compass-colors configuration construct
contacts crack culerity daemons database_cleaner data_objects delayed_job delayed_paperclip diff-lcs directory_watcher validatable erubis eventmachine extlib facebooker
facets factory_girl factory_girl_extensions fakeweb fancy-buttons fastercsv fastthread fcoury-matchy ffi ffmike-test_benchmark flay flexmock flog metric_fu formtastic frankie
friendly fssm gdata gembox gemcutter gem_plugin geoip geokit trample git github git_remote_branch glue gravtastic haml haml-edge has_scope heckle helperful heroku highline hirb
@millisami
millisami / add_lvhme.sh
Created December 18, 2016 09:34 — forked from mdespuits/add_lvhme.sh
Add lvh.me to Mac OS X hosts file
#!/bin/bash
main() {
if [[ $(has_lvh_me) == 1 ]]; then
echo 'lvh.me is already specified in your hosts file'
else
add_lvh_me
echo 'lvh.me was added to your hosts file!'
fi
flush_dns_cache
@millisami
millisami / wp-theme-review-setup.sh
Created December 13, 2016 09:47
Scaffold a new WordPress site using an Alfred workflow and WP-CLI. Development sites are spun up using Laravel Valet and a parked Sites folder in the root.
# Parse query name into theme and version variables (e.g. theme-name 1.0.0)
read theme version <<< "{query}"
# Create directory for new site
cd ~/Sites
mkdir $theme
cd $theme
# Download latest version of WordPress
wp core download
@millisami
millisami / hoodie-not_found.error
Created September 28, 2016 04:16
Error confirming user: Error: not_found
Initializing...
Using remote CouchDB: http://127.0.0.1:5984
Waiting for CouchDB [-*----] SUCCESS
WWW: http://127.0.0.1:6001
Admin: http://127.0.0.1:6002
Starting Plugin: 'hoodie-plugin-appconfig'
Starting Plugin: 'hoodie-plugin-email'
Starting Plugin: 'hoodie-plugin-users'
All plugins started.
@millisami
millisami / hoodie.error
Created September 27, 2016 20:49
Error: spawn EACCES
○ hoodie new appName -t "hoodiehq/hoodie-app-skeleton"
.d$b. .d$b. .d$$$$$$b. .d$$$$$$b. .d$$$$$$b. .d$b..d$$$$$$$$b.
$$$$$..$$$$$.$$$$$$$$$$$b .$$$$$$$$$$$b $$$$$$$$$$b $$$$$$$$$$$$$$$P'
$$$$$$$$$$$$d$$$$$$$$$$$$bd$$$$$$$$$$$$b$$$$$$$$$$$b$$$$$$$$$$$$$$$b.
$$$$$$$$$$$$Q$$$$$$$$$$$$PQ$$$$$$$$$$$$P$$$$$$$$$$$P$$$$$$$$$$$$$$$P'
$$$$$´`$$$$$'$$$$$$$$$$$$''$$$$$$$$$$$$'$$$$$$$$$$P $$$$$$$$$$$$$$$b.
'Q$P' 'Q$P' 'Q$$$$$$P' 'Q$$$$$$P' 'Q$$$$$$$P 'Q$P''Q$$$$$$$$P'
Version: 0.6.3 (node v0.12.15, npm 2.15.11, platform: darwin)
@millisami
millisami / gist:3148874
Created July 20, 2012 05:33 — forked from igrigorik/gist:3148848
Convert any YouTube video into an audio file you can listen to on the go...
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > brew install ffprobe
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file: