View mysql.php
<?php | |
class Mysql{ | |
static private $link = null; | |
static private $info = array( | |
'last_query' => null, | |
'num_rows' => null, | |
'insert_id' => null | |
); |
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", |
View MySQL.php
<?php | |
class Mysql | |
{ | |
private $link = null; | |
private $info = array( | |
'last_query' => null, | |
'num_rows' => null, | |
'insert_id' => null | |
); |
View pdf2jpg.sh
#!/bin/bash | |
# Script to convert PDF file to JPG images | |
# | |
# Dependencies: | |
# * pdftk | |
# * imagemagick | |
PDF=$1 |
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'); |
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); | |
} |
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) |
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 |
NewerOlder