Skip to content

Instantly share code, notes, and snippets.

View emmaodia's full-sized avatar
🏠
Working from home

Emmanuel Oaikhenan emmaodia

🏠
Working from home
View GitHub Profile
@lilpolymath
lilpolymath / LRUCache.md
Created April 12, 2022 14:30
Implementing a given cache size behaving as an LRU cache with an expiry time and auto cache burst

Question

Implement Promise based memoization with a given cache size behaving as an LRU cache with an expiry time and auto cache burst.

Answer

First, what we have to do is breakdown the terms in the problem statement to understand what is going on and what we are asked to do.

  1. Promise based memoization: Memoization is one of the ways we can improve the performance of functions by eliminating redundant calls. Memoization is a technique where we store the results of a function call in a cache and return the result from the cache if the function is called again with the same arguments.
pragma solidity 0.8.0;
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "hardhat/console.sol";
// We need to import the helper functions from the contract that we copy/pasted.
import { Base64 } from "./libraries/Base64.sol";
@bradtraversy
bradtraversy / webdev_online_resources.md
Last active July 24, 2024 20:54
Online Resources For Web Developers (No Downloading)
@justsml
justsml / fetch-api-examples.md
Last active July 8, 2024 17:26
JavaScript Fetch API Examples
@iifeoluwa
iifeoluwa / index.blade.php
Created January 25, 2017 18:18
index view file for guestbook tutorial app
<!DOCTYPE html>
<html>
<head>
<title>GuestBook</title>
</head>
<style type="text/css">
.headings{
font-size: 1.3em;
}
h3{
@zhy0
zhy0 / ubuntu-cli-install-android-sdk.sh
Last active July 10, 2024 12:29
Install Android SDK on headless Ubuntu linux machine via command line, so that you can compile open source Android apps.
#!/bin/bash
# Thanks to https://gist.github.com/wenzhixin/43cf3ce909c24948c6e7
# Execute this script in your home directory. Lines 17 and 21 will prompt you for a y/n
# Install Oracle JDK 8
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install -y oracle-java8-installer
apt-get install -y unzip make # NDK stuff
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@rxaviers
rxaviers / gist:7360908
Last active July 24, 2024 22:23
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@ranskills
ranskills / gpa_calculator.js
Created March 28, 2012 22:45
GPA Calculator In JavaScript
var gradeLetters = ['a', 'b+', 'b', 'c+', 'c', 'd', 'f', 'af', 'wf'],
gradePoints = [4, 3.5, 3, 2.5, 2, 1, 0, 0, 0];
function getNumCoursesToBeEntered() {
"use strict";
var numCourses = 0,
input = "";
do {
input = prompt("Enter number of subjects?");