Skip to content

Instantly share code, notes, and snippets.

View sandinmyjoints's full-sized avatar
🏠
Working from home

William Bert sandinmyjoints

🏠
Working from home
View GitHub Profile
@vicalejuri
vicalejuri / django-crossdomainxhr-middleware.py
Created June 5, 2010 17:47
Middlware to allow's your django server to respond appropriately to cross domain XHR (postMessage html5 API).
import re
from django.utils.text import compress_string
from django.utils.cache import patch_vary_headers
from django import http
try:
import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
@debrouwere
debrouwere / gist:809993
Created February 3, 2011 19:20
Nested resources in django-tastypie
from sandbox import models
from tastypie import fields
from apibase.resources import CamayakModelResource
from django.conf.urls.defaults import url
class ModelResource(CamayakModelResource):
def override_urls(self):
urls = []
for name, field in self.fields.items():
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
@rtomayko
rtomayko / gist:942910
Created April 26, 2011 19:21 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v -e '>' -e master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@eliperelman
eliperelman / LICENSE.txt
Created June 20, 2011 16:53 — forked from 140bytes/LICENSE.txt
String.prototype.trim polyfill for 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Eli Perelman http://eliperelman.com
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# $ brew install https://raw.github.com/gist/1121425/rubberband.rb
require 'formula'
class Rubberband < Formula
homepage ''
url 'http://code.breakfastquay.com/attachments/download/35/rubberband-1.8.1-gpl-executable-osx-universal.tar.bz2'
version '1.8.1'
sha1 'bceba7dba8cdd773a318ca973ed9c5806be03262'
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active April 2, 2024 20:18
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@lazywithclass
lazywithclass / gist:1582626
Created January 9, 2012 11:50
TDD functions for emacs
(global-set-key (kbd "C-c C-r") 'run-mocha)
(defun run-mocha()
"Runs all the tests in the current buffer"
(interactive)
(let* (command result exit-value)
(setq command (concat "mocha -r should " (buffer-name)))
(setq exit-value (shell-command command))
(color-modeline exit-value)))
@mblondel
mblondel / statistical_tests.py
Last active April 21, 2024 13:42
t-test and wilcoxon-test examples in Python
# Mathieu Blondel, February 2012
# License: BSD 3 clause
# Port to Python of examples in chapter 5 of
# "Introductory Statistics with R" by Peter Dalgaard
import numpy as np
from scipy.stats import ttest_1samp, wilcoxon, ttest_ind, mannwhitneyu
# daily intake of energy in kJ for 11 women