Skip to content

Instantly share code, notes, and snippets.

View hdragomir's full-sized avatar

Horia Dragomir hdragomir

View GitHub Profile
@hdragomir
hdragomir / the_classy_way_to_sudo.sh
Created February 9, 2015 19:20
The Classy Way to sudo
alias fucking='sudo '
alias doit='$(history -p !!)'
@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);
@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 / droidshot.sh
Last active August 29, 2015 14:00
droidshot - simple cli utility that wraps taking screenshots from an android phone
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"
}
<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
#