Skip to content

Instantly share code, notes, and snippets.

View liangzan's full-sized avatar

Wong Liang Zan liangzan

View GitHub Profile
@liangzan
liangzan / recursiveRemoveFiles.js
Created February 2, 2011 14:12
A Node.js script to remove all files in a directory recursively
var fs = require('fs')
, path = require('path')
, _ = require('underscore');
var rootPath = "/path/to/remove";
removeDirForce(rootPath);
// path should have trailing slash
function removeDirForce(dirPath) {
fs.readdir(dirPath, function(err, files) {
@liangzan
liangzan / .Xresources
Created January 19, 2012 23:26
Xresources for configuring urxvt
! urxvt
URxvt*buffered: true
URxvt*cursorBlink: true
URxvt*underlineColor: yellow
URxvt*font: xft:inconsolata:size=10:antialias=true
URxvt*depth: 32
URxvt*borderless: 1
URxvt*scrollBar: false
URxvt*loginShell: true
Urxvt*secondaryScroll: true # Enable Shift-PageUp/Down in screen
@liangzan
liangzan / gmail_checker.rb
Created January 19, 2012 23:20
Gmail checker for Xmobar
# Gmail checker for Xmobar
#
# Install the ruby-gmail and mime gem to system
# Put the script under ~/path/to/gmail_checker.rb
# Make sure it is executable
require 'gmail'
gmail = Gmail.new('example@gmail.com', 'password')
mail_count = gmail.inbox.count(:unread)
@liangzan
liangzan / .xmobarrc
Created January 19, 2012 23:17
Xmobar configuration
Config { font = "xft:inconsolata:size=10:antialias=true"
, bgColor = "#002b36"
, fgColor = "#657b83"
, position = Top
, lowerOnStart = True
, commands = [ Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Date "<fc=#93a1a1>%a %b %_d %Y %H:%M</fc>" "date" 10
, Run DiskIO [("/", "IO: <total>"), ("sda4", "<total>")] [] 10
@liangzan
liangzan / twitter-bootstrap-responsive-max-width.css
Created March 28, 2012 09:30
sets the max width of twitter bootstrap's responsive layout to 980
.container-fluid {
max-width: 980px;
margin: 0 auto;
}
@liangzan
liangzan / org-mode-line-wrap.el
Created June 16, 2012 03:33
emacs org mode line wrapping
;; add this to your emacs.d
;; wraps the lines in org-mode
(setq org-startup-truncated nil)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<res:DCTResponse
xmlns:res='http://www.dhl.com'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation= 'http://www.dhl.com DCT-Response.xsd'>
<GetQuoteResponse>
<Response>
<ServiceHeader>
<MessageTime>2016-04-05T05:01:20.512+01:00</MessageTime>
<MessageReference>1234567890123456789012345678901</MessageReference>
<SiteID>CourexPteL</SiteID>
<?xml version="1.0" encoding="UTF-8"?>
<p:DCTRequest xmlns:p="http://www.dhl.com" xmlns:p1="http://www.dhl.com/datatypes" xmlns:p2="http://www.dhl.com/DCTRequestdatatypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com DCT-req.xsd ">
<GetQuote>
<Request>
<ServiceHeader>
<MessageTime>2002-08-20T11:28:56.000-08:00</MessageTime>
<MessageReference>1234567890123456789012345678901</MessageReference>
<SiteID>CourexPteL</SiteID>
<Password>i1td5gCzM7</Password>
</ServiceHeader>
@liangzan
liangzan / fail2ban_configuration.md
Last active January 2, 2016 19:09
Configuration for fail2ban

First install Fail2ban.

sudo apt-get install fail2ban

Then edit the configuration file at /etc/fail2ban/jail.conf

We are only showing the changed sections.

toResponse :: IO (Response BL.ByteString) -> BL.ByteString
toResponse i = view responseBody i
-- compiler error
Couldn't match type ‘IO (Response BL.ByteString)’
with ‘Response BL.ByteString’
arising from a functional dependency between:
constraint ‘mtl-2.2.1:Control.Monad.Reader.Class.MonadReader
(Response BL.ByteString) ((->) (IO (Response BL.ByteString)))’
arising from a use of ‘view’