Skip to content

Instantly share code, notes, and snippets.

@sasha-id
sasha-id / README
Created March 23, 2012 02:45
MongoDB init script for a sharding node.
To install this init script, you should save mongodb to /etc/init.d/ and mongosharding.conf to /etc/
then run the following commands as root or with sudo:
chmod 755 /etc/init.d/mongodb
chown root:root /etc/init.d mongodb
update-rc.d mongodb defaults
This installation procedure was tested on UBUNTU 11.10
@sasha-id
sasha-id / README
Created March 23, 2012 15:03
MongoDB multiple instance upstart scripts: mongodb, mongod --configsvr and mongos
MongoDB upstart scripts for Ubuntu.
Run following commands after installing upstart scripts:
ln -s /lib/init/upstart-job /etc/init.d/mongoconf
ln -s /lib/init/upstart-job /etc/init.d/mongodb
ln -s /lib/init/upstart-job /etc/init.d/mongos
To start services use:
@sasha-id
sasha-id / delayed_job.conf
Created March 26, 2012 05:22
Upstart delayed_job script
# Copy:
# /etc/init/delayed_job.conf
# Execute:
# ln -s /lib/init/upstart-job /etc/init.d/delayed_job
# Change user name
description "Start up the delayed_job service"
start on runlevel [2345]
stop on runlevel [06]
@sasha-id
sasha-id / money_field.rb
Created July 18, 2012 22:08
Money represented with the Money gem, persistence using Mongoid 3
class MoneyField
def mongoize
return if object.nil?
cents
end
class << self
def demongoize(object)
return nil unless object
@sasha-id
sasha-id / gist:3307303
Created August 9, 2012 19:20
How to update multiple documents with a single command
db.test.update({foo: "bar"}, {$set: {test: "success!"}}, false, true);
@sasha-id
sasha-id / bluepill.conf
Created August 11, 2012 00:30
bluepill upstart script as non-privileged user
# bluepill - process monitor
#
# simple process monitoring tool
description "bluepill: simple process monitoring tool"
start on runlevel [2345]
stop on runlevel [!2345]
@sasha-id
sasha-id / bluepill
Created August 11, 2012 02:33
bluepill init.d script for non-privileged user
#!/bin/sh
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start: $local_fs $remote_fs $network $syslog $time
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: bluepill daemon, providing process monitoring
# Description: bluepill is a monitoring tool. More info at http://github.com/arya/bluepill.
@sasha-id
sasha-id / delayed_rake.rb
Last active December 15, 2015 20:59
Run rake task from delayed_job
##
# Stick an Object in the queue.
# Delayed::Job.enqueue(DelayedRake.new("util:mongrel_init:name"))
require 'rake'
require 'fileutils'
class DelayedRake
def initialize(task, options = {})
@sasha-id
sasha-id / gist:e2846bff5d2fb5abe171727532a9416b
Created January 7, 2019 15:16
Hot to find failing asset file on rake assets:precompile
JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
end
@sasha-id
sasha-id / ssl_puma.sh
Last active September 14, 2019 05:45 — forked from tadast/ssl_puma.sh
localhost SSL with puma
#
# Use just this:
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout server.key \
-new \