Skip to content

Instantly share code, notes, and snippets.

ls0f

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
aescalana / manageFlaskSession.py
Last active May 24, 2020
Decode and Encode Flask's session cookie. Great for testing purposes; only the secret key is needed
View manageFlaskSession.py
#!/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
walm / main.go
Last active May 27, 2020
Simple Golang DNS Server
View main.go
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@dooglus
dooglus / public.py
Created Aug 13, 2016
create Bitcoin public key from private key
View public.py
#! /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
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
crazygit / install_go_tools.sh
Last active Nov 30, 2018
免翻墙安装Go tools
View install_go_tools.sh
#!/usr/bin/env bash
# 免翻墙安装Go tools
branch="release-branch.go1.4"
mkdir -p $GOPATH/src/golang.org/x
git clone -b $branch git@github.com:golang/tools.git $GOPATH/src/golang.org/x/tools
git clone git@github.com:golang/net.git $GOPATH/src/golang.org/x/net
cd $GOPATH
go install golang.org/x/tools/cmd/goimports
View face_detect.py
import sys, cv2
# Refactored https://realpython.com/blog/python/face-recognition-with-python/
def cascade_detect(cascade, image):
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
return cascade.detectMultiScale(
gray_image,
scaleFactor = 1.15,
minNeighbors = 5,
@adamnew123456
adamnew123456 / arithmetic.py
Last active Apr 5, 2020
Pratt Parser For Arithmetic Expressions
View arithmetic.py
"""
This implements a fairly simple expression language via a Pratt-style parser.
The language supports fairly standard floating point literals, such as:
5
1.09
.16
12e7
@glombard
glombard / combine.py
Created Nov 24, 2014
Merging 4 images into one with Python and PIL/Pillow
View combine.py
# 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
jbardin / proxy_copy.go
Last active Feb 17, 2020
Go TCP Proxy pattern
View proxy_copy.go
package proxy
import (
"io"
"log"
"net"
)
func Proxy(srvConn, cliConn *net.TCPConn) {
// channels to wait on the close event for each connection
@debrice
debrice / Flask-SQLAlchemy Caching.md
Last active Nov 24, 2019
Flask SQLAlchemy Caching
View Flask-SQLAlchemy Caching.md

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.

Usage

retrieve one object

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