Skip to content

Instantly share code, notes, and snippets.

View timkofu's full-sized avatar
💭
💭

Timothy Makobu timkofu

💭
💭
View GitHub Profile
class FizzBuzz:
def __init__(self):
self.current_number = 0
def detect_multiple(self):
if (self.current_number % 3 == 0) and (self.current_number % 5 == 0):
return "FizzBuzz"
elif self.current_number % 3 == 0:
@timkofu
timkofu / democracy.py
Last active September 23, 2018 03:08
import sys
import math
import random
import collections
def democracy(number_of_candidates):
votes = []
cntr = collections.Counter()
.file "test_g++_flags_speedup.cpp"
.text
.section .rodata.str1.8,"aMS",@progbits,1
.align 8
.LC0:
.string "The billionth fibonacci number is: "
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
.file "test_g++_flags_speedup.cpp"
.text
.section .rodata
.type _ZStL19piecewise_construct, @object
.size _ZStL19piecewise_construct, 1
_ZStL19piecewise_construct:
.zero 1
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.align 8
#include <iostream>
using namespace std;
int main(){
unsigned long long int last_number = 0;
unsigned long long int current_number = 1;
unsigned long long int currnum_buff = 0;
import os
import time
import json
from typing import Union
from datetime import datetime
from argparse import ArgumentParser, Namespace
import tweepy
@timkofu
timkofu / gplustotwitter.py
Created March 19, 2017 06:45
Copy your Google+ posts to Twitter (2013)
import urllib
import json
import twitter
import sqlite3
import os
from HTMLParser import HTMLParser
import nltk
class Worker(object):
@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)])))
# 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 / 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