This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"terminal.integrated.shell.windows": "C:\\WINDOWS\\sysnative\\bash.exe", | |
"workbench.colorTheme": "Ayu Light Bordered", | |
"editor.minimap.enabled": false, | |
"workbench.activityBar.visible": false, | |
"git.ignoreMissingGitWarning": true, | |
"workbench.editor.enablePreview": false, | |
"editor.fontSize": 16, | |
"editor.tabSize": 2, | |
"editor.hover.enabled": false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your key bindings in this file to override the defaults | |
[ | |
{ "key": "ctrl+shift+d", "command": "editor.action.copyLinesDownAction", "when": "editorTextFocus" }, | |
{ "key": "alt+shift+x", "command": "type", "args": { "text": "console.log(" }, }, | |
{ "key": "alt+shift+c", "command": "type", "args": { "text": "/********************************\n\n********************************/" }, }, | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { reducer, UPDATE } from '../util/redux-util' | |
//state | |
export const userState = ({ userReducer: { ...keys } }) => (keys) | |
//dispatch | |
export const userDispatch = (dispatch) => ({ | |
onMount: () => dispatch(mount()), | |
}); | |
//functions | |
export const mount = () => async (dispatch, getState) => { | |
console.log('REDUX: user mount') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//functions | |
const qs = (sel) => document.querySelector(sel) | |
const dhParams = (public) => ({ name: "ECDH", namedCurve: "P-256", public }) | |
const aesParams = (length, counter) => ({ name: "AES-CTR", length, counter }) | |
const keyInt = async(key) => new Uint8Array(await crypto.subtle.exportKey('raw', key)); | |
const derive = async() => await window.crypto.subtle.generateKey(dhParams(), true, ["deriveKey", "deriveBits"]) | |
const deriveAES = async(publicKey, privateKey) => await window.crypto.subtle.deriveKey( | |
dhParams(publicKey), privateKey, aesParams(256), true, ["encrypt", "decrypt"] | |
) | |
const encrypt = async (key, iv, data) => await window.crypto.subtle.encrypt(aesParams(128, iv), key, data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch('http://localhost:8080/test', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({name:'matt', number:34}), | |
// optional | |
// mode: "cors", // no-cors, cors, *same-origin | |
// cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Go to mobile.twitter.com | |
Click following and you should see the followers / following tabs at the top, make sure you're on "following". | |
Open the developer console and paste this bad boy in. | |
You can watch it working away... And stop it anytime by closing the tab. | |
It will start with your most recently followed first and work backwards chronological as it scrolls the accounts you follow. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canBark = (state) => ({ | |
bark:(howManyTimes) => { | |
state.barks += howManyTimes | |
} | |
}) | |
const canEat = (state) => ({ | |
eat:(howMuch) => { | |
state.food -= howMuch | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canBark = (state, howManyTimes) => { | |
state.barks += howManyTimes | |
} | |
const canEat = (state, howMuch) => { | |
state.food -= howMuch | |
} | |
const dog = (name) => { | |
let state = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canBark = (state) => ({ | |
bark:(howManyTimes) => { | |
state.barks += howManyTimes | |
} | |
}) | |
const canEat = (state, howMuch) => { | |
state.food -= howMuch | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//helper function | |
const assignFuncs = (state, funcs) => funcs | |
.map((func) => ({[func.name]: (...args) => func(state, ...args)})) | |
.reduce((acc, func) => ({...acc, ...func})) | |
//example | |
const bark = (state, howManyTimes) => { | |
state.barks += howManyTimes |