Skip to content

Instantly share code, notes, and snippets.

drincruz / .gitconfig
Created Jun 6, 2022
Git configs to support multiple environments and separate files
View .gitconfig
excludesfile = ~/.gitignore_global
name = Adrian Cruz
email =
signingkey = work-signing-key
program = /usr/local/bin/gpg
# Include custom .gitconfig if in personal github dir
drincruz / fast_video_x.js
Created Sep 30, 2020
Play video on a page at a faster rate
View fast_video_x.js
document.querySelector('video').playbackRate = 1.75;
drincruz /
Created Nov 29, 2019
aws CLI Helpful commands
# Output the Public IP, Private IP, Instance Name
aws --profile default ec2 describe-instances --query 'Reservations[].Instances[].[PublicIpAddress,PrivateIpAddress,Tags[?Key==`Name`]| [0].Value]' --output=table
drincruz / gohang.go
Created Jun 18, 2019
Quick Golang HTTP Server
View gohang.go
package main
import (
func main() {
http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request) {
drincruz / fibonacci.ex
Last active Apr 11, 2022
What Fibonacci looks like in Elixir
View fibonacci.ex
defmodule ElixirLab.Fibonacci do
# Recursive
def fib(0), do: 1
def fib(1), do: 1
def fib(n), do: fib(n-1) + fib(n-2)
# Iterative
def iter_fib(0), do: 1
def iter_fib(1), do: 1
def iter_fib(index) do
drincruz / fizz_buzz.ex
Created Mar 14, 2017
FizzBuzz in Elixir and Python
View fizz_buzz.ex
def fizz_buzz(n) when 0 === rem(n, 3) and 0 === rem(n, 5) do
def fizz_buzz(n) when 0 === rem(n, 3), do: "Fizz"
def fizz_buzz(n) when 0 === rem(n, 5), do: "Buzz"
def fizz_buzz(n), do: n
drincruz / 15-xdebug.ini
Created Jun 2, 2016
Xdebug and Vagrant
View 15-xdebug.ini
; Enable xdebug extension module
; see
xdebug.remote_enable = 1
xdebug.remote_host =
xdebug.remote_port = 9000
xdebug.idekey = "vagrant"
xdebug.remote_handler = dbgp
drincruz / tmp.json
Last active Apr 18, 2016
Python JSON to CSV via Pandas
View tmp.json
drincruz / hacker_news_standard_deviation.sql
Last active Apr 29, 2016
Getting variance and standard deviation in BigQuery
View hacker_news_standard_deviation.sql
FROM (standardDeviation(
'[' + GROUP_CONCAT_UNQUOTED(STRING(score)) + ']' AS json_array_input
drincruz /
Last active Dec 22, 2015
data mining on the command line with bash and python
# This is the main meat and potatoes of what I really want
grep -E DEBUG 2015-10-09.err | grep -E '(anonymous_id|high_scores:)'| sed -e 's/anonymous_id//g' |cut -d ' ' -f 2-| python -c "import fileinput; l0=[int(x.split(' ')[-1].strip()) for x in fileinput.input()];print('searches:{}\thigh_scoring:{}\tratio:{}'.format(l0[0],l0[1],l0[1]/float(l0[0])))"
# This is just a bonus to loop through a date range of my log files
for d in {0..15}; do today=`date -d "2015-10-09 + $d days" +'%Y-%m-%d'`; echo -n "${today} "; grep -E DEBUG ${today}.err|grep -E '(anonymous_id|high_scores:)'| sed -e 's/anonymous_id//g' |cut -d ' ' -f 2-| python -c "import fileinput; l0=[int(x.split(' ')[-1].strip()) for x in fileinput.input()];print('searches:{}\thigh_scoring:{}\tratio:{}'.format(l0[0],l0[1],l0[1]/float(l0[0])))"; done