Skip to content

Instantly share code, notes, and snippets.

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to ExpressVPN.

This is adapted from SuperJamie's gist.

Requirements

I used a Raspberry Pi 3 - seems like the extra speed may be useful for running VPN.

//Finish a block of non-zero bytes by outputting the code to the current code pointer,
//then setting the new code pointer to the current output destination, and incrementing
//the output destination (essentially reserving a byte of output to be later set to the
//code for the new run we are starting). Reset code to 0x01, for no bytes in the new run
//we are starting.
#define cobs_finish_block(X) (*code_ptr = (X), code_ptr = dst++, code = 0x01)
void cobs_stuff_data(const uint8_t *ptr, size_t length, uint8_t *dst, size_t *stuffed_length) {
const uint8_t *end = ptr + length;
const uint8_t *dst_start = dst;
195.3 ms13.41 % 195.3 ms13.41 % Chart.bundle.js:7736helpers.clone
194.0 ms13.32 % 194.0 ms13.32 % Chart.bundle.js:6333(anonymous function)
194.0 ms13.32 % 194.0 ms13.32 % Chart.bundle.js:6331Chart.controllers.line.Chart.DatasetController.extend.updateBezierControlPoints
192.8 ms13.24 % 192.8 ms13.24 % Chart.bundle.js:6148Chart.controllers.line.Chart.DatasetController.extend.addElementAndReset
192.8 ms13.24 % 192.8 ms13.24 % Chart.bundle.js:7577buildOrUpdateElements
192.8 ms13.24 % 192.8 ms13.24 % Chart.bundle.js:7218(anonymous function)
192.8 ms13.24 % 192.8 ms13.24 % Chart.bundle.js:7714helpers.each
192.8 ms13.24 % 192.8 ms13.24 % Chart.bundle.js:7203update
192.8 ms13.24 % 192.8 ms13.24 % :5000/elements/boxes-scatter/boxes-scatter.html:101(anonymous function)
192.8 ms13.24 % 192.8 ms13.24 % :5000/bower_components/polymer/polymer.html:1291(anonymous function)
@trepidacious
trepidacious / readme.md
Created February 20, 2015 20:21
Android + Scala + SBT + Idea
  1. Install IDEA 14 Community edition
  2. In Idea:
    1. Install Scala plugin (Preferences -> Plugins, type Scala at top, install)
    2. Install Android Support plugin
  3. Check out an android project using android-sdk-plugin, e.g. https://github.com/macroid/macroid-starter
  4. Import into IDEA using SBT import. File->Import Project, navigate to root of project, import as SBT.
  5. For SDK, choose the android option.
  6. If necessary, create Scala library when prompted.
  7. Delete "Make" from any run configuration(s). Run-> Edit Configurations... then in the activity, scroll to bottom and delete Make from the "Before launch" list.
  8. Build and run the project from SBT, but you can edit it in IDEA.
@trepidacious
trepidacious / JSON
Created February 18, 2015 15:16
Conversion via tokens to XML and JSON
{
"_type_": "Person",
"_id_": 0,
"name": "name",
"friend": {
"_type_": "Option",
"Some": {
"_type_": "Person",
"_id_": 1,
"name": "q",
@trepidacious
trepidacious / fsmc.c
Created July 26, 2013 10:59
FSMC config for PSRAM
#include "ch.h"
#include "hal.h"
#include "stmdrivers/stm32f4xx_rcc.h"
#include "stmdrivers/stm32f4xx_fsmc.h"
void fsmc_early_init(void) {
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
rccEnableAHB3(RCC_AHB3ENR_FSMCEN, FALSE);
public class ListBuilder {
private final StringBuilder b = new StringBuilder();
public ListBuilder li(String s) {
if (s!=null && !s.trim().isEmpty()) {
b.append("<li>"); b.append(s); b.append(</li>);
}
return this;
}
public String toString() {
@trepidacious
trepidacious / gist:5748580
Created June 10, 2013 13:09
Generate local mac address
void mcu_generate_local_mac(uint8_t *mac) {
uint32_t i = 0;
uint32_t m_w = 0;
uint32_t m_z = 0;
for (i = 0; i < 4; i++) {
m_w = (m_w << 8) + mcu_unique_device_id_byte(i*3);
m_z = (m_z << 8) + mcu_unique_device_id_byte(i*3 + 2);
}
m_w += mcu_unique_device_id_byte(1) * 5 + mcu_unique_device_id_byte(7) * 7;
@trepidacious
trepidacious / gist:5693116
Created June 2, 2013 09:18
Plotting a square wave
def plotSignal(c: Channel) = {
def alternating(s: Boolean): Stream[Boolean] = s #:: alternating(!s)
def y(s: Boolean) = if (s) 1 else 0
c.signal().changeTimes.zip(alternating(c.signal().initialState)).flatMap{case(time, state) => List(Vec2(time, y(state)), Vec2(time, y(!state)))}
}
@trepidacious
trepidacious / gist:5652812
Last active December 17, 2015 18:19
Problem with => Unit
package boxes.util
trait Op {
def apply()
}
class OpDefault(action: => Unit) extends Op {
def apply() {
action
}