Skip to content

Instantly share code, notes, and snippets.


sunpietro sunpietro

View GitHub Profile
View custom.html.twig
<h3>My Custom block</h3>
{{ block }}
View blocks.yml
template: MyBlockBundle::custom.html.twig
name: My Custom Block view
View calendar.css
* {
margin: 0;
padding: 0;
body {
font-family: sans-serif;
color: #333;
table {
sunpietro / backbone-load-template.js
Last active Feb 10, 2016
Backbone.js template loader with caching
View backbone-load-template.js
var loadTemplate = function (templateFilePath, templateData) {
//'Loading: ' + templateFilePath + ' with data:', templateData);
if (!APP.cache.templates[templateFilePath]) {
var templateDir = 'js/app/template/';
var templateUrl = templateDir + templateFilePath + '.js';
var templateString = '';
async : false,
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 / Gruntfile.js
Last active Dec 23, 2015
Grunt directives: * removing minified files, * uglifying them and keeping original filename (with dots), adding only min.js extension at the end; * concatenating minified JS files, * minifying CSS files, * copying minified files to production directory Gruntfile.js
View Gruntfile.js
module.exports = function(grunt) {
'use strict'
clean : [
uglify : {
build : {
View styles.css
* VH and VW units can cause issues on iOS devices:
* 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:

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 / index.html
Created Jan 26, 2015
How to detect element’s CSS transition end time with JavaScript? - code samples for the article from
View index.html
<div class="container">
<div class="element"></div>
View GlobalEvents.js
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,