Skip to content

Instantly share code, notes, and snippets.

@dvessel
dvessel / chd-helpers.sh
Last active May 8, 2021
Helper functions to bulk convert bin/cue or gdi files to chd's and back.
View chd-helpers.sh
#!/bin/zsh
# - Requires homebrew. https://brew.sh
# - Converted files will be moved to the current working directory in all cases.
# - You can pass the starting directory for fzf search functions.
# - Pass in glob patterns for the standalone function to convert in bulk.
# For example, to convert gdi's in a sub-directory: chd.create */*.gdi
alias chd.fzf.create='_fzf-paths-to chd.create f ".(gdi|cue)$"'
alias chd.fzf.extract-to-cue='_fzf-paths-to chd.extract-to-cue f .chd$'
@dvessel
dvessel / oeadvscan
Last active Jan 12, 2021
Manage MAME files for OpenEmu Arcade core. Make it executable and unquarantine: `chmod +x oeadvscan && xattr -d com.apple.quarantine oeadvscan`
View oeadvscan
#!/bin/zsh
#
# For use on MAME files managed by OpenEmu.
# advscan roms/disks/samples verifies and repairs.
#
# All options apply to roms, disks (chd) and samples.
# Options:
#
# scan : Generates a report specific to your collection. (default)
@dvessel
dvessel / oemame.sh
Last active Jan 5, 2021
Shell functions for scanning/repairing MAME ROMs for OpenEmu on a Mac. Copy into your .zshrc file. Not tested on bash.
View oemame.sh
# advscan MAME roms/disks/samples scans and repairs.
function oemame.scan {
local command=${@:-scan}
local base_dir=$HOME/Library/Application\ Support/OpenEmu
local version=${${${:-`defaults read \
$base_dir/Cores/MAME.oecoreplugin/Contents/Info.plist CFBundleVersion`
}/./}%%.*}
# Go back to current directory when done.
# advscan can't resolve paths when run outside advscan.rc.
@dvessel
dvessel / oeshader.sh
Created Jan 1, 2021
Shell functions to manage OpenEmu shaders. Copy into your .zshrc file. Requires fzf. Not tested in bash.
View oeshader.sh
# OpenEmu shader functions. Requires fzf.
function oeshader.search {
defaults find videoShader.openemu | grep $@
}
function oeshader.copy {
local source=`oeshader.ls ${@:-1} | fzf --header="Select source:"`
if [[ -n $source ]]; then
oeshader.search -oE "system\.[a-z0-9]*" | sort -u |
fzf -m --header="Apply settings from \"${source##*.}\"." |
@dvessel
dvessel / Share Screen Shot.scpt
Last active Aug 29, 2015
AppleScript to capture screen shots and upload them with SCP.
View Share Screen Shot.scpt
-- Requires public key encryption setup for the remote server.
-- This also assumes LaunchBar is installed.
property the_url : "http://example.com/path/"
property save_folder : "/Users/bob/Sites/example.com/path/"
property scp_remote : "bob@example.com:/www/example.com/path/"
on run
set tmp_name to do shell script "date +'%Y-%m%d-%H%M%S'" & ".png"
@dvessel
dvessel / base-debug.css
Last active Dec 20, 2015
Ensure component modifiers have a set base. @extend in Sass can get out of hand. Manually setting both base and modifiers can trim down the compiled styles.
View base-debug.css
// Find modifer without base.
// .[base--]modifier - yes
// .[base-s]ubelement - no
// .foo-[base--]modifier - no
// .bar[base--]modifier - uhh.. Just name your classes correctly.
[class*="base--"]:not([class*="-base--"]) {
outline: 2px solid red;
}
// Base exists, cancel.
[class*="base--"]:not([class*="-base--"]).base {
@dvessel
dvessel / template.php
Last active Mar 11, 2021
Drupal theme registry alterations to allow theme functions, preprocess/process function to be organized like templates (.tpl.php).
View template.php
<?php
/**
* Theme templates, functions and preprocess/process functions
*
* Theme templates `*.tpl.php` files are stored in the `theme` directory along
* with `*.func.php` and `*.vars.php` files. The latter two are enabled by the
* processing done below. The three types of files can be grouped into
* sub-directories. It is recommended that they are grouped by the modules
* they originate from. Theme specific hooks should be grouped into a folder
@dvessel
dvessel / .bash_profile
Last active Dec 18, 2015
A few of my dot files.
View .bash_profile
# Styles @see man terminfo
__blu=`tput setaf 25` # blue
__gra=`tput setaf 245` # gray
__ora=`tput setaf 208` # orange
__end=`tput setaf 0` # end colors
__bol=`tput bold` # bold
__res=`tput sgr0` # reset
# /usr/local/* defined so it comes before /usr/bin and /bin. Required for
# Homebrew. Default PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
View .ctags
-R
--exclude=.svn
--exclude=.git
--exclude=vendor
--exclude=*.min.js
--c++-kinds=+p
--fields=+iaS
--extra=+qf
--totals=yes
--tag-relative=yes
@dvessel
dvessel / gist:5406410
Created Apr 17, 2013
AppleScript I use with LaunchBar to upload screenshots to dropbox. tmp folder automatically cleans itself out every month through Hazel.
View gist:5406410
--Two changes to be made before you use this script
--1. Find this line in the script below and change it to the path to your Dropbox Public folder.
--Change pubfolder to the path of your dropbox public folder (ex. /Users/John/Dropbox/Public/)
--2. Observe one of your Dropbox URLs and you will notice that there are some numbers in those URLs. That is your Dropbox id.
--Find this line in the script below and change it to your Dropbox id instead of 123456
--set dropboxID to 123456
-------------------------------------------------------------------
--How to use?
--Bring this script in LaunchBar, press space and type the name that you would like to give to that screenshot and press return
--e.g. myname