Skip to content

Instantly share code, notes, and snippets.

View daviferreira's full-sized avatar

Davi Ferreira daviferreira

View GitHub Profile
@justintv
justintv / .bashrc
Created August 17, 2009 00:53
Display git branch in bash prompt
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer!
export PS1="\\w:\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\$ "
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty!
# ~/code/web:beta_directory$ git checkout master
# Switched to branch "master"
# ~/code/web:master$ git checkout beta_directory
# Switched to branch "beta_directory"
@alganet
alganet / gist:819098
Created February 9, 2011 19:33
less javaish SplClassLoader
<?php
spl_autoload_register(
function($className) {
$fileParts = explode('\\', ltrim($className, '\\'));
if (false !== strpos(end($fileParts), '_'))
array_splice($fileParts, -1, 1, explode('_', current($fileParts)));
$file = implode(DIRECTORY_SEPARATOR, $fileParts) . '.php';
@alganet
alganet / basic_routing.php
Created April 12, 2011 18:48
Another microframework concept
<?php
$r = new Respect\Rest\Router;
$r->get('/', function() {
return 'Hello World';
});
$r->get('/users', function() use($users) {
return $users->list()->toHTML(); //sample model/view call
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@idan
idan / _more.scss
Created June 6, 2011 08:40
More is Less
$less-column-width: 68px;
$less-gutter-width: 24px;
@function column-width($columns) {
@return ($less-column-width * $columns) + ($less-gutter-width * ($columns - 1));
}
@function grid-padding-px($columns) {
@if $columns == 10 {
@return 48px;
@dgmike
dgmike / Install.sh
Created June 18, 2011 16:34
Install Lessjs + CSSLint
#!/bin/bash
# pre install
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
sudo apt-get install python-software-properties
# install nodejs
sudo add-apt-repository ppa:jerome-etienne/neoip
sudo apt-get update
@dgmike
dgmike / Validation.php
Created June 27, 2011 16:04
Validation.php
<?php
/**
* Classe de validacao de formularios
*
* PHP Version 5.2
*
* @category Helper
* @package Virgula
* @author Michael Granados <michaelgranados@corp.virgula.com.br>
@luizfonseca
luizfonseca / sample.erb
Created July 21, 2011 17:18
Better loading of styles on a Rails Application :-)
%h1 When using HAML, or even the rails .erb format, you can improve the loading of your pages using:
= stylesheet_link_tag controller.action_name
%span Or
= stylesheet_link_tag self.current_method
%span And create the proper CSS file in the public/style folder (e.g.: action_name.(s)css/ current_method.(s)css.
With this, the user only requests the CSS file from that page he is visiting.
@luizfonseca
luizfonseca / Gemfile
Created July 22, 2011 04:12
Gemfile for Rails Apps
source 'http://rubygems.org'
# Updated Rails version
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Server ('cause Webrick is such a pain in the ass)
gem 'unicorn'
@alganet
alganet / h.php
Created August 10, 2011 22:43
HTML generator prototype
<?php
print
h::html(
h::head(
h::title('Hi!')
),
h::body(
h::h1('Hello')->id('oi'),
h::ul(