Skip to content

Instantly share code, notes, and snippets.

View d-kahara's full-sized avatar
Talk is cheap, show me the code 🙂

David Kahara d-kahara

Talk is cheap, show me the code 🙂
  • Nairobi, Kenya
View GitHub Profile
View sql python
import psycopg2
def get_data():
# Establish a connection to the database
connection = psycopg2.connect(
user = "your_username",
password = "your_password",
host = "", # replace with your host if different
port = "5432", # replace with your port if different
d-kahara / gist:64002d6e774d19bdba0e67380f97c4e5
Created July 27, 2022 06:29
Install Code deploy agent on Ubuntu 22.04 LTS
View gist:64002d6e774d19bdba0e67380f97c4e5
sudo apt-get update
sudo apt-get install ruby-full ruby-webrick wget -y
cd /tmp
d-kahara /
Created April 22, 2020 12:07 — forked from c00kiemon5ter/
Extend Django's management createsuperuser command to allow non-interactive creation of a superuser with a password.
Extend createsuperuser command to allow non-interactive creation of a
superuser with a password.
mkdir -p path-to-your-app/management/commands/
touch path-to-your-app/management/
touch path-to-your-app/management/commands/
wget -O /tmp/code_latest_amd64.deb
sudo dpkg -i /tmp/code_latest_amd64.deb
d-kahara / test.ipynb
Created July 5, 2019 14:23
Jupyter Notebook tutorial
View test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
d-kahara /
Created December 30, 2018 20:16 — forked from Kartones/
PostgreSQL command line cheatsheet


Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
d-kahara /
Created December 20, 2018 06:30
This Gist showcases a unit test in Django
Gist handles testting a user model
using django
from django.test import TestCase
# import the user model
from users.models import User
class UserTestCase(TestCase):
d-kahara /
Created November 27, 2017 07:08 — forked from xaverkapeller/
Implementation of a RecyclverView Adapter base class which uses a SortedList internally
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;