Skip to content

Instantly share code, notes, and snippets.

View hsanchez's full-sized avatar
I may be slow to respond.

Huascar Sanchez hsanchez

I may be slow to respond.
View GitHub Profile
if `ant -version` !~ /version (\d+)\.(\d+)\.(\d+)/ || $1.to_i < 1 || ($1.to_i == 1 && $2.to_i < 8)
puts "ANT version 1.8.0 or later required. Version found: #{$1}.#{$2}.#{$3}"
exit 1
end
require 'time'
def manifest() @manifest ||= REXML::Document.new(File.read(MANIFEST_FILE)) end
def package() manifest.root.attribute('package') end
def build_project_name() @build_project_name ||= REXML::Document.new(File.read('build.xml')).elements['project'].attribute(:name).value end
@hsanchez
hsanchez / Rakefile
Created May 30, 2012 16:56
Automatic installation of multiple apk files.
def config
# in this Rakefile we can allow that
$config ||= Hash.new
end
# ADB command to be invoked when installing *.apk
config['adb'] = 'adb'
# Version
config['version'] = '1.0'
@hsanchez
hsanchez / template.tex
Created September 7, 2012 16:31
My Latex Template for Kindle (Or IPAD)
\documentclass[8pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[paperwidth=9cm, paperheight=11.5cm, top=0.5cm, left=0.5cm, right=0.5cm, bottom=0.5cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz, blindtext}
\makechapterstyle{box}{
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\renewcommand*{\printchapternum}{
@hsanchez
hsanchez / gitstatus.bash
Created September 7, 2012 16:58
Colored Git Status in your command line
## place this in your .profile
## For example,
## ☺ is a clean repository.
## o_O means there are changes.
## O_o means there are staged but not commit changes.
## ☼ means nothing to show for
function parse_git_dirty {
D="$(git status 2> /dev/null | tail -n1 | awk '{ print $1 }' )"
@hsanchez
hsanchez / emacs.pdf
Created September 23, 2012 06:42 — forked from pgundlach/emacs.pdf
ConTeXt refcard
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hsanchez
hsanchez / mydiss.cls
Created September 23, 2012 07:12 — forked from ummels/mydiss.cls
Class file for my PhD thesis
\ProvidesClass{mydiss}[2012/08/22 v1.3 mydiss class (Michael Ummels)]
\NeedsTeXFormat{LaTeX2e}[1996/06/01]
% Options
\newif\if@iso
\@isofalse
\newif\if@crop
\@cropfalse
@hsanchez
hsanchez / ItemsPlacement.java
Created September 26, 2012 21:49
It allows us to get an optimal placement of "clusters of parts" on a grid using backtracking and incremental improvement ideas.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class ItemsPlacement {
// Area where we will placing parts
static class Area {
int x = 0;
@hsanchez
hsanchez / Rakefile
Created November 6, 2012 20:00
Things to remember about Rake Tasks
# tasks with arguments
task :taskname, :argument do |t, args|
message = args[:argument] || 'Hello'
puts message
end
# Tasks in namespaces
namespace :namespacename do
task :taskname, :argument do |t, args|
message = args[:argument] || 'Hello'
#
# A C Parser using the Parslet library.
#
# ANSI C Grammar:
#
# * http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
# * http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
#
require 'parslet'
For those of you who get this error after upgrading to mountain lion:
Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for /usr/bin/gcc-4.2... no