Skip to content

Instantly share code, notes, and snippets.

@cam-gists
cam-gists / Codeigniter: Default Controller
Created May 26, 2012 23:43 — forked from rittme/Codeigniter: Default Controller
Codeigniter: Default codeigniter controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*/
public function index()
{
@cam-gists
cam-gists / gist:2795639
Created May 26, 2012 23:43 — forked from etienne-snippet/gist:1993145
CodeIgniter: Model
<?php
class User_model extends CI_Model {
function __construct()
{
parent::__construct();
}
}
@cam-gists
cam-gists / gist:2795644
Created May 26, 2012 23:45
CodeIgniter: Simple CodeIgniter Templating
//In the controller:
public function index() {
$this->data['content'] = 'your-views-name';
$this->load->view('your-templates-name', $this->data);
}
//In the view:
$this->load->view($content);
<?php
/**
* A simple Facebook PHP example.
*
* - This is not a "Facebook SDK".
* - This example uses Curl, Hash, JSON, Session extensions.
* - This does not use the JavaScript SDK, nor the cookie set by it.
* - This works with Canvas, Page Tabs with IFrames, the Registration Plugin
* and with any other flow which uses the signed_request.
@cam-gists
cam-gists / jquery.ba-tinypubsub.js
Created May 26, 2012 23:54 — forked from cowboy/HEY-YOU.md
jQuery: Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@cam-gists
cam-gists / ajaxify-html5.js
Created May 26, 2012 23:55 — forked from balupton/README.md
AJAX: Ajaxify a Website with the HTML5 History API using History.js, jQuery and ScrollTo
// https://gist.github.com/854622
(function(window,undefined){
// Prepare our Variables
var
History = window.History,
$ = window.jQuery,
document = window.document;
// Check to see if History.js is enabled for our Browser
@cam-gists
cam-gists / 403forbidden.php
Created May 26, 2012 23:56
PHP: Login Script
<?php
header('HTTP/1.1 403 Forbidden');
?>
<html>
<head>
<title>Congratulations! You have been DENIED access</title>
</head>
<body>
<font size="4">You have been denied access because of the following reasons:<br /><br />
1.) Too many failed login attempts, so you are likely brute forcing through logins.<br />
@cam-gists
cam-gists / login.php
Created May 26, 2012 23:59
PHP & MongoDB: Login System
<?php
if(isset($_SESSION['authentication'])){?>
<script type="text/javascript">
<!--
window.location = "main.php"
//-->
</script>
You're already logged in, redirecting you.
<?php }else{
@cam-gists
cam-gists / php-mongo.sh
Created May 26, 2012 23:59 — forked from ecentinela/php-mongo.sh
MongoDB: PHP extension
curl -OL https://github.com/downloads/mongodb/mongo-php-driver/osx-php5.3-1.0.11.zip
@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);