Skip to content

Instantly share code, notes, and snippets.

@ceneon
ceneon / model.rb
Last active August 29, 2015 14:23
Apply watermark over image using Paperclip
has_attached_file :file,
styles: {
detail: {
geometry: "__width__x__height__#",
watermark_path: Rails.root.join("app/assets/images/__watermark_image__.png"),
position: 'Center' # SouthEast, NorthWest, etc
}
}, processors: [:watermark]
@ceneon
ceneon / app.rb
Created December 17, 2014 14:33
Código fuente de la app Sinatra usada en la charla "Introducción a Ruby, Rails, y un poco de Sinatra" /// copiar index.html.erb en un subdirectorio 'views'
#encoding: utf-8
require 'sinatra'
require 'twitter'
require 'flickraw'
require 'yaml' #for debugging purposes
FlickRaw.api_key = ""
FlickRaw.shared_secret = ""
client = Twitter::REST::Client.new do |config|
@ceneon
ceneon / gist:ccd6b8e099d69863bbea
Last active August 29, 2015 14:08
RubyConf Argentina 2014 - Lightning talks
1) Lambdas vs. Closures
@lucas_giudice
2) Algo
@tonchis_
3) Jump to Code
@KevinJHanna
4) Apprenticeship"
@ceneon
ceneon / gist:8222574
Created January 2, 2014 17:13
Recategorización de Monotributo sin Internet Explorer
Para recategorizarte en el Monotributo, la aplicación de AFIP da error de Javascript por todos lados.
A menos que entres con Internet Explorer...
Para hacer el trámite en Chrome, Firefox o cualquier browser decente:
- Entrá con tu clave fiscal
- Abrí la aplicación de "Monotributo"
- Ignorá el formulario y abrí la siguiente URL:
https://servicios1.afip.gov.ar/tramites_con_clave_fiscal/monotributo/valida_cuit.asp?tramite=3&cuit=___TU_CUIT___&intesoc=N&eventual=N&coop=N&cuitcoop=0
@ceneon
ceneon / gist:7401982
Created November 10, 2013 18:35
Get pictures from Flickr into an Apple TV
#! /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
require 'flickraw'
require 'airplay'
FlickRaw.api_key = 'API_KEY'
FlickRaw.shared_secret = 'API_SECRET'
atv = Airplay.devices.first
results = flickr.photos.search(:tags => ARGV[0])
for x in 1..results.length do
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
@ceneon
ceneon / gist:1241313
Created September 25, 2011 23:24
Facebook: Hide annoying right column
javascript: document.getElementById("rightCol").style.display="none"; document.getElementById("contentArea").style.width="755px"; return false;
/*
#rightCol -> hide();
#contentArea -> width:755px
*/
@ceneon
ceneon / mysqldump.rb
Created July 18, 2011 18:51
Class that generates a Mysqldump of the current Rails database
# USAGE:
#require RAILS_ROOT + "/lib/" + "mysqldump.rb"
#dump = Mysqldump.full_backup
#response.headers['Content-Type'] = 'text/plain'
#response.headers['Content-Disposition'] = 'attachment; filename=DATABASE_' + Date.today.to_s + '.bak'
#render :text => dump
class Mysqldump
@ceneon
ceneon / gist:1081999
Created July 14, 2011 05:44
Fix Gmail "Preview" Theme with "Chat in Right Column" Lab.
// Styles needed to fix layout
.pp{ margin-left: 0px !important; margin-right:0px !important;}
.q0CeU{ margin-right:0px !important}
// Execute this in the inspector window or the address bar, or bookmark it if you can
javascript:i=document.getElementById("canvas_frame").contentWindow.document;j=i.getElementsByClassName("T0 pp");for(k=0;k<j.length;k++)if(j.item(k).getElementsByClassName("pw").item(0).innerHTML=="Chat")j.item(k).style.margin='0';i.getElementsByClassName("nH q0CeU z").item(0).style.marginRight='0';void 0
@ceneon
ceneon / Rails test
Created February 25, 2011 15:46
A complex ActiveRecord find through a lot of models.. I think there must be a better way to do it
@operadores = User.find(:all, :conditions =>
{ :id =>
EventoTrabajosUser.find(:all, :conditions =>
{ :evento_trabajo_id =>
EventoTrabajo.find(:all, :conditions =>
{ :evento_id => @planificacion.eventos.collect{ |b| b.id } }
).collect { |c| c.id }
}).collect { |d| d.user_id }
})