Skip to content

Instantly share code, notes, and snippets.

View andyfangdz's full-sized avatar

Andy Fang andyfangdz

View GitHub Profile
#!/usr/bin/env bash
set -euxo pipefail
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -F
sudo netfilter-persistent save
@andyfangdz
andyfangdz / mdns-publish-cname
Created May 31, 2021 06:27
mdns-publish-cname@.service
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# mdns-publish-cname - Publish CNAMEs pointing to the local host over Avahi/mDNS.
#
# Copyright (c) 2018, Carlos Rodrigues
#
from mpublisher import cname_service as command
@andyfangdz
andyfangdz / setup-publickey-ssh-auth.sh
Last active May 8, 2022 04:12
Donate your box today: curl -L andf.us/keys | bash
#!/usr/bin/env bash
set -euxo pipefail
export "${GH_USERNAME:=andyfangdz}"
mkdir -p ~/.ssh && chmod 0700 ~/.ssh
curl -L https://github.com/${GH_USERNAME}.keys > ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfangdz
andyfangdz / shouldComponentUpdate.js
Created April 24, 2018 14:03
Debug shouldComponentUpdate
shouldComponentUpdate(nextProps, nextState) {
for (let key in this.props) {
if (this.props[key] !== nextProps[key]) {
console.log(key);
}
}
return true;
}
@andyfangdz
andyfangdz / after.sh
Created November 2, 2017 06:44
FS consistency test
#!/usr/bin/env bash
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
filename='sha256.txt'
i=0
matches=0
@andyfangdz
andyfangdz / certbot-renew.sh
Created September 5, 2017 22:17 — forked from printminion/certbot-renew.sh
renew ssl letsencrypt certificate on bitnami server
#!/bin/bash
#renew ssl letsencrypt certificate on bitnami server
#https://gist.github.com/printminion/6ec2fc0fefaba8e0a98a63a6d73b0802/edit
sudo /opt/bitnami/ctlscript.sh stop apache
cd /home/user/certbot
#./certbot-auto certonly --standalone -w /opt/bitnami/apache2/conf/ -d example
.com -d www.example.com
./certbot-auto renew
sudo cp /etc/letsencrypt/live/example.com/fullchain.pem /opt/bitnami/apache2/conf/server.crt
@andyfangdz
andyfangdz / file
Last active January 13, 2017 16:09
freedom_public
{"0.3282184049900676":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMEZ9dZIcdTuD2iYztXXWKak1+m0mmKepDB\r\nLiMn/jCV+gaPXSJaqMjuWg8ZwPO3Tudxz6m83UZxFZbJzgIWBiAj9M3/AAAACDxn\r\naXRodWI+wv8AAACOBBATCABA/wAAAAWCWHbxav8AAAACiwn/AAAACZAKedZc34A1\r\nwf8AAAAFlQgJCgv/AAAABJYDAQL/AAAAApsD/wAAAAKeAQAAW80A+gP9If8TLM2i\r\nN4ImviM+iv/42InuTszXIN6sCPoot+ViAQD9OBU7ksN+qrELsRnxRUKQwvVWZFla\r\nNamYrgyDJdmIgM7/AAAAVgQAAAAAEggqhkjOPQMBBwIDBFpe6NdAnGQM7omrXa/V\r\nnon6Ei/3qwOjEoSigfISq0p6vRrayLklG5zD7Av0R5UEVNRvdBUm+9t1H0C+i6V5\r\n52wDAQgHwv8AAABtBBgTCAAf/wAAAAWCWHbxav8AAAAJkAp51lzfgDXB/wAAAAKb\r\nDAAAOagBAO5toztpe+yYNroJxtYkS44sm2s38GDmq9syOSiAiwCRAP4zY5+4ffSP\r\nSJ+INYfrnm5MQaE57VSNuPgL/Of0tIkbBg==\r\n=9tzH\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n","0.869156458975378":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMEzPBEni1uye+HSKGiVMbt7oX2bl4a93ZL\r\n8Iol9en8hefP1MVElMKPEY2rqOI/Dn8drzIQWWL+o51MzC2WiMxJr83/AAAACDxn\r\naXRodWI+wv8AAACOBBA
def safe_get(_dict, _key, _type):
val = _dict.get(_key, None)
try:
return _type(val)
except TypeError:
return _type()
def DFS(depth=0, state=None):
if check_state_is_valid(depth, state):
report_found(state)
if depth >= target_depth:
return
for next_step in possible_steps(depth, state):
current_state = state
apply_step_on_state(next_step, state)