Skip to content

Instantly share code, notes, and snippets.

View wsams's full-sized avatar
🫖

Weldon Sams wsams

🫖
View GitHub Profile
@wsams
wsams / commands.txt
Last active November 24, 2022 20:33
Powerful Minecraft Tools and Armor
/give @s netherite_pickaxe{Enchantments:[{id:efficiency,lvl:10},{id:unbreaking,lvl:10},{id:fortune,lvl:10},{id:mending,lvl:1}]} 1
/give @s netherite_pickaxe{Enchantments:[{id:efficiency,lvl:10},{id:unbreaking,lvl:10},{id:silk_touch,lvl:1},{id:mending,lvl:1}]} 1
/give @s netherite_shovel{Enchantments:[{id:efficiency,lvl:10},{id:unbreaking,lvl:10},{id:fortune,lvl:10},{id:mending,lvl:1}]} 1
/give @s netherite_shovel{Enchantments:[{id:efficiency,lvl:10},{id:unbreaking,lvl:10},{id:silk_touch,lvl:1},{id:mending,lvl:1}]} 1
/give @s netherite_hoe{Enchantments:[{id:efficiency,lvl:10},{id:unbreaking,lvl:10},{id:fortune,lvl:10},{id:mending,lvl:1}]} 1
/give @s netherite_axe{Enchantments:[{id:mending,lvl:1},{id:unbreaking,lvl:10},{id:efficiency,lvl:10},{id:sharpness,lvl:10}]} 1
/give @s netherite_helmet{Enchantments:[{id:mending,lvl:1},{id:unbreaking,lvl:10},{id:respiration,lvl:10},{id:protection,lvl:10},{id:thorns,lvl:10}]} 1
/give @s netherite_chestplate{Enchantments:[{id:mending,lvl:1},{id:unbreaking,lvl:10},{id:prote
@wsams
wsams / multiply.js
Last active November 30, 2021 05:24
Multiply two large integers (1000s of digits - or more given enough time) with Python, and Node.JS
/**
* Usage: node multiply.js <positive integer a> <positive integer b>
*/
function mult(aArr, bArr) {
const as = aArr.reverse().join('');
const bs = bArr.reverse().join('');
let rowa = [];
let remainder = 0;
let rows = [];
for (let bx = 0; bx < bs.length; bx++) {
@wsams
wsams / tiny-cli.js
Last active January 27, 2021 07:42
A tiny CLI framework for writing Node JS command line tools or scripts. It provides a simple way to handle non-positional arguments using a flag based system.
const { execSync } = require('child_process');
const args = {};
const argv = process.argv.slice(2);
if (argv.length === 0) usage();
argv.forEach((arg, i) => args[arg] = argv[i + 1]);
// Every flag must have a value even if it's not being used
// Instead of a boolean --version you might use `-v true`
const inputFileName = args['-i'];
<!DOCTYPE HTML>
<html>
<head>
<title>FoPo Run Club</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<link rel="icon" type="image/ico" href="favicon.ico">
@wsams
wsams / system-upgrade.sh
Created August 30, 2019 04:14
Simple way to trap and clean up temporary files in BASH - This script is useful as a cron job to keep an Ubuntu machine upgraded automatically
#!/bin/bash
# Simple way to trap and clean up temporary files in BASH - This script is useful as a cron job to keep an Ubuntu machine upgraded automatically
# The following cron job would keep the system up-to-date 4 times a day: 0 */4 * * * /root/bin/system-upgrade.sh
pidfile="/root/bin/system-upgrade.pid"
janitor() {
rm -f $pidfile
}
@wsams
wsams / add.js
Last active March 16, 2019 04:24
Multiply or Add big numbers quickly with this node script. 5000 digit numbers squared in < 1 minute, doubled in < 0.1 seconds.
/**
* This node script accepts two arguments, both integers, and returns their sum.
*
* The integers are string inputs split into an array of digits and operated on so
* they can be really big numbers. A 5000 digit number doubled takes less than 0.1 seconds
* to compute on a mid-2014 MacBook Pro. (Node v11.11.0)
*
* Usage: node add.js <int> <int>
*/
@wsams
wsams / adjectives.txt
Last active February 18, 2019 03:35
Create `username-generator.php` and see usage in comment. This gist contains two text files and one PHP file. Running the PHP script produces usernames of the form <adjective><noun>. You get 40 names in 4 columns and the length of each name is configurable.
abandoned
able
absolute
adorable
adventurous
academic
acceptable
acclaimed
accomplished
accurate
@wsams
wsams / compile-min-js.php
Last active September 20, 2018 08:51
A script that obfuscates and minimizes an opinionated JavaScript file. See script comments for instructions.
<?php
/**
* INSTALL & RUN
*
* 1. Install uglifyjs: `npm install -g uglifyjs-es`
* 2. Write your JavaScript with every variable prefixed with two underscores. e.g. `__varName`
* The script also supports functions prefixed with two dashes but it doesn't appear to work anymore.
* 3. Run: `php compile-min-js.php my.js my.min.js` (This script obfuscates and then runs uglifyjs)
*/

Keybase proof

I hereby claim:

  • I am wsams on github.
  • I am wsams (https://keybase.io/wsams) on keybase.
  • I have a public key ASDKSOtKYCVtY9MgPydK0YRm-iqfsU3SW-yLEJ1i2U8l5wo

To claim this, I am signing this object:

@wsams
wsams / rename_datetree_folders.php
Last active March 28, 2017 04:38
A script to rename folders output from DateTree. Directories like 2017-03-27 would be renamed 20170327NikonDump. If that directory exists the contents of 2017-03-27 would be moved into it and deleted.
<?php
$suffix = "NikonDump";
$dirs = glob("*", GLOB_ONLYDIR);
foreach ($dirs as $k=>$dir) {
$dumpdir = preg_replace("/^(\d{4})-(\d{2})-(\d{2})$/", "\${1}\${2}\${3}{$suffix}", $dir);
// Uncomment this line if you are only import new directories of the $suffix type.
// So if you imported everything from a Nikon camera then you can just uncomment
// this rename because all of the photos would be new. You also have to make sure all