Skip to content

Instantly share code, notes, and snippets.

View kemo's full-sized avatar
💭
killing it

kemo

💭
killing it
  • Sarajevo, Bosnia and Herzegovina
  • X @delalick
View GitHub Profile
@kemo
kemo / style.less
Created December 6, 2011 16:06
Pay LESS
// Border Radius
.border-radius(@radius: 5px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
// Drop shadows
.box-shadow(@shadow: 0 1px 3px rgba(0,0,0,.25)) {
-webkit-box-shadow: @shadow;
@kemo
kemo / route.php
Created November 28, 2011 22:43
Kohana 3 Route cache append
<?php defined('SYSPATH') or die('No direct script access.');
class Route extends Kohana_Route {
/**
* Changed:
* - use Cache module instead of Kohana::cache()
* - append cached routes instead of assigning them directly
*/
public static function cache($save = FALSE)
@kemo
kemo / gd.php
Created August 7, 2011 10:26
Kohana_Image_GD with grayscale conversion
<?php defined('SYSPATH') or die('No direct script access.');
class Image_GD extends Kohana_Image_GD {
public function grayscale()
{
// Creating the Canvas
$bwimage = $this->_create($this->width, $this->height);
$this->_load_image();
@kemo
kemo / gist:1122991
Created August 3, 2011 15:56
Kohana 3 Route Caching
<?php // bootstrap ...
// Include app routes
if ( ! Route::cache())
{
require APPPATH.'routes.php';
Route::cache(Kohana::$environment === Kohana::PRODUCTION);
}
@kemo
kemo / request.php
Created June 17, 2011 13:15
Request::process_uri()
<?php
/**
* Process URI
*
* @param string $uri URI
* @param array $routes Route
* @return array
*/
public static function process_uri($uri, $routes = NULL)
{
@kemo
kemo / where.php
Created June 17, 2011 09:03
and_where_open() / or_where_open() auto removal example
<?php defined('SYSPATH') or die('No direct script access.');
abstract class Database_Query_Builder_Where extends Kohana_Database_Query_Builder_Where {
/**
* Closes an open "AND WHERE (...)" grouping.
*
* @return $this
*/
public function and_where_close()
@kemo
kemo / security.php
Created June 14, 2011 11:46
Security antispam check
<?php defined('SYSPATH') or die('No direct script access.');
/**
* @author kemo <github.com/kemo>
*/
class Security extends Kohana_Security {
/**
* Logs the timed purpose to session
* @param string purpose
* @return void
@kemo
kemo / gist:1020533
Created June 11, 2011 13:01
JSend View Model
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Strict JSend response formatting
*
* @author kemo <github.com/kemo>
* @see http://labs.omniti.com/labs/jsend
*/
class View_Ajax {
// Release version
@kemo
kemo / search.php
Created May 26, 2011 13:35
Kohana Search controller example
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Search extends Controller {
/**
* @var Database_Result
*/
protected $_results;
/**
<?php defined('SYSPATH') or die('No direct script access.');
class Text extends Kohana_Text {
public static function extract_emails($string)
{
$return = array();
if (Valid::email($string))
{