Skip to content

Instantly share code, notes, and snippets.

@thiamteck
thiamteck / DML_partition.sql
Created August 9, 2021 13:32
Create MySQL table partition by month
-- a table to be partition by column 'created_at'
-- make sure all primary key and unique key of table contains column used for partition
CREATE TABLE `table_to_be_partitioned` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`col_a` VARCHAR(255) DEFAULT NULL,
`cal_b` VARCHAR(255) DEFAULT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),
`updated_at` DATETIME DEFAULT NULL,
PRIMARY KEY (`created_at`,`id`),
KEY `id` (`id`)
@thiamteck
thiamteck / AesStringEncryptor.java
Last active June 30, 2023 10:51
OpenSSL equivalent for AES encryption with and without PBKDF2 and key-obtention iteration (-iter)
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
import java.util.Base64;
#
# Based on custom settings by Bruce Dodson, http://gisdeveloper.tripod.com/scite.html
# Does not support `start.in.monospaced.mode`, but invert the font setting among monospace and non-monospace font in order to start SciTE with monospace font
#
tabbar.hide.one=1
tabbar.multiline=1
toolbar.visible=1
statusbar.visible=1
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%';
FLUSH PRIVILEGES;
@thiamteck
thiamteck / range_overlap_check.html
Last active November 22, 2018 02:04
Check if number range is overlapping. JS Bin// source https://jsbin.com/poyacef
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@thiamteck
thiamteck / random_datetime_between.sql
Created November 19, 2018 11:50
MySQL function for get random datetime in between 2 given datetime. Copy from : https://stackoverflow.com/a/49727273
DELIMITER $$
DROP FUNCTION IF EXISTS `random_datetime_between`$$
CREATE FUNCTION `random_datetime_between`(date_from DATETIME, date_to DATETIME) RETURNS DATETIME
BEGIN
/**
* reference: https://stackoverflow.com/a/49727273
*/
DECLARE result DATETIME;
@thiamteck
thiamteck / server.py
Created June 26, 2018 17:04
server.py from deoplete-jedi
"""Jedi mini server for deoplete-jedi
This script allows Jedi to run using the Python interpreter that is found in
the user's environment instead of the one Neovim is using.
Jedi seems to accumulate latency with each completion. To deal with this, the
server is restarted after 50 completions. This threshold is relatively high
considering that deoplete-jedi caches completion results. These combined
should make deoplete-jedi's completions pretty fast and responsive.
"""
@thiamteck
thiamteck / svn_gitignore.sh
Created December 18, 2017 02:16
read .gitignore file and ignore the entries via svn:ignore
svn propset svn:ignore -RF .gitignore .
@thiamteck
thiamteck / LogViewer.py
Created November 15, 2017 02:20
A more readable view for capture file of Selenium SMPPSim
import datetime
import fileinput
import shlex
##
# Usage: tail -f *.capture | python LogViewer.py
##
def construct_dictionary(line):
# ref: https://stackoverflow.com/a/38787616/90101
@thiamteck
thiamteck / remove_namespace_from_xml.sh
Created April 6, 2017 03:06
Remove default namespace declaration from pom.xml
#
# Reference : http://stackoverflow.com/a/16700113/90101
#
#
# remove default namespace declaration
#
sed -e 's/ xmlns=".*"//g' pom.xml
#