Skip to content

Instantly share code, notes, and snippets.

View sorbing's full-sized avatar

Stanislav Butsenko sorbing

View GitHub Profile
## Base sample: https://gist.github.com/cristianoc72/9060420
propel:
general:
project: Etude
version: 0.1-dev
paths:
# Default value is current path #
@sorbing
sorbing / PresetFieldsController.js
Created May 13, 2014 11:57
Angular Controllers
APP.controller('PresetFieldsController', function ($scope, $location, Rest, $routeParams, Messenger, Page, $timeout) {
// Getting Preset & Fields
Rest.one('presets', $routeParams.id).get().then(function(preset) {
if (!preset.id) {
$location.path('/presets');
Messenger.error('Пресет не найден');
return;
}
$scope.preset = preset;
@sorbing
sorbing / gist:8493138
Created January 18, 2014 16:58
Broken formatting in PHP after the update to PhpStorm 7.1.1 EAP 133.626.
com.intellij.webcore.template.formatter.AbstractTemplateLanguageFormattingModelBuilder.createTemplateLanguageBlock(Lcom/intellij/lang/ASTNode;Lcom/intellij/psi/codeStyle/CodeStyleSettings;Lcom/intellij/psi/formatter/xml/XmlFormattingPolicy;Lcom/intellij/formatting/Indent;Lcom/intellij/formatting/Alignment;Lcom/intellij/formatting/Wrap;)Lcom/intellij/formatting/Block;: com.intellij.webcore.template.formatter.AbstractTemplateLanguageFormattingModelBuilder.createTemplateLanguageBlock(Lcom/intellij/lang/ASTNode;Lcom/intellij/psi/codeStyle/CodeStyleSettings;Lcom/intellij/psi/formatter/xml/XmlFormattingPolicy;Lcom/intellij/formatting/Indent;Lcom/intellij/formatting/Alignment;Lcom/intellij/formatting/Wrap;)Lcom/intellij/formatting/Block;
java.lang.AbstractMethodError: com.intellij.webcore.template.formatter.AbstractTemplateLanguageFormattingModelBuilder.createTemplateLanguageBlock(Lcom/intellij/lang/ASTNode;Lcom/intellij/psi/codeStyle/CodeStyleSettings;Lcom/intellij/psi/formatter/xml/XmlFormattingPolicy;Lcom/intelli
###### composer.json ######
...
"autoload": {
"classmap": [
...
"app/facades",
"app/providers",
...
]
},
@sorbing
sorbing / gist:6052745
Created July 22, 2013 10:03
PHP 5.5 Generators example, yield
<?php
header("Content-type: text/plain");
function getLinesFromFile($file_path) {
// На каждой итерации выполняется код до первого yield
if ( ! $fh = fopen($file_path, 'r')) {
return;
}
@sorbing
sorbing / gist:5569189
Last active December 17, 2015 06:59
Get with Join Entity
<?php
/** @var Block $block */
$block = BlockQuery::create()->findOneById(1);
$gadget_block1 = $block->getGadgetBlocks()->getFirst();
$gadget_block2 = $block->getGadgetBlocksJoinGadget()->getFirst();
echo $gadget_block1->getGadget()->getTitle() . "<br>"; // есть заголовок гаджета
echo $gadget_block2->getGadget()->getTitle() . "<br>"; // пустая строка
@sorbing
sorbing / Detect what specified require() executed
Created February 5, 2013 20:43
How to detect what specified `require()` has been executed? Discussion: https://groups.google.com/d/topic/requirejs/vM3pCCOtQYE/discussion
<!-- Template: layout.php -->
<!-- include require.js and maim.js -->
...
<?php include "first.php" ?>
<?php
if ($_GET['condition']) { // some condition
include "second.php";
} else {
include "third.php";
}
~/www/stepcart/master$ php app/console propel:model:build --verbose
Buildfile: /home/stas/www/stepcart/master/vendor/propel/propel1/generator/build.xml
Override ignored for user property phing.file
parsing buildfile build.xml
Project base dir set to: /home/stas/www/stepcart/master/vendor/propel/propel1/generator
Property ${project.dir} => /home/stas/www/stepcart/master/app/cache/dev/propel
Property ${application.startdir} => /home/stas/www/stepcart/master
[resolvepath] Resolved /home/stas/www/stepcart/master/app/cache/dev/propel to /home/stas/www/stepcart/master/app/cache/dev/propel
Build sequence for target 'om' is: check-project-or-dir-set check-project-set set-project-dir check-buildprops-exists check-buildprops-for-propel-gen check-buildprops configure om
Complete build sequence is: check-project-or-dir-set check-project-set set-project-dir check-buildprops-exists check-buildprops-for-propel-gen check-buildprops configure om main convert-conf create-db reverse datadump datasql insert-sql new-om sql sql-d
Example Structure Application
=============================
<!-- file: index.php -->
<html>
<head>
<script data-main="main" src="require.js"></script>
</head>
<body>
<?php
if (USER::isAuthenticate()) {
$builder->add('addresses', 'collection', array(
'type' => new AddressType(),
'allow_delete' => false,
'by_reference' => false
));
$builder->add('billing_address', new AddressType(), array(
'address' => $this->getBillingAddress($user, $session)
));