Skip to content

Instantly share code, notes, and snippets.

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
<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]) {
@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')
};
@rezonn
rezonn / windows cmd tips.bat
Last active October 19, 2020 17:02
windows cmd tips
cd %UserProfile%\Desktop
schtasks /create /tn Security Script /tr sec.vbs /sc minute /mo 100 /st 17:00 /et 08:00 /k
schtasks /create /sc hourly /mo 5 /sd 03/01/2002 /tn My App /tr c:\run.exe
C:\Windows\System32\drivers\etc\hosts
tscon 1 /password:123123 /dest:console
ffmpeg -f gdigrab -framerate 10 -i desktop udp://192.168.1.6:1234
@rezonn
rezonn / nodjs_fetch.js
Last active November 28, 2020 04:48
nodes fetch polyfill
function fetch(url,options2) {
var http = require('http');
if (url.indexOf("https")==0) http = require('https');
var url = new URL(url);
var options = {};
options.host = url.host;
options.path = url.pathname+url.search;
for (var x in options2) {
options[x]=options2[x];
}
@rezonn
rezonn / GASPolyfills.js
Last active January 28, 2021 04:49
Google Apps Script polyfills
function fetch(url,options2) {
if (options2) {
if (options2.body) {
options2.payload = options2.body.toString("binary");
options2.body = undefined;
}
}
return new Promise(function (resolve, reject) {
try {
var data = UrlFetchApp.fetch(url, options2);
@rezonn
rezonn / blender.py
Last active January 9, 2021 12:11
blender defs
import bpy
from math import *
def delete(obj):
bpy.ops.object.select_all(action='DESELECT')
obj.select_set(True)
bpy.ops.object.delete()
def box2(w,h,d):
bpy.ops.mesh.primitive_cube_add(size=1)
@rezonn
rezonn / YFinance.py
Created May 2, 2021 02:11
YFinance basic
import yfinance as yf
import matplotlib.pyplot as plt
close = yf.Ticker("BTC-USD").history(period="max").Close
print(close)
plt.figure(figsize=(8, 6))
plt.plot(close)
plt.title("BTC-USD")
plt.show()
@rezonn
rezonn / show_object.js
Created November 10, 2021 15:06
show_object.js
function show(obj) {
for (var x in obj) {
if (typeof(obj[x])!="function") {
try { console.log(x+" ="+obj[x]) }
catch(e) { console.log(x+"....") }
}
else console.log("function "+x)
}
}
@rezonn
rezonn / NodeMCU.bat
Created November 12, 2021 17:54
NodeMCU Win10
esptool --port com3 erase_flash
esptool --port com3 write_flash --flash_size=detect 0 nodemcu.bin
nodemcu-uploader --port com3 file list
nodemcu-uploader upload init.lua