Skip to content

Instantly share code, notes, and snippets.

@a-h
a-h / 01-simple.test.js
Last active December 31, 2023 09:07
Testing styled Material UI components with Enzyme
import React from 'react';
import { shallow } from 'enzyme';
const Item = text => <p>Item {text}</p>;
const Composition = ({ showB }) => (
<p>
<Item text="A" />
{showB && <Item text="B" />}
</p>);
@a-h
a-h / setup.tf
Last active December 8, 2023 14:56
Terraform - Creating an Instance with an S3 Bucket Policy
# Create an IAM role for the Web Servers.
resource "aws_iam_role" "web_iam_role" {
name = "web_iam_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
@a-h
a-h / two-cols-header.vue
Last active November 22, 2023 10:57
slidev two columns with header layout
<!--
Usage:
```md
---
layout: two-cols-header
---
This shows up across both
::left::
# Left
This shows on the left
@a-h
a-h / MorphiaSetupAndTearDown.java
Last active May 21, 2023 07:28
Morphia Integration Testing
import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import org.bson.Document;
import org.mongodb.morphia.AdvancedDatastore;
import org.mongodb.morphia.Morphia;
import org.mongodb.morphia.logging.MorphiaLoggerFactory;
import org.mongodb.morphia.logging.slf4j.SLF4JLoggerImplFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@a-h
a-h / go.csv
Created January 6, 2017 15:23
Github Go Projects January 2017
We can't make this file beautiful and searchable because it's too large.
repo_name
jaredwilkening/goconfig
piger/dulbecco
zemirco/uuid
kevinburke/sll
fd0/probe
maciekmm/go-steam
pyros2097/gdx
JalfResi/gobeanstalk
whosthatknocking/runc
@a-h
a-h / buildspec.yml
Last active November 3, 2022 08:31
Build Go with private dependencies on AWS CodeBuild
version: 0.2
env:
parameter-store:
build_ssh_key: "build_ssh_key"
phases:
install:
commands:
- mkdir -p ~/.ssh
@a-h
a-h / README.md
Created September 11, 2022 15:49 — forked from wpiekutowski/README.md
Apple Virtualization NixOS ISO

Run NixOS ISO using Apple Virtualization framework (for example UTM or vftool)

  • download or build ISO: nix-build -A iso_minimal_new_kernel.aarch64-linux '<nixpkgs/nixos/release.nix>'
  • copy ISO: scp "ip_addr:result/iso/*" .
  • mount: hdiutil *.iso
  • copy kernel and initrd: cp /Volumes/nixos-minimal-21/boot/Image /Volumes/nixos-minimal-21/boot/initrd .
  • find and copy kernel params: less /Volumes/nixos-minimal-21/EFI/boot/grub.cfg
  • append console=hvc0 to params
@a-h
a-h / index.js
Last active May 17, 2022 05:27
JSON logging in winston with a timestamp
const winston = require('winston');
const MESSAGE = Symbol.for('message');
const jsonFormatter = (logEntry) => {
const base = { timestamp: new Date() };
const json = Object.assign(base, logEntry)
logEntry[MESSAGE] = JSON.stringify(json);
return logEntry;
}
@a-h
a-h / stepper_motor_test.ino
Created July 3, 2021 19:01
Stepper motor test code (Arduino)
int ccw = LOW;
int step = D5;
int dir = D6;
int startDelay = 1000;
int speed = 10;
int targetDelay = 350;
void setup()
{
pinMode(step, OUTPUT);
@a-h
a-h / 01-data.tsv
Last active August 17, 2020 20:39
Importing data into DynamoDB - code for blog post
ngram year match_count page_count volume_count
# 1574 1 1 1
# 1584 6 6 1
# 1614 1 1 1
# 1631 115 100 1
# 1632 3 3 1
# 1635 1 1 1
# 1640 1 1 1
# 1641 1 1 1
1935 2 2 1