Skip to content

Instantly share code, notes, and snippets.

View thomashope's full-sized avatar
🍃
Walking in the woods.

Thomas Hope thomashope

🍃
Walking in the woods.
View GitHub Profile
@thomashope
thomashope / DefaultKeyBinding.dict
Last active October 12, 2022 13:37
Changes the behaviour of the Home and End keys on Mac to be the same as Windows instead of being UTTERLY USELESS
/*
Place this file in ~/Library/KeyBindings/DefaultKeyBinding.dict
To access the folder from Finder press COMMAND+SHIFT+G, then type ~/Library and press Enter.
From there locate the KeyBindings folder or create it if it doesn't exist.
*/
{
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
@thomashope
thomashope / NiceColors.cs
Last active February 8, 2022 16:13
Raylib colors, ported to Unity!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Color values and names are taken from Raylib, which is released under the zlib License
// Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
// Custom raylib color palette for amazing visuals
public static class NiceColors
{
@thomashope
thomashope / package_mac.sh
Last active October 5, 2022 11:00
Uploading an app to apple and waiting for notarisation to complete
# script setup
set -Eeuxo pipefail
setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}
@thomashope
thomashope / README.md
Created October 19, 2021 00:51
Defining Mac App Info.plist in code

Having to build an app and bundle it with an Info.plist can sometimes be inconvenient.

A while ago I found out it is possible to bundle your Info.plist directly into a section in the executable by adding the following to your linker options:

-sectcreate __TEXT __info_plist ../../source/Mac/Info.plist

With some trial and error it seems that it is possible to create such a section directly in code using the __attribute__ syntax.

Note that when you include an Info.plist normally you can use variables $(PRODUCT_NAME) which get expanded at some point during the bundling process, if you decided to use this for real you’d have to work around that?

@thomashope
thomashope / .gitattributes
Last active October 5, 2022 10:55
Git setup for Unity projects
# Macro for Unity YAML-based asset files.
[attr]unityyaml -text merge=unity diff
# Macro for all binary files that should use Git LFS.
[attr]lfs -text filter=lfs diff=lfs merge=lfs
# Default to auto-normalized line endings.
* text=auto
# Code
require "config"
local name = config.appName
workspace (name)
configurations { "Debug", "Release" }
location ("build/" .. _ACTION)
project (name)
kind "WindowedApp"
import maya.cmds as cmds
# define the functions before passing them as function objects to the buttons
# functions should take *args because UI elements pass some number of arguments depending on
# what type of element they are and their current state, or something like that...
# see -> http://download.autodesk.com/us/maya/2011help/PyMel/ui.html#function-name-as-string
def say_hello(*args):
number = 123
# numbers have to be converted to strings explicitly with the str() function
print("Testing testing, "+str(number)+"..."+"\nHello!")
import maya.cmds as cmds
# what to call the army
army_name = "Toms_dangerous_cubes"
cmds.group(empty=True, name=army_name)
# how many rows and columns the army should have
rows = 5;
cols = 5;