Monday 9 December 2013

AngularJS: create a custom attribute for a directive

Controller

var tableController = function($scope, $rootScope,UtilService,$element,$attrs) {

    this.defineListeners = function() {
        this.$scope.$on('$destroy', this.destroy.bind(this));
        var _this=this;
        this.$scope.$watch($attrs.gridCollection,function(value){_this.updatedCollection(value);});
    };
    this.defineScope = function() {
       var canvas = $element[0].childNodes[0];
       $scope.collection = {};
       $scope.collection = [{value:100}];
      // console.log($scope.gridCollection);
    };
 
     this.updatedCollection=function(value)
    {
        console.log("updatedCollection",$scope.collection,value,$attrs.gridCollection);
    };

   //initialise the controller
    this.init($scope);
};
tableController.prototype = new BaseController();
tableController.constructor = tableController;

Directive

var canvastable = function()
{
     return {
      restrict: 'E',
      template:"<canvas></canvas>",
      controller:'tableController',
      scope:{
          gridCollection:"=gridCollection"
      }
    };
};

HTML
<canvastable data-grid-collection="collection"></canvastable>

Monday 4 November 2013

AngularJS: Creating a Dynamic Directive

MainController=function($scope,$element,$compile)
{
var elem = $compile("<fahim></fahim>")($scope);
$element.append(elem);
};

Monday 21 October 2013

Sunday 20 October 2013

Creating a Node Express App

1. Write a package.json file which will contain the dependencies for the project. Place this in the root of the project.

{
"name": "NodeApp",
"description": "First Express app",
"version": "0.0.1",
"dependencies": {
"express": "3.x"
}
}

2. In the command line navigate to the node project and run the following command.

npm install

3. Create you project folder and make a index.html file.
4. Write a 'app.js' file.

(function() {
//setup express
var express = require('express');
var app = express();
//add static folders
app.use("/js", express.static(__dirname + '/js'));
app.listen(3000);
app.get('/', function(request, response) {
response.sendfile('./index.html');
});
})();

5.  In the command line navigate to the app.js file and run the following command.

node app.js

Thursday 22 August 2013

Adding Background Images in Outlook

<!--[if gte mso 9]>
    <v:image xmlns:v="urn:schemas-microsoft-com:vml" id="theImage" style='behavior: url(#default#VML); (+ more CSS)' src="background url" />
    <v:shape xmlns:v="urn:schemas-microsoft-com:vml" id="theText" style='behavior: url(#default#VML); (+ more CSS)'>
    <div>
<![endif]-->
<!-- An HTML table -->
<!--[if gte mso 9]>
    </div>
    </v:shape>
<![endif]-->

Tuesday 13 August 2013

HTML Email Build Template


This is a template built by Mike Dove which is the foundations for a HTML email build:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><!--iPhone Display Fix DO NOT DELETE -->

<title>SUBJECTLINE</title>

</head>
<body style="margin:0px;padding:0px;-webkit-text-size-adjust:none;">
<!-- Gmail Transbackground fix --><table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#ffffff"><tr><td valign="top">

<div style="font-size:40px; line-height:40px; mso-line-height-rule: exactly;">&nbsp;</div>

<!-- WRAPPER TABLE (SET WIDTH)&(SET BGCOLOR)-->
<table width="" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#">
<tr>
<!--! ROW -->
<td valign="top">

<!--// ROW --></td>
</tr>
</table>
<!--//WRAPPER TABLE -->

<!--//Gmail Transbackground fix--></td></tr></table>
<!-- Fix autogenerated distribution software footer clearence --><div style="font-size:1px; line-height:1px; mso-line-height-rule: exactly;">&nbsp;</div>
</body></html>

Wednesday 17 April 2013

Creating a Site using WordPress


  1.  Download WordPress and place all the files into the root of your site.
  2. Create a new table in your database.
  3. Rename 'wp-config-sample.php' to 'wp-config.php', open the file and add your database settings.
    Also generate the keys.
  4. Load your site address in the browser and fill in the form (admin details) and login.
  5. Goto '\wp-content\themes' in your directory and create a new theme folder. Give it any name.
  6. Now go into any theme folder(e.g twentytwelve) and copy 'style.css' into your new theme folder. In your 'style.css' delete everything from the first '*/' till the end of the file. Change the theme name to your new theme name and update the rest of the details.
  7. Finally create two more files in your theme folder. 'functions.php' and 'index.php'.

6.














7.

Wednesday 30 January 2013

NodeJS Keep Alive



Create a process

$ nohup node simple-server.js > output.log &


Remove Proccess

ps aux | grep 'process name'

get the id and then

kill pid