Skip to content

Instantly share code, notes, and snippets.

View sashashakun's full-sized avatar
👋

Alex sashashakun

👋
View GitHub Profile
# Server names consist of an alphabetic host type (e.g. "apibox") concatenated with the server number, with server numbers allocated as before (so "apibox1", "apibox2", etc. are valid hostnames).
# Write a name tracking class with two operations, allocate(host_type) and deallocate(hostname). The former should reserve and return the next available hostname, while the latter should release that hostname back into the pool.
# For example:
# >> tracker = Tracker()
# >> tracker.allocate("apibox")
# "apibox1"
# >> tracker.allocate("apibox")
@sashashakun
sashashakun / stripe.py
Created November 15, 2021 14:53 — forked from stealthbomber10/stripe.py
stripe interview
from collections import defaultdict
import string
# You're running a pool of servers where the servers are numbered sequentially starting from 1. Over time, any given server might explode, in which case its server number is made available for reuse. When a new server is launched, it should be given the lowest available number.
# Write a function which, given the list of currently allocated server numbers, returns the number of the next server to allocate. In addition, you should demonstrate your approach to testing that your function is correct. You may choose to use an existing testing library for your language if you choose, or you may write your own process if you prefer.
# For example, your function should behave something like the following:
# >> next_server_number([5, 3, 1])
@sashashakun
sashashakun / Ruby_finance_testcase.md
Created March 9, 2018 18:39 — forked from beshkenadze/Ruby_finance_testcase.md
Тестовое задание для Ruby-разработчика

Задание

Реализовать на Ruby с использованием Rails приложение со следующим функционалом:

  1. Регистрация / авторизация пользователей.
  2. Создание портфеля акций (5-6 акций достаточно) для пользователя: стандартный CRUD.
  3. Данные должны скачиваться с Yahoo Finance.
  4. Сделать вывод графика "стоимость портфеля от времени" за 2 последних года по выбранным в п.2 акциям.

Требования

@sashashakun
sashashakun / latency.markdown
Created October 11, 2016 08:16 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@sashashakun
sashashakun / what-forces-layout.md
Created April 25, 2016 19:29 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@sashashakun
sashashakun / redux_egghead_notes.md
Created January 5, 2016 11:14 — forked from diegoconcha/redux_egghead_notes.md
Redux Egghead.io Notes

###Redux Egghead Video Notes###

####Introduction:#### Managing state in an application is critical, and is often done haphazardly. Redux provides a state container for JavaScript applications that will help your applications behave consistently.

Redux is an evolution of the ideas presented by Facebook's Flux, avoiding the complexity found in Flux by looking to how applications are built with the Elm language.

####1st principle of Redux:#### Everything that changes in your application including the data and ui options is contained in a single object called the state tree

@sashashakun
sashashakun / springer-free-maths-books.md
Created December 30, 2015 17:56 — forked from bishboria/springer-free-maths-books.md
Springer made a bunch of books available for free, these were the direct links
@sashashakun
sashashakun / CodeReview.md
Created December 24, 2015 16:27 — forked from vladimino/CodeReview.md
Code Review Rules

Я когда делаю Code Review критерии следующие:

  • Безопасность:
    • Каждый аргумент метода простого типа должен проверяться на тип в случае его проксирования и на граничные значения в случае обработки. Чуть что не так - бросается исключение. Если метод с кучкой аргументов на 80% состоит из поверки из аргументов - это вполне норм))
    • Никаких trigger_error, только исключения.
    • Исключения ДОЛЖНЫ быть человеко-понятны, всякие "Something went wrong" можно отдавать пользователю, но в лог должно попасть исключение со стектрейсом и человеко-понятным описанием, что же там пошло не так.
    • Каждый аргумент (объект) метода должен быть с тайпхинтингом на этот его класс, или интерфейс.
    • За eval как правило шлю на **й.
    • @ допускается только в безвыходных ситуациях, например проверка json_last_error.
  • Перед работой с БД - обязательная проверка данных.

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () => x) {