Skip to content

Instantly share code, notes, and snippets.

View BolajiAyodeji's full-sized avatar
🥑
Working from home

Bolaji Ayodeji BolajiAyodeji

🥑
Working from home
View GitHub Profile
@BolajiAyodeji
BolajiAyodeji / git-setup.md
Last active March 2, 2019 21:55
How to fix git always asking for username and password

Update the URL of origin remote like, using SSH instead HTTPS;

git remote set-url origin [email protected]:username/repo.git

You can also use;

git config --global credential.helper store

to make git store the username and password and it will never ask for them.

command usage
git init Creates an empty Git repository in the specified directory.
git clone <repository name> Clones a repository located at <repository name> onto your local machine.
git add <directory> Stages only the specified changes for the next commit. Replace <directory> with a <file> to change a specific file.
git add . Stages new files and modifications without deletions
git add -A Stages all changes
git add -all Equivalent to git add -A
git add -u Stages modifications and deletions without adding new files
git add --update Equivalent to git add -u
git commit -m ”<message>” Commits the staged snapshot. replace <message> with the commit message.
@jpinnix
jpinnix / git-cheat-sheet.md
Created February 18, 2019 22:07
git-cheat-sheet.md
command usage
git init Creates an empty Git repository in the specified directory.
git clone Clones a repository located at onto your local machine.
git add Stages only the specified changes for the
@BolajiAyodeji
BolajiAyodeji / filter-map-reduce.js
Last active March 2, 2019 21:53
Understand filter(), map(), reduce() in 10 seconds
// FILTER(), MAP(), REDUCE()
const boxs = [1, 3, 5, 8, 6, 7, 9];
// FITER()
// This method creates a new array if the items of an array pass a certain condition.
const boxFilter = boxs.filter(box => {
if (box > 3) {
return box;
}
// for... in loop
let start = performance.now();
let obj = {
key1: "value1",
key2: "value2",
key3: "value3"
}
for (let key in obj) {
let value = obj[key];
console.log(key, value);
@BolajiAyodeji
BolajiAyodeji / prototypes-cheat-sheet.js
Created March 15, 2019 15:49
JavaScript Prototypes Cheat Sheet.
// Every object (except the root object) has a prototype (parent).
// To get the prototype of an object:
Object.getPrototypeOf(obj);
// In Chrome, you can inspect "__proto__" property. But you should
// not use that in the code.
// To get the attributes of a property:
Object.getOwnPropertyDescriptor(obj, 'propertyName');
@mikowl
mikowl / oneliners.js
Last active September 24, 2025 19:23
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@BolajiAyodeji
BolajiAyodeji / regexCheatSheet.js
Created April 16, 2019 19:40
A Regular Expressions Cheat Sheet
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
import React from "react"
import ReactDOM from "react-dom"
function App() {
const date = new Date()
const hours = date.getHours()
let timeOfDay
if (hours < 12) {
timeOfDay = "morning"
@dabit3
dabit3 / GOTApp.js
Created May 13, 2019 18:44
Game of thrones app build with GraphQL & React Native
import React, {useState, useEffect} from 'react';
import {StyleSheet, Text, View, Image} from 'react-native';
import { API, graphqlOperation } from 'aws-amplify'
const query = `
query listCharacters {
listCharacters {
items {
id name description avatar