Skip to content

Instantly share code, notes, and snippets.

View CarlosEspejo's full-sized avatar
🖖

Carlos Espejo CarlosEspejo

🖖
View GitHub Profile

Keybase proof

I hereby claim:

  • I am carlosespejo on github.
  • I am awcarlos (https://keybase.io/awcarlos) on keybase.
  • I have a public key ASC2JMFchy46ahF4d2Vnp6L4kTL2IplOUR0BaJTFzaM7fAo

To claim this, I am signing this object:

@CarlosEspejo
CarlosEspejo / encoder.rb
Last active January 25, 2016 12:26
Ruby Transcoder
require 'fileutils'
class Encoder
attr_reader :processed, :search_path, :queue
def initialize
@search_path = '/mnt/data/media'
@processed = File.readlines('encode.log') if File.exists?('encode.log')
@processed = Array(processed).map(&:chomp)
@queue = Dir.glob("#{search_path}/**/*.avi").sort
@CarlosEspejo
CarlosEspejo / PG Tuning
Last active October 13, 2015 16:14
Postgres Modern Tuning settings
# Borrowed from this talk
# https://www.youtube.com/watch?v=dBeXS5aFLNc
# http://jberkus.github.io/performance_in_15_min/index.html?utm_source=postgresweekly&utm_medium=email#37
# Thank you Josh!!
# Memory Settings
shared_buffers = 2GB # RAM/4 up to 8GB
work_mem = 32MB # limit: RAM/(max_connections/2)
# 8MB to 32MB: web
@CarlosEspejo
CarlosEspejo / pg_backup.sh
Last active December 18, 2015 05:55
Postgresql 30 day backup script
#!/bin/bash
# This script will create a compressed data dump
# that can be restored in parallel using
# pg_restore -C -j[num of cores] -d postgres 2015-09-30-app_db.dump
# note: when -C is present the db in -d is used only to make the connection.
# http://www.postgresql.org/docs/current/static/app-pgrestore.html
# http://www.postgresql.org/docs/current/static/app-pgdump.html
DATABASE_NAME=app_db

Systemd

sample.service file you have to copy it to /etc/systemd/system

Set it to auto start

sudo systemctl enable sample.service

Troubleshoot

@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
@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 / 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 / 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: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.