Skip to content

Instantly share code, notes, and snippets.

@leotop
leotop / download-unzip.php
Created April 4, 2021 15:57 — forked from philipp-r/download-unzip.php
Download and unzip file with PHP
<?php
// get latest german WordPress file
$ch = curl_init();
$source = "https://de.wordpress.org/latest-de_DE.zip";
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
@leotop
leotop / wikipedia-infoboxes-in-pandas.ipynb
Created March 10, 2018 17:08 — forked from aculich/wikipedia-infoboxes-in-pandas.ipynb
How to extract Wikipedia infoboxes and wikitables using Pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leotop
leotop / .htaccess_slash
Created April 25, 2017 23:03 — forked from s2ar/.htaccess_slash
Убрать слеши в htaccess
#Правило обрабатывает внутренние страницы
# http://site.ru/catalog////item///
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
#Проверяем, повторяется ли слеш (//) более двух раз.
RewriteRule . %1/%2 [R=301,L]
#Исключаем все лишние слеши.
#удаляем слеши для главной http://site.ru/////
RewriteCond %{THE_REQUEST} ([^\s]*)\/{2,}(\?[^\s]*)?
RewriteRule (.*) / [R=301,L]
@leotop
leotop / url_slug.js
Created April 24, 2017 10:38 — forked from sgmurphy/url_slug.js
URL Slugs in Javascript (with UTF-8 and Transliteration Support)
/**
* Create a web friendly URL slug from a string.
*
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
@leotop
leotop / .htaccess
Created April 23, 2017 11:02 — forked from loschke/.htaccess
Die optimale .htaccess-Datei für mehr Speed und Sicherheit
# ----------------------------------------------------------------------
# | Komprimierung und Caching |
# ----------------------------------------------------------------------
# Serve resources with far-future expires headers.
#
# (!) If you don't control versioning with filename-based
# cache busting, you should consider lowering the cache times
# to something like one week.
#
@leotop
leotop / Bootstrap-3_Carousel-Collection
Created April 23, 2017 10:50 — forked from loschke/Bootstrap-3_Carousel-Collection
Bootstrap 3 - Carousel Collection Pack
@leotop
leotop / init.php
Created December 29, 2016 11:39
Битрикс отправка сообщений через smtp mail.ru с помощью phpmailer
/**
* Заменяем стандартную отправку письма
*/
function custom_mail($to, $subject, $message, $additional_headers, $additional_parameters) {
$login = 'логин@mail.ru';
$password = 'пароль';
//парсим дополнительные заголовки в массив
$arHeaders = [];
if (!empty($additionalHeaders)) {
@leotop
leotop / init.php
Created December 28, 2016 09:59 — forked from vadim-ontech/init.php
Bitrix custom_mail function with PHPMailer
<?
function custom_mail($to, $subject, $message, $additional_headers, $additional_parameters){
//Получаем тему письма
$elements = imap_mime_header_decode($subject);
$title = '';
for ($i=0; $i<count($elements); $i++) {
$title .= $elements[$i]->text;
}
//В файле PHPMailerAutoload.php на строке 24
@leotop
leotop / suggest.py
Created July 28, 2016 23:46
Пример работы с подсказками DaData на Python. Использует пакет requests (http://docs.python-requests.org/).
# -*- coding: utf-8 -*-
import json
import requests
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/%s'
def suggest(query, resource):
url = BASE_URL % resource
@leotop
leotop / fix-fias.json
Created July 12, 2016 08:36 — forked from dpwiz/fix-fias.json
Импорт DBF ФИАС в PostgreSQL
{
"actstat": {
"convert": {
"actstatid": "int"
}
},
"addrobj": {
"null": [
"actstat",
"nextid",