Skip to content

Instantly share code, notes, and snippets.

View paulwababu's full-sized avatar

paulwababu

View GitHub Profile
@paulwababu
paulwababu / models.py
Created March 7, 2022 16:45
Church Models
import os, random
from django.db import models
from django.utils.timezone import now
from django.db import models
from django.db.models import Model
from django.db.models import Sum
from django.forms.fields import DateField
from django.contrib.admin.widgets import AdminDateWidget
@paulwababu
paulwababu / index.html
Created March 30, 2022 07:47
javascript testing get element by id code correction
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script>
//function to validate password. For prototyping purposes
function validate() {
//read values from inout in sign in page
@paulwababu
paulwababu / threaded.py
Created March 30, 2022 09:37
Threaded vs Un-threaded functions for the SMS API
from time import sleep, perf_counter
import requests
def task1():
print("Started Unthreaded Requests")
send_sms = requests.get('{{api_url}}?number=254797584194&text=hello')
print(send_sms.status_code)
start_time = perf_counter()
@paulwababu
paulwababu / registration.html
Created March 30, 2022 13:03
On checking the married checkbox, the marriage annivasary date appears, and vice versa
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://res.cloudinary.com/prometheusapi/raw/upload/v1648495012/church_registration/fonts/icomoon/style_piie03.css">
import os
from selenium import webdriver
from time import sleep
from colorama import init, Fore, Style
init(autoreset=True)
def loop1(): # views
sleep(20)
class PayPalView(APIView):
#permission_classes = [HasAPIKey]
def PaypalToken(self, client_id, client_secret):
url = 'https://api.sandbox.paypal.com/v1/oauth2/token'
data = {
"client_id": client_id,
"client_secret": client_secret,
"grant_type": "client_credentials"
}
@paulwababu
paulwababu / C# - RestSharp.cs
Last active December 4, 2022 15:32
Authentication PESAPEDIA
var client = new RestClient("https://pesapedia.co.ke/api/v2/api-token-auth");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AlwaysMultipartFormData = true;
request.AddParameter("username", "xxx");
request.AddParameter("password", "xxx");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
@paulwababu
paulwababu / C# - RestSharp
Created December 2, 2022 10:35
Testing PESAPEDIA API
var client = new RestClient("https://pesapedia.co.ke/api/v2/hello");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e");
request.AlwaysMultipartFormData = true;
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
@paulwababu
paulwababu / C# - RestSharp.cs
Last active December 4, 2022 15:56
Create Order PESAPEDIA . Paypal on PESAPEDIA accepts only USD, TO CONVERT USE. https://pesapedia.co.ke/musk/exchangerate?to=USD&from=KES&amount=100
var client = new RestClient("https://pesapedia.co.ke/api/v2/paypal/order/create");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e");
request.AlwaysMultipartFormData = true;
request.AddParameter("client_id", "xxx");
request.AddParameter("client_secret", "xxx");
request.AddParameter("environment", "sandbox");
request.AddParameter("notify_url", "https://pesapedia.co.ke/api/v2/paypal/cancel/callback");
request.AddParameter("return_url", "https://pesapedia.co.ke/api/v2/paypal/return/callback");
@paulwababu
paulwababu / C# - RestSharp.cs
Last active December 4, 2022 16:41
Capture Order. Aimed to check whether a user has paid or not
var client = new RestClient("https://pesapedia.co.ke/api/v2/paypal/order/capture");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Token fcf3081d09f4c8e37a74f1f528bc37c3ca93091e");
request.AlwaysMultipartFormData = true;
request.AddParameter("environment", "sandbox");
request.AddParameter("client_id", "xxx");
request.AddParameter("client_secret", "xxx");
request.AddParameter("url", "https://api.sandbox.paypal.com/v2/checkout/orders/2S71025914161602N/capture");
IRestResponse response = client.Execute(request);