Skip to content

Instantly share code, notes, and snippets.

Avatar

Azimov Daler daler445

  • OJSC "Commerce Bank of Tajikistan"
  • Dushanbe, Tajikistan
View GitHub Profile
@daler445
daler445 / Converter.php
Created Oct 13, 2021
Array to object mapper
View Converter.php
<?php
declare(strict_types=1);
class Converter
{
/**
* @param array $array
* @param $object
* @return object
* @throws \RuntimeException
@daler445
daler445 / gist:fd57fc57a22f1653e7c67e40bbc6a63b
Created Feb 10, 2021
Regex to match ipv4 addresses, range and mask
View gist:fd57fc57a22f1653e7c67e40bbc6a63b
^([01]?\d\d?|2[0-4]\d|25[0-5])(?:\.(?:[01]?\d\d?|2[0-4]\d|25[0-5])){3}(?:\/[0-2]\d|\/3[0-2])?(?:\-([01]?\d\d?|2[0-4]\d|25[0-5]))?$
# true
255.255.255.255/30
255.255.255.0
255.255.255.100-200
# false
255.255.255.255/33
255.255.255.256
@daler445
daler445 / Usage.class
Created Jan 27, 2021
Dynamically create links in textview, android
View Usage.class
#
# Credits: https://stackoverflow.com/a/45727769/2679982
#
TextView textView = view.findViewById(R.id.textview);
textView.setText("Dynamically created link");
List<Pair<String, View.OnClickListener>> links = new ArrayList<>();
links.add(new Pair<>(getString(R.string.auth_passport_confirm_agreement_link_label), new View.OnClickListener() {
@Override
@daler445
daler445 / proguard-rules.pro
Created Sep 15, 2020
Android build with minify null pointer exception fix
View proguard-rules.pro
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keep,allowobfuscation @interface com.google.gson.annotations.SerializedName
@daler445
daler445 / gist:fa5bb00b925aa231b34cf37c6b83042d
Created Sep 15, 2020
SSL Pinning hash generator from domain name
View gist:fa5bb00b925aa231b34cf37c6b83042d
openssl s_client -servername example.com -connect example.com:443 | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
@daler445
daler445 / main.java
Created Jun 2, 2020
AES/ECB/PKCS5Padding Example
View main.java
import javax.crypto.*;
import javax.crypto.spec.*;
import java.util.*;
public class main {
public static void main(String[] args) throws Exception {
String keyRaw = "fLVjUa1Sw2Auca6R9VSvLmI0T4OnmgvV";
SecretKeySpec skeySpec = new SecretKeySpec(keyRaw.getBytes(), "AES");
@daler445
daler445 / regex.txt
Last active Apr 6, 2020
Префиксы и регулярные выражения номеров мобильных операторов Республики Таджикистан
View regex.txt
Все номера РТ:
\+{0,1}(992)?(\d{9}$)
Мегафон Таджикистан
(\+)?(992)?((90|88|55|00)\d{7})$
90* ** ****
88* ** ****
55* ** ****
00* ** ****
@daler445
daler445 / functions.php
Created Feb 3, 2020
List wordpress post categories and exclude categories by id
View functions.php
<?php
/**
* Вывод категорий с исключением по id
* @param string $exclude - Список категорий разделенные с запятой
*
* Usage:
* exclude_post_categories("1,2,3")
*/
function exclude_post_categories($exclude = '') {
$categories = get_the_category($post->ID);
@daler445
daler445 / npp.txt
Created Oct 4, 2019
Notepad++ regex to remove everything, but leave numbers (and line breaks)
View npp.txt
Notepad++ regex to remove everything, but leave numbers
[^\d]
Notepad++ regex to remove everything, but leave numbers and line breaks
[^\d\r\n]
@daler445
daler445 / partly-looped.js
Last active Sep 19, 2019
Smart pagination
View partly-looped.js
//Output with default params: 1 14 15 [16] 17 18 25
function generatePagination(url = "#", totalPages = 25, limitPerSide = 2, current = 16, showFirst = true, showLast = true) {
var output = "";
var hasFirst = false;
var hasLast = false;
if ( current === 1 ) {
hasFirst = true;
}