Skip to content

Instantly share code, notes, and snippets.

@mgax
mgax / symbols.md
Last active August 29, 2015 14:06
symbols
  • square: ²
  • cube: ³
  • alpha: α
  • beta: β
  • pi: π
  • phi: φ
@mgax
mgax / csr.sh
Last active November 23, 2015 20:45
generate a key signing request
mkdir /var/local/https
cd /var/local/https
WEBSITE=example.com
openssl genrsa -out $WEBSITE.key 2048
chmod 600 $WEBSITE.key
openssl req -new -key $WEBSITE.key -out $WEBSITE.csr
# send .csr, receive .crt
cat $WEBSITE.crt intermediate.crt ca.crt > $WEBSITE.chain # nginx
@mgax
mgax / data.csv
Last active December 20, 2017 08:30
Județe România
id siruta cod nume
1 10 AB Alba
2 29 AR Arad
3 38 AG Argeș
4 47 BC Bacău
5 56 BH Bihor
6 65 BN Bistrița-Năsăud
7 74 BT Botoșani
8 83 BV Brașov
9 92 BR Brăila
@mgax
mgax / swap.sh
Created August 4, 2014 08:45
Swap usage
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
>>> import base64
>>> from Crypto.PublicKey import RSA
>>> from Crypto.Cipher import PKCS1_OAEP
>>> key = RSA.generate(1024)
>>> print key.exportKey()
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDcL3eAUZjtrPQ3KvbcjuHqa28yiKsB6jlVoyEIzEWvajOftq+g
iN7sSQHqKYvG4Z6ieYoAbbnqt5MPgkToU3DAwimDhlHZTO4bTgPpke5RcJHOVcNM
6uWdidVAYalwEZsi5YuChIQM7JHrEZk51cpzPI28EKTILvX5aSnbjKTXrQIDAQAB
AoGBAJy7BPtIGe2E4UmrwZD5/AHbe4mjEucIDMvSlJ8omKnmlNypM5a4FsZmqYA/
@mgax
mgax / Readme.md
Created July 25, 2014 13:15
Chat system

Overview

This page describes the architecture for a private, distributed messaging system. Participants have their own private keys (identity) and encrypt messages end-to-end. Each participant may use several nodes, which can be personal devices, self-hosted or vendor servers; this avoids centralization and allows for server failure and going offline.

Concepts

@mgax
mgax / dns.sh
Created July 9, 2014 08:30
configure dns server
#!/bin/bash
case "$1" in
google)
sudo networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4
;;
auto)
sudo networksetup -setdnsservers Wi-Fi empty
;;
@mgax
mgax / crawl.py
Created July 3, 2014 05:16
starea drumurilor
import os.path
from datetime import datetime
import requests
DRUMURI_URL = 'http://www.cnadnr.ro/drumuri.php'
DOWNLOAD_DIR = os.path.abspath(os.environ.get('DOWNLOAD_DIR', '.'))
def crawl():
@mgax
mgax / authorize.py
Last active August 29, 2015 14:02
authorize with google oauth2
import requests
import flask
from werkzeug.urls import Href
def authorize():
config = flask.current_app.config
authorize_url = Href('https://accounts.google.com/o/oauth2/auth')({
'response_type': 'code',
@mgax
mgax / backup.py
Last active August 29, 2015 14:02
#!/usr/bin/env python
from datetime import date
import subprocess
DB_NAME = 'awesome'
BACKUP_PATH = '/var/local/awesome/backup/awesome-%s.sql.gz'
def main():