Skip to content

Instantly share code, notes, and snippets.

Avatar

sunpietro sunpietro

View GitHub Profile
View custom.html.twig
<h3>My Custom block</h3>
{{ block }}
View blocks.yml
blocks:
custom:
views:
custom:
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
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) {
//console.info('Loading: ' + templateFilePath + ' with data:', templateData);
if (!APP.cache.templates[templateFilePath]) {
var templateDir = 'js/app/template/';
var templateUrl = templateDir + templateFilePath + '.js';
var templateString = '';
$.ajax({
async : false,
@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 / 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'
grunt.initConfig({
clean : [
'js/GoalApp/js/modules/**/*.min.js',
'css/GoalApp/css/*.min.css'
],
uglify : {
build : {
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,