Skip to content

Instantly share code, notes, and snippets.

@bq1990
bq1990 / gist:6df21869a15d82a66c7a39a027f6dd55
Created June 23, 2016 20:28
update letsencrypt cert and push to heroku
sudo certbot renew --agree-tos
sudo heroku _certs:add /etc/letsencrypt/live/www.domain.com/fullchain.pem /etc/letsencrypt/live/www.domain.com/privkey.pem
@bq1990
bq1990 / gist:74d00255e99559fda018114cdb72fa5d
Created June 5, 2016 20:27
Test aws access with boto
>>> import boto
>>> s3 = boto.connect_s3('<access_key>', '<secret_key>')
>>> bucket = s3.lookup('donebox-static')
>>> key = bucket.new_key('testkey')
>>> key.set_contents_from_string('This is a test')
>>> key.exists()
>>> key.delete()
box-shadow: 0px 2px 5px rgba(0, 0, 0, .25);
@bq1990
bq1990 / gist:9d8ca6d321ce54749fb81710e09da7f3
Created April 3, 2016 22:34
sql select duplicate emails
select trim(lower(email)), count(*)
from "users"
group by trim(lower(email))
HAVING count(*) > 1
@bq1990
bq1990 / gist:741f9c845f0cdf2a0564
Created March 25, 2016 04:38
Linux delete all files in a directory when you get the argument list too long error
find . -type f -print -delete
@bq1990
bq1990 / gist:bf337fd5969414c39dd3
Created January 19, 2016 20:30
s3 bucket policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::bucket-name-here",
"arn:aws:s3:::bucket-name-here/*"
]
@bq1990
bq1990 / app.py
Created December 5, 2015 21:14
Subscribe to user_created signal for Flask-Stormpath
from os.path import expanduser
from flask import Flask
from flask.ext.stormpath import StormpathManager, login_required
from flask_stormpath.models import user_created
app = Flask(__name__)
app.config['SECRET_KEY'] = 'xxx'
app.config['STORMPATH_API_KEY_FILE'] = expanduser('stormpath.properties')
@bq1990
bq1990 / init.py
Created October 28, 2015 01:35
Python 2.7 without super
def __init__(self, *args, **kwargs):
Form.__init__(self, *args, **kwargs)
self.multipart = True
@bq1990
bq1990 / double.js
Last active October 28, 2015 01:18
Prevent double submit
//from http://stackoverflow.com/questions/2830542/prevent-double-submission-of-forms-in-jquery
//usage: $('form').preventDoubleSubmission();
//disable per form: $('form:not(.js-allow-double-submission)').preventDoubleSubmission();
jQuery.fn.preventDoubleSubmission = function() {
$(this).on('submit',function(e){
var $form = $(this);
if ($form.data('submitted') === true) {
// Previously submitted - don't submit again
^(?:https?:\/\/)?(?:www\.)?([^\/]+)