Skip to content

Instantly share code, notes, and snippets.

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

Nathan Marley nmarley

🦀
我想吃一點點東西。
View GitHub Profile
@nmarley
nmarley / README.md
Last active April 4, 2024 16:47
Go / C++ bindings example

Go / C++ bindings example

This is an example of Go code calling to a C++ library with a C wrapper.

Build

go build  # this only ensures it compiles
@nmarley
nmarley / dec.py
Last active August 8, 2023 13:55
AWS KMS encryption/decryption using Python/Boto3
import boto3
import base64
if __name__ == '__main__':
session = boto3.session.Session()
kms = session.client('kms')
encrypted_password = 'AQECAHjgTiiE7TYRGp5Irf8jQ3HzlaQaHGYgsUJDaavnHcFm0gAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDDwxVQuG0oVwpkU7nQIBEIAoVGk1/wpserb+GVUOzE7PiL/Nr9fTDFKZfpKpF0ip2ct4B2q0Wn6ZZw=='
binary_data = base64.b64decode(encrypted_password)
@nmarley
nmarley / kapture.sh
Created July 18, 2013 01:43
OSX can capture WiFi packets using only tcpdump (and without needing a clunky interface such as KisMAC). Used for testing security strength of home WiFi setup.
#! /bin/bash
# This is for Mac OSX only.
# =============================================
# explanation of arguments used with 'tcpdump':
# =============================================
# -y IEEE802_11_RADIO => makes it capture __WIFI__ packets, turns resultant file
# into a dump which can be read by aircrack-ng, etc.
#
# -I => puts interface into monitor mode (required to capture packets)
@nmarley
nmarley / filter.sh
Created May 15, 2017 14:12
CloudTrail log parsing/event selection with jq
# `aws s3 sync` the cloudtrail files you want into a dir, then...
cat * | jq '.Records[] | select(.eventSource == "kms.amazonaws.com")' | jq '.userIdentity.arn'
@nmarley
nmarley / README.md
Last active February 8, 2023 15:31
JSON Schema validation example in Node.JS

test json schema validation in Node.JS

Setup Package

$ npm i jsonschema --save

Test/Play:

$ node ./v.js
@nmarley
nmarley / README.md
Last active January 8, 2023 19:16
Rust macro testing

Rust macro testing

rustc --test test2.rs
@nmarley
nmarley / docker_cid.sh
Created December 8, 2016 13:58
Docker — get container ID from within Docker container
bash-4.3# cat /proc/1/cpuset
/docker/13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e
bash-4.3# DOCKER_CID=$(cat /proc/1/cpuset | cut -c9-)
bash-4.3# echo $DOCKER_CID
13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e
@nmarley
nmarley / out.txt
Created June 16, 2022 20:22
testnet debug log analysis
("masternode-1", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:55 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-2", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-3", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-4", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-5", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:55 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-6", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-7", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 1
@nmarley
nmarley / gencert.rb
Last active April 29, 2022 21:20
Ruby script to generate SSL certificates
#! /usr/bin/env ruby
#
# gencert.rb
# =====================================================================
# description: This script will accepts an FQDN as an argument
# and generates a Secure Sockets Layer (SSL)
# certificate request and a private key that corresponds
# to the request. It will not overwrite any existing
# files, so file <fqdn>.cnf , <fqdn>.csr , or <fqdn>.key
# exist, the program will print a message and exit.
@nmarley
nmarley / main.rs
Last active April 23, 2022 12:53
Example of sending interrupt using Rust mpsc channel
use std::sync::mpsc::{channel, Sender};
pub struct PPU {
// data...
cycles: u8,
nmi_channel: Sender<bool>,
}
impl PPU {
pub fn new(chan: Sender<bool>) -> Self {