Skip to content

Instantly share code, notes, and snippets.

View mindon's full-sized avatar
🙃
hx/ui, coding with ts/js, zig, golang and sometimes qt...

Mindon Feng mindon

🙃
hx/ui, coding with ts/js, zig, golang and sometimes qt...
View GitHub Profile
@mindon
mindon / dual-flipped.css
Last active August 20, 2021 08:51
pure css for a simple flipping card
/* <div class="dual"><div class="box"><div onclick="this.parentElement.classList.add('flipped')">current</div><div onclick="this.parentElement.classList.remove('flipped')">current</div></div></div> */
.dual {
max-width: 100%;
position: relative;
margin: 2rem 0;
perspective: 1280px;
}
.dual:hover {
z-index: 999;
@mindon
mindon / deno_ts_testing_private_func_test.ts
Created March 12, 2021 17:43
A simple helper to test functions not-exported but with _ prefix
// A simple helper to test functions not-exported but with _ prefix
const privateCases = async function (flpath: string, cases: Function) {
const decoder = new TextDecoder("utf-8");
let body = decoder.decode(await Deno.readFile(flpath));
body = body.replace(/\nfunction _/g, "\nexport function _");
const tmppath = flpath.replace(/([^\/]+)$/, "~$1"),
encoder = new TextEncoder();
await Deno.writeFile(tmppath, encoder.encode(body));
cases(await import(tmppath));
@mindon
mindon / fetch-js.go
Created January 7, 2021 12:45
make a fetch from js code from golang
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
@mindon
mindon / require.js
Last active November 6, 2020 10:01
A simple require() implemention
/* simple require implemented for browser
* usage example :
* require.dirs({root:'/service/grpc/', modules:'/prefix/node_modules/'})
* && require('hello.js', function(exports){
* window.hello = exports;
* })
**/
!window.require && (function(){ // begin require
const cachedModules = {},
cachedMains = {},
@mindon
mindon / bibtex-simple-demo.html
Last active May 12, 2019 01:21
show bibtex on web (without jquery, without moment, without large bibtex_js.js)
<!--
How to show bibtex on web? (without jquery, without moment, without large bibtex_js.js)
Here's demoing the usage
Inspired by https://github.com/pcooksey/bibtex-js
You wont want a 70+KB js to get latex to unicode in your webpage,
that's why you need an helper to convert latex symbol inside articles content first,
see the simple helper tool latex-to-unicode.html
replace the latexRender function with the helper generated result.
-->
<style>
@mindon
mindon / lsnf.sh
Last active January 16, 2019 03:45
List files in one folder but not in another
#/bin/sh
# only files, subfolders excluded
# example diff <(ls -FL ./one/ | grep -v /) <(ls -FL ./another/ | grep -v /) | awk '{if($1=="<") print $2;}'
diff <(ls -FL $1 | grep -v /) <(ls -FL $2 | grep -v /) | awk '{if($1=="<") print $2;}'
@mindon
mindon / Dockerfile_FuchsiaOS-build-env
Last active January 2, 2019 04:11
Fuchsia OS build env Dockerfile
FROM ubuntu:latest
MAINTAINER Mindon Feng <mindon@live.com>
ENV INSTALLER apt-get install -y --no-install-recommends
WORKDIR /root
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
@mindon
mindon / ios-12beta-an-app-crashed-solution.md
Created August 15, 2018 01:55
iOS 12 beta 下中銀國際保安編碼器崩潰解決辦法

问题

iPhone升级到iOS 12 beta之后,最惨的是中银国际的保安編碼器一直无法使用,启动就提示`

此应用程式基于安全检查失败,以致应用程式不能继续运作。请按“确认”离开。(错误码I004)

`

解决办法

@mindon
mindon / request_testing_helper.go
Last active May 17, 2018 10:39
A helper func for http request testing
// http request testing helper
// author: Mindon Feng <mindon@gmail.com>
// site: https://mindon.github.io
package mindon
import (
"bytes"
"errors"
"io/ioutil"
"net/http"
@mindon
mindon / heart.scad
Created April 17, 2018 09:15
Heart Shape in OpenSCAD format
// simple heart shape for OpenSCAD
// author: Mindon <mindon@gmail.com>
// from https://mindon.github.io/
heart(width = 160, height = 160);
module heart(width, height = 0) { // 0 = auto height
w = width; h = height;
r = 2 * w/7; // top circle radius
i = r/4.0; // top circle intersect-part width