Skip to content

Instantly share code, notes, and snippets.

@iffy
iffy / index.html
Created February 25, 2016 15:29
Angular 1 File Upload example
<!DOCTYPE html>
<html lang="en">
<body ng-app="myapp" ng-controller="UploadCtrl">
<input type="file" file-change="upload">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script>
// the javascript
var app = angular.module('myapp', []);
@iffy
iffy / output
Created August 10, 2015 22:43
Question: How can I get at the `ApplicationSession` instance created through `ApplicationRunner` without polling the private `_session` attribute of the protocol?
$ trial ~/Desktop/sample.py
sample
MyTest
test_stuff ... polling :(
[OK]
-------------------------------------------------------------------------------
Ran 1 tests in 0.169s
PASSED (successes=1)
package main
import (
"os"
"os/exec"
"fmt"
"flag"
"log"
"net"
"net/rpc"
FROM ubuntu
RUN apt-get update -y
RUN apt-get install -y python-dev
RUN apt-get install -y libmysqlclient-dev
RUN apt-get install -y python-pip && pip install -U pip
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# Create the cluster token
docker-machine create -d virtualbox first-machine
$(docker-machine env first-machine)
export TOKEN=$(docker run swarm create)
# Create a master
MASTER_NAME="swarm-master"
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery token://${TOKEN} ${MASTER_NAME}
# Create some nodes
@iffy
iffy / pooling.py
Created December 2, 2014 19:22
An idea for pooling in Alchimia
from twisted.internet import defer
from collections import deque
class TimeoutError(Exception):
pass
class Pooler(object):
@iffy
iffy / output
Created September 22, 2014 16:31
How do I patch a classmethod?
python -m unittest patch_classmethod
E
======================================================================
ERROR: test_usesCreate (patch_classmethod.someFuncTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "patch_classmethod.py", line 27, in test_usesCreate
someFunc('hey')
File "patch_classmethod.py", line 11, in someFunc
return Foo.create(arg)
@iffy
iffy / expected_output
Created April 26, 2014 03:58
How do I get inspect.getsource to get the right source?
class A(object):
def foo(self):
pass
class A(object):
def bar(self, a, b, c):
pass
@iffy
iffy / bar_foo.js
Last active August 29, 2015 13:56
jshint behaves differently for absolute paths and relative paths as far as ignoring goes
syntax error
@iffy
iffy / full output
Created January 10, 2014 22:38
How I tested for red-green in klein for the `dont-return-deferreds` branch.
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
...................................F................................................F.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF klein.test_resource.KleinResourceTests.test_external_url_for
...................................F................................................F.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF klein.test_resource.KleinResourceTests.test_simpleRouting
..................................F.................................................F.FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF klein.test_resource.KleinResourceTest