Skip to content

Instantly share code, notes, and snippets.

@arkty
arkty / README.md
Created September 9, 2020 10:09 — forked from amkisko/README.md
Wireguard and iptables restrictions for multiple users

Wireguard and iptables restrictions for multiple users

If you don't know what Wireguard is, well, you should. It's fast, easy to setup and highly configurable. We will configure Wireguard for multiple users with various restrictions using iptables.

Assumptions

This should fit most setups (not mine though 😉)

So, you want to be able to work from anywhere. You want to be on a mountain somewhere, two bars of 3G signal, and you forward that to your laptop with a WiFi hotspot. Open your laptop and your shell on remote is already open and as responsive as possible. Work/life balance? With power like this, who cares?

Problem Scenario

Often, in academic institutions at least, you have the following situation:

class BooleanPreference(
private val name: String,
private val default: Boolean = false
) {
operator fun getValue(thisRef: LocalStorage, property: KProperty<*>): Boolean =
thisRef.prefs.getBoolean(name, default)
operator fun setValue(thisRef: LocalStorage, property: KProperty<*>, value: Boolean) =
thisRef.prefs.edit().putBoolean(name, value).apply()
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 136 columns, instead of 105. in line 3.
0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@arkty
arkty / .gitlab_ci.yml
Created December 24, 2017 22:46 — forked from Qurus/.gitlab_ci.yml
Deploy from Gitlab CI to Dokku
variables:
DOKKU_HOST: 'dokku.host.es'
IP_DOKKU_HOST: '1.2.3.4'
SSH_DOKKU_PORT: '22'
PROJECT_NAME: 'project_name'
stages:
- deploy_to_dokku
deploy_dokku:
@arkty
arkty / Exceptions.kt
Last active September 5, 2017 10:14
Android Retrofit
// Сам эксепшн
class ApiException(val error: ApiError) : Exception() {
override val message: String?
get() = error.messages.getOrNull(0)
// тут можно добавить метод getOrDefault(fallbackMessage: String)
companion object {
fun from(body: ResponseBody) = ApiException(ApiError.from(body))
}
}
@arkty
arkty / genymotionwithplay.txt
Created October 27, 2016 07:53 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
package com.example.beginner1;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
@arkty
arkty / HClust_Dendogram.R
Created June 10, 2016 18:11 — forked from jamesthomson/HClust_Dendogram.R
R HClust to d3.js Dendogram
library(rjson)
#convert output from hclust into a nested JSON file
HCtoJSON<-function(hc){
labels<-hc$labels
merge<-data.frame(hc$merge)
for (i in (1:nrow(merge))) {
package me.arkty.views;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.Checkable;
import android.widget.FrameLayout;
/**
* Author: Andrey Khitryy
* Email: andrey.khitryy@gmail.com