Skip to content

Instantly share code, notes, and snippets.

View thusoy's full-sized avatar

Tarjei Husøy thusoy

View GitHub Profile
@thusoy
thusoy / netst
Created February 3, 2015 14:37
Windows equivalent of netstat -tulpn
#!/bin/bash
# Normally windows doesn't give out the process name when you run netstat -ano, thus making it
# hard to figure out what process is bound to the different ports. This script extracts the PID
# from the netstat output, and fetches the corresponding binary name from the tasklist, and
# merges the two together. Needs a MinGW environment like Git Bash and python to work.
{ tasklist | tail -n +5; echo ===; netstat -ano | grep LIST; } | python -c "
import sys
pad = [0, 21, 9, 0, 5, 8, 0]
@thusoy
thusoy / debug_logger.py
Created December 4, 2013 21:36
A short example of how to log output from a NXT device using python. and jaraco.nxt.
def log():
print("Establishing connection...")
conn = Connection(3, timeout=5)
print('Logging output...')
while True:
print('Listening for output...')
try:
resp = conn.receive()
except struct.error:
print("Timed out")