Skip to content

Instantly share code, notes, and snippets.

View soasme's full-sized avatar
🐷
Peppa PEG v1.16.0 is released!

Ju soasme

🐷
Peppa PEG v1.16.0 is released!
View GitHub Profile
@soasme
soasme / latency.markdown
Created November 14, 2019 02:07 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@soasme
soasme / Ansible Let's Encrypt Nginx setup
Created October 22, 2019 10:09 — forked from mattiaslundberg/Ansible Let's Encrypt Nginx setup
Let's Encrypt Nginx setup with Ansible
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@soasme
soasme / pyffi.py
Created July 16, 2018 05:36 — forked from cheery/pyffi.py
Samples of LIBFFI usage in pypy/rpython
# Simple sample of LIBFFI usage in pypy/rpython
import sys
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib import jit_libffi, rdynload, clibffi
def entry_point(argv):
lib = rdynload.dlopen('libSDL.so')
SDL_Init = rdynload.dlsym(lib, "SDL_Init")
@soasme
soasme / gist:bc248b592c18584361e693929bab745d
Created June 18, 2017 19:51 — forked from dropwhile/py27.txt
python-2.7.12 centos (rpm fpm recipe)
BUILD_VER=2.7.13
mkdir download /tmp/installdir; cd download;
curl -LO http://python.org/ftp/python/${BUILD_VER}/Python-${BUILD_VER}.tgz
tar xf Python-${BUILD_VER}.tgz
cd Python-${BUILD_VER}
# install build deps
yum -y install openssl-devel readline-devel bzip2-devel sqlite-devel zlib-devel ncurses-devel db4-devel expat-devel gdbm-devel
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@soasme
soasme / install_python.sh
Created May 17, 2017 00:23 — forked from andriisoldatenko/install_python.sh
Install local Python 2.7.10 on CentOS 7
TMP_PATH=~/tmp_install_python
# Versions section
PYTHON_MAJOR=2.7
PYTHON_VERSION=$PYTHON_MAJOR.10
mkdir $TMP_PATH && cd $TMP_PATH
# Update yum and libraries
yum -y update
@soasme
soasme / node-haskell.md
Created January 3, 2017 10:55 — forked from paf31/node-haskell.md
Reimplementing a NodeJS Service in Haskell

Introduction

At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.

Over the past few months, I have been working on two Haskell services:

  • A reimplementation of an existing socket.io service, previously written for NodeJS using TypeScript.
  • A new service, which would interact with third-party components using standard data formats from the medical industry.

I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces

@soasme
soasme / if_else.bf
Created December 25, 2016 10:48 — forked from YetAnotherMinion/if_else.bf
if else in brainfuck
if(a>=b) and else
assume input array is like this
0 1 0 A B 0
and we are pointing to A
+>+<[->-[>]<<]<[- BLOCK_A_GE_B]<[-< BLOCK_A_LT_B ]
@soasme
soasme / gist:e500fb15aa67183f95f23f0cff976b6f
Created December 13, 2016 04:14 — forked from clintel/gist:1155906
Fenced code in bullet lists with GitHub-flavoured MarkDown??

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
@soasme
soasme / gist:dc3f62d39611fec26fb9e99b47f0daa5
Created November 2, 2016 09:09 — forked from nhoad/gist:8966377
Async stdio with asyncio
import os
import asyncio
import sys
from asyncio.streams import StreamWriter, FlowControlMixin
reader, writer = None, None
@asyncio.coroutine
def stdio(loop=None):