from django.db import connection | |
# If using cursor without "with" -- it must be closed explicitly: | |
with connection.cursor() as cursor: | |
cursor.execute('select column1, column2, column3 from table where aaa=%s', [5]) | |
for row in cursor.fetchall(): | |
print row[0], row[1], row[3] |
#!/usr/bin/env python | |
"""Simple HTTP Server With Upload. | |
This module builds on BaseHTTPServer by implementing the standard GET | |
and HEAD requests in a fairly straightforward manner. | |
""" |
# http block | |
geoip_city /usr/local/share/GeoIP/GeoIPCity.dat; | |
geoip_country /usr/local/share/GeoIP/GeoIPCountry.dat; | |
# location block | |
proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code; | |
proxy_set_header GEOIP_COUNTRY_CODE3 $geoip_country_code3; | |
proxy_set_header GEOIP_COUNTRY_NAME $geoip_country_name; |
import torch | |
import torch.nn as nn | |
import torch.nn.parallel | |
class DCGAN_D(nn.Container): | |
def __init__(self, isize, nz, nc, ndf, ngpu, n_extra_layers=0): | |
super(DCGAN_D, self).__init__() | |
self.ngpu = ngpu | |
assert isize % 16 == 0, "isize has to be a multiple of 16" |
This is a basic collection of things I do when setting up a new headless ubuntu machine as a webserver. Following the steps below should give you a reasonable secure server with HTTP/2 support (including ALPN in chrome) and the fast NGINX server. I am happy to add things so leave a comment.
After creating the server (droplet on DigitalOcean) log in with
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
INSTALLED_APPS = ( | |
'modeltranslation', | |
'djangocms_admin_style', # for the admin skin. You **must** add 'djangocms_admin_style' in the list **before** 'django.contrib.admin'. | |
# Boostrap admin theme | |
# 'django_admin_bootstrapped.bootstrap3', | |
# 'django_admin_bootstrapped', | |
# Apps bundled with Django |
Latency Comparison Numbers | |
-------------------------- | |
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 | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |