Skip to content

Instantly share code, notes, and snippets.

View zpoint's full-sized avatar
🏍️
如果把一切都准备好了再前行,那我们永远迈不出第一步。

zpoint zpoint

🏍️
如果把一切都准备好了再前行,那我们永远迈不出第一步。
View GitHub Profile
@zpoint
zpoint / v2ray_wireguard_netflix_spotify_hulu.md
Last active January 21, 2024 20:50
v2ray + wireguard to unblock gfw and netflix,spotify,hulu

I previously write a gist about how to set up v2ray + openvpn to unblock gfw and netflix

Refers to that gist for more detail.

In short, this a solution to proxy your network to bypass Firewall with stable connections, and also unblock Proxy detection for Netflix/Spotify/etc....

In my use case from China network:

wireguard

@zpoint
zpoint / gunicorn.md
Created August 4, 2021 15:58
difference bwtween gunicorn workers(sync/eventlet/gevent/thread/tornado)

gunicorn workersimage title

We've learned SyncWorker for gunicorn in part1, now let's see how other workers work

workers

contents

@zpoint
zpoint / django_and_gunicorn_part1.md
Last active August 4, 2021 15:53
django and gunicorn

django and gunicorn image title

If you've written Python web application, you will find a dozen of server framework and deployment components on the Internet

Or If you take over other teammate's project, though they are all Python code, you may found they use various framework and W(A)SGI lib

"Oh, it's django app, I can start it with python manage.py runserver, but why the deployment command is gunicorn xxx:xxx instead of python manage.py runserver". what is the concurrency capabilities of our system? How many process and thread will the server start? Is it blocking IO or non-blocking IO ?, you start to get confused

You need to understand how it works to choose the proper framework and tune the configuration

@zpoint
zpoint / sanic_singleton_unittest.md
Last active September 10, 2020 10:15
sanic global singleton and unittest

image title

global singleton

We are developing Web application based on sanic framework

Due to the complexity of business, we need to integrate http pool, redis/es pool, database connection pool, even if you're not going to use connection pool, you will need to singleton your connection to gain performance

Python's async power is based on event driven loop, all the connections need to be integrate with the loop

@zpoint
zpoint / script_aggregation.md
Last active August 15, 2020 04:50
es painless nested script aggregation and sum of all buckets

I need to achieve my goal in a single ES query:

Know how many employees in every department in a company, and get the count of active employees, new employees, and leave employees for every department, and sum these buckets to get the active/new/leave count for company

The specific condition can be described as follow(simplified version)

  • Need to search for all employee in the target company (c_company_id field)
  • Need to count the employee without a department("missing": "unknown")
  • The employee only stores hire date and leave date
  • The count of active employees in the beginning of the month(employed_origin field)
@zpoint
zpoint / v2ray_openvpn_netflix.md
Last active February 19, 2024 22:30
v2ray + openvpn to unblock gfw and netflix

If you're using wireguard please refer to v2ray+wireguard to bypass GFW and netflix/spotify/hulu

Two things need to be paid

  • vps(such as bandwagonhost)
    • If you are using China Telecom, a CN2 network is required, or you may get stuck when streaming video
    • For bandwagonhost, you need to login, click Client Area -> Services -> Order New Services to get CN2 server
  • vpn vendor to unblock netflix(a openvpn connection that can unblock netflix)

vpn

@zpoint
zpoint / painless_timezone.md
Last active August 29, 2020 02:42
es painless script with timezone/getDayOfMonth

It's easy to filter by a date range with specific timezone

  {
    "range": {
      "c_birthday": {
        "time_zone": "+08:00",
        "gte": "2019-08-27"
      }
    }

}

@zpoint
zpoint / SSLErrorDebug.md
Last active August 19, 2023 22:30
aiohttp with tlsv1
@zpoint
zpoint / PyRefcount.md
Last active February 25, 2023 08:21
Lost connection to python doesn't means they will be deallocate

In Cpython

If you create some objects and lost connection to these object, it doesn't means the object will be deallocated

# python3.5
import psutil
import os
def memory_profile():
    print("The process consumes %.2f Megabytes\n" % 
    (psutil.Process(os.getpid()).memory_info().rss / float(1000 * 1000), ))