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
""" | |
This is a simple example of WebSocket + Tornado + Simple EventEmitters usage. | |
Thanks to pyee by https://github.com/jesusabdullah | |
@Author:: Narayanaperumal G <[email protected]> | |
""" | |
import tornado.httpserver | |
import tornado.websocket | |
import tornado.ioloop | |
import tornado.web | |
from collections import defaultdict |
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
# -*- coding: utf-8 -*- | |
import asyncio | |
import uvloop | |
from aiohttp.web import Application, MsgType, WebSocketResponse | |
def add_socket(app, socket, user_id): | |
if user_id in app['connections']: | |
pass |
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
sudo apt-get update | |
sudo apt-get -y upgrade | |
sudo apt-get install -y vim | |
sudo apt-get install -y tmux | |
sudo apt-get install -y gcc | |
sudo apt-get install -y build-essential | |
sudo apt-get install -y python3-setuptools |
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
class AdminFileHandler(BaseHandler): | |
@authenticated | |
def get(self, file_name): | |
_file_dir = os.path.abspath("")+"/my/path/downloads" | |
_file_path = "%s/%s" % (_file_dir, file_name) | |
if not file_name or not os.path.exists(_file_path): | |
raise HTTPError(404) | |
self.set_header('Content-Type', 'application/force-download') | |
self.set_header('Content-Disposition', 'attachment; filename=%s' % file_name) |
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
upstream appservers { | |
server 127.0.0.1:8888; | |
} | |
server { | |
server_name ~^www\.(?<domain>.+)\.dev ~^(?<domain>.+)\.dev$; | |
location / { | |
proxy_pass_header Server; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; |
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
if [ -f ~/.bashrc ]; then | |
source ~/.bashrc | |
fi | |
if [ -f ~/.bash_profile ]; then | |
source ~/.bash_profile | |
fi |
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
pip install virtualenv virtualenvwrapper | |
cp ~/.bash_profile ~/.bash_profile-org | |
printf '\n%s\n%s\n%s' '# virtualenv' 'export WORKON_HOME=~/virtualenvs' \ | |
'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bash_profile | |
source ~/.bash_profile | |
mkdir -p $WORKON_HOME |
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
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
server_name www.dipl.io dipl.io; | |
return 301 https://dipl.io$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; |
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
server { | |
listen 3000 ssl; | |
listen [::]:3000; | |
error_log /usr/local/var/log/nginx/error.log; | |
access_log /usr/local/var/log/nginx/access.log; | |
# Google DNS, Open DNS, Dyn DNS | |
resolver 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 216.146.35.35 216.146.36.36 valid=300s; | |
resolver_timeout 3s; |
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
[ | |
{ "keys": ["alt+f"], "command": "fold_function" } | |
] |