Skip to content

Instantly share code, notes, and snippets.

View jeremywall's full-sized avatar

Jeremy Wall jeremywall

View GitHub Profile
@jeremywall
jeremywall / update_jvm_tzdb.sh
Last active February 27, 2024 17:46
A bash script to attempt to locate the computer's default JVM and update it's time zone database file
#!/bin/bash
# use of this script means you agree to hold harmless and indemnify the author of the script
# use at your own risk
# usage example: update_jmv_tzdb.sh 2024a
if [ $# -eq 0 ]; then
echo "TZDB version argument missing"
exit
@jeremywall
jeremywall / readme.md
Last active October 30, 2022 04:14
Windows Terminal start up actions to open with split screen with CMD on left and WSL on right

Add the following as a root level entry in the Windows Terminal settings JSON

"startupActions": "--startingDirectory \"C:\\Work\\Projects\"; split-pane --profile Ubuntu-22.04-work --startingDirectory \"\\\\wsl$\\Ubuntu-22.04-work\\home\\jeremyw\"; move-focus left"
@jeremywall
jeremywall / readme.md
Last active October 5, 2023 19:04
R2, CORS, Presigned Put Object URLs, and uploading directly from browser side JavaScript

First and foremost you need to set the CORS configuration for your bucket. I'm a Java developer so here's the code I wrote using the AWS Java SDK v2 to define the CORS configuration for my R2 bucket. Alternatively you can also edit your bucket CORS configuration using Postman following the tutorial at https://kian.org.uk/configuring-cors-on-cloudflare-r2/

// update the config section here with your information first
String bucketName = "YOUR_BUCKET";
String accessKeyId = "YOUR_R2_ACCESS_KEY_ID";
String secretAccessKey = "YOUR_R2_SECRET_ACCESS_KEY";
String accountId = "YOUR_ACCOUNT_ID";
URI uri = new URI("https://" + accountId + ".r2.cloudflarestorage.com");
@jeremywall
jeremywall / gist:105af450c67f59a4c30a0f4d9da5b9c6
Created October 1, 2022 03:19
Set R2 Bucket CORS config using AWS Java SDK v2
CORSRule corsRule1 = CORSRule.builder()
.allowedMethods("GET","PUT", "POST")
.allowedOrigins("*")
.build();
PutBucketCorsResponse putResponse = s3Client.putBucketCors(
PutBucketCorsRequest.builder()
.bucket(bucketName)
.corsConfiguration(
CORSConfiguration.builder()
@jeremywall
jeremywall / readme.txt
Last active August 31, 2022 21:32
Install/Upgrade TZDB for PHP
1: Create a php file on the server called tz.php (can be in your user’s home folder) and add this 1 line of code to the file: <?php echo timezone_version_get() . "\n"; ?>
2: Now run that file with this command: php -f tz.php
3: If it outputs something like “0.system”, that means you have the default timezone db that shipped with PHP, in other words it’s old. If it's been updated it will return the TZDB version like 2022.2. The part after the dot maps to a letter of the alphabet so 2022.2 is the 2022b TZDB release. If you see 0.system go to the INSTALL section below. If you see a TZDB release version like 2022.2 go to the UPGRADE section below.
INSTALL
1: We need pecl which is part of PHP’s pear package: sudo apt-get install php-pear
2: Use pecl to install the timezonedb extension: sudo pecl install timezonedb
3: If you get errors about "phpize not found" then run the following before re-running the previous "sudo pecl install" command: sudo apt-get install php5-dev
4: After "pecl install timezonedb" complet
@jeremywall
jeremywall / readme.txt
Last active August 9, 2023 08:09
Compile and install new TZDB for Java
# I recently had to try to update the TZDB of a JDK installation where I could not install lzip
# from any registered package repository and trying to compile lzip from source was failing.
# I discovered that as an alternative to using the tzdb-latest.tar.lz file I could just use both
# the tzcode-latest.tar.gz and the tzdata-latest.tar.gz to generate the needed rearguard tarballs.
# These instructions have been updated to no longer rely on lzip since it's not available out of
# the box in many environments.
# SHORTCUT ALERT: If you don't want to go through the whole process to build the rearguard tarball
# or use the ziupdater tool to generate and install a tzdb.dat file you can always just download
# the latest tar.gz and tzdb.dat files from a repo I created that automatically builds new TZDB
@jeremywall
jeremywall / readme.txt
Last active October 24, 2018 17:42
Uninstall SDK Man
look in these files
.bashrc
.bash_profile
.profile
and remove the following from each of them
#THIS MUST BE AT THE END OF THE FILE FOR GVM TO WORK!!!
[[ -s "/home/marco/.gvm/bin/gvm-init.sh" ]] && source "/home/marco/.gvm/bin/gvm-init.sh"
@jeremywall
jeremywall / readme.txt
Last active October 24, 2018 17:44
Clone WSL
LxRunOffline.exe duplicate -n Ubuntu-18.04 -d D:\wsl\ubuntu-18.04-xxx -N Ubuntu-18.04-XXX
But it's not ready to use just yet. Open regedit and find the new WLS instance at Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss and then set the Version field to 1.
@jeremywall
jeremywall / readme.txt
Last active January 16, 2020 18:50
WSL Customization Steps
# Edit ~/.bashrc and add $(lsb_release -rs) in the prompt like so
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h/$(lsb_release -rs)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# update stuff
sudo apt update
sudo apt upgrade
sudo apt install zip unzip lzip