Ctrl+KB | toggle side bar |
Ctrl+Shift+P | command palette |
Ctrl+` | python console |
Ctrl+N | new file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# usage | |
# rvm_env_wrapper /path/to/project some_ruby_file.rb | |
# rvm_env_wrapper /path/to/project some_comand arg1 arg2 arg3 etc | |
# OR | |
# rvm_env_wrapper --use ruby_version@gemset_name some_comand_or_file | |
# Permissions: | |
# sudo chown user:group rvm_env_wrapper | |
# sudo chmod 774 rvm_env_wrapper | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# the first argument should be a path to pid file | |
if [[ -f "$1" ]] ; then | |
if [ $(ps -p $(cat $1) | wc -l) -gt 1 ] ; then | |
# process exists - do nothing | |
#echo "OK" | |
exit 0 | |
else | |
#echo "will do rm $1" | |
rm $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo add-apt-repository ppa:pitti/postgresql | |
sudo apt-get update | |
# stop apache server if you need | |
# sudo /etc/init.d/apache2 stop | |
sudo -i -u postgres | |
pg_dumpall > dumpall_$(date +"%Y%m%d").pgdump | |
exit | |
sudo mv /var/lib/postgresql/dumpall_$(date +"%Y%m%d").pgdump ~/ | |
sudo cp -r /etc/postgresql/8.4 /etc/postgresql/old | |
sudo apt-get install postgresql-9.1 -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Finds bloating passengers and try to kill them gracefully. | |
# @example: | |
# PassengerMonitor.run | |
require 'logger' | |
class PassengerMonitor | |
# How much memory (MB) single Passenger instance can use | |
DEFAULT_MEMORY_LIMIT = 450 | |
# Log file name | |
DEFAULT_LOG_FILE = 'passenger_monitoring.log' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'passenger_monitor')) | |
# Set logger to log into Rails project /log directory and start monitoring | |
PassengerMonitor.run( | |
:log_file => File.join(File.dirname(__FILE__), '..', 'log', 'passenger_monitor.log'), | |
:memory_limit => 400, # this is in MB | |
:wait_time => 10, # this in seconds (timeout before attempts) | |
:attempts => 5 # number of attempts | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FactoryGirl3ForYouAndMe | |
# The new syntax: http://robots.thoughtbot.com/post/19412394597/factory-girl-hits-3-0 | |
# | |
# Where to learn sed? | |
# http://www.grymoire.com/Unix/Sed.html#uh-6 | |
# http://www.markhneedham.com/blog/2011/01/11/sed-across-multiple-files/ | |
# | |
# What needs to change? | |
find . -type f -name "*.rb" -print0 | xargs -0 grep "Factory.create" | |
find . -type f -name "*.rb" -print0 | xargs -0 grep "Factory.build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CURRDATE=`date +%Y_%m_%d-%H_%M` | |
SERVERNAME="localhost" | |
BAK_FILE=/path/to/backups/$SERVERNAME-production-sql-$CURRDATE.sql.gz # change the PATH here | |
DB_HOST="localhost" | |
DB_NAME="DB_NAME_HERE" # Change this | |
function quit { | |
ERROR_CODE=$1 | |
ERROR_MSG=$2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# DBからデータを取り出してYAMLにする。生成したYAMLはtmp/fixturesに保存される | |
namespace :db do | |
namespace :fixtures do | |
desc "Extract database data to tmp/fixtures directory." | |
task :extract => :environment do | |
fixtures_dir = "#{Rails.root}/tmp/fixtures/" | |
skip_tables = ["schema_info", "schema_migrations", "sessions"] | |
ActiveRecord::Base.establish_connection | |
FileUtils.mkdir_p(fixtures_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/smtp' | |
FROM = 'Some name <name@email.me>' | |
TO = %w(name@email.me) | |
SUBJ = "DB backup #{Time.now.strftime('%Y-%m-%d')}" | |
# find the last (in 60 mins) backup | |
filename = `find /path/to/backups/*.sql.gz -mmin -60`.chomp | |
exit if filename.nil? || filename.empty? |
OlderNewer