Skip to content

Instantly share code, notes, and snippets.

Piotr Butkiewicz SpacemanPete

Block or report user

Report or block SpacemanPete

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@SpacemanPete
SpacemanPete / gist:c6f576f3a176f7d2b8eb6784a1ab0c5f
Last active Dec 14, 2018
Adding first/last/odd/even classes to a twig loop in Drupal 8
View gist:c6f576f3a176f7d2b8eb6784a1ab0c5f
{# Borrowed some syntax from https://gist.github.com/NikLP/cb9adc963036d1ffd8896928de2b9b7a and expanded upon it. #}
<div{{ attributes.addClass('container') }}>
{% for item in items %}
{# NB! notation: loop.index is 1 start, loop.index0 is zero start. #}
{# Add first/last/odd/even classes to elements in loop #}
{# odd/even #}
{% set loopClasses = [] %}
{% if loop.index is odd %}
{% set loopClasses = loopClasses|merge(["odd"]) %}
@SpacemanPete
SpacemanPete / Contract Killer 3.md
Created Apr 12, 2017 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@SpacemanPete
SpacemanPete / urlobject.js
Last active Nov 13, 2015 — forked from aymanfarhat/urlobject.js
I changed the **decodeURI** method for decoding the search parameters to **decodeURIComponent** to match the encoding iplementation I'm using on a project, **decodeURI** alone didn't handle commas. Also added regex to replace the '+' encoded by Jquery's $.param() search encoding method. Surprising they don't have an easy $.deparam() method to ac…
View urlobject.js
// **********************************************************************************
//
// Javascript utility to parse page URL into Javascript Object for easy manipulation
//
// Written by: aymanfarhat
//
// Source: https://gist.github.com/aymanfarhat/5608517
//
// Dependencies:
// none
You can’t perform that action at this time.