Skip to content

Instantly share code, notes, and snippets.

@wishfoundry
wishfoundry / Buffer.js
Last active June 3, 2016 19:44
An implementation of Rx.ReplaySubject for cujo/most
var map = require("./collection").map;
var MAX_SAFE = Math.pow(2, 53) - 1;
/**
* buffer/cache
*
* @param {number} max
* @param {number} maxInterval
* @param {function} nowGetter
* @constructor
@wishfoundry
wishfoundry / gist:1eb3a065007cf58f51b4
Last active September 19, 2017 01:02
List of active js libs for modern dev to keep an eye on

compiling a comparison for a blog article...

Observable streams

  • cujojs/most
  • Reactive-Extensions/RxJS
  • pozadi/kefir
  • baconjs/bacon.js
  • caolan/highland
  • pjeby/axos
  • raimohanska/ponyfood.js
source 'https://rubygems.org'
ruby '2.0.0'
group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
/*
$stateProvider.state('admin', {
url: '/admin',
data:{
title: 'Logout',
only: 'admin'
},
templateUrl: URL.toPartial('logout')
})
@wishfoundry
wishfoundry / decorating angular directives 2
Created January 12, 2014 17:03
still experimenting with extending directive, this time more globally. This is a bit of a hack really
(function(undefined){
var oldDir = angular.module('app').directive;
angular.module('app').directive = function(name, dFactory) {
var dir = oldDir(name, dFactory);
if(dir.restrict.indexOf('E') >= 0) {
makeElement(toDashCase(name))
}
};
@wishfoundry
wishfoundry / decorate angular directive example 1
Created January 12, 2014 16:56
experimenting with ways to decorate angular directives. The disadvantage here is you apply this to all directives
app.config(function($provide) {
$provide.decorator('fooDirective', function($delegate) {
var directive = $delegate[0];
if(directive.restrict.indexOf('E') >= 0) {
makeElement(toDashCase(name))
}
function toDashCase(str) {
return (str.charAt(0) + string.slice(1).replace(/([A-Z])/g, "-$&")).toLowerCase()
@wishfoundry
wishfoundry / doctype switcher
Last active December 29, 2015 01:19
Having trouble with xml based templating engines that don't allow you to declare a modern doctype? Use this little snippet to dynamically switch it to something sane!
<script>
(function switchToHTML5() {
// create an html5 doctype
var newDoctype = document.implementation.createDocumentType('html', '', '');
if (document.doctype) {
document.doctype.parentNode.replaceChild(newDoctype, document.doctype);
} else {
var currentHtml = document.head.parentNode;
currentHtml.parentNode.insertBefore(newDoctype, currentHtml)
@wishfoundry
wishfoundry / gist:7036457
Last active April 1, 2022 05:18
Set OSX default text editor to sublime text 3 instead of TextEdit
defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'
@wishfoundry
wishfoundry / gist:6907655
Created October 9, 2013 20:19
quick links for jshinting
http://travisjeffery.com/b/2013/09/testing-javascript-projects-with-grunt-jasmine-jshint/
https://github.com/gruntjs/grunt-contrib-jshint
https://github.com/bkeepers/lucid/blob/master/spec/javascripts/z_jshint_spec.js
# Load dependencies.
pmodload 'helper'
CURRENT_BG='NONE'
SEGMENT_SEPARATOR='⮀'
# Begin a segment
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.