Skip to content

Instantly share code, notes, and snippets.

View jonatasnona's full-sized avatar
🇧🇷
Working from home

Jonatas Pedraza jonatasnona

🇧🇷
Working from home
View GitHub Profile
@jonatasnona
jonatasnona / key-fingerprint
Created March 7, 2012 18:45 — forked from yosemitebandit/key-fingerprint
SSH: print ssh public key's fingerprint
$ ssh-keygen -l -f id_rsa.pub
2048 aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99 id_rsa.pub (RSA)
@jonatasnona
jonatasnona / gist1994877
Created March 7, 2012 19:00
Javascript: UserAgent
<script>
var ua = navigator.userAgent;
var checker = {
ios: ua.match(/(iPhone|iPod|iPad)/),
blackberry: ua.match(/BlackBerry/),
android: ua.match(/Android/),
windowsphone: ua.match(/Windows Phone/)
};
$(document).ready(function() {
@jonatasnona
jonatasnona / gist:1995269
Created March 7, 2012 19:20
GIT: Commiters Rank
git shortlog -s -n
@jonatasnona
jonatasnona / snippet.js
Created March 9, 2012 20:28 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
@jonatasnona
jonatasnona / gist:2050388
Created March 16, 2012 14:48
Javascript: Sort an Array of Objects by Properties
// thanks to daniel walsh
// http://davidwalsh.name/array-sort
// http://dochub.io/#javascript and search for sort to see more details
// sort by age
var o = [{name : "Robin Van Persie", age: 28},
{name : "Theo Walcott", age : 22},
{name : "Bacary Sagna", age : 26}
].sort(function(obj1, obj2) {
return obj1.name - obj2.name;
@jonatasnona
jonatasnona / gist:2625083
Created May 7, 2012 00:07
APT: Removing broken packages in a bad inconsistent state
# rm /var/lib/dpkg/info/flashplugin-nonfree.prerm
# dpkg --remove --force-remove-reinstreq <package>
@jonatasnona
jonatasnona / gist:2625095
Created May 7, 2012 00:11
APT: List deinstall packages with orphan config files
# aptitude search ~c
@jonatasnona
jonatasnona / gist:2625103
Created May 7, 2012 00:12
APT: Removing config files of deinstall packages
# aptitude purge ~c
@jonatasnona
jonatasnona / pre-commit
Created July 7, 2012 14:58 — forked from bcmiller/pre-commit
Git: pre-commit
#!/bin/sh
# Place as .git/hooks/pre-commit
#Reject any commit that would have PHP syntaz errors on .php , .module, .install, .inc files
####
# Reject any commit that would add a line with tabs.
#
# You can enable this as a repo policy with
#
# git config hooks.allowtabs true
####
@jonatasnona
jonatasnona / gist:3066806
Created July 7, 2012 15:03
Git: pre-commit
#!/bin/sh
#
# A git hook script to find and fix trailing whitespace
# in your commits. Bypass it with the --no-verify option
# to git-commit
#
# Find files with trailing whitespace
for file in `git diff --check --cached | grep '^[^+-]' | grep -o '^.*[0-9]\+:'` ; do