Skip to content

Instantly share code, notes, and snippets.

Avatar
🌻
Working from home.

Baylee Schmeisser bayleedev

🌻
Working from home.
View GitHub Profile
@bayleedev
bayleedev / gist:3659846
Created Sep 6, 2012
Align text in PHP GD
View gist:3659846
<?php
function textSize($size, $angle, $font, $text) {
$f = imagettfbbox($size, $angle, $font, $text);
return array(
'height' => $f[1] - $f[5],
'width' => $f[4] - $f[0]
);
@bayleedev
bayleedev / Test Compact and Extract.php
Created Sep 17, 2012
Will compact and extract keep the object reference?
View Test Compact and Extract.php
<?php
$provider = new stdClass();
echo '<pre>';
echo 'First: ' . spl_object_hash($provider) . PHP_EOL;
function testProvider(stdClass $provider) {
$provider->name = 'Blaine';
@bayleedev
bayleedev / alpha.php
Created Sep 18, 2012
Get all alpha characters
View alpha.php
<?php
$alpha = array_map('chr', range(97, 122)); // a-z
$_alpha = array_map('chr', range(65, 90)); // A-Z
print_r($alpha);
print_r($_alpha);
@bayleedev
bayleedev / changeObjectFunction.php
Created Oct 16, 2012
Can change object but can't write over it
View changeObjectFunction.php
<?php
$response = new stdClass();
echo '1): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcd00000000e93b17ba
call_user_func_array(function($response) {
$response = new stdClass();
echo '2): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcf00000000e93b17ba
}, array($response));
@bayleedev
bayleedev / routes.php
Created Oct 16, 2012
Rewrite response in laravel
View routes.php
<?php
Route::filter('after', function($response)
{
$params = \Laravel\Request::$route->parameters;
// The 'type' is the last param
// example: /product/(:num).(:any)
$type = array_pop($params);
if($type == 'json') {
$res = Response::json($response->content->data);
View depInjection.php
<?php
interface iGame {
public function start();
public function end();
public function move();
}
class tictactoe implements iGame {
public function start() {
View FeatureContext.php
<?php
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
use Behat\Mink\Driver\GoutteDriver,
Behat\Mink\Driver\Selenium2Driver,
View question.php
<?php
use lithium\analysis\Logger;
// Setup firephp in one file
Logger::config(array(
'firebug' => array(
'adapter' => 'FirePhp',
),
));
// Setup file adapter in another place
Logger::config(array(
View assertCount.php
<?php
namespace app\tests\cases\controllers;
class AssertTest extends \lithium\test\Unit {
public function testSomething() {
$this->assert(true, 'this is true'); // true
$this->assertCount(10, array(1)); // false
}
View cc.sh
# Clear the cache
alias .hb.remote.cc="ssh mdxdev '.hb.cc'"
function .hb.cc() {
# Directory
.hb
# CSS
if [ $(ls app/webroot/css/compiled/ | wc -l) -gt 0 ]
then
echo Ridding CSS