This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function isWorkingDay(DateTime $dt) | |
{ | |
// Weekends | |
if($dt->format('N') > 5) return false; | |
// New Year's Day | |
if($dt->format('d-m') == '01-01') return false; | |
// Early May Bank Holiday | |
if($dt->format('d-m') == '07-05') return false; | |
// Spring Bank Holiday | |
if($dt->format('d-m') == '28-05') return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LZWEncode = function(s) { | |
var dict = {}; | |
var data = (s + "").split(""); | |
var out = []; | |
var currChar; | |
var phrase = data[0]; | |
var code = 256; | |
for (var i=1; i<data.length; i++) { | |
currChar=data[i]; | |
if (dict[phrase + currChar] != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var excelLetters = function(num) { | |
var mod = num % 26; | |
var pow = num / 26 | 0; | |
var out = mod ? String.fromCharCode(64 + mod) : (pow--, 'Z'); | |
return pow ? excelLetters(pow) + out : out; | |
}; | |
console.log(excelLetters(1)); // A | |
console.log(excelLetters(30)); // AD | |
console.log(excelLetters(189)); // GG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var irregularPolygon = [ | |
{x: 2.66, y: 4.71}, | |
{x: 0.72, y:2.28}, | |
{x: 1.9, y: 1}, | |
{x: 4, y: 1.6}, | |
{x:3.63, y:2.52}, | |
{x:5, y:3.5} | |
]; | |
var rotatePolygon = function(polygon, angle, originX, originY) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html | |
var irregularPolygon = [ | |
{x: 2.66, y: 4.71}, | |
{x: 0.72, y:2.28}, | |
{x: 1.9, y: 1}, | |
{x: 4, y: 1.6}, | |
{x:3.63, y:2.52}, | |
{x:5, y:3.5} | |
]; |