Skip to content

Instantly share code, notes, and snippets.

View YaroslavB's full-sized avatar
🏠
Working from home

YaroslavB YaroslavB

🏠
Working from home
  • Kiev/Ukraine
View GitHub Profile
@YaroslavB
YaroslavB / ffmpeg.md
Created March 30, 2021 07:57 — forked from Orangestar12/ffmpeg.md
quick ffmpeg cheat sheet

These are a few quick easy ffmpeg command lines that can be used to make oft-used video formats. I use them a lot so I wrote them down in a txt file but I converted it to markdown to upload here and access on all my pcs.

Feel free to use 'em. I've gathered them through superuser posts, wiki trawls, and personal experience.

General notes

  • Add -movflags faststart to make mp4 files have their headers at the beginning of the file, allowing them to be streamed (i.e. played even if only part of the file is downloaded).
  • The MP4 container supports MP3 files, so if libfdk_aac isnt available (it's the only good AAC enc) use libmp3lame.
    • Update: unless you're uploading them to Twitter. Twitter doesn't like MP4 files with MP3 audio. Fall back to AAC and provide a higher quality alternative somewhere else.
  • For MP4 files, use -preset X to use MP4 enc presets, like slow or superfast. (veryfast or fast is ok)
<?php
/****************** удаляем из массива ******************/
//массив из которого нужно удалить
$letters = array('(', ')', '[', ']', '{', '}','h', 'r','ff');
//массив данных, которые не трогаем
$no_delete = array('(', ')', '[', ']', '{', '}');
foreach($letters_new as $key => $char){
<?php
/**************
класс чтения и записе csv файла
***************/
/**********************
Иногда при просмотре csv файла в эксель, выходит странная кодровка. Дело не в самой кодировки файла, а в отсутствие одной опции.
fprintf ( $ fp , chr ( 0xEF ). chr ( 0xBB ). chr ( 0xBF ));
В общем виде выглядит это так
$fp = fopen("путь", 'r+');
//https://impuls-web.ru/css-xaki-kak-zadat-css-stili-dlya-raznyx-brauzerov/
/* стили для мозилы */
_:-moz-any-link, :root .new_wid{width: 70% !important;}
/* стили для хрома */
_:-webkit-any-link, :root .new_wid{width: 70% !important;}
/**** стили для разных размеров окна браузера ***/
@media screen and (min-width: 1628px){
.ting-product__text{
/************ выделения пункта меню при активном якоре **************/
//http://jsfiddle.net/bonilka/p7sgwg4L/
<script>
jQuery(window).scroll(function(){
var $sections = $('div');
$sections.each(function(i,el){
var top = $(el).offset().top-100;
var bottom = top +$(el).height();
var scroll = $(window).scrollTop();
var id = $(el).attr('id');
/************
скрыть/показать пароль
без всяких крутых вещей. Главный принцип
**************/
<input type="password" id="password">
<input type="checkbox" onchange="document.getElementById('password').type = this.checked ? 'text' : 'password'"> Show password
// и второй вариант. На Jquery пока не переделал
$('.show-key').click(function() {
document.getElementById('api_key').type = "text";
@YaroslavB
YaroslavB / guidGenerator.php
Created March 30, 2021 07:23
generate - guid token
<?php
function guidGenerator()
{
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
@YaroslavB
YaroslavB / uuidGenerator.php
Last active March 30, 2021 07:20
simple uuid token generator
<?php
function uuidGenerator(){
$bytes = random_bytes(16);
$bytes[6] = chr((ord($bytes[6]) & 0x0f) | 0x40);
$bytes[8] = chr((ord($bytes[8]) & 0x3f) | 0x80);
$hex = bin2hex($bytes);
$fields = [
'time_low' => substr($hex, 0, 8),
'time_mid' => substr($hex, 8, 4),
'time_hi_and_version' => substr($hex, 12, 4),
@YaroslavB
YaroslavB / parse-xml.php
Created March 4, 2021 17:19 — forked from stojg/parse-xml.php
Parsing a huge XML with closure in PHP
<?php
// Open the XML
$handle = fopen('file.xml', 'r');
// Get the nodestring incrementally from the xml file by defining a callback
// In this case using a anon function.
nodeStringFromXMLFile($handle, '<item>', '</item>', function($nodeText){
// Transform the XMLString into an array and
print_r(getArrayFromXMLString($nodeText));
@YaroslavB
YaroslavB / hosts.ps1
Created February 3, 2021 11:31 — forked from markembling/hosts.ps1
Powershell script for adding/removing/viewing entries to the hosts file.
#
# Powershell script for adding/removing/showing entries to the hosts file.
#
# Known limitations:
# - does not handle entries with comments afterwards ("<ip> <host> # comment")
#
$file = "C:\Windows\System32\drivers\etc\hosts"
function add-host([string]$filename, [string]$ip, [string]$hostname) {