Skip to content

Instantly share code, notes, and snippets.

Avatar

Luke Hutscal girasquid

View GitHub Profile
View guard_rail_spec.rb
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 Jul 14, 2018
Simple countdown timer for Unity projects that updates a Text (you supply the Text and how many seconds to start at)
View Timer.cs
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 Nov 26, 2016
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.
View dictionary_words.sh
cat /usr/share/dict/words | grep '.\{3\}' | grep -v '.\{6\}' | sed 's/^/"/;s/$/",/' | pbcopy
@girasquid
girasquid / project-age.sh
Created Jul 19, 2016
Bash script that calculates age of each folder in a directory, based on git commits
View project-age.sh
#!/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 Sep 29, 2015
Kinda-bad keyboard button tracking class with a similar interface to Controllers.as: https://gist.github.com/girasquid/50c7c9f2de45a6079e4c
View Keyboard.as
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 Sep 17, 2015
Kinda-bad multi-controller helper library, loosely modelled off KeyActionBinder but simpler. Supports XBone, PS3 DS, and Logitech F310 (DirectInput mode) on OS X.
View Controllers.as
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;
View SimpleScreenShake.as
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 {
View How to connect a PS3 controller.md

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:

View datamapper_query_counter.rb
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
View SimpleFormat.as
package text {
import flash.text.TextFormat;
public class SimpleFormat extends TextFormat {
public function SimpleFormat(options:Object):void {
for(var k:Object in options) {
if(this.hasOwnProperty(k)) {
this[k] = options[k];
}
}
You can’t perform that action at this time.