Skip to content

Instantly share code, notes, and snippets.

View addyosmani's full-sized avatar
🎯
Focusing

Addy Osmani addyosmani

🎯
Focusing
View GitHub Profile
@scottjehl
scottjehl / jqm-self-init-a-widget.js
Created July 8, 2011 14:29
Self-init a jQuery Mobile plugin
// First, let's define a widget/plugin called "foo"
// Either using jQuery's $.fn plugin namespace, for simple stateless plugins...
$.fn.foo = function(){
// In this scope, this refers to the element on which the plugin foo() was called
// manipulate it and return this at the end, so it can be chainable
};
@sindresorhus
sindresorhus / np.sh
Last active December 11, 2022 21:26
shell function for publishing node modules with some goodies
# npm publish with goodies
# prerequisite: `npm install -g trash`
# `np` with an optional argument `patch`/`minor`/`major`/`<version>`
# defaults to `patch`
np() {
trash node_modules &>/dev/null;
git pull --rebase &&
npm install &&
npm test &&
npm version ${1:-patch} &&
@martinschierle
martinschierle / sw_performance_check.js
Last active October 24, 2022 20:04
Puppeteer script to check performance of a page with and without service worker
// Idea and some code stemming from https://michaljanaszek.com/blog/test-website-performance-with-puppeteer#cacheAndServiceWorker
const puppeteer = require('puppeteer');
const devices = require('puppeteer/DeviceDescriptors');
const {URL} = require('url');
var fs = require('fs');
var sw_scope;
let NETWORK_PRESETS = {
'GPRS': {
'offline': false,
@remy
remy / details.js
Created April 18, 2010 22:28
Add <details> support - includes stylesheet
/**
* Note that this script is intended to be included at the *end* of the document, before </body>
*/
(function (window, document) {
if ('open' in document.createElement('details')) return;
// made global by myself to be reused elsewhere
var addEvent = (function () {
if (document.addEventListener) {
return function (el, type, fn) {
(function( jQuery ) {
var getScript = jQuery.getScript;
jQuery.getScript = function( resources, callback ) {
var // reference declaration & localization
length = resources.length,
handler = function() { counter++; },
deferreds = [],
@sindresorhus
sindresorhus / LICENSE.txt
Created June 4, 2012 12:14 — forked from 140bytes/LICENSE.txt
Photo Booth (140byt.es)
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2012 Sindre Sorhus <http://sindresorhus.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@piatra
piatra / index.html
Created April 29, 2012 11:47
Record stream from getUserMedia() stream
<!DOCTYPE HTML>
<html>
<head>
<title>Video recording demo</title>
<link rel="stylesheet" type="text/css" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
@jlsync
jlsync / Javascript MVC for Ruby-on-Rails.txt
Created June 17, 2010 09:09
Javascript MVC patterns and implementations
http://blog.new-bamboo.co.uk/2010/1/26/why-your-javascript-apps-need-more-structure
http://blog.new-bamboo.co.uk/2010/2/4/let-them-eat-state
http://blog.new-bamboo.co.uk/2010/3/7/the-js-model-layer
http://blog.new-bamboo.co.uk/2010/2/8/rendering-views-in-javascript
Controllers:
http://code.quirkey.com/sammy/ - Sammy is a tiny javascript framework built on top of jQuery. It’s RESTful Evented JavaScript.
@peol
peol / css-named-colors-in-webkit.js
Created August 31, 2011 08:39
All named CSS colors in webkit as a JS Object
// Source: http://www.google.com/codesearch#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/platform/ColorData.gperf&exact_package=chromium&type=cs
// There's also an RGB one defined here: http://www.google.com/codesearch#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/inspector/front-end/Color.js&exact_package=chromium&q=indianred&l=393
var CSS_NAMED_COLORS = {
aliceblue: "#f0f8ff",
antiquewhite: "#faebd7",
aqua: "#00ffff",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
@cowboy
cowboy / unreleased.md
Created June 1, 2011 20:05
Unreleased stuff...

This list will hopefully shrink faster than it can grow. (yeah, right)

jQuery

jQuery deparam / deparam+ / sortObject (WIP)
https://gist.github.com/1025817

jQuery infiniteScroller (WIP)

jQuery scrollinout event