Skip to content

Instantly share code, notes, and snippets.

@jrom
jrom / download-from-s3.rb
Created November 2, 2010 12:02
For downloading assets (in this case Paperclip attachments) from S3 to local filesystem
require 'aws/s3'
AWS::S3::Base.establish_connection!(
:access_key_id => 'id',
:secret_access_key => 'secret'
)
missing_uploads = [1,2,3,4] # ID's from the attachments you want to download
log = File.open('file-import-log.txt','w')
@jrom
jrom / config.ru
Created October 27, 2010 00:02
Rack app that demonstrates Herkou limitation in header size
run lambda { |env|
headers = { "key"=> ("a" * 3455)} # 3454 works, 3455 don't
[200, headers, "Hello World!\n"]
}
@jrom
jrom / devise.ca.yml
Created October 4, 2010 20:58 — forked from codegram/devise.ca.yml
Catalan translation for Devise
ca:
errors:
messages:
not_found: "no s'ha trobat"
already_confirmed: "ja està confirmat"
not_locked: "no està bloquejat"
not_saved:
one: "1 error ha evitat que %{resource} es pugui desar:"
other: "%{count} errors han evitat que %{resource} es pugui desar:"
require 'csv'
CSV.open("#{Rails.root}/../consumers.csv", "w") do |csv|
["Last login","Registration date","Organizations", "Projects count", "Organizations Plan", "name", "time_zone", "Language", "Email", "Phones", "Address"]
User.find_each(:include => [{:card => [:addresses, :phone_numbers]}, :organizations]) do |user|
print '.'
phones = []
if user.card
phones << user.card.phone_numbers.map(&:name).join(";") if user.card.phone_numbers
first_address = user.card.addresses.first
end
select first_name, last_name, email, locale, time_zone from users INTO OUTFILE '~/contacts.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
require 'rubygems'
require 'wx'
class MyFrame < Wx::Frame
def initialize
super(nil, :title => "Thread example")
set_menu_bar menubar
timer = Wx::Timer.new(self, Wx::ID_ANY)
#!/bin/sh
# this file is a git post-update hook
# the file must be named post-update and be executable (chmod +x post-update)
# it must be in the .git/hooks directory
RAILS_ENV=production /path/to/retrospectiva/script/repository_syncer
echo "Retrospectiva was notified :-)"
--- courier-0.47/maildrop/main.C.orig 2004-11-22 12:23:09.000000000 +0100
+++ courier-0.47/maildrop/main.C 2004-11-22 12:23:19.000000000 +0100
@@ -718,38 +718,6 @@
++i;
}
-#if HAVE_COURIER
- if (deliverymode && orig_uid == getuid())
- {
- const char *p;
@jrom
jrom / typus_demo.rb
Created November 30, 2009 17:16
Typus template
##
# $ rails example.com -m http://tr.im/typus_example
##
# Install Typus and friends.
plugin 'typus', :git => 'git://github.com/fesplugas/typus.git'
plugin 'acts_as_list', :git => 'git://github.com/rails/acts_as_list.git'
plugin 'acts_as_tree', :git => 'git://github.com/rails/acts_as_tree.git'
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
#include <stdio.h>
#include "stdlib.h"
#include "string.h"
#include "sys/time.h"
#define SIZE (128*2048)
unsigned long long A[SIZE];
unsigned long long B[SIZE];
unsigned long long C[SIZE];
unsigned long long D[SIZE];