Skip to content

Instantly share code, notes, and snippets.

View liangzan's full-sized avatar

Wong Liang Zan liangzan

View GitHub Profile
<?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>
<?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>
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’
#!/usr/bin/env bash
# leaves 5 copies of the standalone app
total_files=$(find -name '*.jar' -type f -print0 | xargs -0 ls -t | wc -l)
file_num_to_remove=`expr $total_files - 5`
find -name '*.jar' -type f -print0 | xargs -0 ls -t | tail -n $file_num_to_remove | xargs rm
<?php
/**
* Sample to use Courex XML Technical Guide
*
* How to use:
* Search for "//input" and fill in the data accordingly
*
* @author Tao Yueling <yueling@courex.com.sg>
* @copyright 2014 Courex Pte Ltd
* @version 1.0.0
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Keys (oneDriveKey)
import Network.OAuth.OAuth2
import Control.Monad (liftM)
import Data.Aeson (FromJSON)
@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.

@liangzan
liangzan / error.md
Created September 6, 2013 00:11
level 1 error

Internal Server Error

The server has either erred or is incapable of performing the requested operation.

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
@liangzan
liangzan / pg_users_chef_recipe.rb
Last active December 15, 2015 18:59
pg_users_chef_recipe.rb
include_recipe "postgresql::server"
node[:notifymode][:db_users].each do |user|
execute "create-database-user" do
exists = <<-EOH
sudo -u postgres psql -U postgres -c "select * from pg_user where usename='#{user[:name]}'" | grep -c #{user[:name]}
EOH
command "echo \"CREATE ROLE #{user[:name]} with CREATEDB LOGIN PASSWORD '#{user[:password]}'\" | sudo -u postgres psql -U postgres"
not_if exists
end
@liangzan
liangzan / .tmux.conf
Created October 25, 2012 02:26
tmux configuration
## term
set -g default-terminal "screen-256color"
set -g default-shell /bin/zsh
## tmux window titling for X
set -g set-titles on
set -g set-titles-string '#W [#S:#I]'
setw -g automatic-rename on
## msgs