Skip to content

Instantly share code, notes, and snippets.

View naixy28's full-sized avatar

naixy28 naixy28

View GitHub Profile
@naixy28
naixy28 / time-formatter.ts
Created April 29, 2022 07:30
time format
const formatTime = (ms: number): TimeSplitted => {
if (!ms || ms <= 0) {
return { day: 0, hour: 0, min: 0, second: 0 }
}
const total = ~~(ms / 1000)
const day = ~~(total / DAY)
const hour = ~~((total % DAY) / HOUR)
const min = ~~((total % HOUR) / MIN)
const second = ~~(total % MIN)
@naixy28
naixy28 / perlin-noise-flow-field.js
Created September 9, 2019 08:26
P5.js Perlin Noise Flow Field
const scale = 20
const inc = 0.1
let cols
let rows
let yOff
let xOff
let zOff = 0
let fr
let flowField = []
@naixy28
naixy28 / svg_filter_displacement.svg
Created August 19, 2019 15:46
svg_filter_displacement
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
window.onload = function() {
const playground = document.querySelector('#scene')
const app = new PIXI.Application({
width: 512,
height: 512,
autoDensity: true,
transparent: true,
resolution: 1,
})
@naixy28
naixy28 / int-simple.md
Created September 26, 2017 06:12
int-simple

js

  1. 输出
function Foo() {
    getName = function() {alert(1)};
    return this;
}
Foo.getName = function() {alert(2)};
Foo.prototype.getName = function() {alert(3)};
var getName = function() {alert(4)};
@naixy28
naixy28 / int.md
Created September 26, 2017 06:12
interview

js

  1. output
function Foo() {
    getName = function() {alert(1)};
    return this;
}
Foo.getName = function() {alert(2)};
Foo.prototype.getName = function() {alert(3)};
var getName = function() {alert(4)};