Skip to content

Instantly share code, notes, and snippets.

View MitMaro's full-sized avatar
📆
Limited availability

Tim Oram MitMaro

📆
Limited availability
View GitHub Profile
@MitMaro
MitMaro / git-show-branches
Created September 28, 2016 13:16
Git Show Branches
#!/bin/bash
if [[ "$#" -ne 1 ]]; then
echo "usage: git show-merged <remote>"
echo
exit 1
fi
remote="$1"
@MitMaro
MitMaro / index.html
Created April 26, 2016 16:25
Basic Hello World in React
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.0.1/react-dom.js"></script>
<title>Hello World</title>
</head>
@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
@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 / .gitignore
Last active August 29, 2015 14:19
Rewire Mocha Bug
node_modules
@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 / 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 / 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 / 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 / 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]);
}