Skip to content

Instantly share code, notes, and snippets.

View fabeat's full-sized avatar
🎯
Focusing

Fabian Graßl fabeat

🎯
Focusing
  • cadooz GmbH
  • Nürnberg
View GitHub Profile
@fabeat
fabeat / scale.py
Created September 19, 2013 10:13 — forked from enagorny/scale.py
from PIL import Image
def scale(image, max_size, method=Image.ANTIALIAS):
"""
resize 'image' to 'max_size' keeping the aspect ratio
and place it in center of white 'max_size' image
"""
im_aspect = float(image.size[0])/float(image.size[1])
out_aspect = float(max_size[0])/float(max_size[1])
if im_aspect >= out_aspect:
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
<?php
class Page extends SiteTree {
//...
function canPublish($Member = null)
{
if (Director::is_cli())
{
return true;
}
else
<?php
global $lang;
$lang['de_DE']['Uploadify']['SUCCESSFULADDSINGLE'] = 'Datei "%s" hinzugefägt.';
$lang['de_DE']['Uploadify']['SUCCESSFULADDMULTI'] = 'Dateien hinzugefügt.';
$lang['de_DE']['Uploadify']['BUTTONTEXT'] = 'Durchsuchen';
$lang['de_DE']['Uploadify']['CHANGEFOLDERACTION'] = 'ändern';
$lang['de_DE']['Uploadify']['CHOOSEIMPORTFOLDER'] = 'Ordner wählen';
$lang['de_DE']['Uploadify']['PLEASESELECT'] = 'Ordner wählen';
$lang['de_DE']['Uploadify']['IMAGES'] = 'Bilder';
<?php
class Foo
{
protected $bar = 'TEST';
}
$foo = new Foo();
$bar = new ReflectionProperty($foo, 'bar');
$bar->setAccessible(true);
echo $bar->getValue($foo);
<?php
$arr = array('foo ', ' bar ');
$arr = array_map(function($el){ return trim($el); }, $arr);
var_dump($arr);
@fabeat
fabeat / gist:731908
Created December 7, 2010 15:34
Unit tests of protected methods in PHP
<?php
class Foo
{
protected function bar($test)
{
echo $test;
}
}
@fabeat
fabeat / README
Created May 4, 2010 11:02
MYSQL SLUG FIX (Unique fix)
MYSQL SLUG FIX
The table 'content' contains pages with a slug. This slug should be unique but it isn't.
unique_fix.sql fixes this problem and makes the slug-column unique.