Skip to content

Instantly share code, notes, and snippets.

@gschizas
gschizas / pythonproxy.py
Created September 16, 2012 11:03
A python proxy in less than 100 lines of code
#!/usr/bin/python
# This is a simple port-forward / proxy, written using only the default python
# library. If you want to make a suggestion or fix something you can contact-me
# at voorloop_at_gmail.com
# Distributed over IDC(I Don't Care) license
# http://voorloopnul.com/blog/a-python-proxy-in-less-than-100-lines-of-code/
import socket
import select
import time
import sys
Import-Module WebAdministration
# Get the latest certificate in store that applies to my site
$cert = (Get-ChildItem Cert:\LocalMachine\My |
Where-Object {$_.Subject.Contains('*.example.com')} |
Sort-Object -Descending {[System.DateTime]::Parse($_.GetExpirationDateString())} |
Select-Object -First 1)
Set-Location IIS:\Sites
@gschizas
gschizas / requestsprogress.py
Created September 16, 2012 11:04
Requests with progressbar in python
r = requests.get(file_url)
size = int(r.headers['Content-Length'].strip())
self.bytes = 0
widgets = [name, ": ", Bar(marker="|", left="[", right=" "),
Percentage(), " ", FileTransferSpeed(), "] ",
self,
" of {0}MB".format(str(round(size / 1024 / 1024, 2))[:4])]
pbar = ProgressBar(widgets=widgets, maxval=size).start()
file = []
for buf in r.iter_content(1024):
@gschizas
gschizas / FixVirtualNetworkAdapters.ps1
Created February 15, 2013 05:11
Fix virtual network adapters
# see http://msdn2.microsoft.com/en-us/library/bb201634.aspx
#
# *NdisDeviceType
#
# The type of the device. The default value is zero, which indicates a standard
# networking device that connects to a network.
#
# Set *NdisDeviceType to NDIS_DEVICE_TYPE_ENDPOINT (1) if this device is an
# endpoint device and is not a true network interface that connects to a network.
# For example, you must specify NDIS_DEVICE_TYPE_ENDPOINT for devices such as
@gschizas
gschizas / AddApplicationToControlledFolder.ps1
Last active March 6, 2022 06:53
Allow all blocked apps to Windows Defender's Controlled folder access (interactively)
$appEvents = Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" |
Where-Object {$_.Id -eq "1123"}
$allBlockedProcesses = (
$appEvents |
ForEach-Object {
(([xml]$_.ToXml()).Event.EventData.Data |
Where-Object {
$_.Name -eq "Process Name"
}).'#text'
} |
@gschizas
gschizas / clear_emoji.py
Last active May 27, 2021 18:25
Mass upload emoji to reddit redesign alpha
from tqdm import tqdm
from praw_wrapper import praw_wrapper
r = praw_wrapper(scopes=['read', 'structuredstyles'])
subreddit = input("Enter your subreddit name here: ")
sr = r.subreddit(subreddit)
all_emojis = r.get(f"/api/v1/{subreddit}/emojis/all")
@gschizas
gschizas / README.md
Created March 12, 2021 01:01
Convert Amstrad CPC Video Memory to an PIL Image

Some assumptions:

  • The file being read has video memory stored in the first 0x4000 (16384) bytes.
  • The screen hasn't been scrolled
  • Screen mode and border and palette inks follow the main data:
    • MODE is a single byte in position 0x4000
    • BORDER (unused) is in position 0x4001
  • INKS 0-15 follow in positions 0x4002-0x4011
@gschizas
gschizas / Amstrad-CPC-6128.kbd.json
Last active November 2, 2020 18:22
Amstrad CPC 6128
[
{
"name": "Amstrad CPC 6128",
"background": {
"name": "PBT Black",
"style": "background-image: url('/bg/plastic/pbt-black.png');"
},
"pcb": false
},
[
@gschizas
gschizas / Amstrad-CPC-464__6128_.kbd.json
Last active November 2, 2020 18:22
Amstrad CPC 464+/6128+
[
{
"name": "Amstrad CPC 464+/6128+",
"background": {
"name": "ABS WA",
"style": "background-image: url('/bg/plastic/abs-wa.jpg');"
}
},
[
{
@gschizas
gschizas / Amstrad-CPC-664.kbd.json
Last active November 2, 2020 18:21
Amstrad CPC 664
[
{
"backcolor": "#403030",
"name": "Amstrad CPC 664"
},
[
{
"x": 17.25,
"c": "#90A0C0",
"t": "#101010",