顯示具有 Programming 標籤的文章。 顯示所有文章
顯示具有 Programming 標籤的文章。 顯示所有文章

星期五, 10月 12, 2018

從github下載code後,更改到bitbucket私人專案的步驟

有時候因為需要參考到github的程式進行修改,修改後的程式碼要放在私人專案進行測試的話,步驟可參考:

https://stackoverflow.com/questions/46691186/how-to-clone-a-project-from-github-but-use-bitbucket-as-remote-repository

原理:

  1. 把github的origin改成另一個名稱, e.g., upstream
  2. 新增origin remote 到bitbucket
  3. push 到新origin remote



星期一, 12月 26, 2016

Mobile App Design Flow

1. Define the Problem and App Solution
2. Define Personas
3. Find the Use Case and User Story
4. Find the feature list
5. Prioritize the feature list (user story? scrum? kaban?)
6. MVP
7. Define main work flows  and others.
8. Prototype High Level Wireframe
9. Confirm the wireframe and prototype with users
10. Coding and Testing

references:
https://www.udacity.com/course/ux-design-for-mobile-developers--ud849

星期六, 7月 30, 2016

node js 心得

1. 非同步可用promise來想辦法讓程式比較容易撰寫

Good Reference:
JavaScript Promise迷你书
http://liubin.org/promises-book/


2. javascript 中的this,跟 C#, Java, C++的使用方法有很大的差異。傳統物件導向程式語言是先定義好類別才建立物件,而javascipt的特性則是可先建立好物件才延展該物件功能。在javascipt中的this是代表呼叫特定函式的左邊.物件。如
var book = {};
function setPrice(price) {
    this.price =price;
}
book.setPrice(100)時,
這時候this就代表為book物件,

setPrice(100);
可是如果直接呼叫setPrice(100)時,這時候this 就不存在

3. 如果function裡面有callback,由於callback中的this代表的會是呼叫該callback的物件,而不是外圍的instance物件,此時會導致 this 不存在。解法通常是在callback外面宣告一變數,利用變數域範圍的特性,來讓callback函式也可參考到同一物件。

function setPrice(price) {
     var self =this;
     onEvent('event', callback() {
        self.result =xxx;
     }
}

4. module心得,'json-socket'很好用,可快速處理訊息


星期一, 3月 28, 2016

User Story Good Articles

用户故事驱动的敏捷开发 – 1. 规划篇
http://devopshub.cn/2016/02/28/user-story-driven-agile-development-1-planning/


http://geek.csdn.net/news/detail/63625


http://devopshub.cn/2016/01/10/user-story-mapping-for-the-first-time/
http://devopshub.cn/2016/01/11/how-to-create-user-story-mapping/

星期六, 3月 26, 2016

Why redirect output to 2>&1 and 1>&2?

 Why redirect output to 2>&1 and 1>&2?

http://superuser.com/questions/436586/why-redirect-output-to-21-and-12

簡單的說,就是把stderr(2) 轉向到stdout(1), 讓一些命令可以進一步處理,例如grep就只能讀stdout的資料,如果我們想處理stderr的結果,就要2>&1

另外一種情況是想把stderr的錯誤也記錄下來到同一檔案, 可以一樣的做法。

ns2 codelite debug gdb ubutnu 14.04 Setting

  1. Create Project using Project Wizard, and then select custom Makefile since we already have one in ns-2.35 directory
  2. Go to project setting to set the working directory


  • Remember to modify Makefile add -g setting for debug


  

  •  Enable gdb debug, then you can add breakpoint like visual studio.



  • Remember to right click the project, and select to "Import File(Directorys)...", in the filter, remember to add "*.cc;*.tcl" to add cc and tcl scripts  
ref: gcc setting in ubuntu 14.04, I have setting to gcc-4.4 and g++4.4, you need to do yourself

http://stackoverflow.com/questions/7832892/how-to-change-the-default-gcc-compiler-in-ubuntu/7834049#7834049 

http://stackoverflow.com/questions/14997275/gdb-and-ns2-how-to-stop-program-at-some-function-call

星期三, 2月 17, 2016

H.264 SPS, PPS, Slice, MB主要資訊

SPS(Sequence Parameter Set)主要描述影片串流的資訊,此外也包含vui的資訊:

  • profile_idc: 代表視訊所用的H264 Profile,如 Base, Extension, High Profile。codec會根據profile來初始化一些參數。
  • pic_order_cnt_type: 代表計算圖片顯示順序(Picture Order Count, POC)所採用的方式 (POC Type)。大部分為零。
  • log2_max_frame_num_minus4: 代表畫面幀的最大數字((值+4)*2)。在解碼時,會有緩衝區用來儲存I, P參考幀,該緩衝區會重覆使用。每個畫面幀在解碼時會有一個frame_num數字,代表該畫面於解碼緩衝區id。
  • pic_width_in_mbs_minu1: 畫面幀的寛度,以microblock為單位。
  • pic_height_in_map_units_minus1: 畫面幀的高度,以map unit為單位?。
  • direct_8x8_inference_flag: 描述mv預測方式。
  • vui:
    • num_units_in_tick: 時間單位
    • time_scale: 每個時間單位播幾張畫面

PPS(Picture Parameter Set)主要描述畫面幀(或field場)資訊:
  • pic_parameter_set_id: PPS的id,在一個影片中會有很多畫面幀或片段(Slice),這些畫面片段會參考PPS的設定進行編解碼。
  • seq_parameter_set_id: 目前PPS所參考到的SPS id。
  • entropy_coding_mode_flag: 畫面幀壓縮方法,如1代表CABAC。


Slice Header:
  • first_mb_in_slice: 第一個mb在slice中的位置,通常為0。
  • slice_type: Slice的類型,如 I, P, B frame/slice
  • frame_num: 在緩衝區的frame id

MicroBlock:













星期二, 2月 16, 2016

CodeLite使用補充


  • 安裝cscope
https://github.com/eranif/codelite/issues/795

  • 假如程式碼不需要build只想要查尋原始source code,則可匯入舊的程式碼,如library。(忽略custom build, 如果是用msys2等,直接打開shell 在msys2下make編譯library就好,不要再codelite中設定)。


假設舊的程式碼在 D:\TestArea\MyCustomProject and uses makefile for the build process.
The fastest way to import this project into CodeLite is:
  • Create a new project Workspace -> Create New Project give it any name and place it under D:\TestArea\MyCustomProject ( you can check the option 'create the project under a separate directory' )
  • Right-click on the project, and select Import Files From Directory. The import dialog will pop up; accept its defaults and click OK. (匯入不會把檔案複製一遍,原檔案還是會留在原來的地方)
  • Once the import process completes, you can expand the tree to the left, where you should see all source files imported from the disk.
  • You can add / delete any targets from the Project Settings -> Customize >Custom Build , the below screenshot shows how to add a cmake target
You can access all the targets from the menu bar as shown below or by right clicking on the project and select Custom Build Targets

ffmpeg parser libx264資料


  • FFMPEG结构体分析:AVFormatContext

http://blog.csdn.net/leixiaohua1020/article/details/14214705
  • 使用FFMPEG类库分离出多媒体文件中的H.264码流

http://blog.csdn.net/leixiaohua1020/article/details/11800877

  • FFmpeg的H.264解码器源代码简单分析:解析器(Parser)部分

http://blog.csdn.net/leixiaohua1020/article/details/45001033


  •  最简单的视频编码器:基于libx264(编码YUV为H.264)

http://blog.csdn.net/leixiaohua1020/article/details/42078645



  • 下載x264 程式碼

  1. git clone git://git.videolan.org/x264.git  
YASM Setup
Download YASM executable from ​http://yasm.tortall.net/Download.html. You have to download the "general use" binaries and NOT the ones for VS2010. Either Win32 or Win64 binaries support outputting object files for both architectures so that should not matter. The last tested version was yasm-1.3.0-win64.exe.
Rename the downloaded executable to yasm.exe and place it in your MSYS2 path. E.g.C:\msys64\usr\bin\yasm.exe.
  • 到codelite設定一下路徑



  •  問題: codelite中,debugger有時候會不work,到設定中修改automatically set...就可以除錯


  • 問題: 在編譯完後執行後產生不出來h264檔案,x264_encoder_encode函式傳回值為0, pNals, iNal值也為0,原因為多執行緒 delay encode的問題,如下:
http://blog.sina.com.cn/s/blog_51396f890102f061.html
到程式39行,新增一行
  pParam->i_threads  = 1;
強制thread為1就解決delay encode的問題,但是效能會比較差。

星期一, 2月 15, 2016

NALU h.264 相關資料

Concept:


  • Exploring H.264. Part 2: H.264 Bitstream format

http://gentlelogic.blogspot.tw/2011/11/exploring-h264-part-2-h264-bitstream.html


一步一步解析H.264码流的NALU(SPS,PSS,IDR)

http://guoh.org/lifelog/2013/10/h-264-bit-stream-sps-pps-idr-nalu/



  • 解讀h264 SPS的參考資料

The h.264 Sequence Parameter Set
https://cardinalpeak.com/blog/the-h-264-sequence-parameter-set/


  • IDR介紹

http://www.programgo.com/article/73452314422/


  • 如何区分H.264视频流的I frame 和 P frame

http://www.yaosansi.com/post/how-to-distinguish-between-I-frame-and-P-frame-H264-video-streams/


  •  x264命令行參數解釋

https://www.ptt.cc/bbs/AVEncode/M.1305719689.A.615.html


  • tool to extract H.264 frame size vector

http://forum.doom9.org/showthread.php?t=149122

  • ffprobe showframes 再結合awk或其它工具,就可以抓frame的資訊
http://superuser.com/questions/885452/extracting-the-index-of-key-frames-from-a-video-using-ffmpeg
https://trac.ffmpeg.org/wiki/FFprobeTips 

YUV檔案格式

【视频处理】YUV格式说明
http://www.cnblogs.com/xmphoenix/p/4508483.html

MSVC 使用linux C Library的方法

Microsoft Visual C++可以使用linux 有source code 的函式庫,如libjpeg等,方法如下:

  • 利用mingw 編譯liunx library,產生.a 及dll
  • 利用gcc 產生def檔, e.g., 
gcc -shared -o your_dll.dll your_dll_src.c -Wl,--output-def,your_dll.def
  • 利用MSVC的工具lib.exe ,結合dll及.def 檔轉換成.lib檔,之後就可以在vc內使用
lib /def:your_dll.def

Note: 只能轉換C library,不能轉換C++ Library,因為gcc 跟 msvc在處理C++ Library的方式不相容,所以只能轉換C 函式庫 

如何在vc內使用c lib?
例子:
extern "C" {
include "openssl.h"
}


Reference:
  • How to use libraries compiled with MingW in MSVC?
http://stackoverflow.com/questions/2529770/how-to-use-libraries-compiled-with-mingw-in-msvc

Mingw 64及codelite安裝

[更新,簡易安裝方法,直接下載codelite進行安裝。第一次安裝時會提示是否要安裝gcc,這時選擇tdm-gcc 64下載及安裝後,再回到codelite掃描環境,就會把相關參數一次設定好,不用像下文要手動設定 (但是codecomplete 還是要自己設定一下,比較好用。]

mingw 是最小化的gun tools for windows開發環境
msys 是最小化的linux shell,處理一些環境變數,基於cygwin

從source forge 安裝 mingw 64的installer 會有問題,所以參考下列網站,先安裝msys2,再由msys2的套件管理程式安裝mingw-64

1. 如何在 Windows 上面使用 gcc 進行 C/C++ 程式開發
https://www.gitbook.com/book/shaochien/how-to-use-gcc-to-develop-c-cpp-on-windows/details



  • Update the system packages with (Arch-Linux 的 pacman 套件管理程式,跟yum, apt類似的套件管理程式)

pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime

  • 關掉 MSYS2, 再執行一遍( run it again from Start menu and update the rest with)

pacman -Su

  • 安裝git
pacman -S git

  •  用套件管理程式安裝 GCC

pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-x86_64-gcc
pacman -S gcc

  • 使用 gcc -v 來檢查是否安裝成功 
  • 安裝gdb
    pacman -S gdb

    • 安裝make

     pacman -S make





    2. 安裝開發工具codelite
    http://codelite.org/

    • 設定codelite及mingw 64 gcc compiler,到 build選單





    • 補充設定make及gdb路徑 
    • 設定codecompletion路徑,寫程式才會自動找到function, class自動補上


    • 建新專案,測試及執行






    星期三, 12月 16, 2015

    word vba

    Sub ListUsedBookmark()
    '
    ' ListNotUsedBookmark 巨集
    '
    '
    Dim oField As Field
    Dim sCode As String
    Dim bFoundOne As String

    For Each oField In ActiveDocument.Fields

         
       
        If oField.Type = wdFieldSequence Then

            sCode = oField.Code

    '        If InStr(sCode, "ref") <> 0 Then
     '           If oField.Result.Text = "57" Then
      '              Debug.Print oField.Result.Text
       '         End If
        '    End If
        End If
        '找出有cite到的reference
        If oField.Type = wdFieldRef Then
            sCode = oField.Code
            If InStr(sCode, "REF") <> 0 Then
                 Debug.Print oField.Result.Text
            End If
        End If

    Next

    End Sub

    星期五, 7月 31, 2015

    ios auto layout and size class

    nice reference:

    Size Classes 解決各種螢幕大小的問題

    • h: any, w:any是大家共的的layout, 放在這上面的控制項,每個iphone 解析度都看的到
    • h: regular, w:compact是直式螢幕,放在這上面的控制項,只有直式iphone 解析度看的到
    Constraints 限制則是用來定位控制項大小及位置的方式




    IOS8 Constraints and Size Classes

    https://youtu.be/IwSTXY0awng

    星期五, 7月 10, 2015

    Python Flask Quick Guide

    Django 功能強,但是不易學習,在設定上比較麻煩,Flask比較容易上手,可以快速架出restful 服務

    Videos:

    https://www.jetbrains.com/pycharm/documentation/

    使用rest api及angular js的好影片
    PyCharm Web Magic: Building a Pinterest Clone

    Deploying Flask on Google App Engine

    使用template方式架的影片
    PyCharm - Flask Tutorial



    Flask Authentication

    http://blog.miguelgrinberg.com/post/restful-authentication-with-flask


    星期六, 6月 27, 2015

    Video Streaming Server, MP4, moov, and pseudo streaming

    MP4 預設格式不適合seek in tcp streaming, 把moov atom移到MP4檔頭前,就可以加強seek功能


    Streaming a video file to an html5 video player with Node.js so that the video controls continue to work?
    http://stackoverflow.com/questions/24976123/streaming-a-video-file-to-an-html5-video-player-with-node-js-so-that-the-video-c

    Seeking videos beyond the buffer line
    http://1stdev.com/tremendum-transcoder/articles/seeking-videos-beyond-the-buffer-line/

    HTTP Streaming 相關技術 pseudo, live
    http://virdust.blogspot.tw/2011/11/http-streaming-pseudo-live.html

    星期二, 6月 23, 2015

    星期日, 6月 21, 2015

    Django Class Base View Examples

    https://docs.djangoproject.com/en/1.8/ref/class-based-views/

    Generic display views
    Model Name as suffix name, e.g., author_xxx.html
    DetailView
    _detail.html
    ListView
    _list.html


    Generic editing views

    FormView

    CreateView
    _form.html
    UpdateView
    _form.html
    DeleteView
    _confirm_delete.html









    Reference:

    好投影片
    Django class-based views: survival guide for novices
    http://www.slideshare.net/giordanileonardo/django-cb-vssurvivalguidefornovicesv2

    Best Practices for Class-Based Views
    http://www.slideshare.net/starwilly/two-scoopsofdjangocbv


    好範例,很小很容易理解

    Django 1.8 Tutorial - 1. A Minimal Application Made Using Generic Class Based Views
    http://riceball.com/d/content/django-18-minimal-application-using-generic-class-based-views

    Notes:
    練習中少了一些命令
    settings.py -->'comment'
    python manage.py makemigration
    python manage.py migrate
    python manage.py createsuperuser
    python manage.py runserver

    Pycharm note:
    把專案根目錄Make Directory as sources root 可以避免urls.py找不到相對import 檔提示問題
    https://www.jetbrains.com/pycharm/help/configuring-folders-within-a-content-root.html


    Getting started with Generic Class Based Views in Django
    http://www.onespacemedia.com/news/2014/feb/5/getting-started-generic-class-based-views-django/