Skip to content

Instantly share code, notes, and snippets.

View ego008's full-sized avatar
🏠
Working from home

Ybb ego008

🏠
Working from home
View GitHub Profile
@ego008
ego008 / test_ws.py
Created January 10, 2019 13:38 — forked from crodjer/test_ws.py
Application to demonstrate testing tornado websockets
'''
Application to demonstrate testing tornado websockets.
Try it wiith: python -m tornado.testing discover
'''
from tornado import testing, httpserver, gen, websocket
from ws import APP
@ego008
ego008 / make_safely_shutdown.py
Created December 26, 2018 12:30 — forked from nicky-zs/make_safely_shutdown.py
Make the tornado httpserver.HTTPServer to be shutdown safely.
# vim: fileencoding=utf-8
import time, signal
from tornado import web, ioloop, options, httpserver
_SHUTDOWN_TIMEOUT = 30
def make_safely_shutdown(server):
io_loop = server.io_loop or ioloop.IOLoop.instance()
def stop_handler(*args, **keywords):
def shutdown():
@ego008
ego008 / gist:52aa72ffdbd41ff33af99260b0e26f2e
Last active December 26, 2018 11:51 — forked from methane/gist:2185380
Tornado Example: Delegating an blocking task to a worker thread pool from an asynchronous request handler
import time
import tornado
from tornado.concurrent import run_on_executor
from concurrent.futures import ThreadPoolExecutor # `pip install futures` for python2
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, RequestHandler
from tornado import gen
import asyncio
import base64
import hashlib
from japronto.app import Application
class NaiveWsBaseProtocol(asyncio.Protocol):
@staticmethod
def accept(key):
@ego008
ego008 / gchart_offline.html
Created November 27, 2018 12:35 — forked from makevoid/gchart_offline.html
GChart offline example
<!--
How to use Google JS Visualization Api offline, step by step
this approach might work with other libraries loaded with google.load, after all it's still JavaScript!!!
-->
<!DOCTYPE html>
<html>
@ego008
ego008 / unixhttpc.go
Created July 11, 2018 08:02 — forked from teknoraver/unixhttpc.go
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
package main
import (
"fmt"
"github.com/ego008/selenium"
"net"
"time"
"os"
)
package main
import (
agwd "github.com/sclevine/agouti"
tbwd "github.com/tebeka/selenium"
"log"
sgwd "sourcegraph.com/sourcegraph/go-selenium"
)
// Helper for sourcegraph/go-selenium
@ego008
ego008 / get.js
Created May 12, 2018 11:19 — forked from rafaelstz/get.js
AJAX GET and POST with pure Javascript
// Exemplo de requisição GET
var ajax = new XMLHttpRequest();
// Seta tipo de requisição e URL com os parâmetros
ajax.open("GET", "minha-url-api.com/?name=Henry&lastname=Ford", true);
// Envia a requisição
ajax.send();
// Cria um evento para receber o retorno.
@ego008
ego008 / golang_proxy_simple.go
Last active May 9, 2018 10:42
Golang http/https proxy
package main
// ex $ curl --proxy http://127.0.0.1:12345 -L https://www.google.com
import (
"bytes"
"io"
"log"
"net"
"net/url"