Skip to content

Instantly share code, notes, and snippets.

@msr1k
msr1k / combination.js
Last active August 28, 2020 05:40
Get product result of the given arrays (JavaScript)
const a = [ 1, 2, 3, 4 ];
const b = [ 5, 6, 7 ];
const c = [ 8, 9 ];
const d = { a, b, c }
function combinations(aryOfAry) {
const combination = (a1, a2) => {
let a = []
a1.forEach((v1) => {
@msr1k
msr1k / async_queue.hpp
Created July 4, 2019 10:14
C++ async_queue.hpp
#ifndef ASYNC_QUEUE_HPP
#define ASYNC_QUEUE_HPP
#include <condition_variable>
#include <memory>
#include <mutex>
#include <queue>
#include <thread>
// async_queue is an asynchronous queue implementation.
@msr1k
msr1k / .gitconfig
Last active April 17, 2019 20:50
My .gitconfig
[alias]
graph = log --graph --date=format:\"%Y-%m-%d %H:%M\" --pretty=\"format:%C(yellow)%h %C(cyan)%ad %C(green)%an%Creset%C(red)%d %Creset%s\"
g = log --graph --date=format:\"%Y-%m-%d %H:%M\" --pretty=\"format:%C(yellow)%h %C(cyan)%ad %C(green)%an%Creset%C(red)%d %Creset%s\"
ga = log --graph --date=format:\"%Y-%m-%d %H:%M\" --pretty=\"format:%C(yellow)%h %C(cyan)%ad %C(green)%an%Creset%C(red)%d %Creset%s\" --all
d = diff
dc = diff --cached
dn = diff --name-only
dns = diff --name-status
dw = diff --color-words
dcw = diff --cached --color-words
@msr1k
msr1k / lxde-rc.xml
Last active February 27, 2022 03:48
lxde key configuration to tiling windows
<!-- Window tiling key bindings (added) -->
<keybind key="C-A-4"> # HalfLeftScreen
<action name="Unmaximize"/>
<action name="MoveResizeTo"><x>0</x><y>0</y><height>100%</height><width>50%</width></action>
</keybind>
<keybind key="C-A-6"> # HalfRightScreen
<action name="Unmaximize"/>
<action name="MoveResizeTo"><x>50%</x><y>0</y><height>100%</height><width>50%</width></action>
</keybind>
<keybind key="C-A-8"> # HalfUpperScreen
@msr1k
msr1k / a.rb
Last active August 2, 2018 01:31
opal test
class A
native_class if RUBY_ENGINE == 'opal'
def a
puts 'a'
end
native_alias :a, :a if RUBY_ENGIN == 'opal'
end
@msr1k
msr1k / rm_qt_debug_dlls.rb
Created May 10, 2018 10:06
ruby script which deletes all Qt debug version DLLs recursively
dlls = Dir['**/*.dll']
dlls.each do |dll|
debug_version_dll_name = dll.sub(/^(.*)\.dll$/, '\1d.dll')
if dlls.include?(debug_version_dll_name)
puts "Delete #{debug_version_dll_name}"
File.delete(debug_version_dll_name)
end
end
@msr1k
msr1k / mm2txt.rb
Created February 8, 2018 04:17
Convert FreeMind's *.mm file into text
require 'rexml/document'
class Mm2Txt
def self.convert(filename, out=STDOUT)
contents = File.open(filename, 'r', &:read)
doc = REXML::Document.new(contents)
Impl.traverse(0, doc.elements['//map/node'], out)
end
@msr1k
msr1k / anapy.bat
Last active February 1, 2018 04:23
Example batch file which invokes anaconda prompt and execute python script (Windows)
@FOR /F "delims=" %%i IN ('@call "C:\Users\%USERNAME%\AppData\Local\Continuum\Anaconda3\Scripts\conda.exe" ..activate "cmd.exe" %1') DO @SET "NEW_PATH=%%i"
@SET PATH=%NEW_PATH%;%PATH%
python %2
@msr1k
msr1k / anaconda.bat
Created December 25, 2017 04:48
batch file which invoke anaconda prompt
%windir%\system32\cmd.exe "/K" C:\Users\%USERNAME%\AppData\Local\Continuum\Anaconda3\Scripts\activate.bat C:\Users\%USERNAME%\AppData\Local\Continuum\Anaconda3
@msr1k
msr1k / vifmrc
Last active December 20, 2017 07:58
vifmrc
set incsearch
set ignorecase
set smartcase
set wildmenu
set wildstyle=popup
set sortnumbers
nnoremap t tj
nnoremap x :shell<cr>