Skip to content

Instantly share code, notes, and snippets.


sunpietro sunpietro

View GitHub Profile
sunpietro / index.html
Last active Aug 29, 2015
An example of implementing a module pattern with promises
View index.html
<div class="task api-1"></div>
<script src="//"></script>
<script src="//"></script>
<script id="user-profile" type="text/template">
<div class="user">
<img src="<%= picture %>" alt="">
<div class="info">
<h3><%= name.first%> <%= name.last%></h3>
View detectAnagrams.js
function detectAnagrams(a, b) {
return a.toLowerCase().split('').sort().join('') === b.toLowerCase().split('').sort().join('');
View sm-annotated.html
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
View grunt-sitemap.php
* Plugin Name: Grunt Sitemap Generator
* Plugin URI:
* 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:
* Version: 1.0
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 GlobalEvents.js
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,
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>

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"

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:
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 : {