Skip to content

Instantly share code, notes, and snippets.

@rafaelrosafu
rafaelrosafu / .bashrc
Last active July 26, 2017 07:39
Customized bash prompt, with tweaks to git, ls, grep. Save it to ~/.bashrc, should run automatically on new Ubuntu versions, but you cannot have a .bash_profile in the home dir
#=====================================================
# Personal environment variables and startup programs
#=====================================================
# If not running interactively, don't do anything
# vagrant breaks without this
case $- in
*i*) ;;
*) return;;
esac
@rafaelrosafu
rafaelrosafu / gist:1325356
Created October 30, 2011 01:46
Migrating WP with latin symbols convertion
# Good reference
http://en.gentoo-wiki.com/wiki/Convert_latin1_to_UTF-8_in_MySQL
## On the original server on Dreamhost
# Backup the database, pay special attention to character set
mysqldump --user=grokpodcastcom -p --host=mysql.grokpodcast.com --default-character-set=latin1 -c --insert-ignore --skip-set-charset -r dump_grok.sql grokpodcast_com
# The sed replaces the WP instance prefix on the database and also it's name
sed -i 's/_5cweix_/_/' dump_grok.sql
sed -i 's/grokpodcast_com/bitnami_wordpress/' dump_grok.sql
# Put dump on S3 (easier than FTP)
@rafaelrosafu
rafaelrosafu / fabrication_devise.rb
Created December 23, 2011 01:27
How to fix problems using Devise, factories and Capybara + regular specs
# Avoid problems when running Capybara specs before regular ones, and fix the
# "Could not find a valid mapping for X". Part of the solution is to use the
# Devise test helpers as explained on link A, but then you need to clear the
# fabricated objects, as explained on link B. Here's the equivalent code when
# using the Fabrication gem
#
# A - http://stackoverflow.com/questions/4230152/mocks-arent-working-with-rspec-and-devise
# B - http://stackoverflow.com/questions/6363471/could-not-find-a-valid-mapping-for-user-only-on-second-and-successive-t
if Rails.env.development? || Rails.env.test?
ActionDispatch::Callbacks.after do
@rafaelrosafu
rafaelrosafu / Vagrantfile
Last active December 14, 2015 04:49
Vagrant config template
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
# precise-cloudimage is an official Ubuntu image at http://cloud-images.ubuntu.com/vagrant/
@rafaelrosafu
rafaelrosafu / gist:5384508
Last active December 16, 2015 05:29
Installing jasmine headless on Ubuntu 12.04
sudo apt-get install libqt4-dev libicu48 xvfb
On Gemfile:
gem 'jasmine-headless-webkit'
On .gitignore:
.jhw-cache/
bundle install --path=vendor --binstubs
@rafaelrosafu
rafaelrosafu / canada.md
Last active November 16, 2018 13:21
Imigrando e vivendo no Canadá - um guia nada imparcial
@rafaelrosafu
rafaelrosafu / instructions.md
Last active December 17, 2015 19:09
Compile and Install Heka on Centos 6.4

More info on http://hekad.readthedocs.org/en/latest/installing.html

Build and test hekad

yum install git gcc patch python-devel
rpm -ihv http://pkgs.repoforge.org/cmake/cmake-2.8.8-1.el6.rfx.x86_64.rpm

git clone git@github.com:mozilla-services/heka-build.git
cd heka-build
@rafaelrosafu
rafaelrosafu / install.sh
Created June 26, 2013 05:52
Setup sshd on a docker image. You can't run daemons inside docker https://github.com/dotcloud/docker/issues/446#issuecomment-16710461, or at least not manually, looks like lxc-execute can do the trick http://lxc.sourceforge.net/man/lxc-execute.html
apt-get install openssh-server
mkdir /var/run/sshd
sed -i 's/#AuthorizedKeysFile/AuthorizedKeysFile/' /etc/ssh/sshd_config
# run as foreground process
/usr/sbin/sshd -D
@rafaelrosafu
rafaelrosafu / node_setup.sh
Last active December 21, 2015 04:49
Node install for #hackmtl
# Create a new, non-root user
adduser node
echo "node ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
su - node
# Install git
sudo yum install git
# Install node.js through nave
cd ~