Skip to content

Instantly share code, notes, and snippets.

@baopham
baopham / gist:1868420
Created February 20, 2012 08:27
FizzBuzz oneliner
#Rosetta Code
for x in range(1, 101):
print ''.join(['' if x%3 else 'fizz', '' if x%5 else 'buzz']) or x
@baopham
baopham / .bashrc
Created February 22, 2012 18:34
.bashrc
# Show git branch in bash prompt
__git_ps1 ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}
alias la='ls -A'
alias ll='ls -l'
@baopham
baopham / mvim.sh
Created February 23, 2012 20:32
Modified mvim script to have options of opening files in tabs or new windows
#!/bin/sh
#
# This shell script passes all its arguments to the binary inside the
# MacVim.app application bundle. If you make links to this script as view,
# gvim, etc., then it will peek at the name used to call it and set options
# appropriately.
#
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007).
@baopham
baopham / .bash_profile
Created February 23, 2012 20:35
bash_profile
# bash prompt
if [ -n "$SSH_CONNECTION" ] ; then
export PS1="\[\033[G\]\[\033[0;32m\]\u@\h\[\033[0;32m\] \w\$(__git_ps1) \$\[\033[00m\] "
else
if [ "$USER" != "baopham" ] ; then
export PS1="\[\033[G\]\[\033[0;32m\]\u \w\$(__git_ps1) \$\[\033[00m\] "
else
export PS1="\[\033[G\]\[\033[0;32m\]\w\$(__git_ps1) \$\[\033[00m\] "
fi
fi
@baopham
baopham / .git-completion.sh
Created April 1, 2012 01:13
git-completion
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@baopham
baopham / .osx
Created April 4, 2012 17:45
Defaults commands for OSX
# GistID: 2304197
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
@baopham
baopham / mobile-redirect.mkd
Created April 11, 2012 22:29
Mobile Redirect js Snippets

Redirect Mobile Devices

<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "mobile.html";
}
//-->
@baopham
baopham / css-tips.css
Created April 12, 2012 19:16
CSS notes
/* Opacity */
filter:alpha(opacity=95); /* For IE */
-moz-opacity:0.95; /* Older versions of Mozilla */
-khtml-opacity: 0.95; /* For Sarari 1.x */
opacity: 0.95; /* General Usage */
@baopham
baopham / rails-note.md
Created April 22, 2012 02:09
Rails Note

Asset directories

In versions of Rails before 3.0 (including 3.0 itself), static assets lived in the public/ directory, as follows:

public/stylesheets
public/javascripts
public/images

Files in these directories are (even post-3.0) automatically served up via requests to http://example.com/stylesheets, etc.

@baopham
baopham / prompt.sh
Created April 27, 2012 18:10
Glue the bash prompt to the first column
PS1="\[\033[G\]$PS1"