Skip to content

Instantly share code, notes, and snippets.

joeyadams

Block or report user

Report or block joeyadams

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View redirect-server.hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Prelude hiding (log)
import Control.Concurrent
import Control.Exception
import Control.Monad
@joeyadams
joeyadams / connectex-bind.cpp
Created Nov 28, 2012
Working ConnectEx example
View connectex-bind.cpp
#include <stdio.h>
#include <WinSock2.h>
#include <MSWSock.h>
#include <WS2tcpip.h>
#pragma comment(lib, "Ws2_32.lib")
struct mswsock_s {
LPFN_CONNECTEX ConnectEx;
} mswsock;
View json-validate-test-suite.sh
#!/bin/bash
if [ $# -lt 1 ] ; then
echo "Usage: $0 ./command" >& 2
exit 1
fi
if [ $# -eq 1 ] ; then
if [ ! -f "$(which "$1" 2>/dev/null)" ] ; then
if [ -f "./$1" ] ; then
@joeyadams
joeyadams / hpool.c
Created Jun 29, 2011
Simple, fast memory pool implementation for TI-68k, including demo game.
View hpool.c
/*
Copyright (C) 2011 Joseph A. Adams (joeyadams3.14159@gmail.com)
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@joeyadams
joeyadams / randfile.hs
Created Jun 18, 2011
Pick a file by randomly descending until one is found.
View randfile.hs
import Prelude hiding (catch)
import Control.Applicative
import Control.Exception
import System.Directory
import System.Exit
import System.FilePath
import System.Posix.Files
import System.Random
@joeyadams
joeyadams / ci.c
Created Apr 23, 2011
CI: A simple self-interpreter that's actually a compiler
View ci.c
/*
* Copyright (C) 2011 Joseph Adams <joeyadams3.14159@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@joeyadams
joeyadams / gist:930486
Created Apr 20, 2011
Benchmarking tool for sort function
View gist:930486
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void sort(const char **strings, size_t count, const char **out);
/* Macros grabbed from my darray module:
* http://ccan.ozlabs.org/info/darray.html */
#define darray(type) struct {type *item; size_t size; size_t alloc;}
#define darray_new() {0,0,0}
@joeyadams
joeyadams / million-random-lines.c
Created Apr 19, 2011
Benchmarking data for line sorting
View million-random-lines.c
/*
* Generate 1,000,000 lines of pseudorandom text.
* Each line matches ([\x20-\x7E]|[\xA0-\xFF]){0,127}\n
*
* sha256sum of output:
* 64a9d302d9fc1d0dc9d351c706153dfdd7821182ac8c3d7ed5581850c13ae240
*
* sha256sum of output, sorted with LC_ALL=C sort :
* 6e1e5b2cdb848c02c304d08c565dbd34d394b5ee322019098e10a5b7210f314b
*/
View blockscript.c
/*
* Copyright (C) 2011 Joseph Adams <joeyadams3.14159@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@joeyadams
joeyadams / expected
Created Mar 15, 2011
Plain-text alternative to long division test suite
View expected
22
----
56|1234
112
---
114
112
---
2
83501
You can’t perform that action at this time.