Skip to content

Instantly share code, notes, and snippets.

Alexey Samoshkin samoshkin

Block or report user

Report or block samoshkin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View es-versions-and-features.md
@samoshkin
samoshkin / vimrc-merge.vim
Created May 7, 2019
Test vimrc configuration to turn Vim into a mergetool
View vimrc-merge.vim
set nocompatible
filetype plugin indent on
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
set number
set hidden
set splitbelow
set splitright
@samoshkin
samoshkin / difftool_vimrc.vim
Created Apr 30, 2019
Test vimrc configuration to turn Vim into a difftool
View difftool_vimrc.vim
set nocompatible
filetype plugin indent on
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab
set number
set hidden
set splitbelow
set splitright
@samoshkin
samoshkin / env.sh
Created Apr 18, 2019
fzf configuration snippet
View env.sh
# Exclude those directories even if not listed in .gitignore, or if .gitignore is missing
FD_OPTIONS="--follow --exclude .git --exclude node_modules"
# Change behavior of fzf dialogue
export FZF_DEFAULT_OPTS="--no-mouse --height 50% -1 --reverse --multi --inline-info --preview='[[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -300' --preview-window='right:hidden:wrap' --bind='f3:execute(bat --style=numbers {} || less -f {}),f2:toggle-preview,ctrl-d:half-page-down,ctrl-u:half-page-up,ctrl-a:select-all+accept,ctrl-y:execute-silent(echo {+} | pbcopy)'"
# Change find backend
# Use 'git ls-files' when inside GIT repo, or fd otherwise
export FZF_DEFAULT_COMMAND="git ls-files --cached --others --exclude-standard | fd --type f --type l $FD_OPTIONS"
@samoshkin
samoshkin / convert2voice.sh
Last active Apr 1, 2019
Google Text-to-Speech API example
View convert2voice.sh
#!/bin/bash
text=$(cat -)
request="{
'input':{
'ssml':'<speak>$text</speak>'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Wavenet-D',
@samoshkin
samoshkin / postman_vs_insomnia_comparison.md
Created Nov 6, 2018
Comparison of API development environments: Postman vs Insomnia
View postman_vs_insomnia_comparison.md

Postman vs Insomnia comparison

Postman | API Development Environment https://www.getpostman.com
Insomnia REST Client - https://insomnia.rest/

Features                                        Insomnia Postman Notes
Create and send HTTP requests x x
Authorization header helpers x x Can create "Authorization" header for you for different authentication schemes: Basic, Digest, OAuth, Bearer Token, HAWK, AWS
@samoshkin
samoshkin / fetch_vs_xhr.md
Created Nov 1, 2018
Fetch API features and limitations
View fetch_vs_xhr.md

XHR limitations and drawbacks:

  • more complicated API, request and response concepts are mixed together.
  • lacks streaming, whole response is going to buffer in memory, not available for binary data

Fetch API features and pros:

  1. more pleasant simpler API. Has Request and Response abstractions, can be used separately (for example in ServiceWorkers). Based on Promises.
  2. supports streaming, response.body is ReadableStream, you can read data chunk by chunk without buffering, available for binary data. Can access partial content while response is being received.
  3. has cache control support (default, no-store, reload, no-cache, force-cache, only-if-cached)
@samoshkin
samoshkin / systemjs-builder-code-splitting.js
Created Jan 19, 2018
Create common,vendor and several entry point bundles using systemjs-builder
View systemjs-builder-code-splitting.js
let Builder = require('systemjs-builder');
let fs = require('fs');
let mapValues = require('lodash/mapValues');
let config = {
baseURL: '.',
map: {
'vendor': 'lib/vendor'
}
};
@samoshkin
samoshkin / es6-symbol-toprimitive.js
Created Jan 17, 2018
ES6 replace default object-to-primitive conversion logic using Symbol.toPrimitive method
View es6-symbol-toprimitive.js
class Disk {
constructor(capacity){
this.capacity = capacity;
}
[Symbol.toPrimitive](hint){
switch (hint) {
case 'string':
return 'Capacity: ' + this.capacity + ' bytes';
@samoshkin
samoshkin / es5-toprimitive-hooks.js
Created Jan 17, 2018
Custom toString() and valueOf() methods
View es5-toprimitive-hooks.js
var obj = {
prop: 101,
toString(){
return 'Prop: ' + this.prop;
},
valueOf() {
return this.prop;
}
};
You can’t perform that action at this time.