Skip to content

Instantly share code, notes, and snippets.

Avatar

Z Zeelot

  • Microsoft Research
  • Seattle
View GitHub Profile
@Zeelot
Zeelot / Router.php.diff
Created Oct 13, 2012
trying to fix #4113
View Router.php.diff
diff --git a/classes/Kohana/Route.php b/classes/Kohana/Route.php
index fdd2e1b..d8e33fe 100644
--- a/classes/Kohana/Route.php
+++ b/classes/Kohana/Route.php
@@ -531,8 +531,12 @@ class Kohana_Route {
return rtrim($params['host'], '/').'/'.$uri;
}
+ // Keep track of whether an optional param was replaced
+ $provided_optional = FALSE;
@Zeelot
Zeelot / url.php
Created Aug 29, 2012
Fix for security issue in Kohana 3.0.8 - 3.2.1
View url.php
<?php defined('SYSPATH') or die('No direct script access.');
// Just use this file in application/classes/url.php for a fix until 3.2.2 is out
class URL extends Kohana_URL {
/**
* Fetches an absolute site URL based on a URI segment.
*
* echo URL::site('foo/bar');
*
@Zeelot
Zeelot / classes-view-page-browse.php
Created Mar 27, 2012
Top navigation with selected status (change dashes for slashes as gists do not allow directories)
View classes-view-page-browse.php
<?php
Class View_Page_Browse extends View_Page {
// On this page, 'browse' tab is selected
protected $_selected_top_nav_item = 'browse';
}
@Zeelot
Zeelot / example.php
Created Aug 24, 2011
Possible minion options definition
View example.php
<?php
// 1 Property
class Minion_Task_Example extends Minion_Task {
protected $_options = array(
'force' => array(
'default' => NULL,
// Defaults to --{{key}} (--force in this case)
'names' => array('--force', '-f'),
@Zeelot
Zeelot / bla.php
Created Aug 21, 2011 — forked from kiall/bla.php
Valid::at_least()
View bla.php
<?php defined('SYSPATH') or die('No direct script access.');
class Model_Bla extends ORM {
public function rules()
{
return array(
'phone_one' => array(
array('at_least', array(':validation', 1, array('phone_one', 'phone_two', 'phone_three'))),
),
View controller.php
<?php defined('SYSPATH') or die('No direct script access.');
/**
*
*
* @package OAuth2
* @category Library
* @author Managed I.T.
* @copyright (c) 2011 Managed I.T.
*/
@Zeelot
Zeelot / miniond
Created Jul 27, 2011
miniond (for long running minion tasks)
View miniond
#!/bin/bash
#
# This script is similar to minion but will do a few additional things:
# - PHP process is run in the background
# - PHP process is monitored and restarted if it exits for any reason
# - Added handlers for SUGHUP, SIGINT, and SIGTERM
#
# This is meant for long running minion tasks (like background workers).
# Shutting down the minion tasks is done by sending a SIGINT or SIGTERM signal
# to this miniond process. You can also restart the minion task by sending a
@Zeelot
Zeelot / miniond
Created Jul 26, 2011
miniond (for long running minion tasks)
View miniond
#!/bin/bash
#
# This script is similar to minion but will do a few additional things:
# - PHP process is run in the background
# - PHP process is monitored and restarted if it exits for any reason
# - Added handlers for SUGHUP, SIGINT, and SIGTERM
#
# This is meant for long running minion tasks (like background workers).
# Shutting down the minion tasks is done by sending a SIGINT or SIGTERM signal
# to this miniond process. You can also restart the minion task by sending a
@Zeelot
Zeelot / view_model.php
Created Apr 6, 2011
Wrapper for ORM models to add view logic on top
View view_model.php
<?php defined('SYSPATH') or die('No direct script access.');
class View_Model
{
public static function factory(Model $model)
{
// Get the associated View_ name (ex: View_Model_User)
$class = 'View_'.get_class($model);
if (class_exists($class))
@Zeelot
Zeelot / Model_Test.php
Created Oct 31, 2010
saving related orm models with new ORM_Validation_Exception class
View Model_Test.php
<?php
public function save(Validate $validate = NULL)
{
DB::query(NULL, 'START TRANSACTION')->execute();
try
{
parent::save($validate);
}
catch (ORM_Validation_Exception $e)