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 / 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 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)
@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 / node_debian_init.sh
Created December 25, 2011 02:14 — forked from peterhost/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@hlian
hlian / oauth.rb
Created September 3, 2010 22:55 — forked from twoism/oauth.rb
#!/usr/bin/env ruby
%w{rubygems hmac-sha1 base64 cgi net/https uri openssl}.each{ |f| require f }
KEY = '<YOUR KEY>';
SECRET = '<YOUR SECRET>';
# encodes strings that make twitter oauth happy
def encode( string )
URI.escape( string, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]") ).gsub('*', '%2A')
end