Skip to content

Instantly share code, notes, and snippets.

Avatar
🍺
on a roll

Gleb Bahmutov bahmutov

🍺
on a roll
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am bahmutov on github.
  • I am glebb (https://keybase.io/glebb) on keybase.
  • I have a public key ASBM0WBon-OfVjLsNOuqvrPMbR0HNkjc9zdg42Sxp-K3kQo

To claim this, I am signing this object:

@bahmutov
bahmutov / README.md
Created Jul 24, 2019
Looking at wallclock vs frame timestamp
View README.md

Printing wallclock timestamps and frame timestamps (since common start)

cypress:server:video 1.3989999294281006 frame 1.326711893081665 received screencastFrame +0ms
  cypress:server:video 1.5299999713897705 frame 1.4792709350585938 received screencastFrame +131ms
  cypress:server:video 2.922999858856201 frame 2.340052843093872 received screencastFrame +1s
Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
  cypress:server:video 4.042999982833862 frame 2.4192519187927246 received screencastFrame +1s
  cypress:server:video 4.049000024795532 frame 2.584810972213745 received screencastFrame +7ms

@bahmutov
bahmutov / index.js
Created Aug 10, 2017
Kleisli composition example (JSON parsing + deep property)
View index.js
// following along https://medium.com/@luijar/kliesli-compositions-in-javascript-7e1a7218f0c4
const R = require('ramda')
const Maybe = require('ramda-fantasy').Maybe
// parse JSON string into object
// parse :: String -> Object | Null
function parse(s) {
try {
return JSON.parse(s)
} catch (e) {
@bahmutov
bahmutov / tmux.md
Last active Mar 31, 2017
tmux basics
View tmux.md

install

Install on Mac using brew install tmux and start with tmux

main commands

See help (list of commands) with Control-b ? key combination. Leave help view by pressing q key. From now on use Control-b (aka C-b) to start all tmux commands (C-b is called command prefix and can be changed, see tmux.config options).

@bahmutov
bahmutov / Advanced Rx.md
Created Dec 8, 2016
List of advanced Rx.js topics
View Advanced Rx.md
  • Marble diagrams are awesome and show the streams really well. When you cannot fit them due to space constraints - time to refactor
  • Testing Rx.js code is still hard and requires controlling timing of events. See https://glebbahmutov.com/blog/testing-reactive-code/
  • Reactive is all about controlling sequence of events. A simple operation might be take

In its first form it just takes N items s.take(2) which creates second stream with first 2 events from s and the completes. But what happens if you don't know how many items to take? Maybe there is a condition, a simple function that operates on the event data and/or global state that tells when to stop taking items. In this case takeWhile is useful s.takeWhile(x => x < 10)

@bahmutov
bahmutov / README.md
Last active Sep 27, 2018
Loading multiple service workers
View README.md

Imagine I want to separate caching for offline support from other features. I would load first service worker to cache index.html and static resources in /static and would load second service worker to do other things.

<script>
    if ('serviceWorker' in navigator) {
      console.log('page is registering two service workers')
      // one.js should cache index.html and /static folder
      navigator.serviceWorker.register('one.js', {scope: './'})
@bahmutov
bahmutov / Security tools.md
Last active Aug 11, 2018
Websites that can check your site's security
View Security tools.md
@bahmutov
bahmutov / ImageMagick.md
Last active May 14, 2016
My common ImageMagick commands
View ImageMagick.md

ImageMagick commands

Image information

identify <image>

Resize an image

@bahmutov
bahmutov / dynamic-spec.js
Last active Apr 7, 2016
Grid of individual tests
View dynamic-spec.js
// if our data is more complicated and has to form things from items for example
// just pass around list of functions
const API = {
github: (username) => 'http://github.com/' + username,
photo: (username) => `http://github.com/${username}/avatar/`
}
const users = ['bahmutov', 'adity']
Object.keys(API).forEach((apiName) => {
const formApiUrl = API[apiName]
describe('api ' + apiName, () => {
You can’t perform that action at this time.