Skip to content

Instantly share code, notes, and snippets.

View bendavis78's full-sized avatar

Ben Davis bendavis78

  • O'Reilly Media
  • Dallas, TX
View GitHub Profile
@bendavis78
bendavis78 / paru-find-dep-reason.sh
Created June 12, 2024 23:35
Find packages that are causing issues during paru upgrade
#!/bin/bash
# Require argument for the package name
if [ -z "$1" ]; then
# only show script name in usage
echo "Usage: $(basename $0) <package_name>"
exit 1
fi
pkgname="$1"
@bendavis78
bendavis78 / brick.py
Created October 2, 2023 17:41
Brick tutorial using 123d CAD library
from build123d import *
from ocp_vscode import *
C, MIN, MAX = Align.CENTER, Align.MIN, Align.MAX
pip_count = 6
brick_unit_size = 8
pip_height = 1.8
pip_diameter = 4.8
import ml4k
import random
import tkinter as tk
from copy import copy
from tkinter import messagebox
API_KEY = "PASTE-API-KEY-HERE"
AI_MODE = "random"
TRAINING = False
import tkinter as tk
from tkinter import messagebox
# We can make a "virtual" game board as a list of lists. The list contains 3 other lists (rows).
# Each row list contains 3 string values representing spaces. The spaces will be populated with
# either "X" or "O", but we start with empty strings to denote an empty space.
#
# We can access a space on the board using row and column indexes. For example, the top-left space
# is `board[0][0]`, the center space is `board[1][1]`, and the bottom-right space is `board[2][2]`.
@bendavis78
bendavis78 / capslock_super_esc.md
Last active August 7, 2024 10:44
Mapping Caps Lock to simultaneous Esc and Super (Mod4)

Mapping Caps Lock to simultaneous Esc and Super (Mod4)

The CAPS key can be mapped to an escape key when pressed once, and a super (mod4) key when used in combination with other keys.

Create the file /usr/share/X11/xkb/symbols/custom_opts with the following:

// Make Caps an additional Escape
hidden partial modifier_keys
xkb_symbols "super_esc" {

key { [ Escape ] };

Using Python w/ Minecraft on Ubuntu

These instructions should work on any Ubuntu-based OS, but have only been tested on GalliumOS.

Install required packages

Copy and paste the following line into a terminal and press enter to install all the dependencies (you might already have some installed):

sudo apt update
sudo apt install python-software-properties python3 python3-pip idle3 git
sudo apt install openjdk-8-jre-headless openjdk-8-jdk maven
@bendavis78
bendavis78 / Collisions.js
Created April 24, 2018 21:34
extends 3D objects (eg, `Mesh`, or any subclass of `Object3D`) and adds a `.intersects()` function to check if the objects is touching one or more other objects.
/* global THREE */
(function() {
function getBoundingBox(obj) {
var min = obj.position.clone();
var max = obj.position.clone();
if (obj.geometry) {
if (!obj.geometry.boundingBox) {
@bendavis78
bendavis78 / monty.py
Last active September 26, 2017 06:00
import sys
import random
results = []
strategy = 'stay'
if len(sys.argv) > 1:
strategy = sys.argv[1]
for i in range(0, 100):
# Shuffle doors
<body></body>
<script src="http://gamingJS.com/Three.js"></script>
<script src="http://gamingJS.com/ChromeFixes.js"></script>
<script>
// This is where stuff in our game will happen:
var scene = new THREE.Scene();
// This is what sees the stuff:
var aspect_ratio = window.innerWidth / window.innerHeight;
var camera = new THREE.PerspectiveCamera(75, aspect_ratio, 1, 10000);