Skip to content

Instantly share code, notes, and snippets.

var subpixelWordSpacing = false;
if (document.defaultView && document.defaultView.getComputedStyle) {
// Store the original word spacing on the document element
var originalWordSpacing = document.defaultView.getComputedStyle(document.documentElement, null).wordSpacing;
// Set the word-spacing to half a pixel
document.documentElement.style.wordSpacing = '0.5px';
// This will return either 0px or 1px if sub-pixel word-spacing is not supported, otherwise
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
function nestedCallbacks(callback) {
console.log("start");
firstNest(function () {
secondNest(function () {
callback("test");
});
});
}
function firstNest(callback) {
var repeatingArray = [4, 5, 6];
var circularObj = {
a: 1,
b: 1,
c: "an allowed repeating string",
d: "an allowed repeating string",
e: repeatingArray,
f: repeatingArray,
g: [
function censor(censor) {
var i = 0;
return function(key, value) {
if(i !== 0 && typeof(censor) === 'object' && typeof(value) == 'object' && censor == value)
return '[Circular]';
if(i >= 29) // seems to be a harded maximum of 30 serialized objects?
return '[Unknown]';
import os
import sys
output_folder = os.path.abspath(sys.argv[1])
from mincss.processor import Processor
p = Processor()
urls = []
css_files = {}
for root, dirs, files in os.walk(output_folder):
for f in files:
@jiverson
jiverson / page-refresh.js
Last active August 29, 2015 13:58
Angular page reload
/* 1. make sure not to refresh page on search */
$routeProvider.when({
reloadOnSearch = false;
});
/* 2. call to refresh the browser page in the application */
$location.search('refreshed', 'true'); // set the query param
//allow for scope digest cycle
$timeout(function() {
@jiverson
jiverson / gist:10507907
Created April 11, 2014 22:51
Browser poll for angularjs
beforeEach(module('ngCookies', function($provide) {
$provide.factory('$browser', function(){
return angular.extend(new angular.mock.$Browser(), {cookieHash: {selectedLanguage:undefined}});
});
}));
it('cookie for selected should default to english', function() {
expect($cookies).toEqual({'selectedLanguage':undefined});
// access internal cookie storage of the browser mock directly to simulate behavior of document.cookie
$browser.poll();
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@jiverson
jiverson / HideShow
Last active August 29, 2015 14:00
Hide show files in bash
# Hide show files by alias
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'