Skip to content

Instantly share code, notes, and snippets.

View NicholasEli's full-sized avatar

Nicholas Eli NicholasEli

View GitHub Profile
{
"debug": true,
"prettier_cli_path": "",
"node_path": "",
"auto_format_on_save": true,
"auto_format_on_save_excludes": [],
"auto_format_on_save_requires_prettier_config": false,
"allow_inline_formatting": false,
"custom_file_extensions": [],
"max_file_size_limit": -1,
// Cleaner way to manage state and its handlers
import React, { useState, useMemo } from 'react';
const Home = (props) => {
const [count, { inc, dec }] = useCounter();
return (
<main id="home-component" className="component-container">
<h5>Count {count}</h5>
1. Understanding the problem
a. Can you restate the problem in your own words?
b. What are the input that go into the problem?
c. What are teh outputs that should come from the solution of the problem?
d. Do you have enough information to solve the problem?
e. What should you label the important pieces of data in the problem?
2. Create Examples
3. Break it down
a. Write downs steps of problem in a comment latter
4. Solve or Simplify
@NicholasEli
NicholasEli / gist:0b6ae0cc1a78fe2e8cc0b453704586bc
Created February 20, 2020 22:29
Javascript Reverse Array with String Values
/*
Write a function that reverses a string. The input string is given as an array of characters char[].
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
You may assume all the characters consist of printable ascii characters.
*/
const arr = ["h", "e", "l", "l", "o"]
@NicholasEli
NicholasEli / app.js
Created September 25, 2018 21:08 — forked from ColCh/app.js
catch errors and send 'em to Crashlytics in React Native
// WARNING: SIDE-EFFECTS. ONLY FOR PROD VERSION
if (!__DEV__) {
require('./utils/log.js');
}
// SIDE-EFFECTS END
const position = {
latitude: 45.417224,
longitude: -122.659946
}
const { JSDOM } = require('jsdom')
const jsdom = new JSDOM('<!doctype html><html><body></body></html>')
const { window } = jsdom
global.window = window
@NicholasEli
NicholasEli / gist:47f66bb01cdf4e7ff78674aad95987c5
Created April 9, 2018 17:28
Vanilla JS xhttp requst with json
const jsonObject = {
//key values
}
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//on complete
}
}
function stringPosition(needle, haystack) {
var m = needle.length,
n = haystack.length;
if (!m || !n || m > n) {
return -1;
}
if (m === n) {
return needle === haystack ? 0 : -1;
@NicholasEli
NicholasEli / custom-nav-walker-usage.php
Created October 29, 2017 22:27 — forked from kosinix/custom-nav-walker-usage.php
WordPress: Using a custom nav walker to create navigation menus in plain <a> tags. That is the <ul> and <li> tags are not present. Very useful if you want to create simple links that can be centered with a simple text-align:center on the containing element.
<?php
// In your template files like footer.php
// The items_wrap value ('%3$s') removes the wrapping <ul>, while the custom walker (Nav_Footer_Walker) removes the <li>'s.
wp_nav_menu(array('items_wrap'=> '%3$s', 'walker' => new Nav_Footer_Walker(), 'container'=>false, 'menu_class' => '', 'theme_location'=>'footer', 'fallback_cb'=>false ));
?>
@NicholasEli
NicholasEli / gist:89799c128500f93827c613476c610237
Created February 27, 2017 22:35
IE compatible for-loops and event attachments
//passing i to an anonymous self executing funtion will bind event handlers to DOM nodes from IE9 and up. Haven't checked for IE9 and below.
for (let i = 0; i < el.length; i++) {
(function(i){
el[i].addEventListener('click', (event) => {
});
})(i);
}