Skip to content

Instantly share code, notes, and snippets.

View xor-gate's full-sized avatar
👽

Jerry Jacobs xor-gate

👽
View GitHub Profile
@jackspirou
jackspirou / rewriteImportPaths.go
Last active December 21, 2022 17:48
A method for rewriting golang import paths.
package importpaths
import (
"log"
"os"
"strconv"
"strings"
"go/ast"
"go/parser"
@rjz
rjz / handler.go
Last active September 24, 2024 14:40
Handle Github webhooks with golang
// Now available in package form at https://github.com/rjz/githubhook
package handler
// https://developer.github.com/webhooks/
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"errors"
@BobBurns
BobBurns / blinky.s
Created July 31, 2015 16:45
blink led on stm32 L1 Discovery with ARM assembly
@ lets try to blink an LED on the discovery stm32 L1 board
@ uses LED on PB7
@ how to compile and flash:
@ arm-none-eabi-as -mcpu=cortex-m3 blinky.s -o blinky.o
@ arm-none-eabi-ld -v -T stm32.ld -nostartfiles -o blinky.elf blinky.o
@ arm-none-eabi-objcopy -O binary blinky.elf blinky.bin
@ then from st-link (https://github.com/texane/stlink)
@ ./st-flash write ../first_arm/blinky.bin 0x08000000
.thumb
@mdwhatcott
mdwhatcott / custom_json.go
Created July 29, 2015 17:15
Example of implementing MarshalJSON and UnmarshalJSON to serialize and deserialize custom types to JSON in Go. Playground: http://play.golang.org/p/7nk5ZEbVLw
package main
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
)
func main() {
@iamralch
iamralch / compress.go
Last active February 11, 2025 19:32
ZIP archives in Golang
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@niun
niun / root-ro
Last active June 27, 2024 14:06
Read-only Root-FS with overlayfs for Raspian
#!/bin/sh
#
# Read-only Root-FS for Raspian
#
# Modified 2015 by Pascal Rosin to work on raspian-ua-netinst with
# overlayfs integrated in Linux Kernel >= 3.18.
#
# Originally written by Axel Heider (Copyright 2012) for Ubuntu 11.10.
# This version can be found here:
# https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash#Overlayfs
@diorahman
diorahman / ws-client.go
Created July 21, 2015 01:53
golang websocket example with basic auth
package main
import (
"log"
"net/http"
"encoding/json"
"golang.org/x/net/websocket"
"fmt"
)
@iamralch
iamralch / ssh_client.go
Last active September 10, 2025 02:55
SSH client in GO
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"strings"
@d-smith
d-smith / soap1.go
Created June 1, 2015 20:10
build up of soap parsing in golang
package main
import (
"encoding/xml"
"fmt"
)
var payload = `
<ns:workItem>
<typ:correspondenceCount>10</typ:correspondenceCount>
// a pool embedding the original pool and adding adbno state
type DbnoPool struct {
redis.Pool
dbno int
}
// "overriding" the Get method
func (p *DbnoPool)Get() Connection {
conn := p.Pool.Get()