Skip to content

Instantly share code, notes, and snippets.

View peteroome's full-sized avatar

Peter Roome peteroome

View GitHub Profile
@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

Documents

  • Passport
  • Ferry ticket
  • Eurostar ticket
  • Hotel receipt

Gear

  • Water bottles x2
  • Lights + cable
  • Garmin + cable
@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'
@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 / 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 / message.jeco
Created October 8, 2013 07:30
Spine Post & Messages, Chat Display.
<li class='item'>
<%= @body %>
</li>
@peteroome
peteroome / student.rb
Created April 24, 2013 10:09
Searching. Building up a query
def self.search(params)
scope = scoped({})
scope = scope.scoped :where => ['title_id = ?', params[:title_id] ] unless params[:title_id].blank?
scope = scope.scoped :where => ['upper(first_name) like upper(?)', params[:first_name] ] unless params[:manufacturers].blank?
scope
end
@peteroome
peteroome / FSocial
Last active December 16, 2015 01:19
Twitter Web Intents
class window.FSocial
constructor:->
@links = $ '.share-links'
@fbLink = $ '.facebook', @links
@channelUrl = @links.data('channel-url') + "/channel.html"
@bindTwitter()
@bindFacebook()
bindTwitter: () ->
reward = @rewardCredits
@peteroome
peteroome / cols_example
Created February 14, 2013 14:20
inline-block cols
<div class='col1'>
</div>
<!-- -->
<div class='col2'>
</div>
@peteroome
peteroome / access_control_allow_origin_amazon_s3
Created January 16, 2013 08:45
Access-Control-Allow-Origin Configuration on Amazon S3 to load Font Awesome from Rails app on Heroku.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://mydomain.com</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>