Skip to content

Instantly share code, notes, and snippets.

View zapnap's full-sized avatar
🐐

nap zapnap

🐐
View GitHub Profile
@zapnap
zapnap / postfix-config-aws-ses.txt
Created September 29, 2011 23:06
postfix config for AWS-SES
# /etc/postfix/main.cf
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
@zapnap
zapnap / resque_worker.rb
Created September 28, 2011 15:53
Resque worker start script (started by monit)
#!/usr/bin/env ruby
ENV['RAILS_ENV'] ||= 'production'
require File.expand_path('../../config/boot', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
class ResqueWorkerDaemon < DaemonSpawn::Base
def start(args)
@worker = Resque::Worker.new('*') # Specify which queues this worker will process
@worker.verbose = 1 # Logging - can also set vverbose for 'very verbose'
@zapnap
zapnap / short_round.rb
Created September 8, 2011 19:32
HANG ON LADY WE GOING FOR A RIDE
class ShortRound
URL_CHARS = ('0'..'9').to_a + %w(b c d f g h j k l m n p q r s t v w x y z) + %w(B C D F G H J K L M N P Q R S T V W X Y Z - _)
URL_BASE = URL_CHARS.size
# Hang on lady, we going for a ride!
def self.generate(id)
local_count = id
result = ''
while local_count != 0
rem = local_count % URL_BASE
Dear Sir or Madam,
A few hours ago the Bitcoin trading website Mt Gox has been hacked. Malicious individuals have been able to obtain a database containing usernames, email address and encrypted passwords. This information has been posted publicly on the internet.
As a Bitcoin supporter I'm now sending a message to every email address contained in the hacked database. This is to warn you that your username, email address and password have been leaked. I therefore strongly advice you to change your passwords. If you have used the same password on different websites it's highly recommended to change your password on all of your accounts!
For a more secure alternative to Mt Gox, the community appears to be moving to TradeHill. So this is no reason to lose faith in Bitcoin itself. It must be seen as a warning that not every website can be trusted with your data however! Their link is http://www.tradehill.com/?r=TH-R15683 (Note: You can remove the Referral Code when registering if you want!) This is certainly
@zapnap
zapnap / ec2-rubber-aws-ses-email.txt
Created March 5, 2011 17:17
Add Amazon SES support to Rubber / EC2 config
# ------------------------
# add the following packages to rubber.yml:
# ------------------------
packages: [postfix, libio-socket-ssl-perl, libxml-libxml-perl, unzip]
# ------------------------
# add to config/rubber/custom-setup.rb:
# ------------------------
@zapnap
zapnap / iam_fog.rb
Created March 2, 2011 20:24
Using Amazon IAM with Fog (example)
require 'fog'
username = 'testuser'
bucket = 'uniquebucketname1234'
aws_credentials = {
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY'
}
@zapnap
zapnap / ListActivityWithDb4o.java
Created December 12, 2010 00:48
Android ListActivity example using db4o
package org.example.events;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import com.db4o.Db4oEmbedded;
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
<script type="text/javascript">
var rumbleUrl = 'http://railsrumble.com';
</script>
<script type="text/javascript" src="http://blog.railsrumble.com/javascripts/rumble-r10-sash.js"></script>
class ShortRound
URL_CHARS = ('0'..'9').to_a + %w(b c d f g h j k l m n p q r s t v w x y z) + %w(B C D F G H J K L M N P Q R S T V W X Y Z - _)
URL_BASE = URL_CHARS.size
# Hang on lady, we going for a ride!
def self.generate(id)
local_count = id
result = ''
while local_count != 0
rem = local_count % URL_BASE
>> Project.count(:fields => [:owner, :name], :status => 'created', :unique => true)
=> 11011
>> Project.all(:fields => [:owner, :name], :status => 'created', :unique => true).length
=> 2198