Skip to content

Instantly share code, notes, and snippets.

View lastk's full-sized avatar

Rafael Oliveira lastk

  • Salvador-Ba, Brazil
View GitHub Profile
#model
require 'csv'
class ContatoNews < ActiveRecord::Base
paginates_per 9
validates_format_of :email,
:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
:message => 'email must be valid'

Overview

We run multiple server processes in two data centers. Each process listens on two ports, one for HTTP and one for HTTPS. HTTPS is terminated by Apache prior to reaching node.js. HTTP goes directly from the client to node.js (through a master load balancer). We do not use clusters. We slice our physical servers into thin virtual machines running SmartOS, each with about 3GB of memory designed for a single node.js process.

Our node.js servers are hapi.js servers using the composer functionality and plugins architecture. We have three sets of plugins loaded: mobile web front end experience (single page app), legacy API reverse proxy, and monitoring.

We also serve original node.js services off another server zone which runs closed source plugins using hapi.

Analytics

@lastk
lastk / hook.rb
Last active August 29, 2015 14:13 — forked from dce/gist:44754
simple git commit hook
#!/usr/bin/ruby
require 'rubygems'
require 'git'
log = "~/gitlog.txt"
tmp = "/tmp/gitlog"
commit = Git.open('.').log.first
message = [
commit.date.strftime('%D'),
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<!-- topo -->
<div id="topo">
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
function pesquisarUsuario($usuarioTo, $numPagina=null, $qtdRegistros=null) {
$sql = '';
$select = 'SELECT CD_USUARIO, CD_FUNC_ORIG, NOME, SOBRENOME, CPF, EMAIL, SENHA, DT_NASCIMENTO, SEXO, FL_RECEBE_EMAIL, FL_CONFIAVEL, CD_SITE_FUNC, FL_ATIVO, DH_CADASTRO, DH_ULTIMO_ACESSO ';
$selectCount = 'SELECT COUNT(*) ';
$from = ' FROM TB_USUARIO ';
$limit = '';
if(isset($numPagina) && isset($qtdRegistros)){
$numPag = ($numPagina - 1) * $qtdRegistros;
$limit = " LIMIT " . $numPag . ", " . $qtdRegistros;
}
require 'rubygems'
require 'sinatra'
get '/' do
'
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
#!/usr/bin/env ruby
#
# Brute-force way to retrieve all Github's repositories at once
# Usage:
# github_repos.rb clone # will clone all the user's repositories
# github_repos.rb clone test # will just clone 6 repositories for testing purposes
# github_repos.rb pull # will update all of the user's local repositories
#
# If you have forked repositories, the original sources will be added
# as remotes with the default 'forked_from' name, and a new 'forked_from'
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name, :null => false
t.string :email, :null => false
t.string :crypted_password, :null => false
t.string :password_salt, :null => false
t.string :persistence_token, :null => false
t.string :perishable_token, :null => false
class ArtistsController < ApplicationController
def index
redirect_to :action => "new"
end
def new
@artist = Artist.new(params[:artist])
end