Skip to content

Instantly share code, notes, and snippets.

View rtacconi's full-sized avatar

Riccardo Tacconi rtacconi

View GitHub Profile
@rtacconi
rtacconi / password
Created November 13, 2011 17:59
How to change a user password as root with expect
#!/usr/bin/expect
spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof
@rtacconi
rtacconi / change_password_one_line
Created November 13, 2011 18:14
Change password one line
echo -e "linuxpassword\nlinuxpassword" | passwd linuxuser
@rtacconi
rtacconi / random_utils.rb
Created November 14, 2011 10:42
random_data gem was failing to generate unique emails (after ~ 7000 loops), so I decided to add a random number. It passed the test even with 1M loops!
require 'rubygems'
require 'random_data'
require 'spec'
describe "random data" do
it "should be unique" do
prev = RandomUtils.random_email
(1..100000).each do |n|
email = RandomUtils.random_email
@rtacconi
rtacconi / show_distro_version.sh
Created November 21, 2011 11:36
Show distro name and version
cat /etc/issue
@rtacconi
rtacconi / install_rvm_ubuntu.sh
Created November 29, 2011 14:29
Instal RVM on Ubuntu server (10.04) - system wide
#!/bin/bash
apt-get update
apt-get -y install curl git-core
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
apt-get -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
source /root/.bashrc
rvm install 1.9.3
rvm use 1.9.3 --default
@rtacconi
rtacconi / percona_ubuntu_10.04.sh
Created December 7, 2011 22:32
Install Percona Server, Apache and Passenger on Ubuntu 10.04
#!/bin/bash
gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
gpg -a --export CD2EFD2A | sudo apt-key add -
echo 'deb http://repo.percona.com/apt lucid main' >> /etc/apt/sources.list
echo 'deb-src http://repo.percona.com/apt lucid main' >> /etc/apt/sources.list
apt-get update
apt-get -y install percona-server-server-5.5
apt-get install -y apache2-prefork-dev libapr1-dev apache2
apt-get install -y libcurl4-openssl-dev
@rtacconi
rtacconi / Gemfile
Created February 15, 2012 15:15
Basic Gemfile to use datamapper with Rails 3.1
source 'http://rubygems.org'
RAILS_VERSION = '3.2.1'
gem 'actionpack', RAILS_VERSION
gem 'activesupport', RAILS_VERSION
gem 'railties', RAILS_VERSION
gem 'rails', RAILS_VERSION # Unfortunately, needed for `heroku run console`
# For attributes in non-dm models (will be a dependency of future DM versions)
@rtacconi
rtacconi / rails_mongo.sh
Created March 12, 2012 17:33
Rails app with mongoid devise haml
rails new webdb -m http://railswizard.org/77171980b8637239194c.rb -J -O -T
@rtacconi
rtacconi / chef_solo_bootstrap.sh
Created April 19, 2012 12:37 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install
@rtacconi
rtacconi / bootstrap_chef.sh
Created May 10, 2012 11:06
install ubuntu 10.04 packages to install ruby and chef
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev git-core
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install