Restrict the amount of CPU and memory resources that Chrome can consume.
Tested on Ubuntu 16.04/Linux Mint 18.
Install cgroups:
sudo apt install cgroup-bin
function iso7064Mod97_10(iban) { | |
var remainder = iban, | |
block; | |
while (remainder.length > 2){ | |
block = remainder.slice(0, 9); | |
remainder = parseInt(block, 10) % 97 + remainder.slice(block.length); | |
} | |
return parseInt(remainder, 10) % 97; |
Restrict the amount of CPU and memory resources that Chrome can consume.
Tested on Ubuntu 16.04/Linux Mint 18.
Install cgroups:
sudo apt install cgroup-bin
server { | |
listen 80; | |
listen [::]:80; | |
server_name radio.example.com; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Server $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
location / { |
# place this into /usr/share/icecast2/web/json.xsl | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> | |
<xsl:output omit-xml-declaration="yes" method="text" indent="no" media-type="text/javascript" encoding="UTF-8"/> | |
<xsl:strip-space elements="*"/> | |
<xsl:template match="/icestats">{ | |
<xsl:for-each select="source"> | |
"<xsl:value-of select="@mount"/>":{ | |
"server_name":"<xsl:value-of select="server_name"/>", | |
"listeners":"<xsl:value-of select="listeners"/>", | |
"description":"<xsl:value-of select="server_description"/>", |
# Install dependencies (if needed) | |
$ yum install -y xorg-x11-fonts-75dpi | |
$ yum install -y xorg-x11-fonts-Type1 | |
$ yum install xz | |
# Get latest version of wkhtmltopdf (replace version number if needed) | |
$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz | |
# Untar and move wkhtmltox | |
$ unxz wkhtmltox-0.12.4_linux-generic-amd64.tar.xz |
See also:
Open Spotify
Test play/pause key in case it works already
import UUID | |
from sqlalchemy.dialects.mysql import BINARY | |
from sqlalchemy.types import TypeDecorator | |
class BinaryUUID(TypeDecorator): | |
'''Optimize UUID keys. Store as 16 bit binary, retrieve as uuid. | |
inspired by: | |
http://mysqlserverteam.com/storing-uuid-values-in-mysql-tables/ |
const req = require.context('./components/', true, /\.(js|vue)$/i); | |
req.keys().map(key => { | |
const name = key.match(/\w+/)[0]; | |
return Vue.component(name, req(key)) | |
}); |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.