Skip to content

Instantly share code, notes, and snippets.

@cam-gists
cam-gists / Generic CodeIgniter Model
Created July 13, 2012 21:37 — forked from timmahoney/Generic CodeIgniter Model
Codeigniter: PHP: Table Model
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Generic CodeIgniter Database Model - One table version
*
* Set your Database table and table fields at the top,
* and screw creating models for interfacing with one table.
*
* Disclaimer: I'll answer questions or whatever, but I'm creating
* this to speed my own development up. I hope it helps, but it's not supported.
@cam-gists
cam-gists / controller.php
Created July 13, 2012 21:21 — forked from tylerreed/controller.php
CodeIgniter: PHP: AJAX File Uploader
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class My_Controller extends CI_Controller {
public function upload_files()
{
if ($this->input->get('qqfile'))
{
$file = $this->input->get('qqfile');
}
@cam-gists
cam-gists / gist:3107496
Created July 13, 2012 21:13
Codeigniter: MY_Model
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CodeIgniter MY_Model class
*
* Basic data access functionality for CodeIgniter projects
*
* @package CodeIgniter
* @subpackage Core
* @category Core
@cam-gists
cam-gists / fetchtweets_codeignite_model.php
Created July 13, 2012 21:07 — forked from jpalala/fetchtweets_codeignite_model.php
PHP: Codeigniter: Model fetch tweets
<?php
/*
adapted from http://rosstanner.co.uk/2012/01/php-tutorial-twitter-statuses/
*/
class Mytweets extends CI_Model {
// define the account username
@cam-gists
cam-gists / password_hashing.php
Created July 13, 2012 21:04 — forked from taytus/password_hashing.php
PHP: Codeigniter: Password Hash
function new_registration($username, $email, $password, $confirmation_code)
{
// Store the new user's information in the database.
$key = $this->config->item('encryption_key');
$salt1 = hash('sha512', $key . $password);
$salt2 = hash('sha512', $password . $key);
$hashed_password = hash('sha512', $salt1 . $password . $salt2);
@cam-gists
cam-gists / CI_Date.php
Created July 13, 2012 21:02 — forked from kylefarris/CI_Date.php
PHP: Codeigniter: Date Library
<?php
class CI_Date {
public $sec_in_min, $min_in_hour, $hr_in_day, $day_in_wk, $sec_in_wk, $sec_in_day, $min_in_wk, $min_in_day, $hr_in_wk;
public function __construct() {
$this->sec_in_min = 60;
$this->min_in_hr = 60;
$this->hr_in_day = 24;
$this->day_in_wk = 7;
$this->day_in_yr = 365;
$this->sec_in_hr = $this->sec_in_min * $this->min_in_hr;
@cam-gists
cam-gists / nodejs
Created May 27, 2012 00:04 — forked from alessioalex/nodejs
Node.JS: app under nginx
# node.js app under nginx
upstream node {
server 127.0.0.1:8001;
}
server {
listen 80;
server_name node;
@cam-gists
cam-gists / api.js
Created May 27, 2012 00:04 — forked from fwielstra/api.js
Node.JS: / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@cam-gists
cam-gists / nodejs
Created May 27, 2012 00:03
NodeJS: init.d script for CentOS
#!/bin/sh
#
# chkconfig: 35 99 99
# description: Node.js /home/nodejs/sample/app.js
#
. /etc/rc.d/init.d/functions
USER="nodejs"
@cam-gists
cam-gists / static_server.js
Created May 27, 2012 00:03 — forked from ryanflorence/static_server.js
Node.JS: static file web server
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);