This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## to encrypt | |
openssl aes-256-cbc -e -in plaintext.txt -out crypted.blob | |
## to decrypt | |
openssl aes-256-cbc -d -in crypted.blob -out plaintext.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Python support for PERL's shorthand of pattern substitution (s/.../.../) | |
# Supports flags: | |
# i => case insensitive | |
# m => multiline match (caret and dollar represent line terminations, not whole-string) | |
# s => "dot-all" - dot matches everything, including new-line | |
# g => "global" - replace every instance (without this, only the first) | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Show duplicate files (compared by MD5 hash) | |
find ./ -type f -print0 | xargs -0 md5sum | sort | uniq -w 32 -D | |
# Remove smart-quotes from a buffer/file | |
sed "s/[”“]/\"/g; s/[’‘]/'/g" | |
# Rename a series of files (e.g. restore backups) by regular expression in OS X | |
find ./ -type f -name '*.bak' -print | sed -E 's/(.*)\.bak$/mv "&" "\1"/' > rename.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
git_command_context () { | |
cd $1; | |
shift; | |
is_workdir=`git rev-parse --is-inside-work-tree` | |
is_gitdir=`git rev-parse --is-inside-git-dir` | |
is_basedir=`git rev-parse --is-bare-repository` | |
my_gitdir=`git rev-parse --git-dir` | |
git "--work-tree=`pwd`" "--git-dir=${my_gitdir}" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generic data structure for mapping named arguments directly to properties | |
# More readable code than using dictionaries... | |
# Usage: | |
# mystruct = Struct(value1 = "x", value2 = "y", value3 = "z") | |
# print mystruct.value1 | |
# >> x | |
class Struct(object): | |
def __init__(self, **entries): | |
Struct.update(self, entries) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
BASEDIR="${1:-./}" | |
listfiles () { | |
find ${BASEDIR} -type f -print0 | xargs -0 file -i -0 | grep -a "x-php" | cut -d '' -f 1 | |
} | |
listfiles | xargs grep -l "eval(" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" This minimal vimrc is intended to be easily deployed to machines where my | |
" dotfiles are not already installed, while maintaining a basic feature set | |
" for usability. | |
" These directories must exist... @{ | |
set backupdir=$HOME/.vim/backup " backup files location | |
set directory=$HOME/.vim/swap " swap files location | |
set tags=./tags,$HOME/.vim/tags " you probably want to add more to these later. | |
" }@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script creates encrypted tarballs and then | |
# 1) Emails them to you, or | |
# 2) Uploads them to <fileconvoy.com>, and emails you a link and decryption key | |
# Dependencies: curl, openssl, grep, tar | |
# Where to find the content to back up | |
BACKUP_ROOT=/var/backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A lightweight module framework intended to provide (simplified) | |
* AMD-style module support. | |
* | |
* Currently its minified form yields 987 bytes, 577 after gzip compression. | |
* | |
* It DOES NOT parse module identifiers as paths (e.g. "/a/b" or "../a"). | |
* It assumes that all module IDs are simple strings, and seeks an exact | |
* match, without attempting to navigate any hierarchy. | |
* | |
* It DOES NOT parse incoming modules as string for require() statements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
'''USAGE: | |
pyprofile.sh run yourscript.py {your arguments} # Runs your program & stores statistics | |
pyprofile.sh show # Reports your statistics | |
Within the report mode, use 'help' to learn additional commands. | |
Initial recommendation: | |
sort cumtime ncalls # List function calls by total time spent in each function | |
stats 30 # Show top 30 function calls (by sorted metric, descending) |