Skip to content

Instantly share code, notes, and snippets.

@glynrob
glynrob / Welcome Function
Created May 27, 2012 20:59
DynamoDB on Codeigniter
function index()
{
$data = array(
'members' => array()
);
if (!$this->Users->table_exists()){
$this->load->view('no_table', $data);
} else {
$members = $this->Users->getAll(5); // Find all members, limit by 5
if (count($members) != 0){
@glynrob
glynrob / gist:2815896
Created May 27, 2012 21:02
Construtor
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->helper('date');
$this->load->model('Users','',TRUE);
}
@glynrob
glynrob / Index function - DynamoDB
Created May 27, 2012 22:10
Index function - DynamoDB
function index()
{
$data = array(
'members' => array()
);
if (!$this->Users->table_exists()){
$this->load->view('no_table', $data);
} else {
$members = $this->Users->getAll(5); // Find all members, limit by 5
if (count($members) != 0){
@glynrob
glynrob / DynamoDB Model
Created May 27, 2012 22:12
DynamoDB Model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Users extends CI_Model {
protected $primaryKey = 'id';
protected $tableName = 'users';
function __construct() {
parent::__construct();
@glynrob
glynrob / DynamoDB view
Created May 27, 2012 22:21
DynamoDB view
<?php
if(count($members) > 0):
foreach($members as $member => $fields):?>
<h1><a href="<?php echo site_url(array('welcome','view', $fields['id'])); ?>"><?php echo $fields['name']; ?></a>
<a href="<?php echo site_url(array('welcome','edit', $fields['id'])); ?>" style="font-size:12px;">Edit</a> <a href="<?php echo site_url(array('welcome','delete', $fields['id'])); ?>" style="font-size:12px;">Delete</a></h1>
<p><?php echo ($fields['address']); ?><br />
<em>Phone: <?php echo $fields['phone']; ?><br />
Added on <?php echo unix_to_human( $fields['date'] ); ?></em></p>
class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->library('redis');
$this->load->model('Buttons','',TRUE);
}
class Buttons extends CI_Model {
function __construct() {
parent::__construct();
}
function checkDB(){
$result = $this->redis->command('PING');
if($result == 'PONG'){
return true;
@glynrob
glynrob / Example vhost
Created June 30, 2012 18:05
Example vhost for WAMP
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/example1.sdev/"
ServerName example1.sdev
<directory "c:/wamp/www/example1.sdev/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
@glynrob
glynrob / Example hosts file
Created June 30, 2012 18:20
setup example1.sdev in your hosts file
127.0.0.1 example1.sdev
@glynrob
glynrob / colourloop.py
Created July 28, 2012 20:16
Loop through all colours in an array
#!/usr/bin/python
import subprocess
import time
import usblamp
checkTime = 1
arr = ("white", "yellow", "red", "blue", "green")
for i in arr: