Skip to content

Instantly share code, notes, and snippets.

View barbagrigia's full-sized avatar

Vlad Trukhin barbagrigia

View GitHub Profile
@barbagrigia
barbagrigia / Problem.md
Created July 11, 2016 14:36 — forked from Centaur/Problem.md
Scala vs Clojure

Treat or Trick

Everyone knows what Halloween is and how children love it. Children in costumes travel from house to house asking for treats with a phrase "Trick or treat". After that, they divide the treats equally among all. This year, they collected tons of candies, and need your help to share everything equally. You know that children receive different number of candies depending on their costume: vampire gets 3 candies from one house, zombie – 4 candies, and witch – 5 candies. That is, three children in three different costumes get 3+4+5=12 candies from one house.

Input sample:

The first argument is a path to a file. Each line includes a test case with number of vampires, zombies, witches, and houses that they visited.

For example:

Надстройка над вирт.машиной.
Позволяет с помощью заранее подготовленных инструкций развернуть подобие серверного окружения на своей локальной машине
!VirtualBox - самая последняя тестовая версия.
!Если не запускается вм при vagrant up - переименовать файл uxtheme.dll.backup->uxtheme.dll ( C:\Windows\System32 )
!Чтобы получить ssh доступ нужно ключ прогнать через puttyGen
# Комманды:
vagrant init [boxName] - инициализировать vagrant [на основе бокса]
@barbagrigia
barbagrigia / Mongo.md
Last active May 18, 2024 09:06
заметки об MongoDB по мотивам курса https://university.mongodb.com/courses/M101P

MongoDB — кросс-платформенная, документо-ориентированная NoSQL система управления базами данных с открытым исходным кодом.

CRUD в MongoDB

Сопоставление CRUD операций и соответствующих им команд в MongoDB и SQL.

CRUD Mongo SQL
Create Insert Insert
Read Find Select
Update Update Update
@barbagrigia
barbagrigia / insertion_sort.py
Created October 29, 2016 19:47
Python - sort algorithms
# -*- coding: utf-8 -*-
from random import randint
from sys import argv
try:
k = int(argv[1])
s = int(argv[2])
except:
k = 10
s = 1
;; from db
(def coll [{:id 1 :name ""}
{:id 2 :name "item 1" :parent 1}
{:id 3 :name "item 2" :parent 1}
{:id 4 :name "item 3" :parent 2}
{:id 5 :name "item 4" :parent 2}
{:id 6 :name "item 5" :parent 2}
{:id 7 :name "item 6" :parent 4}])
;; требуемый json
function __fish_git_in_working_tree
[ "true" = (git rev-parse --is-inside-work-tree ^ /dev/null; or echo false) ]
end
function __fish_git_dirty
not git diff --no-ext-diff --quiet --exit-code ^ /dev/null
or not git diff-index --cached --quiet HEAD ^ /dev/null
or count (git ls-files --others --exclude-standard) > /dev/null
end
# Useful functions {{{
function ..
cd ..
end
function ...
cd ../..
end
@barbagrigia
barbagrigia / app.js
Created November 15, 2016 23:19 — forked from roman01la/app.js
Minimal setup for efficient state management and rendering in React with single atom state
import React from 'react';
import { render } from 'react-dom';
import Root from './components/root.jsx';
import { silentSwap } from './lib/atom';
import { fromJS } from 'immutable';
import './stores/ui';
const initialState = {
ui: {
@barbagrigia
barbagrigia / react-native-stylesheet.cljs
Created November 15, 2016 23:20 — forked from roman01la/react-native-stylesheet.cljs
Access React Native compiled styles map using Clojure's keywords.
(def stylesheet (.-StyleSheet ReactNative))
(defn create-stylesheet [styles]
(->> styles
(clj->js)
(.create stylesheet)
(js->clj)
(clojure.walk/keywordize-keys)))
; usage
import React, { Component } from 'react';
import {
PixelRatio,
View,
TextInput,
Text,
StyleSheet,
PropTypes
} from 'react-native';