Skip to content

Instantly share code, notes, and snippets.

View daler445's full-sized avatar

Azimov Daler daler445

View GitHub Profile
@daler445
daler445 / Converter.php
Created October 13, 2021 05:34
Array to object mapper
<?php
declare(strict_types=1);
class Converter
{
/**
* @param array $array
* @param $object
* @return object
* @throws \RuntimeException
@daler445
daler445 / add_text_to_copy.html
Created May 17, 2018 14:17
add text to copied text with styles
<!doctype html>
<html>
<head>
<title>Playground</title>
<script type='text/javascript'>
function getSelectionHtml() {
var html = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
@daler445
daler445 / gist:fd57fc57a22f1653e7c67e40bbc6a63b
Created February 10, 2021 04:39
Regex to match ipv4 addresses, range and mask
^([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 January 27, 2021 12:31
Dynamically create links in textview, android
#
# 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 September 15, 2020 06:27
Android build with minify null pointer exception fix
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-keep,allowobfuscation @interface com.google.gson.annotations.SerializedName
@daler445
daler445 / gist:fa5bb00b925aa231b34cf37c6b83042d
Created September 15, 2020 03:20
SSL Pinning hash generator from domain name
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 June 2, 2020 08:26
AES/ECB/PKCS5Padding Example
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 April 6, 2020 07:53
Префиксы и регулярные выражения номеров мобильных операторов Республики Таджикистан
Все номера РТ:
\+{0,1}(992)?(\d{9}$)
Мегафон Таджикистан
(\+)?(992)?((90|88|55|00)\d{7})$
90* ** ****
88* ** ****
55* ** ****
00* ** ****
@daler445
daler445 / functions.php
Created February 3, 2020 05:21
List wordpress post categories and exclude categories by id
<?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 October 4, 2019 11:36
Notepad++ regex to remove everything, but leave numbers (and line breaks)
Notepad++ regex to remove everything, but leave numbers
[^\d]
Notepad++ regex to remove everything, but leave numbers and line breaks
[^\d\r\n]