Skip to content

Instantly share code, notes, and snippets.

View MarvinKweyu's full-sized avatar
👣
I am Marvin

Marvin Kweyu MarvinKweyu

👣
I am Marvin
View GitHub Profile
@89465127
89465127 / cli_progress.py
Last active January 9, 2019 10:43
Simple example of how to get a python progress bar in your program.
import time
from progress.bar import Bar # sudo pip install progress
bar = Bar('Processing', max=20, suffix='%(index)d/%(max)d - %(percent).1f%% - %(eta)ds')
for i in range(20):
time.sleep(.05) # Do some work
bar.next()
bar.finish()
import multiprocessing
import threading
import time
def thread_runner(val):
while True:
print("thread ", val)
num_cpus = multiprocessing.cpu_count()
@armw4
armw4 / 2019-software-review.md
Last active March 7, 2021 13:09
The Current State of Software - 2019

Easier is not Always Better in Engineering (Client Side and Server Side Alike) ⚠️

by Antwan Wimberly

26 August, 2019

A Note to Junior Developers

It is wishful thinking to assume that just because an application is "easier to write" that it is more maintanable and will result in a stable product being deployed to production. The overall architecture, maintainability, stability, and testability of a given library or framework should always be taken into account.

For example, you're building a new large scale web application. You could ⚠️ take a more native approach like document.getElementById and routine DOM manipulation. In my experience however, leveraging a more structured framework like Marionette is an objectively better choice for building large scale applications in contrast to traditional DOM API. The same can be said when comparing [`j

@paitonic
paitonic / expressjs-api-test-with-jasmine-and-request.md
Last active April 19, 2021 14:16
ExpressJS - API Tests with Jasmine and request

ExpressJS - API Tests with Jasmine and request

What am I trying to solve

I was trying to solve an issue with starting the ExpressJS server before each single test and closing it after each test completes, just to make sure each test is running under the same conditions.

Here is the error I ran into while trying to run the tests

$ ./node_modules/jasmine/bin/jasmine.js
Started
started
@fomightez
fomightez / a_note_on LATEX notebook.md
Last active December 22, 2021 09:09
Latex Example Use in a Jupyter Notebook

Looks way better rendered at nbviewer than here.

@muya
muya / msisdn_regex.txt
Created February 28, 2016 16:06
Regex for Safaricom Kenya, Airtel Kenya & Tigo Tanzania Phone Numbers
# KE
SAFARICOM: "/(\+?254|0|^){1}[-. ]?[7]{1}([0-2]{1}[0-9]{1}|[9]{1}[0-2]{1})[0-9]{6}\z/"
AIRTEL: "/(\+254|0|^){1}[-. ]?[7]{1}([3]{1}[0-9]{1}|[8]{1}[5-9])[0-9]{6}\z/"
# TZ
TIGO: "/(\+?255|0|^){1}[-. ]?([7]{1}[1]{1}[2-9]{1}|[6]{1}[57]{1}[2-9]{1})[0-9]{6}\z/"
/**
*
* It is a fact that there exist two numbers x and y such that x! + y! = 10!.
* Write a method named solve10 that returns the values x and y in an array.
* The notation n! is called n factorial and is equal to n * n-1 * n-2 * … 2 * 1, e.g., 5! = 5*4*3*2*1 = 120.
*
*/
package com.hawa.practice;
@luzfcb
luzfcb / uuid4_python_regex.md
Last active September 3, 2022 06:42
uuid4 python regex . django slug

A UUID-4 has five groups of lowcase hexadecimal characters, the first has 8 chars, the second 4 chars, the third 4 chars, the fourth 4 chars, the fifth 12 chars.

However to make it a valid UUID4 the third group (the one in the middle) must start with a 4:

00000000-0000-4000-0000-000000000000
              ^
@Nicksil
Nicksil / gist:5646003
Created May 24, 2013 19:40
Python - Knuth-Morris-Pratt (KMP) string-matching algorithm
# File: KnuthMorrisPratt.py
# Author: Keith Schwarz (htiek@cs.stanford.edu)
#
# An implementation of the Knuth-Morris-Pratt (KMP) string-matching algorithm.
# This algorithm takes as input a pattern string P and target string T, then
# finds the first occurrence of the string T in the pattern P, doing so in time
# O(|P| + |T|). The logic behind the algorithm is not particularly complex,
# though getting it to run in linear time requires a few non-obvious tricks.
#
# To motivate KMP, consider the naive algorithm for trying to match a pattern
import sys
import pymysql
import logging
class Database:
"""Database connection class."""
def __init__(self, config):
self.host = config.db_host