Skip to content

Instantly share code, notes, and snippets.

function MinPQ() {
this.size = 0;
this.data = Array.from({ length: 10 });
}
MinPQ.prototype.swap = function (i, j) {
const tmp = this.data[i];
this.data[i] = this.data[j];
this.data[j] = tmp;
}
MinPQ.prototype.up = function (k) {
@ibreathebsb
ibreathebsb / edge.md
Last active January 26, 2025 14:49
open edge in terminal on macos
  1. open your .zshrc or .bashrc file

I'm using zsh so the command is vim ~/.zsh

  1. add an alias for edge

alias edge="/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge"

  1. open a new session, or run source ~/.zshrc(`source ~/.bashrc if you are using bash) to make the alias work
  2. type edge in the new session and press enter
local function Chinese()
-- 简体拼音
hs.keycodes.currentSourceID("com.apple.inputmethod.SCIM.ITABC")
end
local function English()
-- ABC
hs.keycodes.currentSourceID("com.apple.keylayout.ABC")
end
@ibreathebsb
ibreathebsb / upload.js
Last active January 6, 2026 07:48
file upload from dataUrl with axios
// Note: only for modern browser
import axios from 'axios'
// helper function: generate a new file from base64 String
const dataURLtoFile = (dataurl, filename) => {
const arr = dataurl.split(',')
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)