Skip to content

Instantly share code, notes, and snippets.

View timkofu's full-sized avatar
💭
💭

Timothy Makobu timkofu

💭
💭
View GitHub Profile
import requests
from bs4 import BeautifulSoup
from num2words import num2words
import time
import subprocess
import re
import random
maxlen = 31
@timkofu
timkofu / sema.py
Last active November 3, 2015 08:33
Python code to send SMS via the Sematime API
# Code to send SMS via the Sematime API
# API Doc: https://s3.amazonaws.com/api.sematime.com/Sematime+API+Docs.pdf
import json
import requests
def send_message(recipients, message):
user_id = "" # your user id
@never_cache
def caesar_decrypt(request):
def caesar_shift(crypt_text):
table = string.maketrans(
string.ascii_lowercase,
string.ascii_lowercase[13:]+string.ascii_lowercase[:13])
return string.translate(crypt_text.encode(errors="ignore").lower(), table)
if request.method == 'POST':
#!/bin/bash
# Tell the kernel you want to use this machine as an IP V4 gateway
echo 1 > /proc/sys/net/ipv4/ip_forward
# Set up variables for the network interfaces
lan_interface=eth0
internet_interface=eth1
# Ports you want your users to connect directly to on the internet
@timkofu
timkofu / Jobs Google search
Last active December 18, 2015 11:08
Jobs Google search
@timkofu
timkofu / gist:6989837
Last active December 25, 2015 14:19
Dell Poweredge T620 Specs
Vendor: Dell Inc.
Version: 1.5.3
Release Date: 03/12/2013
BIOS Revision: 1.5
CPU information
Machine class: amd64
CPU Model: Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz
No. of Cores: 12
@timkofu
timkofu / 202020.py
Last active February 29, 2016 19:39
Code to help with sticking to the 20-20-20 rule.
# Combat Computer Vision Syndrome using the 20-20-20 rule
# Every 20 minutes, spend 20 seconds looking at something 20 feet away, minimum.
# https://www.vsp.com/computer-vision-syndrome.html
# @timkofu, 2016
import subprocess
import time
import sys
# Keeps heroku free dyno from sleeping
# Runs from cron every 29 minutes
import requests
import gevent
from gevent import monkey
monkey.patch_all()
@timkofu
timkofu / diagonal_difference.py
Last active December 22, 2016 11:50
just coz
# Given a square matrix of size N x N, calculate the absolute difference between the sums of its diagonals.
m_raw = input().strip()
m_order = int(m_raw.split("\n")[0])
for _ in range(m_order):
m_raw += "\n"+input().strip()
m_trix = [list(map(int, x.strip().split())) for x in m_raw.split("\n")][1:]
print(abs(sum([(m_trix[x][x] - m_trix[x][-(x+1)]) for x in range(m_order)])))
@timkofu
timkofu / Django filter column overflow scrollbar.css
Last active March 7, 2017 05:42
Django filter column overflow scrollbar. Override /django/contrib/admin/static/admin/css/changelists.css
#changelist-filter {
position: absolute;
top: 0;
right: 0;
z-index: 1000;
width: 160px;
height: 100%;
border-left: 1px solid #ddd;
background: #efefef;
margin: 0;