Skip to content

Instantly share code, notes, and snippets.

@vbarinov
vbarinov / alacritty.yml
Created January 31, 2020 16:34
my Alacirtty MacOS cfg
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
#env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
@vbarinov
vbarinov / Javascript-Russian-Knowledge-NOTE.md
Created September 24, 2018 15:21 — forked from edtoken/Javascript-Russian-Knowledge-NOTE.md
Javascript Russian Knowledge NOTE

Posts

https://egghead.io/
https://github.com/trekhleb/javascript-algorithms
https://habr.com/post/359192/ алгоритмы на js все
https://www.youtube.com/watch?v=j4_9BZezSUA event loop
https://fseby.wordpress.com/2016/02/25/практическая-вводная-в-монады-в-javascript/
https://habrahabr.ru/company/mailru/blog/327522/   (Функциональное программирование в JavaScript с практическими примерами)
https://habrahabr.ru/post/298134/ (FizzBuzz, или почему программисты не умеют программировать)     http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2nd-edition-rus/ (всякое общее)
https://medium.com/@frontman/приведение-типов-в-js-9d6f1845ea96   (приведение типов и др. инфа)  

@vbarinov
vbarinov / node-on-ec2-port-80.md
Created April 27, 2017 20:06 — forked from kentbrew/node-on-ec2-port-80.md
How I Got Node.js Talking on EC2's Port 80

The Problem

Standard practices say no non-root process gets to talk to the Internet on a port less than 1024. How, then, could I get Node talking on port 80 on EC2? (I wanted it to go as fast as possible and use the smallest possible share of my teeny tiny little micro-instance's resources, so proxying through nginx or Apache seemed suboptimal.)

The temptingly easy but ultimately wrong solution:

Alter the port the script talks to from 8000 to 80:

}).listen(80);

Structure

CREATE TABLE teacher(
	id INT(10) PRIMARY KEY NOT NULL AUTO_INCREMENT,
	name VARCHAR(100) NOT NULL
);

CREATE TABLE student(
	id INT(10) PRIMARY KEY NOT NULL AUTO_INCREMENT,
@vbarinov
vbarinov / coins_change.php
Created April 10, 2017 05:05
Монеты: проблема сдачи с данными номиналами
<?php
/**
* Первый подход (неверный), пытаемся погасить остаток максимальным номиналом
*
* O(m), m - колич. монет
*
* @return bool
*/
function canPayWithoutChangeBrute($sum, array $denominations)
{
@vbarinov
vbarinov / unfold-config-keys.php
Created March 29, 2017 09:42
Parse ini-style configuration with compound keys in PHP. Cycle vs recursion
<?php
// Recursion splitting: 0.0020239353179932 sec
// Cycle splitting: 0.001431941986084 sec
// Recursion splitting: 0.000885009765625 sec
// Cycle splitting: 0.00057697296142578 sec
$i = <<<INI
db.user.name = vasya
@vbarinov
vbarinov / quickSort.js
Created March 20, 2017 11:36
Quick sort javascript
/**
* Quick sort algorithm
* Complexity: O(n log n) to O(n) - depends on a pivot selection
*/
function quickSort(arr) {
var pivotIndex,
pivot,
left = [],
right = [],
len = arr.length;
@vbarinov
vbarinov / newhost.sh
Created September 30, 2016 10:42
Useful script for adding new nginx hosts
#!/bin/bash
### Set Language
TEXTDOMAIN=virtualhost
### Set default parameters
action=$1
domain=$2
rootDir=$3
owner=$(who am i | awk '{print $1}')
sitesEnable='/etc/nginx/sites-enabled/'
javascript:window.setInterval(function(){var c=$("#box span:first-child").css("background-color"),o=$("#box span:nth-child(2)").css("background-color");c!=o&&$("#box span:first-child").click(),$("#box span").each(function(){var o=$(this).css("background-color");return c!=o?($(this).click(),!1):void(c=o)})},10);