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

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

其它博客地址

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