Skip to content

Instantly share code, notes, and snippets.

@gbigwood
gbigwood / concurrent_coroutines.py
Created August 8, 2017 14:40
concurrent coroutines demonstrated
from aiohttp import ClientSession
async def get_file(name, url):
async with ClientSession() as session:
async with session.get(url) as response:
result = await response.read()
print(name, response.status)
async def parallel_on_loop():
await asyncio.gather(
@gbigwood
gbigwood / simple_coroutine.py
Last active August 8, 2017 14:29
really basic coroutine
import requests
async def requests_coroutine(name, url):
print(name, requests.get(url))
loop = asyncio.get_event_loop()
loop.run_until_complete(requests_coroutine("a", "http://www.google.com"))
loop.close()
@gbigwood
gbigwood / rivencombo.py
Created November 15, 2015 00:35
Riven Fast Q-combo click trainer (Python 3.4+)
import tkinter as tk
import time
import statistics
CIRCLE_X=100
CIRCLE_Y=120
CIRCLE_RADIUS=40
PREVIOUS_ACTION=None
CORRECT_MOVE=True
@gbigwood
gbigwood / Node.java
Last active December 17, 2015 06:19
A multicast demonstration. Please run from several machines in the same subnet. Instructions inside file due to crappy GIST description formatting.
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
/**
* To run:
@gbigwood
gbigwood / queues-sim.py
Last active January 22, 2020 03:56
Simulator and M/M/C theory analyser of several queuing pipelines of fast-food restaurants. Included are Chipotle, Subway, Starbucks, McDonalds, Chopt Feel free to modify the service rates and number of servers accordingly. It should be possible to build queuing simulations for many types of systems using this code
import random
import math
import pprint
from operator import attrgetter
import logging
logging.basicConfig(filename="queues-sim.log", level=logging.INFO,
filemode="w")
class Shop(object):