Skip to content

Instantly share code, notes, and snippets.

View brettchalupa's full-sized avatar

Brett Chalupa brettchalupa

View GitHub Profile
@brettchalupa
brettchalupa / main.gd
Created April 3, 2023 13:00
Godot Player Input Sample
extends Node2D
var rotate_icon = true
var speed = 10
func _process(delta: float) -> void:
if rotate_icon:
$Icon.rotate(delta)
if Input.is_action_pressed("move_down"):
@brettchalupa
brettchalupa / README.md
Last active February 19, 2023 01:18
SDL2 Windows Rumble Tester

Windows variant of https://github.com/brettchalupa/sdl_rumble since that didn't work as expected on Windows like it does on macOS and Linux.

Notes to self:

  • Used Code::Blocks with mingw 64 bit
  • SDL 2.26.3
  • PS4 hint allows for DualShock 4 rumble without any special drivers

Learnings:

@brettchalupa
brettchalupa / menu_demo.rb
Last active December 23, 2022 20:48
DragonRuby Game Toolkit Menu Demo
# LICENSE: https://unlicense.org/ a.k.a. do whatever you want with it, no credit or notice needed
def tick(args)
args.state.scene ||= :main_menu
args.state.main_menu.options ||= [
{
text: "Start",
on_select: -> (args) { args.state.scene = :gameplay }
},
{
text: "Settings",
@brettchalupa
brettchalupa / main.rb
Last active November 22, 2022 01:51
DragonRuby GTK PadBud Source r1
PADDING = 20
def tick args
args.outputs.background_color = [255, 255, 255]
args.outputs.labels << [PADDING, args.grid.h - PADDING, 'PadBud', 3]
args.outputs.labels << [PADDING, args.grid.h - PADDING * 3, 'A simple tool for viewing DragonRuby gamepad input.']
args.outputs.labels << [PADDING, 140, 'Platform Details', 2]
args.outputs.labels << [PADDING, 110, "OS: #{args.gtk.platform}"]
args.outputs.sprites << { x: PADDING + 80, y: args.grid.h - PADDING - 28, h: 32, w: 32, path: "metadata/icon.png" }
@brettchalupa
brettchalupa / asset-cleanup.rb
Created February 11, 2022 23:03
Wordpress image export filename clean up
# A simple script for cleaning up Wordpress file exports that have URL params potentially appended to the end, e.g. `foo.jpg?w=720`
# Assumes the files are located in the `assets` dir
require "fileutils"
def clean_up_files(dir)
Dir.foreach(dir) do |f|
next if f == "." || f == ".."
path = dir + "/" + f
puts path
@brettchalupa
brettchalupa / _organize_mp3s.rb
Last active February 4, 2022 18:40
Organize MP3s Ruby Script
# Organize MP3s by Brett Chalupa
#
# Pre-reqs:
# 1. Ruby v2+
# 2. gem install id3tag
#
# This script loops through a directory of mp3 files, like a an archive
# download from YouTube Music, and organizes them into the following structure
# in the folder:
#
@brettchalupa
brettchalupa / db_import.rake
Last active October 18, 2017 01:02
A Simple Rake Task for Importing Heroku Postgres Databases Locally for Rails Apps
# lib/tasks/db_import.rake
namespace :db do
namespace :import do
desc 'Import Heroku Staging database locally'
task :staging do
import_db('staging', 'YOUR_STAGING_HEROKU_APP_HERE')
end
desc 'Import Heroku Production database locally'
task :production do
@brettchalupa
brettchalupa / config.yml
Created September 15, 2016 23:33
Shopify Theme Kit config example for screencast (https://www.youtube.com/watch?v=1xWFsYmBoX0)
development:
store: example.myshopify.com
password: add-password-in-config
theme_id: "live"
bucket_size: 40
refill_rate: 2
ignore_files:
- "*.swp"
- "*~"
- "config/settings_data.json"
@brettchalupa
brettchalupa / Rakefile
Created March 14, 2016 19:03
Testing Rake tasks with RSpec examples from the talk I gave at Test Ruby PDX in March 2016. See more here: http://bit.ly/testing-rake-tasks
require_relative 'greeter'
desc 'Outputs a greeting to stdout'
task :hello do
Greeter.new.greet
end
@brettchalupa
brettchalupa / gist:e9245a1d9e5f0cdeda4c
Created January 14, 2016 18:22 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2: