Skip to content

Instantly share code, notes, and snippets.

# 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)
Spree::Order.prepend(Kjus::Order)
Spree::Order.class_eval do
attr_accessor :use_shipping
before_validation :clone_shipping_address, if: :use_shipping?
def use_shipping?
@use_shipping == true || @use_shipping == 'true' || @use_shipping == '1'
end
  • Invite Supply Chain Users
    • demonstrate that an invited contact associated with a member authority is given access to the supply chain member dashboard, and sees only their company's data
  • Adding a User
  • Regional Help for Cities
  • Demo expandable guidance doc block
  • Demo webinar calendars and Programme calendars
    • including different colours for supply chain/cities
  • Supply Chain custom search block
  • Supply Chain specific help block
  • Tweaks to search results page?
@sowasred2012
sowasred2012 / timekeepsonslippin.sh
Created June 23, 2014 09:59
Vagrant time slippage
# time in Vagrant seems to fall out of sync fairly often (albeit very slowly)
# and can fuck with some oauth requests - this syncs it back up:
sudo ntpdate pool.ntp.org
Rock Paper Scissors Lizard Spock is a more convoluted and much geekier version of Rock Paper Scissors.
The rules are:
Rock beats Scissors
Rock crushes Lizard
Paper covers Rock
Paper disproves Spock
Scissors cut Paper
Scissors decapitate Lizard
@sowasred2012
sowasred2012 / README.txt
Created May 21, 2014 14:29
NumberLetterCounts Kata (Project Euler)
If the numbers 1 to 5 are written out in words: one, two, three, four, five
then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
NOTE:
Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.