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
vagrant@ubuntu-groovy:~$ sudo unshare --mount bash
root@ubuntu-groovy:/home/vagrant# ls /proc
1 115 1324 157 180 21 26 29 373 473 490 556 606 629 66620 682 83 9 97 bus devices fb irq kpagecgroup meminfo net scsi sys uptime
10 116 1325 16 195 22 27 3 387 474 52538 558 617 635 66621 79 84 91 98 cgroups diskstats filesystems kallsyms kpagecount misc pagetypeinfo self sysrq-trigger version
101 12 1398 17 196 229 273 30 39529 475 52557 56868 618 64015 66632 792 85 92 99 cmdline dma fs kcore kpageflags modules partitions slabinfo sysvipc version_signature
102 121 1399 173 197 23 274 31 39530 476 54058 6 619 643 674 80 86 94 acpi consoles driver interrupts keys loadavg mounts pressure softirqs thread-self v
from cffi import FFI
ffi = FFI()
ffi.cdef("""
void *malloc(size_t size);
#define CLONE_NEWNS 0x00020000
#define CLONE_NEWCGROUP 0x02000000
#define CLONE_NEWUTS 0x04000000
#define CLONE_NEWIPC 0x08000000
package main
import (
"archive/zip"
"fmt"
"io/ioutil"
"os"
"strings"
)
xxx = ts("xxx").align(’1m’, 'max')
yyy = ts('yyy').align(''1m', 'min')
zzz = add(xxx, yyy, groupby='region').rename('zzz')
zzz = xxx.pipe(add, yyy, groupby='region')
query(zzz, data)
live_loop :chords do
play chord(:F, :major), amp: 2, sustain: 1
sleep 2
play chord(:G, :major), amp: 2, sustain: 1
sleep 2
play chord(:E, :minor), amp: 2, sustain: 1
sleep 2
play chord(:A, :minor), amp: 2, sustain: 1
sleep 2
end
@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 / vault
Created November 5, 2019 04:32
chmod +x vault; ./vault bash
#!/usr/bin/env python
import os
import sys
import subprocess
from getpass import getpass
from pykeepass import PyKeePass
kp = PyKeePass(os.environ['VAULT_STORE_PATH'], password=os.environ.get('VAULT_STORE_PASSWORD') or getpass('password:'))
for entry in kp.entries:
@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)
import re, strutils, strformat, uri, tables, lists
import unicode except `strip`, `splitWhitespace`
type
NodeObj*[T] = object
parent*: Node[T]
prev*: Node[T]
next*: Node[T]
head*: Node[T]
tail*: Node[T]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
typedef enum {
MONDAY_OK,
MONDAY_ERR,
MONDAY_RET,
MONDAY_BRK,