Skip to content

Instantly share code, notes, and snippets.

View luisguzman02's full-sized avatar
🎯
Focusing

Luis luisguzman02

🎯
Focusing
View GitHub Profile
@luisguzman02
luisguzman02 / git-branch-status
Last active December 31, 2017 20:55 — forked from vitalk/git-branch-status
Show how many commits each branch is ahead or behind its upstream.
#!/usr/bin/env bash
# Usage: git-branch-status
# Show how many commits each branch is ahead or behind its upstream.
branch=`git rev-parse --abbrev-ref HEAD`
git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads | \
while read local upstream; do
@luisguzman02
luisguzman02 / curl.md
Created November 15, 2017 18:30 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@luisguzman02
luisguzman02 / postgres_table_row_count.sql
Created July 25, 2017 15:56
Row counts for all tables in a postgres db.
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
@luisguzman02
luisguzman02 / post-deploy.yml
Created July 25, 2017 15:55 — forked from klappradla/post-deploy.yml
Rake tasks as post deploy hooks for AWS Elastic Beanstalk Puma-Rails applications
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/01_do_stuff.sh" :
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#! /usr/bin/env bash
# Using similar syntax as the appdeploy pre hooks that is managed by AWS
set -xe
@luisguzman02
luisguzman02 / 03-sidekiq.config
Created July 14, 2017 23:05 — forked from tarom/03-sidekiq.config
Elastic Beanstalk appdeploy/post hook script for Sidekiq
# Sidekiq interaction and startup script
commands:
create_post_dir:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq.sh":
mode: "000755"
owner: root
group: root
@luisguzman02
luisguzman02 / 001_sidekiq.conf
Created July 14, 2017 23:05 — forked from hugodias/001_sidekiq.conf
Amazon Elastic Beanstalk Sidekiq config file
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_sidekiq":
mode: "000755"
content: |
#!/bin/bash
initctl restart sidekiq || initctl start sidekiq
ln -sf /var/app/current/log/sidekiq.log /var/app/containerfiles/logs/sidekiq.log
"/opt/elasticbeanstalk/hooks/appdeploy/pre/03_mute_sidekiq":
@luisguzman02
luisguzman02 / clean-up-remote-branches.rb
Created July 6, 2017 20:51 — forked from pcreux/clean-up-remote-branches.rb
delete remote branches behind master
to_delete = []
branches = `git branch -r | grep origin`
branches.each_line do |branch|
branch.strip!
next if branch['master']
puts branch
puts cmd = "git diff --stat origin/master...#{branch}"
if `#{cmd}`.empty?
to_delete << branch
@luisguzman02
luisguzman02 / tmux.md
Created April 11, 2017 01:23 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@luisguzman02
luisguzman02 / tmux-cheatsheet.markdown
Created April 11, 2017 01:23 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@luisguzman02
luisguzman02 / pdf_merger.rb
Created April 1, 2017 02:11 — forked from eclosson/pdf_merger.rb
Merging PDFs with Prawn
class PdfMerger
def merge(pdf_paths, destination)
first_pdf_path = pdf_paths.delete_at(0)
Prawn::Document.generate(destination, :template => first_pdf_path) do |pdf|
pdf_paths.each do |pdf_path|
pdf.go_to_page(pdf.page_count)