Skip to content

Instantly share code, notes, and snippets.

View vitiral's full-sized avatar

Rett Berg vitiral

  • Google
  • Denver, CO
View GitHub Profile
@vitiral
vitiral / ip route
Last active February 20, 2018 21:21
nixos help
[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 January 16, 2018 02:44
Heading anchors

This is my heading

(#my-heading)

some other heading

See my heading

@vitiral
vitiral / asyncio_question
Created April 25, 2015 17:20
asyncio stack overflow question
import sys
import time
import socket
import asyncio
addr = ('127.0.0.1', 1064)
@asyncio.coroutine
@vitiral
vitiral / __init__.py
Last active August 29, 2015 14:15
Functions that should be standard to pandas dataframe objects
We couldn’t find that file to show.
@vitiral
vitiral / LICENSE.txt
Last active August 29, 2015 14:15
Creative Commons 0 License
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 August 29, 2015 14:15
A Simple Progress Bar to use in the command line
#!/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 September 30, 2022 10:03
ZMQ python communications

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 January 6, 2015 21:45
python import from anywhere
import imp
module = imp.find_module('path/to/module')
module = imp.load_module('module_name', *module)
@vitiral
vitiral / get_platform.py
Last active August 29, 2015 14:10
python code to get all the information about the platform into a dictionary
# 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 August 29, 2015 14:09
Functions that should be in the python builtins module
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