Skip to content

Instantly share code, notes, and snippets.

@hwmrocker
hwmrocker / restore_me.py
Created November 14, 2011 22:33
restore broken dejadup / duplicity fullbackup without manifest
#!/usr/bin/env python
import os
FROM = '/media/New Volume/dejadup-bakup'
TO_TMP = '/home/johndoe/tmp'
TO_MULTI = TO_TMP + '/multivol_snapshot'
TO_SNAP = TO_TMP + '/snapshot'
@hwmrocker
hwmrocker / reclaimWindows10.ps1
Created January 11, 2017 09:02 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
@hwmrocker
hwmrocker / water.py
Last active December 27, 2015 00:58
twitter wall problem
# used the skeleton from https://gist.github.com/igor47/7228586
def water(levels):
lefties = [(levels[0],0)]
volume = 0
for level in levels[1:]:
lefties = [(lelft_level, distance+1) for lelft_level, distance in lefties]
mini = lefties[-1][0]
maxi = lefties[0][0]
if level < mini:
for user_id in d.getUsers():
filen = "out/%s.png" % user_id
if os.path.exists(filen):
continue
i += 1
if i > 20:
exit(0) # we are not done yet
# ... build the figure
fig.savefig(filen, dpi=300)
print "done..."
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import DictProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@hwmrocker
hwmrocker / gist:4944245
Last active December 13, 2015 16:59 — forked from ruxkor/cmp.coffee
coffescript deep compare
# comparison function, checking also the contents of elements if we are comparing 2 arrays.
# very useful for sorting.
cmp = (a,b) ->
typemap =
'null': 0
'undefined': 0
'number': 1
'string': 1
'object': 2
#/usr/bin/env python
import re
import subprocess
def get_networks_in_range_fast(lines=None):
if lines is None:
lines = subprocess.check_output(['nmcli', 'dev', 'wifi', 'list']).splitlines()
re_key = re.compile(r'[A-Z]+\s*')
first_line = lines[0]
keylist = []

Keybase proof

I hereby claim:

  • I am hwmrocker on github.
  • I am hwmrocker (https://keybase.io/hwmrocker) on keybase.
  • I have a public key whose fingerprint is 3D54 D870 C32B 4778 2FF5 71B3 94DB A9BC 6517 8870

To claim this, I am signing this object:

class UniqueMeta(type):
def __new__(cls, *foo, **kw):
tmp = type.__new__(cls, *foo, **kw)
tmp._COUNTER = 0
return tmp
class UniquePizza(metaclass=UniqueMeta):
# Copyright (c) 2014
# David Allouche
# Jp Calderone & Itamar Shtull-Trauring
# Johan Dahlin
# Olaf Gladis
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell