Skip to content

Instantly share code, notes, and snippets.

View sergiolopes's full-sized avatar

Sérgio Lopes sergiolopes

View GitHub Profile
@adrianoalmeida7
adrianoalmeida7 / Data.scala
Created June 19, 2011 12:19
DSL pra criacao de java.util.Calendars
package dsl
import java.util.Calendar
object Data {
class Dia(val dia:Int) {
def de(mes:Mes) = {
new ConectorParaAno(dia, mes)
}
@madrobby
madrobby / gist:4161897
Created November 28, 2012 15:16
Retina screen media query
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 144dpi),
(min-resolution: 1.5dppx) {
/* Retina rules! */
}
@aarongustafson
aarongustafson / getActiveMQ.js
Last active June 27, 2017 03:59
A simple way to track media query use in your JavaScript
// Get the active Media Query as defined in the CSS
// Use the following format:
// #getActiveMQ-watcher { font-family: "default"; }
// @media only screen and (min-width:20em){ #getActiveMQ-watcher { font-family: "small"; } }
// etc.
window.getActiveMQ = function() {
// Build the watcher
var $watcher = document.createElement('div'),
// alias getComputedStyle
computed = window.getComputedStyle,
@mathiasbynens
mathiasbynens / jquery.preload.js
Created April 22, 2010 17:11
JavaScript preload() function
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
@ebidel
ebidel / app.html
Last active May 1, 2021 15:42
Fast Polymer app loading - optimized for first render, progressively enhanced lazy loading
<!DOCTYPE html>
<html>
<head>
<style>
body.loading #splash {
opacity: 1;
}
#splash {
position: absolute;
top: 0;
@derek-watson
derek-watson / simple-throttle.js
Created August 14, 2012 14:44
Simple javascript function throttling
var isThrottled = false,
throttleDuration = 24; // ms
function thingToThrottle() {
if (isThrottled) { return; }
isThrottled = true;
setTimeout(function () { isThrottled = false; }, throttleDuration);
// do your work here
}
@Kilian
Kilian / annoying.js
Created January 6, 2011 15:04
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
@nolanlawson
nolanlawson / parens-and-perf-counterpost.md
Last active August 14, 2023 20:08
"Parens and Performance" – counterpost

"Parens and Performance" – counterpost

Kyle Simpson (@getify) wrote a very thoughtful post decrying optimize-js, which is a tool I wrote that exploits known optimizations in JavaScript engines to make JS bundles parse faster (especially minified bundles, due to what could be reasonably described as a bug in Uglify).

Kyle lays out a good case, but I tend to disagree with nearly all his points. So here's my rebuttal.

@getify
getify / ex1-prototype-style.js
Last active January 7, 2024 11:58
OLOO (objects linked to other objects) pattern explored (with comparison to the prototype style of the same code)
function Foo(who) {
this.me = who;
}
Foo.prototype.identify = function() {
return "I am " + this.me;
};
function Bar(who) {
Foo.call(this,"Bar:" + who);
@jesstelford
jesstelford / 01-shape-up-to-kindle.md
Last active January 10, 2024 20:08
Read SHAPE UP by basecamp on a Kindle / reMarkable / eReader

Read Shape Up by basecamp on a kindle / reMarkable / eReader

Basecamp's new book Shape Up is now available online (https://basecamp.com/shapeup) to read page-by-page.

There is a .pdf version, but that's not the best format for Kindle / other eReaders. Instead, we can convert the page-by-page into an eReader friendly format.

Part 1: Convert to a single page

NOTE: This has only been tested on Chrome