Skip to content

Instantly share code, notes, and snippets.

View ba0f3's full-sized avatar
🇻🇳
#VietnamLeavesNoOneBehind

Huy Doan ba0f3

🇻🇳
#VietnamLeavesNoOneBehind
View GitHub Profile
@ba0f3
ba0f3 / server.conf
Last active August 29, 2015 14:10 — forked from hostmaster/server.conf
local 127.0.0.1
port 1194
proto tcp
dev tun
remote-cert-tls client
log-append /var/log/openvpn.log
ca keys/ca.crt
cert keys/server.crt
key keys/server.key
dh keys/dh1024.pem
@ba0f3
ba0f3 / gist:1cec33b7e18632af3e75
Created March 10, 2015 03:35
Compile Nginx on Raspbian (Debian for PI)
apt-get install libpcre3-dev libssl-dev
wget http://nginx.org/download/nginx-1.7.10.tar.gz
tar zxvf nginx-1.7.10.tar.gz
cd nginx=*
./configure --sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--error-log-path=/var/log/nginx/error.log \

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@ba0f3
ba0f3 / getip.nim
Created April 29, 2015 18:59
Get external IP and display it to stdout
import httpclient, re
proc subString(s: string, start: int, stop: int): string =
return s[start..stop]
var resp: string = ""
try:
resp = getContent("http://checkip.dyndns.org")
except ProtocolError:
quit("Error")
proc testBit(w, i: int): bool {.inline.} =
result = (w and (1 shl (i %% (8*sizeof(int))))) != 0
proc setBit(w: var int, i: int) {.inline.} =
w = w or (1 shl (i %% (8*sizeof(int))))
proc resetBit(w: var int, i: int) {.inline.} =
w = w and not (1 shl (i %% (8*sizeof(int))))
when isMainModule:
import htmlparser
import xmltree
from streams import newStringStream
const
html = """
<html>
<head>
<title>Test</title>
</head>
@ba0f3
ba0f3 / init.el
Last active January 13, 2016 15:58
Emacs init file
(ido-mode 1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
;(menu-bar-mode -1)
(show-paren-mode 1)
(eldoc-mode 1)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq make-backup-files nil)
Hint: used config file '/Volumes/Data/Projects/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: test [Processing]
test.nim(1, 9) Error: undeclared identifier: 'newWideCString'
rgv151@airsupply /V/D/P/bogo-nim> nim -v
Nim Compiler Version 0.11.3 (2015-06-19) [MacOSX: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf
git hash: 29b09a3c7d825cda6dad7c5d4030f752de266190
active boot switches: -d:release
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
int main() {
void *handle;
char* (*processSequence)(const char *);
handle = dlopen("../libbogo.so", RTLD_LAZY);