Skip to content

Instantly share code, notes, and snippets.

@sinanm89
sinanm89 / README.md
Last active August 29, 2015 14:19 — forked from lbolla/README.md

Asynchronous programming with Tornado

Asynchronous programming can be tricky for beginners, therefore I think it's useful to iron some basic concepts to avoid common pitfalls.

For an explanation about generic asynchronous programming, I recommend you one of the [many][2] [resources][3] [online][4].

I will focus on solely on asynchronous programming in [Tornado][1]. From Tornado's homepage:

from zope.interface import implements
from twisted.python import usage
from twisted.plugin import IPlugin
from twisted.application.service import IServiceMaker
from twisted.application import internet
from gameserver.server_main import VersusGameFactory, logger
class Options(usage.Options):
9/16 18:40:39.145 Login program=WoW platform=Wn64 locale=enUS
9/16 18:40:39.176 Component WoW.Wn64.20490
9/16 18:40:39.192 Component WoW.base.20490
9/16 18:40:39.254 Battle.net is Component Bnet.Wn64.37165
9/16 18:40:39.270 LOGIN: state: LOGIN_STATE_CONNECTING result: LOGIN_OK
9/16 18:40:39.301 Connecting to 95.85.2.67:1119
9/16 18:40:39.504 LOGIN: state: LOGIN_STATE_FAILED result: LOGIN_UNKNOWN_ACCOUNT
9/16 18:40:39.520 Disconnected from 95.85.2.67
9/16 18:40:39.536 Client initiated Disconnect from 95.85.2.67
9/16 18:40:39.567 LOGIN: state: LOGIN_STATE_FAILED result: LOGIN_UNKNOWN_ACCOUNT
9/16 20:36:13.918 Login program=WoW platform=Win locale=enUS
9/16 20:36:13.937 Component WoW.Win.20490
9/16 20:36:13.968 Component WoW.base.20490
9/16 20:36:14.031 Battle.net is Component Bnet.Win.37165
9/16 20:36:14.062 LOGIN: state: LOGIN_STATE_CONNECTING result: LOGIN_OK
9/16 20:36:14.093 Connecting to 95.85.2.67:1119
9/16 20:36:14.709 LOGIN: state: LOGIN_STATE_FAILED result: LOGIN_FAILED
9/16 20:36:14.725 Disconnected from 95.85.2.67
9/16 20:36:14.756 Client initiated Disconnect from 95.85.2.67
9/16 20:36:14.772 Client initiated Disconnect from 95.85.2.67
try:
failing_thing()
except SomeException as e:
exception = SomeException()
exception.message = e.message
raise exception
@sinanm89
sinanm89 / .wakeup
Created July 5, 2016 07:39 — forked from ralph089/.wakeup
Restarts Bluetooth Module on Mac OS X El Capitan. Use it with SleepWatcher to automatically restart your Bluetooth Module on wakeup.
#!/bin/bash
#
# Restart Bluetooth Module on Mac OS X
#
# Requires Blueutil to be installed: http://brewformulas.org/blueutil
BT="/usr/local/bin/blueutil"
log() {
echo "$@"
@sinanm89
sinanm89 / no_mans_sky_fix.rst
Last active August 14, 2016 19:35
No mans Sky fix 14.Aug.2016

How to fix No mans Sky on Windows 10 running Strix970

I originally left this comment on TCB's video but the comments are disabled (oops didnt know, makes sense though).

I couldnt play when I first got the game and I had prepurchased. It actually took me about 3 hours to get the game working because everytime I changed an option to optimize my game I HAD TO RESTART IT. That being said I love the game. It reminds me of the fun I used to have playing MYST and Ultima Online.

Heres How

import json
# chart v3 has a list of asteroids that are in a non-changable order
# each asteroid has a cycle which changes each turn
# an astroid with an offset 0 is an illegal move
# initial offset value is given
# find the shortest path (in terms of turns) to reach the end.
class Ship(object):
# TODO: the ports should be dynamically set from the data_service.env file
version: '3'
services:
my_app_service:
container_name: my_app
restart: "no"
build:
context: .
env_file:
- ./config/my_app.env