Skip to content

Instantly share code, notes, and snippets.

View tungd's full-sized avatar
🐳
Back to normal

Tung Dao tungd

🐳
Back to normal
View GitHub Profile
@tungd
tungd / TemplageEngineTest.hs
Created November 17, 2017 02:21
Template Engine Test in Haskell. So far: Lucid is 10x faster than Mustache, and is 200x faster than EDE
#!/usr/bin/env stack
-- stack --resolver lts-9.13 --install-ghc runghc --package scotty
-- --package wai --package wai-middleware-prometheus --package warp --package text --package unix
-- --package lucid --package ede --package mustache
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.IO.Class
import Data.HashMap.Strict (fromList)
@tungd
tungd / pagekit.conf
Last active May 25, 2017 03:36 — forked from DarrylDias/pagekit.conf
NGINX config for PageKit. (Tested on Debian 8)
server {
listen 80;
listen [::]:80;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
root /var/www/justnofap.club;
#!/usr/bin/env stack
-- stack --resolver lts-8.13 --install-ghc runghc --package scotty --package fb
-- --package text --package http-client --package http-client-tls
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad.Trans (lift)
import Control.Monad.Trans.Resource
import qualified Data.Text.Lazy as T
import Facebook
@tungd
tungd / Dockerfile
Last active March 13, 2017 08:44
Dockerize Heroku's Django Chat example
FROM python:2
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ADD requirements.txt /usr/src/app
RUN pip install --no-cache-dir -r requirements.txt
ADD . /usr/src/app
@tungd
tungd / css-helper.el
Created December 14, 2016 02:26
CSS Specificity explain in Emacs Lisp
;;; css-helper.el --- CSS Mode helper functions
;;;
;; Author: Tung Dao <me@tungdao.com>
;; Version: 0.1
;;
;; This file is NOT part of GNU Emacs
;;
;;; License: BSD http://opensource.org/licenses/BSD-3-Clause
;;
;; Copyright (c) 2012, Tung Dao
@tungd
tungd / css-helper.el
Created December 14, 2016 02:26
CSS Mode helper functions:
;;; css-helper.el --- CSS Mode helper functions
;;;
;; Author: Tung Dao <me@tungdao.com>
;; Version: 0.1
;;
;; This file is NOT part of GNU Emacs
;;
;;; License: BSD http://opensource.org/licenses/BSD-3-Clause
;;
;; Copyright (c) 2012, Tung Dao
@tungd
tungd / index.js
Created October 24, 2016 02:58
Hot reloading for `create-react-app` with Redux and React Router using Webpack HMR
import React from 'react'
import ReactDOM from 'react-dom'
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import { Provider } from 'react-redux'
import { Router, browserHistory, applyRouterMiddleware } from 'react-router'
import { useScroll } from 'react-router-scroll'
@tungd
tungd / observable-store.js
Created June 30, 2016 09:15
How use Rx.Observable in-place of Redux store
import update from 'react/lib/update'
import { Observable, Subject, ReplaySubject } from 'rx'
const INITIAL_STATE = {
user: null
}
const updates = new ReplaySubject()
export const state = Observable.of(INITIAL_STATE)
.merge(updates.map(change => state => update(state, change)))
#!/usr/bin/env bash
BATCH_SIZE=250
mkdir output
count=0
for file in *.jpg; do
convert -resize 256x256\! "$file" "output/$file" &
let count+=1
@tungd
tungd / sml-tramp.txt
Created December 28, 2014 23:25
Smart Mode Line/Tramp profile. Open with `profiler-find-profile`.
[profiler-profile "24.3" cpu #s(hash-table size 730 test equal rehash-size 1.5 rehash-threshold 0.8 data ([nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil] 359 [tramp-dissect-file-name tramp-file-name-method string= tramp-smb-file-name-p tramp-find-foreign-file-name-handler tramp-file-name-handler file-name-directory ange-ftp-file-attributes apply byte-code ange-ftp-hook-function apply tramp-ftp-file-name-handler apply byte-code byte-code] 1 [byte-code ange-ftp-wait-not-busy ange-ftp-raw-send-cmd ange-ftp-send-cmd ange-ftp-file-modtime ange-ftp-file-attributes apply byte-code ange-ftp-hook-function apply tramp-ftp-file-name-handler apply byte-code byte-code tramp-file-name-handler file-attributes] 99 [byte-code ange-ftp-wait-not-busy ange-ftp-raw-send-cmd "#<compiled 0x411a05d1>" apply ange-ftp-call-cont ange-ftp-process-filter accept-process-output byte-code ange-ftp-wait-not-busy ange-ftp-raw-send-cmd ange-ftp-send-cmd ange-ftp-file-modtime ange-ftp-file-attributes apply byte-code] 112 [byte