Skip to content

Instantly share code, notes, and snippets.

View diasjorge's full-sized avatar
🤖

Jorge Dias diasjorge

🤖
View GitHub Profile
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 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
(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)))
unless ENV['INSIDE_EMACS']
# load libraries
require 'rubygems'
require 'wirble'
# start wirble (with color)
Wirble.init
Wirble.colorize
end
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)
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}.
git log --pretty=short | grep Author: | awk '{print $2}' | sort | uniq
// 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",
(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)))
# Find files and replace text
find . -name '*.rb' | xargs sed 's/Test::Unit::TestCase/ActiveSupport::TestCase/'