Skip to content

Instantly share code, notes, and snippets.

@nikola
nikola / drives.py
Created November 4, 2014 20:23
Enumerate drives
# coding: utf-8
import re
from itertools import izip_longest
import win32com.client
from win32file import GetDriveType
from win32api import GetLogicalDriveStrings, GetVolumeInformation
@nikola
nikola / genchromeappid.py
Created November 11, 2014 16:18
Generate Chrome Application ID
import hashlib
def getChromeApplicationId(pathname):
if len(pathname) > 1 and pathname[0].islower() and pathname[1] == ":":
pathname = pathname[0].upper() + pathname[1:]
pathname = pathname.encode("utf-16le")
offset = ord("a")
applicationId = "".join([chr(int(digit, 16) + offset) for digit in hashlib.sha256(pathname).hexdigest()[:32]])
@nikola
nikola / getpywin32color.py
Created November 11, 2014 16:23
Get Win32 Color Brush
import ctypes
def getColorBrush(red=0, green=0, blue=0):
class _COLORREF(ctypes.Structure):
_fields_ = [
('byRed', ctypes.c_byte),
('byGreen', ctypes.c_byte),
('byBlue', ctypes.c_byte),
]
return ctypes.windll.gdi32.CreateSolidBrush(_COLORREF(red, green, blue))
@nikola
nikola / enum.js
Created November 19, 2014 17:08
Create enumeration
Array.apply(null, Array(1000)).map(Function.prototype.call.bind(Number))