Skip to content

Instantly share code, notes, and snippets.

View reznov11's full-sized avatar
🎯
Focusing

Ammar reznov11

🎯
Focusing
View GitHub Profile
@reznov11
reznov11 / nginx-tuning.md
Created October 27, 2020 12:05 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@reznov11
reznov11 / models_committed.py
Created June 23, 2020 17:51 — forked from letmaik/models_committed.py
delete, insert, update events after a commit for SQLAlchemy
from sqlalchemy import create_engine, event, orm
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm.session import Session as SessionBase, object_session
from sqlalchemy.event.api import listen
# The following adds delete, insert, and update events after successful commits.
# SQLAlchemy provides only events after flushes, but not after commits.
# The classes are adapted from Flask-SQLAlchemy.
# see also https://stackoverflow.com/a/12026787/60982
@reznov11
reznov11 / unlimited_trials_babeledit.txt
Created April 9, 2020 15:51 — forked from Fusseldieb/unlimited_trials_babeledit.txt
Activate BabelEdit temporarily / Unlimited trial
Obviously for educative purposes only.
Furthermore, this DOESN'T activate BabelEdit permanently.
If you like the software, buy it, the devs deserve it.
Since I have no money to buy it, I discovered a workaround for unlimited trials.
It's quite a annoying workaround, but ... it works!
Firstly go to "c:\windows\system32\drivers\etc\" and open the "hosts" file in Notepad/Notepad++/VSCode/Sublime/Atom/whatever as admin (if you don't open it as admin, it won't let you save it).
Add this line at the end of the file:
@reznov11
reznov11 / soup_prettify2.py
Created December 21, 2018 18:54 — forked from dmattera/soup_prettify2.py
A simple way set custom indentation levels when using BeautifulSoup's soup.prettify()
# Python == 3.6.2
# bs4 == 4.6.0
# The current version of BeautifulSoup's soup.prettify() function only allows for
# an indentation level = to 1 space. This is a simple, reliable way to allow for the use
# of any indentation level you wish.
import requests
@reznov11
reznov11 / blinker_signal.py
Created December 20, 2018 22:28 — forked from doobeh/blinker_signal.py
Blinker/Signal Flask Example
from flask import Flask, current_app
from blinker import Namespace
app = Flask(__name__)
app.secret_key = 'WOO'
my_signals = Namespace()
def moo_signal(app, message, **extra):
@reznov11
reznov11 / curl.md
Created August 11, 2018 00:21 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@reznov11
reznov11 / gist:8bc35d054200a9ba0989d40dd32f7d88
Created June 13, 2018 11:43 — forked from Sinkler/gist:bfc2099235ac96937f34
Flask-OAuthlib sample config: twitter, facebook, instagram, vk
# Twitter
from app.config import TWITTER_APP_KEY, TWITTER_APP_SECRET
twitter_oauth = oauth.remote_app(
'twitter',
consumer_key=TWITTER_APP_KEY,
consumer_secret=TWITTER_APP_SECRET,
base_url='https://api.twitter.com/1.1/',
request_token_url='https://api.twitter.com/oauth/request_token',