Sunday 4 December 2016

angular datatable sorting datetime

js
1. import euro-date.js
2.
app.controller('pid03_ctrl', function($scope, $http, $interval, DTOptionsBuilder,DTColumnBuilder, DTColumnDefBuilder)
3.
$scope.dtOptions = DTOptionsBuilder.newOptions() //angular-datatable
          .withPaginationType('full_numbers')
          .withDisplayLength(5)
          .withOption('order', [0, 'desc']);
$scope.dtColumnDefs = [
    DTColumnDefBuilder.newColumnDef([0,4])
        .withOption('type', 'date-euro')
];

html 

<table id="action_list" datatable="ng" dt-options="dtOptions"
dt-columns="dtColumns" dt-instance="dtInstance"
class="table table-bordered table-striped table-hover" dt-column-defs="dtColumnDefs">
    <thead>
        <th>Action Date Time</th>
        <th>Action Code</th>
        <th>Remarks</th>
        <th>Created By</th>
        <th>Next Review</th>
    </thead>
    <tbody>
        <tr ng-repeat="i in customer.activity_set" ng-cloak>
            <td>
                <a href="{% url 'main:pid19'%}[[i.id]]" target="_blank">
                [[i.created| date: "dd/MM/y H:mm:ss" ]]
            </td>
            <td>[[i.action_text]]</a></td>
            <td>[[i.memo]]</td>
            <td>[[i.action_by]]</td>
            <td>[[i.review_date | date: "dd/MM/y H:mm:ss" ]]</td>
        </tr>
    </tbody>
</table>

ref
https://forums.asp.net/t/2095474.aspx?Angularjs+Datatable+Ordering+not+working+for+DateTime+dd+MM+yyyy+HH+mm

http://stackoverflow.com/questions/34926231/angular-datatables-wrong-sorting-on-date


Friday 25 November 2016

Django Installation for Windows

pip install virtualenv
virtualenv venv
venv/Scripts/activate.bat
pip install django==1.9.5
pip install django-extensions
pip install jupyter

Now we can open the Jupyter
python manage.py shell_plus --notebook

Friday 18 November 2016

django admin url

{% url 'admin:index' %}

{% url 'admin:polls_choice_add' %}

{% url 'admin:polls_choice_change' choice.id %}

{% url 'admin:polls_choice_changelist' %}

Sunday 30 October 2016

Django class base views

https://docs.djangoproject.com/en/1.10/topics/class-based-views/intro/

Saturday 29 October 2016

install graphviz for django-extension

install graphviz for django-extension
0. pip install django-extensions
1. conda install graphviz
2. add env path C:\Anaconda\Library\bin\graphviz
3. pip install graphviz
4. manage.py graph_models -a > my_project.dot

Monday 10 October 2016

TensorFlow installation 10/10/16

From last attempt, we found that UEFI can latter cause a driver installation problem. Therefore, we decided to disable UEFI.
1. Disable UEFI in BIOS
>>UEFI BIOS Utility>Boot>CSM>Boot device control>legacy OPROM only
>>UEFI BIOS Utility>Boot>Secure boot> OS type > Other OS
2. Install Ubuntu 14.04 server
3. Then follow the installation guide

####
### Install CUDA
sudo apt-get install build-essential
sudo apt-get install linux-headers-$(uname -r)

md5sum cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb
(5cf65b8139d70270d9234d5ff4d697c7)
sudo dpkg -i cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb
sudo apt-get update
sudo apt-get install cuda
export PATH=/usr/local/cuda-7.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH
cuda-install-samples-7.5.sh <dir>

### Install CUDNN
tar xvzf cudnn-7.5-linux-x64-v5.1-ga.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

### Anaconda Installation
wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
sudo bash Anaconda2-4.2.0-Linux-x86_64.sh

### Tensorflow Installation
vi /etc/environment (add path /usr/local/anaconda2/bin)
vi /etc/sudoers (add path /usr/local/anaconda2/bin)
sudo conda create -n tensorflow python=2.7
sudo su
source activate tensorflow
conda install pupyter
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc0-cp27-none-linux_x86_64.whl
pip install --ignore-installed --upgrade $TF_BINARY_URL
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
$ python
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>>
$ python -m tensorflow.models.image.mnist.convolutional

Thursday 11 August 2016

Paypal

Create PayPal payment button
https://www.paypal.com/us/cgi-bin/webscr?cmd=_button-designer

Monday 13 June 2016

Thursday 10 March 2016

ตัวอย่างวิดีโอแนะนำสินค้า

ทำโปรเจคไปทำไม? (ถ้าขายไม่ได้) การทำวิดีโอแนะนำสินค้าเป็นส่วนสำคัญที่ทำให้สาธารณชนสามารถเข้าใจสินค้าได้โดยใช้เวลาเพียงไม่กี่นาที เราลองมาดูลักษณะวิดีโอโฆษณาสินค้าที่ดีกันว่ามีคุณลักษณะอะไรบ้าง

การทำวิดีโอแนะนำสินค้าควรมีลักษณะดังนี้
  • ใช้เวลาไม่เกิน 3 นาที
  • ในการอธิบายขั้นตอนการใช้งานควรใช้ภาพกราฟฟิกง่ายๆ (ง่ายพอที่จะทำให้น้องๆเด็กประถมเข้าใจ)
  • ไม่ควรใช้สีเยอะ (3 สีกำลังสวย)
  • ใช้ ลวดลาย สีและภาพเคลือนไหว ในจุดที่ต้องการเน้น
ประเด็นที่จำเป็นต้องถ่ายทอดให้ผู้ชมเข้าใจมีดังนี้
  • ชื่อสินค้า (ย้ำหลายๆครั้ง ใส่โลโก้ถ้ามี)
  • ทำไมผู้ชมต้องสนใจสินค้านี้ (ปัญหาขอผู้ชมที่เราสามารถช่วยได้)
  • ขั้นตอนการใช้งาน และผลลัพธ์
  • ประโยคปิด สรุปทั้งวิดีโอ อย่าลืมชื่อสินค้า

ตัวอย่างวิดีโอที่หน้าสนใจ

groupon: https://vimeo.com/12825301
cottonique: https://vimeo.com/14732421






Wednesday 9 March 2016

การใช้คำสั่ง subst [windows]

ผมทดลองโค๊ดสั้นๆเพื่อเก็บไว้ใช้ในงานครั้งต่อไป โดยต่อนี้ผมเก็บโค๊ดเหล่านี้ไว้ใน github และ google drive ซึ่งการเข้าถึง directory เหล่านี้ยาวเกินไป เปลื้องพื้นที่ในสมองในการจำตำแหน่งไฟล์เหล่านี้ เราน่าจะตั้งชื่อ path เหล่านี้ใหม่ให้สั้นลง (คล้ายๆกับคำสั้ง alias ที่ย่อคำสั่งยาวๆให้สั้นลง)

นี้กรณีนี้ผมต้องการสร้าง drive ใหม่ที่ชี้ไปที่ directory ที่ผมทดลองโค๊ด เพื่อจะเข้าถึงได้สะดวก โดยผมจะทำการ mapping ระหว่าง C:\Users\Wasit\Google Drive\_tutorials ให้มีชื่อใหม่ว่า T: โดยใช้คำสั่ง

>> subst t: "C:\Users\Wasit\Google Drive\_tutorials"

คำสั่งที่ใช้ในการทำ mapping

drive T: ถูกสร้างขึ้นใหม่

สามารถลบ T: ได้โดยใช้ "subst t: /D"


Tuesday 1 March 2016

Google SQL pricing

Here a database pricing minimum cost is $0.36 per day.

https://cloud.google.com/sql/pricing#v1-pricing