Skip to content

Instantly share code, notes, and snippets.

View mlesikov's full-sized avatar
😀

Mihail Lesikov mlesikov

😀
View GitHub Profile

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@mlesikov
mlesikov / IsraeliID.Validator.js
Created March 31, 2020 16:11 — forked from freak4pc/IsraeliID.Validator.js
Israeli ID Validator (Javascript)
function isValidIsraeliID(id) {
var id = String(id).trim();
if (id.length > 9 || id.length < 5 || isNaN(id)) return false;
// Pad string with zeros up to 9 digits
id = id.length < 9 ? ("00000000" + id).slice(-9) : id;
return Array
.from(id, Number)
.reduce((counter, digit, i) => {
@mlesikov
mlesikov / example.md
Created March 12, 2020 11:18 — forked from devdrops/example.md
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯
@mlesikov
mlesikov / mysql-docker.sh
Created March 12, 2020 10:27 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@mlesikov
mlesikov / docker-compose.yaml
Created March 12, 2020 09:56
example microservices docker-compose.yaml
version: '3'
services:
rabbitmq:
image: rabbitmq:3.5.3-management
ports:
- "5672:5672"
- "15672:15672"
mongodb:
@mlesikov
mlesikov / GotenbergKClientTest.kt
Last active October 18, 2019 07:19
Gottenberg simple Kotlin http client. Using google-http-client.
package com.clouway.tools.clients
import com.google.api.client.http.ByteArrayContent
import com.google.api.client.http.GenericUrl
import com.google.api.client.http.HttpHeaders
import com.google.api.client.http.HttpMediaType
import com.google.api.client.http.MultipartContent
import com.google.api.client.http.javanet.NetHttpTransport
import org.junit.Test
import java.io.File
@mlesikov
mlesikov / gist:bf093f8491a88455fde4f68e5854e845
Created July 26, 2019 08:27
Kotlin find max temp city - single row definition
data class City(val temp:Double)
class Utility {
fun maxTemp(cities: List<City>?): City = cities?.maxBy { it.temp }?: throw IllegalArgumentException("param cities should not be null or empty!")
}
//extension funciton - maxBy is integrated in Kotlin by default
fun List<City>.maxTemp(): City = this.maxBy { it.temp }?: throw IllegalArgumentException("param cities should not be null or empty!")
@Test
fix for hotkeys not functional in non-latin keyboard layout in 13.10 / 14.04
tested on ubuntu 14.04, jvm7 and rubymine 6.3
sudo add-apt-repository ppa:attente/java-non-latin-shortcuts
sudo apt-get update
sudo apt-get dist-upgrade
restart unity-settings-daemon
now ctrl+c, ctrl-v etc should work in most java applications like IDEA, RubyMine IDE even on russian keyboard layout
'use strict';
angular
.module('datetimepicker', [])
.provider('datetimepicker', function () {
var default_options = {};
this.setOptions = function (options) {
default_options = options;
@mlesikov
mlesikov / ShardedSequence.java
Created August 9, 2018 07:49 — forked from cilogi/ShardedSequence.java
A sharded sequence generator for App Engine. Useful for a short URL generator
import com.google.appengine.api.datastore.*;
import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.MemcacheServiceFactory;
import com.google.common.collect.ImmutableMap;
import java.util.ConcurrentModificationException;
import java.util.Map;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;