Skip to content

Instantly share code, notes, and snippets.

Avatar
💃
Not much. You?

Tim mildmojo

💃
Not much. You?
View GitHub Profile
@mildmojo
mildmojo / rotate_desktop.sh
Created Jun 18, 2014
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
View rotate_desktop.sh
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation
@mildmojo
mildmojo / left_join_arel_example.rb
Last active Nov 19, 2020
LEFT JOIN in ARel for ActiveRecord in Ruby on Rails
View left_join_arel_example.rb
# Here's a contrived example of a LEFT JOIN using ARel. This is an example of
# the mechanics, not a real-world use case.
# NOTE: In the gist comments, @ozydingo linked their general-purpose ActiveRecord
# extension that works for any named association. That's what I really wanted!
# Go use that! Go: https://gist.github.com/ozydingo/70de96ad57ab69003446
# == DEFINITIONS
# - A Taxi is a car for hire. A taxi has_many :passengers.
# - A Passenger records one person riding in one taxi one time. It belongs_to :taxi.
@mildmojo
mildmojo / gist:2044883
Created Mar 15, 2012
Add Firefox buttons to manipulate about:config settings
View gist:2044883
/*
I needed a button in the Firefox UI to toggle the default page zoom level
setting offered by the NoSquint extension (shown as "extensions.nosquint.fullZoomLevel"
in about:config). Since this isn't likely to be provided directly and I
wasn't interested in writing my own extension for something so simple, I
looked for an extension that would expose about:config settings to buttons.
Instead, I found the Custom Buttons extension:
@mildmojo
mildmojo / darksub.js
Created Feb 4, 2020
Dark frame subtraction script for removing digital camera sensor noise from long-exposure photos
View darksub.js
#!/usr/bin/env node
/*
darksub.js
Implements the dark frame subtraction pipeline using ImageMagick described here:
https://www.imagemagick.org/discourse-server/viewtopic.php?p=62840&sid=c6a5c35cc2805a51e37ae5f18895b609#p62840
It's very slow.
@mildmojo
mildmojo / gulpfile.js
Created May 30, 2019
Gulp task definition helper so all gulp tasks can have descriptions for `gulp -T`.
View gulpfile.js
'use strict';
const exec = require('child_process').exec;
// Quick shortcut for shortcomings in `gulp.task` API:
// 1. `gulp.task` doesn't accept a description, has to be a prop on the function.
// 2. Since description has to be on the task function, it's harder to add a
// description to tasks whose functions were created by a helper (e.g.
// `gulp.series` or `gulp.parallel`) since you didn't define the functions
// they return.
function gulpTask(name, desc, fn) {
@mildmojo
mildmojo / rotate-audio-output.sh
Last active Apr 9, 2019
Script for Linux to set the next available audio output as the default system output, switching all current streams over to it.
View rotate-audio-output.sh
#!/bin/bash
#
# rotate-audio-output.sh
#
# Switch to the next available audio output device and show a notification with
# all available devices and the one currently selected.
#
# You may need to edit /etc/pulse/default.pa and change the appropriate line to:
# load-module module-stream-restore restore_device=false
#
@mildmojo
mildmojo / bitsy-logic-operators-extended.js
Created Mar 4, 2018
More logic operators for bitsy. &&, ||, !==, &&!, and ||!
View bitsy-logic-operators-extended.js
/* Operator logic is at the bottom of this script; need to declare the toolkit first. */
/*
================================
SCRIPT HOOKS TOOLKIT (@mildmojo)
================================
HOW TO USE:
1. Paste this whole file in script tags at the bottom of your Bitsy
exported game HTML, after the last /script> tag.
@mildmojo
mildmojo / bitsy-import-external-game-data.js
Last active Feb 21, 2018
DEPRECATED! See notes in code and in first comment. (Bitsy game engine mod to load game data from an external file or URL)
View bitsy-import-external-game-data.js
/*
************************************************************************
THIS GIST IS OUTDATED
There's a new version published in the bitsy-hacks repo, which fixes
some bugs. Go get it instead!
Direct link to the external game data mod:
https://raw.githubusercontent.com/seleb/bitsy-hacks/master/external-game-data.js
@mildmojo
mildmojo / bitsy-dialog-exit-room.js
Last active Feb 21, 2018
DEPRECATED! See notes in code and in first comment. (Bitsy engine mod: dialog function to exit to another room)
View bitsy-dialog-exit-room.js
/*
************************************************************************
THIS GIST IS OUTDATED
There's a new version published in the bitsy-hacks repo, which changes
syntax to use parentheses instead of curly braces so the editor
doesn't eat your function calls! Go check out the new script and see
all the new stuff in the header comments.
bitsy-hacks repo at: https://github.com/seleb/bitsy-hacks
@mildmojo
mildmojo / html-annotate-filenames.js
Last active Sep 27, 2017
Webpack loader that inserts original source filenames as HTML comments
View html-annotate-filenames.js
/*
html-annotate-filenames
Webpack loader that surrounds generated HTML blocks with comments noting the
original source filename for the block.
To use, modify your webpack config with a `resolveLoader` that can find this
file and a rule for this loader. Example:
{
You can’t perform that action at this time.