Skip to content

Instantly share code, notes, and snippets.

View jml's full-sized avatar

Jonathan Lange jml

View GitHub Profile
@jml
jml / HelloTests.swift
Last active September 10, 2018 15:34
swift test on macOS 10.13.6 (17G65)
import XCTest
class HelloTests : XCTestCase {
func testSimple() throws {
XCTAssertEqual(2, 1 + 1)
}
}
package main
import (
"encoding/json"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
$ brew install emacs-mac --with-emacs-icons-project-EmacsIcon9 --with-gnutls
Checking out v1.0.1 in /usr/local/Homebrew...
To checkout master in /usr/local/Homebrew run:
'cd /usr/local/Homebrew && git checkout master
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.
==> Installing emacs-mac from railwaycat/emacsmacport
==> Downloading https://bitbucket.org/mituharu/emacs-mac/get/emacs-25.1-mac-6.0.
@jml
jml / protolude-wishlist.md
Last active August 25, 2018 12:48
Things I want in Protolude

Stephen Diehl's protolude library is excellent. I highly recommend it as a default prelude for Haskell.

It's so good and so close to what I want that whenever I do come across something missing it's as obvious as a glitch in good music.

Here's what I'd like:

<<$>>

(&lt;&lt;$&gt;&gt;) :: (Functor f, Functor g) =&gt; (a -&gt; b) -&gt; f (g a) -&gt; f (g b)
@jml
jml / gtd.rst
Last active September 14, 2016 17:37

GTD: tl;dr

Assumptions

  • A system must be reliable to be useful
    • Must have all of the things you care about
@jml
jml / waitfor.py
Last active February 10, 2016 16:51
Deferred equivalent of sleep?
def waitFor(clock, delay, deferred):
"""
Usage::
waitFor(reactor, 20, d).addCallback(print)
Will wait for 20s before calling ``print`` with the result of ``d``.
"""
# H/T @tomprince
return deferred.addCallback(lambda x: deferLater(clock, delay, lambda: x))
@jml
jml / runtest.rst
Last active February 11, 2016 17:49
Class decorator instead of base TestCase

Some notes on a different approach to xUnit style tests. I don't necessarily want to implement it—I don't quite have the motive or opportunity—but I think it interesting enough to share.

Instead of telling users to subclass testtools.TestCase, we would tell them to decorate. Tests would look like:

@test_cases()
class MyTests(object):
    def setUp(self):
        # no upcall
        whatever()
    def test_foo(self):
from twisted.trial.unittest import SynchronousTestCase
from twisted.internet.defer import gatherResults, maybeDeferred
class MyTests(SynchronousTestCase):
def test_catches_failure(self):
d = maybeDeferred(lambda: 1/0)
self.failureResultOf(d)
parts s = do
a <- [1..s-1]
b <- [1..s-a]
c <- [1..s-a-b]
d <- [1..s-a-b-c]
return [a, b, c, d]
@jml
jml / gist:e55dee21b5d4708ffca0
Created January 18, 2016 13:51
Ubuntu 14.04 LTS on ec2
$ ssh ubuntu@52.18.74.86
The authenticity of host '52.18.74.86 (52.18.74.86)' can't be established.
RSA key fingerprint is 69:05:36:51:18:6a:ca:89:65:62:d4:a0:33:b5:6f:db.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '52.18.74.86' (RSA) to the list of known hosts.
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-48-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Mon Jan 18 13:47:09 UTC 2016