Skip to content

Instantly share code, notes, and snippets.

View Andati's full-sized avatar

Rodgers Andati Andati

View GitHub Profile
/**
* A program that searches a given key in a given collection of values
* and returns the first index of the key in the collection or -1 if the key doesn't exist
*
* @author Rodgers Andati
* @version 1.0
* @since 2019-01-29
*/
public class SearchIndex {
public static void main(String args[]) {
import java.util.Map;
import java.util.function.Function;
import java.util.concurrent.ConcurrentHashMap;
/**
* A program that has a prime method and memoize
* method that memoize the prime method
*
* @author Rodgers Andati
* @version 1.0
@Andati
Andati / ona.py
Last active January 13, 2019 10:08
"""
A script that pulls data from a form in an Ona project and creates a bar chart.
Author: Rodgers Andati
Date: 12/01/2019
"""
import matplotlib.pyplot as plt;
import numpy as np
import matplotlib.pyplot as plt
import requests

M-Pesa B2C Callback

This is how your b2c endpoint will be called to notify the status of a disbursement request.

  • URL

    Provide a url (preferrably a secure one).

  • Method:

M-Pesa B2C

This is how to call b2c api to send money to customer's M-Pesa account.

  • URL

    API url endpoint will be provided to you via email

  • Method:

@Andati
Andati / c2b.md
Last active September 15, 2017 06:20

M-Pesa C2B

This is how your c2b endpoint will be called when a customer makes an M-Pesa payment to your paybill.

  • URL

    Provide a url (preferrably a secure one).

  • Method:

/*
* Given a string of brackets, devise an algorithm that checks whether they are balanced
*/
import java.util.Stack;
class Parenthesis {
public static void main(String[] args){
Stack<Character> s = new Stack<Character>();
String str = "(((())))))";
for(int i=0; i<str.length(); i++){
if(str.charAt(i)=='(') s.push('(');
/**
Author: Rodgers Andati
A program that returns the shortest substring in the haystack that contains all the contents of the needle.
**/
#include<iostream>
#include<string>
using namespace std;
#define INT_MAX 1000000
@Andati
Andati / Beads.py
Created November 6, 2012 08:00
Solution to beads problem
"""
Beads problem. Written by Andati Rodgers on 6th Nov, 2012
Used aspects of dynamic programming
"""
def length(s): #determine possible max length of b's followed by r's given a string
s2 =s
b=r=pr=mx=index=i=j=0
same = True
for k in range(0,len(s)-1):