Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block ls0f

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aescalana /
Last active May 24, 2020
Decode and Encode Flask's session cookie. Great for testing purposes; only the secret key is needed
#!/usr/bin/env python
from flask.sessions import SecureCookieSessionInterface
from itsdangerous import URLSafeTimedSerializer
class SimpleSecureCookieSessionInterface(SecureCookieSessionInterface):
# Override method
# Take secret_key instead of an instance of a Flask app
def get_signing_serializer(self, secret_key):
if not secret_key:
return None
walm / main.go
Last active May 27, 2020
Simple Golang DNS Server
View main.go
package main
import (
dooglus /
Created Aug 13, 2016
create Bitcoin public key from private key
#! /usr/bin/env python
class Point(object):
def __init__(self, _x, _y, _order = None): self.x, self.y, self.order = _x, _y, _order
def calc(self, top, bottom, other_x):
l = (top * inverse_mod(bottom)) % p
x3 = (l * l - self.x - other_x) % p
return Point(x3, (l * (self.x - x3) - self.y) % p)
ygweric / util.m
Last active Nov 16, 2015
数字转中文大写 obj-c
View util.m
+ (NSString*)numberToChineseUppercase:(double)num{
int iLen,iNum,iAddZero=0;
NSMutableString *szChMoney = [[NSMutableString alloc] init];
NSArray *hzUnit = @[@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"亿",@"",@"",@"",@"",@"",@"",@""];
NSArray *hzNum = @[@"",@"",@"",@"",@"",@"",@"",@"",@"",@""];
NSString *szNum = [NSString stringWithFormat:@"%18.0f",num*100];
szNum = [szNum stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
iLen =(int) szNum.length;
crazygit /
Last active Nov 30, 2018
免翻墙安装Go tools
#!/usr/bin/env bash
# 免翻墙安装Go tools
mkdir -p $GOPATH/src/
git clone -b $branch $GOPATH/src/
git clone $GOPATH/src/
go install
import sys, cv2
# Refactored
def cascade_detect(cascade, image):
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
return cascade.detectMultiScale(
scaleFactor = 1.15,
minNeighbors = 5,
adamnew123456 /
Last active Apr 5, 2020
Pratt Parser For Arithmetic Expressions
This implements a fairly simple expression language via a Pratt-style parser.
The language supports fairly standard floating point literals, such as:
glombard /
Created Nov 24, 2014
Merging 4 images into one with Python and PIL/Pillow
# Combine multiple images into one.
# To install the Pillow module on Mac OS X:
# $ xcode-select --install
# $ brew install libtiff libjpeg webp little-cms2
# $ pip install Pillow
from __future__ import print_function
jbardin / proxy_copy.go
Last active Feb 17, 2020
Go TCP Proxy pattern
View proxy_copy.go
package proxy
import (
func Proxy(srvConn, cliConn *net.TCPConn) {
// channels to wait on the close event for each connection
debrice / Flask-SQLAlchemy
Last active Nov 24, 2019
Flask SQLAlchemy Caching
View Flask-SQLAlchemy

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.


retrieve one object

# pulling one User object
user = User.query.get(1)
You can’t perform that action at this time.