Map [1]
Operation | Time Complexity |
---|---|
Access | O(log n) |
Search | O(log n) |
Insertion | O(n) for <= 32 elements, O(log n) for > 32 elements [2] |
Deletion | O(n) for <= 32 elements, O(log n) for > 32 elements |
This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.
I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)
Before trying it out DIY, I considered using:
;;; typescript.el --- typescript support | |
;;; Commentary: | |
;;; Code: | |
(use-package flycheck | |
:ensure t | |
:config | |
(add-hook 'typescript-mode-hook 'flycheck-mode)) | |
(defun setup-tide-mode () |
For a while, JSX
and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.
This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.
web-mode
web-mode
provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.
pm uninstall -k --user 0 com.google.android.apps.tachyon && | |
pm uninstall -k --user 0 com.google.android.music && | |
pm uninstall -k --user 0 com.google.android.apps.docs.editors.sheets && | |
pm uninstall -k --user 0 com.google.android.apps.docs.editors.slides && | |
pm uninstall -k --user 0 com.google.android.apps.docs.editors.docs && | |
pm uninstall -k --user 0 com.google.android.videos && | |
pm uninstall -k --user 0 com.android.gallery3d && | |
pm uninstall -k --user 0 com.android.calendar && | |
pm uninstall -k --user 0 com.evernote && | |
pm uninstall -k --user 0 com.evernote.promohelper && |
<div className='delete-button' onClick={() => { if (window.confirm('Are you sure you wish to delete this item?')) this.onCancel(item) } } /> |
const problem = { | |
start: {A: 5, B: 2}, | |
A: {C: 4, D: 2}, | |
B: {A: 8, D: 7}, | |
C: {D: 6, finish: 3}, | |
D: {finish: 1}, | |
finish: {} | |
}; | |
const lowestCostNode = (costs, processed) => { |
The i3-wm does not come with a keybinding to lock the screen or a preconfigured auto lockscreen. This gist describes how to setup both using i3lock and xautolock. i3lock is a minimalistic lockscreen and xautolock monitors mouse and keyboard activities to automatically lock the screen after a certain time of beiing inactive.
First get the tools if neccessary.
E.g. sudo apt install i3lock xautolock
.
To setup the keybinding Ctrl+Alt+l (last one is a lowercase L) to lock the screen append the following lines to the i3 configuration file located at ~/.config/i3/config
.
# keybinding to lock screen
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce
method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List
is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
#!/bin/bash | |
# Tom Hale, 2016. MIT Licence. | |
# Print out 256 colours, with each number printed in its corresponding colour | |
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163 | |
set -eu # Fail on errors or undeclared variables | |
printable_colours=256 |