Skip to content

Instantly share code, notes, and snippets.

@JalfResi
JalfResi / gomake-sublime
Created November 18, 2011 11:13
GoMake Sublime Text 2 Build System
{
"cmd": ["gomake", "-C", "$project_path/src"],
"selector": "source.go",
"path":"/Users/bendavies/go/bin:$PATH",
"file_regex": "^(.+):([0-9]+): .+$"
}
@JalfResi
JalfResi / gotour-69.go
Last active December 10, 2015 00:39 — forked from kylelemons/gotour-69.go
package main
import (
"os"
"fmt"
"runtime"
)
type Fetcher interface {
// Fetch returns the body of URL and
@JalfResi
JalfResi / revprox.go
Last active April 23, 2024 10:29
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@JalfResi
JalfResi / killchanlist
Created September 18, 2014 13:34
Kill Channel List
package main
import (
"log"
"sync"
)
type List struct {
sync.Mutex
chans []chan struct{}
@JalfResi
JalfResi / Channel Stack
Created September 19, 2014 11:30
Scaleable Channel Stack with workers
package main
import (
"log"
"sync"
)
// ***************************
type Worker chan struct{}
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
@JalfResi
JalfResi / gist:fcd68104a284c3bf640d
Created June 25, 2015 15:06
Otto JS Plugin - expose host object to JS
package main
import (
"bytes"
"fmt"
"log"
"os"
"github.com/robertkrimen/otto"
)
@JalfResi
JalfResi / gist:54aecca6a64d76081f1a
Created June 25, 2015 15:10
Otto JS Plugin - The JavaScript
var getKeys = function(obj){
var keys = [];
for(var key in obj){
keys.push(key);
}
return keys;
}
function checkRequest(r) {
console.log(r);
@JalfResi
JalfResi / config.xml
Created January 25, 2017 12:02
Magento H&O Import example
<config>
<modules>
<MyModule_ImportCustomers>
<version>0.1.0</version>
</MyModule_ImportCustomers>
</modules>
<global>
<helpers>
<MyModule_ImportCustomers>
<class>MyModule_ImportCustomers_Helper</class>
@JalfResi
JalfResi / logger.go
Created February 2, 2017 21:40
Golang HTTP Handler request/response logger
func logger(prefix string, h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Save a copy of this request for debugging.
requestDump, err := httputil.DumpRequest(r, false)
if err != nil {
log.Println(err)
}
log.Println(prefix, string(requestDump))