Skip to content

Instantly share code, notes, and snippets.

View iDanielLaw's full-sized avatar

Daniel Law iDanielLaw

  • Imagine No Limit Technology
View GitHub Profile
@iDanielLaw
iDanielLaw / tunnel.sh
Created May 26, 2020 07:34 — forked from vishvananda/tunnel.sh
Script to set up an ipsec tunnel between two machines For Example: ./tunnel.sh 10.10.10.1 10.10.10.2 192.168.0.1 192.168.0.2 would set up an ipsec tunnel over 10.10.10.1 address using 192.168.0.1 as a virtual address passwordless sudo required for user on remote machine
#!/bin/bash
if [ "$4" == "" ]; then
echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
echo "creates an ipsec tunnel between two machines"
exit 1
fi
SRC="$1"; shift
DST="$1"; shift
@iDanielLaw
iDanielLaw / xdp_load_balancer.c
Created May 26, 2020 07:24 — forked from summerwind/xdp_load_balancer.c
XDP based load balancer with L3DSR support
#define KBUILD_MODNAME "load_balancer"
#include <uapi/linux/bpf.h>
#include <linux/in.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/if_vlan.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
BPF_HASH(counter, uint32_t, long);
@iDanielLaw
iDanielLaw / ipsec_remote_ip_update
Created May 26, 2020 04:31 — forked from adrianmo/ipsec_remote_ip_update
Mikrotik script to update IPsec peer and policy when remote IP changes
##############Script Settings##################
:local RemoteNOIPHost "domainname.noip.com"
:local IPsecComment "myIPsec"
###############################################
:local TmpIP [/ip ipsec peer get [find comment="$IPsecComment"] address]
:local OldIP [:pick "$TmpIP" 0 ([:len $TmpIP] - 3)]
:local NewIP [:resolve $RemoteNOIPHost]
:if ($NewIP != $OldIP) do={
@iDanielLaw
iDanielLaw / ddns_update
Created May 26, 2020 04:31 — forked from adrianmo/ddns_update
Mikrotik script to update a dynamic DNS host and IPsec policy
##############Script Settings##################
:local DDNSUser "username"
:local DDNSPass "password"
:local DDNSDomain "yourhost.ddns.net"
:local DDNSServer "https://members.dyndns.org/v3/update"
:local WANInter "pppoe-out1"
###############################################
:local IpCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={
server {
location ~* (serviceworker\.js)$ {
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
expires off;
proxy_no_cache 1;
}
}
@iDanielLaw
iDanielLaw / RouterApp.js
Created February 17, 2020 10:51 — forked from VesperDev/RouterApp.js
Sider menu + ant-design + react-router-dom
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import { Layout, Menu, Icon } from 'antd';
import Dashboard from './containers/Dashboard/Dashboard';
import Meseros from './containers/Meseros/Meseros';
const { Header, Content, Footer, Sider } = Layout;
const SubMenu = Menu.SubMenu;
@iDanielLaw
iDanielLaw / deskew.py
Created February 9, 2020 06:21 — forked from russss/deskew.py
Automatic scanned image rotation/deskew with OpenCV
import cv2
import numpy as np
def deskew(im, max_skew=10):
height, width = im.shape
# Create a grayscale image and denoise it
im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
im_gs = cv2.fastNlMeansDenoising(im_gs, h=3)
@iDanielLaw
iDanielLaw / deskew.py
Created February 9, 2020 06:21 — forked from russss/deskew.py
Automatic scanned image rotation/deskew with OpenCV
import cv2
import numpy as np
def deskew(im, max_skew=10):
height, width = im.shape
# Create a grayscale image and denoise it
im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
im_gs = cv2.fastNlMeansDenoising(im_gs, h=3)
@iDanielLaw
iDanielLaw / nginx.conf
Created December 8, 2019 18:50 — forked from ashleydw/nginx.conf
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;
@iDanielLaw
iDanielLaw / http-store.js
Created November 19, 2019 10:36 — forked from ErisDS/http-store.js
HTTP Store, Storage layer for Ghost 0.6.0 - passes images to a HTTP endpoint
var _ = require('lodash'),
fs = require('fs-extra'),
http = require('http'),
path = require('path'),
util = require('util'),
Promise = require('bluebird'),
options = {},
mimeTypes = {