This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| see: http://pyqt.sourceforge.net/Docs/PyQt4/qcoreapplication.html#aboutToQuit | |
| ''' | |
| import threading | |
| from PyQt4 import QtCore, QtGui | |
| class Thread(QtCore.QThread): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://stackoverflow.com/questions/19542333/websocket-server-sending-messages-periodically-in-python | |
| import tornado.httpserver | |
| import tornado.websocket | |
| import tornado.ioloop | |
| from tornado.ioloop import PeriodicCallback | |
| import tornado.web | |
| class WSHandler(tornado.websocket.WebSocketHandler): | |
| def open(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import json | |
| import logging | |
| import websockets | |
| import aioredis | |
| logging.basicConfig(level=logging.INFO) | |
| # STATE = {'value': 0} | |
| USERS = set() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import redis | |
| import time | |
| pool = redis.ConnectionPool(host='192.168.137.3', port=6379, password='', decode_responses=True) | |
| r = redis.Redis(connection_pool=pool) | |
| STREAM_NAME = "consumer" | |
| GROUP_NAME = "g1" | |
| CONSUMER_NAME = "c1" | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # bash generate random alphanumeric string | |
| # | |
| # bash generate random 32 character alphanumeric string (upper and lowercase) and | |
| NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
| # bash generate random 32 character alphanumeric string (lowercase only) | |
| cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM golang:1.9 | |
| WORKDIR /go/src/github.com/purplebooth/example | |
| COPY . . | |
| RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go | |
| FROM scratch | |
| COPY --from=0 /go/src/github.com/purplebooth/example/main /main | |
| CMD ["/main"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <QtWidgets> | |
| #include <QtSql> | |
| //to ensure the database connection is closed and removed at the end | |
| //of the write/read func call | |
| class SQLConnectionRAIIWrapper{ | |
| public: | |
| SQLConnectionRAIIWrapper(QString fileName){ | |
| //use a unique connection name, to ensure thread safety | |
| connectionName = QString("SQLSETTINGS%1").arg((int)QThread::currentThreadId()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| loop = asyncio.get_event_loop() | |
| async def hello(): | |
| await asyncio.sleep(3) | |
| print('Hello!') | |
| if __name__ == '__main__': | |
| loop.run_until_complete(hello()) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Config file for mosquitto | |
| # | |
| # See mosquitto.conf(5) for more information. | |
| # | |
| # Default values are shown, uncomment to change. | |
| # | |
| # Use the # character to indicate a comment, but only if it is the | |
| # very first character on the line. | |
| # ================================================================= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # http://stackoverflow.com/questions/14180179/eventlet-spawn-doesnt-work-as-expected/14180227#14180227 | |
| from flask import Flask | |
| import time | |
| import eventlet | |
| eventlet.monkey_patch() | |
| app = Flask(__name__) |
NewerOlder