Skip to content

Instantly share code, notes, and snippets.

@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:
@treckstar
treckstar / Pastebin
Created October 24, 2021 07:52
Pastebin
Pastebin please give me access back to my account u: treckstar
@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 / 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 / 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 / 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 / .bashrc
Created October 2, 2022 10:26
Ubuntu 18.04 - 20.04
#!/bin/bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
#
# These are just some functions to add into the ~/.bashrc file
# Modified print_r command to output color without installing any themes
# Normally around line #118 these can be placed. I always put them at the end of file.
# You must restart the terminal after updating the ~/.bashrc file
cecho(){
@treckstar
treckstar / awesome-possum.txt
Created December 22, 2022 20:13
Random 😎 Sites for Hope & Inspiration
my personal strapi + gatsby + plain custom + tailwindcss + headlessui + framermotion
this site was never finished which is why some things look out of place
https://www.treckstar.net
The monorepo for above
https://github.com/treckstar/grapsbi
Gatsby Plugins I use/like
https://github.com/treckstar/grapsbi/blob/main/frontend/package.json
Packaged with PNPM
https://pnpm.io/
@treckstar
treckstar / LocaleSwitcher.tsx
Created April 5, 2023 15:04
Class Based TypeScript React.Component - Locale Switcher Menu
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';
type Locale = {
locale: string;
label: string;
};
type Props = {
@treckstar
treckstar / LocaleSwitcher.tsx
Last active April 5, 2023 15:11
Class Based TypeScript React.Component - Locale Switcher
import React from 'react';
import { useRouter } from 'next/router';
type Props = {
locales: string[];
currentLocale: string;
};
class LocaleSwitcher extends React.Component<Props> {
private handleLocaleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {