Skip to content

Instantly share code, notes, and snippets.

@scottsd
scottsd / world.sql
Created March 8, 2013 17:14
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'
)
;
@sandfox
sandfox / README.md
Last active September 19, 2018 03:39
Simple example upstart config for nodejs

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 October 31, 2018 23:58
Clean any Nigerian Number format to be ready for sending SMS
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 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;
@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 / 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 / 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 / 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');
@ARolek
ARolek / ImageMagick-Amazon-Linux.md
Last active February 10, 2023 00:07
Install ImageMagick from source on Amazon Linux

I needed a newer version of ImageMagick than is available on the yum packages on Amazon Linux. I tried using the remi repo but it failed with dependency errors. Here is what I did to install ImageMagick with support for PNG, JPG, and TIFF.

download the most recent package

wget http://www.imagemagick.org/download/ImageMagick.tar.gz

uncomress the package

@krambertech
krambertech / Component.jsx
Created July 2, 2016 10:44
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
super();