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 / 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 / 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 / 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 / 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 / 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")