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 / 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');
@johanquiroga
johanquiroga / useUndoReducer.js
Last active December 14, 2023 08:52
Undo/Redo capability for any reducer using react hook `useReducer`
import { useReducer } from 'react';
const useUndoReducer = (reducer, initialState) => {
const undoState = {
past: [],
present: initialState,
future: []
};
const undoReducer = (state, action) => {
@jaksm
jaksm / TailwindCSS + PurgeCSS React
Last active January 4, 2023 22:14
Tailwind css and Purge css with create-react-app
Steps to reproduce:
1. npx create-react-app my-app
2. yarn add --dev tailwindcss autoprefixer postcss-cli @fullhuman/postcss-purgecss
3. ./node_modules/.bin/tailwind init tailwind.js
4. touch tailwind.css
5. touch postcss.config.js
6. modify start script in package.json: "node scripts/start.js && postcss ./tailwind.css -o src/App.css -w",
7. modify build script in package.json: "node scripts/build.js && postcss ./tailwind.css -o src/App.css"
@yairEO
yairEO / clearTimeouts.js
Last active November 4, 2022 02:51
Clear all browser timeouts
// isolated layer wrapper (for the local variables)
(function(_W){
var cache = [], // will store all timeouts IDs
_set = _W.setTimeout, // save original reference
_clear = _W.clearTimeout // save original reference
// Wrap original setTimeout with a function
_W.setTimeout = function( CB, duration, arg ){
// also, wrap the callback, so the cache reference will be removed
@forivall
forivall / axios-timing.ts
Last active March 21, 2024 16:38
Axios Timing helper POC
import http = require('http')
import https = require('https')
import url = require('url')
import {AxiosInstance, AxiosInterceptorManager} from 'axios'
import {HttpRequestOptions as HttpFollowRequestOptions, http as httpFollow, https as httpsFollow} from 'follow-redirects'
import now = require('performance-now')
import httpAdapter = require('axios/lib/adapters/http')
import InterceptorManager = require('axios/lib/core/InterceptorManager')
@twmbx
twmbx / vanilla-ajax-poll.js
Last active February 6, 2023 14:57
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!
@JaySpears
JaySpears / webpack.config.js
Created May 8, 2017 16:15
Webpack 2.0 Configuration with React Example
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')
],
@antoniocsoares
antoniocsoares / findDuplicateItemsArrays.js
Last active July 28, 2022 02:28
Find duplicate items in arrays using ES6
// ES6
// Count duplicate items
const names = ['Mike', 'Matt', 'Nancy', 'Adam', 'Jenny', 'Nancy', 'Carl']
const count = names =>
names.reduce((a, b) =>
Object.assign(a, {[b]: (a[b] || 0) + 1}), {})
const duplicates = dict =>
@franciscbalint
franciscbalint / restart_bluetooth.sh
Last active July 19, 2018 12:00 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X/macOS Sierra without restarting
#!/bin/bash
# To run this script you need to give execute permission.
# $chmod +x restart_bluetooth.sh;
# If you want only to restart:
# $ ./restart_bluetooth.sh;
# If you want to turn bluetooth on;
# $ ./restart_bluetooth.sh 1;
# If you want to turn bluetooth off;
# $ ./restart_bluetooth.sh 0;