Skip to content

Instantly share code, notes, and snippets.

View radiofreejohn's full-sized avatar

John Clover radiofreejohn

View GitHub Profile
@radiofreejohn
radiofreejohn / async.go
Created May 3, 2018 16:06
adding callback hell to go, why not?
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"sync"
)
@radiofreejohn
radiofreejohn / keybase.md
Created July 18, 2016 15:57
Keybase Verification

Keybase proof

I hereby claim:

  • I am radiofreejohn on github.
  • I am radiofreejohn (https://keybase.io/radiofreejohn) on keybase.
  • I have a public key whose fingerprint is 1C44 2943 B328 703E FBF2 F180 A91A DB31 84F2 2D74

To claim this, I am signing this object:

@radiofreejohn
radiofreejohn / codewithemphasis.md
Last active August 29, 2015 14:05
GitHub Markdown test

with emphasis

I want to test a code snippet with emphasis

without emphasis

I want to test a code snippet without emphasis

@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.
@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 / newc.sh
Created January 16, 2012 05:40
create a skeleton C source with main() and includes
#!/bin/bash
#+
# Usage
# newc filename [include[.h] ...]
#
# Output
# Creates a file (filename) with a skeleton main function, with
# optional include files in the header. If the file exists in
# /usr/include then #include <include.h> is added, if it is not
# found in /usr/include, but is found in the current directory
@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 / 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 / bruteforce.c
Created June 19, 2011 22:03
brute force string search
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int brutesearch(char *p, char *a)
{
int i, j, M = strlen(p), N = strlen(a);
for (i = 0, j = 0; j < M && i < N; i++, j++)
{
if (a[i] != p[j])
@radiofreejohn
radiofreejohn / filecomp.c
Created May 30, 2011 22:29
K&R exercise 7-6 compare two files
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXLINE 1000
int main(int argc, char *argv[])
{
FILE *fileA, *fileB;
char filenameA[257];
char filenameB[257];
char *prog = argv[0];