Skip to content

Instantly share code, notes, and snippets.

View notcome's full-sized avatar

Minsheng Liu notcome

View GitHub Profile
@notcome
notcome / promotion.swift
Created June 10, 2025 07:43
SwiftUI gains ProMotion
import UIKit
import SwiftUI
import QuartzCore
var lastMediaTime: CFTimeInterval? = nil
struct YOffsetEffect: GeometryEffect {
var y: CGFloat
var animatableData: CGFloat {
get { y }
@notcome
notcome / index.ts
Created March 5, 2025 10:47
A faster Deno vite plugin
import { Plugin } from 'vite'
import fsp from 'node:fs/promises'
import { transform } from "esbuild";
import {
isDenoSpecifier,
mediaTypeToLoader,
parseDenoSpecifier,
resolveDeno,
ResolvedInfo,
toDenoSpecifier,
@notcome
notcome / sudoku.js
Created September 11, 2022 15:42
Sudoku v2
const zeroToEight = [0, 1, 2, 3, 4, 5, 6, 7, 8]
const oneToNine = zeroToEight.map(x => x + 1)
function rowCoords({ x, y }) {
return zeroToEight.map(i => { return { x, y: i } })
}
function colCoords({ x, y }) {
return zeroToEight.map(i => { return { x: i, y } })
}
protocol DoSomething {
func f()
}
enum Empty {}
extension Empty: DoSomething {
func f() {}
}
@notcome
notcome / Suduko.js
Created June 6, 2019 01:29
A suduko solver that I wrote on DL89.
// This solver is semi-automaitc and you can see how possibilites are removed through each step.
// It turns out that the hard mode has more than one possible solution, so next time when you
// are stuck, just try one manually.
const zeroToEight = [0, 1, 2, 3, 4, 5, 6, 7, 8]
const oneToNine = zeroToEight.map(x => x + 1)
function rowCoords({ x, y }) {
return zeroToEight.map(i => { return { x, y: i } })
}
@notcome
notcome / main.swift
Created January 24, 2019 02:01
Tuned Swift for completely unscientific benchmark
// roughly 1.8x of best tuned solution.
// quite concerning since I have written a pool manually and added a GC for better cache locality.
import Foundation
struct Node {
var x: Int
var y: Int
var left: Int = -1
var right: Int = -1
import torch
import torch.nn as nn
import torch.nn.functional as F
vocabSize = 30000
hiddenSize = 128
batchSize = 16
seqSize = 128
class Net(nn.Module):
@notcome
notcome / security.swift
Created April 10, 2018 01:01
Read and write RSA keys using Keychain Services
import Foundation
import CoreFoundation
import Security
/*
* Following operations will be supported:
* - generate a new keypair
* - export an existing keypair in PKCS12 format
* - delete an existing keypair
*
@notcome
notcome / install-desktop-apps.sh
Created March 26, 2018 05:27
Example of using Turtle
#!/usr/bin/env stack
-- stack runghc --package turtle
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text.IO as T
import Turtle
exists :: MonadIO io => Text -> io Bool
exists cmd = do
@notcome
notcome / xelatex.sh
Created August 11, 2017 13:42
XeLaTeX inside Docker
#!/bin/sh
docker run \
-v $(pwd):/latex \
-v "/Users/selveskii/Library/Application Support/LaTeX/Styles":/styles \
-v "/Users/selveskii/Library/Application Support/LaTeX/Fonts":/fonts \
"minsheng/latex:latest" \
/bin/bash \
-c "export TEXINPUTS=\".:/styles:\"; xelatex $1"