Skip to content

Instantly share code, notes, and snippets.

View whyrusleeping's full-sized avatar

Whyrusleeping whyrusleeping

View GitHub Profile
@whyrusleeping
whyrusleeping / SimpleClient.go
Created March 7, 2013 00:49
Sample code for tonights tech club talk
package main
import (
"net"
)
func main() {
addr,_ := net.ResolveTCPAddr("tcp","jero.my:10234")
con, err := net.DialTCP("tcp",nil,addr)
if err != nil {
@whyrusleeping
whyrusleeping / rwlock.c
Created March 29, 2013 23:26
Reader Writer lock implementation from Isilon interview.
typedef struct RWLock {
int readers;
bool writer;
bool writeRequest;
}
void LockForRead(RWLock *l) {
m.Lock();
while(l->writer || l->writeRequest) {
m.Unlock();
@whyrusleeping
whyrusleeping / makeprimes.c
Last active December 15, 2015 18:49
Function to make a list of primes.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
inline
int isPrime(int check, int *primes) {
for (; (*primes * *primes) < check; primes++)
if (check % *primes == 0) return 0;
return 1;
}
@whyrusleeping
whyrusleeping / helloworld.cpp
Created April 17, 2013 15:37
OpenCL Code im trying to get to work
#include <utility>
#define __NO_STD_VECTOR
#include <CL/cl.hpp>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <iterator>
#include <fstream>
@whyrusleeping
whyrusleeping / fun.go
Created April 18, 2013 22:30
Guild Wars Port Spam
package main
import (
"net"
"time"
)
func main() {
time.Sleep(time.Second)
addr,err := net.ResolveUDPAddr("udp", "192.168.1.10:6112")
@whyrusleeping
whyrusleeping / bserv.go
Last active December 16, 2015 16:18
had a small idea for a build server in go DISCLAIMER: i wrote this without a real text editor off the top of my head, i dont think its gonna compile or work right at all. just ideas
package main
import (
"net"
"gob"
"os"
"bytes"
)
const (
@whyrusleeping
whyrusleeping / fuzz.go
Last active December 17, 2015 02:29
Quick fuzzy search that could easily be improved
package main
import (
"fmt"
"os"
)
type FuzzMatch struct {
str string
val int
@whyrusleeping
whyrusleeping / manTHEbrot.go
Created May 10, 2013 22:45
some go mandlebrot code
package main
import (
"fmt"
"runtime"
"image"
"image/color"
"image/png"
"math"
"os"
@whyrusleeping
whyrusleeping / example.go
Created May 19, 2013 18:25
Broadcast Channel for go
//In this example i assume that 'T' is an int
func DoWhatever(toSay string, c chan int) {
for {
n := <-c
fmt.Printf('%s %d\n', toSay, n)
}
}
func main() {
@whyrusleeping
whyrusleeping / go-hi.vim
Created June 17, 2013 23:33
struct Method and Member highlighting for go in vim
syn match goMember "\.\zs\w\+\ze\%((\@!\W\)"
syn match goMethod "\.\zs\w\+\ze("
hi def link goMember Identifier
hi def link goMethod Function