This file contains hidden or 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
# http://stackoverflow.com/questions/17499021/io-bound-threads-in-ruby | |
require 'thread' | |
class PoisonPill; end | |
def asyncDispatcher(numWorkers, stateArray, &processor) | |
q = Queue.new | |
threads = [] |
This file contains hidden or 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 scala.annotation.tailrec | |
import java.io.EOFException | |
import java.lang.NumberFormatException | |
object Sandbox extends App { | |
override def main(args: Array[String]) = { | |
print("Enter an int, and I'll compute the factorial: ") | |
val done = for { |
This file contains hidden or 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 scala.annotation.tailrec | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
import ExecutionContext.Implicits.global | |
import java.io.EOFException | |
import java.lang.NumberFormatException | |
object Sandbox extends App { |
This file contains hidden or 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
/* | |
* in this directory: | |
* to build: | |
* javac -Xlint:all GCTest.java | |
* | |
* to run: | |
* java -verbose:gc -server -Xincgc -Xmx1024m -classpath . GCTest | |
* | |
*/ |
This file contains hidden or 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
/* | |
* example of function pointers and safe terminal mode input in C | |
*/ | |
#include <stdarg.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
typedef void (*printFunc_t) (void); |
This file contains hidden or 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
/* | |
* A practical implementation of a 'bulletproof' non-negative integer | |
* recognizer with overflow detection. Results are written to stdout, | |
* and diagnostics are written to stderr. Using redirection, you can | |
* easily retrieve just the recognized values separated by newlines | |
* like this: nnIntRecognizer <testInput >testOutput | |
* | |
* some edge cases ferreted in cooperating with Jared | |
*/ |
This file contains hidden or 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
#include <iostream> | |
struct Foo { | |
virtual int retrieve() = 0; | |
}; | |
struct Bar : public Foo { | |
inline int retrieve() { | |
return 1; | |
} |
This file contains hidden or 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
CC=gcc | |
CFLAGS=-std=c99 -O1 -g -Wall -Wextra -pedantic | |
OUT=rotate | |
RM=rm | |
.PHONY: clean | |
rotate: rotate.c makefile | |
$(CC) $(CFLAGS) -o $(OUT) rotate.c |
This file contains hidden or 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
WITHOUT RESTRICT: | |
$ echo "void frob(unsigned char* first, unsigned char* second, unsigned int count) { | |
for(int i = 0; i < count; ++i ) { | |
first[i] = second[i]; | |
} | |
}" | clang -cc1 -O3 -S -x c -std=c99 - | |
_frob: | |
testl %edx, %edx |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
struct sList { | |
struct sList * next; | |
int data; | |
}; | |
struct sList* sList_new(); |