Skip to content

Instantly share code, notes, and snippets.

View girasquid's full-sized avatar
🦐

Luke Hutscal girasquid

🦐
View GitHub Profile
@girasquid
girasquid / striped_box.rb
Last active October 13, 2023 00:20
This is a helper method that makes you a box filled with diagonal stripes. You can pass in the spacing between stripes, as well as any extras you want applied to the border or lines (ex. colors)
def striped_box(x, y, w, h, spacing=10, border_extra={}, line_extra={})
primitives = []
border_box = {
x: x,
y: y,
w: w,
h: h,
}
primitives << border_box.merge(primitive_marker: :border).merge(border_extra)
top_corner_x = x
context "making sure we don't accidentally take the site down" do
EXPECTED_NUMBER_OF_WORKERS = 10 # copy this value from the other place it's defined; this shouldn't be dynamic, repeating yourself is better
it "reminds the user of side effects" do
begin
expect(MySystem::NUMBER_OF_WORKERS).to eq(EXPECTED_NUMBER_OF_WORKERS)
rescue RSpec::Expectations::ExpectationNotMetError => error
error.message << "\n"
error.message << <<~HEREDOC
📎 Oh hi there! It looks like you changed the value of MySystem::NUMBER_OF_WORKERS.
@girasquid
girasquid / Timer.cs
Created July 14, 2018 17:49
Simple countdown timer for Unity projects that updates a Text (you supply the Text and how many seconds to start at)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[ExecuteInEditMode]
public class CountdownTimer : MonoBehaviour {
public Text timerText;
public int startingSeconds;
@girasquid
girasquid / dictionary_words.sh
Created November 26, 2016 16:04
Get all words that are between 3 and 6 characters long from your system's dictionary, and then format them so that you can drop them into an array.
cat /usr/share/dict/words | grep '.\{3\}' | grep -v '.\{6\}' | sed 's/^/"/;s/$/",/' | pbcopy
@girasquid
girasquid / project-age.sh
Created July 19, 2016 00:28
Bash script that calculates age of each folder in a directory, based on git commits
#!/usr/bin/env bash
# http://www.daveeddy.com/2014/06/29/human-readable-duration-in-bash/
human() {
local seconds=$1
if ((seconds < 0)); then
((seconds *= -1))
fi
local times=(
@girasquid
girasquid / Keyboard.as
Created September 29, 2015 00:26
Kinda-bad keyboard button tracking class with a similar interface to Controllers.as: https://gist.github.com/girasquid/50c7c9f2de45a6079e4c
package controllers {
import com.junkbyte.console.ConsoleChannel;
import starling.display.Stage;
import starling.events.KeyboardEvent;
public class Keyboard {
private static const channel:ConsoleChannel = new ConsoleChannel("Keyboard");
private static var stage:Stage;
private static var trackingKeys:Object = {};
@girasquid
girasquid / Controllers.as
Last active September 17, 2015 02:21
Kinda-bad multi-controller helper library, loosely modelled off KeyActionBinder but simpler. Supports XBone, PS3 DS, and Logitech F310 (DirectInput mode) on OS X.
package controllers {
import com.junkbyte.console.ConsoleChannel;
import flash.events.GameInputEvent;
import flash.ui.GameInput;
import flash.ui.GameInputDevice;
public class Controllers {
private static const channel:ConsoleChannel = new ConsoleChannel("Controllers");
private static var _input:GameInput;
package {
import starling.core.Starling;
import starling.animation.Transitions;
import starling.animation.Tween;
public class Utils {
// This function accepts an originalX and originalY so that you can shake things that
// are on screen but not necessarily originally located at 0, 0 (compared to the original
// implementation which only ever moved things back to 0, 0)
public static function screenShake(drawable:Shakeable, shakeDuration:Number, intensity:Number, originalX:Number, originalY:Number):void {

How to connect PS3 controller on Mac OSX, PC, etc.

This is how you connect PS3 controller to Mac OSX, PC, etc. when previously connected to a PS3. You will need a Mini USB cable. Overcome your laziness and go get one!

A big misconception is that keep holding PS button will reset the controller's pairing. It doesn't! From my testing, the controller pairs with the last machine it was CONNECTED VIA A USB CABLE.

Here are the real Steps:

require 'data_objects'
require 'data_mapper'
require 'dm-core'
require 'dm-do-adapter'
require 'do_postgres'
module DataMapper
class << self
attr_accessor :query_count
end