Skip to content

Instantly share code, notes, and snippets.

View syshen's full-sized avatar

Steven Shen syshen

View GitHub Profile
@syshen
syshen / Dockerfile
Last active March 4, 2024 01:04
Dockerfile for pandas
FROM --platform=linux/amd64 python:3.10-alpine as build
COPY ./ /src
WORKDIR /src
RUN \
apk update && \
apk add py3-pandas && \
apk add --no-cache postgresql-libs && \
apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \
@syshen
syshen / token-balance.js
Created February 15, 2023 10:34
Retrieve the balance of an ERC20 token with the block number
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('<Node API endpoint>'));
const balanceOfABI = [
{
"constant": true,
"inputs": [
{
"name": "_owner",
"type": "address"
nonMaxSuppression: function(scores, boxes) {
const self = this
let zipped = []
for (let i = 0; i < scores.length; i++) {
zipped.push([
scores[i], [boxes[4*i], boxes[4*i + 1], boxes[4*i + 2], boxes[4*i + 3]], i
])
}
computeBoundingBoxes: function(features) {
return tf.tidy(function() {
const confidenceThreshold = tf.scalar(0.5)
const num_classes = cocoClasses.length
const num_anchors = YOLO_ANCHORS.length
const anchors = tf.tensor2d(YOLO_ANCHORS)
const anchors_tensor = tf.reshape(anchors, [1, 1, num_anchors, 2])
toTensor: function(canvas) {
return tf.tidy(() => {
// Convert the ImageData to Tensor
const image = tf.fromPixels(canvas)
// The input shape of YOLO is 416x416x3, we need to crop the image
const size = this.size.width
const beginX = image.shape[1] / 2 - size / 2
const beginY = image.shape[0] / 2 - size / 2
const cropped = image.slice([beginY, beginX, 0], [size, size, 3])
tensorflowjs_converter --input_format keras yolov2-tiny.h5 web_model
python yad2k.py yolov2-tiny.cfg yolov2-tiny.weights model_data/yolov2-tiny.h5
curl https://pjreddie.com/media/files/yolov2-tiny.weights > yolov2-tiny.weights
curl https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov2-tiny.cfg > yolov2-tiny.cfg
public class PieProgressView: UIView {
public var progress:Float {
get {
return _progress
}
set {
_progress = newValue
self.updatePath()
}
@syshen
syshen / random.js
Last active October 19, 2015 05:48
var http = require("http");
var urlParser = require('url');
var names = ["Jim Chang", "Max Liu", "Sara Ku", "Sophie", "Justin", "Brendon", "Jeniffer", "Cherry", "Alice", "John", "Bill", "James", "Steven", "Steve Chen", "Bill Gates", "Steve Jobs", "Mark"]
var currencies = ["HKD", "USD", "TWD", "PHP", "MYR", "RMB", "YEN"];
var notes = ["Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven't found it yet, keep looking. Don't settle. As with all matters of the heart, you'll know when you find it.",
"Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma - which is living with the results of other people's thinking. Don't let the noise of others' opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition.",
"Innovation distinguishes between a leader and a follower.",