Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
jehoshua02 / hasIntegerPower.php
Created October 2, 2012 22:18
Checks to see if an integer has an integer root given an integer power
<?php
function hasIntegerRoot($number, $power, &$root = null) {
$root = round(pow($number, 1.0 / $power));
return round(pow($root, $power)) == $number;
}
function testHasIntegerRoot()
{
// calculate squares
@jehoshua02
jehoshua02 / .bash_alias_composer
Created October 4, 2012 05:32
Bash aliases for Composer
alias composer='php composer.phar'
alias composerinit='curl -s http://getcomposer.org/installer | php; composer init; echo composer.phar >> .gitignore'
alias composerdump='composer dumpautoload --optimize'
@jehoshua02
jehoshua02 / phpMethodTemplate.md
Created October 8, 2012 17:01
PHP Method template for Eclipse IDE

I use this template for PHP methods in Eclipse:

${cursor}
${visibility} function ${functionName}(${dollar}${param})
{
    // @todo method body for ${class_container}::${functionName}()
    return ${value};
}
@jehoshua02
jehoshua02 / testCallingClassAndMethodHeldInArray.php
Created October 30, 2012 21:08
Calling method and class held in array
<?php
class FactoryClass
{
public static function build()
{
return new ProductClass();
}
}
@jehoshua02
jehoshua02 / possibleRoutesThroughGrid.php
Created November 3, 2012 00:53
This was one of the mensa puzzles in a box that I have.
<?php
function factorial($number)
{
$factorial = $number;
$i = $number - 1;
while ($i > 0) {
$factorial *= $i--;
}
return $factorial;
@jehoshua02
jehoshua02 / 51.php
Created November 29, 2012 16:58
Solution to mensa puzzle 51
<?php
$answer = 11;
while (!check($answer)) {
echo "{$answer} is not correct.";
$answer += 11;
echo " trying {$answer}...\n";
}
@jehoshua02
jehoshua02 / FactorFinder.php
Created December 7, 2012 22:02
Finding factor combinations ... tangent to a mensa puzzle
<?php
class FactorFinder
{
protected $pairSets = array();
public function findFactorCombinations($number, $factorCount)
{
if ($factorCount < 2) {
return false;
<?php
class CalendarEvent
{
/**
* Holds the event
*
* @var string
*/
protected $event;
@jehoshua02
jehoshua02 / _layout.scss
Last active December 10, 2015 12:08
After hours of beating my head against the wall, I finally got my cake and ate it too. I wanted a) sticky footer that doesn't overlap content when the window is too small, b) the content element to stretch from the header to the footer so that I could put a background color in if I wanted, and c) the header to stretch across the entire window, j…
$page-header-height: 50px;
$page-footer-height: 50px;
$gutter: 20px;
.page-wrap {
max-width: 1024px;
margin: 0 auto;
@include box-sizing(border-box);
padding: 0 $gutter;
}
<?php
class Sass
{
/**
* Options for sass command
*
* @var array
*/
protected $options = array();