Skip to content

Instantly share code, notes, and snippets.

hijarian / elfinder-select-first-uploaded.js
Last active Aug 29, 2015
How to select first uploaded file in elfinder
View elfinder-select-first-uploaded.js
* 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

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. do their work at read-time.

hijarian / gist:4a3b631f7c3e8e68b715
Created Mar 10, 2015
Countable iterator and MongoDataModelGenerator
View gist:4a3b631f7c3e8e68b715
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.
View yii-phar.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 / mysql.php
Last active Dec 15, 2015
Решение "маленькой" глупой задачки по PHP, где преподаватель на самом деле не понимает, насколько сложную задачу даёт студентам и сколько различных областей знания в ней используются.
View mysql.php
* Форма поиска по заданной таблице в MySQL базе данных.
* Используйте этот скрипт как веб-страницу.
* Ожидается таблица следующего вида:
* create table `<TABLENAME>` (
* id int primary key auto_increment,
* name varchar(255), index (name),
hijarian / array_null_duplicates
Created Mar 8, 2013
В исходном массиве (размер 30 элементов), заполненный цифрами случайным образом, замените все повторные вхождения цифр на 0, а все оставшиеся элементы массива поместить в отдельный массив. Для контроля результата сделайте распечатку массивов, в том числе исходного.
View array_null_duplicates
$null_value = 0;
$input = array();
for ($i = 0; $i < 25; ++$i) {
$input[] = mt_rand(1, 10);
$values_to_null = array_diff_key($input, array_unique($input));
foreach ($values_to_null as $key => $value) {
$input[$key] = $null_value;
hijarian / .EMACS
Created Sep 16, 2011
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)