Node Rest Template

Node Rest Template

I've been working on a project so that I can get started quickly when wanting to write a quick rest service. I used node, since its my new favourite thing, check it out on github, heres a a quick overview!

NodeRestTemplate is everything you need to start writing an ApiService in seconds. Build on top of restify, it handles all the routing leaving you to only need to code up your methods.
Adding actions and controllers onto the node rest template are done by extending MvcApi to include your own methods. The controller name is not restricted, although the action should be the name of the HttpMethod, followed by an action name if you wish to use one.
You can do this by appending to prototype or adding to the created api object. Here is one way of doing this, although there are many ways to extend on the object
MvcApi.prototype.controller = {
  GetAction: function(request, response){
    response.send("Action on Controller Called");
  }
  Get: function(request, response){
    response.send("There is one method on this Controller called 'Action'");
  }
};
When the app starts up, the endpoints available should now be: http://localhost:8081/api/Controller/ http://localhost:8081/api/Controller/Action
You can add as many controllers and actions as you like, using any of the http methods you want. You can also override the "controller not found" and "action not found" methods to customise however you like.
If you like this kind of thing, please share!!



JINQ

JINQ

I was a bit bored so started writing my own linq style extensions for javascript. Its pretty cool so far, they work nicely! https://github.com/craigpayne1985/JINQ More to follow!!

Off Topic - facebook like rant

Off Topic - facebook like rant

Like. I hate to like! Like is just basically saying target me with this particular advertising, or spam my facebook feed with useless drivel I'll just skip past anyways. I noticed recently I had been getting a load more advertising than usual on my facebook wall, lots of extra rubbish I would rather not see! Then I dug a bit deeper. Pages I had like probably years ago, that I have no interest in now spam my feed with stuff I don't even care to see. What happens is somebody creates a group, gets a load of likes, waits a while then spams. Its annoying really! Goodbye Likes, You've now been unliked!

Colorstrap/Colourstrap

Colorstrap/Colourstrap

My new project! https://github.com/craigpayne1985/colourstrap https://github.com/craigpayne1985/colorstrap Eventually i will fork between the two, its just annoying that the american spelling and british spelling of colour have to differ!! I've started working on a project to enable easy colourisation of bootstrap without manually editing the css. so far, i have managed to strip out the hex colours (I'll have to look at the rgba values later) and can swap them out using javascript and regex. Its pretty straight forward, but has a few challenges. I have grouped the main colours into categories, Cold, Warm, Organic, Dry and Mono. I need to work out the differences using the hex values so that i can transform the colours. Another issue i realised i will come across is that if i swap out an organic colour, with a colour from cold, it could get overridden. What i think i need to do is replace within the source the colour based on a calculation, maybe comething like COLD+2000 where 2000 is the difference between the median colour and the current value within the temperature range. So far i have managed to switch out the Cold for the Organic, a bit pointless, but at least its a proof of concept. Not only that, its written purely in javascript, so no server side processing :)

Update to my android app: Triple Triad Card List

Update to my android app: Triple Triad Card List

I've been meaning to update Triple Triad Card List for ages, especially after all the requests for different features. I have actually got round to doing it!! I lost my original key, so i cant do an update, here's hoping i'll get another 10,000 downloads for the new app! https://play.google.com/store/apps/details?id=info.craigpayne.tripletriadcardlist


New Android App

New Android App

Finally knuckled down and got a new android app out! It's basically a CSS Cheat Sheet, but I got a chance to publish a PhoneGap app complete with Twitter Bootstrap and Flat UI to create a responsive design. Download it and check it out, works well across devices!!! https://play.google.com/store/apps/details?id=info.craigpayne.csscheatsheet
Blog Restyling

Blog Restyling

My Rasp Pi has been not serving up pages for the last day? or so. I think I'm going to keep hosting using blogger. My next task is to wrap a blogger template in the twitter boostrap. Should be interesting... *blog may not look right until its complete!!

Migrating Blog - 2

Migrating Blog - 2



Just thought i would link to my migrated blog as I work on it, the DNS address is: http://craigpayne.no-ip.org/ If you browse using your phone, it should look very similar to in the browser.
Here is an iframe version.
If nothing shows up, my raspberry pi has probably crashed or something!
Domain Name

Domain Name

Since I'm never going to be able to get http://craigpayne.co.uk, I've opted for http://craig-payne.co.uk. Maybe google will index me now i dont have a .info name!!


Migrating blog

Migrating blog

I've spent some time working on migrating this blog over to my raspberry pi.
I thought I'd do something a bit different, so first of all I built up the UI to make a responsive design. It looks the same on my laptop as it does on my android and itouch! I then decided that I would host it using node.
I have created my own web server, that renders pages and posts using jade templating engine. It works well, although its still work in progress. Its certainly not ready to swap out my blogger account yet! Check it out: https://github.com/erroroccured/craig-payne-blog


Home Made Jade Web Server

Home Made Jade Web Server

I have been playing around with Node.js again, and have create a Jade web server.
Jade is a html templating engine similar to haml, that allow you to write html without all the extra syntax
e.g.

Valid Jade markup:
html
 head
 body
  div Hello World

The node module I have created is quite simple, it defaults to index.html if a template is not specified. templates can be loaded by using the query string key 'page' e.g. http://localhost:8080?page=about This will translate to about.jade template on disk.
I need to add support for loading local variables, i could do this using query string, but its not practical. maybe by using a post request? who knows! I need more of a think.
Here is the module i wrote: Dependencies - http,jade,fs,url
var http = require('http');
var jade = require('jade');
var fs = require('fs');
var url = require('url') ;
var options = {pretty:true};

http.createServer(function (req, res) {
 var query = url.parse(req.url, true).query;
 console.log(query);

 if(!query || !query.page) {
  //Show Index Page
  fs.readFile("index.html", function read(err, data) {
   if (err) console.log(err);
   res.writeHead(200, {'content-type': 'text/html'});
   res.end(data);
  });
 }else{
  var template = query.page + ".jade";
  fs.readFile(template, function read(err, data) {
   if (err) console.log(err);

   var markup = jade.compile(data, options)({});
   res.writeHead(200, {'content-type': 'text/html'});
   res.end(markup);
  });
 }

}).listen(8080);



blackout.js

blackout.js

I got sick of building snippets of javascript to block out sections of webpages when ajax calls are made etc. I built a jQuery plugin to do this for me, it should be cross browser compatible. Makes life a little bit easier. GitHub: blackout.js


PicoContainer / Mono Droid

PicoContainer / Mono Droid

Reverted back to Windows 7 this weekend (finally removed windows 8!!) and did some development. I started looking at Mono Droid. I really like it, Its a lot faster than i expected it to be!! I started working on a shared library, so that I can write some boilerplate code, ready for when I have an application idea. So far I have been working on a Read Only file picker. My shared application logic uses PicoContainer for dependency injection, as it is a small and lightweight implementation of IOC. The app works well! You can download it from my github to try it out! Github Signed APK


Google Maps API

Google Maps API

I've been playing about with the Google maps API.
Here is an example - I have set the latitude and longitude to show all the bars in the northern quarter in manchester: position 53.484171,-2.236357


NaviX Scraper

NaviX Scraper

Building on top of my cross domain parser, i tried creating my own implementation of a PLX parser, basically something where i can scrape the NaviX website (media aggregator)
Here is my implementation so far, its still work in progress!
You may need to refresh to get this to work, for some reason Blogger loads JQuery in a wierd order!!
Also check out my Github!


JQuery plugin PageScraper

JQuery plugin PageScraper

I've been reading a lot lately about JSONP and cross domain scripting and the massive pain it causes when doing things like page scraping.
I created my own PageScraper JQuery Plugin, which utilises Yahoo Query Language to scrape websites and return the html, without having to make JSON calls to the website (and enable JSONP etc.)
This way I can call any site and get back the result.
You can use it as follows:
$().scrapePage("http://www.google.com", function (data) {
    document.write(JSON.stringify(data));
});

You can check out the code on my GibHub:
JQuery-Cross-Domain-Page-Scraper-Plugin


Katamari Hack

Katamari Hack

This is cool! I love katamari