Code Contest on Instructables

Coded Creations

Instructables with sponsorship by Microsoft is holding a contest for the best Instructables that are code related. The contest is called Coding Creations and among many prizes is a surface pro 3 and a Spark Prototyping Bundle.  The judges prize is for the “best use of Visual Studio,  Microsoft Azure, Kinect/Xbox, Windows Phone apps, or any Windows app” so if anyone has any ideas let me know.

So far I have submitted 2 Instructables for this competition, A View-State Key Generator (in c# & php) and a simple app that does Image Edge Detection.

This is a link to my profile on Instructables.

 

Instructables WordPress Plugin

So a while back I posted a how-to on displaying a user’s Instructables projects on their own site or projects of those that they follow. I have since then created a WordPress plugin to do the work for you.

Download the Instructables Plugin Here

If you’re not familiar with www.Instructables.com and are interested in DIY projects go check it out.

Do you author DIY/How-To’s on Instructables?
Do you like the projects on Instructables?

This plugin allows you to post the latest projects you or other authors have posted or projects by keyword on your own site. See an example below

This is an expansion of an Instructable I wrote a while back that you can find here http://www.instructables.com/id/Display-your-Instructables-on-a-Wordpress-or-PHP-b/

Display a user’s projects:
[instructablesUP username=”MrRedBeard” num=”2″ thumb=”true”]

Display a list of projects by keyword:
[instructablesKW keyword=”tent” num=”3″ thumb=”true”]

 

Combine 2 or more xml files, sort, dedup and display with php

Want to combine 2 or more xml/rss files with php? This commented code should get you started.

The 2 xml files will need to be structured the same in order for this to work without adding more code. The 2 in this example are from the same source with different filters selected. This allows me to sort, filter and dedup using my own methods. You can then re-create the xml or simply display it on the screen like the example does below.

If you still need help feel free to comment below.

Code and Example below

<?php
//Sort Function by title
function sortFunction( $a, $b )
{
return strtotime($b["title"]) - strtotime($a["title"]);
}

$urllist = array();
//Define new xml files here by adding a new line with different urls
$urllist[] = “http://www.instructables.com/tag/type-question/rss.xml?count=100&sort=RECENT”;
$urllist[] = “http://www.instructables.com/tag/type-question/rss.xml?count=100&sort=UNANSWERED”;

//Loop through urllist array adding each item to one multidimensional array
//Define array before populating
$items = array();
foreach($urllist as $url)
{
$feed = simplexml_load_file($url);

//these item names are the child names in the xml
//channel is the wrapper in the xml
foreach($feed->channel->item as $item)
{
$items[] = array(
‘link’ => (string)$item->link,
‘image’ => (string)$item->imageThumb,
‘title’ => (string)$item->title,
‘pubdate’ => (string)$item->pubDate,
‘author’ => (string)$item->author
);
}
}

//Sort by Title
usort($items, “sortFunction”);

//Remove Duplicates
$items = array_map(“unserialize”, array_unique(array_map(“serialize”, $items)));

//Loop through the list and display them
$ictr = 0;
foreach ($items as $item)
{
echo “<div style=’float:left; width:200px; height:300px; margin-right:15px; text-align:center;’>”;
echo “<a href='” . $item[‘link’] . “‘ target=’_blank’>”;

if(strpos($item[‘image’],”defaultIMG”))
{
echo “<img src=’http://www.instructables.com/static/img/footer/footer-robot.png’ />”;
}
elseif(strpos($item[‘image’],”com”))
{
echo “<img src='” . $item[‘image’] . “‘ />”;
}
else
{
echo “<img src=’http://www.instructables.com” . $item[‘image’] . “‘ />”;
}
echo ‘<br />’ . $item[‘title’] . ‘<br />’;
echo ‘By: ‘ . $item[‘author’] . ‘ On ‘ . $item[‘pubdate’] . ‘</a></div>’;
}
echo “<div style=’clear: both;’>&nbsp;</div>”;
?>


Example of the output:

[phpCombineXMLArticle1][/phpCombineXMLArticle1]
Top