Skip to content

Instantly share code, notes, and snippets.

@RichardHan
RichardHan / AES_sample_code
Created February 8, 2016 09:22
C# AES sample code
using System;
using System.IO;
using System.Security.Cryptography;
namespace AES
{
class Program
{
static string aes_key = "AXe8YwuIn1zxt3FPWTZFlAa14EHdPAdN9FaZ9RQWihc=";
static string aes_iv = "bsxnWolsAyO7kCfWuyrnqg==";
rem Get the date and time in a locale-agnostic way
for /f %%x in ('wmic path win32_localtime get /format:list ^| findstr "="') do set %%x
rem Leading zeroes for everything that could be only one digit
set Month=0%Month%
set Day=0%Day%
rem Hours need special attention if one wants 12-hour time (who wants that?)
if %Hour% GEQ 12 (set AMPM=PM) else (set AMPM=AM)
set /a Hour=Hour %% 12
if %Hour%==0 (set Hour=12)
set Hour=0%Hour%
@RichardHan
RichardHan / powershell_get-childitem_sha1.ps1
Created March 14, 2018 14:37
[Powershell] Get All Child item SHA1
$table = get-childitem -recurse | where {! $_.PSIsContainer}
foreach ($row in $table)
{
Get-FIleHash $row.FullName -Algorithm SHA1
}
pause
@RichardHan
RichardHan / win_change_javapath_by_mklink
Created June 20, 2016 11:30
Windows change JAVA path by mklink
@RichardHan
RichardHan / fn_UnderscoreCase.sql
Last active August 17, 2017 18:00
[SQL] Function - Underscore Case
-- select dbo.fn_UnderscoreCase('HelloWorld')
--
-- Input HelloWorld
--
-- Output hello_world
--
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'fn' AND name =
'fn_UnderscoreCase')
DROP function fn_UnderscoreCase
GO
@RichardHan
RichardHan / histock_tw_dividend_helper.js
Created June 20, 2017 00:36
histock.tw dividend - warrant helper
/*
The script only effect on https://histock.tw/stock/dividend.aspx
add warrant link below the financial link.
*/
for (r = 0; r < document.getElementsByClassName('tb-msci').length; r++) {
var table = document.getElementsByClassName('tb-msci')[r];
for (i = 0; i < table.rows.length; i++) {
if (table.rows[i].cells[2]) {
//before https://histock.tw/stock/financial.aspx?no=0056&t=2
//after https://histock.tw/stock/warrant.aspx?no=0056
@RichardHan
RichardHan / loop_invoke_curl
Last active April 11, 2017 03:21
Loop Invoke curl
~$ for ((i=1;i<=1000;i++)); do curl "https://test.com/test.html" && sleep 3; done
@RichardHan
RichardHan / Find_LDAP Server_In_DNS.cmd
Created December 15, 2016 03:23
Find LDAP Server in the DNS
nslookup -type=srv _ldap._tcp.{your_domain_name}
e.g.
nslookup -type=srv _ldap._tcp.tw.server.org
nslookup -type=srv _ldap._tcp.us.server.org
nslookup -type=srv _ldap._tcp.cn.server.org
@RichardHan
RichardHan / Get_DL_member_via_powershell.ps1
Created December 29, 2016 09:28
Get DL member via powershell
Import-Module ServerManager
Add-WindowsFeature RSAT-AD-PowerShell
$DLName = "DL_Name"
$ADServer = "AD_Server_Name"
$ResultList = @()
$Groups = Get-ADGroup -Properties * -Filter{name -like $DLName} -Server $ADServer |Select Name, ManagedBy|
Foreach-Object{
$Group = $_
@RichardHan
RichardHan / Get_AD_user_via_powershell.ps1
Created December 29, 2016 09:27
Get AD user via powershell
Import-Module ServerManager
Add-WindowsFeature RSAT-AD-PowerShell
Get-ADUser "user_name" -Properties *