Skip to content

Instantly share code, notes, and snippets.

View beatgammit's full-sized avatar

Jameson Little beatgammit

View GitHub Profile
@beatgammit
beatgammit / fish_command_not_found.fish
Created January 27, 2015 19:41
nicer command not found handler for Arch using pkgfile
function fish_command_not_found --on-event fish_command_not_found
echo "fish: Unknown command '$argv'" >&2
if functions -q __fish_command_not_found_setup
functions -e __fish_command_not_found_setup
end
if which pkgfile ^/dev/null >/dev/null
if test (count $argv) -ge 1
if pkgfile --binaries $argv[1] ^/dev/null >/dev/null
echo -e "\n'$argv[1]' can be found in these packages:"
for pkg in (pkgfile --binaries "$argv[1]")
@beatgammit
beatgammit / channelIssue.go
Created April 20, 2011 23:25
Issue using channels with os.File.Read in Go
package main
import (
"web"
"os"
"fmt"
"container/vector"
"time"
)
@beatgammit
beatgammit / upload.js
Created June 7, 2011 19:58
Webkit: XHR push files
function upload(url, uint8Data) {
var xhr,
formData = new FormData(),
blobBuilder = new WebKitBlobBuilder(),
blob;
blobBuilder.append(uint8Data);
blob = blobBuilder.getBlob();
@beatgammit
beatgammit / gist:1205053
Created September 8, 2011 23:14
Reqwest timeout bug
function bug() {
window.reqwest({
'url': 'http://thisdoesntexisthahahaha.com',
'timeout': 1000 * 5,
'type': 'html',
'success': function () {
alert('http://thisdoesntexisthahahaha.com exists??');
},
'error': function () {
console.error('Error, trying again');
@beatgammit
beatgammit / index.js
Created September 12, 2011 16:43
NPM bug when using outdated function as systemd service
#!/usr/bin/env node
(function () {
'use strict';
var npm = require('npm'),
fs = require('fs'),
updateTimeout,
seconds = 10;
function update(fd) {
@beatgammit
beatgammit / gist:1871760
Created February 20, 2012 21:57
Vows breaks on nested topics
(function () {
'use strict';
var vows = require('vows'),
assert = require('assert');
vows.describe('some test').addBatch({
'test level 1': {
topic: function () {
this.callback(null, 1);
@beatgammit
beatgammit / appender.go
Created May 3, 2012 07:29
UTOS- Introduction to Go
package main
import "fmt"
type Appender struct {
data []byte
}
func (a *Appender) Write(p []byte) (int, error) {
newArr := append(a.data, p...)
@beatgammit
beatgammit / gist:3894337
Created October 15, 2012 18:51
JSON marshal/unmarshal
import std.conv;
import std.json;
import std.traits;
/* Marshal */
auto marshalJSON(T)(in T val) if (isSomeString!T) {
JSONValue ret;
ret.str = val;
@beatgammit
beatgammit / gist:4084737
Created November 16, 2012 06:18
Derelict3/GLFW example in D
import std.stdio;
import derelict.opengl3.gl;
import derelict.glfw3.glfw3;
pragma(lib, "DerelictGL3");
pragma(lib, "DerelictGLFW3");
pragma(lib, "DerelictUtil");
pragma(lib, "dl");
@beatgammit
beatgammit / Person.java
Last active December 12, 2015 01:18
Attempt at a super explicit class definition for CS 340. Pedigree is assumed to be a tree structure as described in getPedigree().
import java.util.Date;
/**
* @author T. Jameson Little
*
* Person represents a person in a family tree.
* For this application, father and mother are assumed to be biological parents.
*
* Domain:
* - birthdate: Date when the Person was born (Date object)