Skip to content

Instantly share code, notes, and snippets.

Avatar
💃
Not much. You?

Tim mildmojo

💃
Not much. You?
View GitHub Profile
@mildmojo
mildmojo / setup_teardown_helper.js
Last active Nov 3, 2015
Jasmine-node helpers: per-describe `setup` and `teardown` functions
View setup_teardown_helper.js
/*
setup_teardown_helper.js
Setup and teardown helper functions for jasmine-node (jasmine 1.3).
IMNSHO, every damn test runner should provide the following hooks:
startup (global; runs once before any setups or specs begin)
setup (describe-local; runs once before any specs in a `describe`)
beforeEach (describe-local; runs once before each spec in a `describe`)
afterEach (describe-local; runs once after each spec in a `describe`)
@mildmojo
mildmojo / gulpfile.js
Created May 29, 2015
Make gulp look more like rake
View gulpfile.js
/*
gulpfile.js
Gulp lacks a native way to provide task documentation or break tasks
into multiple files. This gulpfile reads './tasks/*.js' and can list
all available tasks with `gulp` or `gulp tasks`. If you set a .desc
property on your task functions, those descriptions will show up in
`gulp tasks` output. Tasks without descriptions will be omitted
from this output (but still visible with `gulp -T`).
@mildmojo
mildmojo / heartbeat.js
Last active Oct 21, 2015
Heartbeat.js - find event loop blocking code by looking for blown timeouts
View heartbeat.js
// Heartbeat log script for node.js. Use this to sniff out code that blocks
// your event loop; heartbeats will take longer if the event loop is
// blocked.
// Just require('./heartbeat.js'); ==OR== require('./heartbeat.js')(3000);
module.exports = go;
var DEFAULT_HEARTBEAT_MS = 2000;
var startedAt, loop;
go();
@mildmojo
mildmojo / LexitronCreateAxes.cs
Last active Aug 29, 2015
Bolt-on Lexitron arcade cabinet compatibility for Unity
View LexitronCreateAxes.cs
/* LexitronCreateAxes.cs
*
* 1. Place this script in your project's Assets/Editor/ directory.
* 2. Open Edit -> Project Settings -> Input and verify that there are four "Lexitron" axes.
* 3. Delete this script.
*
* All of this code shamelessly swiped from:
* http://www.plyoung.com/blog/manipulating-input-manager-in-script.html
* http://answers.unity3d.com/questions/26994/running-a-script-when-unity-starts.html
*/
@mildmojo
mildmojo / tls_creds.js
Last active Jul 6, 2017
Some basic NodeJS TLS security options
View tls_creds.js
var tls = require('tls');
var constants = require('constants');
// Disable client session renegotiation, no known use case per:
// https://www.ssllabs.com/downloads/SSL_TLS_Deployment_Best_Practices_1.3.pdf
// By virtue of require() caching, this will affect all code using `tls`.
tls.CLIENT_RENEG_LIMIT = 0;
// Based on whitelist proposed at: https://bugs.ruby-lang.org/issues/9424
// And SSL/TLS Best Practices: https://www.ssllabs.com/downloads/SSL_TLS_Deployment_Best_Practices_1.3.pdf
@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 / permission_to_leave.js
Created Nov 2, 2013
Saves your bacon when you're using jsbin.com with OS X and try to Cmd+Left to go to the beginning of the line.
View permission_to_leave.js
// ==UserScript==
// @name Permission to Leave
// @namespace permission.to.leave
// @description Prompts before leaving the page. Good for OS X users who press Cmd+Left while editing text to go to the start of the line, only to find the browser goes back a page instead.
// @version 1.0
// @grant none
// @include http://edit.script.and
// @include https://add.target.sites.here
// @include https://twitter.com
// ==/UserScript==
@mildmojo
mildmojo / haters.rb
Last active Dec 20, 2015
Script for pulling out all the Twitter haters blogged at http://gamerfury.tumblr.com (all sorts o' trigger warnings on that one).
View haters.rb
#!/usr/bin/env ruby
#
# haters.rb
#
# Finds all the Twitter users posted to http://gamerfury.tumblr.com and prints
# them, newline-delimited, to STDOUT. Require this file in your own script to
# access ScumbagHaterFinder directly.
#
# Tested with Ruby 2.0.0.
@mildmojo
mildmojo / GoogleAnalytics.cs
Last active Dec 11, 2015
Reporting Unity game events to Google Analytics from the Unity Webplayer. Calls out to the Google javascript library loaded on the page, so the class is configuration-free.
View GoogleAnalytics.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/* Google Analytics integration. Web page must be configured for GA with Google's javascript snippet.
*
* Based on a comment from 2010 found here:
* http://blog.mostlytigerproof.com/2009/10/06/gathering-statistics-using-google-analytics-and-unity-3d/
*
* Analytics category/action/label/value descriptions:
@mildmojo
mildmojo / arel_math_named_functions.rb
Created Nov 22, 2012
ARel named function helpers
View arel_math_named_functions.rb
# Collection of helpers for math-related ARel NamedFunctions.
#
# Include this in classes that need to do trig with DB functions. Lets you write
# cleaner code, like:
#
# dist = acos(sin(lat) * sin(arel_lat_field) +
# cos(lat) * cos(arel_lat_field) * cos(arel_lng_field)) * EARTH_RADIUS_KM
# band_num = round(dist / ring_width, 0)
# band_num.to_sql
# # => round(abs(acos(
You can’t perform that action at this time.