Skip to content

Instantly share code, notes, and snippets.

William Mandai wmandai

Block or report user

Report or block wmandai

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View enable AllowOverride for your DocumentRoot
Filename: /etc/apache2/sites-available/yoursite.conf
<VirtualHost *:80>
ServerAdmin youremail@yahoo.com
ServerName yoursite.com
ServerAlias www.yoursite.com
DocumentRoot "/var/www/yoursite.com/public"
<Directory /var/www/yoursite.com/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
@wmandai
wmandai / mpesa-paybill-inteception.php
Created Oct 3, 2016
Working with MPESA PAYBILL API (using Laravel)
View mpesa-paybill-inteception.php
<?php
// 1. First tell MPESA to enable the PAYBILL API
// 2. Give them the URL you want their servers to ping on a successful payment made
// 3. They will ping ur server’s with a URL like this if you gave them “domainname.com"
// https://domainname.com/mpesa? id=59538715& orig=MPESA& dest=254706513985& tstamp=2014-11-11+16%3A55%3A09& text=FY69MY145+Confirmed.+on+11%2F11%2F14+at+4%3A54+PM+Ksh4%2C516.00+received+from+MARGARET+WANJIRU+254714236724.+Account+Number+16042+New+Utility+balance+is+Ksh3 &customer_id=274& user=safaricom& pass=3EdoRm0XHiUPa7x4& routemethod_id=2& routemethod_name=HTTP& mpesa_code=FY69MY145& mpesa_acc=16042& mpesa_msisdn=254714236724& mpesa_trx_date=11%2F11%2F14& mpesa_trx_time=4%3A54+PM& mpesa_amt=4516.0& mpesa_sender=MARGARET+WANJIRU& business_number=8238238
// 4. Now just break apart the POST parameters, in laravel I’d do
View rewrite
server {
listen X.X.X.X:443 ssl http2;
ssl_protocols TLSv1.2;
ssl_certificate cert.pem;
ssl_certificate_key privkey.pem;
server_name domain.com;
root /var/www/domain.com;
autoindex on;
index index.php;
location / {
@wmandai
wmandai / Codeigniter IIS web.config
Last active Jun 12, 2019
IIS web.config for codeigniter
View Codeigniter IIS web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
@wmandai
wmandai / codeigniter-csrf
Created Jan 4, 2014
Codeigniter disable CSRF in specific pages
View codeigniter-csrf
<?php
// Add this to your config.php file
if (stripos($_SERVER["REQUEST_URI"],'/controller/method') === FALSE) {
$config['csrf_protection'] = TRUE;
}else{
$config['csrf_protection'] = FALSE;
}
//the rest of the code
View codeigniter-affiliates-program
<?php
//check for referal links
function referal()
{
$CI =& get_instance();
$cookie_value_set = $CI->input->cookie('_tm_ref', TRUE) ? $CI->input->cookie('_tm_ref', TRUE) : '';
if ($CI->input->get('ref', TRUE) AND $cookie_value_set == '') {
// referred user so set cookie to ref=username
$cookie = array(
'name' => 'ref',
You can’t perform that action at this time.