Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View notcome's full-sized avatar

Minsheng Liu notcome

View GitHub Profile
@notcome
notcome / LH.hs
Created May 19, 2017 19:35
Liquid Haskell issues
{-@ 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
@notcome
notcome / Lib.hs
Created May 5, 2017 03:49
Play with FFI in Haskell
{-# LANGUAGE CPP, ForeignFunctionInterface #-}
module Lib where
import Data.Word
import Foreign
import Foreign.C.Types
import Foreign.C.Error
import Foreign.C.String
@notcome
notcome / mmap1.cpp
Created May 3, 2017 19:51
Play mmap
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>
int main() {
int fd = open("./test_file", O_RDWR);
@notcome
notcome / runlatex.hs
Created February 28, 2017 08:39
Haskell as script via Turtle, an example
#!/usr/bin/env stack
-- stack --install-ghc runghc --package turtle
{-# LANGUAGE OverloadedStrings #-}
import Turtle
main = do
containerArg <- format (fp%":/latex") <$> pwd
userArgs <- arguments
@notcome
notcome / Dockerfile
Created January 28, 2017 02:32
Docker/minsheng/latex: first version
FROM debian:sid
MAINTAINER Minsheng Liu <lambda@liu.ms>
RUN apt-get update && apt-get install -y --no-install-recommends \
asymptote \
biber \
chktex \
cm-super \
context \
dvidvi \
@notcome
notcome / battery.css
Last active January 4, 2017 04:47
Time Battery: show the time left for the current day, in the form of remaining percentage of a battery.
body {
background-color: #1A1A1A;
font-family: -webkit-system-font, sans-serif;
}
main {
width: 300px;
margin-top: calc(40vh - 82px);
margin-left: auto;
@notcome
notcome / POJ1093.Swift
Created January 1, 2017 20:05
An example of how to employ modern syntactic sugars in writing ACM ICPC code.
// POJ 1093
// This problem asks us to justify monospaced texts with a given width.
// For details, see http://poj.org/problem?id=1093.
let email = "Writing e-mails is fun, and with this program, they even look nice."
let width = 25
let words = email.characters.split(separator: " ").map { String($0) }
let metrics: [Int] = words.map { $0.characters.count }
@notcome
notcome / JavaScript.swift
Created October 21, 2016 16:24
What if we write web app in Swift
//: Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
class Node {}
class NodeList {}
enum MutationRecord {
@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;
}
@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