Skip to content

Instantly share code, notes, and snippets.

View unclechu's full-sized avatar

Viacheslav Lotsmanov unclechu

  • RELEX Solutions
  • Finland
View GitHub Profile
@unclechu
unclechu / package.json
Created October 13, 2016 16:08
webpack config example
{
"main": "app/index.html",
"scripts": {
"webpack": "node_modules/.bin/webpack",
"webpack-dev-server": "node_modules/.bin/webpack-dev-server",
"clean": "rm -rf ./app/",
"bundle": "env NODE_ENV=development webpack --progress --colors",
"bundleprod": "env NODE_ENV=production webpack --progress --colors",
"devserver": "npm run clean && env NODE_ENV=development webpack-dev-server --progress --colors --inline --open --host localhost --port 8000 --watch",
"rebuild": "npm run clean && npm run bundle",
@unclechu
unclechu / init.vim
Last active October 17, 2016 21:01
vim-gitgutter issue: vim-gitgutter sets `&shell` to `sh` and doesn't set it to origial value ( https://github.com/airblade/vim-gitgutter/issues/379 )
filetype off
set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin("~/.config/nvim/bundle")
Plugin 'VundleVim/Vundle.vim', {'pinned': 1}
Plugin 'airblade/vim-gitgutter'
call vundle#end()
filetype plugin indent on
@unclechu
unclechu / previous-tab-after-current-closed.vim
Created October 20, 2016 09:28
Vim: Go to previous tab after current tab closed
function! s:PreviousTab_StoreState()
let s:tab_current = tabpagenr()
let s:tab_last = tabpagenr('$')
endfunction
function! s:PreviousTab_TabClosed()
if s:tab_current > 1 && s:tab_current < s:tab_last
exec 'tabp'
endif
endfunction
autocmd TabEnter,TabLeave * call s:PreviousTab_StoreState()
@unclechu
unclechu / unite-all-menu-source.vim
Last active October 20, 2016 20:29
Vim: Unite plugin: 'menu' source: Solution to merge all child elements from all groups to single group
let s:u_all = []
let s:u_max_prefix_length = 0
for [k, v] in items(g:unite_source_menu_menus)
if s:u_max_prefix_length < len(v.description)
let s:u_max_prefix_length = len(v.description)
endif
for item in v.command_candidates
call add(s:u_all, [v.description, item[0], item[1]])
endfor
endfor
@unclechu
unclechu / inf-random-list.hs
Created October 25, 2016 18:26
Haskell: infinite list of random numbers to 'pure' function as an argument
module Main where
import System.Random (newStdGen, randomRs)
someFunc salts x =
map mapper $ take 20 salts
where mapper = (+ x) . floor . (* 10)
main :: IO ()
main = do
@unclechu
unclechu / pareset.sh
Created December 3, 2016 02:38
pareset.sh
#!/bin/bash
# reset devices outputs volumes
pactl list sinks short | awk '{print $2}' | xargs -I {} pactl set-sink-volume '{}' 0db
# reset devices inputs volumes
pactl list sources short | awk '{print $2}' | xargs -I {} pactl set-source-volume '{}' 0db
# reset applications outputs volumes
pactl list sink-inputs short | awk '{print $1}' | xargs -I {} pactl set-sink-input-volume '{}' 0db
# reset applications inputs volumes
@unclechu
unclechu / breakable-composition.hs
Last active December 18, 2016 20:24
Haskell: breakable composition experiments
#!/usr/bin/env stack
-- stack runghc --resolver lts-7.7 --install-ghc --package data-default-0.7.1.1 --package interpolatedstring-perl6-1.0.0 --package transformers-0.5.2.0 --package either-4.4.1.1
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE PackageImports #-}
import "base" Data.Either (Either(Left, Right), either)
import "interpolatedstring-perl6" Text.InterpolatedString.Perl6 (qc)
import "data-default" Data.Default (Default, def)
@unclechu
unclechu / either-state-t-combined.hs
Created January 9, 2017 01:20
either-state-t-combined.hs
#!/usr/bin/env stack
-- stack runghc --resolver lts-7.7 --install-ghc --package interpolatedstring-perl6 --package transformers --package either --package mtl --package lens
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
@unclechu
unclechu / polymorphic-lens-type.hs
Created January 9, 2017 20:38
polymorphic-lens-type.hs
#!/usr/bin/env stack
-- stack runghc --resolver lts-7.7 --install-ghc --package lens
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RankNTypes #-}
-- that's what I was looking for,
-- thanks to 'shachaf' from #haskell-lens on Freenode IRC.
{-# LANGUAGE NoMonomorphismRestriction #-}
@unclechu
unclechu / cursor-to-display.sh
Last active February 2, 2017 19:11
cursor-to-display.sh
#!/bin/bash
exec 0<&-
displays=$(
xrandr --current \
| grep -oP '(?! )(\d+)x(\d+)\+(\d+)\+(\d+)' \
| sed 's/[x+]/ /g'
)
[ $? -ne 0 ] && { echo 'Error while getting displays info' 1>&2; exit 1; }