Skip to content

Instantly share code, notes, and snippets.

<?php
function addWordHyphenation(string $str) {
$l = [
'all' => "[абвгдеёжзийклмнопрстуфхцчшщъыьэюя]",
'glas' => "[аеёиоуыэю\я]",
'sogl' => "[бвгджзклмнпрстфхцчшщ]",
'zn' => "[йъь]",
'shy' => "&shy;",
];
$re = [];
@dbevdev
dbevdev / .htaccess
Created June 14, 2021 16:20
.htaccess redirects
# SEO URL Settings
RewriteEngine On
# Redirect from www to non-www(https)
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Redirect from http to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@dbevdev
dbevdev / zshrc
Last active March 31, 2020 06:41
Useful Docker Bash functions and aliases
# ------------------------------------
# Docker alias and function
# https://github.com/tcnksm/docker-alias
# ------------------------------------
# Get latest container ID
alias dl="docker ps -l -q"
# Get container process
alias dps="docker ps"
@dbevdev
dbevdev / thisLine.js
Created March 17, 2020 12:44
Get filepath, line, column of where a function is called in Node, Chrome
const thisLine = () => {
const e = new Error();
const regex = /\((.*):(\d+):(\d+)\)$/
const match = regex.exec(e.stack.split("\n")[2]);
return {
filepath: match[1],
line: match[2],
column: match[3]
};
}
@dbevdev
dbevdev / .htaccess
Created November 1, 2019 21:12
Apache redirects from www\http to https://site.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
@dbevdev
dbevdev / .htaccess
Created August 26, 2019 09:01
.htaccess common redirects
# SEO URL Settings
RewriteEngine On
# Redirect from www to non-www(https)
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Redirect from http to https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
@dbevdev
dbevdev / preprint_php.sublime-snippet
Last active April 22, 2019 07:52
Pretty debug output in php
<snippet>
<content><![CDATA[
echo '<pre>'; print_r($1); echo '</pre>';
]]></content>
<tabTrigger>preprint</tabTrigger>
<scope>source.php</scope>
</snippet>
@dbevdev
dbevdev / decrement_letters.php
Last active April 12, 2019 17:22
Decrementing an alphabetical value in php
<?php
function decrement_letters($str) {
$letters = str_split($str);
$c = count($letters);
if ($c === 1) {
$letters[0] = $letters[0] === 'A' ? 'A' : chr(ord($letters[$c-1]) - 1);
} elseif($letters[$c-1] !== 'A') {
$letters[$c-1] = chr(ord($letters[$c-1]) - 1);
@dbevdev
dbevdev / YoutubeDownloader.md
Created December 9, 2018 10:03 — forked from sheharyarn/YoutubeDownloader.md
Download Videos from Youtube in (Ruby || PHP)

Youtube Downloaders

Download Youtube Videos using Ruby or PHP

Just copy the appropriate script, provide the video_id and run. It will list download links for different qualities and streams.

:P

@dbevdev
dbevdev / youtubeID.js
Created December 9, 2018 08:55 — forked from takien/youtubeID.js
Get YouTube ID from various YouTube URL using JavaScript
/**
* Get YouTube ID from various YouTube URL
* @author: takien
* @url: http://takien.com
* For PHP YouTube parser, go here http://takien.com/864
*/
function YouTubeGetID(url){
var ID = '';
url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);