Archive for the ‘developer’ Category

  • Script to get an email when a new property in your area is registered on Gumtree

    Date: 2012.04.17 | Category: developer, developing | Response: 0

    This script will send you an email when a new property in your area comes up on twitter.. Replace shoreditch with the area you want and add in some email addresses. You will also want to modify the price.. at current it’s set to a minimum price of £150 per week.

    It was written to solve a problem where we would be out looking for flats/apartments and we needed to be one of the first people to respond. This script gave us the edge that meant we could secure a good property in the limited window of time we had.

    You need to be familiar with NodeJS to use this. Execute it as a cron job or however you want.. It will store results to a database called db.db

    The code was written by @pitapoison – He is an awesome developer, you should follow him. We literally made this over a cup of tea and a bowl of pasta, it took 15 minutes and saved many hours.

    I think it’s interesting to see the approach we used to solving a housing problem, something that affects everyone yet so few will take the time to create a piece of software that gives them the edge.

    var request = require("request");
    var parser = require("xml2json");
    var db = require("dirty")("db.db");
    var nodemailer = require("nodemailer");
    var transport = nodemailer.createTransport("Sendmail");
    
    db.on('load', function() {
      request('http://www.gumtree.com/rssfeed/single-room-flatshare/shoreditch', function (err, response, body) {
        if(err){
          throw err;
        }
        
        var json = JSON.parse(parser.toJson(body));
        
        var items = json.rss.channel.item;
        
        items.forEach(function(item){
          try {
            var title = item.title;
            var price = /([0-9]+)pw$/.exec(title)[1];
            var content = item["content:encoded"].replace(/\&\#[0-9]+;/g," ");
            var link = item.link;
          
            if(price < 150){
              return;
            }
          
            if(db.get(link) === true){
              return;
            }
            
            db.set(link, true);
          
            var emails = ["person1@example.com", "person2@example.com"];
            
            emails.forEach(function(email){
              var mailOptions = {
                  from: "gumtreebot@example.com",
                  to: email,
                  subject: "GUMTREE: " + title,
                  text: link + "\n\n\n" + content
              }
                        
              transport.sendMail(mailOptions);
            });
          
          } catch(e){
            console.error(e.stack || e);
          }
        });
      });
    });
    
  • When debugging IE stop it using cache

    Date: 2012.03.26 | Category: developer, developing, development | Response: 0

    I often have problems debugging Etherpad Lite in IE mostly due to IE having a hideous way of relentlessly holding onto files in cache.. well today I figured out to stop that problem and it’s super easy.. In Developer tools, Click Cache –> Always refresh from server

    how to debug javascript in IE 550x372 When debugging IE stop it using cache

  • Ajax CSV upload to a Table with jQuery and PHP

    Date: 2012.01.26 | Category: developer, developing, development, jquery, Php | Response: 2

    So I had to write a new user importer for School Email and I was looking for a simple plugin in solution but didn’t find one so here is a simple way of uploading a csv file that is uploaded to a file and rendered to a table..

    Projects used: CsvToTable & jQuery File Upload & Editable Grid *optional for live edits.

    Grab those two projects, grab the below files and put them in a /js folder then put the .js files into your head..

    Put the jQuery-File-Upload folder in your root, we will be uploading files to here.. You may want to add a layer of security in front of the upload function.

    <head>
    <script src="/js/csvToTable.js"></script>
    <script src="/js/jquery.iframe-transport.js"></script>
    <script src="/js/jquery.fileupload.js"></script>
    </head>
    

    At the bottom of your body add..

    <div id="csvToTable"></div>
    <div id="fileupload"></div>
    <script>
    var loggedIn = 1; // you will want to modify this if you require auth
    $(function () {
      if(loggedIn == "1"){
        $('#fileupload').fileupload({
          dataType: 'json',
          acceptFileTypes: '/(csv)$/i',
          url: '/jQuery-File-Upload/php/index.php',
          done: function (e, data, Users) {
            $.each(data.result, function(index, file){
              $('#csvToTable').html("");
              $('#csvToTable').CSVToTable(file.url).bind("loadComplete",function() {
                console.log("Loaded data into table");
                /*
    
                Call functions to manipulate data here
    
                */
              });;
            });
          }
        });
      }
    });
    </script>
    

    Want to make your table editor like the rest of the cool kids? Check out this jQuery plugin

  • Example jQuery package.json

    Date: 2011.12.09 | Category: developer, javascript, jquery | Response: 0

    {
      "name": "Etherpad Lite",
      "description": "jQuery Etherpad Lite collaborative editor plugin.",
      "version": "1.0.0",
      "author": "John McLear <john@mclear.co.uk>",
      "dependencies": {
        "jquery": ">= 1.0"
      }
    }
    
  • Is it possible to build Metro Desktop Tiles without Visual Studio?

    Date: 2011.11.14 | Category: developer, developing, development | Response: 5

    It pains me that I’m asking this but I have spent the last 3 hours using my favorite search engine looking for an answer to this question and I’m literally licking the pink knotted balloon of the internet right now so please hear me out..

    I hate developing on Microsoft platforms, it feels dirty. After watching the Windows 8 developer talks where they introduced Metro and had a bunch of students create their own tiles I figured how hard can it be?

    I’m not willing to use Visual Studio. Microsoft said Metro supports CSS/HTML/JS so I want to build my tile in notepad++. I don’t mind creating my own manifests, that’s fine, but I want to keep it open. I just don’t see a way to do this without installing an “app(has to be a binary)” and then binding that app to the desktop and hoping that Windows finds the manifest for the tile and implements it.

    Anyone had any luck? I’d love a little tutorial that just shows me how to get started.. Once I’m up and running I will be good to go!

    Thanks icon smile Is it possible to build Metro Desktop Tiles without Visual Studio?

    TLDR: I refuse to use Visual Studio so I want a way to create a desktop tile for Microsoft Windows Metro that doesn’t involve compiling anything.