Skip to content

Instantly share code, notes, and snippets.

View reillyeon's full-sized avatar
🏳️‍🌈

Reilly Grant reillyeon

🏳️‍🌈
View GitHub Profile
@reillyeon
reillyeon / chrome_terminal_to_serial_terminal.md
Created August 20, 2022 04:11
Redirecting the Chrome terminal to a serial terminal

Instructions

The following instructions will redirect an SSH connection or local console to a connected serial device.

Step 1

Open the Terminal app or Secure Shell extension and connect to your target system.

Step 2

@reillyeon
reillyeon / async_function_return.md
Last active February 22, 2022 16:05
When does an async function return?

When does an async function return?

Someone recently asked me when an async function in JavaScript "returns". This is an interesting question because while a function like f() below has a return statement in it, f() actually returns much earlier than that. To understand how this works, let's take a look at an example function. Here, a() and c() are normal synchronous functions and b() is another asynchronous function.

async function f() {
  a();
  await b();
  return c();
}

Keybase proof

I hereby claim:

  • I am reillyeon on github.
  • I am reillyeon (https://keybase.io/reillyeon) on keybase.
  • I have a public key whose fingerprint is E626 2DE8 3DF4 AD79 B368 D44E 5508 8D13 1054 7132

To claim this, I am signing this object:

#!/usr/bin/env python3
data = b'/Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj5DOY7/5dADCACGKjHBUQ5kxlhCOF794jbuifRMKAcdwGKasRB9eR7bSXYd0irz9kKxE2hOrCIs7tHNX0JlCndVief35qbaaFH0Q5FF9vEt+ErXAKnx4p1JyphVcFfLcq+YF0iUxV3AhsDQ8WTDwqyamwlFFa4mDuesJBkDuY0IBGKtS2uVF+tGLJezmIU2kFx0UqdY527cbcJ71Pv5SioaGjVOo3Psq/WN71y04Szh96bG729s7wZJOULYZctwcMe8FMEeLEDyhvOoIpYWMVhZgLSei21JDHGZEF9uk8UUKaFXwCqYIw+sKjoLr9jvRUXyic32wSJlP6ebTFOeCTI0O3J5OO1iiRhcm4gVpJTb8C40Pj25PM1oGS67UNSJwg4clcS5dj2hHc2A0hXcBkFp+Pw0oYtvIuTNXxf6chkNagkBR9L4V64NOlN3c0mcnBS93N4LWuZdAqnNbh3qiLyZ9YCbWEfmMNvlyXyT/u3gu8xkYWYe2uzgRMBI0L4VW76RRbaDHUyBi42iv2uSeTpXY73h41G9tIAi8JvdQiwdHJp60AdAXfx0wGJ3lB02wKHIY4bh7mibCZEzUQp9dG83tX1BNVKCr8j7Qj3r2IxY+g73oVmnaCk0hPlMdZa+Ol4JqxgTlryuL+X/bMz7mMxrA2/nHD2z6F8+MaYO5wuojR0BX/k1a0IDPZOmoBJEkIPawNETQ/NqFcS3SkAXpeUJVKYQd1M1FhnssrWZ9W5aWMel4qmeYreFqnW/jcVhKjyi50ifYnoHMfUZUbWggHi7vor8mADu0kdify4ak2u+24NFrGTjozKzrLCo0ptu8oCp8YLqh5lquVENhoEzfSaZbSbLMR5OjhCsQqf0S5adwQ14tq7gM9lObWk2dJlF+wGxsrZ1oQcz1RqPpirVRl9npUVEsQn+QZEMpYdx7wMLnCHtcK+ONWaIoBhz8dBkk
@reillyeon
reillyeon / min_heap.py
Created March 25, 2014 05:34
Min heaps are one of my favorite data structures.
class MinHeap(object):
def __init__(self):
self.a = []
def insert(self, value):
self.a.append(value)
i = len(self.a) - 1
parent = (i - 1) // 2
while i != 0 and self.a[parent] > self.a[i]:
self.a[parent], self.a[i] = self.a[i], self.a[parent]
@reillyeon
reillyeon / mergesort.py
Created March 24, 2014 05:06
Merge sort.
def mergesort(a):
if len(a) <= 1:
return
mid = len(a) // 2
b = a[:mid]
mergesort(b)
c = a[mid:]
mergesort(c)
@reillyeon
reillyeon / hashtable.c
Created March 22, 2014 19:58
Playing with hash tables.
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <readline/readline.h>
#include <readline/history.h>
typedef struct HashNode {
struct HashNode *next;
char *key;
char *value;
@reillyeon
reillyeon / tree.c
Last active August 29, 2015 13:57
Playing with binary search trees.
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
#define USE_VT100 1
#if USE_VT100
#define BOX_DRAWINGS_LIGHT_VERTICAL "\x1B(0\x78\x1B(B"
#define BOX_DRAWINGS_LIGHT_DOWN_AND_HORIZONTAL "\x1B(0\x77\x1B(B"
import functools
def compute_once(f):
class ComputeOnce(object):
def __call__(self):
value = f()
self.__class__.__call__ = lambda x: value
return value
return ComputeOnce()