Skip to content

Instantly share code, notes, and snippets.

View Nyamador's full-sized avatar
🏚️
Working from home

Desmond Nyamador

🏚️
Working from home
View GitHub Profile
@Nyamador
Nyamador / Richardson
Last active December 17, 2021 10:35
Richardson
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body>
<p id="workCurrent">00</p>
@Nyamador
Nyamador / id.py
Created May 16, 2021 18:34
Id Gen
import datetime.datetime
# You can retrieve the id of the last item from your datatabse
# lastid = <YOUR_MODEL>.objects.last().id
def idGen(lastId):
today = datetime.date.today()
day, month, year = today.day, today.month, str(today.year)[2::]
return f"{day}{month}{year}{lastId}"
@Nyamador
Nyamador / latency.txt
Created May 12, 2020 18:20 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@Nyamador
Nyamador / Foo.html
Created February 12, 2020 09:04
Tag templates
{% for item in list %}
<form>
{{ item.name }}
<select>
{% for i in ticket.quantity|add:"1"|times%}
   <option value="1">{{ i }}</option>
 {% endfor %}}
{% endfor %}
</select>
</form>
@Nyamador
Nyamador / my_extras.py
Created February 12, 2020 08:44
Custom filter in django
from django import template
register = template.Library()
@register.filter(name='times')
def times(number):
"""
Returns a numerical loop with the built in python range function
"""
@Nyamador
Nyamador / Templatefilter.py
Last active February 12, 2020 07:32
Django Template filter
<your_app_name>/
__init__.py
models.py
templatetags/
__init__.py
my_extras.py
views.py
@Nyamador
Nyamador / django.config
Created January 18, 2020 14:49
AWS Elastic Beanstalk Config File
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: ebdjango/wsgi.py
#################
# Only if MacOS #
#################
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/darwin/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
@Nyamador
Nyamador / Np.arrays.py
Created December 30, 2019 22:15
Intro to Numpy
1
# Create an integer array of length 100 filled with zeros
2
np.zeros(100, dtype=int)
3
4
# Create a 3x3 floating-point array filled with 1s
5
@Nyamador
Nyamador / Stack.py
Created December 23, 2019 07:23
Stack Data Structure in Python
class Stack():
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()