Skip to content

Instantly share code, notes, and snippets.

View hlian's full-sized avatar
🦫
beaver

Hao Lian hlian

🦫
beaver
View GitHub Profile
@hlian
hlian / keybase.md
Created December 4, 2018 22:01
keybase.md

Keybase proof

I hereby claim:

  • I am hlian on github.
  • I am hao (https://keybase.io/hao) on keybase.
  • I have a public key ASCf_0xWrJ2RajE5uHqk_tjPngCqpxLWFvaJYuqRvevlWQo

To claim this, I am signing this object:

@hlian
hlian / slack.py
Created July 3, 2017 18:54 — forked from shauns/slack.py
Deleting and listing slack files, sorting by size
from slacker import Slacker
import itertools
slack = Slacker('<API TOKEN>')
pages = slack.files.list(page=1).body['paging']['pages']
all_the_files = list(itertools.chain(*[slack.files.list(page=i).body['files'] for i in range(1,pages + 1)]))
biggest_first = sorted(all_the_files, key=lambda f: f['size'], reverse=True)
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Singular where
import BasePrelude hiding (fold)
import Control.Monad.State
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE InstanceSigs #-}
{-# OPTIONS_GHC -Wall -fwarn-incomplete-uni-patterns #-}
module AS2 where
@hlian
hlian / D23Input.hs
Last active December 23, 2016 06:06 — forked from anonymous/-
module D23 where
import BasePrelude hiding ((&), lookup, loop)
import Control.Lens
import qualified Data.Vector as Vector
import D23Input
type State = (Int, Map Char Int, Vector Op)
env :: Int -> State
env i = (0, Map.empty & at 'a' ?~ i, input)
====================================================================================
Lawful Neutral Chaotic
------------------------------------------------------------------------------------
Good Lisp Haskell Shell
Neutral Java Perl
Evil JavaScript
=====================================================================================
@hlian
hlian / 0Main.hs
Last active April 24, 2021 06:39
let's build a servant
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Data.Text (Text)
import Network.HTTP.Types (status200)
import Network.Wai (Application, responseLBS)
import Data.ByteString
import Network.Wreq
main :: IO ()
main = do
r <- postWith defaults "http://requestb.in/oqbxb4oq" empty
print r
@hlian
hlian / a.json
Created February 25, 2016 21:51 — forked from anonymous/-
{"swagger":"2.0","info":{"version":"","title":""},"definitions":{"OptionTemplateAlgorithm":{"required":["name"],"type":"object","properties":{"name":{"type":"string"},"id":{"type":"integer"}}},"OptionIntAlgorithm":{"required":["name"],"type":"object","properties":{"name":{"type":"string"},"id":{"type":"integer"}}},"OptionDayPartAlgorithm":{"required":["name"],"type":"object","properties":{"name":{"type":"string"},"id":{"type":"integer"}}},"SelectorUTCTime":{"type":"object","description":"Could either be 'explicit', 'algorithmic', or empty","properties":{"algorithmic":{"maximum":9223372036854775807,"format":"int64","minimum":-9223372036854775808,"type":"integer"},"explicit":{"$ref":"#/definitions/UTCTime"}}},"SelectorTimeOfDay":{"type":"object","description":"Could either be 'explicit', 'algorithmic', or empty","properties":{"algorithmic":{"maximum":9223372036854775807,"format":"int64","minimum":-9223372036854775808,"type":"integer"},"explicit":{"$ref":"#/definitions/TimeOfDay"}}},"ExperimentVariantRevision":{
@hlian
hlian / JSONBaby.hs
Last active January 25, 2016 04:19
use JSON files as if they were Haskell values / live life maximally with simple language semantics
#!/usr/bin/env stack
-- stack --resolver lts-4.2 --install-ghc runghc --package file-embed --package aeson --package lens --package lens-aeson
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module JSONBaby where
import Control.Lens
import Data.Aeson