Skip to content

Instantly share code, notes, and snippets.

@jtbonhomme
jtbonhomme / git.sh
Created June 21, 2017 12:11
Git cheat sheet
# Show file modified since a specific commit:
git log --name-only --pretty=oneline --full-index 64b7d1ead..HEAD | grep -vE '^[0-9a-f]{40} ' | sort | uniq
@jtbonhomme
jtbonhomme / .asoundrc
Created July 2, 2017 06:24
Alsa configuration file for internal bcm2835 internal soundcard (playback) and external PnP USB microphone
pcm.!default {
type asym
playback.pcm {
type plug
slave.pcm "hw:0,0"
}
capture.pcm {
type plug
slave.pcm "hw:1,0"
}
@jtbonhomme
jtbonhomme / pulseaudio.service
Created July 2, 2017 09:14
Start pulseaudio as a Deamon at startup.
[Unit]
Description=PulseAudio Daemon
Requires=sound.target dbus.service
After=sound.target dbus.service
[Service]
Type=simple
#ExecStart=/usr/bin/pulseaudio -D
ExecStart=/usr/bin/pulseaudio --system --realtime --disallow-exit --disallow-module-loading
@jtbonhomme
jtbonhomme / README.md
Created September 28, 2017 19:45 — forked from SamyPesse/README.md
Complete example of code highlight for Draft.js with Prism

How to test it?

Copy the prism.js file under examples/prism/ in Draft.js repository. Run npm install prismjs Then open it in your browser.

@jtbonhomme
jtbonhomme / bluetooth.sh
Created January 28, 2018 07:11 — forked from jnovack/bluetooth.sh
Control Bluetooth Daemon through Command Line OSX
#read the current pref, returns '0' for off and '1' for on.
defaults read /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState
#set bluetooth pref to off
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 0
#set bluetooth pref to on
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 1
#kill the bluetooth server process
@jtbonhomme
jtbonhomme / client.go
Last active February 6, 2018 14:34
gRPC example
package main
import (
"bufio"
"bytes"
"fmt"
"log"
"net/http"
pb "test_protobuf/post"
proto "github.com/golang/protobuf/proto"
@jtbonhomme
jtbonhomme / display_struct.go
Last active February 27, 2018 09:33
Gist to display a struct in Go (https://play.golang.org/p/kZy25h7qsq9)
package main
import (
"reflect"
"fmt"
"time"
)
type MyStruct struct {
CreatorId string `json:"creator_id"`
@jtbonhomme
jtbonhomme / nested.go
Last active February 27, 2018 11:27
Initialize nested struct (https://play.golang.org/p/A7dbuyPGsw0)
import (
"fmt"
)
type Toto struct {
S string
N struct {
I int64
}
}
@jtbonhomme
jtbonhomme / example.go
Created March 13, 2018 15:47 — forked from ciaranarcher/example.go
Wrapping a ResponseWriter to capture the status code
// Create our own MyResponseWriter to wrap a standard http.ResponseWriter
// so we can store the status code.
type MyResponseWriter struct {
status int
http.ResponseWriter
}
func NewMyResponseWriter(res http.ResponseWriter) *MyResponseWriter {
// Default the status code to 200
return &MyResponseWriter{200, res}
@jtbonhomme
jtbonhomme / Go_recover.md
Created March 15, 2018 10:02
recover from Go handler panic

Handler function


// GET an Object by its ID
func FindObjectEndpoint(w http.ResponseWriter, r *http.Request) {
    params := mux.Vars(r)
    numObject, err := dao.FindById(params["id"])
    if err != nil {