Skip to content

Instantly share code, notes, and snippets.

View bangadennis's full-sized avatar

Dennis Banga bangadennis

  • Kenya
View GitHub Profile
@bangadennis
bangadennis / System Design.md
Created September 2, 2020 18:06 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
echo "Install the app into DHIS app"
cd dist/myapp
curl -X POST -u user:password -F file=@myapp.zip https://mydhis2url/api/apps
echo "app installed into DHIS"
@bangadennis
bangadennis / readme.md
Created October 18, 2018 16:42 — forked from jgamblin/readme.md
Bot that posts SSH logins to slack.

SSH Slackbot

This is a simple slackbot to post successful SSH logins to a slack channel to help you keep track of server access.

Step 1

Create an incoming webhook for your slack community.

Step 2

Create /etc/ssh/sshslack.sh

Paste your code as one comment split.

  • Your full name and Reg Number
  • Backwardpropagation
  • KNN
  • SOM
@bangadennis
bangadennis / postgres-stats.sql
Created March 15, 2018 09:14
PostgreSQL Stats Queries
--PostgreSQL Query: [ Get all running queries ]--
SELECT pid, datname, usename, client_addr, now() - query_start as "runtime", query_start, waiting, state, query
FROM pg_stat_activity
ORDER BY runtime DESC;
--PostgreSQL Query: [ Get all running queries – More than X minutes/hours/days ]--
SELECT pid, datname, usename, client_addr, now() - query_start as "runtime", query_start, waiting, state, query
FROM pg_stat_activity
% Lowpass digital filter with Chebyshev-I analog prototype
%
function lowpass
% Digital Filter Specifications:
wp = 0.125*2*pi; % digital passband frequency in Hz (normalized)
ws = 0.1375*2*pi; % digital stopband frequency in Hz (normalized)
Rp = 0.5; % passband ripple in dB
As = 20; % stopband attenuation in dB
% Analog Prototype Specifications:
@bangadennis
bangadennis / validate_credit_card.js
Created June 16, 2017 08:29 — forked from DiegoSalazar/validate_credit_card.js
Luhn algorithm in Javascript. Check valid credit card numbers
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@bangadennis
bangadennis / luhn.js
Last active June 16, 2017 08:29 — forked from ShirtlessKirk/luhn.js
Luhn validation algorithm
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@bangadennis
bangadennis / db_backup.sh
Created March 28, 2017 08:31 — forked from bendavis78/db_backup.sh
A simple database backup / rotation / prune script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
@bangadennis
bangadennis / .bash_profile
Created February 7, 2017 17:38 — forked from bettysteger/.bash_profile
make your terminal beautiful! (git branch color etc)
# terminal colors, Git branch in prompt, where am i
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=ExFxCxDxBxegedabagacad
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ →\ \1/'
}
export PS1='\[\e[1;37m\][\[\e[1;35m\]\u\[\e[1;37m\]:\[\e[1;36m\]\w\[\e[1;33m\]$(parse_git_branch)\[\e[1;37m\]]$ \[\e[0m\]'