Skip to content

Instantly share code, notes, and snippets.

View MitMaro's full-sized avatar
📆
Limited availability until May

Tim Oram MitMaro

📆
Limited availability until May
View GitHub Profile
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:time];
[UIView setAnimationDelay:0];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView commitAnimations];
-- PRAGMAs
PRAGMA foreign_keys = ON;
-- User
CREATE TABLE account(
id TEXT PRIMARY KEY,
user_id TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
password_reset_code TEXT NULL,
email TEXT UNIQUE NOT NULL,
@MitMaro
MitMaro / Vector.java
Created March 12, 2014 17:30
A vector class in Java
package ca.mitmaro.cs4751.a03;
public class Vector {
public static class Vector2D extends Vector {
public Vector2D(Vector v) {
this(v.components[Vector.X], v.components[Vector.Y]);
}
@MitMaro
MitMaro / jekyll-paginate-bug-create.sh
Created August 23, 2014 02:19
Jekyll site for recreating a bug in Jekyll Paginate
mkdir website.jekyll
cd website.jekyll
mkdir _layouts _posts
touch _layouts/default.md
touch _posts/2000-01-01-title1.md _posts/2000-01-02-title2.md
cat > index.html << EOF
---
layout: default
---
EOF
@MitMaro
MitMaro / LocalStorageAction.js
Created February 2, 2015 17:19
Fluxxor Local Storage
var localStorageActionCreator = function(flux, store) {
var _timerId = null;
// only way I can think to get the dispatcher into the timer actions
// which are not real actions
var _dispatch = flux.dispatchBinder.dispatch;
// force save every little bit in case this storage object doesn't get a chance
// to save
setInterval(_persistData, 60 * 1000);
@MitMaro
MitMaro / Combine.js
Last active August 29, 2015 14:16
How to combine two reals into one in javascript
// some number that when 360 * precision * 100 + 50 * precision won't overflow an integer
// number of positions after the decimal to keep
var digits = 4;
var precision = Math.pow(10, digits);
function combine(x, y, maxydigits) {
x = Math.floor(x * precision);
y = Math.floor(y * precision);
var maxy = Math.pow(10, maxydigits) * precision;
return x * maxy + y;
@MitMaro
MitMaro / index.js
Last active August 29, 2015 14:18
Tabs vs Spaces
// wrong
if (true) {
someLongFunctionName(/*somelong item like this that requires a second line*/,
/*some other item */);
}
// correct
if (true) {
someLongFunctionName(/*somelong item like this that requires a second line*/,
/*some other item */);
@MitMaro
MitMaro / .gitignore
Last active August 29, 2015 14:19
Rewire Mocha Bug
node_modules
@MitMaro
MitMaro / bitbucket-tab-size.js
Created March 29, 2016 19:33
Tampermonkey script for BB diff to change the tab size.
// ==UserScript==
// @name BitBucket tab size
// @namespace http://mitmaro.ca
// @version 1.0.0
// @description Converts the diff tab size on BB
// @author Tim Oram
// @match https://bitbucket.org/*/*/pull-requests/*/diff
// @grant none
// ==/UserScript==
@MitMaro
MitMaro / jsonToModule
Last active April 8, 2016 12:38
Covert JSON to Node module
#!/bin/bash
SCRIPTROOT="$( cd "$(dirname "$0")" ; pwd -P )"
for f in "$@"; do
NEWFILE="${f:0:${#f} - 4}js"
gsed -f "$SCRIPTROOT/jsonToModule.script" "$f" > "$NEWFILE"
rm "$f"
done