Skip to content

Instantly share code, notes, and snippets.

View bennuttall's full-sized avatar

Ben Nuttall bennuttall

View GitHub Profile
@hughdbrown
hughdbrown / sha_backup.py
Created January 17, 2011 21:23
Idea for a git-like backup program
"""
Python script to backup data in src to dst using sha1 hashes of the files
in a backing directory.
Hugh Brown
hughdbrown@yahoo.com
"""
from hashlib import sha1
import os
@luetkemj
luetkemj / wp-query-ref.php
Last active February 6, 2024 14:25
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

---- repeat with replacements -----
!!:gs<marker>SEARCH<marker>REPLACE
eg
git checkout branchA && git pull origin branchA && git merge branchB && git push origin branchA
!!:gs/branchA/branchC
!!:gs/branchC/branchD
@Frimkron
Frimkron / gist:5417267
Created April 19, 2013 00:28
Quick proof-of-concept for comparing python code using the abstract syntax tree as an alternative to pattern matching . It's a little more forgiving with whitespace, comments etc. First arg is the solution file, second is the attempt
import ast
import sys
def find_difference(a,b,lastpos=(0,0)):
if isinstance(b,ast.expr) or isinstance(b,ast.stmt):
lastpos = b.lineno,b.col_offset
if type(a) != type(b): return lastpos
if isinstance(a,ast.AST):
for field in a._fields:
# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
package=$1
mapfile -t versions < versions.txt
for v in "${versions[@]}"
do
echo $v
date
/usr/bin/time -f "piw-import $package-$v-*.whl -y --duration 00:%E" -ao imports.sh pip3 wheel $package==$v -q --no-deps --no-binary $package --extra-index-url https://www.piwheels.org/simple --prefer-binary
done