Skip to content

Instantly share code, notes, and snippets.

View wingkwong's full-sized avatar
👁️‍🗨️
Focusing

WK wingkwong

👁️‍🗨️
Focusing
View GitHub Profile
@wingkwong
wingkwong / query-locked-objects.sql
Created December 4, 2019 10:58
Query locked objects in Oracle Database
select
c.owner,
c.object_name,
c.object_type,
b.sid,
b.serial#,
b.status,
b.osuser,
b.machine
from
@wingkwong
wingkwong / query-check-tablespace-oracle.sql
Created December 4, 2019 10:54
Query to check tablespace size for Oracle Database
select df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))
"Pct. Free"
from
(select tablespace_name,
round(sum(bytes) / 1048576) TotalSpace
from dba_data_files
@wingkwong
wingkwong / .htaccess
Created November 27, 2019 03:01
Redirecting from non-www to www
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
@wingkwong
wingkwong / install-gnu-parallel.sh
Created November 22, 2019 08:54
Installing GNU Parallel
#!/bin/bash
sudo tar xjf parallel-latest.tar.bz2
cd parallel-yyyymmdd
sudo ./configure && make
sudo make install
# in case you need to relink the executable file
sudo ln -s /usr/bin/parallel /usr/local/bin/parallel
@wingkwong
wingkwong / remove-duplicate-records.py
Created November 17, 2019 13:34
Removing duplicate records in a CSV file using Pandas
import pandas as pd
d = pd.read_csv('CSV_FILE.csv', keep_default_na = False)
d.drop_duplicates(subset = ['COMPOSITE_KEY1', 'COMPOSITE_KEY2', 'COMPOSITE_KEY3', 'COMPOSITE_KEY4', 'COMPOSITE_KEY5', 'COMPOSITE_KEY6', 'COMPOSITE_KEY7', 'COMPOSITE_KEY8', 'COMPOSITE_KEY9', 'COMPOSITE_KEY10'], inplace = True, keep = 'first')
d.to_csv('CSV_FILE_PROCESSED.csv', index = False)
@wingkwong
wingkwong / Taskfile.yml
Last active December 6, 2019 15:12
Relocate golang boilerplate packages using Taskfile
version: '2'
tasks:
relocate:
cmds:
- echo " *** Relocating packages to {{.TARGET_PATH}} ***"
- task: replace-string
vars: {
SOURCE_STR: "{{.PACKAGE_NAME}}",
TARGET_STG: "{{.TARGET_PATH}}"
@wingkwong
wingkwong / Makefile
Last active November 18, 2019 14:02
Relocate golang boilerplate packages using Makefile
GITHUB := "github.com"
PROJECTNAME := $(shell basename "$(PWD)")
PACKAGENAME := $(GITHUB)/$(shell basename "$(shell dirname "$(PWD)")")/$(PROJECTNAME)
GOBASE := $(shell pwd)
.PHONY .SILENT: relocate
## relocate: Relocate packages
relocate:
# Example: make relocate TARGET=github.com/wingkwong/myproject
@test ${TARGET} || ( echo ">> TARGET is not set. Use: make relocate TARGET=<target>"; exit 1 )
@wingkwong
wingkwong / gist:a8ece2db9d255718deb9b366457f60ba
Created May 24, 2018 12:54
Import a CSV file to SQLite3
sqlite3 db.sqlite3
sqlite> .mode csv
sqlite> .separator ","
sqlite> .import table1.csv table1
sqlite> .import table2.csv table2
sqlite> .import table3.csv table3
sqlite> .import table4.csv table4
sqlite> .exit