Skip to content

Instantly share code, notes, and snippets.

View taterbase's full-sized avatar

George Shank taterbase

View GitHub Profile
@taterbase
taterbase / system-beep.js
Created July 21, 2012 05:01
System Beep in Node.js
function alertTerminal(){
console.log("\007");
}
@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 / zkscan.go
Created June 21, 2016 01:42
Recursively watch child Zookeeper graph grow
package main
import (
"log"
"path"
"sync"
"time"
"github.com/samuel/go-zookeeper/zk"
)
function J = costFunctionJ(X, y, theta)
% X is the "design matrix" containg our training examples
% y is the class labels
m = size(X,1); % numbedr of training examples
predictions = X*theta; % predictions of hypothesis on all m examples
sqrErrors = (predictions - y) .^2; % squared errors
J= 1/(2*m) * sum(sqrErrors);
@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 / performance.worker.js
Created January 18, 2017 01:44
Performance Worker
onmessage = function() {
postMessage(performance.now())
}
@taterbase
taterbase / regex-interpolation.js
Created October 23, 2012 05:16
Regex for matching interpolated string var
//Finds all instances of #{} style interpolation like #{variable}
string.match(/#{[^}\r\n]*}/g);
@taterbase
taterbase / index.html
Created January 18, 2019 22:30
x12 Viewer
<textarea id="edi-input" placeholder="Paste edi in here...">
</textarea>
<br />
<input id="search" placeholder="search segments and elements">
<table id="edi-table" border="1">
</table>
@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