Skip to content

Instantly share code, notes, and snippets.

View chrismeller's full-sized avatar

Chris Meller chrismeller

View GitHub Profile
@chrismeller
chrismeller / five.php
Created September 19, 2011 15:08
Validating File Uploads in Kohana 3.2
echo Form::open( null, array( 'enctype' => 'multipart/form-data' ) );
<html>
<head>
<title>Video Test</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready( function () {
// hook the click event for any A links with a rel that starts with 'youtube'
@chrismeller
chrismeller / gist:1246516
Created September 27, 2011 23:08
Habari IIS Rewrite Rules
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Match Valid Files" stopProcessing="true">
<match url="^.*$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" ignoreCase="false" />
@chrismeller
chrismeller / gist:1293165
Created October 17, 2011 17:22
Fuel Cache Example
<?php
private function add_external_assets ( ) {
$url = 'http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css';
try {
$content = Cache::get( md5( $url ) );
}
catch ( CacheNotFoundException $e ) {
@chrismeller
chrismeller / gist:1318490
Created October 27, 2011 00:56
Habari Change Homepage Content Type
<?php
class Foo extends Theme {
public function act_display_home ( $user_filters = array() ) {
$user_filters['content_type'] = Post::type( 'foo' );
parent::act_display_home( $user_filters );
<?php
foreach ( $posts as $post ) {
// save the post for the area to use
$theme->post = $post;
echo $theme->area( 'foo' );
}
<?php
class Model_Browser extends Model {
public function list_schemas ( $like = null ) {
$query = \DB::select( array( 'table_schem', 'schema' ) )->from( 'sysibm.sqltables' );
if ( $like != null ) {
$query->where( 'table_schem', 'like', $like );
@chrismeller
chrismeller / gist:1339633
Created November 4, 2011 15:44
Github Packager
<?php
class Github_Packager {
private static $api_endpoint = 'http://github.com/api/v2/json/';
private static $temp_path = './temp/';
public static function list_branches ( $addon_name, $with_commits = false ) {
$url = self::$api_endpoint . 'repos/show/habari-extras/' . $addon_name . '/branches';
@chrismeller
chrismeller / theme.php
Created November 19, 2011 22:59
Habari Theme Updates for Page Caching
<?php
/**
* @package Habari
*
*/
/**
* Habari Theme Class
*
* The Theme class is the behind-the-scenes representation of
@chrismeller
chrismeller / vhost.com
Created January 10, 2012 20:52
Standard Nginx Vhost
server {
include listen_80;
server_name vhost.com;
include /etc/nginx/fastcgi_params;
access_log /home/chris/public_html/vhost.com/logs/access.log;
error_log /home/chris/public_html/vhost.com/logs/error.log;
root /home/chris/public_html/vhost.com/public;