Skip to content

Instantly share code, notes, and snippets.

View DevL's full-sized avatar

Lennart Fridén DevL

View GitHub Profile
@DevL
DevL / generate_sequel_migration.rake
Created December 14, 2012 14:48
Generate a timestamped, empty Sequel migration in the 'migrations' directory.
namespace :generate do
desc 'Generate a timestamped, empty Sequel migration.'
task :migration, :name do |_, args|
if args[:name].nil?
puts 'You must specify a migration name (e.g. rake generate:migration[create_events])!'
exit false
end
content = "Sequel.migration do\n up do\n \n end\n\n down do\n \n end\nend\n"
timestamp = Time.now.to_i
@DevL
DevL / heroku_redis_cli.rake
Created December 12, 2012 12:59
Rake task for connecting to Redis on Heroku. Replace OPENREDIS_URL with whatever environment variable contains Redis connection string.
desc 'Connect to Redis (production)'
task :redis do
redis_uri = `heroku config:get OPENREDIS_URL`
pattern = /redis:\/\/:(\S+)@(\S+):(\d+)/
redis_uri[pattern]
command = "redis-cli -a #{$1} -h #{$2} -p #{$3}"
exec command
end
@DevL
DevL / sequel_migrations.rake
Created December 12, 2012 10:11
Sequel migration rake tasks based on https://gist.github.com/1409152
namespace :db do
require 'sequel'
namespace :migrate do
Sequel.extension :migration
task :connect do
if ENV['DATABASE_URL']
DB = Sequel.connect(ENV['DATABASE_URL'])
else
puts 'ABORTING: You must set the DATABASE_URL environment variable!'
@DevL
DevL / listjs_int_char_test.html
Created December 9, 2011 23:10
list.js international character test
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>list.js international characters test</title>
<script type="text/javascript" src="list.min.js"></script>
</head>
<body>