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 hexlify(msg) | |
msg.split("").collect { |c| c[0].to_s(16) }.join | |
end | |
def unhexlify(msg) | |
msg.scan(/../).collect { |c| c.to_i(16).chr }.join | |
end | |
puts hexlify("Hello World") |
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
xml.instruct! | |
xml.playlist :version => "1.0", :xmlns => "http://xspf.org/ns/0/" do | |
xml.trackList do | |
@tracks.each do |track| | |
xml.track do | |
xml.location track.title | |
xml.creator "#{track.user.firstname} #{track.user.lastname}" | |
xml.album track.album | |
xml.title track.title | |
xml.location track.song.url |
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
require 'rubygems' | |
require 'sinatra/base' | |
class AppNumberOne < Sinatra::Base | |
get '/?' do | |
"You've found App1. Go to /app2/ to find App2!" | |
end | |
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
require 'resolv' | |
require 'rubygems' | |
require 'sequel' | |
def validate_email_domain(email) | |
domain = email.match(/\@(.+)/)[1] | |
Resolv::DNS.open do |dns| | |
@mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) | |
end | |
@mx.size > 0 ? true : false | |
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
require 'rubygems' | |
require 'fastercsv' | |
FasterCSV.open("email_final.csv", "w") do |csv| | |
FasterCSV.foreach("validated.csv") do |row| | |
csv << [row[0], "#{row[1]} #{row[2]}"] | |
end | |
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
#user nobody; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; |
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
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 MyApplication < Sinatra::Base | |
use Rack::Session::Cookie | |
use Warden::Manager do |manager| | |
manager.default_strategies :password | |
manager.failure_app = MyApplication | |
end | |
Warden::Manager.serialize_into_session{ |user| user.id } |
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
require 'formula' | |
class Libtool <Formula | |
url 'http://ftp.gnu.org/gnu/libtool/libtool-2.2.8.tar.gz' | |
homepage 'http://www.gnu.org/software/libtool/' | |
md5 'cad2a7188242bc8dbab0645532ae3d6f' | |
def install | |
system "./configure", "--disable-debug", "--disable-dependency-tracking", | |
"--prefix=#{prefix}" |
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
tab "database server" do | |
run "mongod --config /usr/local/Cellar/mongodb/*/mongod.conf" | |
end | |
tab "redis" do | |
run "redis-server" | |
end | |
tab "resque" do | |
run "QUEUE=* bundle exec rake resque:work" |
OlderNewer