Skip to content

Instantly share code, notes, and snippets.

Avatar
:atom:
Building react apps & micro-services

Andrew Hart AndrewJHart

:atom:
Building react apps & micro-services
View GitHub Profile
View es6-convert-map-to-object.js
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 — forked from revolunet/python-es6-comparison.md
# Python VS JavaScript ES6 syntax comparison
View python-es6-comparison.md

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 Apr 24, 2022 — forked from nornagon/1-intro.md
How to make a Minecraft (1.8) mod
View 1-intro.md

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 Apr 21, 2022 — forked from zmts/update-build.md
Auto update application build version. Husky pre-commit hook.
View update-build.md

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 Jan 10, 2022
Netflix Delete/Remove/Cleanup Your List: Simple Script to drop in browser to tidy up your queue/list of movies
View netflix-remove-my-list.js
/**
* 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 Sep 4, 2019 — 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 )
View vanilla-ajax-poll.js
// 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 Feb 19, 2018 — forked from markerikson/react-controlled-inputs.md
React "controlled" vs "uncontrolled" inputs explanation
View react-controlled-inputs.md

[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 Nov 28, 2017 — 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)
View restart_bluetooth.sh
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
@AndrewJHart
AndrewJHart / remerge.py
Created Oct 17, 2017 — forked from mahmoud/remerge.py
Recursively merging dictionaries with boltons.iterutils.remap. Useful for @hynek's configs. https://twitter.com/hynek/status/696720593002041345
View remerge.py
"""
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.
"""
@AndrewJHart
AndrewJHart / webpack.config.js
Created May 8, 2017 — forked from JaySpears/webpack.config.js
Webpack 2.0 Configuration with React Example
View webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:3000/',
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'app/index')
],