Skip to content

Instantly share code, notes, and snippets.

Avatar

Horia Dragomir hdragomir

View GitHub Profile
View the_classy_way_to_sudo.sh
alias fucking='sudo '
alias doit='$(history -p !!)'
@hdragomir
hdragomir / index.html
Created Jul 7, 2014
IIFE version of SM Font Loading
View index.html
<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);
@hdragomir
hdragomir / sm-annotated.html
Last active Nov 1, 2021
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
View sm-annotated.html
<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 / droidshot.sh
Last active Aug 29, 2015
droidshot - simple cli utility that wraps taking screenshots from an android phone
View droidshot.sh
function droidshot {
saveto=~/droidshots
fname=$(date +"%Y%m%d%H%M").png
[[ ! -z $1 ]] && fname=$1
[[ -d $saveto ]] || mkdir $saveto
adb shell screencap -p /sdcard/$fname
adb pull /sdcard/$fname $saveto/$fname
adb shell rm /sdcard/$fname
echo "saved to $saveto/$fname"
}
View abs.html
<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 Oct 12, 2015
By popular demand
View .vimrc
autocmd!
set nocompatible
let mapleader = ","
filetype on
set title
set ai
set relativenumber
set cursorline
set expandtab expandtab
View shadow-bars.html
<!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;
View switch-default.js
switch (num) {
case 1:
'do your stuff';
break;
default:
case 2:
'do other stuff';
break;
case 3:
'more stuff';
@hdragomir
hdragomir / dabblet.css
Created Jul 2, 2012
Weird behavior when combining opacity & z-index: -1
View dabblet.css
/**
* 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 Jun 27, 2012 — forked from mrsimo/hack.sh
OSX For Hackers
View hack.sh
#!/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
#