Skip to content

Instantly share code, notes, and snippets.

View indygwyn's full-sized avatar

Thomas W. Holt Jr. indygwyn

  • Indianapolis, IN US
View GitHub Profile
@indygwyn
indygwyn / README.md
Created September 6, 2023 22:35 — forked from DewaldDeJager/README.md
Easy GitHub workflow for keeping a fork in sync with upstream

Sync Fork

This workflow uses the GitHub CLI to keep a forked repo in sync with the upstream repo. Add it to your repo as .github/workflows/sync-fork.yaml.

It runs daily to sync the default branch and can be triggered manually for any branch.

@indygwyn
indygwyn / 01-truthy-and-falsey-ruby.md
Created July 6, 2023 19:23 — forked from jfarmer/01-truthy-and-falsey-ruby.md
True and False vs. "Truthy" and "Falsey" (or "Falsy") in Ruby, Python, and JavaScript

true and false vs. "truthy" and "falsey" (or "falsy") in Ruby, Python, and JavaScript

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False. But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.).

This outlines how this works in Ruby, with some basic examples from Python and JavaScript, too. The idea is much more general than any of these specific languages, though. It's really a question of how the people designing a programming language wants booleans and conditionals to work.

If you want to use or share this material, please see the license file, below.

Update

Ad-free Twitter

Inject this css snippet to remove all ads from your Twitter timeline.

div[data-testid="placementTracking"]:has(path[d="M19.498 3h-15c-1.381 0-2.5 1.12-2.5 2.5v13c0 1.38 1.119 2.5 2.5 2.5h15c1.381 0 2.5-1.12 2.5-2.5v-13c0-1.38-1.119-2.5-2.5-2.5zm-3.502 12h-2v-3.59l-5.293 5.3-1.414-1.42L12.581 10H8.996V8h7v7z"]) {
  display: none;
}

You can inherit the environment variables from PID 1 by iterating over the list of null-terminated strings in /proc/1/environ, parsing the first characters up to the first = as the variable name, setting the remaining value as that variable, and exporting it.

The Code Snippet

This works with multiline environment variables, and environment variables with arbitrary values, like strings, including = or JSON blobs.

Paste this in your current terminal session to inherit the environment variables from PID 1:

@indygwyn
indygwyn / LICENSE.md
Created December 29, 2022 23:59 — forked from sj26/LICENSE.md
Bash retry function

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit

@indygwyn
indygwyn / man2pdf.sh
Created December 5, 2022 17:16 — forked from PicoMitchell/man2pdf.sh
Display "man" pages as PDFs on macOS, with nice filenames and caching.
#!/bin/sh
man2pdf() {
##
## Created by Pico Mitchell (of Random Applications) on 11/16/22
##
## https://gist.github.com/PicoMitchell/619c12fd6a53ae6ec657514915d4edf9
##
## MIT License
##
#!/bin/sh
# Copyright 2021 Jonathan Bowman. All documentation and code contained
# in this file may be freely shared in compliance with the
# Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
# and is **provided "AS IS" without warranties or conditions of any kind**.
#
# OUT="$(mktemp)"; wget -q -O - https://gist.github.com/bowmanjd/d72e2e89996087f71ffe3e9777dea5a2/raw > $OUT; . $OUT
#
# You may read a brief synopsis at
This file has been truncated, but you can view the full file.
[15:21:09] [main/INFO]: ModLauncher running: args [--username, indygwyn, --version, forge-43.1.25, --gameDir, /Users/twh/Twitch/Minecraft/Instances/All the Mods 8 - ATM8 - 1.19.2, --assetsDir, /Users/twh/Twitch/Minecraft/Install/assets, --assetIndex, 1.19, --uuid, 6d2c563e1d2247f89d31ce48fc49a49b, --accessToken, ❄❄❄❄❄❄❄❄, --clientId, QThEMjQwMjI1RjJCNEVCODhERUY1MjA1NEZERkQ4MkY=, --xuid, 2533274810344824, --userType, msa, --versionType, release, --width, 1024, --height, 768, --launchTarget, forgeclient, --fml.forgeVersion, 43.1.25, --fml.mcVersion, 1.19.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220805.130853]
[15:21:09] [main/INFO]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 17.0.3 by Microsoft; OS Mac OS X arch x86_64 version 12.6
[15:21:10] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/Users/twh/Twitch/Minecraft/Install/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2391!/ Service=ModLauncher Env=CLIENT
[15:21:11] [main/INFO]: Found mod
---- Minecraft Crash Report ----
// Ouch. That hurt :(
Time: 2022-09-24 15:22:55
Description: Mod loading error has occurred
java.lang.Exception: Mod Loading has failed
at net.minecraftforge.logging.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:55) ~[forge-1.19.2-43.1.25-universal.jar%23400!/:?] {re:classloading}
at net.minecraftforge.client.loading.ClientModLoader.completeModLoading(ClientModLoader.java:167) ~[forge-1.19.2-43.1.25-universal.jar%23400!/:?] {re:classloading,pl:runtimedistcleaner:A}
at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:585) ~[client-1.19.2-20220805.130853-srg.jar%23395!/:?] {re:mixin,pl:accesstransformer:B,pl:runtimedistcleaner:A,re:classloading,pl:accesstransformer:B,pl:mixin:APP:rubidium.mixins.json:core.MixinMinecraftClient,pl:mixin:APP:balm.mixins.json:MinecraftMixin,pl:mixin:APP:mixins.oculus.json:MixinMinecraft_Keybinds,pl:mixin:APP:mixins.oculus.json:MixinMinecraft_PipelineManagement,pl:mixin:APP:ae2.mixins.json:PickColorMixin,pl:mix

Unofficial Bash Strict Mode

Sometimes a programming language has a "strict mode" to restrict unsafe constructs. E.g., Perl has use strict, Javascript has "use strict", and Visual Basic has Option Strict. But what about bash? Well, bash doesn't have a strict mode as such, but it does have an unofficial strict mode:

set -euo pipefail

set -e