Skip to content

Instantly share code, notes, and snippets.

Tony Amoyal tamoyal

Block or report user

Report or block tamoyal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:9121301
{
"name" : "Ike's Place",
"address" : "3489 16th Street",
"city" : "San Francisco",
"state" : "California",
"phone" : "(415) 553‑6888"
"website" : "http://www.ikes.com",
"owner_email" : "ike@ilikeikesplace.com",
"owner_name" : "Ike Shehadeh",
"socials" : {
@tamoyal
tamoyal / gist:10303138
Last active Aug 29, 2015
Update Postgres 9.1 to 9.3 on Ubuntu
View gist:10303138
# Note this uses a dump and restore method. You can try using pg_upgrade instead
# Make a copy of postgresql.conf and hba.conf since you'll want to use those to edit the 9.3 conf later
$ sudo cp /etc/postgresql/9.1/main/postgresql.conf ~
$ sudo cp /etc/postgresql/9.1/main/pg_hba.conf ~
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
$ sudo apt-get update
$ sudo apt-get upgrade
View gist:33df0699327e503d3cf9
# There are Minitest tests for reliably_enqueue below the module
# Note that this isn't well tested because it was used briefly for maintenance and we ended up killing Resque
# I apologize in advance for any off-by-one errors
module Resque
SLEEP_BETWEEN_RETRY = 0.1.freeze
RETRY = 3
NUM_PROCS_FOR_FAST_ENQUEUE = 10
class << self
@tamoyal
tamoyal / sync_me
Created Sep 30, 2015
Script to sync a local directory to external hard drive
View sync_me
#!/usr/bin/env bash
# This will sync LOCAL_DIR directory to XTAL_DIR (which is my xtal hard drive)
# It's meant to run on frequent polling cron job so that it syncs "immediately"
# when the xtal is plugged in. It will do nothing if the xtal drive is not
# plugged in.
# After a successful sync, it will change the crontab so it is not sync'd again
# for 24 hours. This script assumes you don't need more frequent backing up than
# that because I use it for my projects directory where everything important is
View gist:1805965
~/HumanGeo/datacards/crawlers/deps/hacked-bossmashup [master] $ sudo python setup.py install
running install
running build
running build_py
copying yos/crawl/dict2xml.py -> build/lib/yos/crawl
copying yos/crawl/object_dict.py -> build/lib/yos/crawl
copying yos/crawl/xml2dict.py -> build/lib/yos/crawl
running install_lib
copying build/lib/yos/crawl/dict2xml.py -> /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/yos/crawl
copying build/lib/yos/crawl/object_dict.py -> /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/yos/crawl
@tamoyal
tamoyal / gist:1b7ec4d3871b343d353d
Last active Jul 1, 2017
Transitioning your pem/key on an EC2 instance
View gist:1b7ec4d3871b343d353d

Note: This is mainly useful for instances you are essentially locked out of in the case where you don't want to create a new instance.

  1. Launch a micro instance with your new key (we'll call this the "key transitioning instance"). This instance will need to be in the same availability zone ("us-east-1b", for example) as the instances you are locked out of.
  2. Make sure you can ssh in
  3. Select the instance you are locked out of and make note of the attached EBS volume ID which will look something like vol-6a844e25 and the Root Device which will look something like /dev/sda1.
  4. Stop the EC2 instance you are locked out of
  5. Go to that instance's Root Device EBS volume and detach it
  6. Re-attach the EBS volume to the key transitioning instance
  7. On the key transitioning instance, run sudo fdisk -l
  8. Note the "Device" column output from this command that is similar to the "Attachment information" which is displayed when you select the EBS volume (we'll use /dev/xvdf1 as an example). That will be yo
@tamoyal
tamoyal / gist:38287887923cc29869e5
Created Dec 29, 2014
Upgrade Postgres 9.3 to 9.4 on OS X
View gist:38287887923cc29869e5
# Shutdown postgres
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Install 9.4
brew update && brew upgrade postgresql
# Make 9.4 DB
initdb /usr/local/var/postgres9.4 -E utf8
# Upgrade postgis or the upgrade will fail (if you require postgis)
@tamoyal
tamoyal / gist:2ea1fcdf99c819b4e07d
Last active Apr 20, 2019
Upgrade Postgres 9.3 to 9.4 on Ubuntu
View gist:2ea1fcdf99c819b4e07d
# Be sure to save your config files. Optional but I do:
sudo cp /etc/postgresql/9.3/main/postgresql.conf ~
sudo cp /etc/postgresql/9.3/main/pg_hba.conf ~
# Package repo (for apt-get)
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
# Also probably optional but I like to update sources and upgrade
sudo apt-get update
@tamoyal
tamoyal / gist:10441108
Created Apr 11, 2014
Create super user and database user in Mongo 2.6
View gist:10441108
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
You can’t perform that action at this time.