Skip to content

Instantly share code, notes, and snippets.

@smahs
smahs / dj_rest.py
Last active Mar 28, 2016
Micro REST Framework for Django: A Prototype
View dj_rest.py
from django.views.generic import View
from django.http import (
QueryDict, HttpResponse, HttpResponseBadRequest,
HttpResponseNotFound, HttpResponseNotAllowed,
)
from django.core.serializers.json import DjangoJSONEncoder
from django.core.exceptions import (
ObjectDoesNotExist, ValidationError,
)
from django.db import transaction
@entropiae
entropiae / fix_git_sslread_9806.sh
Last active Feb 3, 2022
git: how to solve "SSLRead() return error -9806" in OSX using brew
View fix_git_sslread_9806.sh
$ brew remove git
$ brew remove curl
$ brew install openssl
$ brew install --with-openssl curl
$ brew install --with-brewed-curl --with-brewed-openssl git
@postrational
postrational / gunicorn_start.bash
Last active Feb 22, 2022
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
View gunicorn_start.bash
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@GrahamDumpleton
GrahamDumpleton / gist:b380652b768e81a7f60c
Last active Apr 7, 2022
Setting environment variables for Apache/mod_wsgi hosted Python application.
View gist:b380652b768e81a7f60c

Django documentation says to use:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
@ines
ines / Install
Last active Apr 27, 2022
Streamlit + spaCy
View Install
pip install streamlit
pip install spacy
python -m spacy download en_core_web_sm
python -m spacy download en_core_web_md
python -m spacy download de_core_news_sm
@miry
miry / 01_extract_crt.rb
Last active Jun 12, 2022
Extract certificate from the kubernetes config.
View 01_extract_crt.rb
require 'optparse'
require 'yaml'
require 'base64'
options = {
config_path: File.join(ENV['HOME'], '.kube', 'config'),
write_dir: File.join(ENV['HOME'], '.kube')
}
OptionParser.new do |opts|
@nerdalert
nerdalert / Netfilter-IPTables-Diagrams.md
Last active Jun 30, 2022
Linux NetFilter, IP Tables and Conntrack Diagrams
View Netfilter-IPTables-Diagrams.md

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

@Atem18
Atem18 / gist:4696071
Last active Jul 1, 2022 — forked from evildmp/gist:3094281
Tutorial to seting up a django website in production.
View gist:4696071

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
@jboner
jboner / latency.txt
Last active Jul 2, 2022
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD