Skip to content

Instantly share code, notes, and snippets.

View nmarley's full-sized avatar
🦀
我想吃一點點東西。

Nathan Marley nmarley

🦀
我想吃一點點東西。
View GitHub Profile
@nmarley
nmarley / get-latest-alpine-ami.sh
Last active April 13, 2021 15:18
Get latest Alpine AMI
#! /bin/bash
# get latest alpine linux AMI
aws ec2 describe-images --output text --filters Name=owner-id,Values=538276064493 Name=name,Values='alpine-ami-3.13*-x86_64*' Name=architecture,Values=x86_64 Name=state,Values=available --query 'max_by(Images[], &CreationDate).ImageId'
@nmarley
nmarley / README.md
Last active March 29, 2021 10:26
Go fresh install Ubuntu 18.04

Go install using gvm on fresh Ubuntu instance

Install

Using a fresh Ubuntu 18.04 (latest LTS) install:

# Install prerequisites
sudo apt update
sudo apt install -y bison binutils gcc make
@nmarley
nmarley / most-recent-ubuntu-ami.sh
Last active February 11, 2021 00:28
AWS EC2: Search most recent Ubuntu AMI for all regions
#! /bin/bash
# search based on prefix and most recent date
IMAGE_PREFIX="ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-"
# Canonical (makers of Ubuntu)
OWNER_ID="099720109477"
for REGION in $(aws ec2 describe-regions | jq -r '.Regions[].RegionName'); do
IMAGE_ID=$(aws ec2 describe-images --region "${REGION}" --filters "Name=name,Values=${IMAGE_PREFIX}*" --owners "$OWNER_ID" | jq -r '.Images | sort_by(.CreationDate)[-1].ImageId')
@nmarley
nmarley / .gitignore
Last active November 27, 2020 12:55
LOD parser in Go (parse Luxembourg Online Dictionary XML files) basic PoC
# ignore the ignore/ dir
ignore/
@nmarley
nmarley / README.md
Last active May 13, 2020 21:46
Python JSON Schema validation example

test json schema validation

Setup Virtualenv

$ virtualenv ./venv
$ ./venv/bin/pip install -r requirements.txt

Test/Play:

$ ./venv/bin/python ./v.py

@nmarley
nmarley / main.go
Created December 12, 2019 18:44
Go basic recursion on string parts
package main
import (
"fmt"
"os"
"regexp"
"strings"
)
var reS3KeyPDFUpload = regexp.MustCompile(`^.*\/(?P<year>\d{4})\/(?P<month>\d{2})\/(?P<day>\d{2})\/.*\.pdf$`)
@nmarley
nmarley / 32.asm
Created December 1, 2019 16:58 — forked from FiloSottile/32.asm
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4
@nmarley
nmarley / format-hex-bytes.go
Created September 27, 2019 00:20
Format byte slice as hex digits
package main
import (
"fmt"
)
func dispByteSlice(slice []byte) {
for i, b := range slice {
if (i % 8) == 0 {
fmt.Printf("\n")
@nmarley
nmarley / README.md
Last active September 12, 2019 17:09
Example using Rui Marinho's "bitcoin-core" Bitcoin daemon client library

Example of "bitcoin-core" Node.js client usage

This is an example using Rui Marinho's "bitcoin-core" Bitcoin daemon JSONRPC and REST client library.

Install

npm ci
@nmarley
nmarley / pubkey_to_address.js
Last active September 10, 2019 11:45
Ethereum public key hex string to address
var eu = require('ethereumjs-util')
var uncompressed_public_key_hex = '04320c6bb9c30cd4ee54484ad10b01d2742105a70b9333b2310be8e870344f18f23d70897cf0588510fc28cf76b637902179cc2d3ead649718bef61c6eb95cec7e'
var upk_buf = new Buffer(uncompressed_public_key_hex, 'hex')
var addr_buf = eu.pubToAddress(upk_buf.slice(1,65))
var addr = addr_buf.toString('hex')
console.log("addr: " + eu.toChecksumAddress(addr) )