Skip to content

Instantly share code, notes, and snippets.

View samir's full-sized avatar
:octocat:
I may be slow to respond.

Samir M. Braga samir

:octocat:
I may be slow to respond.
View GitHub Profile
@samir
samir / php.rb
Created January 7, 2011 11:28
Homebrew Formula for PHP with Freetype support
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php <Formula
url 'http://www.php.net/get/php-5.3.3.tar.gz/from/this/mirror'
homepage 'http://php.net/'
md5 '5adf1a537895c2ec933fddd48e78d8a2'
@samir
samir / gist:734321
Created December 9, 2010 04:04
Distance between two coordinates (latitude/longitude) in PHP
function distance($lat1 = 0, $lng1 = 0, $lat2 = 0, $lng2 = 0, $miles = true)
{
$pi80 = M_PI / 180;
$lat1 *= $pi80;
$lng1 *= $pi80;
$lat2 *= $pi80;
$lng2 *= $pi80;
$r = 6372.797; // mean radius of Earth in km
$dlat = $lat2 - $lat1;
@samir
samir / gist:718089
Created November 27, 2010 17:21
Mac OS X Terminal Tips
# Make hidden Dock icons transparent
defaults write com.apple.Dock showhidden -bool YES
killall Dock
# Change the location of snapped screenshots
mkdir -p ~/Pictures/Screnshots
defaults write com.apple.screencapture location ~/Pictures/Screenshots
killall Dock
# Change your current screenshot format
@samir
samir / gist:714407
Created November 24, 2010 21:03
Renaming files in one line
# Rename files in one line
# Util for renaming files with prefix or sufix, removing, modifying, etc
# First, list files that will be renamed
# In sequence, create the command to rename it (using mv command)
# Modify the command swapping the string
# Send it to /bin/bash
ls *_abc.png | awk '{print("mv "$1" "$1)}' | sed 's/_abc/_def/2' | /bin/bash
@samir
samir / gist:707798
Created November 20, 2010 12:51
Base for create .bash_profile for OS X
# --------------------------------------------------------
export APXS2=`which apxs`
export CFLAGS="-arch x86_64 -O2"
export ARCHFLAGS="-arch x86_64"
export EDITOR='mate -w'
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=DxGxcxdxCxegedabagacad
export LC_CTYPE=en_US.UTF-8
@samir
samir / gist:707793
Created November 20, 2010 12:41
Show current version of git, svn and rvm in prompt
# I made this gist to build my shell prompt based in various references on the web
# I will try to list the most of references, but sorry if I not put your here -
# http://henrik.nyh.se/2008/12/git-dirty-prompt (GIT)
# GIT
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
<!--#if expr="$REMOTE_ADDR = /^200\.182\.35\./" -->
<!--#else -->
<!--#endif -->
UPDATE table SET field = REPLACE(field, "before", "after") WHERE field REGEXP "([pattern])";