Skip to content

Instantly share code, notes, and snippets.

View Auto-refresh bookmarklet
// origin: http://www.google.com/support/forum/p/Chrome/thread?tid=1a37ccbdde5902fd&hl=en
javascript:
timeout=prompt("Set timeout [s]");
current=location.href;
if(timeout>0)
setTimeout('reload()',1000*timeout);
else
location.replace(current);
function reload(){
View owning-account-assume-role.tf
# this defines a role "role-name" in the account where this TF will be applied
resource "aws_iam_role" "role_name" {
name = "role-name"
description = "Allows role-name to do things in account"
assume_role_policy = "${data.aws_iam_policy_document.my_role.json}"
}
# this says that any one in a separate account with ID 123456789012 can assume the "role-name" role
data "aws_iam_policy_document" "role_name" {
statement {
@eculver
eculver / protocol-fix.txt
Created Mar 16, 2015
How to deal with tmux "protocol version mismatch"
View protocol-fix.txt
$ tmux attach
protocol version mismatch (client 7, server 6)
$ pgrep tmux
3429
$ /proc/3429/exe attach
@eculver
eculver / htpasswd.py
Created Dec 1, 2011
htpasswd script in python (no need to install apache utils)
View htpasswd.py
#!/usr/local/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
@eculver
eculver / is-merged.sh
Created Aug 2, 2012
Simple shell script to determine if a branch has been fully merged back in to master and develop(ment)
View is-merged.sh
#!/usr/local/bin/zsh
autoload colors
if [[ "$terminfo[colors]" -gt 8 ]]; then
colors
fi
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval $COLOR='$fg_no_bold[${(L)COLOR}]'
eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]'
done
@eculver
eculver / replace_apt_sources.sh
Created Dec 26, 2013
Replace default Ubuntu apt repository URLs w/ DigitalOcean's
View replace_apt_sources.sh
sudo sed -i "s/archive\.ubuntu/mirrors.digitalocean/g" /etc/apt/sources.list
@eculver
eculver / Python SMTP server one-liner
Created Oct 27, 2009
Python SMTP server one-liner
View Python SMTP server one-liner
python -m smtpd -n -c DebuggingServer localhost:1025
@eculver
eculver / filter microsoft word special characters
Created Apr 18, 2010
convert microsoft word special characters to html entities
View filter microsoft word special characters
import re
def convert_1252_codes(text):
"""Convert windows-1252 characters to appropriate html entities.
@param str String to filter
@type string/unicode
@return unicode version of filtered string
Adapted from: http://effbot.org/zone/unicode-gremlins.htm
@eculver
eculver / mples of how to implement inheritance with Django models
Created Apr 18, 2010
Examples of how to implement inheritance with Django models
View mples of how to implement inheritance with Django models
"""Examples of how to implement inheritance with Django models.
Idea here is DRY (don't repeat yourself). If models are similar, let them
share functionality to the extent that its ancestrty makes sense.
It's important to note is that because of the "abstract = True", Django knows
not to create tables for those models, and instead only creates tables for
those models that implement those abstract base classes.
It can also be noted that instead of having one gigantic, monolithic models.py
@eculver
eculver / batch.go
Created May 31, 2019
Divide slice into batches
View batch.go
// run at: https://play.golang.org/p/bhgYlgGbdHz
package main
import (
"fmt"
)
func main() {
total := 22
batch := 3