Skip to content

Instantly share code, notes, and snippets.

View jhbabon's full-sized avatar
🦊

Juan Hernández jhbabon

🦊
View GitHub Profile
@jhbabon
jhbabon / render_template.php
Created August 3, 2011 18:06
Quick and dirty PHP function to render templates
<?php
function render($template, $params = array(), $directory = 'templates') {
// make sure that the template has the desired params
extract($params);
// catch the template content
ob_start();
include($directory . '/' . $template . '.php'); // you have the correct include_path, right?
$applied_template = ob_get_contents();
@jhbabon
jhbabon / uninstall_all_gems.sh
Created November 9, 2011 21:36
Uninstall all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@jhbabon
jhbabon / unicorn.rb
Created February 1, 2012 18:16
Basic unicorn configuration for Rails
# -*- encoding: utf-8 -*-
# config/server/unicorn.rb
require 'fileutils'
# required data
env = ENV['RACK_ENV']
app_dir = File.expand_path('../../..', __FILE__)
app_key = 'app'
@jhbabon
jhbabon / ios_ui_design_tips.markdown
Created February 11, 2012 20:45
iOS UI Design Tips

iOS User Interface Design Tips

Focus

  • Create an application definition statement.
  • Reduce your app's feature set to just the essentials.
  • In the UI, display only the most important items.
  • Showcase content.
  • Place secondary options in separate screen or popover.
@jhbabon
jhbabon / perl_pattern_substitution_command.sh
Created February 15, 2012 23:33
Command line to substitute string patterns in a group of files
perl -e "s/old_pattern/new_pattern/g;" -pi.save $(ack -f path/to/files)
# NOTE: this will create *.save files. Remove them with: rm -f **/*.save
@jhbabon
jhbabon / git_delete.sh
Created February 29, 2012 08:26
Remove deleted files from git index
# borrowed from: http://log.iany.me/post/16812080563/git-rm-deleted-files
git ls-files -d | xargs git rm
@jhbabon
jhbabon / pre-commit.sh
Created March 6, 2012 09:55
Pre commit git-hook that checks if there are changes that must not be committed. The changes should be marked with a NOCOMMIT flag.
#!/bin/sh
#
# Do not commit files with the flag: NOCOMMIT
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@jhbabon
jhbabon / passman.sh
Created March 11, 2012 11:42
passman - Minimal password manager
#!/bin/sh
# passman - GPL3 - nibble <develsec.org> 2009
# Minimal password manager
# link: http://nibble.develsec.org/hg/toys/file/ddaf55c59fc7/passman
PASSFILE=~/.passmandb
TMPFILE=~/.passmandb.$$
trap "shred -fuz ${TMPFILE}" 0 2 15 &&
umask 177 &&
@jhbabon
jhbabon / gist:2198506
Created March 25, 2012 17:33
rbenv install with Xcode 4.3
# set the gcc in the environment
env CC=/usr/bin/gcc rbenv install ruby-interpreter-here
@jhbabon
jhbabon / application_helper.rb
Created May 9, 2012 09:57
Useful Rails 2.3 view helpers
# -*- encoding: utf-8 -*-
module ApplicationHelper
def title(txt, show = true)
content_for(:title) { h(txt.to_s) }
@show_title = show
show_title
end