Skip to content

Instantly share code, notes, and snippets.

@jorgepsmatos
jorgepsmatos / cloudSettings
Last active March 13, 2021 22:05
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-03-13T22:05:37.704Z","extensionVersion":"v3.4.3"}
@jorgepsmatos
jorgepsmatos / SMWinservice.py
Created November 27, 2018 22:14
Python Http Server as Windows Service
'''
SMWinservice
by Davide Mastromatteo
from https://medium.com/the-python-corner/how-to-create-a-windows-service-in-python-88ca534ce76b
Base class to create winservice in Python
-----------------------------------------
Instructions:
public void ListDirectory(string remoteDirectory, string host, string username, string password)
{
try
{
using (var sftpClient = new SftpClient(host, username, password))
{
sftpClient.Connect();
var files = sftpClient.ListDirectory(remoteDirectory);
public void Upload(string fileToUpload, string host, string username, string password)
{
try
{
using (var sftpClient = new SftpClient(host, username, password))
using (var fs = new FileStream(fileToUpload, FileMode.Open))
{
sftpClient.Connect();
sftpClient.UploadFile(
public void Download(string fileToDownload, string host, string username, string password)
{
try
{
using (var sftpClient = new SftpClient(host, username, password))
using (var fs = new FileStream(Path.GetFileName(fileToDownload), FileMode.OpenOrCreate))
{
sftpClient.Connect();
sftpClient.DownloadFile(
public void Delete(string fileToDelete, string host, string username, string password)
{
try
{
using (var sftpClient = new SftpClient(host, username, password))
{
sftpClient.Connect();
sftpClient.DeleteFile(fileToDelete);
#Persistent
Toggle := false ; Initialize the toggle state to "off"
Return
^!t:: ; Hotkey: Ctrl + Alt + T
Toggle := !Toggle ; Toggle the state (on/off)
If (Toggle)
{
SetTimer, LoopWindows, 6000 ; Start the timer
}