Skip to content

Instantly share code, notes, and snippets.

View leonelgalan's full-sized avatar

Leonel Galán leonelgalan

View GitHub Profile
@leonelgalan
leonelgalan / imagemagick.rb
Last active August 29, 2015 14:14
ImageMagick 6.7.7-10
require "formula"
class Imagemagick < Formula
homepage "http://www.imagemagick.org"
url "http://www.imagemagick.org/download/releases/ImageMagick-6.7.7-10.tar.xz"
sha256 "85b0f9afe122c52a821001976a4f54ae011bb3d94a87b97e3112e515185731ad"
head "http://www.imagemagick.org/subversion/ImageMagick/trunk"
option "with-quantum-depth-8", "Compile with a quantum depth of 8 bit"
@leonelgalan
leonelgalan / gist:49b8ea9b33f221a092ab
Last active August 29, 2015 14:13
Remove .js and .css from .coffee and .scss files
find . -name '*.js.coffee' -type f | while read NAME ; do mv "${NAME}" "${NAME%.js.coffee}.coffee" ; done
find . -name '*.css.scss' -type f | while read NAME ; do mv "${NAME}" "${NAME%.css.scss}.scss" ; done
@leonelgalan
leonelgalan / README.md
Created November 17, 2014 21:39
Using stackprof and rspec (Rails)
  1. Existing rspec-stackprof is "empty"
  2. stackprof is written as a replacement for perftools.rb
  3. Added an environment variable to conditionally run the profiler, it slows down test runtime by a couple of seconds for me.
  4. Just add stackprof.rb to your spec/support folder, which is loaded on rails_helper.rb
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details

The Beauty of Ruby (Part 2)

If you read the title and thought I was going to talk about the gemstone, you are in the right place. This series is intended for non-developers to understand why some of us, developers, prefer Ruby over other languages.

This is a series of blog posts, read part 1 to see Ruby examples against other languages: PHP and Java.

===

I often see code written like this:

allItems = document.getElementsByTagName('*')
i = 0
while i < allItems.length
if allItems[i].tagName isnt 'HTML' and allItems[i].tagName isnt 'BODY'
allItems[i].addEventListener 'mouseover', (event) ->
console.log event.target.style.border
event.target.setAttribute 'data-border', event.target.style.border
event.target.style.border = '2px solid #F00'
event.stopPropagation()
allItems[i].addEventListener 'mouseout', (event) ->
@leonelgalan
leonelgalan / test_helper.rb
Created November 9, 2013 00:43
Default test_helper.rb Rails 4.0.1
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
@leonelgalan
leonelgalan / beauty_of_ruby_1.md
Last active December 27, 2015 12:09
A future blog post titled "The Beauty of Ruby (Part 1)"

The Beauty of Ruby (Part 1)

If you read the title and thought I was going to talk about the gemstone, you are in the right place. This series is intended for non-developers to understand why some of us, developers, prefer Ruby over other languages.

"Ruby is simple in appearance, but is very complex inside, just like our human body" says Yukihiro "Matz" Matsumoto, its creator. After 7 years in school studying computer science, I didn't felt like doing "rocket science" the rest of my life. Not all computer scientists (let's say developers from know on) enjoy dealing with the underlying complexities of computers every day. While studying, my area of interest was to solve complex problems with simple technology and Ruby fitted like a glove.

This blog post started 8 months ago with this tweet. I have been coding for a while and every day I am pleasantly surprised about how pretty my code looks thanks to Ruby. The resul

Create an alias

alias mou='open -a Mou'

Open any md file from command line

mou FILE.md
@leonelgalan
leonelgalan / sinatra_base.sh
Last active December 14, 2015 19:29
Downloads my sinatra_base repository and renames it to the desired name. Usage: `curl https://raw.github.com/gist/5137209 | bash -s project_name`
#!/bin/bash
wget https://github.com/leonelgalan/sinatra_base/archive/master.zip
unzip master.zip
rm master.zip
mv sinatra_base-master $1
LAST_RUBY=`curl 'http://ftp.ruby-lang.org/pub/ruby/1.9/' 2> /dev/null | ruby -e 'puts STDIN.lines.map { |x| /1\.9\.3-p\d+\b/.match(x) }.compact.last[0]'`
echo $LAST_RUBY > $1/.ruby-version
echo $1 > $1/.ruby-gemset