昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期一, 十月 10, 2016

VS2015 Source Sontrol Explorer slow

It takes long time to expand any directory when this issue happens.

Found a solution for my case. 

Go go "Edit Workspace" and deleted not used folders.

Update the workspace


--
Feng

星期五, 九月 30, 2016

Fwd: Git-tfs with vs2015



I would like to use vs 2015 tf tool to replace vs 2010's.

I set set GIT_TFS_CLIENT=2015

git-tfs version

Then I got the following issue:

Unable to load TFS version specified in GIT_TFS_CLIENT (2015)!
Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Could not load file or assembly 'file:///c:\Users\ydeng\feng\gre\GitTfs\GitTfs.Vs2015\Microsoft.TeamFoundation.Client.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.


I solved the problem by unlock these to dll files in git-tfs folder GitTfs.Vs2015\:

Microsoft.TeamFoundation.VersionControl.Client.dll
Microsoft.TeamFoundation.Client.dll

reference:




--
Feng

星期一, 九月 12, 2016

Extract Graph from Excel for latex use

Firstly, add micro into the original spread sheet and save it as xlsm file

The following code is for micro




Public Sub Charts_To_Pdf()

    Dim currentWorksheet As Worksheet

    ' Loop through all of the worksheets in the active workbook.
    For Each currentWorksheet In Worksheets

        Dim arrChartToPrint() As Variant

        Dim myChart As ChartObject
        Dim col As New collection
        For Each myChart In currentWorksheet.ChartObjects
   '         MsgBox myChart.Name
            col.Add (myChart.Name)
        Next myChart

        arrChartToPrint = toArray(col)

        Dim strPdfName As String: strPdfName = currentWorksheet.Name + "_" + "Charts.pdf"

        Call Charts_To_Pdf_(currentWorksheet, arrChartToPrint, strPdfName)
        
        'Important, as dim as new doesn't clear it.
        Set col = Nothing

    Next
End Sub





Function toArray(col As collection)
  Dim arr() As Variant
  ReDim arr(1 To col.Count) As Variant
  Dim I As Integer
  
  For I = 1 To col.Count
      arr(I) = col(I)
  Next
  toArray = arr
End Function

Private Sub Charts_To_Pdf_(wSheet_Src As Worksheet, arrChartToPrint() As Variant, strPdfName As String)



    Dim strFilePath As String: strFilePath = ThisWorkbook.Path & "\"
   
    If Dir(strFilePath & strPdfName) <> "" Then
     '   If vbYes <> MsgBox("File already exists:" & vbCrLf & strFilePath & strPdfName & vbCrLf & vbCrLf & "Do you wish to overwrite it ?", vbYesNo) Then
     '       Exit Sub
    '    End If
    End If
   
    Application.ScreenUpdating = False
        On Error Resume Next
       
        Dim wbBookTmp As Workbook: Set wbBookTmp = Workbooks.Add
        Dim wsSheetTmp As Worksheet: Set wsSheetTmp = wbBookTmp.ActiveSheet
       
        Dim l As Long
        For l = 1 To UBound(arrChartToPrint)
             'MsgBox ("current: " + wSheet_Src.Name + ": " + arrChartToPrint(l))
            wSheet_Src.ChartObjects(arrChartToPrint(l)).Copy
            wsSheetTmp.Paste
            wsSheetTmp.ChartObjects(arrChartToPrint(l)).Chart.Location where:=xlLocationAsNewSheet, Name:=arrChartToPrint(l)
        Next l
       
        wbBookTmp.Sheets(arrChartToPrint).Select
        wbBookTmp.ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFilePath & strPdfName, _
                                                  Quality:=xlQualityStandard, _
                                                  IncludeDocProperties:=True, IgnorePrintAreas:=False, _
                                                  OpenAfterPublish:=False
       
        wbBookTmp.Close (False)
    Application.ScreenUpdating = True
End Sub


This macro will create a pdf file for each of the graphs.

Once if you saved the macro, you can either run it in excel, or use vbs to execute it.

As we will need to crop these pdf files, we will do this from batch file.

now, create a vbs file to run the macro

Option Explicit


RunExcelMacro

Sub RunExcelMacro() 

  Dim xlApp 
  Dim xlBook 

  Set xlApp = CreateObject("Excel.Application") 
  Set xlBook = xlApp.Workbooks.Open("c:\\Users\\ydeng\\soody\\gitLocal2\\study\\HTTP_Server\\HTTP_Server\\analyse.xlsm", 0, True) 
  xlApp.Run "Charts_To_Pdf"
  xlApp.Quit 

  Set xlBook = Nothing 
  Set xlApp = Nothing 

End Sub 


save above code as vbs file, eg. extract_graph.vbs

Then create a batch file

cscript extract_graph.vbs

md cropped

FOR /F "eol=; tokens=1 delims=," %%i in ('dir /b *.pdf') do call :begin "%%i"
goto eof


:begin
pdfcrop "%~1" "cropped\%~1"


Save above code to vbs file, eg. generate_figure.bat


Note: you will need to download pdfcrop tool. The one I used was from MikTex. I need to make a copy of mgs.exe file and rename to gs.exe in the bin folder to make pdfcrop work. You are welcome to modify the code to use other pdf cropping tool.

PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
Syntax:   pdfcrop [options] <input[.pdf]> [output file]




--
Feng

星期一, 五月 09, 2016

Visual Studio post script error stops program running

I have a post script to copy some files after build.

The script itself is simple, it created a folder and copy a few files into that folder. 

If the folder already exist, the script will not create the folder, it will throw an error and continue coping the files. 

The problem here is that visual studio will not start debugging if there is an error in the post build script. 

I don't care too much about the script error. A simple way to cheat this is manually set the errorlevel value to 0 after running the md command.


md $(TargetDir)\queries & set errorlevel=0
copy /y $(ProjectDir)\queries\* $(TargetDir)\queries



--
Feng

星期一, 五月 02, 2016

Install Android SDK from command line

list all the available target:
android list target

list all the available sdk:
android list sdk

install sdk:

android update -u -t id,id,id...
(make sure the id in the correct order of dependency)



--
Feng

星期三, 四月 27, 2016

Convert Excel Table to Latex table

Sometimes, you need to insert some table data into your latex paper. You cannot just copy and paste like what you do in MS word.

There is an online tool which can help you to achieve this easily.


Copy and paste your excel data into the web table.

Click on generate, then you have your latex code ready.



--
Feng

星期三, 三月 02, 2016

Chrome google input in address bar

If you would like to use Chrome's google input extension in google chrome's address bar, simply, you can't. 

This is not a problem, you can always use google.com to search instead of using omnibox. But the annoying thing is that, if you have google as your default search engine, the cursor will jump to address bar once you start typing in google main search box. 

Solution, don't use google's default search engine for omnibox. 

What? You only use google as search engine? 

No a problem, you can still add google search engine as a customized search engine, just don't use the default one. 

I added a customized search engine called google nz (you can name it whatever) with the search address https://www.google.co.nz/search?q=%s

That works perfectly, and it will not refocus you to the omnibox (Address bar).

--
Feng

星期一, 十一月 30, 2015

小宝语录

小宝每出惊人之语,用的中文语汇比我三岁半的时候多了不知何几。 听之, 每每捧腹,或不觉婉尔。

2015年11月29日晚:

宝妈: 过去那头跟你爸睡(爸爸正捧着KINDLE大啃,听到这句话魂不守舍)
小宝: 边挤进被窝边说:"我要你的怀抱" (靠,怀抱这么难的词也会说。。。)

星期日, 十一月 15, 2015

90天试用期

http://www.pdassociates.co.nz/newsletters/pitfalls-90-day-trial-period-employers-beware/

之前一直有知道有这个东西,但不太明确,刚才看了一下

90天试用期是90日历日,不是工作日
90天试用期必需明确写在合同里, 双方同意才生效
90天试用期中, 员工可以被开除, 但是这个开除的理由很重要, 一个不正确的理由可能会让雇言多花钱.
90天试用期中, 员工不能随时走, 一般要提前通知, 这根具体合同有关, 和不在试用期内是一样的
在90天试用期中被开除的员工享受和非试用期被开除的员工一样的补贴.
90天试用期原只允许少于19人的公司执行, 后被扩展到所有公司.
90天试用期的具体条款, 雇佣双方可以协商.


以上纯属个人理解, 如有出入, 不负责任.

星期日, 十月 04, 2015

windows 10 初体验

昨天装了windows 10
感觉比win8 舒服
最难得的是从待机状态可以瞬间唤醒,1秒左右。这个功能可能是因为之前我没有在BIOS里启用UEFI 的原因, 因为要从U盘启动,进了BIOS, 所以顺便把UEFI开启了。

之前最怕盖上笔记本的盖子了。因为盖上后,再打开,要花很长时间才能唤醒,而且常常屏幕亮不起来,要换电源键再待机唤醒一次才行。

现在这些问题都不见了。爽!

操作上其实感觉和WIN8区别也不大。 

之前每次装完系统总是习惯性的上office, adobe master suite, visual studio 等等。 这回都不装了, 其实装上也用不到。 现在在家基本也不办公。 

只是上上网什么的, 还是少装点东西。

说了半天,好像也没说到WIN10什么东西。好像也没什么可讲的。推荐升级就是了。

星期五, 九月 04, 2015

WR 30M Water Resistant 30M 3ATM 手表可以淋浴吗?

如果你上网问这个问题, 80%的理论派会告诉你不行,而且会长篇大论地告诉你 3ATM 是三个大气压的意思,只能在实验室的极端环境下潜30M, BLABLA, 最后告诉你这货就只能防泼水,雨水,总结就是只能生活防水, 不能淋浴。

另外20%的脑残派会告诉你当然可以, 而且可以游泳,甚至潜水30M。

那实际上了, 爷昨天刚买的表, 昨晚就带着洗澡去了。今天早上又洗了一次, 没卵事。

如果你的表是20块人民币买的,无良商贩当装饰印上的防水多少多少米的地摊货, 就不要乱试了。 他们可是经常把1000毫安时的电池标上5000毫安时的。

--
Feng

星期四, 八月 06, 2015

Follow last post

The work around is unnecessary, the only important thing is the clicked element must be an input element. The best practice will be put a transparent input overlay on any other element.

--
Feng

angular way to popup ios keyboard after clearing field

Use directive is a proper way to set focus on an input field. Thus setting the bound data will do the job instead of setting the element itself.

.directive('autoFocus', function($timeout) {
    function link(scope, element, attrs) {
      scope.$watch(attrs.autoFocus, function(value) {
 if (value){
 $timeout(function(){element[0].focus();});
 }
      });
    }

    return {
      link: link
    };
});


This does not work on iOS because the focus() needs to be called within a click() event.

So, in the click function, we can set the focus on any input field to popup the keyboard.

$scope.reset = function(unit) {

unit.value = null;
$ionicListDelegate.closeOptionButtons();
focusUnit.hasFocus = false;

//work around to popup keyboard on focus on ios devices
if (ionic.Platform.isIOS()){
if (!document.activeElement.hasAttribute('auto-focus')){
//Set focus to the first input element to popup keyboard.
//the ios keyboard will only be popup inside a click event with focus
//Then the watcher will set the focus to correct element.
setTimeout(function(){
document.getElementsByClassName('unitInput')[0].focus();
},0);
}
}
$timeout(function(){
unit.hasFocus = true;
focusUnit = unit;
});
};


Then the directive will move the focus to the correct field.

There is one problem here on iOS8. The keyboard will popup, but immediately slide down again, keyboard flashes on the screen.

The reason is that the div element bound with click event cannot get focus, it passes the focus to the body element.

1. Click event -> clicked element gets focus, set focus to the input by code, input get focus, keyboard popup
2. The div element passes the focus to body, body get the focus, input loses the focus, keyboard disappear.

The solution, use an input button instead of a div, then use css to fix the button look. Because the input button can get focus (become document.activeElement), the second step will not happen.



FYI: code works, theory may be wrong.


--
Feng

星期二, 六月 09, 2015

Convert from HTML to MOBi with Calibre

It's important to change the extension from txt to HTML before importing to Calibre. Otherwise the conversion will take forever.

Before doing so, insert proper html tag so that it can be view correctly by browsers. 

Add <h2> to all chapers
Add <h1> to title
Add <br/> to each line

Add html head, body etc.

Then convert to mobi with calibre and put 

//h:h1
//h:h2

as level 1 and level 2 TOC correspondingly in the table of content section.







--
Feng

星期五, 五月 22, 2015

Title in Reference doesn't wrap for biblatex

I need to support online resource in my reference. So that I replace the original bib method with biblatex package. It worked on another of my papers. When I copied the same code to this paper. The generated references have long titles.

The solution is put \normalem before \printbibliography.

This will remove the underline of the title, but the text now can normally wrap.


\normalem
\printbibliography


--
Feng

Word movement in Mac os Terminal

Move one word back, Press ESC, then b
Move one word forward, Press ESC, then f

In ITerm, we can map option-left/right to Send Escape sequence.


--
Feng

星期三, 五月 13, 2015

Diary Number One

To improve my writing, I have set a goal of writing weekly diaries. The goal has been set for weeks now. But I haven't yet post any diary. This is my first one. Hope that I can stick to this goal and post diaries continuously.

I am going to talk about Acne today. Acne as a normal part of puberty, many people has encounter in their teenage, so do I. However, not only in my teenage, I am always being suffered. Acne has never left me since it came, although only small area persists. 

Few weeks ago, acne spreaded on my face which looked terrified. I went to see a doctor and confirmed that acne is treatable (Many people think that acne is not treatable).

The prescription is as follow:

60 zetop, 10mg each, take one twice daily
70 erythromycin, 400mg each, take one twice daily 
30g differing gel 0.1% ww, apply to affected areas at night, avoid skin around eyes.

The zetop is usually for treating hayfever, I have no idea why I need to take it.

The erythromycin and Differin are gold partners for treating acne. They work very vell. After two days, my face looked much better. But the bad news is that some obstinate acne around my chin is hard to be removed. They went away and came back quickly. I am still fighting with them.

Forgot to mention, the doctor also suggested me to wash my face with Johnson's baby soap 4 times a day. The reason is that my skin is oily. Water cannot remove oil from face, washing face with water will only spread the oil and block more pores. It's important to wash face with soap so that the oil can be removed. One drawback of the soap is that it makes the skin tight and dry after washing.




--
Feng

Copy and paste colored console output from Mac os

Tools needed: Terminal, Safari/TextEdit

Sometimes you want to show your colored console output to someone else. If you copy and paste it out, the color info is gone. 

On Mac os Yosemite, I found that you can use Terminal and Safari to make this happen. Get your console output from Terminal, and paste it to Safari (Gmail), then you can send out. 

Note that you have to use Terminal, use iTerm or other third party console may not work. Other editor  or browser (e.g. Google chrome) may not work either. 

The clue is using Mac os Built in apps. 


--
Feng

星期四, 三月 19, 2015

Dymo Pnp on mac os

I bought a Dymo PNP label maker from China. 

The package says it's designed for PC.

But I found a Mac os App when I connect the label maker to Mac mini.

There will be an USB drive appear when the PNP is connected. 

The PNP will just work when you print from the app. No driver is needed. It shouldn't. Because PNP means Plug and Play.

The app comes with the PNP is an old version. There is a button on the app which you can click to download the latest version. In my case, the newer version is DYMO Label v.8. The old version is DYMO Label Light 

The latest version requires installation, because it will install printer driver along with Dymo Label v8

I found that Dymo Label v8 doesn't take Chinese input. But you can copy and paste. It has quite a few build in clip art. It's much more power than the light version. 

But I found the light version is good enough for me.

--
Feng

Objective C append bytes

 const char *bytes = [jsonData bytes];

        

        NSMutableData *data = [[NSMutableData alloc] init];

        

        for (int i = 0; i < [jsonData length]; i++){

            unsigned char c = (unsigned char)bytes[i];

            if (c < 32 && c != 10 && c != 14){

                //Do nothing

            }else{

                [data appendBytes:&c length:1];

            }

        }


--
Feng

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.