Skip to content

Instantly share code, notes, and snippets.

View antonnifo's full-sized avatar
🎯
Focusing: Make Hard Things Happen.

Mwangi Anthony antonnifo

🎯
Focusing: Make Hard Things Happen.
View GitHub Profile
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@antonnifo
antonnifo / .https
Created May 21, 2021 09:38
Redirect http to https in cpanel .https file
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@antonnifo
antonnifo / .gitignore
Created July 23, 2020 07:24
gitignore file example a django project
venv/*
.vscode/
__pycache__
*.pyc
.env
.gitignore
media
db.sqlite3
db.json
@antonnifo
antonnifo / django_deploy.md
Last active February 3, 2024 09:20 — forked from bradtraversy/django_deploy.md
Django Deployment - Digital Ocean

Django Deployment to Ubuntu 18.04

In this guide I will go through all the steps to create a VPS, secure it and deploy a Django application. This is a summarized document from this digital ocean doc

Any commands with "$" at the beginning run on your local machine and any "#" run when logged into the server

Create A Digital Ocean Droplet

Use this link and get $10 free. Just select the $5 plan unless this a production app.

@antonnifo
antonnifo / pipenv_cheat_sheet.md
Created May 14, 2019 14:47 — forked from bradtraversy/pipenv_cheat_sheet.md
Pipenv cheat sheet for common commands

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell
@antonnifo
antonnifo / ordinal.py
Created January 19, 2019 09:00
Finish the function numberToOrdinal, which should take a number and return it as a string with the correct ordinal indicator suffix (in English). For example, 1 turns into "1st"
def numbertoordinal(number):
if number < 0 or number > 10001:
return None
if number < 20: #determining suffix for < 20
if number < 10:
if number == 0:
suffix =''
elif number == 1:
suffix = 'st'
@antonnifo
antonnifo / denomations.py
Created January 19, 2019 08:58
Write a function that counts how many different ways you can make change for an amount of money, given an array of coin denominations.
def resolve(n, coins, k):
if k < 0 or n < 0:
return 0
if n == 0:
return 1
count = resolve(n, coins, k - 1) + resolve(n - coins[k], coins, k)
@antonnifo
antonnifo / power.py
Created January 19, 2019 08:57
Write a function named power that accepts two arguments, a and b and calculates a raised to the power b.
def power(a,b):
if b == 0:
return 1
else:
return eval(((str(a)+"*")*b)[:-1])
@antonnifo
antonnifo / main.py
Created January 19, 2019 08:55
Write a function my_sort which takes in a list of numbers (integers). The function should return a list of sorted numbers such that odd numbers come first and even numbers come last.
def my_sort(numbers):
odd = [n for n in numbers if n % 2 != 0]
even = [n for n in numbers if n % 2 == 0]
return sorted(odd) + sorted(even)
print( my_sort([60, 25, 88]))
@antonnifo
antonnifo / main.py
Created January 19, 2019 08:53
Given a non-negative integer, return an array or a list of the individual digits in order.
def digitize(n):
return [int(s) for s in str(n)][::1]
print(digitize(123))