Skip to content

Instantly share code, notes, and snippets.

View jordic's full-sized avatar
🐛
python

Jordi Collell jordic

🐛
python
  • https://tmpo.io
  • Barcelona, ES
View GitHub Profile
package main
// based on gist
// https://gist.github.com/ir4y/11146415
// http://stackoverflow.com/questions/21417223/simple-ssh-port-forward-in-golang
import (
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/gopass"
"fmt"
@jordic
jordic / jsonhandler.go
Last active August 29, 2015 14:02
Specialized middlewares
package main
import (
"encoding/json"
"github.com/bmizerany/pat"
"html/template"
"log"
"net/http"
)
@jordic
jordic / responsewriterwatcher.go
Created July 23, 2014 13:34
http.ResponseWriter embed
type ResponseWriterWatcher struct {
rw http.ResponseWriter
Status int
Size int
}
func WatchResponseWriter(rw http.ResponseWriter) *ResponseWriterWatcher {
return &ResponseWriterWatcher{
rw: rw,
@jordic
jordic / test.html
Created January 29, 2015 12:45
Fucking javascript prototype inheritance
<script>
c = function() {}
c.prototype.d = {}
a = new c()
b = new c()
a.d.test = 'a'
@jordic
jordic / Dockerfile
Last active November 4, 2015 13:26
3DES_crypt
FROM php:5.6-cli
RUN apt-get update && apt-get install -y libmcrypt-dev \
&& docker-php-ext-install mcrypt
CMD ["php"]
@jordic
jordic / template.sh
Created November 19, 2015 06:46
Bash template variable
# tpl is a variable only template parser for bash.
tpl() {
if [ -z "$1" ]; then
echo "Must provide a tpl name: tpl tplname"
exit;
fi
TPL=$(cat $1)
eval "echo \"$TPL\""
}
@jordic
jordic / goproxy.go
Created December 3, 2015 05:41
go proxy
/*
url1, _ := url.Parse("https://www.google.es")
url2, _ := url.Parse("http://www.mon.cat")
a := &proxy{
entry: map[string]*httputil.ReverseProxy{
"google": httputil.NewSingleHostReverseProxy(url1),
"mon": httputil.NewSingleHostReverseProxy(url2),
},
}
http.Handle("/", a)
@jordic
jordic / untar
Created June 23, 2016 05:10
Create a multitar archive
# Create
tar czpvf - /path/to/archive | split -d -b 100M - tardisk
# Decompress
cat tardisk* | tar xzpvf -
# http://superuser.com/questions/290986/how-to-create-tar-archive-split-into-or-spanning-multiple-files
(function(){
angular.module('mnt')
.directive('tTimer', function() {
return {
template: [
'<div class="tpreload">',
' <div style="width:{{$ctrl.percent}}%"></div>',
'</div>'
].join("\n"),
package client
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"