Skip to content

Instantly share code, notes, and snippets.

@oelbrenner
oelbrenner / Bohemian.Rhapsody.js
Created August 16, 2019 20:03 — forked from designbyadrian/Bohemian.Rhapsody.js
The well known tune transcribed into JavaScript, based on an image I found on the Internet. Please link me the source and author if you have it.
/**
* @author Freddie Mercury
* @copyright Sony/ATV Music Publishing LLC
*/
let BohemianRhapsody = function(){
// Is this the real life?
// Is this just fantasy?
try {
@oelbrenner
oelbrenner / mongiod_mysql_migrator.rb
Created July 11, 2018 14:53 — forked from tomriley/mongiod_mysql_migrator.rb
Migrate a Mongoid / MongoDB database to an ActiveRecord based SQL one. One method to convert the schema, another to migrate data. Copes with most basic data types. Some hacks to infer TEXT columns. Converts embeds_one relationships to AR aggregations. I wrote this for a one-time migration. It could be a good starting point for someone doing the …
# Migrate schema and data from Mongoid to MySQL ActiveRecord
class MongoidMysqlMigrator
def randomize_auto_increment_values(source_models, from=5500, to=10500)
source_models.each do |model|
value = rand(from-to)+from
sql = %(ALTER TABLE #{model.name.tableize} AUTO_INCREMENT=#{value})
puts sql
ActiveRecord::Base.connection.execute(sql)
end
Methionylthreonylthreonylglutaminylarginyltyrosylglutamylserylleucylphenylalanylalanylglutaminylleuc yllysylglutamylarginyllysylglutamylglycylalanylphenylalanylvalylprolylphenylalanylvalylthreonylleucylgl ycylaspartylprolylglycylisoleucylglutamylglutaminylserylleucyllysylisoleucylaspartylthreonylleucylisoleu cylglutamylalanylglycylalanylaspartylalanylleucylglutamylleucylglycylisoleucylprolylphenylalanylseryla spartylprolylleucylalanylaspartylglycylprolylthreonylisoleucylglutaminylasparaginylalanylthreonylleucyl arginylalanylphenylalanylalanylalanylglycylvalylthreonylprolylalanylglutaminylcysteinylphenylalanylglu tamylmethionylleucylalanylleucylisoleucylarginylglutaminyllysylhistidylprolylthreonylisoleucylprolylisol eucylglycylleucylleucylmethionyltyrosylalanylasparaginylleucylvalylphenylalanylasparaginyllysylglycyli soleucylaspartylglutamylphenylalanyltyrosylalanylglutaminylcysteinylglutamyllysylvalylglycylvalylaspa rtylserylvalylleucylvalylalanylaspartylvalylprolylvalylglutaminylglutamylserylalanylprolylphen
#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'
require 'json'
require 'faraday'
# things you must configure
PATH_TO_DROPBOX = "/Users/your_name/Dropbox/backup/tweets/" # you need to create this folder
TWITTER_USER = "your_twitter_username"
@oelbrenner
oelbrenner / delayed_jobs_controller.rb
Created October 24, 2012 12:27 — forked from dblock/delayed_jobs_controller.rb
Delayed job view and controller
class Admin::DelayedJobsController < AdminController
# GET /admin/delayed_jobs
def index
@delayed_jobs = Delayed::Backend::Mongoid::Job.desc(:created_at)
.paginate :page => params[:page], :per_page => 20
end
end
# system-specific logs may be also be configured here.
/home/*/logs/*_log /home/*/domains/*/logs/*_log {
rotate 5
weekly
compress
postrotate
cp /dev/null /path/to/where/the/apache/log/file/lives
cp /dev/null /path/to/where/the/other/files/is
cp /dev/null /path/to/where/the/other/files/is/etc/etc
endscript
@oelbrenner
oelbrenner / ebs_snapshot.rb
Created July 18, 2012 19:27
Snapshot and manage AWS EBS volumes
require 'fog'
puts "Starting.."
today = Time.now.strftime("%Y%m%d")
puts "Today is #{today}"
@fog = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => 'YOUR_ACCESS_KEY', :aws_secret_access_key => 'YOUR_SEKRET_ACCESS_KEY')
volumes = @fog.volumes.all
volumes.each do |vol|
@oelbrenner
oelbrenner / delayed_job.sh
Created July 5, 2012 17:25
delayed_job wrapper script for use with monit
#!/usr/bin/env bash
if [ $# -lt 1 ] ; then
echo "Usage: " $0 " <start | stop> "
exit 1
fi
action=$1
rails_root=`pwd`
logfile=$rails_root/log/monit_delayed_job.log
class Date
def to_words
if self == Date.today
"Today"
elsif self <= Date.today - 1
if self == Date.today - 1
"Yesterday"
elsif ((Date.today - 7)..(Date.today - 1)).include?(self)
"Last #{self.strftime("%A")}"
elsif ((Date.today - 14)..(Date.today - 8)).include?(self)