Skip to content

Instantly share code, notes, and snippets.

View hyunbinseo's full-sized avatar

Hyunbin hyunbinseo

View GitHub Profile
@hyunbinseo
hyunbinseo / D3.svelte
Created March 13, 2024 15:43
D3 in vanilla Svelte
<!-- https://d3js.org/getting-started#d3-in-vanilla-html -->
<script lang="ts">
import * as d3 from 'd3';
import type { Action } from 'svelte/action';
const width = 640;
const height = 400;
const marginTop = 20;
const marginRight = 20;
@hyunbinseo
hyunbinseo / pw_auth.bash
Created March 9, 2024 15:08
Disable password authentication in Ubuntu 22.04 (Vultr instance)
cd /etc/ssh
sudo nano sshd_config
# PasswordAuthentication no
# Remove the leading pound sign
cd sshd_config.d
ls # 50-cloud-init.conf
sudo nano 50-cloud-init.conf
@hyunbinseo
hyunbinseo / cloudflare.tsv
Last active March 4, 2024 03:34
Cloudflare Colocations in Korea
구분 통신사 지역
5G KT LAX
5G KT LAX
5G KT LAX
5G KT LAX
5G LGU HKG
5G LGU ICN
5G SKT KIX
5G SKT KIX
5G SKT LAX
@hyunbinseo
hyunbinseo / js.svelte
Created January 9, 2024 06:05
Svelte Syntax Highlighting
<script>
$: if (browser && data) {
chart.ref?.updateSeries(data.series);
}
</script>
<p>Hello, World</p>
@hyunbinseo
hyunbinseo / index.js
Last active November 3, 2023 05:14
SMS API Speed Comparison
// Create .env file and add secret values.
// Run with node --env-file=.env index.mjs
// Requires Node.js 20+ (LTS as of 2023-10-24)
const {
NHN_SMS_APP_KEY,
NHN_SMS_SECRET,
NHN_SMS_SEND_NO,
SEND_TO,
TWILIO_ACCOUNT_SID,
@hyunbinseo
hyunbinseo / index.ts
Created June 24, 2023 12:09
Drizzle ORM Cheat Sheet
import { asc, eq, gte, lte } from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/mysql2';
import { createPool } from 'mysql2';
import * as schema from './schema';
import { comments, users } from './schema';
const connection = createPool({
host: '...',
user: '...',
password: '...',
@hyunbinseo
hyunbinseo / crypto-key.js
Created June 21, 2023 15:50
Web Crypto - Key Generation, Export, and Import
import { webcrypto as crypto } from 'node:crypto'; // Node.js only
/* Generate */
const key = await crypto.subtle.generateKey(
{
name: 'AES-GCM',
length: 256
},
true,
@hyunbinseo
hyunbinseo / vite.config.ts
Created May 16, 2023 17:27
Vite Build End Notification (SendGrid Email)
import { generateSgSendRequest } from 'sendgrid-send';
import { defineConfig } from 'vite';
// Vite Conditional Config
// Reference https://vitejs.dev/config/#conditional-config
export default defineConfig(({ command }) => ({
plugins: [
{
name: 'Build End Notification',
buildEnd: async (error) => {
@hyunbinseo
hyunbinseo / index.cjs
Last active June 8, 2023 01:42
Import as ESM and CJS - with VS Code IntelliSense and type check
const { generateSgSendBody } = require('sendgrid-send');
generateSgSendBody;
@hyunbinseo
hyunbinseo / ubuntu-server.bash
Last active June 30, 2023 00:29
Setup Ubuntu Server
# Moved to https://github.com/hyunbinseo/blog/blob/master/posts/setup-linux.md
### Remote Desktop ############################################################
sudo apt install xfce4 xrdp
sudo systemctl enable xrdp
# Applications / Settings / Screensaver
# [ ] Enable Screensaver
# [ ] Lock Screen with Screensavera