Blog

Spirograph Generator

Here is something I cobbled together with a bit of maths I tried desperately to remember from school. There are some pretty intense possible calculations, I think I definitely crashed codepen at one point (nothing worked in my pen, the latest pens feed didn't work, and - mysteriously - hours later the pen had been edited with some JavaScript commented out...

Anyway, here it is, its looking pretty strong I think! There are a few tweaks to be made, for example there are 'repeatable' patterns where as some numbers change, it just draws over itself rather than trace a new evolution.

The dream is to add animation, but to be honest... I think that step was what destroyed codepen, and my brain!

See the Pen Spirograph generator by djave_co (@sheepysheep60) on CodePen

New CSS update!

I updated my site's main CSS file. I say 'updated', I really should say 'culled' as most of what was lurking in the multiple stylesheets was just waffle, built up over years of gradual updates.

I hope you like it, every page has a random primary colour, but other than that is super stripped down. I use a few grids I made in gridpak, and some colours from flatuicolours, and some new fonts: Montserrat, Roboto Slab and Source code pro for the code snippets.

Feedback welcome, and encouraged!

I also stripped down and updated the ridiculous rules of Carl Cox, one of the best and most ridiculous drinking games ever conceived.

Order of the cards James Gallea 673 King Street trick

This is the order of the cards in James Gallea 673 King Street trick. I thought one day I might like to learn it, its awesome. I couldn't find the cards written down anywhere so I played the video and jotted them down.

The suits don't matter except the red and black queens at the start, and make sure your straight flush at the end is all Spades : )

Red Queen Red Queen Black Queen Black Queen Jack 6 7 3 King 2 5 2 5 Jack 7 King 6 7 3 King 6 7 3 King 2 5 10 10 10 10 Jack 4 4 8 8 8 4 9 9 9 9 8 A A A A WHAT THE HELL? Jack 2 3 4 5 6

Made famous by reddit!

This the same trick that was recently featured on reddit videos, with the Irish lad at the pool table. You can check out his great rendition here

Blog pagination.

I just did it. This is the function that returns an array of my posts:

public static function find_active($page=0)
	{
		$all_posts = static::find_by_sql("SELECT * FROM " . static::$table_name . " WHERE  `active`=1 ORDER BY `date` DESC  "); 
		if($page==0){
			return $all_posts;
		}
		$from = POSTS_PER_PAGE * ($page - 1);
		return array_slice($all_posts, $from, POSTS_PER_PAGE);
	}

This function is slightly interesting because, always remember, after a return, an else statement isn't necessary. I also made a little function that just counts the total posts:

public static function count(){
		$all_posts = static::find_by_sql("SELECT * FROM " . static::$table_name . " WHERE  `active`=1 ORDER BY `date` DESC  "); 
		return count($all_posts);
	}

Then I just use these two functions in my page to grab whichever posts I want:

// Grab the page number
if(!empty($_GET['p'])){$page = $_GET['p'];}
else{$page = 1;};
$blogs = Blog::find_active($page); 

And to echo out the pagination at the bottom:

<nav class="blog-pages">Select page:
<?php
	// Count the posts
	$count = Blog::count();
	// Find the number of pages (round up no matter how small the difference)
	$pages = ceil($count / POSTS_PER_PAGE);
	// For each page
	for($i=1; $i<=$pages;$i++):
		// Create a link to the page
		$marker = "<a href='".WEB_ROOT."blog/p/$i'";
		if($i == $page){
			// If it is the current page (if blog/p/this_page_number) make it active
			$marker .= " class='active'";
		}
		// Add the number
		$marker .=">$i</a>";
		// Echo
		echo $marker;
	endfor;
?>
</nav>