Skip to content

Instantly share code, notes, and snippets.

View wulymammoth's full-sized avatar
processing unit

David W wulymammoth

processing unit
View GitHub Profile
This file has been truncated, but you can view the full file.
directive @requiredCapabilities(
requiredCapabilities: [String!]
) on ARGUMENT_DEFINITION | ENUM | ENUM_VALUE | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | INPUT_OBJECT | INTERFACE | OBJECT | SCALAR | UNION
"""
Marks an element of a GraphQL schema as only available via a preview header
"""
directive @preview(
"""
The identifier of the API preview that toggles this field.
@wulymammoth
wulymammoth / subclass_registry.py
Last active February 20, 2023 17:24
Python 3: registry with auto-subclass registration
from abc import abstractmethod
from collections import defaultdict
from dataclasses import dataclass
from typing import Any
from typing import Union
@dataclass(frozen=True)
class Event:
name: str
@wulymammoth
wulymammoth / authorYourOwnUnitTests.js
Created June 20, 2022 19:24
How to write your own test cases and test
/*
You are given an array `numbers` and an integer `pivot`
Your task is to return a new array in with the i-th element equals:
- 0 if numbers[i] is zero
- 1 if numbers[i] and the pivot have the same sign
- -1 if the numbers[i] and the pivot have differing signs
*/
function assessNums(nums, pivot) {
const output = []
@wulymammoth
wulymammoth / alacritty-tmux-vim_truecolor.md
Created June 8, 2022 22:45 — forked from evantancy/alacritty-tmux-vim_truecolor.md
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh
bash 24-bit-color.sh
@wulymammoth
wulymammoth / graph-stuff.md
Last active January 16, 2022 19:18
graphs

graph theory stuff

trees

  • components
    1. nodes
    2. branches (binary trees have 2, others have n)

graphs

@wulymammoth
wulymammoth / elixir-chained-assertions.exs
Last active January 7, 2022 04:13
chained/pipeline assertions in elixir
defmodule TestHelper do
defmacro __using__(_opts) do
quote do
import ExUnit.Assertions, only: [assert: 1]
# we can name this whatever we'd like,
# but "is" makes sense to me in most cases
# 👇
def is(result, expectation) do
assert result == expectation

Girls in Tech // Putting It Together: NodeJS, API hook up & React

Who am I?

David Wu

  • contact
    • twitter: @wulymammoth
    • github: github.com/wulymammoth
@wulymammoth
wulymammoth / vimgrep.md
Created March 13, 2021 20:41 — forked from seanh/vimgrep.md
vimgrep cheatsheet

vimgrep

  • Vimcasts on vimgrep

  • Uses native vim regexes (which are slightly different from the regexes used by grep, ack, ag, etc) so the patterns are the same as with vim's within-file search patterns.

You can do a normal within-file search first, then re-use the same pattern to

'queue implemented with a list (dyanmic array) with O(n) time operations'
class Queue:
def __init__(self):
self.data = [] # using a python list here instead of array (we need dynamic sizing)
def enqueue(self, item):
self.data.append(item)
def dequeue(self):
remaining = self.data[1:] # slices from index 1 to the end of the list
@wulymammoth
wulymammoth / recursion.exs
Last active January 7, 2022 04:14
nth-Fibonacci (in elixir) : naive and TCO (tail-call optimized)
# naive will not work for larger values of N
defmodule FibNaive do
def n(0), do: 0
def n(1), do: 1
def n(2), do: 1
def n(n), do: n(n - 1) + n(n - 2)
end
# tail-call optimized (employing dynamic programming)
defmodule FibTailCall do