This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get(base, pathQuery, returnOnUndefinedValue) { | |
var pathArr = pathQuery.split('.'); | |
var currentVal = base; | |
for (var i=0; i<pathArr.length; i++) { | |
var key = pathArr[i]; | |
currentVal = currentVal[key]; | |
if (!currentVal) { | |
return returnOnUndefinedValue ; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- my normal flow? | |
- good commit messages ****** | |
- searching commit messages (group by keywords) | |
- searching code * | |
- working with history (viewing, time traveling) | |
- rebasing (for pulling & squashing, splitting a commit) * | |
- undoing local commits (soft, hard reset) | |
- forgot to add / change message (amend) | |
- LOST commits? * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# $ ./gitmove [destGitRepo] [src_file] | |
DEST_FOLDER=$1 | |
SOURCE_FILE=$2 | |
# get the earliest hash of a source file to copy | |
HASH=$(git log --format=%H $SOURCE_FILE | tail -1) | |
# echo $HASH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
slug: introducing-the-react-testing-library | |
date: 2019-02-18 | |
title: Introducing the react-testing-library 🐐 | |
description: "NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s sent. Subscribe to get more content like this earlier right in your inbox! 💌 Two weeks ago, I wrote a new…" | |
categories: ['React'] | |
keywords: [React,JavaScript,Testing] | |
banner: './images/banner.jpg' | |
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple example of how to create a function that calls a middleware chain, similar to express middleware | |
var req = {type: "req"}; | |
var res = {type: "res"}; | |
// 3 middlewares | |
var first = function(req, res, next) { | |
req.first = true; //easy way to verify that all have been executed | |
res.first = true; | |
return next(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
// Expectation: When I curl localhost:3000, I want to be able to | |
var server = http.createServer(function (req, res) | |
res.statusCode = 200; | |
res.write(e.stack); // throws exception | |
res.end() | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//add this code at the end of "functions.php" (Theme Functions). This can be accessed through the WP admin menu under Appearance -> Editor -> Theme Functions | |
//this is the logic to get the posts you want | |
function displayHomePosts(){ | |
//default values obj from post.php. | |
//pass these in as args that you really want | |
$defaults = array( | |
'numberposts' => 5, 'offset' => 0, | |
'category' => 0, 'orderby' => 'post_date', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash #adding this to force silly gist highlighting. REMOVE THIS | |
# BASH standalone npm install autocomplete. Add this to ~/.bashrc file. | |
_npm_install_completion () { | |
local words cword | |
if type _get_comp_words_by_ref &>/dev/null; then | |
_get_comp_words_by_ref -n = -n @ -w words -i cword | |
else | |
cword="$COMP_CWORD" | |
words=("${COMP_WORDS[@]}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh #adding this to force silly gist highlighting. REMOVE THIS | |
# ZSH standalone npm install autocompletion. Add this to ~/.zshrc file. | |
_npm_install_completion() { | |
local si=$IFS | |
# if 'install' or 'i ' is one of the subcommands, then... | |
if [[ ${words} =~ 'install' ]] || [[ ${words} =~ 'i ' ]]; then | |
# add the result of `ls ~/.npm` (npm cache) as completion options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use this when you can curl an https server, but node request() will return 'econnreset: socket hang up' | |
var options = { | |
url: 'https://some/site', | |
method: 'POST', | |
// these 3 lines matter | |
strictSSL: false, | |
secureProtocol: 'TLSv1_method', | |
rejectUnhauthorized: false | |
} |