Skip to content

Instantly share code, notes, and snippets.

View jyap808's full-sized avatar

Julian Yap jyap808

View GitHub Profile
@aalness
aalness / benchmark.cpp
Last active March 10, 2023 10:15
Benchmark SHA256 for libsecp256k1 / crypto++ / openssl
#include <string.h>
#include <sys/time.h>
#include <iostream>
#include <openssl/sha.h>
#include <openssl/rand.h>
#include "secp256k1/src/hash_impl.h"
#include "cryptopp/sha.h"
static const size_t NUM_RUNS = 300000UL;
@ryandotsmith
ryandotsmith / main.go
Created January 15, 2015 01:10
Sending an OP_RETURN Bitcoin Transaction with Go using Chain's Bitcoin API
package main
import (
"bytes"
"encoding/hex"
"encoding/json"
"io/ioutil"
"log"
"net/http"
@yurydelendik
yurydelendik / !wasmllvm.md
Last active September 9, 2025 17:33
Using WebAssembly in LLVM

NOTE: the content is out-of-date. All development is moved to the https://github.com/yurydelendik/wasmception

Using WebAssembly in LLVM

Compiling

# locations, e.g.
export WORKDIR=~/llvmwasm; mkdir -p $WORKDIR
export INSTALLDIR=$WORKDIR
@andrewmilson
andrewmilson / file-upload-multipart.go
Last active June 28, 2025 18:41
Golang multipart/form-data File Upload
package main
import (
"net/http"
"os"
"bytes"
"path"
"path/filepath"
"mime/multipart"
"io"
@mjohnsullivan
mjohnsullivan / parse_json.go
Created December 14, 2015 23:17
Parse JSON objects with arbitrary key names in Go using interfaces and type assertions
// Parsing arbitrary JSON using interfaces in Go
// Demonstrates how to parse JSON with abritrary key names
// See https://blog.golang.org/json-and-go for more info on generic JSON parsing
package main
import (
"encoding/json"
"fmt"
)
@alexvandesande
alexvandesande / Random generator
Last active December 23, 2022 09:10
A very simple random generator. A miner can influence the number by not publishing a block with an unwanted outcome, and forfeiting the 5 block reward.
contract random {
/* Generates a random number from 0 to 100 based on the last block hash */
function randomGen(uint seed) constant returns (uint randomNumber) {
return(uint(sha3(block.blockhash(block.number-1), seed ))%100);
}
/* generates a number from 0 to 2^n based on the last n blocks */
function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) {
uint n = 0;
for (uint i = 0; i < size; i++){
@wyattjoh
wyattjoh / caddy.conf
Last active April 18, 2018 12:39
Caddy Supervisord Setup
[program:caddy]
command=/usr/bin/caddy -conf="/etc/caddy/Caddyfile"
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/caddy.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/caddy_error.log
@thekcsam
thekcsam / macvim
Last active September 30, 2023 22:15
- How to set the default font size in macvim
# Open Terminal
vim ~/.vimrc
# Mac OS-X -> .vimrc ; Window -> .gvimrc
# Add it in the file and adjust the font size (h12) accordingly
set guifont=Menlo\ Regular:h15
@mattdenner
mattdenner / README.markdown
Last active July 30, 2025 07:25
Suspend and then hibernate after 60 minutes

I found a post about suspending and then going into hibernate that included a really clever script. Turns out that with NixOS this is even esaier to coordinate as you have systemd so can have a before and after service. I just include this in my /etc/nixos/configuration.nix file and nixos-rebuild; then a systemctl suspend or a close of the lid will cause the hibernate timer to be set.

# -*- coding: utf-8 -*-
# Original code found at:
# https://gist.github.com/DenisFromHR/cc863375a6e19dce359d
# http://www.circuitbasics.com/raspberry-pi-i2c-lcd-set-up-and-programming/
"""
Compiled, mashed and generally mutilated 2014-2015 by Denis Pleic
Made available under GNU GENERAL PUBLIC LICENSE