Skip to content

Instantly share code, notes, and snippets.

View whyrusleeping's full-sized avatar

Whyrusleeping whyrusleeping

View GitHub Profile
@whyrusleeping
whyrusleeping / test.go
Created April 2, 2014 16:49
Go isnt a scripting language.... ??
//home/whyrusleeping/go/bin/go run "$0"; exit
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello!")
}
@whyrusleeping
whyrusleeping / widget.lua
Last active August 29, 2015 13:56
Possible implementation of my chromebook battery widget for awesome 3.4
batwidget = widget({ type = "textbox" })
function readnumber(path)
local f = io.open(path,"r")
return tonumber(f:read("*number"))
end
function batwidget.updateDisplay()
local timeleft = readnumber("/sys/class/power_supply/sbs-4-000b/time_to_empty_avg")
timeleft = timeleft / 60
@whyrusleeping
whyrusleeping / gist:9038076
Created February 16, 2014 17:55
Sample rmake.json file
{
"Server": "localhost:11221",
"Files": [
{
"Path": "src/Actor.h",
"LastTime": "2014-02-16T02:38:13.961195864Z"
},
{
"Path": "src/Button.cpp",
"LastTime": "2014-02-16T02:38:13.961626655Z"
@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");