Skip to content

Instantly share code, notes, and snippets.

@kevinlebrun
kevinlebrun / rangefinder.py
Created November 27, 2018 02:23
rangefinder code using Pi camera module
#! /usr/bin/env python
import sys
import argparse
import cv2
import numpy
from picamera import PiCamera
from picamera.array import PiRGBArray
import RPi.GPIO as GPIO
import time
import math
@kevinlebrun
kevinlebrun / capture_laser.py
Created November 27, 2018 02:06
Capture laser using Pi camera module
import RPi.GPIO as GPIO
from picamera import PiCamera
GPIO.setmode(GPIO.BCM)
laser_pin = 22
GPIO.setup(laser_pin, GPIO.OUT)
print(GPIO.VERSION)

PoC Keep Session during domain migration

The idea is simple: pass the session cookie from the old domain to the new one.

Usage

$ go run server.go

Go to http://session and http://nosession.

@kevinlebrun
kevinlebrun / bin.py
Created April 20, 2016 14:52
Plug into Orange API
bins = [
'01010000',
'01101100',
'01110101',
'01100111',
'00100000',
'01101001',
'01101110',
'01110100',
'01101111',
@kevinlebrun
kevinlebrun / resharp_project_structure.go
Created April 1, 2016 15:04
A little script I used to reorganize one of my project tree.
package main
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"
)
package singleton
var Instance *_Singleton
type _Singleton struct {
SharedResource int
}
func _Load() {
Instance = &_Singleton{SharedResource: 1}
@kevinlebrun
kevinlebrun / reverse_test.go
Created January 8, 2015 13:52
Quickcheck, Reverse, and Runes in Go
package main
import (
"testing"
"testing/quick"
"unicode/utf8"
)
func reverseUsingBytes(a string) string {
b := make([]byte, len(a))
@kevinlebrun
kevinlebrun / state_machine.go
Created January 6, 2015 12:32
A simple state machine using recursive type in Go as shared here: http://talks.golang.org/2014/compiling.slide#6
package main
import "fmt"
type F func(*State) F
type State int
func Begin(s *State) F {
*s = 1
@kevinlebrun
kevinlebrun / method.go
Created January 5, 2015 17:47
Method Expression with Go
package main
import (
"fmt"
"reflect"
)
type T struct {
Message string
}
@kevinlebrun
kevinlebrun / README.md
Last active December 26, 2015 16:49
Outward Counterclockwise Spiral Matrix Traversal

Outward Counterclockwise Spiral Matrix Traversal

Programming interview practice of the week (October 25)

Problem

Write a function that accepts four arguments. The first two arguments are the size of the grid (h x w), filled with ascending integers from left to right, top to bottom, starting from 1. The next two arguments are is the starting positions, the row (r) and column (c).

Return an array of integers obtained by spiraling outward anti-clockwise from the r and c, starting upward.