Skip to content

Instantly share code, notes, and snippets.

@stevenferrer
stevenferrer / asymmetric.go
Created May 18, 2017 04:14 — forked from cryptix/LICENSE
example of using JWT for http authentication in go
package main
// using asymmetric crypto/RSA keys
import (
"crypto/rsa"
"fmt"
"io/ioutil"
"log"
"net/http"
# Make sure you grab the latest version
curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
# Unzip
unzip protoc-3.2.0-linux-x86_64.zip -d protoc3
# Move only protoc* to /usr/bin/
sudo mv protoc3/bin/protoc /usr/bin/protoc
@stevenferrer
stevenferrer / webcam-cv2.py
Created June 9, 2017 18:27 — forked from tedmiston/webcam-cv2.py
Display the webcam in Python using OpenCV (cv2)
'''
Simply display the contents of the webcam with optional mirroring using OpenCV
via the new Pythonic cv2 interface. Press <esc> to quit.
'''
import cv2
def show_webcam(mirror=False):
cam = cv2.VideoCapture(0)
while True:
@stevenferrer
stevenferrer / gist:ab00929a90793108a7bb96b6e5c7a2e4
Last active June 16, 2017 03:05 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@stevenferrer
stevenferrer / optimusPrime.js
Created June 20, 2017 10:06 — forked from platypusrex/optimusPrime.js
Javascript - Sum all prime numbers
function sumPrimes(num) {
return Array.apply(0, Array(num + 1))
.map(function(x, y){
return y
}).filter(function (i){
return (i > 1) && Array
.apply(0, Array(1 + ~~Math.sqrt(i)))
.every(function(x, y){
return (y < 2) || (i % y !== 0)
});
@stevenferrer
stevenferrer / cache.go
Created June 27, 2017 11:10 — forked from santiaago/cache.go
Learning HTTP caching in Go
package main
import (
"bytes"
"flag"
"image"
"image/color"
"image/draw"
"image/jpeg"
"log"
@stevenferrer
stevenferrer / main.go
Created June 28, 2017 16:10 — forked from husobee/main.go
simple golang http middleware chaining example
package main
import (
"fmt"
"net/http"
"time"
"golang.org/x/net/context"
"github.com/husobee/backdrop"
@stevenferrer
stevenferrer / negroni-gorilla.go
Created June 28, 2017 16:33 — forked from danesparza/negroni-gorilla.go
Negroni with Gorilla mux subrouter
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"log"
"net/http"
)
import (
"fmt"
"html/template"
"net/http"
"github.com/oxtoacart/bpool"
)
var bufpool *bpool.BufferPool
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"