| /** | |
| * 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'); |
| import { useReducer } from 'react'; | |
| const useUndoReducer = (reducer, initialState) => { | |
| const undoState = { | |
| past: [], | |
| present: initialState, | |
| future: [] | |
| }; | |
| const undoReducer = (state, action) => { |
| // 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 |
| 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') |
| // 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! |
| 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') | |
| ], |
| // 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 => |
| #!/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; |
[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