Skip to content

Instantly share code, notes, and snippets.

Avatar

Artem Ledzz

  • Russia, Kazan
View GitHub Profile
View generate-svg-icons.js
const fs = require('fs');
fs.readFile('./sprite.svg', 'utf8', (err, data) => {
const regex = /<symbol id='([^']+)' viewBox='([^']+)'>(.*?)<\/symbol>/gs;
const outputDir = './icons';
let match;
const matches = [];
while ((match = regex.exec(data)) !== null) {
const [symbol, name, viewBox, content] = match;
View ios-drag-drop.ts
const coordinateSystemForElementFromPoint = navigator.userAgent.match(/OS [1-4](?:_\d+)+ like Mac/) ? "page" : "client";
let doc = document;
function onEvt(el, event, handler, context) {
if(context) {
handler = handler.bind(context);
}
el.addEventListener(event, handler);
return {
off: function() {
return el.removeEventListener(event, handler);
View phpmailer-smtp.php
<?
$mail = new PHPMailer;
// $mail->SMTPDebug = 3; Раскомментировать, чтобы увидеть отладочные сообщения
$mail->setFrom('email@sender.ru', 'Sender name');
$mail->addAddress('email@reciever.ru');
$mail->Host = 'smtp.host.com';
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'usename'; // SMTP username
$mail->Password = 'password';
View backup_db.php
<?php
// https://github.com/tazotodua/useful-php-scripts
//optional: 5th parameter - backup specific tables only: array("mytable1","mytable2",...)
//optional: 6th parameter - backup filename
// NOTE! to adequatelly replace strings in DB, MUST READ: goo.gl/2fZDQL
function EXPORT_TABLES($host,$user,$pass,$name, $tables=false, $backup_name=false){
set_time_limit(3000); $mysqli = new mysqli($host,$user,$pass,$name); $mysqli->select_db($name); $mysqli->query("SET NAMES 'utf8'");
$queryTables = $mysqli->query('SHOW TABLES'); while($row = $queryTables->fetch_row()) { $target_tables[] = $row[0]; } if($tables !== false) { $target_tables = array_intersect( $target_tables, $tables); }
$content = "SET SQL_MODE = \"NO_AUTO_VALUE_ON_ZERO\";\r\nSET time_zone = \"+00:00\";\r\n\r\n\r\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\r\n/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;\r\n/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;\r\n/*!401
@Ledzz
Ledzz / jquery.redraw.js
Created Aug 26, 2016
$.redraw function
View jquery.redraw.js
(function() {
$.fn.redraw = function(){
$(this).each(function(){
var redraw = this.offsetHeight;
});
};
})();
@Ledzz
Ledzz / transitionEnd.js
Created Aug 26, 2016
transitionEnd polyfill
View transitionEnd.js
(function(){
function transitionEndEventName() {
var i,
el = document.createElement('div'),
transitions = {
'transition':'transitionend',
'OTransition':'otransitionend', // oTransitionEnd in very old Opera
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
};
@Ledzz
Ledzz / zip.php
Created Aug 26, 2016
Creates archive
View zip.php
<?php
/*
*
* This script will backup your web site by remotely archiving all files on the root FTP directory.
* It will work even if your web server is memory limited buy splitting zips in several arhive files it they are too many files.
* All zip files will be stored in a directory called temporary which must be writable.
*
* How to use it:
* - Place the script at the root of your FTP.
You can’t perform that action at this time.