Skip to content

Instantly share code, notes, and snippets.

View adardesign's full-sized avatar
🎯
Focusing

Eliazer Braun adardesign

🎯
Focusing
View GitHub Profile
@eknown
eknown / breadcrumbs-no-more
Created March 30, 2015 17:26
Kosher Breadcrumbs for Passover
do {
$(nav).switchClass( "breadcrumbs", "matzaballs", 0, "linearBurn" );
}
while (passover==true);
@acdha
acdha / bookmarklet-template.js
Created April 3, 2009 21:04
A template for creating bookmarklets which load jQuery from the Google CDN - see http://chris.improbable.org/2009/apr/3/cleaning-up-the-web-with-jquery-and-a-little-help/
/*
To avoid polluting the global namespace this uses an anonymous
function which is called with either the URL for an external
JavaScript file or a function. In either case jQuery will be loaded
from the Google CDN before your code is executed so it's free to
depend on jQuery without checking for it and can do things like
jQuery.getScript() to load other components (e.g. jQuery UI),
stylesheets, etc.
*/
(function (target, msg) {
@JeffreyWay
JeffreyWay / gist:1544440
Created December 31, 2011 16:06
Local XHR in Chrome
# Add to ~/.bash_profile
function chrome() {
open $@ --args --allow-file-access-from-files
}
# Usage - chrome index.html
# now you don't have to worry about those pesky local XHR issues in Chrome.
@quickredfox
quickredfox / example.js
Created February 23, 2012 15:17
JSON.lookup() # find things in JSON collections
var json;
json = [
{
foo: {
bar: ['ka', 'boom']
}
}, {
foo: {
bar: ['sna', 'fu']
<!--
In an HTTP2 world, delivering multiple small individually cachable
and executable scripts can be more efficient than one big
concatenated script. Can we better prepare for this? Can it be
done in a way that works with existing JS files?
Imagine a page that had 4 interactive modules, all of which
depended on a couple of utility scripts. We could progressively
add behaviour to the page by executing the 'action' scripts
as soon as they download & the utilities have executed.
(function($) {
$.fn.clippy = function(text, bgcolor) {
if (!bgcolor) {
var node = $(this);
while (node.css('background-color') == 'transparent' && node.length) {
node = node.parent();
}
if (!node.length) {
bgcolor = '#ffffff';
} else {
@zachleat
zachleat / rwdurl
Last active February 5, 2019 02:20
A command line utility to open a url with a bunch of different screen widths (and organize the windows).
# My Chrome developer profile is in the `Profile 1` directory, make sure to update with yours.
# Best on an ultra wide monitor.
function rwdurl() {
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(0,0);window.resizeTo(320,1395);window.location='$1';</script></body></html>"
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(330,0);window.resizeTo(480,1395);window.location='$1';</script></body></html>"
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(815,0);window.resizeTo(640,1395);window.location='$1';</script></body></html>"
open -n -g -a "Google Chrome" --args --new-window --profile-directory=Profile\ 1 --app="data:text/html,<html><body><script>window.moveTo(1460,0);window.resizeTo(800,1395);window.location='$1';</script></body></html>"
open -n
@gmarik
gmarik / README.md
Created October 21, 2011 21:44
phantomjs qunit.js example

About

minimal example of using [phantomjs] with [qunit]

$ phantomjs run-qunit.js file://`pwd`/test.html
'waitFor()' finished in 200ms.
Tests completed in 21 milliseconds.
5 tests of 5 passed, 0 failed.

Installation

@jonfalcon
jonfalcon / object-keys-polyfill.js
Created February 5, 2013 15:54
Javascript: Object keys polyfill
/**
* Polyfill for Object.keys
*
* @see: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys
*/
if (!Object.keys) {
Object.keys = (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
dontEnums = [
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}