Skip to content

Instantly share code, notes, and snippets.

@treckstar
treckstar / Ubuntu-18.04-hostnames.txt
Created October 2, 2022 10:16
WSL2 Ubuntu 18.04 Start
hostname.localhost.com
dev.localhost.gg
whatever.domain.com
@treckstar
treckstar / get-wsl2-ip-address.ps1
Created September 28, 2022 12:02
Get WSL2 IP Address from Windows Terminal / Powershell
# Once WSL2 has been started, use either of these commands to get the IP address
# I typically would run this command right after I launch the WSL2 VM I am using.
# This is a good command to have cached in your history, so you can easily execute on the fly.
wsl -- ip -o -4 -json addr list eth0 | ConvertFrom-Json | %{ $_.addr_info.local } | ?{ $_ }
# They are both the same; however this one is multiline.
# The intent is to help break it down and understand the options and syntax
# The powershell command is essentially executing a linux `ip` command
# on the guest server, and then uses a Powershell function to read the
# JSON output and return the IP address.
@treckstar
treckstar / 2022-05-25-ubuntu-18.04-wsl2.sh
Created May 27, 2022 16:13
Shell Script to setup LEMP on Windows 10 WSL2 - Using Ubuntu 18.04, PHP 7.3, MariaDB 10.3, nginx
# No LSB modules are available.
# Distributor ID: Ubuntu
# Description: Ubuntu 18.04.4 LTS
# Release: 18.04
# Codename: bionic
#
# PHP 7.3.14-6+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 5 2020 16:51:32) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.14, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.14-6+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
@treckstar
treckstar / police-ticket.php
Created November 15, 2021 20:46
PHP Police Officer Ticket Function with birthday logic
<?php
function calculateTicketAmount($speed, $isBirthday)
{
// Unless it is your birthday -- on that day,
// your speed can be 5 higher in all cases.
// If speed is `60` or less, the result is `0`.
if($speed <= (!$isBirthday ? 60 : 65))
return 0; // no ticket
// If speed is between `61` and `80` inclusive, the result is `1`.
@treckstar
treckstar / Pastebin
Created October 24, 2021 07:52
Pastebin
Pastebin please give me access back to my account u: treckstar
@treckstar
treckstar / gist:9977855
Created April 4, 2014 16:10
keybase.md
### Keybase proof
I hereby claim:
* I am treckstar on github.
* I am treckstar (https://keybase.io/treckstar) on keybase.
* I have a public key whose fingerprint is D1CE BB05 DF1A 8C76 6F02 FDCF ED7C 0170 04E2 66D8
To claim this, I am signing this object: