Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mojaray2k's full-sized avatar

Amen Moja Ra mojaray2k

  • Miami, Fl
View GitHub Profile
@mojaray2k
mojaray2k / rest-api-pitfalls.md
Last active March 2, 2024 17:37
This is about the pitfalls of rest api’s
  1. Deciding on a url schema gets tough when we begin to have heavily nested relationships of data.

  2. When fetching heavily nested data wecan easily run into situations where we make to many http requests to get the data we need.

  3. We are vulnerable to overfetching data.

@mojaray2k
mojaray2k / handling_multiple_github_accounts.md
Created August 6, 2020 18:53 — forked from Jonalogy/handling_multiple_github_accounts.md
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@mojaray2k
mojaray2k / handling_multiple_github_accounts.md
Created August 6, 2020 18:53 — forked from Jonalogy/handling_multiple_github_accounts.md
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@mojaray2k
mojaray2k / unique-array-values-js.md
Created May 28, 2020 15:48
3 Ways to get unique values from an array in Javascript

Here are 3 ways to retrieve unique values from arrays in Javascript

  1. The array.filter method which is a higher order function which means it takes a function as it's argument.
const someArray = ['😁', '💀', '💀', '💩', '💙', '😁', '💙'];

const getUniqueValues = (array) => (
  array.filter((currentValue, index, arr) => (
		arr.indexOf(currentValue) === index
@mojaray2k
mojaray2k / generics.ts
Last active May 24, 2020 18:20
Using Generics in Typescript
class ArrayOfNumbers {
constructor(public collection: number[]) {}
get(index: number): number {
return this.collection[index];
}
}
class ArrayOfStrings {
constructor(public collection: string[]) {}
get(index: number): string {
@mojaray2k
mojaray2k / typescript-compiler-config-optons.md
Created May 23, 2020 16:17
Common TypeScript compiler and tsconfig options

TypeScript Compiler and TS Config Options

You can store the TS compiler configuration in the file called tsconfig.json. You’ll usually add this file to the root directory of your project, together with the package.json.

When you launch the compiler, it reads the tsconfig.json from the folder you launched it from, to get the instructions about how to compile your project (e.g., which source files to compile, where to store the output, etc).

The compiler reads the tsconfig.json from the folder where you run it. Also, you can tell the compiler where to look for the config using the -p option:

tsc -p tsconfig.server.json The structure of the tsconfig.json looks like this:

@mojaray2k
mojaray2k / mongo-db-queries.md
Last active May 15, 2020 00:21
Mongo DB Queries

Queries used to interact with MongoDB

We are going to use a sample books collection

  1. Get all documents in a collection
  db.getCollection('books').find({})

reasult:

@mojaray2k
mojaray2k / square-patterns-css.md
Created May 14, 2020 17:05
Square Patterns in CSS

Square Patterns in CC

nesting and centering squares

<!DOCTYPE html>
<html>
<head>
</head>
<body>
@mojaray2k
mojaray2k / function-generator.md
Created May 11, 2020 17:16
Create a simple Function Generator Gist

Sample Function Generator

Without while true loop

function* testing() {
    yield 1;
    yield 2;
    yield 3;
}
@mojaray2k
mojaray2k / react-registration-form-using-useState.md
Last active February 3, 2023 09:06
Sample React Registration form Using UseState Hook

React Registraton Form using useState Hook

import React, { Fragment, useState } from "react";
import { Link } from "react-router-dom";
import axios from "axios";

const Register = () => {
  const [formData, setFormData] = useState({
    name: "",