Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alashov Berkeli alashow

🏠
Working from home
View GitHub Profile
View DateUtil.java
/*
* Copyright 2014. Alashov Berkeli
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
View do-i-wanna-know_TM.txt
Ýaňagyňda reňkler barmy?
Gymyldap bilmejek derejede gorky gördüňmi?
Dişiňde galan zat ýaly, hiç ýere gitmeýän?
Mümkin sende maňa aýdarlyk zadyň bardyr?
Ýüregimde doly ornaşanyňy bileňokdyňmy?
Şu hepde sen barada her gije pikirlendim
Syrlary saklap bilýäňmi?
Umuman, näme üçündir seni ýadyma salýan aýdym tapdym
We men ony ýatyp galýançam gaýta-gaýta diňleýän
Içgilerimi düşegime döküp
View Mover.java
package mover;
import java.io.File;
import java.nio.file.Files;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Moves files to folders with name founded year (4 length number in parenthesis) in file name. Can be used for ordering movie files
* Ex.: file name: The Bourne Identity (2002).mp4
@alashow
alashow / haproxy.cfg
Created Sep 11, 2016 — forked from T0MM0R/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
View haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@alashow
alashow / PrettyIntegers.java
Last active Oct 1, 2016
Convert long integers to "pretty" strings. Could be used for ids in pretty urls
View PrettyIntegers.java
package tm.alashow.playground;
public class PrettyIntegers {
public static void main( String args[] ) {
Character[] map = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K',
'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't',
'u', 'v', 'x', 'y', 'z', '1', '2', '3'};
View U.java
/**
* Part of my utils class that I use in my apps.
* Contains only functions related to showing snackbars and toasts.
* Some string/resources are missing in this gist. Names of resources are self explanatory. Hence, it shouldn't be hard to define it in your resources.
*/
public class U {
public static float density = 1;
public static final int SNACK_DEFAULT = 0;
@alashow
alashow / Fibonacci.java
Last active Oct 2, 2017
Fibonacci in Java using tail call.
View Fibonacci.java
package tm.alashow.homework.datastructures.second;
import java.util.Locale;
import java.util.Scanner;
/**
* Created by alashov on 10/1/17.
*/
public class Fibonacci {
@alashow
alashow / user.js
Last active Mar 19, 2018
Force tumblr posts use hight quality images. Tempermonkey user script.
View user.js
// ==UserScript==
// @name Tumblr image size converter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Force tumblr post photos use high quality
// @author Alashov Berkeli
// @include https://www.tumblr.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js
// @grant none
// ==/UserScript==
View ImageUtils.java
/*
* Copyright (c) 2016 Alashov Berkeli
* It is licensed under GNU GPL v. 2 or later. For full terms see the file LICENSE.
*/
package tm.asmanoky.aziada.util.glide;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
@alashow
alashow / AppViewModelFactory.kt
Last active Apr 1, 2019
ViewModel dynamic parameters hack
View AppViewModelFactory.kt
class AppViewModelFactory @Inject constructor(
private val creators: @JvmSuppressWildcards Map<Class<out ViewModel>, Provider<ViewModel>>
) : ViewModelProvider.Factory {
var onViewModelCreate: ((viewModel: ViewModel) -> Unit)? = null
override fun <T : ViewModel> create(modelClass: Class<T>): T {
var creator: Provider<out ViewModel>? = creators[modelClass]
if (creator == null) {
for ((key, value) in creators) {