Skip to content

Instantly share code, notes, and snippets.

View Dimanaux's full-sized avatar

Dmitry Barskov Dimanaux

View GitHub Profile
@Dimanaux
Dimanaux / Subsets.hs
Last active August 29, 2023 09:26
Generating all subsets of a set (list) on Haskell
module Subsets
(
subsets
) where
subsets :: [a] -> [[a]]
subsets [] = [[]]
subsets (x:xs) = subsets xs ++ map (x:) (subsets xs)
@Dimanaux
Dimanaux / BinomailHeap.java
Last active January 25, 2022 18:38
Binomial heap java implementation
package datastructures;
import java.util.Comparator;
public class BinomailHeap<K extends Comparable> {
private Node<K> head;
private int size;
private Comparator<K> comparator;
import java.util.ArrayList;
import java.util.List;
class Main {
public static void main(String[] args) {
System.out.println(
tokenize(
("<html>\n" +
" <h1>content1</h1>\n" +
" <div>\n" +
{
"animation_enabled": false,
"close_windows_when_empty": true,
"default_line_ending": "unix",
"drag_text": false,
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"fallback_encoding": "Cyrillic (Windows 1251)",
"font_face": "JetBrains Mono",
"font_options":
// >= 0, <= 1_000_000
// problem suggests that string can only contain 'million'
// or less -> million can occure only once and it's the whole string
const parseInt = (string) =>
string.includes('million')
? 1000000 : parseMillion(string);
// < 1_000_000
// if we have 'thousand' word in given string,
// split on it and solve parse left, multiply it by 1000
set nocompatible
filetype off
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'flazz/vim-colorschemes'
Plug 'tpope/vim-surround'
call plug#end()
{
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"files.autoSave": "onFocusChange",
"editor.fontFamily": "'JetBrains Mono', Monaco, 'Courier New', monospace",
"editor.wordWrap": "on",
"[ruby]": {
"editor.tabSize": 2
},
"editor.fontLigatures": true,
function git_branch() {
branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
if [[ $branch == "" ]]; then
:
else
echo "$branch "
fi
}
setopt prompt_subst
PROMPT='%B%F{240}%2~%f%b %F{red}$(git_branch)%f%(?.%#.%F{red}%#)%f '

Typical REST API design

Use nouns and ids to represent a resource

// OK
/users/1
/galleries/1/photos/23/comments

// prefer plural nouns, since GET /user Should respond with many users
class Sequence
def initialize(str)
@digits = str.chars.map(&:to_i)
end
def next
new_digits = []
digit_repeats = 1
@digits.each_cons(2) do |prev, curr|
if prev == curr