Skip to content

Instantly share code, notes, and snippets.

@shanemikel
shanemikel / ast.rs
Created April 13, 2019 01:57
Lua parsing in Rust with Pest (operator precedence)
#[derive(Parser)]
#[grammar = "lua.pest"]
pub struct LuaParser;
lazy_static! {
static ref PREC_CLIMBER: PrecClimber<Rule> = {
use Rule::*;
use Operator as O;
use Assoc::Left as L;
@shanemikel
shanemikel / pretty_parse_tree.rs
Created April 11, 2019 03:09
pretty parse tree output (ala pest.rs)
pub fn pretty_parse_tree(pairs: Pairs<Rule>) -> String {
#[derive(Clone)]
struct State {
depth: usize,
prefix: String,
};
fn go(pairs: Pairs<Rule>, lines: &mut Vec<String>, mut state: State) {
if state.prefix.is_empty() {
let indent: String = iter::repeat(" ").take(state.depth).collect();
/* @import "./tabs_full_width.css"; */
@-moz-document url(chrome://browser/content/browser.xul)
{
/* Your style rules for the user interface go here */
:root
{
--custom-tab-border-roundness: 2px;
--custom-tab-border-width: 1px;
#!/usr/bin/env bash
if [ $# -ne 2 ]; then
echo expecting two integer arguments... aborting >&2
exit 1
fi
profile=$(readlink ~/.nix-profile)
dirA="${profile}-$1-link"

Keybase proof

I hereby claim:

  • I am shanemikel on github.
  • I am shanepearlman (https://keybase.io/shanepearlman) on keybase.
  • I have a public key whose fingerprint is 4B47 3C58 3FCF 5BEF 1464 ED34 179B D224 079A 5EE4

To claim this, I am signing this object:

@shanemikel
shanemikel / loop.sh
Created September 19, 2015 00:07
out.txt is what my shell looks like, trap.sh receives SIGINTS, sending a SIGTERM to the most recently forked loop.sh
#!/bin/bash
trap 'echo "loop $$ recieved SIGTERM; exiting" && exit' SIGTERM
for i in `seq $1 -1 1`; do
echo count = $i in loop $$
sleep 1s
done