-
q. How do you comfort a JavaScript bug? a. You console it
-
When a JavaScript date has gone bad, "Don't call me, I'll callback you. I promise!"
-
Dev1 saw a strange JavaScript function & asked, "What is this?". Dev2 responded, "I don't know. I would've called you, but I was in a bind"
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 node | |
const shell = require("shelljs"); | |
function audit(name) { | |
const tempDir = `${shell.tempdir()}/audit/${name}`; | |
shell.mkdir("-p", tempDir); | |
shell.cd(tempDir); | |
shell.exec("npm init -y", { silent: true }); | |
shell.exec(`npm install ${name}`, { silent: true }); |
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 array_like = {}; | |
array_like[ 0 ] = "test 0"; | |
array_like[ 1 ] = "test 1"; | |
array_like[ 2 ] = "test 2"; | |
array_like[ 3 ] = "test 3"; | |
array_like.length = 4; | |
array_like.splice = [].splice; |
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 ghpr() { | |
GH_FORCE_TTY=100% gh pr list | fzf --query "$1" --ansi --preview 'GH_FORCE_TTY=100% gh pr view {1}' --preview-window down --header-lines 3 | awk '{print $1}' | xargs gh pr checkout | |
} | |
# awesome! |
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
// Avoid `console` errors in browsers that lack a console. | |
(function() { | |
var method; | |
var noop = function () {}; | |
var methods = [ | |
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', | |
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', | |
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', | |
'timeStamp', 'trace', 'warn' | |
]; |
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
import React, { Component } from "react"; | |
import { render } from "react-dom"; | |
import "./index.css"; | |
class Widget extends Component { | |
state = { text: "" }; | |
handleChange = (e) => { | |
this.setState({ text: e.target.value }); | |
}; | |
render() { |
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 reverseString(str) { | |
// Step 1: Use the split() method to return a new array | |
let splitString = str.split(""); // split() method splits a string into an array of substrings | |
// Step 2: Use the reverse() method to reverse the new created array | |
let reverseArray = splitString.reverse(); // reverse() method reverses an array in place | |
// Step 3: Use the join() method to join all elements of the array into a string | |
let joinArray = reverseArray.join(""); // join() method joins all elements of an array into a string |
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
<!doctype html> | |
<html lang="en"> | |
<!-- ... --> | |
<body> | |
<div class="reveal"> | |
<div class="slides"> | |
<section data-markdown="slides.md" | |
data-separator="^\n---\n$" | |
data-vertical="^\n------\n$" | |
data-notes="^Notes:" |
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
“Debugging is twice as hard as writing the code | |
in the first place. Therefore, if you write the | |
code as cleverly as possible, you are, by | |
definition, not smart enough to debug it.” | |
--Brian Kernighan |
NewerOlder