Skip to content

Instantly share code, notes, and snippets.

View tarqd's full-sized avatar

Christopher Tarquini tarqd

View GitHub Profile
function sendBlob(blob) {
var xhr = new XMLHttpRequest();
var fd = new FormData();
fd.append('post-data', 'goeshere');
fd.append('foo', 'bar');
// use the right name for the file (the name element of the form ussually)
fd.append('file', blob);
xhr.open('POST', 'http://YOUR.DOMAIN.HERE/posturl.php', true);
xhr.send(fd);
}
@tarqd
tarqd / a.js
Created November 25, 2012 10:29
alert(0);
chrome.webRequest.onBeforeRequest.addListener(
function(details) { return {cancel: true}; },
{urls: ["*://www.evil.com/*"]},
["blocking"]);
<style>
/* overlay color */
#wf-gateway .ui-widget-overlay{
background-color: #1A1A1A !important;
}
/* hides title bar */
#wf-gateway .ui-dialog-titlebar{
display: none;
}
var formData = new FormData();
formData.append("image", imageBlobOrArrayBuffer, "cropped.png");
xhr.send(formData);
var formData = new FormData();
formData.append("image", imageBlob, "cropped.png");
xhr.send(formData);
if (typeof Object.create !== "function") {
function C(){}
Object.create = function(toCreate) {
C.prototype = toCreate;
return new C();
}
}
(function($, window, document, undefined){
@tarqd
tarqd / gist:6171014
Last active December 20, 2015 17:49
Compare objects
var toString = Object.protototype.toString
function objectEquals(x, y) {
// anything that's strictly equal is good
if(x === y) return true;
// at this point any falsy values will not be equal
if(!x || !y) return false;
// valueOf should work for dates
@tarqd
tarqd / MathASTSpec.md
Last active December 23, 2015 09:29
A pseudo-specification for a Math Abstract Syntax Tree

AST Goals

  • Should be an accurate representation of the users input
  • Should be easy to convert to a human friendly representation (text, latex, images, etc)

AST Nodes

Node Type Description Examples / Purposed Syntax
MathExpression Equivelent of "Program" in Spidermonkey JS AST, container for all other Nodes
AssignmentExpression Expression assigning a value to a variable x := 1; y := 3; y += 5; x -= 3
FunctionDeclaration Declares a callable function f(x) := x+3
@tarqd
tarqd / interpolate.js
Last active December 31, 2015 02:09
Quick and dirty interpolation method (outermost pairs only)
// Example Usage
var str = "Result: {foo({bar: true})} other stuff"
var result = interpolate(str,'{', '}', handle_chunk)
console.log(result.join('')) // outputs: Result: success! other stuff
function handle_chunk(chunk) {
var fn = new Function('foo', 'return ' + chunk)
return fn(foo)
}