Skip to content

Instantly share code, notes, and snippets.

@WesleyAC
WesleyAC / asm.py
Created June 24, 2019 03:04
janky z80 assembler
#!/usr/bin/env python3
# vim: ts=11
# Copyright 2019 Google LLC
# SPDX-License-Identifier: Apache-2.0
#
# A SUPER JANK Z80 assembler, written to see if writing a assembler that parses
# the opcode table was reasonable.
# (see https://twitter.com/WAptekar/status/1142828240874221568)
#
@jokeru
jokeru / aws_delete-default-vpc.sh
Created March 31, 2018 15:14
Script to delete all AWS default VPCs from all regions using AWS CLI
#!/usr/bin/env bash
if [ "$AWS_PROFILE" = "" ]; then
  echo "No AWS_PROFILE set"
  exit 1
fi
for region in $(aws ec2 describe-regions --region eu-west-1 | jq -r .Regions[].RegionName); do
@ErikAugust
ErikAugust / spectre.c
Last active April 15, 2024 13:55
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@gigamonkey
gigamonkey / criteria.txt
Last active January 5, 2020 06:21
Hiring criteria: looking for the ability to …
Write a program that does what it’s supposed to do
Write idiomatic code
Debug a program that you wrote
Debug a program someone else wrote
Debug the interaction between a system you wrote and one you didn’t
File a good bug report
Modify a program you didn’t write
Test a program you wrote
Test a program you didn’t write
Learn a new programming language
@varemenos
varemenos / 1.README.md
Last active April 21, 2024 23:21
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@SrPeixinho
SrPeixinho / gist:3c34f66fd86f12af165f
Last active August 29, 2015 14:23
Syntax considered harmful
-- When your code grows too big for a line:
separateParens = foldr (\ head tail -> if head == '(' then head : ' ' : tail else if head == ')' then ' ' : head : tail else head : tail) []
-- Your natural instinct is to add new lines and comments:
separateParens =
foldr (\ head tail ->
if head == '('
then head : ' ' : tail -- inserts space after left parens
@sdiehl
sdiehl / state.hs
Created January 13, 2015 18:44
State monad implementation + example
import Control.Monad
-------------------------------------------------------------------------------
-- State Monad Implementation
-------------------------------------------------------------------------------
newtype State s a = State { runState :: s -> (a,s) }
instance Monad (State s) where
return a = State $ \s -> (a, s)
@shashi
shashi / measure.jl
Last active August 29, 2015 14:08
arithmetic for relative length measures
abstract Measure
immutable Length{unit} <: Measure
value::Float64
end
abstract MeasureOp{n} <: Measure
abstract UnaryOp{A} <: MeasureOp{1}
abstract ScalarOp{A} <: MeasureOp{2}
abstract BinaryOp{A, B} <: MeasureOp{2}
@merijn
merijn / MyState.hs
Last active January 15, 2021 19:20
MyState homework
data MyState s a = MyState (s -> (a, s))
get :: MyState s s
get = undefined
put :: s -> MyState s ()
put = undefined
modify :: (s -> s) -> MyState s ()
modify = undefined