<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jonathan Devine</title>
	<atom:link href="http://jonnydevine.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonnydevine.com</link>
	<description>Irish Software &#38; Web Developer</description>
	<lastBuildDate>Thu, 25 Sep 2014 12:17:16 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>Introducing DocumentaryWIRE</title>
		<link>http://jonnydevine.com/introducing-documentarywire/</link>
		<comments>http://jonnydevine.com/introducing-documentarywire/#comments</comments>
		<pubDate>Sun, 07 Sep 2014 03:53:05 +0000</pubDate>
		<dc:creator><![CDATA[Jonny]]></dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jonnydevine.com/?p=207</guid>
		<description><![CDATA[DocumentaryWIRE is a website dedicated to documentaries. Our mission is to help people find and share documentaries they love. http://www.documentarywire.com/ DocumentaryWIRE was built using the following technologies: PHP Framework called Syfmony2 MySQL and Doctrine2 ORM Pentaho Spoon APC caching HTML, CSS, and Twig Social Network API&#8217;s such as Facebook and Twitter]]></description>
				<content:encoded><![CDATA[<p><a href="http://jonnydevine.com/wp-content/uploads/2014/09/docuwire.png"><img class="alignnone size-full wp-image-208" alt="docuwire" src="http://jonnydevine.com/wp-content/uploads/2014/09/docuwire.png" width="1247" height="1155" /></a></p>
<p>DocumentaryWIRE is a website dedicated to documentaries. Our mission is to help people find and share documentaries they love. <a href="http://www.documentarywire.com/">http://www.documentarywire.com/</a></p>
<p>DocumentaryWIRE was built using the following technologies:</p>
<ul>
<li>PHP Framework called Syfmony2</li>
<li>MySQL and Doctrine2 ORM</li>
<li>Pentaho Spoon</li>
<li>APC caching</li>
<li>HTML, CSS, and Twig</li>
<li>Social Network API&#8217;s such as Facebook and Twitter</li>
</ul>
<p><span id="more-207"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://jonnydevine.com/introducing-documentarywire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Skynet &#8211; A Minecraft Bot</title>
		<link>http://jonnydevine.com/introducing-skynet/</link>
		<comments>http://jonnydevine.com/introducing-skynet/#comments</comments>
		<pubDate>Sun, 07 Sep 2014 03:16:59 +0000</pubDate>
		<dc:creator><![CDATA[Jonny]]></dc:creator>
				<category><![CDATA[Code Example]]></category>
		<category><![CDATA[Minecraft]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://jonnydevine.com/?p=192</guid>
		<description><![CDATA[Skynet is a Minecraft bot written with Node.js, MySQL, and Symfony2 for a Minecraft server called Civcraft. You can see it on Github: https://github.com/JonnyD/Skynet (Keep in mind it was my first time coding with Node.js so it may be a bit cringey but I did my best to make the code readable by using Async and other modules. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jonnydevine.com/wp-content/uploads/2014/09/skynet.png"><img class="alignnone size-full wp-image-193" alt="skynet" src="http://jonnydevine.com/wp-content/uploads/2014/09/skynet.png" width="1297" height="657" /></a></p>
<p>Skynet is a Minecraft bot written with Node.js, MySQL, and Symfony2 for a Minecraft server called Civcraft. You can see it on Github: <a href="https://github.com/JonnyD/Skynet">https://github.com/JonnyD/Skynet</a> (Keep in mind it was my first time coding with Node.js so it may be a bit cringey but I did my best to make the code readable by using Async and other modules.</p>
<p><span id="more-192"></span></p>
<p>Civcraft is Minecraft server with the goal of leaving players as free as possible to generate their own political, social, and economic order within Minecraft through the use of several custom mods as well as some more general ones. That means no rulers but doesn&#8217;t mean no rules. Those rules are enforced by other players in the community. It&#8217;s part of a social experiment to see which ideas would win in a free society.</p>
<p>This bot was for my in-game security business that allows players, in combination with other plugins, to make their property more secure &#8211; to find out which players are using alts (alternative accounts), which players are trespassing on their property or stealing their property, which criminals are in the vicinity so you can avoid that area all without logging in.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonnydevine.com/introducing-skynet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Calculating Standings by Results</title>
		<link>http://jonnydevine.com/calculating-standings-by-results/</link>
		<comments>http://jonnydevine.com/calculating-standings-by-results/#comments</comments>
		<pubDate>Sun, 07 Sep 2014 03:12:28 +0000</pubDate>
		<dc:creator><![CDATA[Jonny]]></dc:creator>
				<category><![CDATA[Code Example]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jonnydevine.com/?p=171</guid>
		<description><![CDATA[Using a PHP Framework called Symfony2, I am developing a web application for people who play the video game Fifa to compete against each other in an online competition. It&#8217;s on Github: https://github.com/JonnyD/Elite-Fifa In the picture above you can see the UI of the league standings. These values are calculated and stored in a Standings table [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://jonnydevine.com/wp-content/uploads/2014/09/hqy9J.png"><img class="aligncenter size-full wp-image-172" alt="hqy9J" src="http://jonnydevine.com/wp-content/uploads/2014/09/hqy9J.png" width="942" height="495" /></a></p>
<p>Using a PHP Framework called Symfony2, I am developing a web application for people who play the video game Fifa to compete against each other in an online competition. It&#8217;s on Github: <a href="https://github.com/JonnyD/Elite-Fifa">https://github.com/JonnyD/Elite-Fifa</a></p>
<p>In the picture above you can see the UI of the league standings. These values are calculated and stored in a Standings table after every confirmed match. There&#8217;s a problem with this and that is storing calculated values breaks normalization. The only time this could be acceptable is in cases where you want to improve performance by not having to re-calculate the values every time you need them.</p>
<p>However, what if I want to find out a teams standing by their Last X Games Played at Home, Last X Games Played Away, or Last X Games Played Combined?</p>
<p>Here&#8217;s how I could get Standings by home matches only:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT team.name, home_team_id AS team_id,
    COUNT(*) AS played,
    SUM((CASE WHEN home_score &gt; away_score THEN 1 ELSE 0 END)) AS won,
    SUM((CASE WHEN away_score &gt; home_score THEN 1 ELSE 0 END)) AS lost,
    SUM((CASE WHEN home_score = away_score THEN 1 ELSE 0 END)) AS drawn,
    SUM(home_score) AS goalsFor,
    SUM(away_score) AS goalsAgainst,
    SUM(home_score - away_score) AS goalDifference,
    SUM((CASE WHEN home_score &gt; away_score THEN 3 WHEN home_score = away_score THEN 1 ELSE 0 END)) AS points
FROM matches
INNER JOIN team ON matches.home_team_id = team.id
WHERE league_id = 94
    AND season_id = 82
    AND confirmed IS NOT NULL
GROUP BY home_team_id
ORDER BY POINTS DESC;
</pre>
<p><span id="more-171"></span><br />
<a style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 14px; line-height: 1.5em;" href="http://jonnydevine.com/wp-content/uploads/2014/09/homeonly.png"><img class="alignnone size-full wp-image-183" alt="homeonly" src="http://jonnydevine.com/wp-content/uploads/2014/09/homeonly.png" width="719" height="239" /></a><br />
Here's how I could get Standings by Away matches only:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT team.name, away_team_id AS team_id,
    COUNT(*) AS played,
    SUM((CASE WHEN away_score &gt; home_score THEN 1 ELSE 0 END)) AS won,
    SUM((CASE WHEN home_score &gt; away_score THEN 1 ELSE 0 END)) AS lost,
    SUM((CASE WHEN home_score = away_score THEN 1 ELSE 0 END)) as drawn,
    SUM(away_score) AS goalsFor,
    SUM(home_score) AS goalsAgainst,
    SUM(away_score - home_score) AS goalDifference,
    SUM((CASE WHEN away_score &gt; home_score THEN 3 WHEN away_score = home_score THEN 1 ELSE 0 END)) AS points
FROM matches
INNER JOIN team ON matches.away_team_id = team.id
WHERE league_id = 94
    AND season_id = 82
    AND confirmed IS NOT NULL
GROUP BY away_team_id
ORDER BY points DESC;
</pre>
<p><a href="http://jonnydevine.com/wp-content/uploads/2014/09/awayonly.png"><img class="alignnone size-full wp-image-187" alt="awayonly" src="http://jonnydevine.com/wp-content/uploads/2014/09/awayonly.png" width="721" height="240" /></a></p>
<p>Here's how I could get Standings by Home and Away matches combined:</p>
<pre class="brush: sql; title: ; notranslate">
SELECT team.name,
       team_id AS team_id,
       COUNT(*) AS played,
       SUM((CASE WHEN team_score &gt; other_team_score THEN 1 ELSE 0 END)) AS won,
       SUM((CASE WHEN team_score &lt; other_team_score THEN 1 ELSE 0 END)) AS lost,
       SUM((CASE WHEN team_score = other_team_score THEN 1 ELSE 0 END)) AS drawn,
       SUM(team_score) AS goalsFor,
       SUM(other_team_score) AS goalsAgainst,
       SUM(team_score - other_team_score) AS goalDifference,
       SUM((CASE WHEN team_score &gt; other_team_score THEN 3
                 WHEN team_score = other_team_score THEN 1
                 ELSE 0 END)) AS points
FROM
    (
        -- LIST TEAM STATS WHEN PLAYED AS HOME_TEAM
        SELECT
             id,
             league_id,
             season_id,
             home_team_id as team_id,
             home_score   as team_score,
             away_score   as other_team_score,
             confirmed
        FROM    matches
        UNION ALL
        -- LIST TEAM STATS WHEN PLAYED AS AWAY_TEAM
        SELECT
             id,
             league_id,
             season_id,
             away_team_id as team_id,
             away_score   as team_score,
             home_score   as other_team_score,
             confirmed
        FROM matches
    ) matches
INNER JOIN team ON matches.team_id = team.id
WHERE league_id = 94
    AND season_id = 82
    AND confirmed IS NOT NULL
GROUP BY team.name, team_id
ORDER BY POINTS DESC;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jonnydevine.com/calculating-standings-by-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating Citadel Schema</title>
		<link>http://jonnydevine.com/upgrading-citadel-schema/</link>
		<comments>http://jonnydevine.com/upgrading-citadel-schema/#comments</comments>
		<pubDate>Mon, 16 Dec 2013 01:05:41 +0000</pubDate>
		<dc:creator><![CDATA[Jonny]]></dc:creator>
				<category><![CDATA[Code Example]]></category>
		<category><![CDATA[Minecraft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://jonnydevine.com/?p=127</guid>
		<description><![CDATA[Citadel is a Minecraft plugin Before Update After Update Script]]></description>
				<content:encoded><![CDATA[<p>Citadel is a Minecraft plugin</p>
<p><strong style="line-height: 1.5em;">Before Update</strong></p>
<p><a href="http://jonnydevine.com/wp-content/uploads/2013/12/old_schema.png"><img alt="old_schema" src="http://jonnydevine.com/wp-content/uploads/2013/12/old_schema.png" width="740" height="294" /></a></p>
<p><span id="more-127"></span></p>
<p><strong>After Update</strong></p>
<p><a href="http://jonnydevine.com/wp-content/uploads/2013/12/new_schema.png"><img alt="new_schema" src="http://jonnydevine.com/wp-content/uploads/2013/12/new_schema.png" width="742" height="263" /></a></p>
<p><strong>Script</strong></p>
<pre class="brush: sql; title: ; notranslate">
-- Citadel 3 Schema

CREATE TABLE groups_group (
 `id` INT AUTO_INCREMENT,
 `name` VARCHAR(255) UNIQUE,
 `password` VARCHAR(255),
 `personal` TINYINT(1) DEFAULT 0,
 `status` INT(2) DEFAULT 0,
 `updated` DATETIME,
 `created` DATETIME,
 PRIMARY KEY (id)
);

CREATE TABLE groups_member (
 `id` INT AUTO_INCREMENT,
 `name` VARCHAR(32) UNIQUE,
 `updated` DATETIME,
 `created` DATETIME,
 PRIMARY KEY (id)
);

CREATE TABLE groups_group_member (
 `member_id` INT,
 `group_id` INT,
 `role` INT DEFAULT 0,
 `updated` DATETIME,
 `created` DATETIME,
 PRIMARY KEY (member_id, group_id)
);

ALTER TABLE groups_group_member
ADD FOREIGN KEY (member_id)
REFERENCES groups_member (id);

ALTER TABLE groups_group_member
ADD FOREIGN KEY (group_id)
REFERENCES groups_group (id);

-- Citadel 3 Upgrade Script

-- Migrate members
INSERT INTO groups_member (name, updated, created)
SELECT name, now(), now() FROM member;

-- Migrate Groups
INSERT INTO groups_group(name, password, updated, created)
SELECT name, password, now(), now() FROM faction;

-- Migrate Personal Groups
UPDATE groups_group
SET personal = 1
WHERE name IN (SELECT name FROM personal_group);

-- Migrate Disciplined Groups
UPDATE groups_group g
JOIN faction f on g.name = f.name
SET status = 2
WHERE f.discipline_flags = 1;

-- Migrate Group Admins
INSERT INTO groups_group_member(member_id, group_id, role, updated, created)
SELECT gm.id AS member_id, g.id AS group_id, 0, now(), now()
FROM groups_member gm, faction f, groups_group g
WHERE gm.name = f.founder AND g.name = f.name;

-- Migrate Group Members
INSERT INTO groups_group_member(member_id, group_id, role, updated, created)
SELECT gm.id AS member_id, g.id AS group_id, 2, now(), now()
FROM faction_member fm, groups_member gm, groups_group g
WHERE gm.name = fm.memberName AND g.name = fm.factionName;

-- Migrate Group Moderators
INSERT INTO groups_group_member(member_id, group_id, role, updated, created)
SELECT gm.id AS member_id, g.id AS group_id, 1, now(), now()
FROM moderator m, groups_member gm, groups_group g
WHERE gm.name = m.memberName AND g.name = m.factionName;

-- Citadel 3 Schema Selects
SELECT * FROM groups_member;
SELECT * FROM groups_group;
SELECT * FROM groups_group_member;

</pre>
]]></content:encoded>
			<wfw:commentRss>http://jonnydevine.com/upgrading-citadel-schema/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Finite State Machine in Minecraft</title>
		<link>http://jonnydevine.com/a-finite-state-machine-in-minecraft/</link>
		<comments>http://jonnydevine.com/a-finite-state-machine-in-minecraft/#comments</comments>
		<pubDate>Sun, 10 Jun 2012 23:54:27 +0000</pubDate>
		<dc:creator><![CDATA[Jonny]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Code Example]]></category>
		<category><![CDATA[Minecraft]]></category>

		<guid isPermaLink="false">http://jonnydevine.com/?p=30</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://jonnydevine.com/wp-content/uploads/2012/06/minecraft_antenna.png"><img class="size-full wp-image-31 aligncenter" title="minecraft_antenna" alt="" src="http://jonnydevine.com/wp-content/uploads/2012/06/minecraft_antenna.png" width="580" height="240" /></a></p>
<pre><span id="more-30"></span>

<pre class="brush: java; title: ; notranslate">
public String first(String text) {
return text.substring(0, 1);
}

@EventHandler(priority = EventPriority.HIGHEST)
public void blockPlace(BlockPlaceEvent bpe)
{
    // Block placed by player
    Block block = bpe.getBlock();

    // Get the blocks material relative to the block placed by the player
    Material main = block.getType();
    Material up1 = block.getRelative(BlockFace.UP, 1).getType();
    Material up2 = block.getRelative(BlockFace.UP, 2).getType();
    Material down1 = block.getRelative(BlockFace.DOWN, 1).getType();
    Material down2 = block.getRelative(BlockFace.DOWN, 2).getType();

    // Concatenate the first letters of each of the materials
    String materialFirstLetters = first(up1.toString()) + first(up2.toString()) +
                                  first(main.toString()) + first(down1.toString()) +
                                  first(down2.toString());

    // Regex pattern
    String regex = &quot;DIJ..|I.DJ.|..IDJ&quot;;

    // Check if the first letters of the materials match the regex pattern
    if (materialFirstLetters.matches(regex))
    {
        System.out.println(&quot;Antenna Created&quot;);
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jonnydevine.com/a-finite-state-machine-in-minecraft/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Online Book Store</title>
		<link>http://jonnydevine.com/online-book-store/</link>
		<comments>http://jonnydevine.com/online-book-store/#comments</comments>
		<pubDate>Fri, 01 Jun 2012 23:18:44 +0000</pubDate>
		<dc:creator><![CDATA[Jonny]]></dc:creator>
				<category><![CDATA[Code Example]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://jonnydevine.com/?p=218</guid>
		<description><![CDATA[For my final year project I had to build an n-tier web application from scratch using design patterns such as MVC, Command, Factory, Service, and DAO and technologies such as Java, JSP, JSTL, Tomcat, JUnit, XML, HTML/CSS, Javascript, MySQL. Homepage. Displays featured books, latest books, newest members, and recent reviews. All Books. Displays list of [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>For my final year project I had to build an n-tier web application from scratch using design patterns such as MVC, Command, Factory, Service, and DAO and technologies such as Java, JSP, JSTL, Tomcat, JUnit, XML, HTML/CSS, Javascript, MySQL.</p>
<p>Homepage. Displays featured books, latest books, newest members, and recent reviews.<a href="http://jonnydevine.com/wp-content/uploads/2014/09/bookstore1.png"><img class="alignnone size-full wp-image-219" alt="bookstore1" src="http://jonnydevine.com/wp-content/uploads/2014/09/bookstore1.png" width="1024" height="506" /></a></p>
<p><span id="more-218"></span></p>
<p>All Books. Displays list of books which can be sorted by Title, Price, Rating, or Release Date.<a href="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore2.png"><img class="alignnone size-full wp-image-223" alt="bookstore2" src="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore2.png" width="1024" height="506" /></a></p>
<p>Book (top). Shows the books title, image, rating and<br />
<a href="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore3.png"><img class="alignnone size-full wp-image-224" alt="bookstore3" src="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore3.png" width="1024" height="506" /></a></p>
<p>Book (bottom). Shows similar themed books. Reviews by the users which can be filtered.<br />
<a href="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore4.png"><img class="alignnone size-full wp-image-225" alt="bookstore4" src="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore4.png" width="1024" height="506" /></a></p>
<p>Profile. Shows profile of user and their recent reviews.<br />
<a href="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore5.png"><img class="alignnone size-full wp-image-226" alt="bookstore5" src="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore5.png" width="1024" height="506" /></a></p>
<p>The shopping cart<br />
<a href="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore6.png"><img class="alignnone size-full wp-image-227" alt="bookstore6" src="http://jonnydevine.com/wp-content/uploads/2012/06/bookstore6.png" width="1024" height="506" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jonnydevine.com/online-book-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
