Skip to content

Instantly share code, notes, and snippets.

@sowasred2012
sowasred2012 / README.txt
Last active August 29, 2015 13:56
Made Code Dojo 1: Roman Numeral Kata
FAILED
http://butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata
Notes (cos I had to look up what Prime Factors were):
=====================================================
http://en.wikipedia.org/wiki/Prime_factor
Prime factors of a number are the prime numbers you would multiply together to get that original number as a result, e.g:
# Installs migrations from unmountable engines
bundle exec rake railties:install:migrations FROM=<ENGINE-NAME>_engine
@sowasred2012
sowasred2012 / detectOrientation.js
Last active December 10, 2015 21:28
Executes function whenever there's an orientation change (i.e. rotating a smartphone/tablet)
$(window).bind('orientationchange', function(){
// do whatever
});
// The below will give you the current orientation for iOS devices, possible values being 0, 90, -90 or 180 (180 on iPad only)
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
alert(window.orientation);
}
@sowasred2012
sowasred2012 / fullImage.js
Last active December 10, 2015 19:48
This was written by Eric (http://stackoverflow.com/users/102441/eric), in response to this question on SO: http://stackoverflow.com/questions/1682495/jquery-resize-to-aspect-ratio Resizes images to fit their parent, blowing it out of the sides if necessary to completely fill any white space (and the parent container is set to overflow:hidden).
jQuery.fn.fitToParent = function()
{
this.each(function()
{
var width = $(this).width();
var height = $(this).height();
var parentWidth = $(this).parent().width();
var parentHeight = $(this).parent().height();
if(width/parentWidth < height/parentHeight)