Skip to content

Instantly share code, notes, and snippets.

@ernesto-jimenez
ernesto-jimenez / git-submit-stack
Created September 14, 2024 21:22
Push graphite stack to git directly
#!/usr/bin/env sh
set -e
current_branch=$(git rev-parse --abbrev-ref HEAD)
gt ls -s -r | rg '(?<branch>[^ ]+)$' -o | rg -v '^(main|master)$' | \
while read -r branch; do
gt co "${branch}"
git push --force-with-lease
done

Before you start

Make sure you have python, OpenFace and dlib installed. You can either install them manually or use a preconfigured docker image that has everying already installed:

docker pull bamos/openface
docker run -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
cd /root/openface

Keybase proof

I hereby claim:

  • I am ernesto-jimenez on github.
  • I am ernesto (https://keybase.io/ernesto) on keybase.
  • I have a public key whose fingerprint is 8D10 A2C2 7C76 CD6A 59E6 7407 4927 19FF F4CE 55FB

To claim this, I am signing this object:

@ernesto-jimenez
ernesto-jimenez / dependencies.md
Created January 25, 2016 13:12
Top packages used in public repos from Gopher Gala 2016

I did a quick calculation of what are the most imported packages.

Top 20 imported packages

  10 github.com/gorilla/mux
   9 golang.org/x/net/context
   7 golang.org/x/oauth2
   7 github.com/gorilla/websocket
   6 github.com/spf13/cobra
@ernesto-jimenez
ernesto-jimenez / .zshrc
Created March 20, 2015 15:23
When entering a dir with a git repository, start a new tmux session for that repository or attach to the existing one if it has already been started.
# Always use the same tmux session in directories with git
attach_tmux_for_dirs_with_repos() {
if [ "$TERM" != "screen-256color" ]; then
if [ -d .git ]; then
SESSION_NAME=$(echo -n ${PWD//*\//}-tmux | tr . -)
tmux attach -t $SESSION_NAME || tmux new -s $SESSION_NAME
fi
fi
}
add-zsh-hook precmd attach_tmux_for_dirs_with_repos
@ernesto-jimenez
ernesto-jimenez / test.go
Created January 26, 2015 17:03
Limiting the amount of requests in-flight
package main
import (
"fmt"
"net/http"
"sync"
)
type LimitedRoundTripper struct {
inflight chan interface{}
@ernesto-jimenez
ernesto-jimenez / gist:11276103
Last active March 27, 2017 09:15
Missing information in slack's payload

Issue

Given an 3rd party integrated with outbound webhooks, when a client writes a message mentioning another user (@user) or channel (#channel). The 3rd party receives a message containing the usrer/channel ID but the payload doesn't specify what user/channel that message corresponds to.

E.g. from https://github.com/ernesto-jimenez/slackline/issues/2

The following message

@blanca_tp: check out #general

We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 4 columns, instead of 1 in line 7.
/Users/ernesto/webmob-reports/webdevdata-latest//00/goolive.de_00e1e029f6b66ee4d6c2d6cb20a3d4d0.html.txt,meta,apple-mobile-web-app-capable,yes
/Users/ernesto/webmob-reports/webdevdata-latest//00/spark.ru_006d396650a3d177698dfc83631c1cad.html.txt,meta,apple-mobile-web-app-capable,yes
/Users/ernesto/webmob-reports/webdevdata-latest//01/hubic.com_01a371682d84564071cc4ebb7dd7b90d.html.txt,meta,apple-mobile-web-app-capable,yes
/Users/ernesto/webmob-reports/webdevdata-latest//01/ostrovok.ru_011d92c671691eefc4b39bae360dd511.html.txt,meta,apple-mobile-web-app-capable,yes
/Users/ernesto/webmob-reports/webdevdata-latest//01/traffichaus.com_01589fbfece5140e342e8b0b48065e11.html.txt,meta,apple-mobile-web-app-capable,yes
/Users/ernesto/webmob-reports/webdevdata-latest//02/goldenmoustache.com_02eab7bc0923a014e9b39de9b024d2c8.html.txt,meta,apple-mobile-web-app-capable,yes
/Users/ernesto/webmob-reports/webdevdata-latest//02/jing.fm_02856bfc25fcb5195920e40a67244338.html.txt,meta,apple-mobile-web-app-capable,yes
/Users/ernesto

Patch to cross compile to android with net/http support

Installation instructions

We need to patch Go's source code to allow cgo when cross-compiling and make Android-specific changes since it sometimes differs from linux (e.g.: it doesn't use /etc/resolv.conf for DNS config)

  1. Clone the go source: hg clone -u release https://code.google.com/p/go
  2. Enter the go source directory: cd go
  3. Apply the patch in this gist: patch -p1 < /path/to/patch/go_android.patch
  4. Enter the go/src directory: cd src