Skip to content

Instantly share code, notes, and snippets.

@fesor
fesor / Email.php
Last active August 29, 2015 14:20
Domain-model: User
<?php
class Email
{
private $email;
public function __construct($email)
{
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
@fesor
fesor / BirdMock.php
Created March 18, 2015 20:05
Prophet generated class
<?php
namespace Double\Wings;
class P1 extends Wings implements ProphecyProphecyProphecySubjectInterface, ProphecyDoublerGeneratorReflectionInterface
{
private $objectProphecy;
public function swing()
# OS Spefific files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
.DS_Store
.AppleDouble
@fesor
fesor / script
Last active August 17, 2023 12:28
Jenkins: script for checking is directory has changed from last build
#!/bin/bash
DIR_PATH=$1
if [ ! -d "$DIR_PATH" ]; then
echo "Directory '$DIR_PATH' not exists"
exit 1
fi
if [ -z "$GIT_COMMIT" ]; then
echo "No current commit... fail"
@fesor
fesor / example.js
Created February 8, 2015 20:17
provider.js
// module.provider, available in config phase
function defaultProvider () {
this.$get = defaultFactory;
}
// module.factory
function defaultFactory (depService) {
return new SomeService(depService);
@fesor
fesor / stateDecorator.js
Created February 2, 2015 11:52
$stateDecorator for ionic
angular
.module('fsIonicStateDecorator', ['ionic', 'ui.router'])
.config(function ($provide) {
$provide.decorator('$state', stateDecorator);
})
;
function stateDecorator ($delegate, $injector) {
var $ionicHistory;
<?php
namespace WT\ServiceBundle\Service;
use Doctrine\ORM\EntityManager;
use WT\CommonBundle\DateRange;
use WT\BackendBundle\Entity\Service\AccountSource;
use WT\ServiceBundle\AccountContextFactory;
use WT\ServiceBundle\Entity\Transaction;
function generateForm (name, id) {
return {
id: id,
name: name,
updatedAt: new Date(),
sections: {
section_1: {
id: sectionID(1),
name: 'Section 1',
@fesor
fesor / example.feature
Created January 20, 2015 10:16
Example.feature
Scenario Outline: user may want to select value from predefined list or enter it's onw value
Given i have form with select control
When i select <selected> option
And custom option is <entered>
Then form should use value <expected>
Examples:
| selected | entered | expected |
| First option | | First option |
| Second options | | Second option |
| | Custom option | Custom option |
@fesor
fesor / example.js
Created January 19, 2015 08:25
Cordova: FormData file upload
function upload (url, files, config) {
config = config || {};
files = angular.isArray(files) ? files : [files];
config.transformRequest = angular.identity;
config.headers = config.headers || {};
config.headers['Content-Type'] = undefined;
return fileAppender(files).then(function (formData) {