Skip to content

Instantly share code, notes, and snippets.

View peterc's full-sized avatar
🏠
Working from home

Peter Cooper peterc

🏠
Working from home
View GitHub Profile
@p4bl0-
p4bl0- / 00_readme.md
Last active December 1, 2025 16:13
A complete compiler for a simple language (in less than 150 LoC)

This project is a tiny compiler for a very simple language consisting of boolean expression.

The language has two constants: 1 for true and 0 for false, and 4 logic gates: ! (not), & (and), | (or), and ^ (xor).

It can also use parentheses to manage priorities.

Here is its grammar in BNF format:

expr ::= "0" | "1"

#!/bin/bash
#
# Backs up my entire website, in case Tumblr or CloudApp goes down someday.
# Last time I ran this, it took 18 minutes.
#
wget \
--mirror `# turns on recursion and timestamping, basically says we want to "mirror" the whole site` \
--convert-links `# after download, convert all links to point to localhost` \
@duskwuff
duskwuff / dictionary.bin
Last active December 30, 2025 23:04
Contents of the Brotli dictionary (JSON encoded)
"time"
"down"
"life"
"left"
"back"
"code"
"data"
"show"
"only"
"site"

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@sburns
sburns / example-lambda-gha.yml
Last active December 4, 2020 23:23
This is an example GitHub Actions workflow to continuously deploy a Lambda function.
name: example CICD
on:
push:
branches:
- master
paths:
# only commits containing changes under these paths will trigger this workflow
- 'services/example/**'
- 'lib/example/**'
@texodus
texodus / .block
Last active June 4, 2022 04:41
regular-table / Minesweeper
license: apache-2.0
@PierBover
PierBover / explanation.md
Created May 8, 2020 15:55
FQL recursive function to get nested documents

This is how you'd call the function:

Call(Function("GetNestedDocument"), [Ref(Collection("SomeCollection"), "264260207986606612"), 0, 3])

Parameters:

  • A Ref of a document.
  • Current depth. Since AFAIK we cannot have default values in Lambda we need to pass 0 for the first level.
  • Max depth. The max number of levels the recursive function will go.
@miry
miry / 01_dynamodb_get_all.rb
Last active September 30, 2022 02:53
Sample to get all items from DynamoDB table
# frozen_string_literal: true
require 'aws-sdk-dynamodb'
require 'hirb'
# NOTICE: Authorize via https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
dynamodb = Aws::DynamoDB::Client.new
scan_opts = { table_name: '<TABLE_NAME>' }
items = []
@IanColdwater
IanColdwater / twittermute.txt
Last active December 6, 2025 11:37
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@moyix
moyix / tree.sh
Created December 16, 2019 23:45
A very silly script to make a Christmas tree with 224 cores in htop
# Upper
cpulimit -l 1 -- taskset -c 0 ./pct
cpulimit -l 18 -- taskset -c 1 ./pct
cpulimit -l 35 -- taskset -c 2 ./pct
cpulimit -l 52 -- taskset -c 3 ./pct
cpulimit -l 69 -- taskset -c 4 ./pct
cpulimit -l 86 -- taskset -c 5 ./pct
cpulimit -l 103 -- taskset -c 6 ./pct
cpulimit -l 1 -- taskset -c 63 ./pct