$ docker
const { google } = require('googleapis'); | |
const fs = require('fs'); | |
const credentials = require('./credentials.json'); | |
const scopes = [ | |
'https://www.googleapis.com/auth/drive', | |
'https://www.googleapis.com/auth/spreadsheets', | |
]; |
export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`); | |
export const wsObserver = ws | |
.pipe( | |
retryWhen(errors => | |
errors.pipe( | |
delay(1000) | |
) | |
) | |
); |
upload(files) { | |
const config = { | |
onUploadProgress: function(progressEvent) { | |
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total) | |
console.log(percentCompleted) | |
} | |
} | |
let data = new FormData() | |
data.append('file', files[0]) |
import React from "react" | |
import { Route, Switch } from "react-router-dom" | |
const AppRoute = ({ component: Component, layout: Layout, ...rest }) => ( | |
<Route {...rest} render={props => ( | |
<Layout> | |
<Component {...props} /> | |
</Layout> | |
)} /> | |
) |
import sys | |
from PIL import Image | |
from math import pi,sin,cos,tan,atan2,hypot,floor | |
from numpy import clip | |
# get x,y,z coords from out image pixels coords | |
# i,j are pixel coords | |
# face is face number | |
# edge is edge length | |
def outImgToXYZ(i,j,face,edge): |
// copy-pasta'd from isarray | |
var toString = {}.toString; | |
const isArray = Array.isArray || function (arr) { | |
return toString.call(arr) == '[object Array]'; | |
}; | |
export function batchedSubscribe() { | |
let currentListeners = []; |
#Understanding closures, callbacks and promises
For a code newbie like myself, callbacks, closures and promises are scary JavaScript concepts.
10 months into my full-time dev career, and I would struggle to explain these words to a peer.
So I decided it was time to face my fears, and try to get my head around each concept.
Here are the notes from my initial reading. I'll continue to refine them as my understanding improves.
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent