Skip to content

Instantly share code, notes, and snippets.

View tcalmant's full-sized avatar

Thomas Calmant tcalmant

View GitHub Profile
@tcalmant
tcalmant / HTTPWebSocketsHandler.py
Created October 25, 2022 17:47 — forked from SevenW/HTTPWebSocketsHandler.py
HTTPWebSocketsHandler extends SimpleHTTPServer with WebSockets enabling the use of HTTP and WebSockets throught the same port
'''
The MIT License (MIT)
Copyright (C) 2014, 2015 Seven Watt <info@sevenwatt.com>
<http://www.sevenwatt.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@tcalmant
tcalmant / properties_converter.py
Created September 27, 2022 13:23
Converts UTF-8 Java properties files into ISO-8859-1 with \u encoding
import pathlib
for p in pathlib.Path(".").glob("*.properties"):
with open(p, "r", encoding="utf-8") as fd:
converted = fd.read().encode("raw-unicode-escape").decode("latin1")
with open(p, "w", newline="\n", encoding="latin1") as fd:
fd.write(converted)
@tcalmant
tcalmant / cmd.info.numeric.FilPilote6Ordres.html
Created August 27, 2022 11:28
Jeedom custom template for an ESP Easy based 6-order pilot wire heating. To be placed in `jeedom/data/customTemplates/dashboard`
<div style="width:120px;min-height:35px;margin-top:10px" class="cmd #history# tooltips cmd-widget" data-type="info"
data-subtype="numeric" data-cmd_id="#id#" title="Valeur du #valueDate#, collectée le #collectDate#">
<center>
<span style="font-size: 1.2em;" class="label label-info" id="iconCmd#id#">N/A</span>
</center>
<script>
function updateText(cmdId, state) {
let iconId = "#iconCmd" + cmdId;
if (state < 11) {
$(iconId).text("Arrêt");
@tcalmant
tcalmant / apt_lock.py
Created March 17, 2017 09:40
Locks apt* tools until closed.
#!/usr/bin/env python
# -- Content-Encoding: UTF-8 --
"""
Locks apt until closed
"""
from __future__ import print_function
import time
import signal
import sys
@tcalmant
tcalmant / socks5.py
Last active January 17, 2021 21:00
A working SOCKS5 server based on asyncio (TCP Connect only)
#!/usr/bin/env python3
"""
Asyncio-based SOCKS5 Proxy
:author: Thomas Calmant
:copyright: Copyright 2017, Thomas Calmant
:license: Apache License 2.0
:version: 0.0.1
"""
@tcalmant
tcalmant / Activator.java
Last active March 17, 2017 09:39
Minimalist OSGi activator
package hello.impl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
// TODO Auto-generated method stub
System.out.println("start");
@tcalmant
tcalmant / send_mail.py
Created February 1, 2015 10:33
A small script to send mails with attachements from command line.
#!/usr/bin/python3
# -- Content-Encoding: UTF-8 --
"""
Sends e-mails with attachments
:author: Thomas Calmant
:copyright: Copyright 2014, isandlaTech
:license: Apache License 2.0
:version: 0.0.1
:status: Alpha
@tcalmant
tcalmant / pip_dl.py
Last active December 9, 2020 12:22
A script to get the URL or install pip wheels for other platforms. Useful when creating binary installers from a single OS.
#!/usr/bin/python3
# -- Content-Encoding: UTF-8 --
"""
Small script which is able to look for and install packages targeting another
platform, using pip.
This simplifies the creation of distribution files for different platform.
Only works for Python 3.4 downloads.