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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / go-pipelines.md
Created April 4, 2016 08:05 — forked from brandur/go-pipelines.md
Go Pipelines

Go Pipelines

This document demonstrates a basic pipeline in Go and talks about a risk in in implementing them. Keep in mind that:

  • Using FizzBuzz here is contrived, but quite a nice way to demonstrate the concept. Obviously there is no advantage to running the basic workload of FizzBuzz in a Goroutine, but if the task involved heavy computation or long lived I/O, it starts to make a lot more sense.
  • The problem discussed only applies to Goroutines that actually need to have a way to
@LeMeteore
LeMeteore / ajax_setup.js
Created April 8, 2016 19:20 — forked from rca/ajax_setup.js
Setup Django CSRF token in JQuery AJAX requests
/**
* setup JQuery's AJAX methods to setup CSRF token in the request before sending it off.
* http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
*/
function getCookie(name)
{
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
@LeMeteore
LeMeteore / kill_thread.c
Created April 16, 2016 16:03 — forked from ymmt2005/kill_thread.c
Kill a specific thread externally by using tgkill(2).
#include <signal.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
#include <sys/types.h>
#include <unistd.h>
int main() {
pid_t tgid=18456;
pid_t tid=24671;
return syscall(SYS_tgkill, tgid, tid, SIGABRT);
}