Skip to content

Instantly share code, notes, and snippets.

View amirrajan's full-sized avatar
💭
Working on DragonRuby Game Toolkit and RubyMotion

Amir Rajan amirrajan

💭
Working on DragonRuby Game Toolkit and RubyMotion
View GitHub Profile
@amirrajan
amirrajan / readme.org
Created April 16, 2025 23:44
DragonRuby primer for Love2D

functions

lua

function foo(a, b)
  return a + b
end

ruby

def foo(a, b)
@amirrajan
amirrajan / HotKeys.lua
Created April 16, 2025 14:18
hammer spoon ctrl+t to swap bettween windows
require("hs.ipc")
hs.hotkey.bind({'ctrl'}, "t", function()
app_name = hs.application.frontmostApplication():name()
if app_name == 'Alacritty' then
hs.osascript.applescript('tell application "Chrome" to activate')
else
hs.osascript.applescript('tell application "Alacritty" to activate')
end
end)
@amirrajan
amirrajan / WindowsManagement.lua
Created April 16, 2025 13:53
Hammer Spoon windows management
require("hs.ipc")
--- ==========================================
--- Window Management
--- ==========================================
-- ctrl+option+left resizes window to left half of screen
hs.hotkey.bind({'ctrl', 'option'}, "Left", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
@amirrajan
amirrajan / .zshrc
Created April 15, 2025 22:31
ZSH vim mode
set -o vi
# =====================
# vi mode
# =====================
bindkey -v
export KEYTIMEOUT=1
# =====================
# Change cursor shape for different vi modes.
# ~/.oh-my-zsh/custom/themes/amirrajan.zsh-theme
# https://github.com/blinks zsh theme
function _prompt_char() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
echo "%{%F{blue}%}±%{%f%k%b%}"
else
echo ' '
fi
}
@amirrajan
amirrajan / .tmux.conf
Created April 15, 2025 19:13
Tmux config 5/15/2025
# ~/.tmux.conf
# * brew install tmux reattach-to-user-namespace
# * C-e - Your leader <l> key.
# * <l>: - Type command not handled by shortcut keys. Eg: <l>: kill-pane ENT
# * <l>r - Reload this file/config.
# * <l>j - Select split using number jump list.
# * <l>{ - Swap splits left.
# * <l>} - Swap splits right.
# * <l>| - Create vertical split.
# * <l>- - Create orizontal split.
@amirrajan
amirrajan / 00_preview.md
Last active April 6, 2025 07:14
DragonRuby Game Toolkit - Beakers with liquids

beaker

@amirrajan
amirrajan / main.rb
Last active March 30, 2025 06:48
DragonRuby Game Toolkit: Slay the Card Game Example
class Game
attr_gtk
attr :enemy
def tick
defaults
calc
render
end
@amirrajan
amirrajan / main.rb
Created March 25, 2025 23:33
DragonRuby Game Toolkit - Dual Stick Shooter with keyboard and analog support.
class Game
attr_gtk
def defaults
state.player ||= { x: 640,
y: 360,
w: 80,
h: 80,
dx: 0,
dy: 0,
@amirrajan
amirrajan / day_1.rb
Last active March 28, 2025 02:16
Advent of Code 2024
def parse_input path
content = File.read path
list_1 = []
list_2 = []
content.each_line do |line|
l = line.strip.gsub(/\s+/, ' ').split(' ')
next if l.length != 2
list_1 << l[0].to_i
list_2 << l[1].to_i
end