Skip to content

Instantly share code, notes, and snippets.

View isRuslan's full-sized avatar

Ruslan Ismagilov isRuslan

  • Yandex
  • Russia, Moscow
View GitHub Profile
const timeout = (ms) => new Promise(resolve => setTimeout(resolve, ms))
function getJob(ms, id) {
return async function () {
return job(ms, id)
}
}
async function job(ms, id) {
await timeout(ms)
@isRuslan
isRuslan / conf.ngx
Created December 17, 2018 04:09
Nginx active check
upstream zen_zen-front_production_splitter {
keepalive 2;
server [2a02:06b8:0c00:3b10:0000:1452:7fb3:1e24]:80 max_fails=0 fail_timeout=60 weight=1;
server [2a02:06b8:0c08:f427:0000:1452:005d:5634]:80 max_fails=0 fail_timeout=60 weight=1;
check interval=5000 rise=2 fall=3 timeout=2000 default_down=false type=http;
check_http_send "GET /ok.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
match statusok {
@isRuslan
isRuslan / test.java
Created November 22, 2018 12:23
Опросник на java джуниора
Думаю, очень круто было бы в начале предупредить, что знание тонкостей языка не так важно,
как умение размышлять и делать разумные предположения
1. Immutable strings
String a = "hello ";
String b = a;
a = a + "world!";
System.out.println(b);

Learn Regex


What is Regular Expression?

Regular expression is a group of characters or symbols which is used to find a specific pattern from a text.

A regular expression is a pattern that is matched against a subject string from left to right. The word "Regular expression" is a

@isRuslan
isRuslan / quickselect.py
Created May 10, 2017 21:14
QuickSelect finds the kth smallest element of an array in linear time.
'''
QuickSelect finds the kth smallest element of an array in linear time.
'''
def partition(arr):
left = []
right = []
if not arr:
return (left, right, None)
'''
Given an array of integers containing duplicates, return the majority element in an array if present. A majority element appears more than n/2 times where n is the size of the array.
'''
def find_leader(arr):
'''
1. remove pairs of different elements from array
2. the element that still exists is a candidate
3. check majority of candidate, should be in len(arr) // 2 elements
'''
@isRuslan
isRuslan / Makefile
Created March 24, 2017 19:19
Make boilerplate
CXX = g++-4.9
CC = gcc-4.9
DOXYGEN = doxygen
CFLAGS = -fdiagnostics-color=always -std=gnu11 -s -c -g3 -O3 -time
WARNINGS = -Werror -Wall -Wextra -pedantic-errors -Wformat=2 -Wno-import -Wimplicit -Wmain -Wchar-subscripts -Wsequence-point -Wmissing-braces -Wparentheses -Winit-self -Wswitch-enum -Wstrict-aliasing=2 -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wdisabled-optimization -Wunused-macros -Wno-unused
LDFLAGS =
LIBRARIES = -lcurl
SOURCES = main.c test.c
OBJECTS = $(SOURCES:.c=.o)
EXECUTABLE = test
@isRuslan
isRuslan / commit-msg
Last active March 20, 2017 09:37
.git/hooks/commit-msg
#!/bin/sh
#
# Automatically add branch name and branch description to every commit message except merge commit.
#
COMMIT_EDITMSG=$1
addBranchName() {
BRANCH=$(git branch | grep '*' | sed 's/* //')
NAME=$(echo "$BRANCH" | sed -E 's/([A-Z]+-[0-9]+(--[A-Z]+-[0-9]+)?).*/\1/')
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@isRuslan
isRuslan / main.go
Last active February 6, 2017 20:20
Destributed redis lock in golang
package main
import (
"flag"
"github.com/garyburd/redigo/redis"
"log"
"math/rand"
"os"
"time"
)