Skip to content

Instantly share code, notes, and snippets.

View CalebMuhia's full-sized avatar

Muhia Njoroge CalebMuhia

  • Ovtygen Web Solutions
  • Nairobi
View GitHub Profile
@CalebMuhia
CalebMuhia / models.py
Created August 30, 2012 12:33 — forked from mbrochh/models.py
Attach the django-shop cart to a User that started shopping anonymously
# add this soewhere where it gets loaded very early, i.e.
# your shop's models.py
from django.contrib.auth import login
from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
from registration.signals import user_activated
from shop.models.defaults.cart import Cart

Source

Vim Commands Cheat Sheet


How to Exit

:q[uit]

##
# Creates an alias called "git hist" that outputs a nicely formatted git log.
# Usage is just like "git log"
# Examples:
# git hist
# git hist -5
# git hist <branch_name>
# git hist <tag_name> -10
##
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
@CalebMuhia
CalebMuhia / simple_mlp_tensorflow.py
Created December 1, 2017 16:25 — forked from vinhkhuc/simple_mlp_tensorflow.py
Simple Feedforward Neural Network using TensorFlow
# Implementation of a simple MLP network with one hidden layer. Tested on the iris data set.
# Requires: numpy, sklearn>=0.18.1, tensorflow>=1.0
# NOTE: In order to make the code simple, we rewrite x * W_1 + b_1 = x' * W_1'
# where x' = [x | 1] and W_1' is the matrix W_1 appended with a new row with elements b_1's.
# Similarly, for h * W_2 + b_2
import tensorflow as tf
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
@CalebMuhia
CalebMuhia / pg_change_schema_owner.sh
Created December 5, 2017 10:02 — forked from bspkrs/pg_change_schema_owner.sh
Changes the owner on all tables, sequences, views, and functions in a PostgreSQL database with support for identifiers with whitespace and non-public schemas.
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script sets ownership for all tables, sequences, views, and functions for a given schema.
Run this script as your postgres OS user.
@CalebMuhia
CalebMuhia / .gitignore
Created February 10, 2018 03:45 — forked from kenjyco/01-Learning-Python3.md
Learn Python 3 with Jupyter Notebook
*.swp
.ipynb_checkpoints/
@CalebMuhia
CalebMuhia / wget.md
Created March 11, 2019 10:57 — forked from simonw/wget.md
Recursive wget ignoring robots
$ wget -e robots=off -r -np 'http://example.com/folder/'
  • -e robots=off causes it to ignore robots.txt for that domain
  • -r makes it recursive
  • -np = no parents, so it doesn't follow links up to the parent folder
@CalebMuhia
CalebMuhia / post-server.py
Last active March 25, 2020 23:43 — forked from kylemcdonald/post-server.py
Python POST simple server
from http.server import HTTPServer, BaseHTTPRequestHandler
from io import BytesIO
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCpOevIq8wZhjEtggtf7kjDcL/v/rqkvNN1wMGv+HTgUCNoeVyUsc4KUk97UmNrlhe6xGP/vfpFfo2cOLtyuk5LIiFx+MMonf7HSBJRQM0dNtWu0hIidNoKPvZOcQnR0DMBjRxNkSXbbIQQiSpnWUS0QsRjux9/hBXRJASGHLTU5xVTJrdNnDFXzmUOMv81wLmXBJb+fI0Ryiyk5nEQ+Swgfu2qvjVA1TbUZj5SbQLwTHnVMHFF6eqkpQkaNcVPHnDHivfnQjcv+SGYL/VfgHMXorESXuBUXgeo+evbWZYLeZS3k1znC56wx/nXnF5pClGmUeA3aIsAsd4CfHLRlHVJTqKWGp6wpVFa6hk2TFfDZwYZBBSBPG1MlKfR6cJlyiIi/ya2cRRB6c8egVJC3llAlCHk/tvAT9//9iagPia+TBxBDGQfvNxKjCgDfbnl0HYjaxhMvYpDQDVNOyklQUOWEzlgdH6mHYsYE1jh1MtcIiGTxNC53l/myYvt9qadPF6BZ5lE2WFANMJ/acbq/TvixEtrkCzAjo7UaqXQBJQzQKVze/7LlpOW9h3f6RYcWwgJeJPTeFh531xkUs42hw9RFiBeyOvG1A+rWy/M0s2z7ywW/tw40E0wm+QoA3QnLQoa8fUQTbIg7YeJb9j0m8UNXzHXkIc5fQcIY5hdiOx+hQ== clbnjoroge@gmail.com
^XA\n^FT22,43\n^A0N,,36\n^FDEXPRESS WORLDWIDE^FS\n^FT22,43\n^A0N,,36\n^FDEXPRESS WORLDWIDE^FS\n^FT69,70\n^A0N,,15\n^FD2020-03-02 XMLPI 6.2 / *90-1604*^FS\n^FO386,0\n^GB150,79,79,B^FS\n^FT388,58\n^A0N,,65\n^FR^FDWPX^FS\n^FO0,78\n^GB780,0,2,B^FS\n^FT19,102\n^A0N,,17\n^FDFrom :^FS\n^FT19,102\n^A0N,,17\n^FDFrom :^FS\n^FT87,102\n^A0N,,25\n^FDHarumio^FS\n^FT87,129\n^A0N,,25\n^FDHarumio Shipping^FS\n^FT87,156\n^A0N,,24\n^FD402, Yeonnam-dong 249-15, Mapo-gu^FS\n^FT87,182\n^A0N,,25\n^FD03979 Seoul^FS\n^FT87,209\n^A0N,,25\n^FDSouth Korea^FS\n^FT693,102\n^A0N,,22\n^FDOrigin:^FS\n^FT694,140\n^A0N,,41\n^FDSEL^FS\n^FT693,140\n^A0N,,41\n^FDSEL^FS\n^FO0,220\n^GB780,0,2,B^FS\n^FT35,252\n^A0N,,17\n^FDTo :^FS\n^FT35,252\n^A0N,,17\n^FDTo :^FS\n^FO25,226\n^GB0,31,5,B^FS\n^FO28,224\n^GB31,0,5,B^FS\n^FO750,226\n^GB0,31,5,B^FS\n^FO720,224\n^GB31,0,5,B^FS\n^FO25,409\n^GB0,31,5,B^FS\n^FO28,439\n^GB31,0,5,B^FS\n^FO750,409\n^GB0,31,5,B^FS\n^FO720,439\n^GB31,0,5,B^FS\n^FT87,249\n^A0N,,31\n^FDJiaxing Guo^FS\n^FT87,282\n^A0N,,31\n^FDJiaxin