Skip to content

Instantly share code, notes, and snippets.

@ibreathebsb
ibreathebsb / upload.js
Last active May 15, 2025 20:29
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)
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 / 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
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 / vimrc.txt
Last active September 19, 2021 11:02
.vimrc
set path+=**
set relativenumber
set nu
set hidden
set nowrap
set smartindent
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set incsearch
@ibreathebsb
ibreathebsb / imgp.cpp
Created February 6, 2022 05:42
The imgp file loader
#include<iostream>
#include <fstream>
#include <map>
#include<vector>
#include <stb_image.h>
#include <stb_image_write.h>
#define IMGP_SIZE 1024 * 1024
@ibreathebsb
ibreathebsb / .ideavimrc
Last active September 24, 2024 08:19
.ideavimrc
" .ideavimrc is a configuration file for IdeaVim plugin. It uses
" the same commands as the original .vimrc configuration.
" You can find a list of commands here: https://jb.gg/h38q75
" Find more examples here: https://jb.gg/share-ideavimrc
""" Map leader to space ---------------------
let mapleader=" "
"" -- Suggested options --
@ibreathebsb
ibreathebsb / Build Protobuf for Unreal Engine 5 on Windows.md
Last active September 4, 2025 04:08
Build Protobuf for Unreal Engine 5 C++ 20 on Windows
// Vertex shader source code
const vertexShaderSource = `#version 300 es
in vec4 position;
in vec2 texCoord;
out vec2 vTexCoord;
void main() {
gl_Position = position;
vTexCoord = texCoord;
}`;
@ibreathebsb
ibreathebsb / unreal wold position uv node.txt
Created February 26, 2025 10:57
unreal custom node to compute uv
Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_19" ExportPath="/Script/UnrealEd.MaterialGraphNode'/Engine/Transient.PreviewMaterial_0:MaterialGraph_0.MaterialGraphNode_19'"
Begin Object Class=/Script/Engine.MaterialExpressionCustom Name="MaterialExpressionCustom_0" ExportPath="/Script/Engine.MaterialExpressionCustom'/Engine/Transient.PreviewMaterial_0:MaterialGraph_0.MaterialGraphNode_19.MaterialExpressionCustom_0'"
End Object
Begin Object Name="MaterialExpressionCustom_0" ExportPath="/Script/Engine.MaterialExpressionCustom'/Engine/Transient.PreviewMaterial_0:MaterialGraph_0.MaterialGraphNode_19.MaterialExpressionCustom_0'"
Code="\r\nfloat4 NDCPosition = LWCMultiply(MakeLWCVector4(LWCWorldPosition, 1.0f), ResolvedView.WorldToClip);\r\nNDCPosition.xy /= NDCPosition.w;\r\nfloat2 uv = NDCPosition.xy * float2(0.5f, -0.5f) + 0.5f;\r\nreturn uv;\r\n"
OutputType=CMOT_Float2
Description="ComputeUV"
Inputs(0)=(InputName="WorldPosition",Input=(Expression="