Skip to content

Instantly share code, notes, and snippets.

View xdougx's full-sized avatar

Douglas Rossignolli xdougx

View GitHub Profile
var IApp = (function() {
var InterfaceApp = function() {
this.run = function(obj, vars) {
if(obj == null) { obj = this.modules; }
if(vars !== undefined) { this.addGlobals(vars); }
this.callEvents(obj);
};
@xdougx
xdougx / git_cmd.markdown
Last active December 19, 2015 19:49
comandos para o git

GIT

Commitar uma feature

git add . => Adiciona todas as mudanças
git commit -a -m "<mensagem do commit>"
git push origin staging

Sincronizar

@xdougx
xdougx / redis_persistence.rb
Last active August 29, 2015 13:57
Simple Redis Persistence with Namespace and Keys
# Classe que faz uma simples persistencia para o Redis, usando de métodos simples.
# @author Douglas Rossignolli
# @version 0.0.5
class RedisPersistence
attr_accessor :redis
def initialize
if Rails.env.production?
ENV["REDISTOGO_URL"] ||= "<redis server uri>"
uri = URI.parse(ENV["REDISTOGO_URL"])
@redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
---
- :cod_uf: '52'
:uf: Goiás
:city_id: '00050'
:city: Abadia de Goiás
:sigla_uf: GO
:city_code: '5200050'
- :cod_uf: '31'
:uf: Minas Gerais
:city_id: '00104'
upstream unicorn {
server unix:/tmp/unicorn.foo.sock fail_timeout=0;
}
server {
listen 80 default deferred;
listen 443 ssl default;
ssl_certificate /etc/ssl/certs/foo.crt;
ssl_certificate_key /etc/ssl/private/foo.key;
Thanks to Jason Roelofs for his article at http://jasonroelofs.com/2012/03/12/manage-and-monitor-resque-with-upstart-and-monit/ which got me most of the way there.
@xdougx
xdougx / validations.js
Last active August 29, 2015 14:01
Validations.js
var Validations = (function(){
var Validation = function() {
var name = $("[name='nome']");
var email = $("[name='email']");
var empresa = $("[name='empresa']");
var telefone = $("[name='telefone']");
var mensagem = $("[name='mensagem']");
var regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
require 'rufus/scheduler'
class Scheduler
# Starts the scheduler unless it is already running
def self.start_unless_running(pid_file)
with_lockfile(File.join(File.dirname(pid_file), 'scheduler.lock')) do
if File.exists?(pid_file)
pid = IO.read(pid_file).to_i
if pid > 0 && process_running?(pid)
puts "not starting scheduler because it already is running with pid #{pid}"
@xdougx
xdougx / iptable.conf
Created June 6, 2014 18:49
iptable for postgreesql
# Generated by iptables-save v1.4.12 on Wed Feb 19 15:24:27 2014
*filter
:INPUT ACCEPT [400:37871]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [283:59798]
# rules for postgree
#-A INPUT -d 202.54.1.20/32 -p tcp -m tcp --sport 1024:65535 --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
#-A INPUT -d 202.54.1.20/32 -p tcp -m tcp --sport 5432 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
#-A INPUT -s 202.54.1.20/32 -d 202.54.1.20/32 -p tcp -m tcp --sport 1024:65535 --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
require 'base64'
require 'net/http'
class ImageProxyController < ActionController::Base
def get
url = URI.parse(Base64.decode64(params[:url]))
image = Net::HTTP.get_response(url)
send_data image.body, type: image.content_type, disposition: 'inline'
end
end