Skip to content

Instantly share code, notes, and snippets.

@andyhawthorne
andyhawthorne / .htaccess
Created November 14, 2012 21:05
CodeIgniter
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
public function day_tasks($day)
{
$sql = "SELECT * FROM tasks_list WHERE due = '" . $day . "'";
$q = $this->db->query($sql);
if($q->num_rows() > 0)
{
foreach($q->result() as $row)
{
$data[] = $row;
}
@andyhawthorne
andyhawthorne / welcome.php
Last active October 12, 2015 09:47
show method
<?php
public function show()
{
$year = $this->uri->segment(3);
$month = $this->uri->segment(4);
$day = $this->uri->segment(5);
$date = $year . '-' . $month . '-' . $day;
$data['day'] = date('d/m/Y', strtotime($date));
$data['tasks'] = $this->tasks_model->day_tasks($date);
$this->load->view('show', $data);
<?php
class Tasks_Model extends CI_Model
{
public function __construct()
{
parent:: __construct();
}
public function get_tasks($month)
{
@andyhawthorne
andyhawthorne / welcome.php
Created November 2, 2012 23:47
index action - tasks
public function index()
{
$month = (!$this->uri->segment(4)) ? date('m') : $this->uri->segment(4);
$tasks = $this->tasks_model->get_tasks($month);
if($tasks == 0)
{
$data['cal'] = $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));
}
else
@andyhawthorne
andyhawthorne / welcome.php
Created November 2, 2012 23:28
Tasks constructor
class Welcome extends CI_Controller
{
public function __construct()
{
parent:: __construct();
$this->load->model('tasks_model');
$prefs = array (
'show_next_prev' => TRUE,
'next_prev_url' => 'http://tasks.dev/welcome/index'
@andyhawthorne
andyhawthorne / tasks.sql
Created November 2, 2012 22:17
schema for task_lists table
CREATE TABLE `tasks_list` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) DEFAULT NULL,
`body` text,
`due` date DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`completed` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB
@andyhawthorne
andyhawthorne / file1.rb
Created October 19, 2012 19:29
Sinatra ru file
require './main'
run Sinatra::Application
@andyhawthorne
andyhawthorne / file1.rb
Created October 19, 2012 19:28
Sinatra ru file
require './main'
run Sinatra::Application
@andyhawthorne
andyhawthorne / file1.rb
Created October 19, 2012 19:23
Sinatra Gemfile file
source :rubygems
gem 'sinatra'
gem 'rdiscount'
gem 'data_mapper'
gem 'dm-migrations'
gem 'pony'
gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development
group :production do
gem 'pg', '0.14.1'