Skip to content

Instantly share code, notes, and snippets.

View otengkwame's full-sized avatar
💭
Cooking some open source projects

Kwame Oteng Appiah-Nti otengkwame

💭
Cooking some open source projects
View GitHub Profile
@IsaacVanName
IsaacVanName / PHP Method Chaining from Constructor
Created December 23, 2010 17:39
PHP Method Chaining from Constructor
/*
new MyClass->my_method() isn't possible. However, there are a couple of solutions, of which the best seems to be the most unlikely as well.
****
Note: Make sure you read/skim to the end, even if you figure out the first solution quickly
(which you should). The second solution has a bit of brief research to go along with it! :-)
****
At times, it can be useful to have a class that maintains state long enough to complete a
cycle, but doesn't get stored in memory. No extra baggage needed, right?
@og-shawn-crigger
og-shawn-crigger / MY_Config.php
Created January 16, 2012 16:34
MY_Config to extend HMVC CodeIgniter's Config class to use the database to fetch settings
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once APPPATH.'third_party/MX/Config.php';
/*
Class: MY_Config
This is how I used to store my config items in the database, hopefully it will be found useful.
Extends:
MX_Config
@MikeRogers0
MikeRogers0 / validate-email.php
Created June 16, 2012 17:09
How to validate an email address with PHP
<?php
function validEmail($email){
// Check the formatting is correct
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
return FALSE;
}
// Next check the domain is real.
$domain = explode("@", $email, 2);
return checkdnsrr($domain[1]); // returns TRUE/FALSE;
@andredublin
andredublin / dependency_inject.php
Created August 22, 2012 18:13
dependency injection in php/codeigniter
<?php
class BASE_Model extends CI_Model
{
/**
* inject_class - load class using dependency injection
*
* @access public
* @param string $path
* @param string $class
* @param string $func
@bencevans
bencevans / gist:3513313
Created August 29, 2012 14:23 — forked from mebcomputers/gist:2550712
php: create visitor log file
<?php
class log {
public $filename;
public $timestamp;
public $ip;
public $u_agent;
public $u_refer;
public $ub;
@taylormoss15
taylormoss15 / gist:3940270
Created October 23, 2012 17:39 — forked from boucher/gist:1750368
Stripe sample checkout form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Sample Form</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<script type="text/javascript">
@BernardoSilva
BernardoSilva / .htaccess
Created February 5, 2013 20:03
.htaccess for Codeigniter to avoid index.php and force www. before any URL
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
# BEGIN force www before URL
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# END for www on URL
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
define( function() {
function isValidElement(element) {
var nodeName = element[0].nodeName.toUpperCase(), invalidInputTypes = [ "BUTTON", "SUBMIT", "CLEAR" ]
var result = ((nodeName != "BUTTON") && !(nodeName == "INPUT" && (invalidInputTypes.contains( element.attr(
"type" ).toUpperCase() ))))
return result
}
/* select element styling */
jQuery('.rtp-select').each( function() {
var self = jQuery(this),
title = self.attr('title');
if( jQuery('option:selected', this).val() !== '' ) title = jQuery('option:selected', this).text();
self
.css({
'z-index': 10,
'opacity': 0,