Skip to content

Instantly share code, notes, and snippets.

View zerolab's full-sized avatar
🖖
Live long and prosper

Dan Braghiș zerolab

🖖
Live long and prosper
View GitHub Profile
// instead of this:
if( foo ) {
if( bar ) {
doSomething();
} else {
errorHandling();
}
} else {
errorHandling();
}
@davist11
davist11 / Fancy File Inputs.js
Created October 25, 2010 21:32
Fancy File Inputs
var SITE = SITE || {};
SITE.fileInputs = function() {
var $this = $(this),
$val = $this.val(),
valArray = $val.split('\\'),
newVal = valArray[valArray.length-1],
$button = $this.siblings('.button'),
$fakeFile = $this.siblings('.file-holder');
if(newVal !== '') {
// original
for(e,l='article aside footer header nav section time'.split(' ');e=l.pop();document.createElement(e))
// original + moved pop
for(l='article aside footer header nav section time'.split(' ');;document.createElement(l.pop()))
// mine (not tested! might need some braces...)
// v1 (no globals)
var l=['article','aside','footer','header','nav','section','time'];for(var i in l)document.createElement(l[i])
@jpstacey
jpstacey / .gitconfig
Last active February 7, 2024 04:35
Sample git config
# See the following for references:
# * http://www.metacircus.com/hacking/2011/02/18/play-git-like-a-violin.html
# * http://cheat.errtheblog.com/s/git/
# * http://pyrtsa.posterous.com/aligning-your-git-logs
# * http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
# Git >v1.7.10 lets you include external files
# Put your user configuration in here, so it never
# accidentally gets checked in
[include]
@tvandervossen
tvandervossen / gist:1231476
Created September 21, 2011 07:33
Mobile Safari viewport sizes on iOS 4.3 and 5
iPad
1024 × 690 In landscape on iOS 4.3
1024 × 672 In landscape on iOS 5
768 × 946 In portrait on iOS 4.3
768 × 928 In portrait on iOS 5
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3
1024 × 644 Always showing bookmarks bar in landscape on iOS 5
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3
@msonnabaum
msonnabaum / gist:1306569
Created October 22, 2011 22:28
install xhprof on mamp for php 5.3
wget http://pecl.php.net/get/xhprof-0.9.2.tgz
tar -xzf xhprof-0.9.2.tgz
cd xhprof-0.9.2/extension
/Applications/MAMP/bin/php/php5.3.6/bin/phpize
./configure
make
cp modules/xhprof.so $(/Applications/MAMP/bin/php/php5.3.6/bin/php-config --extension-dir)/
echo "extension=xhprof.so" >> /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
@beddari
beddari / install_vagrant_sudoers.sh
Created December 13, 2011 12:47
Allow Vagrant sudo-access without password for NFS-setup
#!/bin/bash
# Script for placing sudoers.d files with syntax-checking
if [ -z "$1" ]; then
# Making a temporary file to contain the sudoers-changes to be pre-checked
TMP=$(mktemp)
cat > $TMP <<EOF
Cmnd_Alias VAGRANT_EXPORTS_ADD = /bin/su root -c echo '*' >> /etc/exports
Cmnd_Alias VAGRANT_NFSD = /etc/init.d/nfs-kernel-server restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -e /*/ d -ibak /etc/exports
<script>
// Break out of an iframe, if someone shoves your site
// into one of those silly top-bar URL shortener things.
//
// Passing `this` and re-aliasing as `window` ensures
// that the window object hasn't been overwritten.
//
// Example:
// var window = 'haha, punked!';
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter