Skip to content

Instantly share code, notes, and snippets.

View winstondu's full-sized avatar

Winston Du winstondu

  • Backbone
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script type="text/javascript" src="out/bundle.js"></script>
<div class="demo" style="text-align: center;">
<p>Chart Demo</p>
<div class="chartcontainer">
@winstondu
winstondu / RepeatWithBehaviorFixed.swift
Last active January 17, 2021 03:49
Fix of memory leak on RepeatWithBehavior for RxSwiftExt
//
// Observable+RepeatWhenFixed.swift
// Backbone
//
// Created by Winston Du on 1/16/21.
import Foundation
import RxSwift
import RxSwiftExt
@winstondu
winstondu / SDWebImageManagerExtension.swift
Created June 30, 2021 21:40
SDWebImageManager: Store image with transform
//
// SDWebImageManager.swift
// Backbone
//
// Created by Winston Du on 1/8/20.
//
import Foundation
import SDWebImage
@winstondu
winstondu / Interpret.ts
Last active July 12, 2021 06:15
InterpretProgram
function interpret(pgm: any): any {
let isArray = Array.isArray(pgm);
if (isArray) {
let program = pgm as any[];
switch (program[0]) {
case 'if': {
let condition: boolean = interpret(program[1]);
let trueValue = interpret(program[2]);
let falseValue = interpret(program[3]);
@winstondu
winstondu / Interpret2.js
Last active July 12, 2021 17:55
Interpret
"use strict";
const fns = {
gt: (a, b) => a > b,
lt: (a, b) => a < b,
eq: (a, b) => a === b,
add: (a, b) => a + b,
sub: (a, b) => a - b,
mul: (a, b) => a * b,
div: (a, b) => a / b,
if: (cond, a, b) => (cond ? a : b),
@winstondu
winstondu / DemoView.swift
Created November 1, 2024 21:54 — forked from JoshHrach/DemoView.swift
UIViewRepresentable Sample Code
struct ThirdPartyDemoView: View {
@State private var shouldAdd = true
@State private var currentValue = 0
var body: some View {
ThirdPartyReader { proxy in
Text("\(currentValue)")
ThirdPartyView(shouldAdd: shouldAdd)
.viewChangedValueTo { view, newValue in
currentValue = newValue