Skip to content

Instantly share code, notes, and snippets.

View EtherDream's full-sized avatar
👓
🎃

EtherDream EtherDream

👓
🎃
View GitHub Profile
@EtherDream
EtherDream / pbkdf2.html
Created March 13, 2024 02:51
WebCrypto PBKDF2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>PBKDF2 Test</title>
<style>
body, input {
font-family: monospace;
}
(function() {
'use strict'
let s = fetch('/')
console.time('t0')
for (let i = 0; i < 1e9; i++) {
if (true) {}
}
console.timeEnd('t0')
(function() {
'use strict'
let s
console.time('t0')
for (let i = 0; i < 1e7; i++) {
}
console.timeEnd('t0')
console.time('t1')

打造闭环:

var a = {}
var b = {}
a.b = b
b.a = a

底层逻辑:

# see https://github.com/EtherDream/freecdn/blob/master/examples/free-host/npm-upload.sh
IFS=$'\n'
if [[ "$NPM_PKG" == "" ]]; then
echo "\$NPM_PKG is not specified"
exit
fi
if [[ "$*" == "" ]]; then
echo "file list empty"
(function() {
'use strict'
async function pending() {
return 11
}
function mayPending() {
if (Math.random() < 0.001) {
return pending()
@EtherDream
EtherDream / install-openresty.sh
Last active October 16, 2020 09:31
Compile OpenResty
OPENRESTY_VER=1.17.8.2
ZLIB_VER=1.2.11
PCRE_VER=8.44
OPENSSL_VER=1.1.1h
DIR=$(mktemp -d)
echo $DIR
cd $DIR
git clone https://github.com/google/ngx_brotli.git --recurse-submodules
@EtherDream
EtherDream / formatTime.js
Created March 15, 2018 08:55
date object -> "yyyy/MM/dd hh/mm/ss"
function formatTime(date) {
var d = new Date(date - 60000 * date.getTimezoneOffset());
var s = d.toISOString();
return s.substr(0, 10) + ' ' + s.substr(11, 8);
}
formatTime( new Date() ); // "2018-03-15 16:52:34"
@EtherDream
EtherDream / formatTime.js
Created March 15, 2018 08:55
date object -> "yyyy/MM/dd hh/mm/ss"
function formatTime(date) {
var d = new Date(date - 60000 * date.getTimezoneOffset());
var s = d.toISOString();
return s.substr(0, 10) + ' ' + s.substr(11, 18);
}
formatTime( new Date() ); // "2018-03-15 16:52:34.969Z"
@EtherDream
EtherDream / prime.scss
Last active October 16, 2020 09:33
2 to N primes in SCSS
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
@function is_prime($num, $sqrt) {
@for $i from 3 through $sqrt {
@if $num % $i == 0 {
@return false;
}