Skip to content

Instantly share code, notes, and snippets.

@nileshtrivedi
nileshtrivedi / home-server.md
Last active June 1, 2024 00:11
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

@tiagocoutinho
tiagocoutinho / s2net.py
Last active June 27, 2024 16:07
Python serial to tcp
"""
tsb.py -- A telnet <-> serial port bridge
Copyright (C) 2005 Eli Fulkerson
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
@untra
untra / record.sh
Last active January 28, 2024 18:09
ffmpeg rtsp to hls recording script
# /bin/sh
# ./record.sh -i 192.168.0.47:554 -v 11 -r 1280x720
# Some sane defaults for the environment.
DATE=`date +%Y-%m-%d`
TIME=`date +%H-%M-%S`
CAMERA_USER='admin'
CAMERA_PASS='admin'
CAMERA_IP='10.10.10.1'
CAMERA_NAME='cam1'
@checkaayush
checkaayush / suds_object_to_dict.py
Created October 10, 2016 20:55
Convert Suds object to Python dictionary
# Source: http://stackoverflow.com/questions/17581731/parsing-suds-soap-complex-data-type-into-python-dict
def basic_sobject_to_dict(obj):
"""Converts suds object to dict very quickly.
Does not serialize date time or normalize key case.
:param obj: suds object
:return: dict object
"""
if not hasattr(obj, '__keylist__'):
return obj
@ivanleoncz
ivanleoncz / flask_app_logging.py
Last active May 23, 2021 07:25
Demonstration of logging feature for a Flask App.
#/usr/bin/python3
""" Demonstration of logging feature for a Flask App. """
from logging.handlers import RotatingFileHandler
from flask import Flask, request, jsonify
from time import strftime
__author__ = "@ivanleoncz"
import logging
@longhotsummer
longhotsummer / leaflet-big-image-full.html
Created April 5, 2016 06:47
Full example of using leaflet to pan and zoom a big image, as described at http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html
<html>
<!-- See also: http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html -->
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"></script>
<style>
#image-map {
width: 100%;
height: 300px;
border: 1px solid #ccc;
margin-bottom: 10px;
@allanlei
allanlei / publish.py
Created February 26, 2016 05:09
MQTT Example
import paho.mqtt.client as mqtt
client = mqtt.Client(protocol=mqtt.MQTTv311)
client.connect('iot.eclipse.org', port=1883, keepalive=60)
client.publish('update', 'hello world')
@mowings
mowings / readme.md
Last active April 9, 2024 20:51
ffmpeg stream and save video from Dahua 4300s IP Camera

Use ffmpeg to stream video from a dahua 4300s to a file or files

You can use ffmpeg to directly pull frames off of a dahua 4300s at full resolution. May be a good alternative to pricey dvrs which likely cannot record at full resolution, may not work with the camera, or are prohibitevly expensive

Simple Stream to file

Simple stream to file. Full resolution

ffmpeg -loglevel debug -rtsp_transport tcp -i "rtsp://admin:admin@198.175.207.61:554/live" \

-c copy -map 0 foo.mp4

@ryesalvador
ryesalvador / pizilla-pygtk.py
Last active November 17, 2021 02:11
Python + PyGTK + WebKit + Raspberry Pi
# pizilla-pygtk.py
import gtk, webkit
class window(gtk.Window):
def __init__(self):
super(window, self).__init__()
self.set_title("Pizilla-PyGTK")
@onjin
onjin / pydispatcher_demo.py
Created May 6, 2014 13:30
pydispatcher demo
#!/usr/bin/env python
# encoding: utf-8
"""
pydispatcher demo
requirements: pip install pydispatcher
"""