Skip to content

Instantly share code, notes, and snippets.

View damilare's full-sized avatar
🎯
Focusing

Damilare Onajole damilare

🎯
Focusing
View GitHub Profile
@damilare
damilare / clone_or_update_repo.py
Created April 15, 2019 15:42
Clone all repost, or update its master branch
import os
import subprocess
with open('repos.txt') as f:
for repo in f.readlines():
dir_name = repo.split('/')[1].split('.')[0]
if os.path.exists(dir_name):
print("Updating ... %s" % dir_name)
subprocess.run(['git', '-C', dir_name, 'checkout', 'master'])
subprocess.run(['git', '-C', dir_name, 'pull', 'origin', 'master'])
@damilare
damilare / data-interchange.md
Created March 19, 2019 18:18 — forked from evancz/data-interchange.md
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@damilare
damilare / macronutrientcalc.py
Last active January 23, 2017 10:00
Calculate your recommended calorie intake, and macronutrient ratio based on your weight and your level of activity
import sys
import math
"""
To use, just run python macronutrientcalc.py <body weight in kg> <lifestyle between 10 and 20>
"""
def _(num, numbers):
return math.floor((num / numbers) * 100)
@damilare
damilare / System Design.md
Created May 3, 2016 06:10 — 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?
@damilare
damilare / izendmd.py
Last active August 29, 2015 14:21 — forked from cluther/izendmd.py
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2012, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################
'''
packs = None
if hasattr(dmd, 'ZenPackManager'):
packs = dmd.ZenPackManager.packs
else:
packs = dmd.packs
phase2 = False
for pack in packs():
try:
@damilare
damilare / tree.md
Last active August 29, 2015 14:19 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
"""
The MIT License (MIT)
Copyright (c) 2011 Numan Sachwani
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
def __unicode__(self):
try:
return '{0}'.format(self.name)
except UnicodeError:
return ''