Skip to content

Instantly share code, notes, and snippets.

@shazow
shazow / secp256k1.rb
Last active January 24, 2023 01:21
Homebrew recipe for secp256k, put it into /usr/local/Library/Formula/secp256k1.rb or run: brew install https://gist.github.com/shazow/c71c652409015479a7e6/raw/secp256k1.rb
class Secp256k1 < Formula
desc "Optimized C library for EC operations on curve secp256k1"
homepage "https://github.com/bitcoin/secp256k1"
url "https://github.com/bitcoin/secp256k1.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
def install
@shazow
shazow / convert-gifs.sh
Last active January 22, 2024 10:13
Batch convert a directory of gifs into mp4
#!/usr/bin/bash
# Convert *.gif into *.mp4, skip if already exists.
outdir="."
for path in *.gif; do
out="${outdir}/${path/.gif/}.mp4"
[[ -f "$out" ]] && continue
ffmpeg -f gif -i "${path}" "${out}"
done
@shazow
shazow / example.go
Last active September 12, 2015 02:51
Snippets for a blog post: Neither self nor this: Receivers in Go
type Person struct {
Name string
}
func (person Person) Talk(out io.Writer) {
fmt.Fprintf("Hello, I am %s", person.Name)
}
@shazow
shazow / a.go
Last active October 13, 2015 01:32
Constructors in Go
package tmp
import "net"
type ServerA struct {
Clients map[string]net.Conn
}
func (srv *ServerA) Accept(conn net.Conn) error {
key := conn.RemoteAddr().String()
@shazow
shazow / Makefile
Last active January 25, 2016 01:52
My bourbon base override
all: scss
CSS_OUT = ../static/css/screen.css
SCSS_LIBS = ./lib/
$(CSS_OUT): **.scss $(SCSS_LIBS)
sassc --style nested $(addprefix -I ,$(SCSS_LIBS)) screen.scss $(CSS_OUT)
scss: $(CSS_OUT)
@shazow
shazow / ptrproxy.go
Created May 9, 2016 17:57
Safe pointer proxy for lending pointers across runtimes
package main
import "sync"
type ptrId uint
type ptrProxy struct {
sync.Mutex
count uint
lookup map[ptrId]interface{}
@shazow
shazow / .vimrc
Last active August 7, 2016 21:47
Makefile for my SCSS stuff
" Find the nearest Makefile and run it
function! MakeUp()
let makefile = findfile("Makefile", ".;")
if makefile != ""
silent exe "NeomakeSh make -C " . fnamemodify(makefile, ':p:h')
endif
endfunction
autocmd BufWritePost *.scss call MakeUp()
@shazow
shazow / watch-sshchat.md
Last active August 18, 2016 19:30
out of band ssh-chat ding watcher lol

First make a fifo

$ export fifopath=$PWD/chat.fifo
$ mkfifo "$fifopath"

Then start reading from the fifo and looking for the ^G ding escape code.

@shazow
shazow / multierror.go
Last active September 18, 2016 17:26
Yet another Go MultiError
package main
import (
"fmt"
"strings"
)
// MultiError implements the Error interface, can be checked as nil just like normal errors.
func MultiError() multiError {
var err multiError = nil
@shazow
shazow / SimpleGeo.cs
Created January 7, 2017 18:31 — forked from phosphoer/SimpleGeo.cs
Simple Geometry Painter for Unity
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR