Skip to content

Instantly share code, notes, and snippets.

View jeffbrl's full-sized avatar

Jeff Loughridge jeffbrl

View GitHub Profile
@codeinthehole
codeinthehole / values.py
Created June 21, 2017 13:55
Example value objects using Python 3.6's typing.NamedTuple functionality
import typing
import datetime
class Period(typing.NamedTuple):
"""
Value object representing a period in time
"""
start_dt: datetime.datetime # noqa (as flake8 doesn't support this syntax as of v3.3)
end_dt: datetime.datetime # noqa
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@einarnn
einarnn / jxmlease-netconf-sample.py
Created July 26, 2016 21:06
Simple use of jxmlease to make XML seem more like JSON
#
# Get running config from an IOS-XR device and print out some
# interface information. Shows how to use the jxmlease library
# for when you'd rather have JSON but have to deal with XML!
#
from ncclient import manager
import jxmlease
HOST = '127.0.0.1'
PORT = 8303
@varqox
varqox / install_debian_with_debootstrap_howto.md
Last active October 27, 2024 21:16
Instructions how to install Debian using debootstrap
@akorobov
akorobov / ipv6-httpd.py
Created December 11, 2013 00:58
quick ipv6 http server using python's SimpleHttpServer
import socket
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class MyHandler(SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/ip':
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
@cedbeu
cedbeu / __init__.py
Last active April 16, 2019 00:11
Minimal Flask application - Basic package design pattern Create a structure like this: `./run.py` `./webapp/__init__.py` `./webapp/views.py`
#!/usr/bin/python
# coding: utf-8
""" Filename: __init__.py
Purpose: This file is required to structure the web service as a
package, to be able to define routes in multiple modules.
This is the most basic design pattern for multiple files
Flask apps: http://flask.pocoo.org/docs/patterns/packages/
Requirements:
Author: Cédric Beuzit
"""
@marcelom
marcelom / pysyslog.py
Created December 5, 2012 18:06
Tiny Python Syslog Server
#!/usr/bin/env python
## Tiny Syslog Server in Python.
##
## This is a tiny syslog server that is able to receive UDP based syslog
## entries on a specified port and save them to a file.
## That's it... it does nothing else...
## There are a few configuration parameters.
LOG_FILE = 'youlogfile.log'