Skip to content

Instantly share code, notes, and snippets.

View geekelo's full-sized avatar
👩‍💻
Embracing the potential for new opportunities

Eloghene Otiede geekelo

👩‍💻
Embracing the potential for new opportunities
View GitHub Profile
@geekelo
geekelo / jadencasing..txt
Last active August 8, 2023 08:21
Jaden Casing Strings
QUESTION:
Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known for almost always capitalizing every word. For simplicity, you’ll have to capitalize each word, check out how contractions are expected to be in the example below.
Your task is to convert strings to how they would be written by Jaden Smith. The strings are actual quotes from Jaden Smith, but they are not capitalized in the same way he originally typed them.
Example:
Not Jaden-Cased: “How can mirrors be real if our eyes aren’t real”
Jaden-Cased: “How Can Mirrors Be Real If Our Eyes Aren’t Real”
@geekelo
geekelo / File1.md
Last active August 16, 2023 08:03
Crypto Price Rank - Tutorials

INITIAL SET UP

  • Migrate to your projects folder using bash command cd <name of folder>

  • Create new react app using npx create-react-app <name of project

  • Migrate to the newly created project folder and launch project folder in vscode code .

  • Remove redunt files in the src folder

@geekelo
geekelo / File1.md
Last active August 18, 2023 07:45
GeekOverflow

QUESTION:

When I am on the home page I want to display a REFRESH button

When I am on the inside pages I want to display a GO BACK button instead

How can I achieve this in react

SOLUTION

To achieve the desired behavior of displaying a refresh button on the home page and a back button on inside pages in a React application, you can use conditional rendering based on the current route. You can use the useLocation hook from react-router-dom to get the current location, and then determine whether to display the refresh or back button.

@geekelo
geekelo / File1.md
Created August 27, 2023 04:02
Sorting in JavaScript

To sort an array in JavaScript, you can use the sort() method. The sort() method sorts the elements of an array in place and returns the sorted array. By default, it sorts the elements as strings, which might not be suitable for numeric or custom sorting. You can pass a comparison function to the sort() method to customize the sorting behavior.

Here's the basic syntax for using the sort() method:

array.sort([compareFunction])

If you want to sort an array of numbers, you can provide a custom comparison function to achieve numeric sorting:

@geekelo
geekelo / diff.md
Created September 11, 2023 08:13
Differences & Similarities Between JavaScript and Ruby

Differences Between JavaScript and Ruby

JavaScript and Ruby are both powerful programming languages, but they have some key differences:

  1. Syntax:
    • JavaScript (JS): It has C-style syntax, which means it uses curly braces {} and semicolons ; to structure code blocks.
      for (let i = 0; i < 5; i++) {
        console.log(i);

}

@geekelo
geekelo / example1.css
Last active January 2, 2024 09:18
Styling Checkboxes
input[type=checkbox] {
position: relative;
border: 2px solid #000;
border-radius: 2px;
background: none;
cursor: pointer;
line-height: 0;
margin: 0 .6em 0 0;
outline: 0;
padding: 0 !important;
@geekelo
geekelo / animated-gradient.css
Created January 3, 2024 03:40
Animated Gradient
.gradient-background {
background: linear-gradient(67deg,#d2ffda,#94c894,#174217);
background-size: 180% 180%;
animation: gradient-animation 12s ease infinite;
}
@keyframes gradient-animation {
0% {
background-position: 0% 50%;
}
@geekelo
geekelo / date.js
Created January 3, 2024 19:54
Date Formatter
function formatDate(inputDate) {
const months = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
];
const [year, month, day] = inputDate.split('-');
const monthAbbreviation = months[parseInt(month, 10) - 1];
return `${parseInt(day, 10)} ${monthAbbreviation}, ${year}`;
@geekelo
geekelo / loadmore_loadless.js
Created January 4, 2024 07:51
Load More | Load Less Algorithm (React.js)
const personnels = useSelector((state) => state.display_personnel.value);
const [itemsToShow, setItemsToShow] = useState(12);
// HANDLE PAGINATION
const handleLoadMore = (e) => {
e.preventDefault();
setItemsToShow(itemsToShow + 12);
};
const handleLoadLess = (e) => {
@geekelo
geekelo / promiseinuseeffect.js
Created January 15, 2024 01:07
Using promise.all in dispatching & checking results
useEffect(() => {
const fetchData = async () => {
try {
// Use Promise.allSettled to ensure that all promises are settled,
// regardless of success or failure.
const results = await Promise.allSettled([
dispatch(displayCertificates()),
dispatch(displayStudents()),
dispatch(displayPersonnel()),
]);