Skip to content

Instantly share code, notes, and snippets.

@vavprog
vavprog / index.html
Created January 8, 2025 08:16 — forked from AmirrezaNasiri/index.html
Telegram Share Button in HTML
<!--
This is a simple URL share button for Telegram application.
It's compatible with iOS/Android app, Telegram Desktop and uses its web mode for fallback.
-->
<a href="https://t.me/share/url?url={url_to_share}&text={caption_text}&to={phone_number}">
Share Me
</a>
<!--
/*Вставляем в теле сайта*/
<body>
<a class="btn_telegram_share" href="https://telegram.me/share/url?url=ВАШ_URL&text=ТЕКСТ">Поделиться</a>
</body>
</html>
/*Вставляем CSS стиль*/
$(document).ready(function() { // вся магия после загрузки страницы
$("#ajaxform").submit(function(){ // перехватываем все при событии отправки
var form = $(this); // запишем форму, чтобы потом не было проблем с this
var error = false; // предварительно ошибок нет
form.find('input, textarea').each( function(){ // пробежим по каждому полю в форме
if ($(this).val() == '') { // если находим пустое
alert('Заполните поле "'+$(this).attr('placeholder')+'"!'); // говорим заполняй!
error = true; // ошибка
}
});
@vavprog
vavprog / url_slug.php
Created May 20, 2022 08:29 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* 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>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@vavprog
vavprog / controller.md
Created September 16, 2020 02:16 — forked from themsaid/controller.md
OG post images

require "stil/gd-text": "^1.1",

class ControllerClass extends Controller
{
    public function __invoke($slug)
    {
        $post = WinkPost::where('slug', $slug)->first();
        $quickDip = $post->tags()->whereSlug('quick-dip')->first() ;
@vavprog
vavprog / closetags.php
Created June 5, 2020 05:58 — forked from JayWood/closetags.php
Close ALL open HTML tags in PHP string
<?php
function closetags($html) {
preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
$openedtags = $result[1];
preg_match_all('#</([a-z]+)>#iU', $html, $result);
$closedtags = $result[1];
$len_opened = count($openedtags);
@vavprog
vavprog / KeepUTMRedirect.php
Created February 9, 2020 08:35 — forked from koekaverna/KeepUTMRedirect.php
Laravel middleware that keeps utm marks while redirect
<?php
// This middleware save utm query from url while redirect
// It's require Spatie\Url (https://github.com/spatie/url)
namespace App\Http\Middleware;
use Closure;
use Spatie\Url\Url;
class KeepUTMRedirect
@vavprog
vavprog / beanstalkd.bat
Created January 15, 2020 05:11 — forked from fhferreira/beanstalkd.bat
Use Beanstalkd into Windows
C:\Users\MyUser\Downloads\beanstalkd-1.4.6-cygwin\bin\beanstalkd.exe -l 127.0.0.1 -p 11300
@vavprog
vavprog / parse_utm.js
Created April 30, 2019 05:28 — forked from hunty/parse_utm.js
Парсит UTM метки и подставляет в скрытые поля
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');
@vavprog
vavprog / linkify.php
Created March 25, 2019 08:30 — forked from jasny/linkify.php
PHP function to turn all URLs in clickable links
<?php
/**
* Turn all URLs in clickable links.
*
* @param string $value
* @param array $protocols http/https, ftp, mail, twitter
* @param array $attributes
* @param string $mode normal or all
* @return string
*/