Skip to content

Instantly share code, notes, and snippets.

To create a new Device ID (and reset configuration) after cloning a VM with Syncthing, just remove the content of this folder:
- Unix-like: $HOME/.config/syncthing
- Mac: $HOME/Library/Application Support/Syncthing
- Windows XP: %AppData%/Syncthing
- Windows 7+: %LocalAppData%/Syncthing
@Kerrigan29a
Kerrigan29a / Uninstall Node in MacOS X
Last active August 13, 2017 13:10
Uninstall Node in MacOS X
npm ls -gp --depth=0 | awk -F/node_modules/ '{print $2}' | grep -v -e '^$' -e '^npm$' | xargs npm -g rm
sudo rm -rf /usr/local/lib/node_modules/
sudo rm -rf /usr/local/include/node/
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/share/man/man*/node*
sudo rm -rf /usr/local/share/man/man*/npm*
sudo rm -rf /usr/local/lib/dtrace/node.d
@Kerrigan29a
Kerrigan29a / update_datetime.py
Last active August 17, 2017 11:31
Script to update datetime when its not possible to connect to NTP servers
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import sys
from datetime import datetime, timedelta
import os
import time
#!/usr/bin/env python
# Linux usage: ./extract_tampermonkey_script.py "/home/<USER>/.config/<BROWSER>/Default/Local Extension Settings/<EXTENSION_ID>"
# i.e.: ./extract_tampermonkey_script.py "/home/foo/.config/google-chrome-beta/Default/Local Extension Settings/gcalenpjmijncebpfijmoaglllgpjagf"
# Mac usage: ./extract_tampermonkey_script.py "/Users/<USER>/Library/Application Support/Google/Chrome/Default/Local Extension Settings/<EXTENSION_ID>/"
# i.e.: ./extract_tampermonkey_script.py "/Users/foo/Library/Application Support/Google/Chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo/"
import leveldb
import sys
import re
@Kerrigan29a
Kerrigan29a / Stream2Logger.py
Created May 28, 2015 11:50
How to redirect unittest stream to the logging module
class Stream2Logger(object):
def __init__(self, stream, logger, level):
self._stream = stream
self._logger = logger
self._level = level
self._buffer = []
def write(self, message):
self._buffer.append(message)
@Kerrigan29a
Kerrigan29a / Executing Python unittest
Last active September 12, 2018 08:36
Executing Python tests that use multiprocessing module in Windows
C:\multiprocessing_unittest>python -m unittest discover
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
.
----------------------------------------------------------------------
Ran 1 test in 0.219s
OK