Skip to content

Instantly share code, notes, and snippets.

View ChenYingChou's full-sized avatar

陳瀛洲 ChenYingChou

View GitHub Profile
@ChenYingChou
ChenYingChou / gist:4696872
Created February 2, 2013 10:53
SQL 整理示範
SELECT
DISTINCT DECODE(CARNO, NULL, 'X','Y') P -- 是否有車號, 'X':無, 'Y':有
, RQT_NO RNO -- 叫車序號
, RQTSEQ_NO RSNO -- 叫車序號支號
, DEP -- 通關類別
, (SELECT SUBSTR(DEP_NAME,1,2) FROM ORG WHERE ORG.DEP_ID = T.DEP_ID) DEP_ID -- 部門名稱前2碼
, RQT_BY
, DECODE(BOX_NOCAR,NULL, CARNO,CARNO||','||BOX_NOCAR) CARNO
, NVL((SELECT CEMP_NAME FROM EMPLOYEE WHERE EMP_CODE= T.DRIVER),DRIVER)DR
, CASE WHEN RESERVED_FLAG = 'Y' THEN -- 若是專車
@ChenYingChou
ChenYingChou / pgCursors.js
Last active May 2, 2020 10:52
Node JS : Make pg-cursor easier to use
// vim: set ts=4 sw=4 sts=4 et cindent:
const pg = require('pg')
const Pool = pg.Pool
const Cursor = require('pg-cursor')
//@ts-check
class PgCursors {
/**
* @param {pg.Pool} db
@ChenYingChou
ChenYingChou / watch-log.js
Last active July 23, 2021 08:26
Check system logs and add DNS and SSH attackers to the firewall blacklist
#!/usr/bin/env node
//@ts-check
const fs = require('fs')
const path = require('path')
const dns = require('dns')
const util = require('util')
const dateformat = require('dateformat')
const Tail = require('tail').Tail
const resolve4 = util.promisify(dns.resolve4)