Skip to content

Instantly share code, notes, and snippets.

@bryanbanda
bryanbanda / ColorExt.swift
Created March 16, 2024 09:01 — forked from m1guelpf/ColorExt.swift
Source for the Underlay demo
import SwiftUI
extension Color {
static var background: Color {
return Color(uiColor: .systemBackground)
}
static var secondaryBackground: Color {
return Color(uiColor: .secondarySystemBackground)
}
@bryanbanda
bryanbanda / index.html
Created March 4, 2024 20:06 — forked from oaluna/index.html
Stripe Website Gradient Animation
<html>
<head>
<title>Stripe Gradient</title>
</head>
<body>
<canvas id="gradient-canvas" data-js-darken-top data-transition-in>
<!--
Remove data-js-darken-top to keep the same brightness in the upper part of the canvas
-->
</canvas>
@bryanbanda
bryanbanda / compinit.zsh
Created September 24, 2022 18:27 — forked from ctechols/compinit.zsh
Speed up zsh compinit by only checking cache once a day.
# On slow systems, checking the cached .zcompdump file to see if it must be
# regenerated adds a noticable delay to zsh startup. This little hack restricts
# it to once a day. It should be pasted into your own completion file.
#
# The globbing is a little complicated here:
# - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct.
# - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error)
# - '.' matches "regular files"
# - 'mh+24' matches files (or directories or whatever) that are older than 24 hours.
autoload -Uz compinit

This is explaining stuff relevant to AOC 2021 day 6

How is a matrix used to count fish?

First lets do fibonacci numbers because it's smaller (2x2 matrix instead of 9x9) and it's familiar ground.

So you can implement fibs like this:

def fib(n):
@bryanbanda
bryanbanda / gist:be79121ecca85501f09ee266f6d68f22
Created March 8, 2019 12:09 — forked from oddnoc/gist:3280068
Handy git config settings
# Some of these settings came from http://cheat.errtheblog.com/s/git
[alias]
br = branch
brav = branch -avv
brv = branch -vv
ci = commit
co = checkout
contributors = shortlog -se
df = diff
@bryanbanda
bryanbanda / Dockerfile
Created February 12, 2019 13:43 — forked from thesandlord/Dockerfile
ConfigMaps and Secrets with Kubernetes
# Copyright 2017, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
FROM node:6-onbuild
EXPOSE 3000
ENV LANGUAGE English
ENV API_KEY 123-456-789
@bryanbanda
bryanbanda / Dockerfile
Created December 31, 2018 22:47 — forked from remarkablemark/Dockerfile
Install node and npm with nvm using Docker.
# set the base image to Debian
# https://hub.docker.com/_/debian/
FROM debian:latest
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
@bryanbanda
bryanbanda / GoConcurrency.md
Created August 30, 2018 14:25 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@bryanbanda
bryanbanda / Price-Time Matching Engine.c
Created August 17, 2018 14:34 — forked from Jud/Price-Time Matching Engine.c
Price-Time Matching Engine
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@bryanbanda
bryanbanda / JavaScriptSafeNavigation.md
Created February 17, 2016 07:17 — forked from d-akara/JavaScriptSafeNavigation.md
JavaScript Safe Navigation

Experimental Safe JavaScript Navigation

Implemented using ES6 Proxies and Symbols

Suggestions for improvements welcome!

const nonNavigableTarget = Symbol();

function safe(target, defaultValue) {