Skip to content

Instantly share code, notes, and snippets.

View wjn's full-sized avatar
Learning always

Will Nielsen wjn

Learning always
View GitHub Profile
@wjn
wjn / firewall.user
Created July 9, 2021 20:00 — forked from stokito/firewall.user
OpenWrt: Allow only CloudFlare to access HTTP 80 and HTTPS 443 ports. Use if your uhttpd is hidden behind CF. Put this file to /etc/firewall.user. NOTE: It uses HTTP to get the list of IPs because to wget via https we need to install ca-certs. This makes you vulnerable to MiTM attacks but that's ok to be protected from internet's hackers
# https://www.cloudflare.com/ips replace the ips-v4 with ips-v6 if needed
# https://blog.cloudflare.com/cloudflare-now-supporting-more-ports/
for ip in `wget -qO- http://www.cloudflare.com/ips-v4`; do
iptables -I INPUT -p tcp -m multiport --dports 80,443,8080,8443,2052,2053,2082,2083,2086,2087,2095,2096,8880 -s $ip -j ACCEPT
done
@wjn
wjn / .prettierrrc.yaml
Created February 6, 2021 16:01
Prettier config
arrowParens: "always"
bracketSpacing: true
endOfLine: "lf"
htmlWhitespaceSensitivity: "css"
jsxBracketSameLine: false
jsxSingleQuote: false
printWidth: 80
proseWrap: "preserve"
quoteProps: "as-needed"
requirePragma: false
@wjn
wjn / mysqlSettings
Created June 14, 2015 04:15
Optimized MySql settings (/etc/mysql/my.cnf)
# For 1 GB Linode
max_connections = 75
key_buffer = 32M
max_allowed_packet = 1M
thread_stack = 128K
table_cache = 32
@wjn
wjn / Apache2
Created June 14, 2015 03:42
Apache2 Optimization for 2GB Linode (/etc/apache2/apache2.conf)
# Make sure these settings are as follows:
KeepAlive Off
...
# for a 2 gb ram linode
<IfModule mpm_prefork_module>
StartServers 4
MinSpareServers 12
MaxSpareServers 24
@wjn
wjn / mysqlRootReset
Last active January 3, 2016 20:39
Reset MySql Root Password
sudo service mysql stop
sudo killall -vw mysqld
## write stdout and stderr to resetMySql file
sudo mysqld_safe --skip-grant-tables >resetMySql 2>&1 &
## updates the password for root to whatever you enter in place of **NEW_PASSWORD**
sudo mysql mysql -e "UPDATE user SET Password=PASSWORD('**NEW_PASSWORD**') WHERE User='root';FLUSH PRIVILEGES;"
sudo killall -v mysqld
## Restart MySql Service
sudo service mysql restart
@wjn
wjn / freshclam_log_error
Created May 25, 2015 21:25
/var/log/clamav/freshclam.log is locked by another process
## stop the daemon
# sudo /etc/init.d/clamav-freshclam stop
## manually start freshclam
# sudo freshclam -v
## restart daemon
# sudo /etc/init.d/clamav-freshclam start
@wjn
wjn / Sample Apache2 Virtual Host
Last active August 29, 2015 14:20
Sample Apache2 Virtual Host
# domain: academicindexing.com
# public: /var/www/academicindexing.com/public/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin [email protected]
ServerName www.academicindexing.com
ServerAlias academicindexing.com
# Index file and Document Root (where the public files are located)
@wjn
wjn / Helpful Linux Commands
Created May 4, 2015 15:13
Helpful Linux Commands
**Find Files by Date**
- `ll | grep '2014-12-27’`
- `ll | grep '2015-04-28’`
**Find Compressed Files**
- `find / -type f -exec file {} + | grep compress > compressed_files.txt` (prints to report file)
{
"aar":
{
"int":["Afar"],
"native":["Afaraf"]
},
"aa":
{
"int":["Afar"],
"native":["Afaraf"]
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",