Skip to content

Instantly share code, notes, and snippets.

View samuelko123's full-sized avatar

Samuel Ko samuelko123

  • Melbourne, Victoria, Australia
View GitHub Profile
@samuelko123
samuelko123 / upload.js
Created May 28, 2022 14:18
Bulk upload to ImageKit
const FormData = require('form-data')
const axios = require('axios')
const fs = require('fs')
const path = require('path')
async function upload(image_url_or_base64, file_name, overwrite) {
const data = {
file: image_url_or_base64,
fileName: file_name,
useUniqueFileName: !overwrite,
@samuelko123
samuelko123 / ImageMagick.txt
Last active June 10, 2022 12:30
ImageMagick scripts
Remove white background (and make it transparent)
magick *.png -bordercolor white -fuzz 20% -trim -transparent #ffffff output_%02d.png
@samuelko123
samuelko123 / delete_github_deployments.js
Created May 14, 2022 01:46
delete github deployments
const axios = require('axios')
const user = '<your username>'
const repo = '<your repo>'
const personal_access_token = '<your token>' // with repo_deployment access
const url = `https://api.github.com/repos/${user}/${repo}/deployments`
const auth = {
username: user,
password: personal_access_token,
@samuelko123
samuelko123 / symmetric_difference.js
Last active May 14, 2022 01:47
Javascript algorithms
/*
Symmetric difference of two sets is the set of elements
which are in either of the two sets but not in both.
e.g.
symmetric_difference([1, 2, 3], [5, 2, 1, 4])
// [3, 5, 4]
*/
function symmetric_difference(...args) {