Skip to content

Instantly share code, notes, and snippets.

@williamhaley
williamhaley / README.md
Last active February 12, 2023 08:51
GRUB2 Theme With grub-mkstandalone

Problem

grub-mkstandalone creates an image designed to be held in memory. grub-mkstandalone comes with a --themes flag that could be used to specify a theme, but depending on the modules installed, you may encounter this error like I did.

grub-mkstandalone: error: core image is too big (0x1d71b3 > 0x78000).

This means that the image generated by grub-mkstandalone was too large.

One Solution

@williamhaley
williamhaley / get-kinesis-records-by-shard-id-in-bash-one-liner.markdown
Last active December 20, 2018 01:01
Get Kinesis Records By Shard In Bash One Liner

One line to get all records from a stream since its StartingSequenceNumber. Just specify the shard, endpoint, and stream at the start of the script.

shard="shardId-000000000001"; endpoint="http://localhost:4567"; stream="test-stream";

See here an example pointed at kinesalite running locally.

shard="shardId-000000000001"; endpoint="http://localhost:4567"; stream="test-stream"; \
@williamhaley
williamhaley / gcd.go
Created December 29, 2018 23:17
Calculate the Greatest Common Denominator using GoLang
package main
import (
"fmt"
)
// https://www.reddit.com/r/golang/comments/7b4mt9/greatest_common_divisor/
// GreatestCommonDenominator finds the GCD of two ints
func GreatestCommonDenominator(a, b int) int {
@williamhaley
williamhaley / nginx.sh
Created January 2, 2020 00:48
Generate LetsEncrypt cert and deploy nginx from docker with HTTP basic auth
#!/usr/bin/env bash
set -x
email='whatever@gmail.com'
domain='whatever.wherever.com'
username='admin'
password='password'
# Copy this inside the container. Let's Encrypt is going to modify it automatically.
@williamhaley
williamhaley / license-audit.js
Created January 24, 2020 01:42
Get the top-level licenses of all node packages/libraries/modules and print them out in CSV
/**
* Run this script from the root of the repo you want to inspect. It's assumed
* that there's a `./node_modules` and `./package.json` where this script runs.
*/
const packageJSON = require('./package.json');
// Get all the top-level dependencies for the current project.
const dependencies = {
...packageJSON.dependencies,
@williamhaley
williamhaley / HelloWorld.java
Last active December 16, 2020 19:58
NCP Java Demo (Hello World)
class Main {
public static void main(String[] args) {
System.out.println("hello world");
}
}
@williamhaley
williamhaley / Client.java
Last active December 16, 2020 20:01
NCP Java Demo (Client and Server)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
public class Client {
private Socket clientSocket;
private PrintWriter out;
private BufferedReader in;
@williamhaley
williamhaley / Main.java
Created December 16, 2020 20:04
NCP Java Demo (Logic)
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
class Main {
public static void main(String[] args) {
Demo demo = new Demo();
demo.doTheDemo();
@williamhaley
williamhaley / MoveLeftCommand.java
Created December 16, 2020 20:05
NCP Java Demo (Commands)
public class MoveLeftCommand extends RobotCommand {
public MoveLeftCommand(String button) {
super(button);
}
protected void logic() {
// Set up the motors
// Move the robot
// Make sure robot is in the right position
System.out.println("move left!");
@williamhaley
williamhaley / README.md
Last active January 20, 2021 20:51
A demonstration of encryption vs hashing using the full English text of the book, Alice in Wonderland

Plain text / source material

Here is the plain text English full version of Alice in Wonderland.

Hashed

Here is a hash of the entire book. Every single word, punctation mark, space, etc.

c8f5de222fcf1804197e97b0df02d30d25ab70715fcf93bb8d61c0f7b2c13acb