Skip to content

Instantly share code, notes, and snippets.

View OlivierJM's full-sized avatar
🇿🇲

Olivier JM Maniraho OlivierJM

🇿🇲
View GitHub Profile
@OlivierJM
OlivierJM / promises.js
Created August 8, 2024 06:23
Show how to use promises
const fetchData = () => {
return new Promise((resolve, reject) => {
// Here we are simulating an action that would likely take time, basically it doesn't run immediately
// it could be something like long calculations, fetching data from a server, writing data to a file, etc ...
setTimeout(() => {
const success = true; // this is just to simulate a successful action
if (success) {
// if we succeed then we mark as resolved
resolve('Data fetched successfully!');
@OlivierJM
OlivierJM / interview.md
Created July 14, 2024 10:47
interview.md
  1. What is the output of the following code?
console.log(typeof NaN);

a) "undefined" b) "number" c) "NaN" d) "object"

[
{
"number": 1,
"key": "ibyo-tubona-mwiyi-si",
"title": "Ibyo tubona mw'iyi si",
"markdown": "1. Ibyo tubona ...Mwiyisi Nubusagusa\nNinyi Buchu bihinduka mukanya gato Neino duhunge umujyinya wuwiteka\n\n**Chorus**\n\nImanda Yanyuma nivuga nituzasezeranaho abapfuye bazazuka tuzarebana twishimye tuzarira amarirayumunezero.\n\n2. ubugome bwikigihe burenze urugero Abantu benshi bigize \n\n**Chorus**\nIsinshya nijuru Rishya Yesu azadutambagiza yerusaremunshya tuza mbikwa amakamba yizahabu.\n\n3. Ababyeyi Bikigihe barahangayitse abana babobigize ibwigomeke Yesu Niwemurezi mwiza utayobya.\n\n**Chorus**\n\nImanda Yanyuma nivuga nituzasezeranaho abapfuye bazazuka tuzarebana twishimye tuzarira amarirayumunezero.(×2)\n\nIsinshya nijuru Rishya dorebose byahumuye Yesu azadutambagiza muri yerusaremunshya tuza mbikwa amakamba yizahabu.(×2}"
},
{
"number": 2,
"key": "tuzanywe-no-kuvuga",
@OlivierJM
OlivierJM / student_admin.py
Last active February 8, 2024 17:55
student management
import json
students = []
def add_student():
print("\nAdd New Student Details:")
last_name = input("Last Name: ")
first_name = input("First Name: ")
id_number = input("ID Number: ")
major = input("Major: ")
@echo off
setlocal enabledelayedexpansion
:: Prompt for username
set /p username=Enter the username for which you want to change the password:
:: Prompt for new password
set /p newPassword=Enter the new password:
:: Change the password
@OlivierJM
OlivierJM / records_keeper.py
Last active December 25, 2023 09:40
records_keeper.py
import json
students_data = []
def add_student():
last_name = input("Enter last name: ")
first_name = input("Enter first name: ")
id_number = input("Enter ID number: ")
major = input("Enter major: ")
email = input("Enter email: ")
{
"breakpoints": {
"keys": [
"xs",
"sm",
"md",
"lg",
"xl"
],
"values": {
import { useEffect, useState } from 'react';
/**
* Debounce a value to avoid constant calls to the server
* @param value it can be a string or a number
* @param delay the amount in milliseconds that will be delayed
* @returns The give value debounced
*/
export default function useDebounceValue<T>(value: T, delay: number): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value);
function removeDuplicates(arr, prop){
return arr.filter((obj, index, self) => {
return index === self.findIndex((t) => {
return t[prop] === obj[prop]
})
})
}
function onInputChange(file) {
// convert image file to base64 string
const reader = new FileReader();
reader.addEventListener(
'load',
() => {
setInputImg(reader.result);
},
false