Discover gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fun(data, ...args) { | |
const res = JSON.stringify(data) | |
console.log(res) | |
const t = new Function('console.log("huhaoran")') | |
args.map(item => { | |
const tfun = new Function(`return ${res}.${item}`) | |
console.log(tfun()) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var overScrollable = false, scrollSpeed = 150; | |
function updateScroll(state){ | |
var overflow = state.e.parent().outerHeight() - state.e.prop('scrollHeight'); | |
if(state.deltaY < 0){ | |
state.scrollPos += scrollSpeed; | |
if(state.scrollPos > 0) state.scrollPos = 0; | |
state.e.css({"transform": "translateY(" + state.scrollPos + "px)"}); | |
} | |
else if(overflow < 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setPassword(p){ | |
salt = crypto.randomBytes(16).toString('hex'); | |
hash = crypto.pbkdf2Sync(p, salt, 1000, 64, 'sha512').toString('hex'); | |
} | |
function validPassword(p) { | |
return crypto.pbkdf2Sync(p, salt, 1000, 64, 'sha512').toString('hex') === hash; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
<script src="jquery.js"></script> | |
<script src="tabs.js"></script> | |
<style> | |
nav { | |
border-bottom: 1px solid gray; cursor: default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (proc) { | |
const timeout = 3000; | |
const events = new Map(); | |
const rec_events = new Map(); | |
var id = 0; | |
proc.on('message', (message) => { | |
if (message.type == 'request') { | |
var reply = { id: message.id, type: 'reply' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const currentTime = () => process.hrtime()[0] * 1000 + process.hrtime()[1] / 1000000; | |
module.exports = class StopWatch { | |
constructor() { | |
this.startTime = 0; | |
this.pauseTime = 0; | |
this.running = false; | |
} | |
start() { | |
this.startTime = currentTime(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fileRegex = /\.(frag|vert|fs|vs|glsl)$/ | |
import fs from "fs"; | |
import path from "path"; | |
function processShader(src, id) { | |
const lines = src.split("\n"); | |
let result = ""; | |
for (const line of lines) { | |
if (line.startsWith("#include ")) { | |
const relativeFile = line.split(" ")[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def get_tf_mat(i, dh): | |
a = dh[i][0] | |
d = dh[i][1] | |
alpha = dh[i][2] | |
theta = dh[i][3] | |
q = theta |
NewerOlder