Skip to content

Instantly share code, notes, and snippets.

View insert_csv_to_db.go
package main
import (
"database/sql"
"encoding/csv"
"fmt"
_ "github.com/mattn/go-sqlite3"
"io"
"log"
"os"
View gitlab_403_forbidden.md
  1. docker exec -it gitlab /bin/sh
  2. /opt/gitlab/embedded/bin/redis-cli -s /var/opt/gitlab/redis/redis.socket
  3. keys cache:gitlab:rack::attack*
  4. del cache:gitlab:rack::attack:allow2ban:ban:172.17.0.1
@ficapy
ficapy / install_nginx_http2.md
Created May 21, 2019
install nginx with http2 support on ubuntu 14.04
View install_nginx_http2.md
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
View show_polygon.py
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],
View linear_algebra.py
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 Mar 30, 2018
网页版本使用(20页使用限制) https://ocr.ficapy.com
View pdfaddtext.py
#!/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
View thread_lock.py
#!/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
将phash得到的64位数据转换成bigint方便存储到数据库
View phash.py
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 Mar 4, 2018
BK树和VP树
View bk_tree.py
#!/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 Dec 27, 2017
Postgresql 批量更新对比单条更新
View single_vs_batch_update.py
#!/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
You can’t perform that action at this time.