Skip to content

Instantly share code, notes, and snippets.

View khswong's full-sized avatar

toast khswong

  • toronto
View GitHub Profile
@khswong
khswong / keybase.md
Created April 21, 2023 17:27
keybase verification

Keybase proof

I hereby claim:

  • I am khswong on github.
  • I am toastw (https://keybase.io/toastw) on keybase.
  • I have a public key ASCasT9qwSxPeNc-aDn1wkLnlgGYHq9b5n5_CBWSECbjSwo

To claim this, I am signing this object:

@khswong
khswong / blinky.py
Created December 26, 2020 02:38
its just a guy
from nmigen import *
class PWM(Elaboratable):
def __init__(self):
self.i = Signal(8)
self.o = Signal()
def elaborate(self, platform) -> Module:
m = Module()
@khswong
khswong / rot13.c
Created January 15, 2020 05:56
Quick Rot13 impl
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
const char upperAlpha[26] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char lowerAlpha[26] = "abcdefghijklmnopqrstuvwxyz";
int charPos(const char *alphabet, char letter) {
for (int i = 0; i < 26; ++i) {
if (letter == alphabet[i])
@khswong
khswong / dantzig42_d.txt
Last active December 30, 2019 03:44
Travelling salesman genetic algorithm (not optimal solution)
0 8 39 37 50 61 58 59 62 81 103 108 145 181 187 161 142 174 185 164 137 117 114 85 77 87 91 105 111 91 83 89 95 74 67 74 57 45 35 29 3 5
8 0 45 47 49 62 60 60 66 81 107 117 149 185 191 170 146 178 186 165 139 122 118 89 80 89 93 106 113 92 85 91 97 81 69 76 59 46 37 33 11 12
39 45 0 9 21 21 16 15 20 40 62 66 104 140 146 120 101 133 142 120 94 77 73 44 36 44 48 62 69 50 42 55 64 44 42 61 46 41 35 30 41 55
37 47 9 0 15 20 17 20 25 44 67 71 108 144 150 124 104 138 143 123 96 80 78 48 40 46 50 63 71 51 43 55 63 43 41 60 41 34 26 21 37 41
50 49 21 15 0 17 18 26 31 50 72 77 114 150 156 130 111 143 140 124 94 83 84 53 46 46 48 64 66 46 38 50 56 35 31 42 25 20 18 18 47 53
61 62 21 20 17 0 6 17 22 41 63 68 106 142 142 115 97 129 130 106 80 68 69 41 34 30 34 47 51 30 22 34 42 23 25 44 30 34 34 35 57 64
58 60
@khswong
khswong / nqueens.cpp
Created December 27, 2019 10:17
Practice NQueens soln
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
typedef vector<int> Queens;
typedef pair<int, int> Position;
void fmtQueens(Queens board, int n)
{
@khswong
khswong / package_jetfoiler_index.json
Last active July 19, 2019 18:57
jetfoiler M0 board package
{
"packages": [
{
"name": "Jetfoiler",
"maintainer": "Kai Concepts",
"websiteURL": "http://www.jetfoiler.com/",
"email": "kenneth@kiteboat.com",
"help": {
"online": "http://www.jetfoiler.com"
},