Skip to content

Instantly share code, notes, and snippets.

View mohsen-hassani's full-sized avatar
📚
Reading

Mohsen Hassani mohsen-hassani

📚
Reading
View GitHub Profile
@mahmoud-eskandari
mahmoud-eskandari / README.md
Last active June 27, 2024 07:58
Install v2ray on Bridge:(Ubuntu +18 via systemd) - Upstream (Ubuntu +18/CentOS +7 via docker)

پنل x-ui

پنل تحت وب مدیریت V2ray و ساخت کاربر و مدیریت سرور

mkdir x-ui && cd x-ui
docker run -itd --network=host \
    -v $PWD/db/:/etc/x-ui/ \
 -v $PWD/cert/:/root/cert/ \
@leisurelicht
leisurelicht / workbook.md
Last active February 13, 2024 16:53
Export queryset to Excel workbook
from django.http import HttpResponse
from .utils import queryset_to_workbook

def download_workbook(request):
    queryset = User.objects.all()
    columns = (
        'first_name',
        'last_name',
        'email',
@Suhas-G
Suhas-G / Deploying Django with Gunicorn, Nginx and MySQL on Ubuntu 18.04.md
Last active June 7, 2024 18:49
Deploying Django with Gunicorn, Nginx and MySQL on Ubuntu 18.04

Deploying Django with Gunicorn, Nginx and MySQl on Ubuntu 18.04

Setting up software

  1. Update ubuntu software repository
  2. Install
    1. nginx - Serve our website
    2. mysql-server and libmysqlclient-dev - For database
    3. Python 3
  3. ufw - Firewall for our system
@gaearon
gaearon / modern_js.md
Last active June 11, 2024 07:33
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@taozle
taozle / hasattr.md
Last active November 6, 2022 10:14
How `hasattr` implemented in python

How hasattr implemented in Python

Python 2.7:

static PyObject *
builtin_hasattr(PyObject *self, PyObject *args)
{
    PyObject *v;
@carcinocron
carcinocron / debugger pause beforeunload
Last active April 25, 2024 16:48
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
"""
HexByteConversion
Convert a byte string to it's hex representation for output or visa versa.
ByteToHex converts byte string "\xFF\xFE\x00\x01" to the string "FF FE 00 01"
HexToByte converts string "FF FE 00 01" to the byte string "\xFF\xFE\x00\x01"
"""
#-------------------------------------------------------------------------------
@Atem18
Atem18 / gist:4696071
Last active April 19, 2024 11:18 — forked from evildmp/gist:3094281
Tutorial to seting up a django website in production.

Set up Django, Nginx and Gunicorn in a Virtualenv controled by Supervisor

Steps with explanations to set up a server using:

  • Virtualenv
  • Virtualenvwrapper
  • Django
  • Gunicorn