Skip to content

Instantly share code, notes, and snippets.

@tristar500
tristar500 / laravel base controller authentication
Created February 14, 2013 23:04
Laravel 4 base controller authentication
class BaseController extends Controller {
public function __construct()
{
// controllers in the array have to be authenticated before they can be viewed
if(in_array( Request::segment(1), array('job','journal','user')) )
{
echo 'This page needs to be authenticated';
echo '<p>';
@tristar500
tristar500 / Return Progress Data
Created January 13, 2013 15:36
MySql to select progress data and return steps, completed, not_completed and progress
/**
* Return the goal step progress values
* @param int $id the goal id
* @return object contains goal step completion data
*/
public static function progress($id)
{
$query = "SELECT
COUNT(completed) as total,
COUNT(if(completed=1, 1, null)) as completed,
@tristar500
tristar500 / routes.php
Created December 28, 2012 04:42 — forked from Meroje/routes.php
/*
|--------------------------------------------------------------------------
| Register
|--------------------------------------------------------------------------
*/
Route::get('register', function()
{
return View::make('register');
});
@tristar500
tristar500 / dir_list.php
Created December 1, 2012 18:17
Directory Listing Script
<?php
/*
Directory Listing Script - Version 3
====================================
Script Author: Ash Young <[email protected]> / www.evoluted.net
REQUIREMENTS
============
This script requires PHP and GD2 if you wish to use the
thumbnail functionality.
@tristar500
tristar500 / TZ Select .HTML
Created October 21, 2012 03:42
Time Zone HTML form select
<h3>Your Timezone</h3>
<div class="field">
<select name="timezone-timezone_name" id="id_timezone-timezone_name">
<option value="US/Pacific">US/Pacific</option>
<option value="US/Eastern">US/Eastern</option>
<option value="Europe/London">Europe/London</option>
<option value="Europe/Paris">Europe/Paris</option>
<option value="Europe/Amsterdam">Europe/Amsterdam</option>
<option value="Europe/Berlin">Europe/Berlin</option>
<option value="Australia/Sydney">Australia/Sydney</option>
@tristar500
tristar500 / PHP Tag Cloud
Created October 16, 2012 18:22
PHP Tag Cloud
http://rhodopsin.blogspot.com/2008/05/php-tag-cloud.html
PHP Tag Cloud
I was trying to develop a tag cloud for one of my sites, and had some difficulty finding the best way to calculate what the size of each tag should be. Since I couldn't find a good solution online, I wrote my own.
A little bit of Googling landed me at Prism-Perfect. Here we find a very basic PHP script that really doesn't cut the mustard. The problem is that she takes a strictly linear approach -- the tag proportion (percentage) is used directly to determine the font size of the tag cloud. The reason why this is a poor choice to create a tag cloud is that tag frequency tends to not to be evenly distributed. Instead a few tags will usually have a very high frequency of use, and then it drops off rapidly. A tag cloud created using a tag frequency directly to determine font size will have a few tags that are very large, many tags that are very small, and almost nothing in between.
In the comments section of the Prism-Perfect post, I found
@tristar500
tristar500 / gist:3157196
Created July 21, 2012 21:08
Return a URL paramter
// url = "http://www.testing.com/page.php?text=testing&page=34";
// result = getParameterByName("text", url);
// result is "testing"
function getParameterByName(name, url){
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(url);
if(results == null)
@tristar500
tristar500 / index.html
Created July 18, 2012 01:53
A web page created at CodePen.io
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CodePen &middot; Pen</title>
<!--
Copyright (c) 2012 Mahroof Ali, http://codepen.io/anon
Permission is hereby granted, free of charge, to any person obtaining
@tristar500
tristar500 / index.html
Created July 18, 2012 01:39
A web page created at CodePen.io
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CodePen &middot; Pen</title>
<!--
Copyright (c) 2012 Mahroof Ali, http://codepen.io/anon
Permission is hereby granted, free of charge, to any person obtaining
@tristar500
tristar500 / index.html
Created July 18, 2012 01:39
A web page created at CodePen.io
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CodePen &middot; Pen</title>
<!--
Copyright (c) 2012 Mahroof Ali, http://codepen.io/anon
Permission is hereby granted, free of charge, to any person obtaining