Skip to content

Instantly share code, notes, and snippets.

View ibrahimlawal's full-sized avatar

Ibrahim Lawal ibrahimlawal

View GitHub Profile
@ibrahimlawal
ibrahimlawal / LC_CTYPE.txt
Created February 27, 2017 07:02 — forked from jampajeen/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@ibrahimlawal
ibrahimlawal / verify-and-handle-paystack-event.php
Last active June 22, 2022 22:17
Paystack Webhook Code Skeleton, 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');
@ibrahimlawal
ibrahimlawal / Git Scripts for speedy delivery.md
Last active April 12, 2021 15:20
Git Scripts for speedy delivery

Creating the executable files

Create new files with the names below in a folder that is on your PATH. The sample command below uses the default editor to open such in your default editor. Likely TextEdit.

$ open -e /usr/local/bin/git-mrm /usr/local/bin/git-ddev
@ibrahimlawal
ibrahimlawal / HibeeRSA.h
Last active December 18, 2020 20:24
An Objective-C class that provides RSA encryption using SecKeyEncrypt on Mac10.7 and iPhone2.0 Remember to change the sample key to the base64 encoded string of your public key.
//
// HibeeRSA.h
//
// Created by Ibrahim Lawal (ibrahim@lawal.me) on Feb/27/2016.
//
#import <Foundation/Foundation.h>
@interface HibeeRSA : NSObject
+ (nullable NSString *)encryptRSA:(nonnull NSString *)plainTextString;
@ibrahimlawal
ibrahimlawal / paystack-transaction-initialize.php
Last active December 17, 2020 13:54
Initializing a Paystack Transaction for 20 naira // And verifying it. // Uses Paystack Class : https://github.com/yabacon/paystack-class
<?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(
@ibrahimlawal
ibrahimlawal / PaystackFees.php
Last active April 6, 2020 00:57
A php class to add paystack's local charge to a transaction total. Totally flops if the user pays with a foreign card.
<?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 / README.md
Last active November 22, 2019 12:19
My PHP libraries Git hooks

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 / validateCardNumber.php
Last active September 10, 2019 11:44
Validate card numbers using Regex and a Luhn Check
<?php
class Operations {
const PATTERN_AMERICAN_EXPRESS = "/^3[47][0-9]{13}$/";
const PATTERN_DINERS_CLUB = "/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/";
const PATTERN_DISCOVER = "/^6(?:011|5[0-9]{2})[0-9]{12}$/";
const PATTERN_JCB = "/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/";
const PATTERN_MASTERCARD = "/^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/";
const PATTERN_VERVE = "/^((506(0|1))|(507(8|9))|(6500))[0-9]{12,15}$/";
@ibrahimlawal
ibrahimlawal / PaystackTransactionsFetcher-usage.js
Last active August 1, 2019 12:09
Get a list of transactions from Paystack
const paystackTransactionsFetcher = require('./PaystackTransactionsFetcher');
paystackTransactionsFetcher.fetch({
secretKey: 'sk_live_youwishiwereavalidkey___', // secret key
perPage: 100, // leave empty to fetch 50 per page
status: 'all', // leave empty to fetch only successful
startFrom: new Date('2011-01-01'), // Leave empty to fetch only a week ago
})
.then((i) => { console.log(JSON.stringify(i, null, 2)); })
.catch(console.error);
@ibrahimlawal
ibrahimlawal / PaystackFee.js
Last active March 23, 2019 07:21
Add Paystack fees in Javascript
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;