Skip to content

Instantly share code, notes, and snippets.

View lcaballero's full-sized avatar

Lucas Caballero lcaballero

View GitHub Profile
@lcaballero
lcaballero / varnishlog-examples.sh
Created January 13, 2020 05:49 — forked from cupracer/varnishlog-examples.sh
varnishlog examples (version 4.x)
# filter by request host header
varnishlog -q 'ReqHeader ~ "Host: example.com"'
# filter by request url
varnishlog -q 'ReqURL ~ "^/some/path/"'
# filter by client ip (behind reverse proxy)
varnishlog -q 'ReqHeader ~ "X-Real-IP: .*123.123.123.123"'
# filter by request host header and show request url and referrer header
@lcaballero
lcaballero / docker-tricks.org
Created September 18, 2019 20:49
Docker tricks
@lcaballero
lcaballero / vec.ts
Last active January 21, 2019 04:26
js/ts 2d Vector lib.
function isNum(x) {
return !isNaN(x);
}
function hasX(v) {
return v && isNum(v.x);
}
function hasY(v) {
return v && isNum(v.y);
}
function hasXY(v) {
@lcaballero
lcaballero / wget
Created September 3, 2017 04:42
Basic HW in bash to test mock wget.
echo "Mock wget"
@lcaballero
lcaballero / elisp-snippets.el
Created September 3, 2017 00:47
Some setup snippets for init.el
;; This is typical setup stuff with bootstrap loading of use-package
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
@lcaballero
lcaballero / bash-snippets.sh
Last active August 31, 2017 15:23
Some bash snippets.
# :create-user :password :wheel :sudoer :sudo
sudo useradd -G wheel -p "$(openssl passwd)" "admin"
# grep stuff
find . | grep -vE "(.git|./wiki)" | grep -E "\.sh$" | xargs -0 grep -ni "batman"
# :here-doc :variable :here
# save multi-line value from 'here doc' into bash variable
VAR=$(cat <<'END_HEREDOC'
abc'asdf"
@lcaballero
lcaballero / init-webpack.sh
Created July 30, 2017 05:22
Initialize a webpack + react + redux + some-loaders... + sass --- because shit just got giant real.
#!/bin/bash
function react() {
npm init -y
npm install -S \
react \
react-dom \
redux \
babel-core \
babel-loader \
@lcaballero
lcaballero / broken-pipe-session.txt
Last active July 20, 2017 16:08
Broken pipe exit session
Supported escape sequences:
~. - terminate session
~B - send a BREAK to the remote system
~R - Request rekey (SSH protocol 2 only)
~# - list forwarded connections
~? - this message
~~ - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)
Reference:
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
dir := "."
@lcaballero
lcaballero / pre-commit.sh
Created February 10, 2017 18:35
A simple pre-commit hook to run go tests (with race flag)
#!/bin/bash
git stash -q --keep-index
go test --race ./...
RESULT=$?
git stash pop -q
if [ $RESULT -ne 0 ] ; then
echo "pre-commit tests failed."
exit 1