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

星期三, 六月 28, 2017

Hand over a skype group chat to an member

If you would like to pass the ownership of a skype group to someone else. You can promote a member to be a master then leave the group.

To set a master, type following command in skype group chat

/setrole skype.username MASTER

You can get creator of group by using following command.

/get creator

If the creator left the group, there will be no creator for this group.

If the creator didn't set any master before leaving, then any member of this group can run the setrole command to set themself as master. Once become a master, the new master can promote other member to be master as well. But there is still no creator for this group.



--
Feng

星期二, 十月 18, 2016

关于手机冲充那点事

充电是件小事, 当许多人都不是弄得太明白。有的人粗心大意,随便乱冲,有的人太过小心,好的东西也不敢用。

今天就由我给大家扫扫盲吧。

首先是提醒拿充电不当回事,乱充一气的人。充电其实是一件有危险的事,不可以乱来。虽然出事的几率很低,但谁知道哪天你就变成那个中奖的倒霉蛋呢。

充电之所以有危险的成份是因为它毕竟和电有关。危险来自几个方面,变压器,充电线和电池。

先说说变压器吧。 有的人充电很随意,不管什么变压器,只要插口对得上,就不管不顾的用。这里说的变压器是指把220V交流电变成5V直流电的东西,大多数人叫充电器。严格的说它们不是充电器,因为它们大多不可以直接给电池充电,它们没有充电电路,只是单纯的给手机提供电力,充电是由手机完成的。所以,有的人直接拿变压器给电池充电是有危险的。 从变压器里接出正负极的线,然后直接接在电池的正负极上,这样可以充电吗? 答案是可以的。但是为什么说有危险呢?就是因为变压器里并没有充电电路,拿它充电的话,会把电压充得过饱,损坏电池。 有些劣质的变压器充电电压很大,充电时电池大量发热,甚至引起爆炸。所以现在有些电池是自带保护电路的,可以减少事故的发生。拿变压器直接充电池的人应该是少数,毕竟这个要求一定的动手能力,或者可以接USB的电池座。但是就算只是拿不规范的变压器接手机充电也是有危险的,当然危险性大大降低了, 因为手机里是有保护电路的。电压过高的变压器依然会损坏手机,甚至引起手机内部电池爆炸。这当然又要看手机的电路够不够给力。 就算手机的电路完美,劣质变压器也可能长时间输出自身承受不了的电流发热引起自燃。

说了劣质变压器的危险,再说说正规的变压器吧。 正规的变压器通常不会发生危险,否则它就不能通过检验,也就和正规无缘了。 但是电压上还是要注意,否则可以人为引起事故。比如说有一些变压器可以调节电压,通常范围是3V到24V。 而且它们还很可能支持USB接口。 如果你不小心把电压调到5V以上,甚至在用24V给手机冲电, 轻则损坏手机,重则电池爆炸。当然也有些手机的保护电路可以对付这种情况。 不管是不是正规的变压器,不通过保护电路直接对电池充电都是有危险的。

所以最保险的方法是用原装充电器。

那充电线也有危险吗?太危言耸听了吧? 的确, 充电线并没有那么危险。 劣质的冲电线可能发热过大引起自燃,但这样的事极少发生。

电池呢?电池的质量就很重要了,劣质的电池可能在没充电的情况也自燃,爆炸,完全无法把握。电池一定要用正规的产品。 劣质品就是个定时炸弹。连三星这样的大厂检测过的电池都可能在NOTE7里面爆炸。 那些小作坊生产的,几乎没有什么检测的电池你敢用吗?


说完那些粗心太意的人, 再谈谈那些过份小心的人。

过份小心的人通常只敢用原装的,这样做当然安全,但是有时候就会失去一些便利。如果你有一个IPHONE和一个IPAD, 你敢不敢用IPAD的变压器来冲IPHONE呢? 你不敢? 这就是太过小心了。 其实大多数变压器都是通用的, 你只要注意一个参数,电压, 就可以保证安全。大多数的变压器都是5V左右,有的会标5.25, 5.5, 5.75这样的参数,基本上是通用的。但是超过6V的变压器就最好不要用来给手机充电了。IPHONE和IPAD的变压器都是5V, 所以它们是可以替换使用的。 但是并不是说它们的充电效果是一样的。 IPAD的变压器的输出最大电流是2.1A, 而IPHONE的是1A。 所以用IPAD的变压器给IPHONE充电效果是一样的。 但如果用IPHONE的变压器给IPAD充电,就会慢得多。 因为IPAD是个大胃王,1A的电流对它来说太小了。 IPHONE只能吃进1A的电流,用IPAD的变压器虽然可以提供2.1A的电流,但IPHONE吃不了那么多,实际充电的时候只会提供1A电流。有些手机是可以支持快充的,但原装的变压器却不支持快充, 所以尽可以买一个支持快充的充电器来提高充电速度,没什么好怕的,只要买对了就可以。


所以大电流的变压器是可以给小电流的手机充电的, 但是大电压的变压器则不可以给小电压的手机冲电。


那说说线材吧, 一定要原装的线才敢充电?不必那么小心,只要是正规的线都可以互换使用。有一点还是要注意一下, 有些快充的手机最好用快充手机配的线,因为快充的电流比较大,如果用普通的线可能会引起安全问题,虽然几率很小。一般便宜的线也不是不能用, 但是往往因为电阻大, 会大大的降低充电效率,比如本来可以2A电流充电的手机,用便宜的线,充电电流可能就只能达到0.4A, 要用5倍的时间才能充满。 所以,线材也是一分钱一分货,不是随便淘宝可以乱买的。中看的不一定中用。


那电池呢?其实正规产商生厂的非原厂电池也是可以用的,比如飞毛腿等就在手机维修店里被用来替换原厂电池。也并不是非原厂不可,只要够安全就可以。


最后说说用电脑USB口充电吧。 USB2.0 的最大电流是0.5A, USB3.0 则是0.9A, 所以并不是很好的选择。实际上USB充电口也并不是只能提供这样的电流。 苹果的电脑USB口基本都可以提供额外的电流,用mac os 给IPAD充电的话,充电电流可以达到2.1A. 当然,苹果的这个功能只能在连接苹果设备的时候生效。 但是有些充电辅助设备可以骗到额外电流。 比如我就用YZX STUDIO的充电检测器从MAC OS骗到1.5 A的电流给我的三星 S6 Edge 充电。 同样可以从DELL的设备骗到1.5A的电流。 所以说USB最大0.9A 并不是绝对的。




总结就是买对东西,建议就是都用好的,如果手机支持12V的快充,就搞个支持12V快充的变压器,加上支持快充的线,加上一个靠谱的电池。不要把时间浪费在充电上,人生只有两三万天可活。





--
Feng

星期一, 十月 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

其它博客地址

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