Skip to content

Instantly share code, notes, and snippets.

View Philosoft's full-sized avatar

Aleksandr Frolov Philosoft

View GitHub Profile
/*
* List directories using getdents() because ls, find and Python libraries
* use readdir() which is slower (but uses getdents() underneath.
*
* Compile with
* ]$ gcc getdents.c -o getdents
*/
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>

➜ theme git:(master) ✗ cil intimtime.ru

HTTP/1.0 200 OK
Date: Mon, 18 Sep 2017 08:07:15 GMT
Server: Apache/2.2.22 (Debian)
X-Powered-By: PHP/5.6.30-1~dotdeb+7.1
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: Mon, 18 Sep 2017 08:07:15 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
<?php
return [
"doctrine" => [
"connection" => [
"orm_default" => [
"driverClass" => 'Doctrine\DBAL\Driver\PDOPgSql\Driver',
"params" => [
"host" => "localhost",
"port" => 5433, // non standard port
// <a href="#" data-next-title="spart"></a>
$("a").data("title"); // read
$("a").data("title", "new title"); // write
@Philosoft
Philosoft / replace-first.sql
Last active March 28, 2017 06:10
replace first occurence of substring in string mysql
SET @string = 'this is TEST string with AA replace and An Answer';
SELECT @string as actual_string,
CONCAT(
REPLACE(
LEFT(
@string,
INSTR(@string, 'TEST') + LENGTH('TEST') - 1
),
'TEST',
'WTF'
<?php
$dir = new RecursiveDirectoryIterator(__DIR__);
$iter = new RecursiveIteratorIterator($dir);
$regex = new RegexIterator($iter, '#^.*index\.php$#i', RecursiveRegexIterator::GET_MATCH);
foreach ($regex as $fileArray) {
echo $fileArray[0] . PHP_EOL;
}
<?php
namespace app\web\theme\module;
use Yii;
use yii\base\Module;
use yii\base\BootstrapInterface;
/**
* Class ThemeModule is the Module class for your Theme and site-specific functions
* @package app\web\theme\module
@Philosoft
Philosoft / aliases.php
Created December 16, 2015 05:49
Default aliases for dotplant2
<?php
/*
* ! WARNING !
*
* This file is auto-generated.
* Please don't modify it by-hand or all your changes can be lost.
*/
@Philosoft
Philosoft / catalog.md
Last active December 14, 2015 20:57
Много директорий на dotplant2

Чего мы хотим добится?

Вывода категорий и подкатегорий, как вот здесь http://www.atlant1.ru/catalog

Как?

Регистрируем новую вьюху

Свойства - представления - добавить

@Philosoft
Philosoft / backuper.sh
Created November 13, 2015 21:31
simplest possible script for backing up your DB with sh + cron
#!/bin/bash
# usage:
# crontab -e
# 20 1 * * * /bin/bash /home/user/bin/backuper.sh
## configuration {
BACKUP_DIR="ABSOLUTE_PATH_TO_BACKUP_DIR"
DBNAME="UR_DB_NAME"
DBUSER="UR_DB_USER"