Skip to content

Instantly share code, notes, and snippets.

View jrencz's full-sized avatar

Jarek Rencz jrencz

  • Wonga
  • Warsaw, Poland
View GitHub Profile
@jrencz
jrencz / Entity.php
Last active May 31, 2018 07:38
Generating LiipImagineBundle media URIs for FOSRestBundle Api using JMSSerializerBundle
<?php
namespace Acme\AcmeDemoBundle\Entity;
use JMS\Serializer\Annotation as Serializer;
/**
* Entity
*
* @Serializer\ExclusionPolicy("all")
@jrencz
jrencz / angular-angular
Last active August 29, 2015 14:01
Funny names across JS projects
https://github.com/angular/angular.js/blob/25a476ea096b200fb4f422aaa9cd7215e2596ad3/src/ng/directive/select.js#L145-L146
//000011111111110000000000022222222220000000000000000000003333333333000000000000004444444444444440000000005555555555555550000000666666666666666000000000000000777777777700000000000000000008888888888
var NG_OPTIONS_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/,
@jrencz
jrencz / register-many-event-handlers-angular
Created May 16, 2014 08:48
Simple way to register many event handlers to AngularJS scope.
function traverse(scope, level, rootPath, delimiter) {
rootPath = rootPath || [];
Object.keys(level).forEach(function (key) {
const path = rootPath.slice(0);
path.push(key);
if (angular.isFunction(level[key])) {
scope.$on(path.join(delimiter), level[key]);
return;
}
traverse(scope, level[key], path, delimiter);
@jrencz
jrencz / README_PHPCS.md
Last active August 20, 2018 10:13
This tutorial describes how to set PHP_CodeSniffer as the local project dependency instead of the suggested global PEAR dependency.
@jrencz
jrencz / Gruntfile.js
Last active August 29, 2015 14:04
Grunt task to strip unnecessary imports from the sass files
grunt.registerMultiTask('sassStripImports',
'Strips @import statements from the top of SCSS files',
// Stripping imports prevents code duplication yet still allows IDEs to properly resolve variables.
function () {
var options = this.options();
this.files.forEach(function (mapping) {
grunt.file.expand(mapping.src).forEach(function (path) {
grunt.file.write(path, grunt.file.read(path).replace((options.pattern || /@import\s\".+\";/), ''));
});
});
@jrencz
jrencz / Grunfile-part.js
Created August 20, 2014 08:27
Cofiguration dump for issue #5 on jubalm/grunt-fontello
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
fontello: {
share: {
options: {
config: 'fontello-config.json',
fonts: 'app/fonts',
styles: 'app/core-styles',
@jrencz
jrencz / q-race.es6
Last active May 7, 2018 08:58
Quick attempt to add spec-compliant race method to Angular $q
(function () {
'use strict';
angular
.module('q.race', [])
.config(function ($provide) {
$provide.decorator('$q', function ($delegate) {
$delegate.race = promises => $delegate((resolve, reject) => {
const bind = promise => {
@jrencz
jrencz / finally.js
Created January 7, 2016 11:49
Quick sketch of Angular1 attribute directive that calls a function after a promise returned by ngClick handler is resolved or rejected
(function () {
'use strict';
angular
.module('finally', [])
.directive('finally', function (
$parse
) {
return {
@jrencz
jrencz / angular-di-tests-short-syntax.es6
Created January 21, 2016 10:43
An idea of shorter syntax for loading services in angular1
let $log,
let $q;
// currently:
beforeEach(inject(function (_$log_, _$q_) {
$log = _$log_;
$q = _$q_;
}));
// maybe:
@jrencz
jrencz / .eslintrc
Created April 12, 2016 12:05
Useful set of words for eslint-plugin-spellcheck
{
"plugins": [
"spellcheck"
],
"rules":
// Spellcheck
//
"spellcheck/spell-checker": ["warn", {
"skipWords": [
// own names