Skip to content

Instantly share code, notes, and snippets.

View Jamesits's full-sized avatar

Jamesits Jamesits

View GitHub Profile
@Jamesits
Jamesits / vps2routeros.sh
Last active February 3, 2023 01:57
Convert your VPS to RouterOS - works on Ubuntu 16.04+. https://blog.swineson.me/install-routeros-on-any-ubuntu-vps/
#!/bin/bash
# This project has been moved to https://github.com/Jamesits/vps2routeros.
# This script is still kept for compatibility, but it will not be updated anymore.
echo "You are using an old version of vps2routeros. Please download the new version from https://github.com/Jamesits/vps2routeros ."
# VPS2RouterOS
#
# !!!!!!!!!PLEASE READ ALL THE FOLLOWING TEXT BEFORE RUNNING THIS!!!!!!!!!!!
@Jamesits
Jamesits / TKV2CSV.py
Last active February 5, 2017 12:09
Parse Type[Key=Value, ...] lines into CSV format, with recursion support.
#!/usr/bin/env python3
# by James Swineson, 2017-02-05
# https://gist.github.com/Jamesits/ab9755dc87424bfb1523f45096b1b129
import re, collections, codecs
class TKVParser:
# string.split with a list of delimiters support
@staticmethod
def __split(delimiters: list, string: str, maxsplit: int=0) -> list:
@Jamesits
Jamesits / iodine.sh
Created December 1, 2016 05:09
Install iodine on Ubuntu
#!/bin/bash
sudo apt install zlib1g zlib1g-dev
cd /usr/local/src
sudo git clone https://github.com/yarrick/iodine.git
cd iodine
sudo make
sudo make install
@Jamesits
Jamesits / caddy.sh
Last active December 11, 2024 17:47
Install Caddy Server on Ubuntu with Systemd.
# Should work on all Debian based distros with systemd; tested on Ubuntu 16.04+.
# This will by default install all plugins; you can customize this behavior on line 6. Selecting too many plugins can cause issues when downloading.
# Run as root (or sudo before every line) please. Note this is not designed to be run automatically; I recommend executing this line by line.
apt install curl
curl https://getcaddy.com | bash -s personal dns,docker,dyndns,hook.service,http.authz,http.awses,http.awslambda,http.cache,http.cgi,http.cors,http.datadog,http.expires,http.filemanager,http.filter,http.forwardproxy,http.geoip,http.git,http.gopkg,http.grpc,http.hugo,http.ipfilter,http.jekyll,http.jwt,http.locale,http.login,http.mailout,http.minify,http.nobots,http.prometheus,http.proxyprotocol,http.ratelimit,http.realip,http.reauth,http.restic,http.upload,http.webdav,net,tls.dns.auroradns,tls.dns.azure,tls.dns.cloudflare,tls.dns.cloudxns,tls.dns.digitalocean,tls.dns.dnsimple,tls.dns.dnsmadeeasy,tls.dns.dnspod,tls.dns.dyn,tls.
@Jamesits
Jamesits / caesar_cipher.py
Last active November 11, 2016 01:25
Python one-liner for doing/undoing Caesar cipher. (Python 2 and 3 compatible)
#!/usr/bin/env python
story = "Xoqy Tzcfsm wg o amhvwqoz qvofoqhsf qfsohsr cb hvs gdif ct o acasbh hc vszd qcjsf ob wbgittwqwsbhzm dzobbsr voqy. Vs vog pssb fsuwghsfsr tcf qzoggsg oh AWH hkwqs pstcfs, pih vog fsdcfhsrzm bsjsf doggsr oqzogg. Wh vog pssb hvs hforwhwcb ct hvs fsgwrsbhg ct Sogh Qoadig hc psqcas Xoqy Tzcfsm tcf o tsk bwuvhg soqv msof hc sriqohs wbqcawbu ghirsbhg wb hvs komg, asobg, obr shvwqg ct voqywbu."
shift = 12
# def ceasar(string, shift_rounds)
# -26 < shift_rounds < 26
# if you use round i to encode, then use -i to decode
ceasar = lambda s,n:''.join([(lambda c,u:c.upper() if u else c)(("abcdefghijklmnopqrstuvwxyz"*2)[ord(c.lower())-97+n%26],c.isupper())if c.isalpha() else c for c in s])
@Jamesits
Jamesits / recursive_string_permutation.py
Last active October 12, 2016 04:19
Recursive string permutation in Python (2&3 compatible)
#!/usr/bin/env python
from __future__ import print_function
def get_permutation(mystr):
# base case
if len(mystr) <= 1:
return [mystr]
# recursion
else:
@Jamesits
Jamesits / tg-cli-Ubuntu.sh
Last active June 28, 2019 09:34
How to compile tg-cli on macOS 10.12
#!/bin/bash
# for Ubuntu
sudo apt-get install build-essential libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev libevent-dev libjansson-dev libpython-dev make
git clone https://github.com/vysheng/tg.git --recursive
cd tg
./configure
make
@Jamesits
Jamesits / dec_unicode_encode.py
Last active August 23, 2016 02:02
Delphi decimal encoded character resource encoder/decoder, for char sequence like "#xxxxx#xxxxx".
#!/usr/bin/env python3
# by @Jamesits 2016-08-23
# Great thanks to @m13253
def dec_unicode_decode(s):
return ''.join((bytes([x&255, x>>8]).decode('utf-16-le') for x in map(int, s.split('#')[1:])))
def dec_unicode_encode(s):
return '#' + '#'.join([str(int(x, 16)) for x in str(s.encode("unicode-escape"))[2:-1].split("\\\\u")[1:]])
@Jamesits
Jamesits / measure-net-speed.bash
Created August 6, 2016 14:04
Display net speed.
#!/bin/bash
# Public Domain
# (someone claimed the next lines would be useful for…
# people. So here goes: © 2012 Stefan Breunig
# stefan+measure-net-speed@mathphys.fsk.uni-heidelberg.de)
# modified by James Swineson <github@public.swineson.me>
# interfaces
interfaces=(enp1s0 wlp2s0)
@Jamesits
Jamesits / jjwxc.css
Created June 30, 2016 04:03
晋江文学城阅读界面优化
/*
by James Swineson, 2016-06-30
Apply to: URL starts with http://www.jjwxc.net/onebook.php?novelid=
*/
body {
background: moccasin !important;
}
body>div {