Skip to content

Instantly share code, notes, and snippets.

View cardin's full-sized avatar
🎸
🎶

Cardin Lee cardin

🎸
🎶
  • R&D and Engineering
  • Singapore
  • 06:04 (UTC +08:00)
View GitHub Profile
@cardin
cardin / nodejs-unhandled-uncaught-example.mjs
Last active May 5, 2022 03:30
Demonstrates NodeJS UncaughtException and UnhandledRejection
#! /usr/bin/env node
/*
npm install p-queue
*/
import PQueue from "p-queue";
process.on("uncaughtException", (err) => {
console.log("Uncaught!", err);
@cardin
cardin / exportPlantuml.sh
Last active February 5, 2022 15:20
Export PlantUML diagrams using Docker PlantUML Server
#!/usr/bin/env bash
########################
# Exports PlantUML diagrams using a Docker PlantUML Server.
# ARGS:
# $1 : Target directory to recursively search
# CONFIG:
# $port : Port to bind the PlantUML Server to
# $dockerName : Name of the Docker container
# $fileExt : File extensions that belong to PlantUML
# $dryRun : Detect files but not process them
@cardin
cardin / GitLab-Runner-Offline-Unregister.ps1
Created February 11, 2021 02:10
Offline GitLab Runners are not automatically unregistered, nor is there an easy GUI way to remove them. This script uses GitLab API to remove the runners.
#######################################
# Please replace this values
$gitlabUrl = "https://gitlab.com"
$bearerToken = "abcdefg"
#######################################
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer $bearerToken")
$runners = Invoke-RestMethod "$gitlabUrl/api/v4/runners?status=offline" `
-Headers $headers
@cardin
cardin / palindrome.js
Created June 10, 2020 02:28
Check if input string is a palindrome, if character deletions are allowed
/**
Copyright 2020 Cardin Lee
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
@cardin
cardin / html_injection.py
Last active April 30, 2019 02:03
Injects HTML elements (specified by xpath, filtered by lambdas) using a Javascript alert(), with auto-success detection
'''
Injects HTML elements (specified by xpath, filtered by lambdas)
using a Javascript alert(), with auto-success detection
Requires:
pip install selenium
geckodriver
'''
import itertools
import json
@cardin
cardin / MayaCloseWindows
Last active December 16, 2015 13:19
Closes all Maya application windows in the scene, leaving only the main Maya window and the Script Editor.
// MEL
$allWindows = `lsUI -windows`;
for ($window in $allWindows)
if ($window != "MayaWindow" && $window!= "scriptEditorPanel1Window")
deleteUI $window;
evalDeferred "deleteUI scriptEditorPanel1Window";
# Python
import maya.cmds as cmds
@cardin
cardin / MyAnimeList cmd Updater.py
Last active April 9, 2017 03:18
A command line utility to update your anime and manga lists at MyAnimeList.net, since MAL.net is not accessible for users who have dynamic IP addresses due to ISPs.
"""
Requirements:
Python 2.7x onwards (2.6 might work)
Not compatible with Python 3
Purpose:
Help to update MAL list
Functions:
- Adds/updates/deletes new series from list
@cardin
cardin / Enumerable.as
Created July 6, 2011 06:22
Enumerations in Actionscript 3
package src.Lib
{
/**
* Enumerable.as
* @version Dated 6 July 2011
* ---------------
* Faux enumerations in Actionscript. Done through code reflection and static initializers.
*
* Adapted from:
* http://scottbilas.com/2008/06/01/faking-enums-in-as3/