Skip to content

Instantly share code, notes, and snippets.

View elijahmanor's full-sized avatar
😀

Elijah Manor elijahmanor

😀
View GitHub Profile
@elijahmanor
elijahmanor / index.js
Last active September 21, 2023 21:07
Audit Single Package
View index.js
#!/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 });
@elijahmanor
elijahmanor / custom-array-like-object.js
Last active August 9, 2023 12:10
jQuery Array-like Object
View custom-array-like-object.js
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;
@elijahmanor
elijahmanor / README.md
Last active May 6, 2023 23:47
OCR from macOS Terminal
View README.md

I was reviewing a PR and there was a screenshot of the terminal that had output I wanted in text form.

Terminal Screenshot

So, I installed an OCR tool locally (called tesseract) and converted the PNG into TEXT.

# Install the OCR tool
brew install tesseract tesseract-lang
@elijahmanor
elijahmanor / .zshrc
Last active May 5, 2023 17:26
ghpr function
View .zshrc
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!
View console-monkey-patch.js
// 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'
];
@elijahmanor
elijahmanor / index-0-non-debounced.js
Last active December 20, 2022 21:14
React Debouncing Events
View index-0-non-debounced.js
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() {
@elijahmanor
elijahmanor / ChatGTP.js
Created December 4, 2022 19:01
Chat GTP: Show JavaScript code that will reverse a string and take the first 5 characters and uppercase them
View ChatGTP.js
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
@elijahmanor
elijahmanor / index.html
Last active October 21, 2022 18:25
Reveal.js External Markdown
View index.html
<!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:"
@elijahmanor
elijahmanor / gist:4197877
Created December 3, 2012 20:45
Quote: Clever Code
View gist:4197877
“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
@elijahmanor
elijahmanor / realtime-twitter-banner.json
Created June 5, 2022 17:12
Real-time Twitter Banner Config
View realtime-twitter-banner.json
{
"editor": "source",
"widgets": [
{
"data": {
"type": "user"
},
"type": "background"
},
{