Skip to content

Instantly share code, notes, and snippets.

@rezonn
rezonn / httpsServ.sh
Last active August 16, 2020 13:47
https server nodes openssl
cd "${0%/*}"
cat > "app.js" <<- EOM
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
<meta charset="utf-8">
<title>MediaRecorder</title>
<script>
function newhtml(tag,attributes,ths) {
var rv = document.createElement(tag);
for (var x in attributes) {
if (x!="style") rv[x] = attributes[x];
else {
for (var s in attributes[x]) {
async function upload(canvas,url) {
let blob = await (new Promise(resolve => canvas.toBlob(resolve)));
try {
const response = await fetch(url,
{
method:'POST',
headers:{
'Content-Type':'application/octet-stream'
},
body:blob
window.speechSynthesis.speak(new SpeechSynthesisUtterance("From fairest creatures we desire increase, That thereby beauty's rose might never die, But as the ripershould by time decease,His tender heir might bear his memory"));
@rezonn
rezonn / TF_trainable_function.html
Last active May 12, 2020 15:19
TensorFlow.js trainable function javascript
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tfjs-vis.umd.min.js"></script>
<script>
function plot(x,y,z) {
var [x_,y_,z_] = [x,y,z||y].map( (t)=>t.arraySync() );
var p = x_.map(function(x__,i){return {x:x__,y:y_[i]} });
var p1 = x_.map(function(x__,i){return {x:x__,y:z_[i]} });
tfvis.render.scatterplot({name:"",tab:'Charts'},{values:[p,p1]});
@rezonn
rezonn / macos_tips.sh
Last active June 5, 2022 10:49
macOS terminal tips
#update nodejs
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
#macos python -> ssh -> win10
cat helloworld.py | ssh [email protected] python -
#all webm to mp4
for f in *.webm; do ffmpeg -fflags +genpts -i "$f" -r 24 "$f.mp4"; done
@rezonn
rezonn / OpenCV_example.htm
Created May 6, 2020 03:22
OpenCV.js basic example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function ascript(src){
return new Promise((resolve, reject) => {
let script2 = document.createElement('script');
script2.async = true;
@rezonn
rezonn / run.bat
Created May 5, 2020 07:41
Desktop application from JavaScript. Chrome app mode. Windows 10
cd %~dp0
"%PROGRAMFILES(X86)%\Google\Chrome\Application\chrome.exe" --app=http://localhost:8000/index.html | node.exe server.js
pause
@rezonn
rezonn / webgl.htm
Created May 5, 2020 07:18
100% Native Javascript WebGL
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<script id="vshader" type="VERTEX_SHADER">
uniform mat4 position;
uniform mat4 camera;
attribute vec3 aVertexPosition;
void main() {
gl_Position = position * camera * vec4(aVertexPosition, 0.9);
@rezonn
rezonn / Connect_raspberry_to_router.sh
Created May 5, 2020 04:39
Connect Raspberry/OperWRT to router via LAN. Terminal/UCI
#setup router as '192.168.1.200' in router settings
uci set network.lan.ipaddr='192.168.1.1'
uci set network.lan.gateway='192.168.1.200'
uci set network.lan.dns='8.8.8.8'
uci commit && service network restart