Skip to content

Instantly share code, notes, and snippets.

View LeMeteore's full-sized avatar

Nsukami _ LeMeteore

  • Nil
  • Somewhere in the universe
View GitHub Profile
@LeMeteore
LeMeteore / comprehensions.md
Created March 27, 2016 15:09 — forked from bearfrieze/comprehensions.md
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain

@LeMeteore
LeMeteore / on_stateful_code.txt
Created March 14, 2016 19:58 — forked from josteink/on_stateful_code.txt
On why stateful code is bad
On why stateful code is bad
===========================
STUDENT: Sir, can I ask a question?
TEACHER: Yes!
STUDENT: How do you put an elephant inside a fridge?
TEACHER: I don't know.
STUDENT: It's easy, you just open the fridge and put it in. I have another question!
TEACHER: Ok, ask.
STUDENT: How to put a donkey inside the fridge?
@LeMeteore
LeMeteore / upgrade_postgres_92_93_debian.sh
Created March 10, 2016 05:48 — forked from doole/upgrade_postgres_92_93_debian.sh
Upgrade PostgreSQL 9.2 to 9.3 of Debian Wheezy
#!/bin/bash
# Update and upgrade packages
sudo apt-get update && sudo apt-get upgrade
# Install postgres 9.3
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3
# Having Postgres 9.2 already, this will create database instance configured to run on port 5433
@LeMeteore
LeMeteore / latency.txt
Created February 17, 2016 12:52 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
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 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
@LeMeteore
LeMeteore / cors-nginx.conf
Created February 9, 2016 18:41 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@LeMeteore
LeMeteore / replace-debian-with-arch.txt
Created January 28, 2016 16:59 — forked from m-ou-se/replace-debian-with-arch.txt
Instructions to replace a live Debian installation with Arch
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/
wget http://ftp.nluug.nl/os/Linux/distr/archlinux/iso/2016.01.01/archlinux-bootstrap-2016.01.01-x86_64.tar.gz
# Make sure you'll have enough entropy for pacman-key later.
apt-get install haveged
# Install the arch bootstrap image in a tmpfs.
mount -t tmpfs none /mnt
cd /mnt
tar xvf ~/archlinux-bootstrap-2016.01.01-x86_64.tar.gz --strip-components=1
@LeMeteore
LeMeteore / cron.go
Created January 20, 2016 15:53 — forked from stupidbodo/cron.go
Golang - Keep more than 1 program running forever (similar to cron job but shorter interval)
package main
import (
"fmt"
"runtime"
"time"
)
var (
INTERVAL_SEC = 10
@LeMeteore
LeMeteore / http_get.go
Created January 20, 2016 01:44 — forked from ijt/http_get.go
Example of using http.Get in go (golang)
package main
import (
"fmt"
"http"
"io/ioutil"
"os"
)
func main() {
@LeMeteore
LeMeteore / springer-free-maths-books.md
Created December 29, 2015 18:37 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links

Nginx Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400,000 to 500,000 requests per second (clustered), most what i saw is 50,000 to 80,000 (non-clustered) requests per second and 30% CPU load, course, this was 2xIntel Xeon with HT enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

First, you will need to install nginx, my way to install nginx is compiling it from source, but for now we will use apt-get