This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_thumbnail(addendum, new_width, new_height) | |
width, height = get_resolution | |
logger.debug "width=#{width}, height=#{height}" | |
needs_resize = (new_width < width) && (new_height < height) | |
ratio = new_width.to_f / new_height.to_f # Watch out for the floats | |
if needs_resize | |
logger.debug "needs rez" | |
# NEW FORMULA | |
# First step crops a rectangle proportional to new dimensions from the center of the original image | |
# After that, new rectangle is resized to fit new dimensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is what I try in console | |
1.upto(1500) do |i| | |
MiddleMan.worker(:performance_worker). | |
async_test_performance(:job_key => "performance_#{i}", | |
:arg => "TEXTO A MOSTRAR #{i}") | |
end | |
#Worker | |
class PerformanceWorker < BackgrounDRb::MetaWorker | |
set_worker_name :performance_worker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun haml-convert-rhtml-file (rhtmlFile hamlFile) | |
"Convierte un fichero rhtml en un haml y abre un nuevo buffer" | |
(interactive "fSelect rhtml file: \nFSelect output (haml) file: ") | |
(let ((comando (concat "/usr/bin/html2haml -r " | |
rhtmlFile | |
" " | |
hamlFile))) | |
(shell-command comando) | |
(find-file hamlFile))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless ENV['INSIDE_EMACS'] | |
# load libraries | |
require 'rubygems' | |
require 'wirble' | |
# start wirble (with color) | |
Wirble.init | |
Wirble.colorize | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :adva do | |
namespace :i18n do | |
#Define locales root | |
language_root = Rails.root.join("vendor/plugins/adva_cms/locale/adva_cms/") | |
base_language = "en" | |
desc "Check differences in locale files" | |
task :check do | |
base = YAML::load_file("#{language_root}#{base_language}.yml") | |
base_keys = all_keys(base, base_language) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RemoteLinkRenderer < WillPaginate::LinkRenderer | |
def prepare(collection, options, template) | |
@remote = options.delete(:remote) | |
super | |
end | |
protected | |
def page_link(page, text, attributes = {}) | |
if @remote | |
@template.link_to_remote(text, {:url => url_for(page), :method => :get}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --pretty=short | grep Author: | awk '{print $2}' | sort | uniq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on apidock.org Ubiquity Search: http://gist.github.com/8132 | |
CmdUtils.CreateCommand( | |
{ | |
name: "code", | |
takes: {"function": noun_arb_text}, | |
icon: "http://github.com/fluidicon.png", | |
homepage: "http://tiago.zusee.com", | |
author: {name: "Tiago Bastos", email: "comechao@gmail.com"}, | |
license: "MPL,GPL", | |
description: "Search on Github Code Search", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun insert-path () | |
"Inserts a path into the buffer with completion" | |
(interactive) | |
(insert (expand-file-name (read-file-name "Path: ")))) | |
(defun insert-path (file) | |
"insert file" | |
(interactive "FPath: ") | |
(insert (expand-file-name file))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find files and replace text | |
find . -name '*.rb' | xargs sed 's/Test::Unit::TestCase/ActiveSupport::TestCase/' |
OlderNewer