Skip to content

Instantly share code, notes, and snippets.

View chidindu-ogbonna's full-sized avatar
👽

Promise Ogbonna chidindu-ogbonna

👽
View GitHub Profile
@chidindu-ogbonna
chidindu-ogbonna / auth-utils.js
Created September 28, 2021 11:44
Authorization Helpers for AWS Authorizers
/*global require exports Buffer */
const { promisify } = require("util");
const fetch = require("node-fetch");
const jwkToPem = require("jwk-to-pem");
const jsonwebtoken = require("jsonwebtoken");
/**
* Generate Auth Error
* @param {('invalid_token'|'boye')} code Error message code
* @param {string} message Message of the error
@chidindu-ogbonna
chidindu-ogbonna / useUser.js
Last active September 4, 2021 21:21
A useUser context for Nextjs using AWS Amplify
import { Auth } from "@aws-amplify/auth";
import Router from "next/router";
import { createContext, useContext, useEffect, useState } from "react";
import { createUser, getUser } from "../utils/api";
const AuthContext = createContext();
export const useAuthContext = () => useContext(AuthContext);
export const AuthProvider = (props) => {
@chidindu-ogbonna
chidindu-ogbonna / tailwindhome.html
Created September 4, 2021 20:44
Home page of tailwindcss
<!--
Welcome to Tailwind Play, the official Tailwind CSS playground!
Everything here works just like it does when you're running Tailwind locally
with a real build pipeline. You can customize your config file, use features
like `@apply`, or even add third-party plugins.
Feel free to play with this example if you're just learning, or trash it and
start from scratch if you know enough to be dangerous. Have fun!
-->
@chidindu-ogbonna
chidindu-ogbonna / kaggle.py
Last active November 13, 2020 22:14
Get data to Colab from Kaggle
!pip install --upgrade --force-reinstall --no-deps kaggle
from google.colab import files
# Upload you kaggle.json file gotten from Kaggle Account settings.
files.upload()
!chmod 600 kaggle.json
!mkdir ~/.kaggle
!cp kaggle.json ~/.kaggle/
@chidindu-ogbonna
chidindu-ogbonna / camera.vue
Created October 30, 2020 19:18
Control the camera in vue (nuxtjs) component
<template>
<div class="camera__layout">
<main class="camera__layout-content">
<video ref="video" autoplay></video>
<input
ref="fileExp"
class="hidden"
type="file"
accept="image/*"
@chidindu-ogbonna
chidindu-ogbonna / a.sql
Created August 29, 2020 05:36
Learning SQL
CREATE DATABASE IF NOT EXISTS recommendation_spark;
USE recommendation_spark;
DROP TABLE IF EXISTS Recommendation;
DROP TABLE IF EXISTS Rating;
DROP TABLE IF EXISTS Accommodation;
CREATE TABLE IF NOT EXISTS Accommodation
(
@chidindu-ogbonna
chidindu-ogbonna / ds-another.py
Last active March 5, 2020 02:26
Data Science & Machine Learning Snippets - Useful snippets for simple things (All files start with "ds-" )
# Second stuff comes here
@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:
@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": [
{
/**
* 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