Skip to content

Instantly share code, notes, and snippets.

Peter Conerly pconerly

Block or report user

Report or block pconerly

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
@pconerly
pconerly / eip_failover.sh
Last active Sep 19, 2015 — forked from Ashex/eip_failover.sh
EIP failover
View eip_failover.sh
#!/bin/sh
# This script will monitor another HA node and take over an Elastic IP (EIP)
# if communication with the other node fails
# High Availability IP variables
# Other node's IP to ping and EIP to swap if other node goes down
HA_Node_IP=10.0.0.11
EIP=10.0.0.10
#Specify the Secondary Private IP for this node
@pconerly
pconerly / django_command.py
Last active Aug 29, 2015
Rolling your own localtunnel
View django_command.py
# this file lives in /project/app/management/commands/devtunnel.py
# it just spins up a localtunnel and retries it if it fails, until it gets a key command shutdown.
# you need to define some configuartion in your settings.py: SSH_TUNNEL_USER, SSH_SERVER_IP
# This assumes you're running your website on port 8070
import sys
import time
import subprocess
from django.conf import settings
@pconerly
pconerly / record_nock_to_json_file.js
Created Mar 5, 2015
Record nocks to a json file
View record_nock_to_json_file.js
var nock = require('nock');
var low = require('lowdb');
// lowdb is a great straight-to-json minidb.
var db = low('integration_test_nock_records.json');
writeToFileLog = function(object) {
console.log("writing nock to json....");
db('records').push(object);
}
@pconerly
pconerly / info.md
Created Sep 17, 2014
Sublime text power-users session
View info.md

Sublime text:

Plugins:

GitGutter

Languages

Preferences:

Language preferences.

View requirejs_coffee_convertTo_alternate_syntax.py
import fnmatch
import glob
import os
start_dir = '.'
start_dir = '/Users/peterconerly/src/picmonkey/py/frontend/frontend/static/js/v2'
extension = '*.coffee'
for root, dirnames, filenames in os.walk(start_dir):
@pconerly
pconerly / app.py
Created May 12, 2014
Failing to run Tornado tests
View app.py
#!/usr/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado.options import options
class FooHandler(tornado.web.RequestHandler):
def get(self):
self.write("derp")
@pconerly
pconerly / README.md
Last active Aug 29, 2015
python's `if __name__ == "__main__"`, but for php.
View README.md
A slightly fuller example for this stackoverflow question: PHP equivalent of Python's name == “main”?

If you run php import.php the expected output is:

$ php import.php 
I am import.php
I am import.php, and I was run from the command line.
@pconerly
pconerly / fabfile.py
Created May 1, 2013
Using jinja2 with fabric
View fabfile.py
import os
from fabric.api import *
from jinja2 import Environment, FileSystemLoader
from StringIO import StringIO
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
@task
def config():
# put nginx.conf template into remote nginx folder
You can’t perform that action at this time.