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
@jtblin
jtblin / udp-loader.go
Last active August 22, 2024 01:34
UDP server performance optimisation
package main
import (
"crypto/rand"
"flag"
"log"
mrand "math/rand"
"net"
"os"
"os/signal"
@brennanMKE
brennanMKE / hero.ts
Last active April 6, 2025 07:33
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
@adrianmo
adrianmo / ipsec_remote_ip_update
Created January 18, 2016 12:01
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={
@adrianmo
adrianmo / ddns_update
Last active October 4, 2020 09:24
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={
@Restuta
Restuta / framework-sizes.md
Last active April 19, 2025 05:14
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@whs
whs / enroll.sh
Last active July 17, 2019 12:00
Dumb bulk cert generator
#!/bin/sh
BIN=/home/whs/.local/share/letsencrypt/bin/letsencrypt
SHUT_SVC=1
if [ "$SHUT_SVC" = "1" ]; then
sudo service nginx stop
sudo service apache2 stop
fi
SITES=certs/*
@kimh
kimh / docker-migrate.sh
Last active June 17, 2022 15:20
Shell script to demonstrate docker migration with CRIU
#!/bin/bash -e
function run-vg-cmd() {
pushd $1
eval $2
popd
}
function usage() {
echo "Usage: $0 container from-vagrant-dir to-vagrant-dir"
@nerdalert
nerdalert / Netfilter-IPTables-Diagrams.md
Last active April 16, 2025 02:11
Linux NetFilter, IP Tables and Conntrack Diagrams

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

@dogrocker
dogrocker / ESP8266 Web Server to storing ap config to EEPROM.md
Last active October 12, 2022 12:02
ESP8266 Web Server to storing ap config to EEPROM

ESP8266 Web Server to storing ap config to EEPROM.

Original by chriscook8 from esp8266.com I just modified to use ESP8266WebServer library for easy to handle the http request.

This is sample code not yet complete.

Todo

  • when Wifi connected need to close the softAP.
@tomasinouk
tomasinouk / snat_dnat_advantech.md
Last active April 3, 2025 19:03
examples of SNAT, DNAT with iptables for Advantech, Conel routers, with comments (probably will work on other routers where iptables can be manipulated, care needs to be taken on applying these commands after reboot).

Some examples of SNAT, DNAT with iptables with comments

mainly used in start-up script

How to test 'safely'

When we play with iptables aka firewall we might end up in situation, where we execute rule, which has unforseen impact - lock yourself out. Recovering from this situation is necessity.

How to:

  • Enable reboot via SMS.
  • Test all commands in shell first before putting them into Start-up script. This way the command will be wiped out, when unit is rebooted.

masquarade all outgoing packets to be WLAN0 IP