Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# How to use
# my_script_name bd_user db_pass project_name(should be same name on database and project_directory)
# by Alfredo Ribeiro: [email protected]
# Create the daily backup, delete old backups, and each month, make a copy last backup on a separated directory
mysql_user=$1
mysql_pass=$2
project_name=$3
# First parameter is a bash printf formatting string
# From second till fifth parameter, rvm-prompt format parameters
__ruby_ps1 () {
if [ ! -f ./Rakefile ] &&
[ "$(find -maxdepth 1 -name '*.rb' | head -n1)" == "" ]; then
exit 1
fi
if [ -f ~/.rvm/bin/rvm-prompt ]; then
rst=$(~/.rvm/bin/rvm-prompt $2 $3 $4 $5)
fi
#!/usr/bin/env ruby
require 'rubygems'
require 'activesupport'
require 'chronic'
require 'optparse'
DAY_VALUE = 0 # regular value per day
WDAY_REGULAR = 1..5 # range for regular days 1..5 means from monday to friday
EXTRAS_VALUES = {
@aribeiro
aribeiro / default
Created February 29, 2012 12:53 — forked from mauricio/default
# as we’re going to use Unicorn as the application server
# we’re not going to use common sockets
# but Unix sockets for faster communication
upstream shop {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/shop.socket fail_timeout=0;
@aribeiro
aribeiro / default
Created February 29, 2012 12:53 — forked from mauricio/default
# as we’re going to use Unicorn as the application server
# we’re not going to use common sockets
# but Unix sockets for faster communication
upstream shop {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/shop.socket fail_timeout=0;
@aribeiro
aribeiro / Ubuntu rbenv
Created March 3, 2012 19:37
Installing Ruby 1.9.2 with OpenSSL on Ubuntu 11.04 using ruby-build and rbenv
# for more info: https://gist.github.com/1120938
require "rest-client"
begin
exists = RestClient.head("http://google.com").code == 200
rescue RestClient::Exception => error
exists = (error.http_code != 404)
end
puts "exists=#{exists}"
@aribeiro
aribeiro / ubuntu-install-ruby-1.8.7.sh
Created March 28, 2017 12:07 — forked from murphyslaw/ubuntu-install-ruby-1.8.7.sh
Install Ruby 1.8.7 with rbenv on Ubuntu
# Install system libraries.
sudo apt-get install zlib1g-dev openssl libssl-dev libreadline-dev git-core
# Install rbenv.
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# Setup bash.
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
@aribeiro
aribeiro / skipContactsDisplay.html
Last active May 3, 2017 17:05
Cloudsponge Widget Reference - The skipContactsDisplay option with beforeDisplayContacts callback
<!DOCTYPE html>
<html>
<head>
<!--·
Include the script anywhere on your page, usually in the head
@aribeiro
aribeiro / displayContactsColumns.html
Last active July 26, 2017 18:02
CloudSponge Widget Reference - Display Phone Column and filter contacts with phone number
<!DOCTYPE html>
<html>
<body>
<!--
Include the script anywhere on your page, usually in the head
(don't forget to replace YOUR_WIDGET_SCRIPT with your CloudSponge key)
-->
<script src="//api.cloudsponge.com/widget/localhost-only.js"></script>
<script>
cloudsponge.init({