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 / gist:35d021882ff1053a2b27bd5931835cfe
Created March 20, 2017 12:46 — forked from moraes/gist:2141121
LIFO Stack and FIFO Queue in golang
package main
import (
"fmt"
)
type Node struct {
Value int
}
package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
@ego008
ego008 / main.go
Created February 28, 2017 06:51 — forked from benbjohnson/main.go
Bolt for timestamp data
package main
import (
"encoding/binary"
"log"
"time"
"github.com/boltdb/bolt"
)
@ego008
ego008 / store.go
Created February 28, 2017 06:17 — forked from benbjohnson/store.go
Session Store Expiration
package store
import (
"fmt"
"github.com/boltdb/bolt"
)
// reap removes sessions older than a given duration.
// This function assumes that all session data is stored in a "sessions" bucket
@ego008
ego008 / store.go
Created February 28, 2017 06:17 — forked from benbjohnson/store.go
Session Store Expiration
package store
import (
"fmt"
"github.com/boltdb/bolt"
)
// reap removes sessions older than a given duration.
// This function assumes that all session data is stored in a "sessions" bucket
@ego008
ego008 / des.go
Created February 22, 2017 07:44 — forked from cuixin/des.go
des ecb mode in golang
package main
import (
"bytes"
"crypto/des"
"errors"
)
func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
padding := blockSize - len(ciphertext)%blockSize
@ego008
ego008 / tornado_websocket_ee.py
Created January 19, 2017 09:42 — forked from gnpkrish/tornado_websocket_ee.py
Realtime Communicating with front-end using simple EventEmitter. With use of Tornado + Websocket.
"""
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
#!/usr/bin/env python
# coding:utf-8
import _env
from time import time
from urllib import urlencode
from urllib2 import urlopen as urlopen2
from urlparse import parse_qsl
from hashlib import md5
from urlgrabber import urlopen
import errno
@ego008
ego008 / aiohttp+websockets.md
Created October 28, 2016 02:03
aiohttp server with websocket

** aiohttp now supports in its webframework websocket **

http://aiohttp.readthedocs.org/en/v0.14.1/web.html#websockets

This is a quick hack (ported from django-c10k) to get websocket working along side classic http with aiohttp web server. I think it would be better to inherit the aiohttp.web.RequestHandler and add the code to handle the upgrade in RequestHandler.start instead of overriding RequestHandler.transport.close in WebsocketResponse.

Anyway, it seems like it works.

requirements:

@ego008
ego008 / start-stop-example.sh
Created October 21, 2016 01:48 — forked from alobato/start-stop-example.sh
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar