Skip to content

Instantly share code, notes, and snippets.

View hdragomir's full-sized avatar

Horia Dragomir hdragomir

View GitHub Profile
@hdragomir
hdragomir / sm-annotated.html
Last active March 5, 2024 08:57
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(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 css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
@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);
<script>
function abs(x) {
x = typeof x === "string" ? x.indexOf(',') > -1 ? Number.NaN : ( x.indexOf('.') > -1 ? parseFloat(x, 10) : parseInt(x, 10) ) : (typeof x === "number" || x === null ? x : Number.NaN);
return Number.isNaN(x) ? x : (x === null ? 0 : (x < 0 ? -x : x ));
}
function assert(message, condition) {
condition || console.error(message);
}
@hdragomir
hdragomir / .vimrc
Last active October 12, 2015 08:47
By popular demand
autocmd!
set nocompatible
let mapleader = ","
filetype on
set title
set ai
set relativenumber
set cursorline
set expandtab expandtab
@hdragomir
hdragomir / shadow-bars.html
Created October 10, 2012 15:41
shadow bars
<!doctype html>
<title>background bars proto</title>
<style type="text/css">
.row {
margin: .20em auto;
width: 200px;
position: relative;
font: 14px/22px sans-serif;
color: #333;
background: white;
@hdragomir
hdragomir / switch-default.js
Created October 10, 2012 11:54
Switch Default
switch (num) {
case 1:
'do your stuff';
break;
default:
case 2:
'do other stuff';
break;
case 3:
'more stuff';
@hdragomir
hdragomir / dabblet.css
Created July 2, 2012 12:13
Weird behavior when combining opacity & z-index: -1
/**
* Weird behavior when combining opacity & z-index: -1
*/
div {
position: relative;
width: 200px; height: 200px;
background: yellowgreen;
/* Try commenting this or setting it to 1: */
@hdragomir
hdragomir / hack.sh
Created June 27, 2012 17:09 — forked from mrsimo/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2299719/hack.sh | sh
#
@hdragomir
hdragomir / cd!.sh
Created March 23, 2012 13:29
Changes to a directory, creates it first if not already there. Saves me loads of headaches
function cd! {
mkdir $1
cd $1
}
@hdragomir
hdragomir / .gitconfig
Created February 22, 2012 11:11
By Popular demand, my gitconfig file
[user]
name = Horia Dragomir
email = horia@hdragomir.com
[github]
user = hdragomir
[alias]
st = status -sb
ci = commit
co = checkout
p = push