Skip to content

Instantly share code, notes, and snippets.

View cwli24's full-sized avatar
💭
I love 🐍 danger noodle (v3)

Chunwai Li cwli24

💭
I love 🐍 danger noodle (v3)
View GitHub Profile
@cwli24
cwli24 / min-heap.js
Last active May 2, 2022 03:09
Generic min heap class for JS (which lacks that DS built-in)
class MinHeap {
constructor(selector = x => x[0]) {
this.items = [0];
this.selector = selector;
}
insert(item) {
let childIdx = this.items.length;
this.items.push(item);
let childItem = item;
let parentIdx = Math.trunc(childIdx/2), parentItem = this.items[parentIdx];
@cwli24
cwli24 / Ruby.rs
Last active April 20, 2022 07:06
Ruby syntax 101 guide
#!/usr/bin/ruby -W0
BEGIN {
puts "This block will always run first."
print <<EOF
----------------
EOF
} # notice EOF cannot be indented
END {
print <<"up2u"
----------------
@cwli24
cwli24 / Solidity.sol
Last active April 29, 2022 23:17
Quick reference to Solidity syntax (vers. 0.8)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7; // '^' is for >= this version
/* DISCLAIMER:
This is a sample that provides a brief overview and glimpse into the basics of Solidity 0.8 types and language structure.
It is a quick breakdown meant for those with previous coding experience. All the highlights and key points are noted as comments.
With the economics and scalability-congestion of ETH in mind, search for "GAS" tips that help lower the cost of your contract executions.
*/
contract HelloWorld {
string public myString = "hello world";
@cwli24
cwli24 / mp0.asm
Last active April 29, 2022 21:15
[ECE411] Testing/simple prog code for the 3 MPs in Assembly
;; Calculates factorial of arbitrary number using LC-3b assembly. (Only LDR/STR/ADD/AND/NOT/BR instructions supported.)
ORIGIN 4x0000
SEGMENT CodeSegment:
;; Assuming all registers, specifically R0, are zeroed at beginning
;; R0 - x0000 throughout program for convenience due to limited instrs
;; R1 - accumulator of final factorial RESULT ("s")
;; R2 - down counter of 's' additions in each round (inner loop, "j")
;; R3 - down counter of factorial rounds from x to 0 (outer loop, "i")
;; R4 - 's' at the beginning of reach round ("n")
;; R5 - contain decrement value (-1) for convenience
@cwli24
cwli24 / new-forward.cuh
Created January 23, 2018 04:58
[ECE408] Parallelizing CNN computation using CUDA
#ifndef MXNET_OPERATOR_NEW_FORWARD_CUH_
#define MXNET_OPERATOR_NEW_FORWARD_CUH_
#define TILE_WIDTH 24 // has to be a multiple of this to get correctness = 0.8562
//#define TILE_WIDTH 8
#include <mxnet/base.h>
namespace mxnet
{
namespace op