mkvirtualenv createdenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$phone = "0748123456"; // safaricom | |
//$phone = "+254789123456"; // airtel | |
$safaricom = "/(+?254|0|^){1}[-. ]?[7]{1}([0-2]{1}[0-9]{1}|[5|9]{1}[0-9]{1}|[4]{1}[0-4]{1}|[4]{1}[6|8]{1})[0-9]{6}z/"; | |
$equitel = "/(\+?254|0|^){1}[-. ]?[7]{1}([6]{1}[3-5]{1})[0-9]{6}\z/"; | |
$airtel = "/(\+?254|0|^){1}[-. ]?[7]{1}([3]{1}[0-9]{1}|[5]{1}[0-6]{1}|[8]{1}[0-2|5-9]{1})[0-9]{6}\z/"; | |
$telcom = "/(\+?254|0|^){1}[-. ]?[7]{1}([7]{1}[0-9]{1})[0-9]{6}\z/"; | |
if(preg_match($safaricom, $phone)){ | |
echo 'SAFARICOM'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pip install virtualenv virtualenvwrapper-win | |
mkdir \Projects\helloworld && cd \Projects\helloworld | |
mkvirtualenv helloworld | |
setprojectdir . | |
deactivate | |
workon helloworld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sms = "Dear {{name}}, {{amount}} has been deposited to your bank account. Your current balance is {{balance}}. Thank you for banking with us."; | |
$required = ['{{name}}','{{amount}}','{{balance}}']; | |
$values = [ | |
$required[0] => 'John Doe', | |
$required[1] => 'KES 5,000', | |
$required[2] => 'KES 75,000' | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$http = new GuzzleHttp\Client; | |
$response = $http->post(url('oauth/token'), [ | |
'form_params' => [ | |
'grant_type' => 'password', | |
'client_id' => 2, | |
'client_secret' => 'SECRET_HERE', | |
'username' => 'user@example.com', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Make virtual ENV | |
mkvirtualenv test | |
## Make virtual ENV in current DIR | |
mkvirtualenv -a $(pwd) test | |
## Make virtual ENV with Python version | |
mkvirtualenv -a $(pwd) python=python3 test | |
## Set project dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A decorator is just a function that gets called before another function | |
import functools # function tools | |
def my_decorator(f): | |
@functools.wraps(f) | |
def function_that_runs_f(): | |
print("Hello!") | |
f() | |
print("After!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$msg = 'Dear {{BNAME}}, your loan of KES {{AMOUNT}} has been fully repaid.'; | |
function wrap($str) | |
{ | |
return "{{{$str}}}"; | |
} | |
function parse($msg,array $placeholders) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Gotten from https://en.wikipedia.org/wiki/Telephone_numbers_in_Kenya#Mobile_phone_numbers | |
$providers = [ | |
'100' => 'Airtel', | |
'101' => 'Airtel', | |
'102' => 'Airtel', | |
'110' => 'Safaricom', | |
'111' => 'Safaricom', | |
'701' => 'Safaricom', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading.Tasks; | |
namespace TempConvert.Interfaces | |
{ | |
[System.ServiceModel.ServiceContractAttribute( | |
Namespace="https://www.w3schools.com/xml/", | |
ConfigurationName="TempConvert.Interfaces.ITempConvert")] | |
public interface ITempConvert | |
{ |