Skip to content

Instantly share code, notes, and snippets.

View whyrusleeping's full-sized avatar

Whyrusleeping whyrusleeping

  • Mana
  • The Metaverse
View GitHub Profile
@whyrusleeping
whyrusleeping / arrayGo.go
Created January 22, 2013 23:34
throwing up some code for later
package main
import "fmt"
import "math/rand"
func IsSorted(arr []int) bool {
for i := 1; i < len(arr); i++ {
if arr[i - 1] > arr[i] {
return false
@whyrusleeping
whyrusleeping / gist:4609052
Created January 23, 2013 16:23
Notes from the git lesson last night

To copy a git repository from online (github or other)

git clone [insert url here]

That will create a directory for the project and copy it to your local machine.

Once youve made changes to the files, for each file you modified do:

git add myFile.txt
@whyrusleeping
whyrusleeping / splitStr.cpp
Last active December 11, 2015 13:39
my go to function for splitting a string into a vector of strings
vector<string> oGlModel::splitString(string s, char delim)
{
vector<string> retTok;
int beg=0,end=0;
for(int end = 0; end < s.length(); end++)
{
if(s[end] == delim)
{
retTok.push_back(s.substr(beg,end-beg));
end++;
@whyrusleeping
whyrusleeping / strspl.c
Created February 7, 2013 00:42
The challenge problem for today will be to take a very long string and break it into tokens by a given delimiter, and print out each token.
Example input/output.
"the cat in the hat is very fat"
outputs:
the
cat
in
the

##Control

This is our base class

	int x
	int y
	int width
	int height
	int max_height 		// defaults to height

int max_width // defaults to height

@whyrusleeping
whyrusleeping / gist:5001753
Last active December 14, 2015 00:49
A mockup for gocmdchat class structure
type Drawable interface {
Draw()
}
type Selectable interface {
Draw()
Select() //button clicked
}
type Rectangle struct {
@whyrusleeping
whyrusleeping / gist:5025652
Created February 24, 2013 21:14
example input for recurring subsequence problem
bdddbcbaaacdcbacdbbcdcacdddacdbaddbabdbcbccdbdcadbbbbdabacdddcbacabcdcdaccdcbdaadbbbbdbddccacdadadbcbddbdccbcacbdcabdbdcccbdccbcdbadbcdbacadadaaadacdaadaabdbcccddcccdcadaccdaacbdddcbadadcadcbcbaaadcaabadbcadcdaaddacaddbadbbdbbcacaaacbbaadcaadbbaadbbbabbddcacaaabddbccbcacaadcbabcaaacdbdbcdabdbdddbcddaaabcadccbcdccdcdadbcddcdaacbaadbcbcdcbadbccbdbaabbabcadacbdcdbaadbcacdcbabcdaabdccadabccdccdcabbcabcbccdaaaddabbcdabcbdbddbbddaadbcbbddabccadccbcccdcdcbbbdaccdcbdccbdbbaacbabacdcabcdbcbadadadbcdaccaadcdcbbbcdcbcbcbaaaadcabacbdbdbcaddbadcaabdbacbaacbdcadcdbacbbbbabacdbcdaacdcbdadaaddbacccbccccaacabacddbbbbcbcbccbbccaddbaabcdbdbaaaccddacaaccdaccdcbcacbccbbabcbcadbcbdacdcbdacacadcdbbbbdcbddcddddaadbdacbcddbdacbadaacdabaddddaddbcbbbdaddcaaaabaacdbacaddcadbcaaabdbcdacaabcdcdcdddacdacbabdcaabdaaadddbcdbbdaacacacbabaadaaabcdbbabacddcdbaacaaadddddcabdabaababcbdcbadbddaccddcbabbdbcbaacdbbbdbdadddacdcddaacdbbadbacbcaccacbbbbdcadabadaccbcdcbcbbacacdaddabdddbdccbbccdaacbcbbabaddabcbbacccbbadbadbcccccccbbdcdbacacbdbbabdbaaaacc
@whyrusleeping
whyrusleeping / gist:5027193
Created February 25, 2013 03:07
My solution to the problem i posted earlier
//Check whether the given subsequence occurs in the src
func SubsequenceOccurs(src, seq []byte) bool {
for i := 0; i < len(src) - len(seq); i++ {
if src[i] == seq[0] {
j := 1
for ; j < len(seq); j++ {
if src[i + j] != seq[j] {
break
}
}
@whyrusleeping
whyrusleeping / gist:5054299
Last active December 14, 2015 07:59
quick test code to listen for udp packets
package main
import (
"net"
"fmt"
)
func main() {
addr, _ := net.ResolveUDPAddr("udp",":9000")
ucon, _ := net.ListenUDP("udp",addr)
buf := make([]byte, 1)
for {
@whyrusleeping
whyrusleeping / gist:5066551
Last active December 14, 2015 09:39
golang mergesort, threaded
package gosort
import (
"math/rand"
"time"
"runtime"
//Extra for profiling
//"testing"
"runtime/pprof"
"flag"