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 / ubuntu-php7-install.bash
Last active July 6, 2016 02:54
Ubuntu 14.04 PHP7 (Install from Source)
#!/usr/bin/env bash
sudo -i;
apt-get update;
apt-get install --yes \
git \
bison \
autoconf \
@ego008
ego008 / index.html
Created December 16, 2015 09:24 — forked from CodeMyUI/index.html
Material Design Register Login Form
<div class="materialContainer">
<div class="box">
<div class="title">LOGIN</div>
<div class="input">
<label for="name">Username</label>
<input type="text" name="name" id="name">
from math import ceil
class Pagination(object):
"""A Pagination object to be used for querying and displaying pagination links on frontend
Example usage:
>>> p = Pagination(total=15, per_page=5, current_page=1, side_page_num=3)
>>> p.start
0
@ego008
ego008 / nginx
Created April 23, 2016 07:16 — forked from vdel26/nginx
Openresty init.d script
#!/bin/sh
#
# chkconfig: 2345 55 25
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
# For Debian, run: update-rc.d -f nginx defaults
# For CentOS, run: chkconfig --add nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
@ego008
ego008 / tornado_asyncio.py
Created August 15, 2016 07:07 — forked from drgarcia1986/tornado_asyncio.py
Tornado and Asyncio Mixed example
# -*- coding: utf-8 -*-
import asyncio
import re
import asyncio_redis
import tornado.concurrent
import tornado.httpclient
import tornado.web
import tornado.platform.asyncio
@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
@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:

#!/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 / 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
@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