Skip to content

Instantly share code, notes, and snippets.

View world.sql
CREATE TABLE City (
ID BIGSERIAL,
Name varchar(35) NOT NULL DEFAULT '',
CountryCode varchar(3) NOT NULL DEFAULT '',
District varchar(20) NOT NULL DEFAULT '',
Population int NOT NULL DEFAULT '0'
)
;
@ibrahimlawal
ibrahimlawal / verify-and-handle-paystack-event.php
Last active Oct 24, 2016
Paystack Webhook Code Skeleton, PHP
View verify-and-handle-paystack-event.php
<?php
if ((strtoupper($_SERVER['REQUEST_METHOD']) != 'POST' ) || !array_key_exists('HTTP_X_PAYSTACK_SIGNATURE', $_SERVER) ) {
// only a post with paystack signature header gets our attention
exit();
}
// Retrieve the request's body
$input = @file_get_contents("php://input");
define('PAYSTACK_SECRET_KEY','sk_xxxx_xxxxxx');
@sandfox
sandfox / README.md
Last active Sep 19, 2018
Simple example upstart config for nodejs
View README.md

This example assumes your running a recent Ubuntu with upstart installed and you have install n from npm.

To see an example use of this ina a wider context, look at this gist for deploying node.js + nginx

Adapt as required.

  1. Put the node.conf in /etc/init/
  2. Create a folder for individual site configs to live in /etc/node
  3. Put the node-test.conf inside /etc/node
  4. Create the folder for the logs /var/logs/node
@Kendysond
Kendysond / clean.php
Last active Oct 31, 2018
Clean any Nigerian Number format to be ready for sending SMS
View clean.php
function clean_number($phone_number){
$phone_number = preg_replace('/^0/','234',$phone_number);
$phone_number = preg_replace('/^\+/','',$phone_number);
return $phone_number;
}
// This should convert a number like 09023293092 or +2349023293092 to 2349023293092
@ibrahimlawal
ibrahimlawal / PaystackFee.js
Last active Mar 23, 2019
Add Paystack fees in Javascript
View PaystackFee.js
function PaystackFee() {
this.DEFAULT_PERCENTAGE = 0.015;
this.DEFAULT_ADDITIONAL_CHARGE = 10000;
this.DEFAULT_THRESHOLD = 250000;
this.DEFAULT_CAP = 200000;
this.percentage = this.DEFAULT_PERCENTAGE;
this.additional_charge = this.DEFAULT_ADDITIONAL_CHARGE;
this.threshold = this.DEFAULT_THRESHOLD;
this.cap = this.DEFAULT_CAP;
@ibrahimlawal
ibrahimlawal / README.md
Last active Nov 22, 2019
My PHP libraries Git hooks
View README.md

PRE-REQUISITES

  • php in your path
  • git
  • your php projects should have phpunit installed

INSTALL

  • download all files, rename them removing the .sh extension.
  • chmod +x each of them
  • copy git-mrm and git-ddev to a folder in your executable path e.g. /usr/local/bin
@ibrahimlawal
ibrahimlawal / PaystackFees.php
Last active Apr 6, 2020
A php class to add paystack's local charge to a transaction total. Totally flops if the user pays with a foreign card.
View PaystackFees.php
<?php
class PaystackFees
{
const DEFAULT_PERCENTAGE = 0.015;
const DEFAULT_ADDITIONAL_CHARGE = 10000;
const DEFAULT_THRESHOLD = 250000;
const DEFAULT_CAP = 200000;
public static $default_percentage = PaystackFees::DEFAULT_PERCENTAGE;
@ibrahimlawal
ibrahimlawal / paystack-transaction-initialize.php
Last active Dec 17, 2020
Initializing a Paystack Transaction for 20 naira // And verifying it. // Uses Paystack Class : https://github.com/yabacon/paystack-class
View paystack-transaction-initialize.php
<?php
// Get this from https://github.com/yabacon/paystack-class
require 'Paystack.php';
$paystack = new Paystack('sk_test_xxx');
// the code below throws an exception if there was a problem completing the request,
// else returns an object created from the json response
$trx = $paystack->transaction->initialize(
@hirobert
hirobert / response-content-disposition-cloudfront.txt
Last active Mar 2, 2021
response-content-disposition and cloudfront
View response-content-disposition-cloudfront.txt
1) Log in to aws console.
2) Click cloudfront
3) Click behaviors
4) Select pattern and edit
@davidrushton
davidrushton / Kernel.php
Created Feb 17, 2016
Laravel 5 Database Queue - Shared Hosting
View Kernel.php
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**