Skip to content

Instantly share code, notes, and snippets.

View fervic's full-sized avatar

Roberto Fernandez fervic

View GitHub Profile
@fervic
fervic / remove_class_regex.js
Created April 18, 2015 21:12
Romove class by regex jQuery extension
//------------------------------------------------------------------------------
// Remove class by Regex
// Array.filter for IE<9: https://gist.github.com/eliperelman/1031656
[].filter||(Array.prototype.filter=function(a,b,c,d,e){c=this;d=[];for(e in c)~~e+''==e&&e>=0&&a.call(b,c[e],+e,c)&&d.push(c[e]);return d});
// http://stackoverflow.com/a/18621161
$.fn.removeClassRegex = function(regex) {
return $(this).removeClass(function(index, classes) {
return classes.split(/\s+/).filter(function(c) {
@fervic
fervic / errs.go
Created January 7, 2016 07:16
Golang error checking closure
func httpRequestHandler(w http.ResponseWriter, req *http.Request) {
err := func () os.Error {
if req.Method != "GET" {
return os.NewError("expected GET")
}
if input := parseInput(req); input != "command" {
return os.NewError("malformed command")
@fervic
fervic / sunrise-and-nicoulaj-zsh-theme.md
Last active June 21, 2017 20:22
This theme combines nicoulaj simplicity with sunrise Git status codes
@fervic
fervic / colors.sh
Created June 21, 2017 20:32 — forked from farsil/colors.sh
Print a 256-color test pattern in the terminal
#!/bin/sh
#
# Marco Buzzanca © 2016. MIT License.
# Originarilly written by Tom Hale © 2016. MIT Licence.
#
# Print out 256 colors, with each number printed in its corresponding color.
#
# Compared to the original script this one also prints the first 16 colors in
# bright/bold, to check the interaction between bold and the ANSI colors. This
# script is also POSIX compliant. Unfortunately this meant I had to use
@fervic
fervic / redshift_table_sizes.sql
Created August 15, 2017 02:44
Table sizes in Redshift
-- Get table sizes in Gigabytes sorted by size descending
SELECT name AS "table", substring(datname, 1, 15) AS "database", ROUND((COUNT(*) / 1024.0),2) AS "GB"
FROM stv_blocklist
INNER JOIN (
SELECT DISTINCT id, name, datname, db_id FROM stv_tbl_perm
INNER JOIN pg_database
ON stv_tbl_perm.db_id = pg_database.oid
) AS t
ON t.id = stv_blocklist.tbl
GROUP BY name, datname
@fervic
fervic / s3cat.sh
Created September 9, 2017 04:46
Stream S3 file contents to a UNIX pipe
#!/usr/bin/env sh
BUCKET=<bucket name>
PATH=<path to file(s)>
for key in `/usr/bin/aws s3api list-objects --bucket $BUCKET --prefix $PATH | /usr/bin/jq -r '.Contents[].Key'`
do
echo $key
/usr/bin/aws s3 cp s3://$BUCKET/$key - | /usr/bin/wc -l
done
@fervic
fervic / zshrc.zsh
Last active May 3, 2018 10:58
.zshrc
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt appendhistory autocd
unsetopt beep extendedglob nomatch notify
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall (but then updated for speed)
zstyle :compinstall filename '/home/rfernandez/.zshrc'
@fervic
fervic / embracing_neovim.md
Last active June 26, 2019 20:58
Embracing Neovim (Progressively)

Embracing Neovim (Progressively)

The idea about this document is to take each section one at a time to learn and memorize the key combinations. Stay on the section until each command becomes muscle memory (1 day, 1 week, ...), then move onto the next section.

1. Use Vim Like Other Editors

Key(s) Action
i Switch to INSERT mode, in which it does what you expect it to do when you type
@fervic
fervic / keybase.md
Created July 3, 2019 15:35
Keybase Verification

Keybase proof

I hereby claim:

  • I am fervic on github.
  • I am fervic (https://keybase.io/fervic) on keybase.
  • I have a public key ASDRGmZb2-On9dT3SIS63b668rwTTOiUpXm5Bpy1J9eH6Qo

To claim this, I am signing this object:

@fervic
fervic / bq_expenses.sh
Created May 28, 2020 06:11
My rough Big Query jobs expenses calculator
#!/usr/bin/env sh
bq ls -j -n 10000 | grep SUCCESS | awk '{print $1}' | \
xargs -n 1 bq --format prettyjson show -j | \
jq .statistics.query.totalBytesBilled | \
sed s/\"//g | \
awk '{ sum += $1 } END { print sum/1024/1024/1024 }'