Skip to content

Instantly share code, notes, and snippets.

Avatar

sunpietro sunpietro

View GitHub Profile
@sunpietro
sunpietro / CustomBlock.php
Last active Jul 21, 2016
Extending eZ Studio with new blocks
View CustomBlock.php
<?php
namespace My\BlockBundle\Block;
use EzSystems\LandingPageFieldTypeBundle\Exception\InvalidBlockAttributeException;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockDefinition;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Definition\BlockAttributeDefinition;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\AbstractBlockType;
use EzSystems\LandingPageFieldTypeBundle\FieldType\LandingPage\Model\BlockValue;
View calendar.css
* {
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
color: #333;
}
table {
@sunpietro
sunpietro / string-formatter.js
Last active Feb 1, 2016
Formats a string like sprintf
View string-formatter.js
var formatString = (function()
{
var replacer = function(context)
{
return function(s, name)
{
return context[name];
};
};
@sunpietro
sunpietro / fade-in-out.css
Created Jul 8, 2015
CSS - fade-in/fade-out transition
View fade-in-out.css
.m-fadeOut {
visibility: hidden;
opacity: 0;
transition: visibility 0s linear 300ms, opacity 300ms;
}
.m-fadeIn {
visibility: visible;
opacity: 1;
transition: visibility 0s linear 0s, opacity 300ms;
}
View styles.css
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
View _intro.md

something something es6

a bit cleaned up version of my "slides"

disclaimer: this "talk" was done to show some "real life use cases" to simplify the knowledge I mainly got from Axel Rauschmayer's articles

why "destructring is a good way to go"

@sunpietro
sunpietro / index.html
Created Jan 26, 2015
How to detect element’s CSS transition end time with JavaScript? - code samples for the article from http://share.ez.no/blogs/piotr-nalepa/how-to-detect-element-s-css-transition-end-time-with-javascript
View index.html
<div class="container">
<div class="element"></div>
</div>
View GlobalEvents.js
(function(window){
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,
_eventStack,
_findByName,
stackEvent,
removeEvent,
eventListener,
@sunpietro
sunpietro / createContent.js
Created Dec 23, 2014
An example of how to use eZ JS REST API to create a new content and get article user-friendly URL in the end.
View createContent.js
var pageUrl = 'http://ez.local',
authAgent = new SessionAuthAgent({
login : 'admin',
password: 'admin'
}),
jsRestClient = new CAPI(pageUrl, authAgent),
contentService = jsRestClient.getContentTypeService(),
parentLocationId = '/api/ezp/v2/content/locations/1/2/102',
contentTypeId = '/api/ezp/v2/content/types/16',
locationStruct = contentService.newLocationStruct(parentLocationId),
View grunt-sitemap.php
<?php
/**
* Plugin Name: Grunt Sitemap Generator
* Plugin URI: http://www.github.com/lgladdy
* Description: Generate a JSON list of every page on a site so it can be used with grunt and uncss. Create a folder in /wp-content called mu-plugins, and drop this code into that folder, as grunt-sitemap.php
* Author: Liam Gladdy
* Author URI: http://gladdy.co.uk
* Version: 1.0
*/