Skip to content

Instantly share code, notes, and snippets.

@gschizas
gschizas / spell.py
Created November 23, 2011 20:05
Spell almost any email in NATO phonetic alphabet
#!/usr/bin/python
# -*- coding: utf-8 -*-
# inspired by a comment in http://redd.it/mmr8m
import sys
letters = {' ': 'space',
'a': 'alfa', 'b': 'bravo', 'c': 'charlie', 'd': 'delta',
@gschizas
gschizas / autorename.sql
Created September 15, 2012 18:22
Automatically rename a SQL Server based on the current computer host name
/*
This script can be used to automatically rename a SQL Server
based on the current computer host name
Run this script after:
Computer Name Changed
Virtual Machine Cloned
*/
DECLARE
@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
@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 / win32clipboard.py
Created August 30, 2013 19:09
Interact with windows clipboard
import win32clipboard
# set clipboard data
win32clipboard.OpenClipboard()
win32clipboard.SetClipboardText('testing 123')
win32clipboard.CloseClipboard()
# get clipboard data
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
Function HexDump(text)
hexdigits = ""
plaintext = ""
output = ""
For i = 1 to Len(text)
current = Mid(text, i, 1)
hexdigits = hexdigits & Right("0" & Hex(Asc(current)), 2) & " "
if Asc(current) >= 32 And Asc(current) < 127 Then
plaintext = plaintext & current
Else
#!/usr/bin/env python3
import struct
import re
class Wad(object):
"""Encapsulates the data found inside a WAD file"""
def __init__(self, wadFile):
"""Each WAD files contains definitions for global attributes as well as map level attributes"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import requests
import struct
import uuid
def java_uuid_hash_code(uuid):
leastSigBits, mostSigBits = struct.unpack('>QQ', uuid.bytes)
l1 = leastSigBits & 0xFFFFFFFF
@gschizas
gschizas / bot.py
Last active September 21, 2015 12:09
# coding: utf-8
import urllib.parse
import praw
import configparser
import datetime
import http.server
import webbrowser
from dateutil.parser import parse as dateparser