This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This program receives the accurate string of the username (as written by `net user`) | |
and log offs the session associated with that user, if any is active. | |
In order to log off another users on the system, Administrator permissions | |
are required. Thus, the program should be run as an Administrator. | |
Flow of the code is: | |
1) Enumerate active sessions | |
2) For each session, enumerate the username string associated with the session |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A small program that log off a user (possibly in another session) in Windows | |
This is actually an implementation in Python of the `LogoffUser.cpp` program I have made. | |
I made that program in order to automate the manual operation of logging off my family | |
user in the workstation each time after they have used it :) | |
LogoffUser.cpp link: https://gist.github.com/ohaval/a922fc07f4585b81c119614e852d9dbd | |
Make sure that the `pywin32` packages is installed before using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
I wanted to play with the clipboard via Windows API so I wrote a small program that | |
checks if the clipboard contains an image, and if so saves the image as a .bmp file. | |
This program obtains the handle on the clipboard data, put together all of the | |
information and raw data a .bmp file holds, and writes it to the disk. | |
With small changes it's possible to make this code run in a loop and save an image | |
from the clipboard every X seconds. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Tuple | |
def quick_sort(lst: List[int]) -> List[int]: | |
"""The Quicksort algorithm. | |
Wikipedia: https://en.wikipedia.org/wiki/Quicksort | |
""" | |
if len(lst) < 2: | |
return lst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def bubble_sort(lst: List[int]) -> None: | |
"""The Bubble sort algorithm. | |
The sorted list is placed in place. | |
Wikipedia: https://en.wikipedia.org/wiki/Bubble_sort | |
""" | |
for i in range(len(lst) - 1, 0, -1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def merge_sort(lst: List[int]) -> List[int]: | |
"""The Merge sort algorithm. | |
Wikipedia: https://en.wikipedia.org/wiki/Merge_sort | |
""" | |
if len(lst) <= 1: | |
return lst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def insertion_sort(lst: List[int]) -> None: | |
"""The Insertion sort algorithm. | |
The sorted list is placed in place. | |
Wikipedia: https://en.wikipedia.org/wiki/Insertion_sort | |
""" | |
for i in range(1, len(lst)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def selection_sort(lst: List[int]) -> None: | |
"""The Selection sort algorithm. | |
The sorted list is placed in place. | |
Wikipedia: https://en.wikipedia.org/wiki/Selection_sort | |
""" | |
for i in range(len(lst) - 1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def cycle_sort(lst: List[int]) -> None: | |
"""The Cycle sort algorithm. | |
The sorted list is placed in place. | |
Wikipedia: https://en.wikipedia.org/wiki/Cycle_sort | |
""" | |
for i in range(len(lst) - 1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This example shows how easy it is to generate and export ECDSA keys with python. | |
This program is similar to `ssh-keygen -t ecdsa` with no passphrase. | |
To export the private key with a passphrase, read paramiko.pkey.PKey._write_private_key method. | |
""" | |
import paramiko | |
from cryptography.hazmat.primitives.serialization import ( | |
Encoding, PrivateFormat, PublicFormat, NoEncryption | |
) |
OlderNewer