Skip to content

Instantly share code, notes, and snippets.

View jougene's full-sized avatar
🎼
Focusing

Eugene Sinitsyn jougene

🎼
Focusing
View GitHub Profile
// PATCH
if (column.default !== undefined) {
expression_1 += this.connection.driver.normalizeDefault(column);
} else {
// sqlite
if (_this.connection.driver instanceof AbstractSqliteDriver_1.AbstractSqliteDriver) {
expression_1 += "NULL"
// not sqlite
} else {
@jougene
jougene / parse.sh
Created April 29, 2019 17:56
Bash parse yaml
function parse_yaml {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\):|\1|" \
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
const splitByPairs = (x) => {
const pairsCount = x.length - 1;
return new Array(pairsCount).fill().map((index, val) => x.substr(val, 2));
};
const digitsCount = (digit, number) => number.split('').filter(num => num == digit).length;
const dec2bin = (dec) => { return (dec >>> 0).toString(2) };
@jougene
jougene / reverse.clj
Created November 12, 2017 13:45
clojure reverse list
(fn [l]
((fn [l acc]
(if (empty? l)
acc
(recur (rest l) (conj acc (first l)))))
l `()))
@jougene
jougene / bubble.php
Last active April 13, 2017 08:23
sort algorithms
<?php
// it is just a inversed version of bubble sort
// and elements dive to the dhische instead of go up like a bubble
function bubbleSort(&$array) {
$n = count($array);
for($j = 0; $j < $n; $j++) {
// inner loop
for($i = $n; $i > $j + 1; $i--) {
error_reporting(E_ALL);
ini_set('display_errors', 1);
function divide($a, $b)
{
    $divisor = $b;
    if ($b > $a) {
        return 0;
    }

    $res = 1;
 while (($b + $b) &lt;= $a) {
function mulByAdd(a, b) {
	var iter = function (res, a, b) {
		if (b == 0) {
			return res;
		}
		if (b % 2 == 0) {
			return iter(res, a << 1, b >> 1)
		}
 return iter(res + a, a, b - 1)
<?php

$contacts = [
    [
        'id'        => 1,
        'name'      => 'OAO Vorkuta',
        'parent_id' => null
    ],
    [

#Задача

Сколько нужно кирпичей, чтобы построить комнату размером A x B x C. Где:

  • A - высота комнаты,
  • B - ширина комнаты,
  • C - длина комнаты.

Размера комнаты задаются в метрах. Толщина стены комнаты - 1 кирпич. Размеры комнаты кратны размерам кирпича, то есть не получится так, что стена будет состоять не из целого количества кирпичей. Толщиной цемента пренебрежем, и учтем что ширина кирпича вдвое меньше его длины.