Skip to content

Instantly share code, notes, and snippets.

View Dimanaux's full-sized avatar

Dmitry Barskov Dimanaux

View GitHub Profile
class CollectionDecorator
def self.page(objects_relation, page = 1)
CollectionDecorator.new(objects_relation.order("created_at").page(page))
end
def initialize(objects_relation)
@objects_relation = objects_relation
end
include Enumerable
@Dimanaux
Dimanaux / 00.md
Last active October 29, 2019 20:38

Bugs for dumb.exe

1. При уменьшении размера окна, размер и расположение элементов не меняется, появляются полосы прокрутки

Severity: High

Шаги:

- Запустить приложение, создать новый файл
- Уменьшить размер окна

Ожидаемый результат: Элементы программы занимают всю площадь экрана, уменьшаются пропорционально\

@Dimanaux
Dimanaux / 00.md
Last active October 18, 2019 12:19

При сохранении файла заголовок окна не меняется

ID: 8
Severity: Medium
Версия ListBoxer: 1.89
Модуль: Работа с файлами
01.png
Шаги:

1. Открыть ListBoxer
  1. Добавить элементы в список
@Dimanaux
Dimanaux / Main.java
Created October 14, 2019 14:01
Long arithmetics example, + and * for natural numbers.
import java.util.Scanner;
/**
* Natural numbers here are represented by byte arrays.
* They are stored reversed. Each byte represents decimal digit
* of the number. E. g. 456 = {6, 5, 4}
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
@Dimanaux
Dimanaux / .bashrc
Last active August 20, 2019 05:43
My PS1
export PS1="\[\033[92m\]\u\[\033[00m\]:\[\033[34m\]\w\[\033[00m\]\[\033[31m\] \$(__git_ps1 '(%s)')\[\033[00m\]$ "
@Dimanaux
Dimanaux / HowToFightSpringSecurity.java
Created June 18, 2019 17:17
May be it is an OOP solution
class Account {
private String email;
private String password;
// single method
public UserDetails asDetails() {
return new AccountDetails() {
@Override public String getPassword() {
return Account.this.password;
}
@Dimanaux
Dimanaux / task.erl
Last active February 23, 2019 06:34
Some examples of simple functions in Erlang
-module(task).
-export([words_count/1, count/1, check/1]).
words_count(S) -> iter(0, false, S).
iter(W, _ , [] ) -> W;
iter(W, _ , [32 | Tail]) -> iter(W , false, Tail);
iter(W, false, [_ | Tail]) -> iter(W + 1, true , Tail);
iter(W, _ , [_ | Tail]) -> iter(W , true , Tail).
@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 / max_subarray.py
Created January 25, 2019 06:46
Find the subarray (continuous subsequence) with max sum or its sum
def max_subarray_naive(a: list) -> int:
""" takes O(n^2) time
just sum all of the subarrays
"""
m = a[0] if len(a) > 0 else 0
for i in range(len(a)):
for j in range(i, len(a)):
m = max(m, sum(a[i:j]))
return m
@Dimanaux
Dimanaux / longest_common_subsequence.py
Created January 23, 2019 05:02
How to find longest common subsequence (LCS)
def lcs(a: list, b: list) -> list:
""" finds the longest common subsequence
"""
pass