Skip to content

Instantly share code, notes, and snippets.

# Minsheng Liu notcome

Created September 11, 2022 15:42
Sudoku v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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 } }) }
Created November 16, 2020 01:50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 protocol DoSomething { func f() } enum Empty {} extension Empty: DoSomething { func f() {} }
Created June 6, 2019 01:29
A suduko solver that I wrote on DL89.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // 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 } }) }
Created January 24, 2019 02:01
Tuned Swift for completely unscientific benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 // 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
Created December 9, 2018 19:46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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):
Created April 10, 2018 01:01
Read and write RSA keys using Keychain Services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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 *
Created March 26, 2018 05:27
Example of using Turtle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #!/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
Created August 11, 2017 13:42
XeLaTeX inside Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #!/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"
Last active August 1, 2017 07:37
A simple threading pool backed parallel computing class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #include #include #include #include #include #include #include #include #include #include
Created June 30, 2017 13:26
Slideshow effects with CSS transitions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 Transition