Skip to content

Instantly share code, notes, and snippets.

View iboard's full-sized avatar
🏠
Crafting beautiful code at home

Andreas Altendorfer iboard

🏠
Crafting beautiful code at home
View GitHub Profile
@iboard
iboard / restart_rails_app_and_jobs_worker.thor
Created December 15, 2010 01:33
Restart your passanger-Rails app and delayed_job-workers
#
# Description at http://r3.iboard.cc/postings/30
#
class Application < Thor
desc "restart [--worker_only]", "kill 'rake jobs:work' and 'touch tmp/restart.txt'"
method_options :worker_only => :boolean
def restart
kill_pid("ps x|grep 'rake jobs:work'|grep -v grep")
unless options[:worker_only]
@iboard
iboard / workaround_mongo_associations.rb
Created February 12, 2011 10:55
Workaround for mongo-id-associations
class Author
include Mongoid::Document
include Mongoid::Timestamps
...
references_and_referenced_in_many :institutes
after_save :update_institutes #WORKAROUND
...
private
...
@iboard
iboard / user.rb
Created February 24, 2011 08:07
Usage of CBA, DelayedJob
# Referenced in: http://cba.iboard.cc/p/readme
class User
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paperclip
.....
# Notifications
after_create :async_notify_on_creation
before_destroy :async_notify_on_cancellation
@iboard
iboard / default_scope.rb
Created June 24, 2011 10:03
default_scope doesn't work on debian
# MODEL
class Page
include Mongoid::Document
include Mongoid::Timestamps
include CoverPicture
#....
field :is_template, :type => Boolean, :default => false
default_scope where(is_template: false )
@iboard
iboard / mongo.conf.sample.markdown
Created July 2, 2011 06:38
MongoDB 1.8 ReplicaSet Config

This is a sample config I use for CBA on two debian boxes

  • edge.iboard.cc is the "master" where the app is running
  • s1.iboard.cc is the "slave" where mongo is running as a kind of backup

On edge.iboard.cc

/etc/mongodb/mongodb.conf

@iboard
iboard / org.mongodb.mongod.plist
Created July 15, 2011 08:07
Mac OS X LaunchDaemon for mongodb
<!-
save this in /Library/LaunchDaemons/org.mongodb.mongod.plist
use with: lauchctl load org.mongodb.mongod
->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
@iboard
iboard / iterate_div.coffee
Created August 3, 2011 08:54
iterate divs in coffescript
cnt_tabs = $(".side-tab").length
for idx in [0..(cnt_tabs-1)]
tab = $(".side-tab:nth-child(#{idx})")
unless tab.attr('id') == "side-tab-#{except.attr('id')}"
tab.hide()
@iboard
iboard / locales.rake
Created February 27, 2012 08:44
Rake-Task to find undefined locale-keys in a rails project
# -*- encoding : utf-8 -*-
namespace :locales do
desc "Find undefined locales"
task :undefined_locales => :environment do
used_strings = []
Dir['**/*'].each do |file|
if File::ftype(file) == "file"
begin
@iboard
iboard / migrations.rake
Last active January 20, 2019 08:04
obsolete: Rake-task to initialize localized fields with MongoId
#
# I had a model where the fields banner_title and banner_text was simple text-fields
# Then I added :localized => true to this fields and all specs pass because specs use new data.
# On my production-server the app crashed because of "nil-fields".
#
# I figured out how to solve this by initializing the _translations for existing records.
# Feel free to use my example in your production-environment - but, sure, without any warranty.
#
# [email protected], August 8, 2012
#
@iboard
iboard / install_ruby2_with_rvm.sh
Last active January 20, 2019 08:04
obsolete - install ruby2
# How I managed to install #ruby-2.0 with #rvm on #MacOS 10.8
export CC=/usr/bin/gcc
rvm pkg install openssl
rvm install ruby-head --with-gcc=clang --verify-downloads 1 # see *
rvm use ruby-head
ruby -v
ruby 2.0.0dev (2013-02-24) [x86_64-darwin12.2.0]