Skip to content

Instantly share code, notes, and snippets.

View edwelker's full-sized avatar

Eddie Welker edwelker

View GitHub Profile
@npathai
npathai / Currying.scala
Created August 10, 2014 16:06
Practicing the currying lecture of Functional Programming in scala course on coursera.
object Currying {
def sum(f: Int => Int) : (Int, Int) => Int = {
def sumF(a: Int, b: Int) : Int = {
if(a > b) 0
else f(a) + sumF(a + 1, b)
}
sumF
}
@jessitron
jessitron / gist:8777503
Created February 3, 2014 01:09
The magic of blocking { ... } in Scala's global ExecutionContext: it leads to the creation of more threads, so the CPUs don't get bored
val des = scala.concurrent.ExecutionContext.global
import scala.concurrent._
import duration._
def ct = Thread.currentThread.getName
val n = Runtime.getRuntime.availableProcessors
def hogThread(sec:Int) = future {
@jonobr1
jonobr1 / interpret.js
Last active April 24, 2020 16:11
Interpret any valid css string and return an r, g, b, (a) object with normalized values.
/**
* Interpret any valid css string as an r, g, b, (a) object.
* If nothing found then it returns an object that is black with
* no alpha.
*
* Usage: interpret('red'); // { r: 1, g: 0, b: 0 };
* interpret('#f00'); // { r: 1, g: 0, b: 0 };
* interpret('#ff000'); // { r: 1, g: 0, b: 0 };
* interpret('rgb(255, 0, 0)'); // { r: 1, g: 0, b: 0 };
* interpret('rgba(255, 0, 0, 1)'); // { r: 1, g: 0, b: 0, a: 1 };

Where people struggle learning Django

Over the last 3 years or so I've helped a bunch of companies, small and large, switch to Django. As part of that, I've done a lot of teaching Django (and Python) to people new to the platform (and language). I'd estimate I've trained something around 200-250 people so far. These aren't people new to programming — indeed, almost all of them are were currently employed as software developers — but they were new to Python, or to Django, or to web development, or all three.

In doing so, I've observed some patterns about what works and what doesn't. Many (most) of the failings have been my own pedagogical failings, but as I've honed my coursework and my skill I'm seeing, time and again, certain ways that Django makes itself difficult to certain groups of users.

This document is my attempt at organizing some notes around what ways different groups struggle. It's not particularly actionable — I'm not making any arguments about what Django should or shouldn't do (at least

@mbbx6spp
mbbx6spp / gist:4043507
Created November 9, 2012 03:19 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
grep -v 'pr/' |
xargs -L1 |
sed 's|origin/||' |
xargs git push origin --delete
@acdha
acdha / compiler-jshint.vim
Created June 1, 2012 22:18
Use JSHint as the VIM compiler for error checking
CompilerSet makeprg=jshint\ \"%\"
CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m
" vim: set sts=4 sw=4 expandtab ff=unix fdm=syntax :
@wickman
wickman / README.md
Created April 12, 2012 22:55
Python development in Pants (tutorial)

Python development using Pants

brian wickman - @wickman

[TOC]

Why use Pants for Python development?

Pants makes the manipulation and distribution of hermetically sealed Python environments

@kennethreitz
kennethreitz / phantom-jasmine-xunit.js
Created June 17, 2011 23:33 — forked from tmpvar/phantom-jasmine-xunit.js
xunit output from jasmine tests
if (phantom.state.length === 0) {
if (phantom.args.length !== 1) {
console.log('Usage: run-jasmine.js URL');
phantom.exit();
} else {
phantom.state = 'run-jasmine';
phantom.open(phantom.args[0]);
}
} else {
window.setInterval(function () {
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
@hugs
hugs / tweet_archiver.py
Created December 13, 2010 23:59
Python code for retrieving all your tweets, based on code from @terrycojones.
# Based on http://blogs.fluidinfo.com/terry/2009/06/24/python-code-for-retrieving-all-your-tweets/
# Patched to retry upon failure until *all* tweets are downloaded.
import sys, twitter, operator
from dateutil.parser import parse
import time
twitterURL = 'http://twitter.com'
def fetch(user):
data = {}
api = twitter.Api()