Skip to content

Instantly share code, notes, and snippets.

View pureugong's full-sized avatar
🌴
On vacation

pureugong pureugong

🌴
On vacation
  • Tokyo
View GitHub Profile
@pureugong
pureugong / manju.js
Last active April 12, 2025 05:30
manju.js
const scriptName = "kakao";
function response(room, msg, sender, isGroupChat, replier) {
replier.reply("안녕하세요! 만쥬야입니다.");
}
// Names array (last name first, then first name)
const names = [
{ lastName: 'JO', firstName: '' },
{ lastName: 'IM', firstName: '' },
{ lastName: 'LEE', firstName: '' },
{ lastName: 'LIM', firstName: '' },
{ lastName: 'SUNG', firstName: '' },
{ lastName: 'LIM', firstName: '' }
];
#!/bin/bash
# Function to format numbers
format_number() {
if (( $1 >= 1000000000 )); then
echo $(bc <<< "scale=1; $1/1000000000")B
elif (( $1 >= 1000000 )); then
echo $(bc <<< "scale=1; $1/1000000")M
elif (( $1 >= 1000 )); then
echo $(bc <<< "scale=1; $1/1000")K
func GenUpsertQueryWithRecords(tablename string, cols []string, onConflictCols []string, updateCols []string, values [][]interface{}) string {
// Create the ON CONFLICT clause based on the specified columns
onConflict := ""
if len(onConflictCols) > 0 {
onConflict = fmt.Sprintf("ON CONFLICT (%s) DO UPDATE SET", strings.Join(onConflictCols, ", "))
}
// Create the SET clause for the UPDATE part of the query
setClause := ""
if len(updateCols) > 0 {
#!/bin/bash
# Step 1: Get the content IDs and titles of the articles from the last 6 months in the project
results=$(curl -u username:password -s "https://your-confluence-site/wiki/rest/api/content?limit=50&expand=history&spaceKey=XXX" -H "Content-Type: application/json" | jq --arg six_months_ago "$six_months_ago" -r '.results[] | {id, title}')
# Step 2: Retrieve the likes for each content ID and print the details
while IFS= read -r line; do
content_id=$(jq -r '.id' <<< "$line")
title=$(jq -r '.title' <<< "$line")
likes=$(curl -u username:password -s "https://your-confluence-site/wiki/rest/api/content/${content_id}/likes" -H "Content-Type: application/json" | jq -r '.likes')
@pureugong
pureugong / foo.sh
Created October 25, 2019 01:12
List of URL Scheme Mappings for Mac
# 1. dump of the Launch Services database
# ref: https://stackoverflow.com/questions/29614303/list-of-url-scheme-mappings-for-apple-mac-and-or-iphone
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump
# 2. the alternative way
# ref: https://superuser.com/questions/548119/how-do-i-configure-custom-url-handlers-on-os-x/548122#548122
@pureugong
pureugong / parse_csv.sh
Created October 15, 2019 06:59
how to parse csv with awk, which has "new lines within double quotes"
cat << EOF > /tmp/sample.csv
"one",
"three
four",
"seven"
EOF
gawk -v RS='"' 'NR % 2 == 0 { gsub(/\n/, "") } { printf("%s%s", $0, RT) }' /tmp/sample.csv | awk -F, '{print $1}'
@pureugong
pureugong / execel_custom_format_cell.md
Created July 31, 2019 00:37
How to add & subtract time in Excel to show over 24 hours

How to add time in excel to show over 24 hours

# Total hours	            [h]
# Hours & minutes	        [h]:mm
# Hours, minutes, seconds	[h]:mm:ss
# Total minutes	          [m]
# Minutes & seconds	      [m]:ss
# Total seconds	          [s]
<?php
// https://stackoverflow.com/questions/39086660/upgrading-phpunit-from-4-8-to-5-5
/**
* Returns a mock object for the specified class.
*
* This method is a temporary solution to provide backward compatibility for tests that are still using the old
* (4.8) getMock() method.
* We should update the code and remove this method but for now this is good enough.
*
*
@pureugong
pureugong / gist:e6dd29e4ee1d4a9e28b91108e396635b
Created April 7, 2018 06:20 — forked from srsbiz/gist:8373451ed3450c0548c3
php AES-128-CBC mcrypt & openssl
<?php
function encrypt_mcrypt($msg, $key, $iv = null) {
$pad = 16 - (strlen($msg) % 16);
$msg .= str_repeat(chr($pad), $pad);
if (!$iv) {
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
}
$encryptedMessage = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $msg, MCRYPT_MODE_CBC, $iv);
return base64_encode($iv . $encryptedMessage);
}