Skip to content

Instantly share code, notes, and snippets.

View pingf's full-sized avatar
💭
waiting for delivery!

Makefile君 pingf

💭
waiting for delivery!
View GitHub Profile
@pingf
pingf / login-example
Created February 23, 2016 08:48 — forked from bkdinoop/login-example
Flask-Login : login.py created by https://github.com/maxcountryman : Matthew Frazier
# -*- coding: utf-8 -*-
"""
Flask-Login example
===================
This is a small application that provides a trivial demonstration of
Flask-Login, including remember me functionality.
:copyright: (C) 2011 by Matthew Frazier.
:license: MIT/X11, see LICENSE for more details.
"""
@pingf
pingf / gist:dbd16cdbeed84a007def
Created March 1, 2016 03:10 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@pingf
pingf / gist:59b46ae40a8ee743ff54ffadeb608310
Created November 1, 2016 08:15 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@pingf
pingf / btree.py
Created November 24, 2016 03:26 — forked from teepark/btree.py
a pure-python B tree and B+ tree implementation
import bisect
import itertools
import operator
class _BNode(object):
__slots__ = ["tree", "contents", "children"]
def __init__(self, tree, contents=None, children=None):
self.tree = tree
@pingf
pingf / stream_to_youtube.sh
Created March 17, 2017 07:15 — forked from olasd/stream_to_youtube.sh
Stream video to youtube via ffmpeg
#! /bin/bash
#
# Diffusion youtube avec ffmpeg
# Configurer youtube avec une résolution 720p. La vidéo n'est pas scalée.
VBR="2500k" # Bitrate de la vidéo en sortie
FPS="30" # FPS de la vidéo en sortie
QUAL="medium" # Preset de qualité FFMPEG
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" # URL de base RTMP youtube
@pingf
pingf / dom-to-json.js
Created August 29, 2017 08:51 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
node = node || this;
var obj = {
nodeType: node.nodeType
};
if (node.tagName) {
obj.tagName = node.tagName.toLowerCase();
} else
if (node.nodeName) {
obj.nodeName = node.nodeName;
@pingf
pingf / aiohttp+websockets.md
Created January 15, 2018 07:17 — forked from amirouche/aiohttp+websockets.md
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:

@pingf
pingf / aiohttp+websockets.md
Created January 15, 2018 07:17 — forked from amirouche/aiohttp+websockets.md
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:

@pingf
pingf / aiohttp+websockets.md
Created January 15, 2018 07:17 — forked from amirouche/aiohttp+websockets.md
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: