Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
eat sleep code repeat

ildar r. khasanshin ildarkhasanshin

🚀
eat sleep code repeat
View GitHub Profile
@ildarkhasanshin
ildarkhasanshin / translit.php
Created Jan 19, 2020 — forked from danillab/translit.php
Транслит для Яндекса
View translit.php
<?php
function translit($str) {
$tr = array("а"=>"a","б"=>"b","в"=>"v","г"=>"g","д"=>"d","е"=>"e","ё"=>"e","ж"=>"j","з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l","м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r","с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h","ц"=>"c","ч"=>"ch","ш"=>"sh","щ"=>"shh","ъ"=>"","ы"=>"y","ь"=>"","э"=>"e","ю"=>"u","я"=>"ya","—"=>"-","«"=>"","»"=>"","…"=>""," "=>"-","№"=>"#");
$str = mb_strtolower($str,'utf-8');
// $str = preg_replace("/\s+/",' ',$str);
$str = strtr(trim($str), $tr);
$str = trim(preg_replace("/\-+/",'-',$str),'- ');
$str = preg_replace('~[^a-z0-9/-]~', '', $str);
return $str;
View translit.php
function translit_str( $str, $maxLength = 100, $encode = 'utf-8' ) {
$tr = array(
"А" => "a",
"Б" => "b",
"В" => "v",
"Г" => "g",
"Д" => "d",
"Е" => "e",
"Ё" => "yo",
"Ж" => "zh",
@ildarkhasanshin
ildarkhasanshin / MySQL.php
Last active Apr 3, 2020 — forked from NabilNoN/MySQL.php
Simple PHP MYSQLi Class
View MySQL.php
<?php
class Mysql
{
private $link = null;
private $info = array(
'last_query' => null,
'num_rows' => null,
'insert_id' => null
);
@ildarkhasanshin
ildarkhasanshin / pdf2jpg.sh
Created Sep 1, 2019 — forked from yura/pdf2jpg.sh
script to PDF to JPG using pdftk and imagemagick
View pdf2jpg.sh
#!/bin/bash
# Script to convert PDF file to JPG images
#
# Dependencies:
# * pdftk
# * imagemagick
PDF=$1
@ildarkhasanshin
ildarkhasanshin / parse_utm.js
Created Aug 5, 2019 — forked from hunty/parse_utm.js
Парсит UTM метки и подставляет в скрытые поля
View parse_utm.js
window.onload = function() {
// Parse the URL
function getParameterByName(name) {
var name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Give the URL parameters variable names
var source = getParameterByName('utm_source');
@ildarkhasanshin
ildarkhasanshin / gist:3aad191fb1da668e7eeeffeff147fca6
Created Apr 8, 2019 — forked from reinink/gist:1467201
Example of how to parse HTML document with phpQuery
View gist:3aad191fb1da668e7eeeffeff147fca6
<?php
// Include the phpQuery library
// Download at http://code.google.com/p/phpquery/
include 'phpQuery.php';
// Load Mike Fisher's player page on thescore.com
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.thescore.com/nhl/player_profiles/859-mike-fisher');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
View php-strings-class.php
<?php
namespace System;
// простая функция для создания экземпляра класса
function strs($php_string) {
return new Strings($php_string);
}
@ildarkhasanshin
ildarkhasanshin / password.py
Created Jan 27, 2019 — forked from DOKL57/password.py
Генератор паролей Python
View password.py
import random
num = input('login ')
pas = ''
for x in range(16): #Количество символов (16)
pas = pas + random.choice(list('1234567890abcdefghigklmnopqrstuvyxwzABCDEFGHIGKLMNOPQRSTUVYXWZ')) #Символы, из которых будет составлен пароль
print('Hello, ', num, 'your password is: ', pas)
@ildarkhasanshin
ildarkhasanshin / .htaccess
Created Jan 2, 2019 — forked from lukecav/.htaccess
Apache - Browser caching and mod_deflate for WordPress
View .htaccess
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/schema+json
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
@ildarkhasanshin
ildarkhasanshin / .htaccess
Created Jan 2, 2019 — forked from lukecav/.htaccess
Apache mod_expires for WordPress
View .htaccess
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault “access plus 1 month”
ExpiresByType text/html "access plus 2 hours"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/js "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
You can’t perform that action at this time.