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 / device-info.service
Created August 29, 2012 01:26
/ffp/etc/avahi/services/device-info.service
<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_device-info._tcp</type>
<port>0</port>
<txt-record>model=RackMac</txt-record>
</service>
</service-group>
@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 / Console Output
Created December 19, 2013 03:12
Multiplication Table: This Java class creates a simple, text-based, multiplication table based on user's input.
Upto what whole number would you like your times table? 10
------------------------------------------------------------------------
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
------------------------------------------------------------------------
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
------------------------------------------------------------------------
| 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 |
------------------------------------------------------------------------
| 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 |
@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 / append.java
Created December 27, 2013 02:24
Append: This class appends array list a to array list b thus creating array list c.
package Arrays;
import java.util.ArrayList;
import java.util.Scanner;
public class Append {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
@wjn
wjn / GuessTheNumber.java
Created December 23, 2013 20:21
Guess The Number: a Java version of the first computer game I ever played.
import java.util.Scanner;
public class GuessTheNumber {
@SuppressWarnings("unused")
public static void main(String[] args)
{
final int HIGHEST_NUMBER = 100;
final int MAX_GUESSES = 10;
int guessCount = 0;
@wjn
wjn / writepath.xsl
Created December 19, 2013 03:28
Write Path: a utility that I use for XSLT debugging, which will show the present XPath location in an XML document.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template name="write-path">
<xsl:param name="path"/>
<xsl:param name="output"/>
<xsl:choose>
<xsl:when test="$path/parent::node()">
<xsl:call-template name="write-path">
<xsl:with-param name="output">
@wjn
wjn / class.shapes.php
Last active December 31, 2015 18:18
PHP Sample Problem: This application loads a csv datafile from the command line, manipulates the data and provides information based on the ID provided.
<?php
/**
*
* @author "Will Nielsen"
* website: http://willnielsen.com
* Date: December 13, 2013
*/
class Shapes {
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date">
<xsl:import href="get-schedule.xsl" />
<!--
Name: XSLT Calendar