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 | |
"""Simple HTTP Server With Upload. | |
This module builds on BaseHTTPServer by implementing the standard GET | |
and HEAD requests in a fairly straightforward manner. | |
""" | |
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
def integers(): | |
i = 1 | |
while True: | |
yield i | |
i += 1 | |
def head(iter, n): | |
return [iter.next() for i in xrange(n)] |
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
[submodule "iostream_callback"] | |
path = iostream_callback | |
url = git://gist.github.com/753987.git |
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
""" | |
Parses GAE single-line logs and computes the sum of the time-related fields: | |
total time, cpu time and api time. | |
""" | |
from operator import add | |
def parse_file(url_path, file_path): | |
def parse_line(line): |
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
// assume just this and you don't have access to its source code | |
let doAsyncThing: () => Promise<void>; | |
// another async fn - eg. logging, GA reporting | |
const doAsyncThingSafe = (): Promise<void> => | |
new Promise((resolve, _reject) => { | |
console.log('🎉did <this> where <this = always needs to be done>🚀'); | |
resolve(); | |
}); |
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
export default { | |
name: 'stretch', | |
title: 'Stretch', | |
type: 'document', | |
fields: [ | |
{ | |
name: 'name', | |
title: 'Name of stretching exercise', | |
type: 'string', | |
}, |
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
require(["lib/play-manager"], function(a) { | |
// via http://stackoverflow.com/a/6274381 | |
//+ Jonas Raoni Soares Silva | |
//@ http://jsfromhell.com/array/shuffle [v1.0] | |
function shuf(o) { for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x); } | |
shuf(a.source.models); | |
var c = a.getCurrentSound(), p = c ? c.isPaused() : false; | |
a.playNext(); a.playPrev(); // poor man's refresh of current playing song | |
if (p) a.pause(c); // preserve first-run state |
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
""" | |
Came up with this for satchmo's downloadable product migration, 0001_split. | |
""" | |
def db_table_exists(table, cursor=None): | |
try: | |
if not cursor: | |
from django.db import connection | |
cursor = connection.cursor() | |
if not cursor: | |
raise Exception |
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
import static org.junit.Assert.*; | |
import static org.junit.matchers.JUnitMatchers.*; // for non-hamcrest core matchers | |
import static org.mockito.Mockito.*; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.io.StringWriter; | |
import java.util.HashMap; | |
import java.util.Map; |
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
# next try: `test` before `export` | |
val=`tmux show-environment | grep '^SSH_AUTH_SOCK='`;\ | |
test -n "$val" && export "$val" | |
# with the $_ bash-ism: | |
test -n `tmux show-environment | grep '^SSH_AUTH_SOCK='`\ | |
&& export "$_"; |
NewerOlder