Skip to content

Instantly share code, notes, and snippets.

@hijarian
hijarian / ffmpeg_cut_video
Created January 6, 2022 00:30 — forked from donis/ffmpeg_cut_video
Cut middle out from some video with ffmpeg
# First we cut the video in how many parts we want
# Step 1. cut the first part of the video and cut it to a separate file
ffmpeg.exe -ss 00:00:00.000 -t 00:02:18.00 -i recording-full.flv -c:v copy -c:a copy recording-full-part1.flv
# Step 2. cut the second part from original video
ffmpeg.exe -ss 00:03:47.000 -i recording-full.flv -c:v copy -c:a copy recording-full-part2.flv
# Step 3. create a file with your cut parts to concat into one video with these contents and name it whatever (i.e. videos.txt):
file 'C:\Path\To\recording-full-part1.flv'
@hijarian
hijarian / elfinder-select-first-uploaded.js
Last active August 29, 2015 14:24
How to select first uploaded file in elfinder
/**
* Handler for 'upload' event.
* That event passes `event` object to its handlers.
*
* This object has `data` object, which contains list of stats for uploaded files under `added` key.
*
* Trick is as follows:
* elfinder lists all files as `div` elements with IDs equal to file "hashes", internal elfinder IDs.
* We get the "hash" of first uploaded element and just double-click on the corresponding `div` element.
*/

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@hijarian
hijarian / gist:4a3b631f7c3e8e68b715
Created March 10, 2015 14:10
Countable iterator and MongoDataModelGenerator
interface CountableIterator extends \Iterator, \Countable { }
class MongoDataModelGenerator implements CountableIterator
{
/** @var MongoCursor */
private $cursor;
/**
* This should be the function accepting array representing mongo document from MongoCursor and returning something else based on it.
<?php
/*
Place this script in the Yii framework folder (yii-x.y.z.rxxx/yii-phar.php) and run it
to package the framework into a single phar file.
In the "index.php" of your application, assuming you placed the packaged framework under
your application's "protected" folder, add the following line at the top:
@hijarian
hijarian / mysql.php
Last active December 15, 2015 04:38
Решение "маленькой" глупой задачки по PHP, где преподаватель на самом деле не понимает, насколько сложную задачу даёт студентам и сколько различных областей знания в ней используются.
<?php
/**
* Форма поиска по заданной таблице в MySQL базе данных.
* Используйте этот скрипт как веб-страницу.
*
* Ожидается таблица следующего вида:
*
* create table `<TABLENAME>` (
* id int primary key auto_increment,
* name varchar(255), index (name),
@hijarian
hijarian / array_null_duplicates
Created March 8, 2013 20:45
В исходном массиве (размер 30 элементов), заполненный цифрами случайным образом, замените все повторные вхождения цифр на 0, а все оставшиеся элементы массива поместить в отдельный массив. Для контроля результата сделайте распечатку массивов, в том числе исходного.
$null_value = 0;
$input = array();
for ($i = 0; $i < 25; ++$i) {
$input[] = mt_rand(1, 10);
}
print_r($input);
$values_to_null = array_diff_key($input, array_unique($input));
foreach ($values_to_null as $key => $value) {
$input[$key] = $null_value;
@hijarian
hijarian / .EMACS
Created September 16, 2011 09:59
My EMACS config at 2011.09.16
;;; Hijarian's .emacs config file
;;; 2011-08-31
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 1: MODES
;;; Enable Viper-mode by default
(setq viper-mode t)
(require 'viper)