Skip to content

Instantly share code, notes, and snippets.

View caarlos0's full-sized avatar
๐Ÿ„

Carlos Alexandro Becker caarlos0

๐Ÿ„
View GitHub Profile
@caarlos0
caarlos0 / nginx.conf
Last active December 25, 2015 21:29
Config that I'm using right now with Puma + nginx
upstream puma {
server unix://tmp/wealcash.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name wealcash.com;
root /var/www/wealcash/current/public;
location ^~ /assets/ {

Setup Mac OS X Mountain Lion

I just replaced the hard drive of my mbp and decided to do a clean install of Mountain Lion (10.8.5) since I was still using Snow Leopard (10.6.8).

I kinda regret for not using Boxen to automate the process, but TBH I have this laptop for almost 3yrs and this is the first time I needed to reinstall everything, maybe the next time...

alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
#!/usr/bin/env bash
set -u
set -e
export GIT_WORK_TREE="/var/www/example.com"
export NODE_VERSION="0.10"
echo "--> Checking out..."
git checkout -f
---------------------------------------------------------------------------------------------------------
# app/helpers/application_helper.rb
---------------------------------------------------------------------------------------------------------
def horizontal_simple_form_for(record, options={}, &block)
options[:html] ||= {}
options[:html][:class] = "form-horizontal #{options[:html][:class]}".rstrip
options[:wrapper] = :bootstrap_horizontal
simple_form_for(record, options, &block)
end
---------------------------------------------------------------------------------------------------------
#!/bin/sh -e
echo "Creating a new jekyll site..."
jekyll new bug
cd bug
echo "Creating needed folders..."
mkdir -p _assets/stylesheets
mkdir _plugins
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@caarlos0
caarlos0 / eq.or.higher.than.9.2.sql
Created June 3, 2014 19:25
PostgreSQL query monitoring (deadlocks and shit)
SELECT bl.pid AS blocked_pid,
a.usename AS blocked_user,
ka.query AS blocking_statement,
now() - ka.query_start AS blocking_duration,
kl.pid AS blocking_pid,
ka.usename AS blocking_user,
a.query AS blocked_statement,
now() - a.query_start AS blocked_duration
FROM pg_catalog.pg_locks bl
JOIN pg_catalog.pg_stat_activity a ON a.pid = bl.pid
@caarlos0
caarlos0 / for.less
Created June 6, 2014 15:00
LESS loop with variable interpolations (recursive).
.generate-cols(@n, @i: 1) when (@i =< @n) {
@var: ~"col@{i}";
input.col@{i},
.col@{i} {
width: @@var;
}
.table-default td.col@{i} {
max-width: @@var;
}
.generate-cols(@n, (@i + 1));