Skip to content

Instantly share code, notes, and snippets.

View CarlosEspejo's full-sized avatar
🖖

Carlos Espejo CarlosEspejo

🖖
View GitHub Profile
@CarlosEspejo
CarlosEspejo / gist:4162468
Created November 28, 2012 16:49
Must have dev environment gems
group :development do
gem 'railroady'
gem 'quiet_assets'
gem 'letter_opener'
gem 'pry'
gem 'awesome_print'
end
@CarlosEspejo
CarlosEspejo / gist:4236663
Created December 7, 2012 21:26
indexing needed?
class CreateListProductInteractions < ActiveRecord::Migration
def change
create_table :list_product_interactions do |t|
t.integer :votes_up, default: 0
t.integer :votes_down, default: 0
t.integer :votes_activity, default: 0
t.integer :votes_total, default: 0
t.integer :list_id
t.integer :product_id
@CarlosEspejo
CarlosEspejo / gist:4705107
Created February 4, 2013 05:03
List Comprehension in Coffee Script
// Coffee script
books = [1..25]
data = (book for book in books)
console.log data
// Generated Javascript
(function() {
var book, books, data, _i, _results;
books = (function() {
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "spec"
t.pattern = "spec/**/*_spec.rb"
end
Rake::TestTask.new(:webkit) do |t|
t.libs << "spec_webkit"
t.pattern = "spec_webkit/**/*_spec.rb"
package main
import (
"fmt"
"os"
"compress/gzip"
"encoding/xml"
)
@CarlosEspejo
CarlosEspejo / gist:430be4ee5e121a3a6dc4
Last active August 29, 2015 14:23
fstab settings

Auto mounting drives on boot /etc/fstab

https://help.ubuntu.com/community/Fstab

helpful commands

sudo lsblk # list block devices
sudo blkid # Get block device UUID
sudo mount -a # will try to mount everything and throw errors if fstab is screwed up.
@CarlosEspejo
CarlosEspejo / gist:96176fa486bc50f7bb15
Created June 24, 2015 12:52
Add a column to a big table without downtime
disable_ddl_transaction!
def up
add_column :users, :processed, :boolean
change_column :users, :processed, :boolean, default: false
execute 'update users set processed = false where processed is null'
add_index :users, :processed, where: 'processed = false', algorithm: :concurrently
end
@CarlosEspejo
CarlosEspejo / gist:f9024b3cb37f0d3e7591
Created June 29, 2015 20:48
See the environment variables of a running process
sudo cat /proc/[pid]/environ | tr '\0' '\n'
@CarlosEspejo
CarlosEspejo / Rake Task and CRON
Last active October 23, 2015 15:40
Rake Tasks via CRON
# Look into
# Explicitly define PATH at the top of your crontab file:
PATH=/Users/deployer/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin
Or
export PATH=~/.rbenv/shims:~/.rbenv/bin:"$PATH"
@CarlosEspejo
CarlosEspejo / Mongo NUMA Hardware
Last active May 10, 2024 06:09
Fix mongo for NUMA hardware
Ubuntu 15.04
sudo apt-get install numactl
# Open systemd file
# find /etc/systemd/ | grep -i mongo
/etc/systemd/system/multi-user.target.wants/mongod.service
[Unit]
Description=An object/document-oriented database