Skip to content

Instantly share code, notes, and snippets.

View wjn's full-sized avatar
Learning always

Will Nielsen wjn

Learning always
View GitHub Profile
@wjn
wjn / .bowerrc
Last active August 29, 2015 13:57
.bowerrc
{
"directory" : "assets/lib"
}

Forms have been an integral part of any interactive site since the dawn of time, they promote interactivity and are usually the most common way users interact with a site. It's commonplace that when a form is submitted, the website will take 'action' and do something with the data and then provide a user with the result. Symphony provides this logic layer via Events.

This tutorial assumes you have a basic understanding of how Events work in Symphony (if not, this may be a good introduction) and are semi comfortable writing some PHP code. I'll be showing you some of the lesser known features of Symphony Events, including event priority, event chaining and a brief demonstration of how to write a custom Event. The difficulty level progresses as we go through, but with any luck you'll be able to learn a thing or two :)

Getting Started

The Scenario

Our client requires a form that allows a user to submit some details about their new car purchase. Th

@wjn
wjn / XSLTHashGenerator.xslt
Created February 27, 2014 16:40
Generates an alpha numeric hash of a specified length using xslt 1. 0 and exlt math library.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:math="http://exslt.org/math"
extension-element-prefixes="math">
<xsl:template name="makeHash">
<xsl:param name="length">8</xsl:param>
<xsl:param name="count" select="$length"/>
<xsl:param name="hash"/>
<xsl:variable name="possibleFirst">xABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</xsl:variable>
@wjn
wjn / Git dmg uninstall.sh
Created February 27, 2014 15:55
This is the uninstall script provided with the Git Installer
if [ ! -r "/usr/local/git" ]; then
echo "Git doesn't appear to be installed via this installer. Aborting"
exit 1
fi
echo "This will uninstall git by removing /usr/local/git/**/*, /etc/paths.d/git, /etc/manpaths.d/git"
printf "Type 'yes' if you sure you wish to continue: "
read response
if [ "$response" == "yes" ]; then
sudo rm -rf /usr/local/git/
sudo rm /etc/paths.d/git
@wjn
wjn / append.java
Created December 27, 2013 02:24
Append: This class appends array list a to array list b thus creating array list c.
package Arrays;
import java.util.ArrayList;
import java.util.Scanner;
public class Append {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
@wjn
wjn / GuessTheNumber.java
Created December 23, 2013 20:21
Guess The Number: a Java version of the first computer game I ever played.
import java.util.Scanner;
public class GuessTheNumber {
@SuppressWarnings("unused")
public static void main(String[] args)
{
final int HIGHEST_NUMBER = 100;
final int MAX_GUESSES = 10;
int guessCount = 0;
@wjn
wjn / writepath.xsl
Created December 19, 2013 03:28
Write Path: a utility that I use for XSLT debugging, which will show the present XPath location in an XML document.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template name="write-path">
<xsl:param name="path"/>
<xsl:param name="output"/>
<xsl:choose>
<xsl:when test="$path/parent::node()">
<xsl:call-template name="write-path">
<xsl:with-param name="output">
@wjn
wjn / Console Output
Created December 19, 2013 03:12
Multiplication Table: This Java class creates a simple, text-based, multiplication table based on user's input.
Upto what whole number would you like your times table? 10
------------------------------------------------------------------------
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
------------------------------------------------------------------------
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
------------------------------------------------------------------------
| 3 | 6 | 9 | 12 | 15 | 18 | 21 | 24 | 27 | 30 |
------------------------------------------------------------------------
| 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 |
@wjn
wjn / class.shapes.php
Last active December 31, 2015 18:18
PHP Sample Problem: This application loads a csv datafile from the command line, manipulates the data and provides information based on the ID provided.
<?php
/**
*
* @author "Will Nielsen"
* website: http://willnielsen.com
* Date: December 13, 2013
*/
class Shapes {
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date">
<xsl:import href="get-schedule.xsl" />
<!--
Name: XSLT Calendar