Skip to content

Instantly share code, notes, and snippets.

Avatar

Rett Berg vitiral

  • Google
  • Denver, CO
View GitHub Profile
@vitiral
vitiral / ip route
Last active Feb 20, 2018
nixos help
View ip route
[root@garrett-laptop:~]# ip addr
...
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1406 qdisc pfifo_fast state UNKNOWN group default qlen 500
link/none
inet 10.249.208.187/32 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::a4be:e60c:f593:2fac/64 scope link stable-privacy
valid_lft forever preferred_lft forever
[root@garrett-laptop:~]# ip route
@vitiral
vitiral / .md
Created Jan 16, 2018
Heading anchors
View .md

This is my heading

(#my-heading)

some other heading

See my heading

@vitiral
vitiral / asyncio_question
Created Apr 25, 2015
asyncio stack overflow question
View asyncio_question
import sys
import time
import socket
import asyncio
addr = ('127.0.0.1', 1064)
@asyncio.coroutine
@vitiral
vitiral / __init__.py
Last active Aug 29, 2015
Functions that should be standard to pandas dataframe objects
We couldn’t find that file to show.
@vitiral
vitiral / LICENSE.txt
Last active Aug 29, 2015
Creative Commons 0 License
View LICENSE.txt
Description
Written in 2015 by Garrett Berg <garrett@cloudformdesign.com>
© Creative Commons 0
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. THIS SOFTWARE IS DISTRIBUTED WITHOUT ANY WARRANTY.
<http://creativecommons.org/publicdomain/zero/1.0/>
@vitiral
vitiral / progress.py
Last active Aug 29, 2015
A Simple Progress Bar to use in the command line
View progress.py
#!/usr/bin/python
'''
Progress Bar - A Simple Progress Bar to use in the command line
Written in 2015 by Garrett Berg <garrett@cloudformdesign.com>
© Creative Commons 0
To the extent possible under law, the author(s) have dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. THIS SOFTWARE IS DISTRIBUTED WITHOUT ANY WARRANTY.
<http://creativecommons.org/publicdomain/zero/1.0/>
@vitiral
vitiral / README.md
Last active Oct 3, 2020
ZMQ python communications
View README.md

ZMQ python

Demonstrates some simple zmq communication

Similar to this example but usable more generally.

Quoting http://zeromq.org/area:faq:

Can I subscribe to messages using regex or wildcards?

@vitiral
vitiral / imp_anywhere.py
Created Jan 6, 2015
python import from anywhere
View imp_anywhere.py
import imp
module = imp.find_module('path/to/module')
module = imp.load_module('module_name', *module)
@vitiral
vitiral / get_platform.py
Last active Aug 29, 2015
python code to get all the information about the platform into a dictionary
View get_platform.py
# python 3
import os
import platform
import ctypes
import re
import subprocess
import psutil
def processor():
'''Get type of processor
@vitiral
vitiral / builtins.py
Last active Aug 29, 2015
Functions that should be in the python builtins module
View builtins.py
from enum import Enum
def enum(name, attrs=None):
'''enum generator function
Creates an Enum type. attrs can be: set, list, tuples or a dictionary.
The behavior is as follows:
- dictionaries and lists/tuples of the form [(name, key), (name2, key2), ...] will behave
as expected. (dictionaries will have their items() method called
- sets will be converted to zip(sorted(attrs), range(len(attrs)))
- lists/tuples without embeded tuples will do the same without sorting