Skip to content

Instantly share code, notes, and snippets.

View KarelWintersky's full-sized avatar

Karel Wintersky KarelWintersky

View GitHub Profile
@KarelWintersky
KarelWintersky / Russian Plural Form in PHP
Last active August 15, 2016 05:20 — forked from fomigo/gist:2382775
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}
@KarelWintersky
KarelWintersky / ffmpeg.md
Created August 21, 2016 18:04 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Extract Audio

ffmpeg -i video.mp4 -f mp3 -ab 192000 -vn music.mp3

The -i option in the above command is simple: it is the path to the input file. The second option -f mp3 tells ffmpeg that the ouput is in mp3 format. The third option i.e -ab 192000 tells ffmpeg that we want the output to be encoded at 192Kbps and -vn tells ffmpeg that we dont want video. The last param is the name of the output file.


@KarelWintersky
KarelWintersky / mysql.sh
Created September 6, 2016 16:13 — forked from valerio-bozzolan/mysql.sh
Debian GNU/Linux MySQL-MariaDB autologin
#!/bin/bash
########################################
# MySQL | MariaDB autologin
# License: GNU GPL v3+
# Author: Valerio Bozzolan
########################################
file=/etc/mysql/debian.cnf
while [ -z "$user" ] && read ln; do
@KarelWintersky
KarelWintersky / csv2sql-insert.php
Last active September 13, 2016 02:44
CSV to SQL convertor (insert only).
<?php
$content = '';
if ($_POST["ref"] === "csv2sql") {
// prepare data
$table_name = $_POST["table_name"];
$csv_delimeter = @isset($_POST['DELIMETER']) ?: ',';
$csv_enclosure = @isset($_POST['ENCLOSURE']) ?: '"';
$csv_data = $_POST["csv_data"];
$csv_as_array = explode("\n", $csv_data);
@KarelWintersky
KarelWintersky / echo_status_cli.php
Last active December 16, 2016 18:28
Echo_status_cli() - раскраска вывода в консоли
function echo_status_cli($message = "", $breakline = TRUE)
{
static $fgcolors = array(
'black' => '0;30',
'dark gray' => '1;30',
'blue' => '0;34',
'light blue' => '1;34',
'green' => '0;32',
'light green' => '1;32',
'cyan' => '0;36',

Regular Expression Cheatsheet

Anchors

^   Matches at the start of string or start of line if multi-line mode is
	enabled. Many regex implementations have multi-line mode enabled by
	default.

$ Matches at the end of string or end of line if multi-line mode is enabled.
@KarelWintersky
KarelWintersky / meta-tags.md
Last active February 24, 2017 13:33 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@KarelWintersky
KarelWintersky / uri.js
Created April 2, 2017 04:17 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@KarelWintersky
KarelWintersky / mkstage4.sh
Created June 1, 2017 22:54
Backup script for Gentoo Linux
#!/bin/bash
# Backup script for Gentoo Linux
# Copyright Reto Glauser aka Blinkeye
# Distributed under the terms of the GNU General Public License v2
# Mailto: stage4 at blinkeye dot ch
# Forum post: http://forums.gentoo.org/viewtopic-t-312817.html
# Date: 2005-06-30
version=v3.5
basename=`basename $0`
@KarelWintersky
KarelWintersky / bench.php
Last active June 11, 2017 12:07
PHP Benchmark Performance Script v1.0.6
#!/usr/bin/php
<?php
/*
##########################################################################
# PHP Benchmark Performance Script #
# © 2010 Code24 BV #
# #
# Author : Alessandro Torrisi #
# Author : Sergey Dryabzhinsky #
# Company : Code24 BV, The Netherlands #