Skip to content

Instantly share code, notes, and snippets.

View AndrewJHart's full-sized avatar
:atom:
Building react apps & micro-services

Andrew Hart AndrewJHart

:atom:
Building react apps & micro-services
View GitHub Profile
@AndrewJHart
AndrewJHart / react-markdown-external-links.js
Last active January 3, 2024 20:43
react-markdown w/ rehype-external-links for opening markdown links in a new tab
@AndrewJHart
AndrewJHart / es6-convert-map-to-object.js
Last active May 11, 2022 00:49 — forked from lukehorvat/es6-map-to-object-literal.js
Convert ES6 Map to Object Literal
let map = new Map();
map.set("a", 1);
map.set("b", 2);
map.set("c", 3);
let obj = [...map.entries()] // or Array.from(map) - either works;
.reduce((acc, [key, value]) =>
({ ...acc, [key]: value }), // Can also spread in reduce or assign, latter is quicker but I love spread syntax lol
{}
);
@AndrewJHart
AndrewJHart / python-es6-comparison.md
Created May 1, 2022 21:37 — forked from revolunet/python-es6-comparison.md
# Python VS JavaScript ES6 syntax comparison

Python VS ES6 syntax comparison

Python syntax here : 2.7 - online REPL

Javascript ES6 via Babel transpilation - online REPL

Imports

import math
@AndrewJHart
AndrewJHart / 1-intro.md
Created April 24, 2022 20:58 — forked from nornagon/1-intro.md
How to make a Minecraft (1.8) mod

How to make a Minecraft mod

Minecraft mods, especially mods which change the client, are by and large written with Forge. If you visit their website, you'll be greeted abruptly by a mysterious message at the top of an SMF forum, with no clear path towards actually... making a mod. I'm documenting here the steps I went through to get started, in the hopes of helping the next person have an easier time of it.

I'll be using Scala for this guide, but it should be fairly easy to adapt these instructions to any JVM language (e.g. clojure or if you're feeling masochistic, Java). I'm also developing on OS X, so some of the commands will be a little different if you're on Linux or Windows. I'm assuming you have some proficiency with your operating system, so I won't go into details about how to adapt those commands to your system.

Background

Minecraft doesn't have an official mod API (despite early [promises](http://notch.t

@AndrewJHart
AndrewJHart / update-build.md
Created April 21, 2022 23:58 — forked from zmts/update-build.md
Auto update application build version. Husky pre-commit hook.

Auto update application build version. Husky pre-commit hook.

package.json

"husky": {
    "hooks": {
      "pre-commit": "npm run build && node ./update-build.js"
    }
  }
@AndrewJHart
AndrewJHart / netflix-remove-my-list.js
Last active August 20, 2023 16:27
Netflix Delete/Remove/Cleanup Your List: Simple Script to drop in browser to tidy up your queue/list of movies
/**
* You can copy and paste this into your browser console and it works as of 1/1/2021 - its not pretty.
*/
// replace "user-id" with your actual user id e.g. "123455" & same for auth url
const userId = 'my-user-id-goes-here';
const authUrl = 'auth-url-goes-here';
// first gather up all the DOM nodes in the list that have anchors w/ the title id to delete
const nodes = document.querySelectorAll('.rowList .title > a');
@AndrewJHart
AndrewJHart / vanilla-ajax-poll.js
Created September 4, 2019 17:44 — forked from twmbx/vanilla-ajax-poll.js
Polling in JS with an async ajax call that returns a promise ( modified from: https://davidwalsh.name/javascript-polling )
// The polling function
function poll(fn, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
var checkCondition = function(resolve, reject) {
var ajax = fn();
// dive into the ajax promise
ajax.then( function(response){
// If the condition is met, we're done!
@AndrewJHart
AndrewJHart / react-controlled-inputs.md
Created February 19, 2018 20:53 — forked from markerikson/react-controlled-inputs.md
React "controlled" vs "uncontrolled" inputs explanation

[12:03 AM] acemarke: "controlled" and "uncontrolled" inputs
[12:04 AM] acemarke: if I have a plain, normal HTML page, and I put <input id="myTextbox" type="text" /> in my page(edited)
[12:04 AM] acemarke: and I start typing into that textbox
[12:04 AM] acemarke: it remembers what I've typed. The browser stores the current value for that input
[12:05 AM] acemarke: and then sometime later, I can get the actual element, say, const input = document.getElementById("myTextbox"), and I can ask it for its value: const currentText = input.value;
[12:05 AM] acemarke: good so far?
[12:08 AM] acemarke: I'll keep going, and let me know if you have questions
[12:08 AM] lozio: ok, actually I'm reading
[12:09 AM] lozio: good
[12:09 AM] acemarke: so, a normal HTML input field effectively stores its own value at all times, and you can get the element and ask for its value

@AndrewJHart
AndrewJHart / restart_bluetooth.sh
Last active November 28, 2017 18:28 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X without restarting - this also works when the UI does not (preferences or menu bar)
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@AndrewJHart
AndrewJHart / remerge.py
Created October 17, 2017 18:42 — forked from mahmoud/remerge.py
Recursively merging dictionaries with boltons.iterutils.remap. Useful for @hynek's configs. https://twitter.com/hynek/status/696720593002041345
"""
This is an extension of the technique first detailed here:
http://sedimental.org/remap.html#add_common_keys
In short, it calls remap on each container, back to front, using the accumulating
previous values as the default for the current iteration.
"""