Skip to content

Instantly share code, notes, and snippets.

@seanrose
seanrose / sampleBoxFileUpload.js
Last active October 28, 2022 20:16
A sample file upload in javascript to the Box API
// Requires JQuery and CORS enabled for the Origin you're testing from.
// Uncomment the next 4 lines to import JQuery
// var script= document.createElement('script');
// script.type= 'text/javascript';
// script.src= '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js';
// document.head.appendChild(script);
// Set up the multipart form using HTML5 FormData object
// https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/FormData
var form = new FormData();
@katowulf
katowulf / I Dream in Code.js
Last active January 26, 2023 17:01
I Dream in Code...
/*********************
** I Dream in Code **
*********************/
while( I .sleep() ) {
I.dream() in code;
I.dream() in algorithms;
I.dream() in subroutines;
Rewind.age(5) && I.dream.of(["missing pants", "driving hotwheels", "peeing in fountains"]) ); //hint: it’s my bed
@katowulf
katowulf / filter_using_extend.js
Last active November 7, 2019 21:10
Filter records loaded into AngularFire based on some criteria.
// this will be much more efficient than $watch()
app.factory('FilteredArray', function($firebaseArray) {
function FilteredArray(ref, filterFn) {
this.filterFn = filterFn;
return $firebaseArray.call(this, ref);
}
FilteredArray.prototype.$$added = function(snap) {
var rec = $firebaseArray.prototype.$$added.call(this, snap);
if( !this.filterFn || this.filterFn(rec) ) {
return rec;
@orod
orod / rxjs subjects.md
Last active February 11, 2018 04:14
Subject, ReplaySubject, BehaviorSubject in RxJS

1 source, Three subscribers
Subscriber 1 subscribes and source starts emitting
Subscriber 2 subscribes halfway
Subscriber 3 subscribes after source has completed.

import Rx from 'rxjs/Rx';

var data = [];