Skip to content

Instantly share code, notes, and snippets.

View danmaispace's full-sized avatar
🎯
Focusing

Danmai danmaispace

🎯
Focusing
  • www.danmai.com.cn
  • Shenzhen,China
View GitHub Profile
@mheadd
mheadd / monitor.sh
Created May 13, 2013 20:00
Simple bash script to check whether MySQL is running.
#!/bin/bash
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
else
echo "All is well.";
fi
@shmatov
shmatov / deploy.rake
Created November 15, 2012 13:17
rails + mina + unicorn
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end
@mrichie
mrichie / gist:4043266
Created November 9, 2012 02:05 — forked from jfirebaugh/gist:4007524
Installing Ruby 2.0.0-preview1 with RVM on OS X
# First, make sure that you have the most recent rvm. Several bugs with 2.0.0-preview1
# have recently been fixed.
#
# Second, the openssl that comes with MacOS is too old for Ruby 2.0. You need to install
# a newer one with homebrew or the rvm pkg command.
# Option 1, with homebrew openssl:
brew update
brew install openssl
upstream myapp {
server unix:///myapp/tmp/puma.sock;
}
server {
listen 80;
server_name myapp.com;
# ~2 seconds is often enough for most folks to parse HTML/CSS and
# retrieve needed images/icons/frames, connections are cheap in
@kaievns
kaievns / gist:3158011
Created July 22, 2012 02:38
Paperclip mongoid support that works with mongoid 3
#
# Save this into your `lib/mongoid/paperclip.rb` file
#
#
require "paperclip"
module Paperclip
class << self
@joelmoss
joelmoss / gist:2470666
Created April 23, 2012 12:37
Capistrano recipe for Puma start/stop/restarts
set :shared_children, shared_children << 'tmp/sockets'
namespace :deploy do
desc "Start the application"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{stage} bundle exec puma -b 'unix://#{shared_path}/sockets/puma.sock' -S #{shared_path}/sockets/puma.state --control 'unix://#{shared_path}/sockets/pumactl.sock' >> #{shared_path}/log/puma-#{stage}.log 2>&1 &", :pty => false
end
desc "Stop the application"
task :stop, :roles => :app, :except => { :no_release => true } do
@ayamomiji
ayamomiji / deploy.rb
Created April 4, 2012 16:52
My capistrano + rainbows configure
# Check if remote file exists
def remote_file_exists?(full_path)
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
end
# Check if process is running
def remote_process_exists?(pid_file)
capture("ps -p $(cat #{pid_file}) ; true").strip.split("\n").size == 2
end
@dtolj
dtolj / gist:784634
Created January 18, 2011 16:02
Ruby MS access create database
#
#
#
#
#
require 'rubygems'
require 'win32ole'
require 'csv'
mdb_file="c:/dtolj/ruby_projects/phone.accdb"
@3dd13
3dd13 / 1_controller_test.rb
Created January 7, 2011 07:04
sharing on functional test refactoring with code block. cleaner and more readable.
test "not allow to update state after account reconciliation" do
# get fixture
account = accounts(:fresh)
# submit and expect no errors
post :waive_fee, :id => account.id
assert_nil flash[:error]
post :add_fee, :id => account.id
assert_nil flash[:error]