Skip to content

Instantly share code, notes, and snippets.

@mgax
mgax / freeswitch.sh
Last active October 18, 2016 10:55
Installation instructions for root.io
#!/bin/bash
## set up freeswitch on debian jessie for root.io
set -e
set -x
curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub \
| sudo apt-key add -
curl -L https://packagecloud.io/github/git-lfs/gpgkey \
| sudo apt-key add -
echo 'deb http://ftp.ro.debian.org/debian/ jessie-backports main' \
@mgax
mgax / Readme.md
Last active November 10, 2016 12:12
DIY letsencrypt

setup

sudo mkdir /opt/https
sudo chown `whoami`: /opt/https
cd /opt/https

mkdir bin libexec acme-challenge nginx
chmod 700 nginx

openssl dhparam -out nginx/dhparams.pem 2048

Keybase proof

I hereby claim:

  • I am mgax on github.
  • I am mgax (https://keybase.io/mgax) on keybase.
  • I have a public key whose fingerprint is F788 30C9 EB2C 65C7 2B77 BC7B 5F12 EA6A BF6A 321D

To claim this, I am signing this object:

@mgax
mgax / client
Created June 14, 2016 16:30
VPN client-server setup with username and password login
#!/bin/bash
set -e
args=(
/usr/sbin/openvpn
--client
--proto udp
--remote 192.168.2.10 30335
--dev tun
@mgax
mgax / index.html
Last active May 30, 2016 16:27
cartodb basemaps
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css" />
<title>CartoDB Basemaps preview</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-hash/0.2.1/leaflet-hash.min.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 100%; position: fixed; left:0; top:0; overflow:hidden;"></div>
\o /dev/null
\timing
\echo '\npgp:'
select pgp_sym_decrypt(pgp_sym_encrypt('n≃'||n, 'fff'), 'fff') FROM generate_series(1, 10000) as n;
--- Time: 18368.963 ms
\echo '\nencrypt_iv:'
select convert_from(decrypt_iv(encrypt_iv(convert_to('n≃'||n, 'UTF8'), 'fff', 'iviviv', 'aes'), 'fff', 'iviviv', 'aes'), 'UTF8') FROM generate_series(1, 10000) as n;
--- Time: 37.718 ms
@mgax
mgax / google-authenticator.rb
Created May 8, 2016 17:02
Homebrew formula for google-authenticator
class GoogleAuthenticator < Formula
desc "Google Authenticator PAM module"
homepage "https://github.com/google/google-authenticator"
head "https://github.com/google/google-authenticator.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
def install
@mgax
mgax / planets.html
Created April 29, 2016 22:15
Planets!
<!doctype html>
<meta charset="utf-8">
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser-polyfill.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js"></script>
<script type="text/babel">
const π = Math.PI
const width = 600
pwgen -1 -n 40 --secure | head -c 40 > /root/foo.key
cryptsetup --verbose --cipher "aes-cbc-essiv:sha256" --key-size 256 --key-file /root/foo.key luksFormat /dev/mapper/foo-enc
cryptsetup open --type luks --key-file /root/foo.key /dev/mapper/foo-enc foo
cryptsetup close foo
import sys
from time import time
import simplejson as json
from datetime import datetime
from sqlalchemy import create_engine
engine = create_engine(
'mssql+pymssql://user:pass@server:1433/portal_mj_nou?charset=utf8&timeout=300'
)