Skip to content

Instantly share code, notes, and snippets.

@tomjamescn
tomjamescn / iptables-redsocks.sh
Created October 16, 2022 22:05 — forked from ChronoMonochrome/iptables-redsocks.sh
RedSocks proxy for Linux
#!/bin/bash
# Create new chain
sudo iptables -t nat -N REDSOCKS
# Ignore LANs and some other reserved addresses.
sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
sudo iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
################################################################################################
# name: convert_daily_to_monthly.py
# desc: takes inout as daily prices and convert into monthly data
# date: 2018-06-15
# Author: conquistadorjd
################################################################################################
import pandas as pd
import numpy as np
print('*** Program Started ***')
@tomjamescn
tomjamescn / the_probability_lifesaver.ipynb
Created January 1, 2022 15:24
普林斯顿概率论读本 书中实验
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tomjamescn
tomjamescn / mount_qcow2.md
Created June 19, 2020 01:20 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@tomjamescn
tomjamescn / translate.go
Created June 9, 2020 14:47 — forked from hvoecking/translate.go
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
#!/bin/bash
sudo add-apt-repository ppa:jonathonf/vim
sudo apt-get update
sudo apt-get install vim
@tomjamescn
tomjamescn / key-my-complex-rules.json
Last active December 18, 2023 05:27
Karabiner-Elements的自定义配置,放到~/.config/karabiner/assets/complex_modifications/路径下,并到app中启用
{
"title": "Personal Rules (@tomjamescn)",
"rules": [
{
"description": "Change caps_lock to control if pressed with other keys, to escape if pressed alone.",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock",
@tomjamescn
tomjamescn / install-python3.8.sh
Created March 31, 2020 02:27
ubuntu/debian install python3.8
#!/bin/bash
set -e
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.8 python3-venv
# python3.8 -m venv myenv
@tomjamescn
tomjamescn / letsencrypt_notes.sh
Created March 15, 2020 06:03 — forked from lachesis/letsencrypt_notes.sh
Set up LetsEncrypt using acme.sh without root
# How to use "acme.sh" to set up Lets Encrypt without root permissions
# See https://github.com/Neilpang/acme.sh for more
# This assumes that your website has a webroot at "/var/www/<domain>"
# I'll use the domain "EXAMPLE.com" as an example
# When this is done, there will be an "acme" user that handles issuing,
# updating, and installing certificates. This account will have the following
# (fairly minimal) permissions:
# - Host files at http://EXAMPLE.com/.well-known/acme-challenge