Skip to content

Instantly share code, notes, and snippets.

View whyrusleeping's full-sized avatar

Whyrusleeping whyrusleeping

  • Mana
  • The Metaverse
View GitHub Profile
package main
import (
"fmt"
"net"
cmds "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core"
corehttp "github.com/ipfs/go-ipfs/core/corehttp"
corenet "github.com/ipfs/go-ipfs/core/corenet"
@whyrusleeping
whyrusleeping / gist:8274404
Last active January 2, 2016 08:09
quick go linq hack, proof of concept
package main
import (
"fmt"
)
type T interface{}
type Collection []interface{}
func From(i T) Collection {
@whyrusleeping
whyrusleeping / negate.asm
Created December 29, 2013 02:19
Test of ways of negating a number
.text
.align 2
.global main
.type main, %function
main:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 1, uses_anonymous_args = 0
@ link register save eliminated.
str fp, [sp, #-4]!
add fp, sp, #0
@whyrusleeping
whyrusleeping / permute.go
Created December 18, 2013 00:04
Get all permutations of a set of strings
func permute(opts []string) []string {
return _permute("", opts)
}
func _permute(s string, opts []string) []string {
if len(opts) == 0 {
return []string{s}
}
ret := make([]string, 0, 16)
olist := make([]string, 0, len(opts))
@whyrusleeping
whyrusleeping / sol.c
Created November 14, 2013 17:54
Lab 12 Solutions.
int recursive_sum(int num) {
int ones = num % 10;
if (num == 0 ) {
return 0;
}
return ones + recursive_sum(num / 10);
}
void reverse_string(char *start, char *end) {
char temp;
package main
import (
"net"
"bufio"
)
//Handles a connection
func handleConnection(conn net.Conn) {
//There are a few ways to read from the connection
@whyrusleeping
whyrusleeping / xorg.conf
Created October 14, 2013 01:39
My chromebooks xorg.conf file
Section "Device"
Identifier "Mali FBDEV"
Driver "fbdev"
Option "fbdev" "/dev/fb0"
Option "Fimg2DExa" "false"
Option "DRI2" "true"
Option "DRI2_PAGE_FLIP" "false"
Option "DRI@_WAIT_VSYNC" "true"
Option "SWccursorLCD" "false"
EndSection
@whyrusleeping
whyrusleeping / lab4help.c
Last active December 23, 2015 08:59
CS 121 Lab 4 Help sheet
/********************************************
Hello Everyone, This is going to be a
(hopefully) helpful sheet of notes for lab 4.
********************************************/
/* Open A File for reading, and check to make sure it exists */
FILE *some_file = NULL;
some_file = fopen("my_file_name.txt", "r");
if (some_file == NULL) {
printf("This file does not exist!!\n");
@whyrusleeping
whyrusleeping / gist:6108204
Last active December 20, 2015 09:30
examples of the C coding style i am going to enforce, for future students
/*
surround a binary operator (particular a low precedence
one) with spaces; don't try to write the most compact
code possible but rather the most readable.
*/
int i = 5 + 3;
//NOT
int i=5+3;
/*
@whyrusleeping
whyrusleeping / gist:5887111
Created June 28, 2013 18:55
Xor encryption dawg
void xor(char *str, char *key) {
char *t=key;
for (;*str;str++,t++){
if(!*t){t=key;}
*str^=*t;}}