Skip to content

Instantly share code, notes, and snippets.

View raphaeltraviss's full-sized avatar

Raphael Traviss raphaeltraviss

View GitHub Profile
@raphaeltraviss
raphaeltraviss / Hexagon Ripple.swift
Created November 20, 2017 16:38 — forked from d-ronnqvist/Hexagon Ripple.swift
Hexagon Ripple in a Swift Playground (Swift 4)
import AppKit
import QuartzCore
import PlaygroundSupport
// Parameters that define the style
let hexSideLength: CGFloat = 15.0
let hexLineWidth: CGFloat = 3.0
let colors = [NSColor.red, NSColor.cyan, NSColor.green, NSColor.yellow, NSColor.red].map { $0.cgColor }
@raphaeltraviss
raphaeltraviss / DateIntervalEnhanced.php
Created April 16, 2015 15:51
PHP Date interval class that can recalculate values for date components.
<?php
class DateIntervalEnhanced extends DateInterval {
/* Keep in mind that a year is seen in this class as 365 days, and a month is seen as 30 days.
It is not possible to calculate how many days are in a given year or month without a point of
reference in time.*/
public function to_seconds() {
return ($this->y * 365 * 24 * 60 * 60) +
($this->m * 30 * 24 * 60 * 60) +
($this->d * 24 * 60 * 60) +