Skip to content

Instantly share code, notes, and snippets.

View peteroome's full-sized avatar

Peter Roome peteroome

View GitHub Profile
@peteroome
peteroome / post_length.rb
Created October 15, 2013 21:54
Jekyll post length in words, plugin.
# A simple word/time count plugin for Jekyll.
#
# input = The given content (a Liquid tag).
# count_words = Returns the word count.
# count_seconds = Returns the seconds by dividing the word count by 5,
# which is how many words the average person reads per second.
# reading_length= Consumes the length of the post in seconds, works out minutes
# and queries time_and_word for a relevant string.
# time_and_word = Takes the length of the post in minutes and returns a string
# relating to the length of the read.
@peteroome
peteroome / colour_generator.js
Created March 24, 2014 20:42
Generate a colour within a range based on a value
function Interpolate(start, end, steps, count) {
var s = start,
e = end,
final = s + (((e - s) / steps) * count);
return Math.floor(final);
}
function Color(_r, _g, _b) {
var r, g, b;
var setColors = function(_r, _g, _b) {
@peteroome
peteroome / FAdminForm.coffee
Created May 13, 2014 13:58
Admin form CS
class window.FAdminForm
PREFILL_CONTENT =
general_news:
title: 'General News'
body: '<p><strong><a href=""></a></strong> have </p>
<p></p>
<p></p>
<p><strong>See Also: <a href="URL">TITLE</a></strong><br/>
<strong>See Also: <a href="URL">TITLE</a></strong></p>'
seo_title: 'Page Title: | News | The 405'

Documents

  • Passport
  • Ferry ticket
  • Eurostar ticket
  • Hotel receipt

Gear

  • Water bottles x2
  • Lights + cable
  • Garmin + cable
@peteroome
peteroome / squares.c
Last active February 5, 2016 08:29
Algorithm to get the maximum size of n squares that fit into a rectangle with a given width and height (http://math.stackexchange.com/questions/466198/algorithm-to-get-the-maximum-size-of-n-squares-that-fit-into-a-rectangle-with-a) #WIP
int main(){
double x=5, y=6, n=7;//values here
double px=ceil(sqrt(n*x/y));
double sx,sy;
if(floor(px*y/x)*px<n) //does not fit, y/(x/px)=px*y/x
sx=y/ceil(px*y/x);
else
sx= x/px;
double py=ceil(sqrt(n*y/x));
if(floor(py*x/y)*py<n) //does not fit