Skip to content

Instantly share code, notes, and snippets.

View jimmyislive's full-sized avatar

Jimmy John jimmyislive

View GitHub Profile
@jimmyislive
jimmyislive / form
Created November 15, 2014 20:16
Honeypot
<div class="control-group">
<label class="hidden" for="inputPot">Do not fill me in</label>
<div class="controls">
<input class="hidden" type="text" id="inputPot" placeholder="pot" ng-model="session.packagePot" name="packagePot">
</div>
</div>
@jimmyislive
jimmyislive / gist:d9d00783f06d7f278e30
Created January 26, 2015 06:08
Meet a (Potential) Founder
Ever want to meet like minded individuals who have (or have the desire) to start some crazy idea on their own. Maybe over coffee or lunch. You may/may not want to start your own, but just meeting with such folks is an interesting excercise in itself. If so, email me your details and i'll hook you up with someone closeby (me included!)
Jim
jimmyislive@gmail.com
@jimmyislive
jimmyislive / feeds.html
Created December 2, 2013 04:36
Sample files to add a RSS feed to an Express/Restify setup
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>My title</title>
<link>https://awesomesite.com/#/</link>
<description>My Description</description>
<language>en-us</language>
<copyright>Copyright 2014, MyAwesomeSite</copyright>
<managingEditor>owner@myawesomesite.com</managingEditor>
<webMaster>owner@myawesomesite.com</webMaster>
@jimmyislive
jimmyislive / pubsubhubbub_post.js
Created December 16, 2013 17:50
Sample function that can be used to POST to the hub whenever your feed changes. The cfg object is something that has all the appropriate params depending on which environment you are on e.g. dev | staging | production etc
function pubsubhubub_post(post_url, callback) {
var payload = { hostname: cfg.hub,
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}
var pubsubhubub_request = https.request(payload, function(pubsubhubub_response) {
//dunno y, but this no-op is needed here !!!
pubsubhubub_response.on('data', function(chunk) {
@jimmyislive
jimmyislive / csrf_decorator.py
Created October 19, 2016 06:58
csrf origin check
def csrf_check(web_request):
def real_decorator(view_func):
@wraps(view_func)
def wrapper(*args, **kwargs):
if (request.method == 'GET'):
return view_func(*args, **kwargs)
u = urlparse(request.headers['Origin'])
if u.netloc in ['www.my_awesome_domain.com', 'my_awesome_domain.com']:
return view_func(*args, **kwargs)
@jimmyislive
jimmyislive / api_module.js
Last active January 3, 2018 17:45
Single Page App components
var cfg = require('../config').Config,
qs = require('querystring'),
request = require('request');
request = request.defaults({jar: true})
exports.awesome = function(req, res){
headers = {};
@jimmyislive
jimmyislive / index.js
Created April 16, 2014 07:47
angularjs with seo
exports.index = function(req, res){
if (req.query._escaped_fragment_ !== undefined) {
if (req.query._escaped_fragment_[0] === '/') {
req.query._escaped_fragment_ = req.query._escaped_fragment_.substring(1);
}
if (req.query._escaped_fragment_[req.query._escaped_fragment_.length - 1] === '/') {
req.query._escaped_fragment_ = req.query._escaped_fragment_.substring(0, req.query._escaped_fragment_.length - 1);
@jimmyislive
jimmyislive / aws_kms.py
Last active February 21, 2019 21:19
aws kms
# Define your AWS_KMS_ARN, KMS_REGION, KMS_AWS_ACCESS_KEY_ID, KMS_AWS_SECRET_ACCESS_KEY someplace
import base64
import boto3
from Crypto.Cipher import AES
class AwsKms(object):
def __init__(self):
self.key_id = AWS_KMS_ARN
self.client = boto3.client('kms',
@jimmyislive
jimmyislive / clone_redis.py
Created January 4, 2015 04:53
Redis Elasticache Export
from optparse import OptionParser
import sys
import redis
__author__ = 'Jimmy John'
__doc__ = '''
This is a script to make a copy of a redis db. Mainly to be used for cloning AWS Elasticache
instancces. Elasticache seems to disable the SAVE/BGSAVE commands and you do not have access to
the physical redis instances. The UI allows you to create 'Snapshots', but no way to download