Skip to content

Instantly share code, notes, and snippets.

View v1nc3ntlaw's full-sized avatar

Vincent Lin (Sheng-Je Lin) v1nc3ntlaw

View GitHub Profile
@geemus
geemus / 0_rackspace.rb
Created December 6, 2010 07:46
fog or: How I Learned to Stop Worrying and Love the Cloud (examples)
server_data = compute.create_server(
1,
49
).body['server']
until compute.get_server_details(
server_data['id']
).body['server']['status'] == 'ACTIVE'
end
@zoras
zoras / rmagick.sh
Created August 2, 2011 17:14
Install RMagick on Ubuntu 11.04
sudo apt-get install libdjvulibre-dev libjpeg-dev libtiff-dev libwmf-dev libmagickcore-dev libmagickwand-dev libmagick++-dev rvm
sudo gem install rmagick
ok!
Fetching: rmagick-2.13.1.gem (100%) Building native extensions. This could take a while ... Successfully installed rmagick-2.13.1 1 gem installed
require 'RMagick' #=> true
AWS_ACCESS_KEY_ID="YOURAWSACCESSKEYID"
AWS_SECRET_KEY="YOURAWSSECRETKEY"
EC2_REGION=$(wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
EC2_INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
EC2_CLOUDWATCH_NAMESPACE='WebService'
NGINX_CONNECTIONS=$(wget -q -O - http://127.0.0.1/nginx_status | grep 'connections' | awk '{print $3}')
/usr/bin/mon-put-data --region \"$EC2_REGION\" --metric-name HttpConnections --namespace \"$EC2_CLOUDWATCH_NAMESPACE\" --dimensions \"InstanceId=$EC2_INSTANCE_ID\" --value \"$NGINX_CONNECTIONS\" -I \"$AWS_ACCESS_KEY_ID\" -S \"$AWS_SECRET_KEY\"
@thomaswitt
thomaswitt / deploy_to_opsworks.rake
Last active April 25, 2016 02:59
Deploy to opsworks via rake
# Put this into lib/tasks
require 'rubygems'
require 'bundler'
require 'aws-sdk'
require 'socket'
require 'os'
if Rails.env.development?
@matschaffer
matschaffer / create_data_bag.rb
Created June 8, 2012 15:30
Creating local encrypted data bags
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('data_bag_key')
data = {"id" => "mysql", "root" => "some secret password"}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('data_bags/passwords')
File.open('data_bags/passwords/mysql.json', 'w') do |f|
f.print encrypted_data.to_json
@ericgibb
ericgibb / brew_setup.sh
Created May 1, 2012 19:21
Installs Brew, Ruby, MySql, and other helpful utilities
# if ask "Do you want to do something?"; then
# echo "Yes"
# else
# echo "No"
# fi
#
# # Default to No if the user presses enter without giving an answer:
# if ask "Do you want to do something?" N; then
# echo "Yes"
# else
@kakipo
kakipo / webapp.conf
Last active July 9, 2017 13:46
Force Redirect HTTP to HTTPS on nginx behind ELB
# redirect http to https
set $redirect "";
if ($http_x_forwarded_proto != 'https') {
set $redirect "1";
}
if ($http_user_agent !~* ELB-HealthChecker) {
set $redirect "${redirect}1";
}
if ($http_host ~ "your-nifty-domain.com") {
set $redirect "${redirect}1";
@wizardishungry
wizardishungry / Gemfile
Last active February 12, 2018 18:49
Vagrant snippet to set VirtualBox guest CPU count to the number of host cores on Linux or OS X (broken 2018)
gem 'concurrent'
@aaronjensen
aaronjensen / edit_data_bag.rb
Created November 21, 2012 04:39
Edit encrypted data bags for use with chef-solo and knife-solo
#!/usr/bin/env ruby
Dir.chdir File.join(__FILE__, "../..")
unless ENV['EDITOR']
puts "No EDITOR found. Try:"
puts "export EDITOR=vim"
exit 1
end
unless ARGV.count == 2
@karmi
karmi / workers.rake
Created July 22, 2010 15:58
Rake taks to launch multiple Resque workers in development/production with simple management included
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.