Skip to content

Instantly share code, notes, and snippets.

View f3ath's full-sized avatar
🐴
I am most seriously displeased.

Alexey f3ath

🐴
I am most seriously displeased.
View GitHub Profile
@f3ath
f3ath / 1.php
Created December 24, 2016 08:13
<?php
namespace F3\Changelog;
use Composer\Semver\Semver;
use F3\Changelog\Exception\NoTagsFound;
use F3\Changelog\Exception\TagNotFound;
class ReleaseNotes
{
/**
@f3ath
f3ath / zadachka.php
Last active January 14, 2017 14:19
<?php
$actionList = [
'action-1' => "Начало дня",
'action-2' => "Поднимаюсь с кровати с левой ноги",
'action-3' => "Поднимаюсь с кровати с правой ноги",
'action-4' => "Падаю с кровати",
'action-5' => "Пробежка по аллее",
'action-6' => "Физ. зарядка на балконе",
'action-7' => "Варю крепкий кофе",
function longest_ones_sequence(m) {
for (
var r = m.length - 1, c = m[0].length - 1;
r >= 0 && c >= 0;
m[r][c] === '1' ? c-- : r--
);
return m[0].length - c - 1;
}
console.log(
function TreeBuilder() {
var makeEmptyNode = function() {
return {
"_items": []
};
};
var root = makeEmptyNode();
@f3ath
f3ath / naming.php
Last active January 29, 2017 07:31
#!/usr/bin/env php
<?php
require_once __DIR__ . '/vendor/autoload.php';
$renamedClasses = (new NamespacePrefixAdder())
->addPrefix(
'MyPrefix',
Files::inDirectories(['src', 'test'])
);
/*
Баг в initializeIdAndName
1. Подумать, что в программе неправильно.
2. Вынести реализацию метода initializeIdAndName в класс User.
3. initializeIdAndName в классе User должен возвращать тип User.
4. Поправить программу, чтобы компилировалась и работала.
Такой код изначальный.
*/
function interpret(code) {
if (code.length == 0) return '';
const machine = new (function(code) {
var x = 0;
var y = 0;
var dir = 'r';
var stack = [];
var out = '';
var skipNextMove= false;
/*
Count the number of equivalence classes in an equivalence relation.
*/
function EqRelation(len) {
let parent = [];
for (let i = 0; i < len; i++) parent.push(i);
const root = function(x) {
while (x !== parent[x]) x = parent[x];
return x;
@f3ath
f3ath / inheritance-vs-composition.md
Created March 16, 2017 00:39
inheritance-vs-composition.md

inheritance-vs-composition.md

  1. Design the object model for a currency conversion library. Assume you're working for a bank which allows its clients to deposit money into their USD account. Customers have cash in different currencies and want to know the amount in USD which will be added to their account. You want to create a library for a widget which calculates the resulting amount in USD.
    UI looks like this:
[Currency name] [Amount] 
[Currency name] [Amount] 
[+] 
… 
[Resulting amount in USD]