Skip to content

Instantly share code, notes, and snippets.

View tomasinouk's full-sized avatar

Tomas Blaha tomasinouk

View GitHub Profile
@tomasinouk
tomasinouk / Disable Stict host check OS X
Last active August 29, 2015 14:11
Disable strict host checking in OS X for IP subnet
# You will need to probably create ~/.ssh/config file or edit, and add the following lines:
# Host [IP Address]
# StrictHostKeyChecking no
# UserKnownHostsFile=/dev/null
# A example for whole 192.168.0.0/16 IP subnet:
Host 192.168.*.*
StrictHostKeyChecking no
@tomasinouk
tomasinouk / I2C_scanner
Created March 30, 2015 05:36
I2C scanner from Arduino playground using **wire** library
// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
@tomasinouk
tomasinouk / snat_dnat_advantech.md
Last active November 29, 2024 21:41
examples of SNAT, DNAT with iptables for Advantech, Conel routers, with comments (probably will work on other routers where iptables can be manipulated, care needs to be taken on applying these commands after reboot).

Some examples of SNAT, DNAT with iptables with comments

mainly used in start-up script

How to test 'safely'

When we play with iptables aka firewall we might end up in situation, where we execute rule, which has unforseen impact - lock yourself out. Recovering from this situation is necessity.

How to:

  • Enable reboot via SMS.
  • Test all commands in shell first before putting them into Start-up script. This way the command will be wiped out, when unit is rebooted.

masquarade all outgoing packets to be WLAN0 IP

@tomasinouk
tomasinouk / gist:1c59a99c82ed8df7c3f5
Last active August 29, 2015 14:21
logrotate and pm2 logs
# logrotate and pm2 logs
# file location
# /etc/logrotate.d/pm2
/root/.pm2/logs/*.log {
daily
rotate 15
missingok
notifempty
sharedscripts
-- control 2 first neopixels via RGB
--ws2812.writergb(2, string.char(100,255,0,255,0,0))
-- control 8 neopixels with same RGB color
-- ws2812.writergb(2, string.char(100,255,0):rep(8))
-- -- control 8 neopixels with same RGB color - turn off
ws2812.writergb(2, string.char(0,0,0):rep(8))
@tomasinouk
tomasinouk / battery_capacity_nodemcu
Last active August 3, 2016 17:36
Reading battery capacity nodeMCU - lua
id=0
-- represent actually PIN on nodeMCU such as
-- D7 and D5 in this case
-- GND needs to be connected
sda=7 -- GPIO13
scl=5 -- GPIO14
-- initialize i2c, set pin1 as sda, set pin2 as scl
i2c.setup(id,sda,scl,i2c.SLOW)
@tomasinouk
tomasinouk / parse_conel_smartworkx_gps.py
Last active October 27, 2016 22:29
Takes GPS and Cellular metrics from Conel, SmartWorkx router and write *.csv file. I used different method for parsing of each metrics as an exercise. Running Python from USB stick and writing file to a USB stick.
# run that in start-up script
# echo "Time UTC (GPS);Latitude;Longtitude;Altitude;Satellites;Fix;Speed over ground;Course over Ground;Date (GPS);Date (router);Time (Router)" > location_report.csv
import csv
import time
import datetime
import os.path
import os
csv_header_text = "Time UTC (GPS);Latitude;Longtitude;Altitude;Satellites;Fix;Speed over ground;Course over Ground;Date (GPS);Date (router);Time (Router); Cell Technology;Cell ID;Signal Strength;Signal Quality\n"
@tomasinouk
tomasinouk / Westermo-SNMP-SHDSL.md
Last active November 18, 2015 01:44
Westermo SNMP SHDSL

Speed of SHDSL(1):

IF-MIB::ifSpeed.4096 = Gauge32: 15288000

  • OID: snmptranslate -On IF-MIB::ifSpeed.4096 -> .1.3.6.1.2.1.2.2.1.5.4096

SHDSL IN:

IF-MIB::ifInOctets.4096 = Counter32: 10923350

  • OID snmptranslate -On IF-MIB::ifInOctets.4096 -> .1.3.6.1.2.1.2.2.1.10.4096
@tomasinouk
tomasinouk / ffmpeg_examples.md
Created November 30, 2015 04:21
ffmpeg examples for streaming full screen

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -tune zerolatency -b:v 500k -bufsize 300k -f rtp rtp://localhost:1234

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -tune zerolatency -b:v 500k -bufsize 300k -f rtp udp://127.0.0.1:1234

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -tune zerolatency -b:v 500k -bufsize 300k -f mpegts udp://127.0.0.1:1234

ffmpeg -f avfoundation -i "1" -vcodec libx264 -r 10 -pix_fmt uyvy422 -tune zerolatency -b:v 500k -bufsize 300k -f mpegts udp://192.168.88.38:1234

@tomasinouk
tomasinouk / conel-enable-disable-wireless.md
Last active November 3, 2017 14:45
How to enable and disable wireless (cellular, wifi) on Conel, SmartWorkx routers. This is more for v2 routers as v3 does have more options, such as entering power saving mode.

Solution to disable and enable radio interfaces on Conel, SmartWorkx routers based on time.

Solution is to change the setting of the router enable/disable and reboot the router for the setting to be used by router.

I used two time constants:

  • On timer - TIME_ON
  • Off timer - TIME_OFF

Script to copy paste into Configuration -> Start-up Script setting of the Conel router.