Skip to content

Instantly share code, notes, and snippets.

View taterbase's full-sized avatar

George Shank taterbase

View GitHub Profile
@taterbase
taterbase / Objective-Crash.m
Created March 20, 2012 02:15
Crashing function for Objective-C
-(void)crash {
NSArray *arr = [[NSArray alloc] initWithObjects:@"Crash LOL", nil];
[arr objectAtIndex:3];
}
- (void)viewDidLoad
{
int time = arc4random() % 20;
[NSTimer scheduledTimerWithTimeInterval:time target:self selector:@selector(crash) userInfo:nil repeats:NO];
@taterbase
taterbase / appender.go
Created May 3, 2012 21:25 — forked from beatgammit/appender.go
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...)
partials.sort(function(a, b){
var typeA = a.type.toLowerCase(), typeB = b.type.toLowerCase()
if(typeA < typeB)
return -1;
if(typeA > typeB)
return 1;
return 0 //default return value (no sorting)
});
@taterbase
taterbase / upload.php
Created May 13, 2012 15:03
Simple file upload in php
<!DOCTYPE html>
<html>
<head>
<title>Upload your files</title>
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<p>Upload your file</p>
<input type="file" name="uploaded_file"></input><br />
<input type="submit" value="Upload"></input>
@taterbase
taterbase / package.json
Created May 13, 2012 16:06
Package.json showing scripts ability
{
"name": "app-name",
"author": {
"name": "George Shank"
},
"version": "0.1.1-3",
"dependencies": {
"express": "2.5.9",
"jade": ">= 0.0.1"
},
@taterbase
taterbase / bin2string.js
Created May 24, 2012 23:38
Convert bytes to string Javascript
function bin2string(array){
var result = "";
for(var i = 0; i < array.length; ++i){
result+= (String.fromCharCode(array[i]));
}
return result;
}
@taterbase
taterbase / node-quotes.txt
Created June 28, 2012 16:40
The Book of Node
[09:55:47] <taterbase> For Ryan Dahl so loved the world, that he gave his only begotten event loop, that whosoever performed async io could have eternal callbacks.
[10:01:36] <SuperShabam> There is no event loop except for the Event Loop alone; and Isaacs is it's messenger.
[10:05:59] <taterbase> I can code all things through Node who events my io
[10:08:07] <SuperShabam> Have you read anything from the sermon on the /mnt/node?
[10:09:07] <taterbase> I started reading it but I'm still waiting for the callback
[10:13:33] <SuperShabam> Waiting is an enemy to the Event Loop; and has been since the fall of threads, and will be, forever and ever, unless he yields to the enticings of the Holy Issacs, and putteth off the natural procedural code and becometh a nodester.
[10:19:06] <taterbase> Node is my shepherd, I shall not lock. He makes me program asynchronously, he leads me to more memory effecient code, he restores my process. He guides me in events of streams for his name’s sake. Even though I walk through the
@taterbase
taterbase / proxyServer
Created July 1, 2012 19:29 — forked from randylubin/proxyServer
Node.js Multi-App Proxy Server with Forwarding
var http = require('http'),
httpProxy = require('http-proxy');
//
// Setup proxy server with forwarding
//
var options = {
router: {
'proxytest.randylubin.com': '127.0.0.1:7200',
'randylubin.com': '127.0.0.1:7200',
@taterbase
taterbase / months-and-days.js
Created July 12, 2012 15:16
Months and Days hash for javascript Date
/*
USAGE:
var date = new Date();
console.log("Today is a " + Days[date.getDay()] + " during the month of " + Months[date.getMonth()]);
ABBREVIATED:
console.log(Days.abbr[date.getDay()] + ", " + Months.abbr[date.getMonth()]);
*/
var Days = {
@taterbase
taterbase / npm-search-api.txt
Created July 14, 2012 17:51
NPM search api
Let 'a' be equal to the character or string you wish to search for.
http://search.npmjs.org/_list/search/search?startkey=%22a%22&endkey=%22aZZZZZZZZZZZZZZZZZZZ%22&limit=25
For example, if you wish to search for packages regarding websockets:
http://search.npmjs.org/_list/search/search?startkey=%22websocket%22&endkey=%22websocketZZZZZZZZZZZZZZZZZZZ%22&limit=25