Skip to content

Instantly share code, notes, and snippets.

@tt
tt / README.md
Created February 10, 2016 19:40
Godep problem

When installing dependencies, dependencies are evaluated based on the latest version in $GOPATH and not based on whatever version is saved in Godeps/

Steps to reproduce

Install Logrus and reset to old version:

go get github.com/Sirupsen/logrus
(cd $GOPATH/src/github.com/Sirupsen/logrus && git reset --hard 8cdd4b39f502d10358d92586e020d3535f257ec9^)

Create a small program (main.go):

@tt
tt / busltee.go
Created April 30, 2015 18:47
busl tee utility
package main
import (
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"sync"
)
@tt
tt / main.go
Created March 2, 2015 18:45
Server-Sent Events example
package main
import (
"log"
"net/http"
"strconv"
"time"
"gopkg.in/antage/eventsource.v1"
)
touch foo
chmod u+x foo
echo 'require "fileutils"; FileUtils.cp("foo", "foo-1.9.2")' | (chruby 1.9.2 && ruby)
echo 'require "fileutils"; FileUtils.cp("foo", "foo-1.9.3")' | (chruby 1.9.3 && ruby)
ls -l
% chruby 1.9.2
% echo "pid = Process.spawn('sh -c \"exit 0\"'); _, status = Process.wait2(pid); warn status.inspect; warn status == 0; warn status.exitstatus == 0" | ruby
#<Process::Status: pid 50482 exit 0>
true
true
% echo "pid = Process.spawn('sh -c \"exit 0\"'); _, status = Process.wait2(pid); warn status.inspect; warn status == 1; warn status.exitstatus == 1" | ruby
#<Process::Status: pid 50454 exit 0>
false
@tt
tt / convert-to-tags.sh
Last active December 22, 2015 07:38
Convert all branches of origin matching `/v[0-9*/` to tags.
branches=`git branch -a | grep 'remotes/origin/v[0-9]*$' | cut -d '/' -f 3`
echo $branches | xargs -I {} git tag {} origin/{}
git push origin --tags
echo $branches | sed 's/^/:refs\/heads\//' | xargs git push origin
git remote prune origin
@tt
tt / README
Created July 16, 2012 16:33
Self-modifying batch file
You can use this for all sorts of crazy. It seems it will continue at the exact character position where it left, so you can both prepend and append stuff while it's running.
var uri = new Uri("http://example.com/?");
var uriBuilder = new UriBuilder(uri);
for (int i = 0; i < 10; i++)
{
uriBuilder.Query = uriBuilder.Query;
}
// uriBuilder.Uri.AbsoluteUri == "http://example.com/???????????"
@tt
tt / twitter_filtering.md
Created June 12, 2011 07:15
Twitter filtering

Metrics for improving relevance of Twitter stream

  • Retweets/favorites (both amount and by whom)
  • Scores from Klout/PeerIndex
  • Topics
  • Whilelist
  • Tweets/second (the less activity the less strict)
@tt
tt / .gitignore
Created February 14, 2011 01:42
[Bb]in
[Oo]bj
*.suo
*.user