Skip to content

Instantly share code, notes, and snippets.

View neenjaw's full-sized avatar
:shipit:
Shippin' code

Tim Austin neenjaw

:shipit:
Shippin' code
View GitHub Profile
@neenjaw
neenjaw / simple-bench.ts
Created October 22, 2020 14:57
Simple typescript benchmarker
export const wrapBenchmark = (
fn: (...args: any[]) => any,
label?: string
): ((...args: any[]) => any) => {
return (...args) => {
const start = Date.now()
const result = fn.apply(null, args)
const end = Date.now()
console.info(`📈 BENCHMARK${label ? ` ${label}` : ''} ${end - start}ms`)
return result
function GetGreetingForSubject({subject}) {
const [isLoading, setIsLoading] = React.useState(false)
const [error, setError] = React.useState(null)
const [greeting, setGreeting] = React.useState(null)
React.useEffect(() => {
async function fetchGreeting() {
try {
const response = await window.fetch('https://example.com/api/greeting')
const data = await response.json()
setGreeting(data.greeting)
@neenjaw
neenjaw / howto.md
Created October 6, 2020 00:44
How to design programs

How to design your first programs

Design step 1) Define your goal

  • state this in a sentence or two
  • state this as a user-facing outcome

Design step 2) Define requirements

  • constraints solution needs to abide by (budget, timelinem, space, memory, etc)
@neenjaw
neenjaw / github_color.js
Created September 16, 2020 18:45
Github contribution graph color changer
const activeColorBorderStyle = "2px solid rgb(255, 0, 0)";
const inactiveColorBorderStyle = "0";
const legend = document.querySelector("ul.legend");
const svg = document.querySelector("svg.js-calendar-graph-svg");
let colorChangeEnabled = false;
let selectedColorBox = null;
let selectedColor = null;
@neenjaw
neenjaw / arithmetic_arranger.py
Created September 4, 2020 18:46
Arithmetic Arranger
from problem import ArithmeticProblem
def arithmetic_arranger(problems, show_answer=False):
try:
if len(problems) > 5:
raise ValueError("Too many problems.")
def convert_problem(s):
return str(ArithmeticProblem(s, show_answer)).splitlines()
@neenjaw
neenjaw / fizzbuzz.php
Created August 24, 2020 20:53
PHP fizzbuzz
<?php
// Approach 1
$lb = "\n";
for ($i = 1; $i <= 100; $i++)
{
if ($i % 15 === 0) {
echo "FizzBuzz $lb";
@neenjaw
neenjaw / rev2.php
Created August 24, 2020 16:03
reverse Linked list II
/**
* Definition for a singly-linked list.
* class ListNode {
* public $val = 0;
* public $next = null;
* function __construct($val = 0, $next = null) {
* $this->val = $val;
* $this->next = $next;
* }
* }
@neenjaw
neenjaw / rev.php
Created August 24, 2020 15:23
PHP reverse list
/**
* Definition for a singly-linked list.
* class ListNode {
* public $val = 0;
* public $next = null;
* function __construct($val = 0, $next = null) {
* $this->val = $val;
* $this->next = $next;
* }
* }
@neenjaw
neenjaw / list.php
Created August 24, 2020 05:18
palindrome linked list
/**
* Definition for a singly-linked list.
* class ListNode {
* public $val = 0;
* public $next = null;
* function __construct($val = 0, $next = null) {
* $this->val = $val;
* $this->next = $next;
* }
* }
@neenjaw
neenjaw / setup.md
Created August 19, 2020 04:27
Laradock and Laravel

Goal

  • Set up laravel for php/composer/nginx/mysql/phpmyadmin in a docker environment

required

  • PHP (current)
  • Composer
  • Docker
  • Git