Skip to content

Instantly share code, notes, and snippets.

View radiofreejohn's full-sized avatar
🤓

John radiofreejohn

🤓
  • Goldsky
  • Raleigh, NC
View GitHub Profile
@sanxiyn
sanxiyn / lisp.c
Created August 14, 2010 04:16
Lisp
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
@radiofreejohn
radiofreejohn / itob.c
Created July 23, 2011 06:04
integer to binary string
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
char *itob(char *buffer, int x)
{
unsigned int z = INT_MAX + 1U;
char *buf = buffer;
do
@radiofreejohn
radiofreejohn / nv3h_read_gz.c
Created January 11, 2012 02:12
IDL dlm to read formatted ASCII files
/*
* gcc nv3h_read_gz.c -shared -Bsymbolic -I/zshare/rsi/idl_6.3/external/include -L/zshare/rsi/idl_6.3/bin/bin.linux.x86_64 -lidl -o nv3h_read_gz.so -fPIC -lz -ldl
*
* requires zlib 1.2.5 for gzbuffer -- will check for right version
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <zlib.h>
@radiofreejohn
radiofreejohn / check-frag.c
Created January 20, 2012 02:00
check individual files for fragmentation on Mac OS X
/*
check-frag filename [blocksize guess]
blocksize default is 4096 -- smaller and seeks take too long
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <unistd.h>
@radiofreejohn
radiofreejohn / poker.c
Created March 25, 2012 06:33
Poker game solver
/*
input is 1 line with 10 cards, black first, white second
cards are sorted by value (suit is disregarded when sorting)
when tested for hand type -- they are sorted again based on the
order of evaluation of the hand when comparing the two, so
full house will put the 3 of a kind highest, then the 2 of a kind.
A pair will have the pair as the last two cards, and the rest
sorted by from lowest to highest. This makes it easy to determine
the winner by comparing down from the top.
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@willurd
willurd / web-servers.md
Last active August 5, 2025 00:46
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@XVilka
XVilka / TrueColour.md
Last active August 3, 2025 16:57
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@kosta
kosta / inout.java
Created March 26, 2014 06:47
Copy stdin to stdout in Java
import java.io.IOException;
/**
* Class that copies stdin to stdout, as compained about as not being cleanly
* writable in Java on Hacker News.
* In real code, you would just write IOUtils.copy(System.in, System.out),
* which does basically the same thing.
* This does not catch any exceptions as a) this is just an "exercise" and
* b) all we could do with them is pretty-print them. So let the runtime
* print them for you.
@staltz
staltz / introrx.md
Last active August 2, 2025 18:25
The introduction to Reactive Programming you've been missing