Skip to content

Instantly share code, notes, and snippets.

View reedobrien's full-sized avatar

Reed O'Brien reedobrien

View GitHub Profile
@reedobrien
reedobrien / r.py
Last active December 17, 2015 10:39
def paths():
for root, dirs, files, in os.walk('path/to/www.n.g'):
for name in files:
if name == "lost+found":
continue
filepath = os.path.join(root, name)
yield filepath
def fix_url(path):
if mime_type in ("text/html", "other html types or make another one for xml"):
@reedobrien
reedobrien / blocking-worker.go
Created July 7, 2013 14:04
A worker that blocks until done
// from http://play.golang.org/p/nNyTtoRzgW
package main
import (
"fmt"
"sync"
)
var (
@reedobrien
reedobrien / remove-from-history.sh
Last active December 20, 2015 10:31
Remove sensitive data from git history
git filter-branch --index-filter 'git update-index --remove filename' <revision-before-introduction-sha1>..HEAD
git push --force --verbose --dry-run
git push --force
@reedobrien
reedobrien / postgres-size-overview
Created September 6, 2013 15:22
20 largest relations and tables in posgres 8.4
## Largest tables
db=# SELECT nspname || '.' || relname AS "table",
pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
AND C.relkind <> 'i'
AND nspname !~ '^pg_toast'
ORDER BY pg_total_relation_size(C.oid) DESC
package main
// overview of crqs.go:
// this example app and supporting documentation enables you to query analytics data via the Core Reporting API in a completely headless manner, with
// no "popup" or user intervention required. it doesn't "handle" the returned data very well, as that will depend on what metrics/dimensions your
// query has. better handling of this is left as an exercise for the reader. :) follow the pre-reqs, change the ga* consts specific to your own app,
// and you should be good to go. uses google-api-go-client, analytics/v3, oauth, and oauth/jwt which you can download and install from
// https://code.google.com/p/goauth2/ and http://code.google.com/p/google-api-go-client/
// docs/pre-reqs:
@reedobrien
reedobrien / gist:7120663
Last active December 26, 2015 08:09 — forked from sanatgersappa/gist:4030649
SAML
package main
import (
"fmt"
"io/ioutil"
"net/http"
"log"
"regexp"
"strings"
)
[buildout]
extensions = mr.developer
parts =
gae_sdk
gae_tools
app_lib
local_appserver_deps
nosetests
# order matters so that this python overwrites the one generated by gae_tools
# until they publish the fix https://github.com/prmtl/appfy.recipe.gae/pull/9
@reedobrien
reedobrien / example.sh
Last active August 29, 2015 14:00
multifield indexing?
## Example from http://bit.ly/1m7DFKs
curl -XDELETE 'localhost:9200/my_index'
echo
curl -XPUT 'localhost:9200/my_index' -d'
{
"settings": {
"analysis": {
"filter": {
"trigrams_filter": {
"type": "ngram",
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"os/exec"
"strings"
package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)