Skip to content

Instantly share code, notes, and snippets.

@philipp-r
philipp-r / download-unzip.php
Last active October 20, 2023 13:32
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);
@s2ar
s2ar / .htaccess_slash
Created July 28, 2016 12:21
Убрать слеши в 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]
// Cartesian product of arrays
// @takes N arrays -- arguments *must* be arrays
// @returns an array of X arrays of N elements, X being the product of the input arrays' lengths.
function cartesianProduct(...arrays) {
function _inner(...args) {
if (arguments.length > 1) {
let arr2 = args.pop(); // arr of arrs of elems
let arr1 = args.pop(); // arr of elems
return _inner(...args,
@loschke
loschke / .htaccess
Created February 23, 2016 14:02 — forked from seoagentur-hamburg/.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.
#
@vadim-ontech
vadim-ontech / init.php
Last active August 9, 2021 13:31
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
@loschke
loschke / Bootstrap-3_Carousel-Collection
Last active March 6, 2024 15:31
Bootstrap 3 - Carousel Collection Pack
@sgmurphy
sgmurphy / url_slug.js
Created July 12, 2012 02:05
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>