Skip to content

Instantly share code, notes, and snippets.

View munificent's full-sized avatar

Bob Nystrom munificent

View GitHub Profile
@munificent
munificent / Sieve.mag
Created June 14, 2011 17:06 — forked from dscleaver/Sieve.mag
Implementation of the Sieve of Eratosthenes in Magpie
import async
def spawnGenerator(channel is Channel)
run with for i = count(from: 2, by: 1) do channel send(i)
end
def spawnFilter(in is Channel, prime is Int)
val out = Channel new(1)
run with
while true do
@munificent
munificent / 2 - Plan 9
Created July 20, 2011 04:13
UNIX V5, OpenBSD, Plan 9, FreeBSD, and GNU coreutils implementations of echo.c
#include <u.h>
#include <libc.h>
void
main(int argc, char *argv[])
{
int noNewline;
int arg, length;
char *output, *p;
@munificent
munificent / gist:1225296
Created September 18, 2011 17:20
Problem pushing to github
After a long delay, this is the result I get:
$ git push
Connection closed by 207.97.227.239
fatal: The remote end hung up unexpectedly
This, as far as I can tell, started happening spontaneously. Up until this point,
I've been able to push to github without any problems. I haven't changed anything
with my ssh keys.
$ git branch -avv; git remote -v
blogofile d3f4117 Start styling and setting up blogofile templates.
* master 04ba27e [origin/master: ahead 9] New post about new blog.
remotes/origin/master d3f4117 Start styling and setting up blogofile templates.
origin git@github.com:munificent/journal.git (fetch)
origin git@github.com:munificent/journal.git (push)
@munificent
munificent / HelloDartTest.dart
Created November 22, 2011 06:05
Dart Compilation
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// Compiled using frog, the in-progress self-hosted compiler:
// dart/frog$ ./frogsh --out=hello.js --compile-only samples/hello.dart
class HelloDartTest {
static testMain() {
@munificent
munificent / server.dart
Created September 5, 2012 22:54
Awesome Dart web server
#import('dart:io');
#import('dart:isolate');
void main() {
var type = 'fast';
var args = new Options().arguments;
if (args.length > 0) {
type = args[0];
}
name: your_awesome_app
dependencies:
git: /home/daw/myLib # Or whatever the path to myLib is
class Graph {
num nodesNumber;
List<List<num>> edges;
Graph(this.nodesNumber, List<List<num>> edges) {
this.edges = new Iterable.generate(nodesNumber,
(_) => new List.fixedLength(nodesNumber)).toList();
for (var e in edges) edge(e[0], e[1], e[2]);
}
@munificent
munificent / stress.dart
Created March 19, 2013 20:31
This is my little script for stress-testing a Dart program. Change `script_to_run.dart` to the name of the Dart script to run. Make sure that script ends with a non-zero exit code to indicate failure.
import 'dart:io';
const MAX_ATTEMPTS = 10000;
const MAX_JOBS = 20;
var total = 0;
var numRunning = 0;
main() {
for (var i = 0; i < MAX_JOBS; i++) spawnProc();
@munificent
munificent / gist:5328982
Created April 7, 2013 04:12
Beer-battered tilapia!
Ingredients:
- 5-6 tilapia fillets, cut in half lengthwise
- 1 cup flour, plus more for dredging
- 2 tsp salt (maybe a bit more)
- 2 tsp garlic powder
- 2 tsp onion powder
- 2 tsp black pepper
- 1 tbsp paprika
- dash cayenne