Skip to content

Instantly share code, notes, and snippets.

@sarjsheff
sarjsheff / tasmota-to-gun.js
Created June 7, 2020 06:23
Store tasmota mqtt events in GUN database.
var Gun = require('gun');
const gun = Gun("http://localhost:8888/gun");
gun.get("switches").map().on(function(v, name) {
console.log(name, v.status, v.power || "ON", v.temp || "?");
})
var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://localhost', {
username: "sonoff",
@sarjsheff
sarjsheff / Auth.js
Last active June 7, 2020 12:38
Authorization react + socket.io
import React, { useState, useEffect } from "react";
import * as io from "socket.io-client";
const socket = io();
function Auth() {
const [auth, setAuth] = useState(false);
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [name, setName] = useState("");
@sarjsheff
sarjsheff / cors.js
Created June 13, 2020 17:04
Allow CORs for Express
...
app.use((r, rs, n) => {
rs.setHeader("Access-Control-Allow-Origin", "*")
rs.setHeader("Content-Type", "application/json")
rs.setHeader("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE")
rs.setHeader("Access-Control-Allow-Headers", "Content-Type")
n();
})
...
@sarjsheff
sarjsheff / inline.sh
Created August 18, 2020 19:00
Video on background OSX
vlc --video-wallpaper --zoom 2 --no-osd <url>
@sarjsheff
sarjsheff / job.sh
Created August 19, 2020 18:49
Script for always restart service. +ash +openwrt
#!/bin/sh
if [ -z ${1} ]
then
echo "Set shell script."
else
trap 'kill $(jobs -p);logger exit;exit' SIGINT SIGTERM EXIT
for i in `seq 1 50000`
do
@sarjsheff
sarjsheff / example.md
Last active October 27, 2020 09:04
Sequelize associations

Model

...
  User.init(
    {
      username: { type: DataTypes.STRING, primaryKey: true },
      password: { ...def },
      fio: { ...def },
    },
@sarjsheff
sarjsheff / dtest.sh
Last active February 9, 2021 15:36
docker test
#!/bin/sh
#docker rm -f $(docker ps -a -q)
for I in $(seq 1 50)
do
docker run --name nginx$I -p 90$I:80 -d nginx &
pids[${i}]=$!
done
@sarjsheff
sarjsheff / app-pom.xml
Created April 14, 2021 09:37
maven ssh repository
...
<repositories>
<repository>
<id>ssh-repository</id>
<url>scp://192.168.1.1/maven</url>
</repository>
</repositories>
<build>
<extensions>
@sarjsheff
sarjsheff / filter.sh
Created April 26, 2021 16:17
iptables lua
# opkg install iptables-mod-lua
iptables -A INPUT -j LUA --script ./script.lua
@sarjsheff
sarjsheff / test.sh
Last active April 27, 2021 07:09
ubus openwrt
# 10 last log messages
ubus -v call log read '{"lines":10,"stream":false,"oneshot":true}'
# boardinfo
ubus call system board
# system stat
ubus call system info