Skip to content

Instantly share code, notes, and snippets.

View chidindu-ogbonna's full-sized avatar
👽

Promise Ogbonna chidindu-ogbonna

👽
View GitHub Profile

Here is a non-exhaustive list of books that have influenced how I think about software.

@chidindu-ogbonna
chidindu-ogbonna / custom-ubuntu1604.sh
Created March 25, 2018 09:40 — forked from evertontrindade/custom-ubuntu1604.sh
Things to do after install ubuntu 16.04
# First you update your system
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y
# Cleanup system
sudo apt-get purge account-plugin-facebook
sudo apt-get purge account-plugin-flickr
sudo apt-get purge account-plugin-google
sudo apt-get purge aisleriot
sudo apt-get purge fonts-opensymbol libreoffice libreoffice-\* openoffice.org-dtd-officedocument1.0 python\*-uno uno-libs3-\* ure ure-dbg
sudo apt-get purge gnome-terminal
@chidindu-ogbonna
chidindu-ogbonna / Writing_a_request_response_to_file.py
Last active June 27, 2018 21:31
Downloading a file with the requests module
import requests
import shutil
import json
# Writing a json response from an API to file
r = requests.get('http://api.domain.com')
with open('file.json', 'w') as f:
json.dump(r.json(), f, indent=2)
@chidindu-ogbonna
chidindu-ogbonna / list_comprehensions.py
Created April 29, 2018 05:23
TIL - Saw something new in list comprehensions
# Today I Learned using if/else in list comprehension is not as straight forward
# Correct
list_of_values = [a if a else 2 for a in [0, 1, 0, 3]]
# Correct
list_of_values = [a for a in [0, 1, 0, 3] if a]
# Wrong : Raises Syntax Error
list_of_values = [a if a for a in [0, 1, 0, 3]]
@chidindu-ogbonna
chidindu-ogbonna / cymath.py
Created December 14, 2018 09:22
Basic API example for https://cymath.com
"""
DISCLAIMER
I am not responsible for any actions or usage of this API, the api clearly states
"Restricted Access. We may pursue legal actions over unauthorized uses of this API."
This script is for educational purposes ONLY
"""
@chidindu-ogbonna
chidindu-ogbonna / vuefire.md
Last active April 30, 2019 11:25
Solution to binding vuefire to components
@chidindu-ogbonna
chidindu-ogbonna / service-worker.js
Created April 30, 2019 11:22
Including workbox in service workers
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.setConfig({ debug: true }); // show debugging even during development
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
console.log("%c Workbox is activated", "font-size: 30px; color: blue");
// Enable offline analytics
workbox.googleAnalytics.initialize();
/**
* Helper helper function
* Generate a title case.
* @param {string} string
*/
const titleCase = string => {
let splitStr = string.toLowerCase().split(" ");
for (let i = 0; i < splitStr.length; i++) {
// You do not need to check if i is larger than splitStr length, as your for does that for you
// Assign it back to the array
@chidindu-ogbonna
chidindu-ogbonna / settings.json
Created October 4, 2019 06:27
VSCode settings for using Eslint and Nuxt in your project.
{
// Install the Eslint plugin
// Install the Vetur plugin
// Disable the Prettier plugin for this workspace.
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatter.html": "js-beautify-html",
"eslint.packageManager": "yarn",
"eslint.autoFixOnSave": true,
"eslint.validate": [
{
@chidindu-ogbonna
chidindu-ogbonna / gcp_nl.py
Created October 18, 2019 23:12
Google Cloud Natural Language API
from google.cloud import language_v1
from google.cloud.language_v1 import enums
from google.auth import compute_engine
def analyze_sentiment(text):
"""
Analyze sentiment in a text
Args: