Skip to content

Instantly share code, notes, and snippets.

View Dimanaux's full-sized avatar

Dmitry Barskov Dimanaux

View GitHub Profile
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" +
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 '
{
"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,
{
"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":

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
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()
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
#include <stdio.h>
void init_encode_context(AVCodecContext* encode_context) {
ctxEncode = avcodec_alloc_context();
ctxEncode->coder_type = 0; // coder = 1
ctxEncode->flags |=CODEC_FLAG_LOOP_FILTER; // flags=+loop
ctxEncode->me_cmp |= 1; // cmp=+chroma, where CHROMA = 1
ctxEncode->partitions |= X264_PART_I8X8+X264_PART_I4X4 + X264_PART_P8X8 + X264_PART_B8X8; // partitions=+parti8x8+parti4x4+partp8x8+partb8x8
ctxEncode->me_method = ME_HEX; // me_method=hex
public class Main {
// declaration: int x;
// initialization: x = 4;
// int x = 4;
public static void main(String[] args) {
int[] array = new int[] {1, 2, 3, 4, 5, 1};
// 1 <= x <= 100; where x from array
// E = exists - if 0 exists in the array
(define (density symbol)
(list-ref
(list 0 (/ 25 100) (/ 55 100) (/ 80 100) (/ 100 100))
symbol))
(define (next-section a b i)
(let ([l (- b a)])
(cons
(+ a (* l (density (- i 1))))
(+ a (* l (density i))))))