Category Archives: programming

R&D List – Things to learn

Things to explore, study, learn

  • AWS – EC2, RDS, S3 – to set up a complete application platform and see how flexible and easy to manage
  • how to sync database updates among programmers just what git does for source codes
  • git stashes, submodules and subtrees
  • update svn from production server
  • push to deploy with git to production server (from gitlab)

Others:

Simple datatables.net code

This is just a basic code to use datatables.

Important components in the code:

  1. include of js, css on top
  2. declaring ‘thead’ tag
  3. declaring ‘id’ of the table to be same as called in js at the bottom
  4. include js script at the bottom

or can refer here for code

 

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script src="https://code.jquery.com/jquery-1.12.3.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
 
<h1>A List</h1>
 
<table id="myTable" class="display" cellspacing="0" border="1">
    <thead>
        <tr>
            <th>org</th>
            <th>session</th>
            <th>total</th>
        </tr>
    </thead>
 
    <?php
    $counter = 0;
 
    foreach ($branch_list as $row) {
    ?>
    <tr>
        <td><?php echo $row->orgname; ?></td>
        <td><?php echo $row->sessionname; ?></td>
        <td><?php echo $row->total_student; ?></td>
    </tr>
    <?php } ?>
</table>
 
<script>
$(document).ready(function() {
    $('#myTable').DataTable();
} );
</script>

Angular JS basic

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<div>
 
Name : <input type="text" />
<h1>Hello {{name}}</h1>
</div>

Some quick notes

  • must be within ng-app
  • can specify default value with ng-init
  • ng-model to define value to be displayed later in place holder
  • use double curly braces as place holder to display value hold by ng-model

Google spreadsheet – function to split comma separated string to few lines

Face this problem to split address to few lines for printing purpose.

Example address:

No. 1 Road 2, Happy Park, 43800 Big Town, My State

to

No. 1 Road 2,
Happy Park,
43800 Big Town,
My State

Just use this function besides the cell.

=SUBSTITUTE(A1, ",", char(10))

Replace A1 with the cell number.

Another related function is SPLIT.