Skip to content

Instantly share code, notes, and snippets.

View samsoir's full-sized avatar

Sam de Freyssinet samsoir

View GitHub Profile
<?php
list($hours, $mins) = explode(':', $_POST['time']);
if ($_POST['ampm'] == 'am' AND $hours == 12)
$hours = 0;
elseif ($_POST['ampm'] == 'pm' AND $hours != 12)
$hours += 12;
# most basic approach
find system -type f -exec sed -i -e "s/defined('SYSPATH') OR die('No direct access allowed.');//" '{}' \;
# case insensitive
find system -type f -exec sed -i -e "s/defined('SYSPATH') [oO][rR] die('No direct access allowed.');//" '{}' \;
# case insensitive with any die message
find system -type f -exec sed -i -e "s/defined('SYSPATH') [oO][rR] die('[^']\{0,\}');//" '{}' \;
<?php
$curl = Curl::factory(array('options' => array(CURLOPT_FAILONERROR => FALSE, CURLOPT_URL => 'http://sam.clark.name')));
var_dump($curl);
<?php defined('SYSPATH') or die('No direct script access.');
class chrono_Core {
/**
* Outputs a textual representation of
* how long ago something happened
*
* @param int time_stamp
* @return string
@samsoir
samsoir / vhost.conf
Created November 6, 2009 11:22 — forked from shadowhand/vhost.conf
nginx 1.0.0 config for Debian 6 (Squeeze)
# default server
server {
listen 80;
server_name dev.kohana.framework;
root /mnt/hgfs/Projects/kohana;
access_log /var/log/nginx/dev.kohana.framework.access.log;
error_log /var/log/nginx/dev.kohana.framework.error.log;
location / {
@samsoir
samsoir / gist:303566
Created February 13, 2010 17:13
Refactored the Kohana_View::set_filename() method to allow use of .phtml or other extensions besides .php
<?php
/**
* Sets the view filename.
*
* @throws View_Exception
* @param string filename
* @return View
*/
public function set_filename($file)
{
<?php
$statuses = ORM::factory('status')->find_all()->as_array();
$multi_array = array();
foreach ($statuses as $key => $value)
{
$multi_array[$key] = $value->as_array();
}
<?php
Route::set('default', '(<controller>)((/<id>)/<action>)')
->defaults(array(
'controller' => 'auth',
'action' => 'index',
));
<?php
Route::set('feed', 'feed<format>', array('format' => '\.\w+'))
->defaults(array(
'controller' => 'feed',
));
Route::set('article', 'article(s)/<article>(<format>)', array('format' => '\.\w+'))
->defaults(array(
<?php
/**
* View node that mirrors node, providing a MySQL view to the
* nodes and related tables.
*
* This has been implemented to allow node searching from the
* main context screen
*/
class node_view extends tsMetaNode {
protected $table = 'view_nodes';