Skip to content

Instantly share code, notes, and snippets.

@ficapy
ficapy / install_nginx_http2.md
Created May 21, 2019 05:49
install nginx with http2 support on ubuntu 14.04
sudo service nginx stop
sudo apt-get remove nginx nginx-common

sudo add-apt-repository ppa:fxr/nginx-alpn
sudo apt-get update

sudo apt-get install nginx
sudo service nginx restart
from shapely.geometry import Polygon
from matplotlib import pyplot as plt
from shapely.ops import cascaded_union
import geopandas as gpd
m = cascaded_union([Polygon(i if i[0] == i[-1] else i[:-2].append(i[0])) for i in [
[
[81.300003051757812, 37.588695526123047],
[75.599998474121094, 37.588695526123047],
[75.599998474121094, 39.888694763183594],
import numpy as np
np.array([8.218,-9.341]) + np.array([-1.129,2.111])
np.array([7.119,8.215]) - np.array([-8.223,0.878])
7.41 * np.array([1.671,-1.012,-0.318])
@ficapy
ficapy / pdfaddtext.py
Created March 30, 2018 08:21
网页版本使用(20页使用限制) https://ocr.ficapy.com
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: ficapy
import io
from urllib.parse import urlencode
from base64 import b64encode
from pdf2image import convert_from_bytes
from PyPDF2 import PdfFileWriter, PdfFileReader
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: ficapy
# Create: '12/03/2018'
from threading import Lock, get_ident
class RLock:
@ficapy
ficapy / phash.py
Last active May 12, 2019 13:48
将phash得到的64位数据转换成bigint方便存储到数据库
from PIL import Image
import imagehash
def get_phash(file_path):
img = Image.open(file_path)
phash = imagehash.phash(img).hash.flatten()
phash_list = list(map(bool, phash))
if phash_list[0] is True:
@ficapy
ficapy / bk_tree.py
Last active March 4, 2018 02:18
BK树和VP树
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: ficapy
# Create: '03/03/2018'
import random
from string import ascii_lowercase
def distance(str1: str, str2: str):
@ficapy
ficapy / single_vs_batch_update.py
Created December 27, 2017 10:59
Postgresql 批量更新对比单条更新
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: ficapy
import random
import csv
import time
from functools import wraps
from io import StringIO
from contextlib import closing, contextmanager
package main
import (
"encoding/gob"
"encoding/json"
"fmt"
"os"
"strings"
"sync"
@ficapy
ficapy / proxy_dns.go
Created December 19, 2017 03:44
对特定域名根据内网域名是否可以访问返回特定的ip
package main
import (
"log"
"net"
"os"
"os/signal"
"syscall"
"time"