Skip to content

Instantly share code, notes, and snippets.

View notcome's full-sized avatar

Minsheng Liu notcome

View GitHub Profile
@notcome
notcome / clean-xcode-cahce.sh
Created March 9, 2015 10:59
Clean Xcode Cache of Plug-Ins
rm -f /private/var/folders/*/*/*/com.apple.DeveloperTools/*/Xcode/PlugInCache-Debug.xcplugincache
rm -rf /private/var/folders/*/*/*/com.apple.DeveloperTools/*/Xcode/PlugInCache.xcplugincache
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad.Writer
listify :: Writer [a] () -> [a]
listify = execWriter
item x = tell [x]
main = do
@notcome
notcome / CLL.hs
Created April 22, 2015 16:43
陆陆的姓名生成器
import Control.Monad.State
import System.Random
type Range = (Int, Int) -> Int
rangify :: Int -> Range
rangify x (lo, hi) = x `mod` (hi - lo + 1) + lo
getRandomsR :: RandomGen g => State g [Range]
getRandomsR = map rangify . randoms <$> state split
@notcome
notcome / kmp.hs
Created May 26, 2015 14:08
KMP by some guy on 知乎 with “tying the knot” technique
{-# LANGUAGE NoMonomorphismRestriction #-}
module KMP3 (buildKMP , matchKMP , State) where
data State a =
State (State a) (State a) a -- State next fail char
| Aux (State a) -- Aux next
| Finish (State a) -- Finish fail
nextOf :: Eq a => State a -> a -> State a
@notcome
notcome / FixedList.hs
Created June 8, 2015 03:43
Static list with fixed length
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
@notcome
notcome / sequent_calculus.hs
Created June 27, 2015 03:14
A naïve implementation of sequent calculus.
module Calculus where
import Control.Monad (liftM2)
import Data.List (sort, permutations, nub)
import Data.Char (chr)
import Debug.Trace
data Formula = Formula Int
| Not Formula
% http://www.tutorialspoint.com/execute_matlab_online.php
n = 8;
N = zeros(n+1);
c = linspace(1,n+1,n+1);
for i=1:n+1
for j=1:n+1
N(i,j)= ((j-1)/n)^(i-1);
end
c(i)=1/c(i);
end
@notcome
notcome / IxFix.hs
Created November 21, 2015 01:43 — forked from AndrasKovacs/IxFix.hs
Example for recursion schemes for mutually recursive data
{-# LANGUAGE
UndecidableInstances, RankNTypes, TypeOperators, TypeFamilies,
StandaloneDeriving, DataKinds, PolyKinds, DeriveFunctor, DeriveFoldable,
DeriveTraversable, LambdaCase, PatternSynonyms, TemplateHaskell #-}
import Control.Monad
import Control.Applicative
import Data.Singletons.TH
#C++ 吧的吧友看过来
头疼如何共享代码嘛?来使用 Github 的 Gist 吧……
首先你需要一个 Github 的账号,不知道何为 Github 的现在就去搜索,这太可怕了。嗯嗯!
然后访问 gist dot github dot com,按照指示去做就可以了。方便吧……
最后记着防度娘抽风哦!
@notcome
notcome / editor.js
Created March 16, 2016 05:25
A simple “bidirectional” text editor prototype/proof-of-concept
logOnPageTarget = document.getElementById('log-on-page-target');
function resetOnPageLog () {
logOnPageTarget.innerText = '';
}
function logOnPage (text) {
logOnPageTarget.innerText = text + '\n' + logOnPageTarget.innerText;
}