Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name PPS
// @namespace http://github.com/chrisirhc/
// @include *
// @exclude http://www.google.com/*
// ==/UserScript==
var PPS = {};
// Expose it
window.PPS = PPS;
@chrisirhc
chrisirhc / index.js
Created October 5, 2015 04:45
rx-interdependency-experiment
var Rx = require('rx');
var clone = require('lodash.clone');
var isequal = require('lodash.isequal');
var Config = new MutableSubject({a: null});
var Options = new MutableSubject({});
function MutableSubject(name, obj) {
var behaviorSubject = new Rx.BehaviorSubject(obj);
@chrisirhc
chrisirhc / gist:3726139
Created September 15, 2012 02:38
Safe JSON stringify
// A JSON stringifier that handles cycles safely.
// Usage: JSON.stringify(obj, safeCycles())
function safeCycles() {
var seen = [];
return function(key, val) {
if (!val || typeof val !== 'object') {
return val;
}
// Watch out for Window host objects that are trickier to handle.
if (val instanceof Window || seen.indexOf(val) !== -1) {
@chrisirhc
chrisirhc / angularjs-with-ngrepeatusekey.js
Created September 23, 2012 11:33
AngularJS with ngRepeatUseKey
/**
* @License AngularJS v1.1.1-bcaa3bb3
* (c) 2010-2012 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, document, undefined) {
'use strict';
////////////////////////////////////
@chrisirhc
chrisirhc / te.logging.js
Created October 23, 2012 20:57
TE logging function
/*global console:true */
var te = te || {};
(function () {
var _levels = [ 'log', 'info', 'warn', 'error' ],
_noop = function () {},
_passthru = function (lvl) {
return function () { console[lvl].apply(console, arguments); };
@chrisirhc
chrisirhc / grunt-incremental-plan.md
Last active December 11, 2015 23:39
Plan for implementing grunt-incremental

grunt-incremental build/watch method

Consists of two tasks:

  • incwatch
    Only does one thing very well, watch the files that have changed since a certain time reference point.
  • incbuild
    Builds/recompiles only what's needed. It configures tasks based on what's built/changed so that the tasks only act on what's needed.
@chrisirhc
chrisirhc / grunt-log-to-file.js
Last active December 12, 2015 02:28
Log grunt output into file. Intercepts grunt.log.write to do its job.
function gruntLogToFile(grunt, logFilePath) {
logFilePath = logFilePath || grunt.option('log-file');
if (!logFilePath) {
throw new Error('No log file path specified');
return null;
}
var namespace = '_gruntLogToFile_' + logFilePath;
var origLogFunc = grunt.log.write;
@chrisirhc
chrisirhc / resolve_sass_dependencies.rb
Created February 4, 2013 01:41
A function to resolve sass dependencies. Might come in handy with the grunt sass plugin. This is from guard-sass reference to: https://github.com/hawx/guard-sass/pull/31
def resolve_partials_to_owners(paths)
# Get all files that might have imports
root = (options[:input][-1] == "/" ? options[:input] : "#{options[:input]}/").reverse
search_files = Dir.glob("#{options[:input]}/**/*.s[ac]ss")
search_files = Watcher.match_files(self, search_files)
# Get owners
owners = search_files.select do |file|
# Get dependencies of file
deps = Sass::Engine.for_file(file, {}).dependencies.collect! {|dep| dep.options[:filename]}
@chrisirhc
chrisirhc / README.md
Last active December 17, 2015 03:09
Timeout with no targetable DOM feedback

Case 2

Read about this and more on the ThousandEyes blog.

@chrisirhc
chrisirhc / README.md
Last active December 17, 2015 03:18
Timeout with targetable DOM feedback