Arley Lobato alobato

View monitrc
1 2 3 4 5 6 7 8 9 10
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file, a complete list of statements and
## options please have a look in the monit manual.
View webserver.sh
1 2 3 4 5 6 7 8 9 10
ssh root@ip
passwd
useradd -m -s /bin/bash deployer
echo "deployer:secret" | chpasswd
visudo
deployer ALL=(ALL) NOPASSWD: ALL
su deployer
cd
sudo apt-get update
sudo ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
View deploy.rb
1 2 3 4 5 6 7 8 9 10
require "bundler/capistrano"
 
# --------------------------------------------------
# nginx
namespace :nginx do
%w[start stop restart].each do |command|
desc "#{command} nginx"
task "#{command}", roles: :web do
sudo "service nginx #{command}"
end
View disk.rb
1 2 3 4
#!/usr/bin/env ruby
v = %x(df -h).split(/\n/)[1].split[4].gsub("%","")
`curl -s -u EMAIL:TOKEN -d 'gauges[0][name]=PREFIX_disk' -d 'gauges[0][value]=#{v}' -X POST https://metrics-api.librato.com/v1/metrics`
puts "#{Time.now.strftime('%Y-%m-%d %H:%M:%S')} DISK #{v}"
View nginx.conf
1 2 3 4 5 6 7 8 9
# use the socket we configured in our unicorn.rb
upstream unicorn_APPNAME {
server unix:/tmp/unicorn.APPNAME.sock fail_timeout=0;
}
 
server {
listen 80;
server_name DOMAIN;
rewrite ^/(.*) http://www.DOMAIN/$1 permanent;
View unicorn_conf.rb
1 2 3 4 5 6 7 8 9
# Configuration file for Unicorn
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
# See also http://unicorn.bogomips.org/examples/unicorn.conf.rb for
# a more verbose configuration using more features.
 
app_name = "appname"
root = "/home/deployer/apps/#{app_name}/current"
View etc_init.d_unicorn_example.co.uk
1 2 3 4 5 6 7 8 9 10
#! /bin/bash
 
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
View unicorn_init.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
View railscasts.rb
1 2 3 4 5 6 7 8 9 10
require 'rubygems'
require 'hpricot'
require 'open-uri'
 
doc = open('http://railscasts.com/') { |f| Hpricot(f) }
total_episodes = (doc/'div.number').first.inner_html[1,3].to_i
total_pages = (total_episodes / 10).ceil
 
(1..total_pages).each do |i|
puts "PAGE #{i} ================================"
View gist:5033956
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/ruby
require 'rss'
 
p 'Downloading rss index'
 
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
 
videos_filenames = videos_urls.map {|url| url.split('/').last }
Something went wrong with that request. Please try again.