sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50
codeup:13b | |
codeup:13b-llama2 | |
codeup:13b-llama2-chat | |
codeup:13b-llama2-chat-q2_K | |
codeup:13b-llama2-chat-q3_K_L | |
codeup:13b-llama2-chat-q3_K_M | |
codeup:13b-llama2-chat-q3_K_S | |
codeup:13b-llama2-chat-q4_0 | |
codeup:13b-llama2-chat-q4_1 | |
codeup:13b-llama2-chat-q4_K_M |
// The polling function | |
function poll(fn, timeout, interval) { | |
var endTime = Number(new Date()) + (timeout || 2000); | |
interval = interval || 100; | |
var checkCondition = function(resolve, reject) { | |
var ajax = fn(); | |
// dive into the ajax promise | |
ajax.then( function(response){ | |
// If the condition is met, we're done! |
import sqlalchemy as sa | |
import sqlalchemy.orm as orm | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.ext.declarative import declared_attr | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
DBSession = scoped_session(sessionmaker()) | |
class BaseMixin(object): | |
query = DBSession.query_property() | |
id = sa.Column(sa.Integer, primary_key=True) |
// This is a simple NodeJS app to display triggered events on a smart contract | |
// you need your contract ABI and deployed address and also a synced geth running | |
// github.com/shayanb | |
var optionsABI = [YOUR_CONTRACT_ABI] | |
var contractAddress = "0xYOUR_CONTRACT_ADDRESS" | |
var Web3 = require('web3'); |
[uwsgi] | |
disable-logging = True | |
socket = /srv/qrs/test/wsgi.sock | |
chdir = /srv/qrs/test | |
chmod = 660 | |
master = true | |
processes = 2 | |
module = qrs.wsgi:application | |
virtualenv = /env/qrs/test | |
enable-threads = true |
What I did to get Python 3.4.2 on Ubuntu 14.04. The stock version of Python 3 on Ubuntu is 3.4.0. Which is missing some of the best parts! (asyncio, etc). Luckily I discovered pyenv which solved my problem.
Pyenv (not to be confused with pyvenv) is the Python equivelant of rbenv. It lets you configure which Python environment/version is available per directory, user, or other session variables.
I followed the instructions here to install pyenv in my home directory. Verbatem, those instructions are:
sudo apt-get install git python-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
<?php | |
/** | |
* ----------------------------------------------------------------------------------------- | |
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php` | |
* ----------------------------------------------------------------------------------------- | |
*/ | |
// HTML Minifier | |
function minify_html($input) { |
from django.db import connection | |
from django.utils.log import getLogger | |
logger = getLogger(__name__) | |
class QueryCountDebugMiddleware(object): | |
""" | |
This middleware will log the number of queries run | |
and the total time taken for each request (with a | |
status code of 200). It does not currently support |
By default when Nginx starts receiving a response from a FastCGI backend (such as PHP-FPM) it will buffer the response in memory before delivering it to the client. Any response larger than the set buffer size is saved to a temporary file on disk. This process is also explained at the Nginx ngx_http_fastcgi_module page document page.
Since disk is slow and memory is fast the aim is to get as many FastCGI responses passing through memory only. On the flip side we don't want to set an excessively large buffer as they are created and sized on a per request basis (i.e. it's not shared memory).
The related Nginx options are:
fastcgi_buffering
appeared in Nginx 1.5.6 (1.6.0 stable) and can be used to turn buffering completely on/off. It's on by default.- [
fastcgi_buffer_size
](http://nginx.org/en/