Skip to content

Instantly share code, notes, and snippets.

Ben Davies JalfResi

View GitHub Profile
@JalfResi
JalfResi / logger.go
Created Feb 2, 2017
Golang HTTP Handler request/response logger
View logger.go
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))
@JalfResi
JalfResi / config.xml
Created Jan 25, 2017
Magento H&O Import example
View config.xml
<config>
<modules>
<MyModule_ImportCustomers>
<version>0.1.0</version>
</MyModule_ImportCustomers>
</modules>
<global>
<helpers>
<MyModule_ImportCustomers>
<class>MyModule_ImportCustomers_Helper</class>
@JalfResi
JalfResi / gist:54aecca6a64d76081f1a
Created Jun 25, 2015
Otto JS Plugin - The JavaScript
View gist:54aecca6a64d76081f1a
var getKeys = function(obj){
var keys = [];
for(var key in obj){
keys.push(key);
}
return keys;
}
function checkRequest(r) {
console.log(r);
@JalfResi
JalfResi / gist:fcd68104a284c3bf640d
Created Jun 25, 2015
Otto JS Plugin - expose host object to JS
View gist:fcd68104a284c3bf640d
package main
import (
"bytes"
"fmt"
"log"
"os"
"github.com/robertkrimen/otto"
)
View httpclient.go
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
@JalfResi
JalfResi / Channel Stack
Created Sep 19, 2014
Scaleable Channel Stack with workers
View Channel Stack
package main
import (
"log"
"sync"
)
// ***************************
type Worker chan struct{}
@JalfResi
JalfResi / killchanlist
Created Sep 18, 2014
Kill Channel List
View killchanlist
package main
import (
"log"
"sync"
)
type List struct {
sync.Mutex
chans []chan struct{}
@JalfResi
JalfResi / revprox.go
Created Aug 20, 2013
Simple reverse proxy in Go
View revprox.go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
View gotour-69.go
package main
import (
"os"
"fmt"
"runtime"
)
type Fetcher interface {
// Fetch returns the body of URL and
@JalfResi
JalfResi / gomake-sublime
Created Nov 18, 2011
GoMake Sublime Text 2 Build System
View gomake-sublime
{
"cmd": ["gomake", "-C", "$project_path/src"],
"selector": "source.go",
"path":"/Users/bendavies/go/bin:$PATH",
"file_regex": "^(.+):([0-9]+): .+$"
}
You can’t perform that action at this time.