Skip to content

Instantly share code, notes, and snippets.

View zanonnicola's full-sized avatar
💭
I like Kotlin

Nicola Zanon zanonnicola

💭
I like Kotlin
View GitHub Profile
@Gerhard-Kanzler
Gerhard-Kanzler / cache.js
Last active September 20, 2015 10:34
Css Caching in sessionstorage
var css_href_array = [];
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var styleTags = document.getElementsByClassName('js-style');
function getBrowser() {
var myAgent = navigator.userAgent.toLowerCase();
if( myAgent.indexOf('msie') != -1 && parseInt(myAgent.split('msie')[1]) == 8 ){
return 'ie8';
@derekjohnson
derekjohnson / webfonts.js
Last active December 28, 2015 18:49
Font loader
(function(win, doc, undefined) {
// sanity check - is it a decent browser
if('addEventListener' in win && 'localStorage' in win && 'querySelector' in doc) {
// https://gist.github.com/scottjehl/5406853
var injectref = doc.getElementsByTagName('script')[0],
loadCSS = function(href) {
var fontslink = doc.createElement('link');
@eliperelman
eliperelman / LICENSE.txt
Last active April 18, 2016 23:20 — forked from 140bytes/LICENSE.txt
Preloader140
DO WHAT YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Eli Perelman <http://eliperelman.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 YOU WANT TO PUBLIC LICENSE
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Credit Card Form</title>
<style>
.forAppleCardScan {
width: 1px;
height: 1px;
margin-left: -1000px;
@mariusGundersen
mariusGundersen / moduleImports.js
Created June 9, 2014 20:05
Potential module import syntax in ES6
module _ from "underscore";
import _ from "underscore";
import module _ from "underscore";
import {each, map, find} from "underscore";
import "underscore";
import default _ from "underscore";
const _ = System.import("underscore");
import "underscore" as _;
import {_} from "underscore";
import {each as forEach} from "underscore";
@adelevie
adelevie / .travis.yml
Created April 9, 2015 18:15
Automated accessibility testing using Travis-CI and pa11y
before_script:
- npm install -g http-server
- npm install -g pa11y
- npm install -g pa11y-reporter-ci
script:
- nohup http-server -p 8080 >/dev/null 2>&1 &
- pa11y localhost:8080/index.html -r ci -s WCAG2AAA
@bjankord
bjankord / gist:2399828
Created April 16, 2012 16:35
Accurate cross-browser viewport width
/* -----------------------------------------------
* Accurate Cross-Browser Viewport Width
* https://gist.github.com/2399828
* -----------------------------------------------
* Copyright 2012, Brett Jankord.
* http://www.brettjankord.com/
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
* ------------------------------------------------*/
@hdragomir
hdragomir / index.html
Created July 7, 2014 09:48
IIFE version of SM Font Loading
<script type="text/javascript">
(function (css_href) {
"use strict";
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
} else if (el.attachEvent) {
el.attachEvent("on" + ev, callback);
@oslego
oslego / gist:f13e136ffeaa6174289a
Last active January 3, 2019 14:24 — forked from sl4m/gist:5091803
create self-signed certificate for localhost
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@developit
developit / _preact-pure-component.md
Created September 7, 2016 14:14
pure-component for Preact

pure() can be used as a higher order function or a decorator.

When passed a pure functional component, it wraps the function in a classful Component with a shouldComponentUpdate() that ignores renders for unchanged props.

When passed a classful Component, it injects a shouldComponentUpdate() method into the Component's prototype that ignores renders for unchanged props & state.

Functional Example

import pure from 'pure-component';