Skip to content

Instantly share code, notes, and snippets.

Avatar

Minsheng Liu notcome

  • XNZG
  • Hangzhou, China
View GitHub Profile
View uninhabited-in-struct.swift
protocol DoSomething {
func f()
}
enum Empty {}
extension Empty: DoSomething {
func f() {}
}
@notcome
notcome / Suduko.js
Created Jun 6, 2019
A suduko solver that I wrote on DL89.
View Suduko.js
// 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 Jan 24, 2019
Tuned Swift for completely unscientific benchmark
View main.swift
// 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
View minimal.py
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 Apr 10, 2018
Read and write RSA keys using Keychain Services
View security.swift
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 Mar 26, 2018
Example of using Turtle
View install-desktop-apps.sh
#!/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 Aug 11, 2017
XeLaTeX inside Docker
View xelatex.sh
#!/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"
@notcome
notcome / CrashQueue.cpp
Last active Aug 1, 2017
A simple threading pool backed parallel computing class
View CrashQueue.cpp
#include <iostream>
#include <atomic>
#include <vector>
#include <thread>
#include <functional>
#include <condition_variable>
#include <mutex>
#include <random>
#include <algorithm>
#include <tuple>
@notcome
notcome / transition.html
Created Jun 30, 2017
Slideshow effects with CSS transitions.
View transition.html
<!DOCTYPE html>
<html>
<head>
<title>Transition</title>
<style type="text/css">
#container {
width: 512px;
margin: auto;
height: 512px;
overflow: hidden;
@notcome
notcome / LH.hs
Created May 19, 2017
Liquid Haskell issues
View LH.hs
{-@ LIQUID "--exact-data-con" @-}
{-@ LIQUID "--higherorder" @-}
{-@ LIQUID "--totality" @-}
{-@ LIQUID "--automatic-instances=liquidinstances" @-}
module A where
import qualified Prelude
import Prelude (Char, Int, Bool (..))
import Language.Haskell.Liquid.ProofCombinators
You can’t perform that action at this time.