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 / 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 / Page-Transitions-in-Backbone.markdown
Last active March 9, 2023 20:40
Simple and elegant Backbone.js View Animations and Transitions for web and hybrid mobile apps. A Pen by Andrew J Hart.

Backbone.View Page Transitions in Backbone

An easy and effective way to implement page transitions into any Backbone.js application. Its been tested with Thorax by extending Thorax.View and tested with Marionette with various ways to implement it. There are also many other various attempts at animations/transitions with marionette that can be found on its issues page.

This originated from an idea and quest for a clean way to create a simple yet reusable animated backbone view. I found an excellent post by Mike Fowler titled Page Transitions in Backbone that provided a large part of the core and concept.

@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 / jwt_authentication.py
Created April 13, 2016 18:47
JWT authentication middleware for django rest framework that populates the request.user object
from django.utils.functional import SimpleLazyObject
from django.contrib.auth.models import AnonymousUser
from rest_framework.request import Request
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
def get_user_jwt(request):
"""
Replacement for django session auth get_user & auth.get_user for
@AndrewJHart
AndrewJHart / Node-streams-demystified.md
Last active January 20, 2020 07:46 — forked from joyrexus/README.md
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified

Overview

Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.

@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!