Skip to content

Instantly share code, notes, and snippets.

Avatar
🦫
beaver

Hao Lian hlian

🦫
beaver
View GitHub Profile
View 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 Jul 3, 2017 — forked from shauns/slack.py
Deleting and listing slack files, sorting by size
View slack.py
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)
View Singular.hs
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Singular where
import BasePrelude hiding (fold)
import Control.Monad.State
View gist:24c66a53c7780e703d183fbe968ae727
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE InstanceSigs #-}
{-# OPTIONS_GHC -Wall -fwarn-incomplete-uni-patterns #-}
module AS2 where
View D23Input.hs
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)
View gist:6150020e4dcb04100963cfcb17f1156f
====================================================================================
Lawful Neutral Chaotic
------------------------------------------------------------------------------------
Good Lisp Haskell Shell
Neutral Java Perl
Evil JavaScript
=====================================================================================
@hlian
hlian / 0Main.hs
Last active Apr 24, 2021
let's build a servant
View 0Main.hs
{-# 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)
View EmptyBaby.hs
import Data.ByteString
import Network.Wreq
main :: IO ()
main = do
r <- postWith defaults "http://requestb.in/oqbxb4oq" empty
print r
View a.json
{"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 Jan 25, 2016
use JSON files as if they were Haskell values / live life maximally with simple language semantics
View JSONBaby.hs
#!/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