2016年2月21日星期日

Fwd: Caller Info

经常在打log的时候要把上下文带上,很麻烦,好在C#提供了一个功能,可以在编译时获得调用者的方法名、文件名和行号,十分方便。
如果你以前用C++写Logger,一定对这些宏不陌生:
二者功能类似。

常言道:If it can be done in authoring time, don't do it in compile time. If it can be done in compile time, don't do it in run-time.

是为一点小小的心得。

2016年2月14日星期日

ssh tunnel from the phone

sometimes I want to share a photo from my phone via facebook, then I need ssh tunnel on phone.
As I used Android, I get VX connectbot from my local app store. It has port forward functionality build-in.
As I cannot always open putty on my laptop, I put the proxy into background
cat start_proxy.sh
{{{
nohup python proxy.py --port 8080 --hostname '' > proxy.log 2>&1 &
}}}


On my phone, the proxy setting is not at browser level, but at WALN setting, which means the network traffic of any app will go to the proxy, but interesting, the ssh tunnel itself didn't go to the proxy.

Don't forget to stop the proxy when you want to save money.

{{{
pkill -f proxy.py
}}}


2016年2月12日星期五

Fwd: Proxy.py + SSH Tunnel

I have a Linux server S in JP WEST, which can connect to Google.
Then I setup a proxy.py, a single file web proxy which support HTTPS, at S:8080.
Then I use SwitchySharp locally and set S:8080 as proxy server.
However, when I open Google in browser and search something, the connection is closed.
Checked proxy.py log, it should be because the communication between local machine and S was detected contains Google in plain text. Then I understand what happened on the wire.

Then I use Putty to setup SSH Tunnel, map local:1234 to S:8080, and set localhost:1234 as proxy in SwitchSharp.

Finally the information goes like this: my browser -- local proxy at localhost:1234 -- remote proxy at S:8080 -- internet





 


2015年12月31日星期四

A command line tool to sync your AdWords account to your BingAds


In my dream, it will be a cloud based application. You can use your phone to manage the update: control how to sync your campaigns from AdWords to BingAds. Workflows:

config: grant access to 2 networks. trigger full sync and rebuild id map (required before the first sync). how to automatically resolve conflict by entity type by attribute. skip and ignore, skip and notify, take suggestion

recent conflict report: (duplicate conflict should be detected and removed): ignore once (resolve manually by yourself later), take suggestion...checkbox: remember option

historical sync report. what has been updated on g, what has been synced/skipped to bingads, over the time, statistics

Just a dream of adops.

2013年12月29日星期日

Fwd: An interesting property of AUC

Get definition of AUC here


Property: if you flip ground truth only, or flip prediction only, you will get 1-original AUC as new AUC.

Proof:
Take original ROC curve as function of moving score threshold (x(s),y(s))=(fp(s)/N, tp(s)/P)
Where fp(s) is false positive=number of cases predicted as positive under score threshold s but actually negative.
tp(s) is true postive=number of cases predicted as positive and actually also positive.
N is number of negative cases and P is number of positive cases.

1. Flip ground truth only
You will get P'=N and N'=P. Note that prediction is kept unchanged, so fp'(s)=tp(s), tp'(s)=fp(s).
As a result, (x'(s),y'(s))=(y(s),x(s)), which means the two curves are symmetric to line y=x.
So, the area a is the same as area c.
Note that a+b+c=1, so a+(a+b)=1 where a and a+b are AUC before and after ground truth flip.

2. Flip prediction only
You will get N'=N, P'=P, fp'(s)=N-fp(s) and tp'(s)=P-tp(s). 
As a result, (x'(s),y'(s))=(1-x(s), 1-y(s)), which means the cuve flip according to line x=1/2 and then flip according to line y=1/2.
Note that the flip horizontal never change the area under the curve.
while flip vertical make the curve top down, that is to say, the area under the new curve is the area above the original curve.
So AUC+AUC'=1.
#



    

2013年12月2日星期一

Fwd: Copy path in context menu



Copy, save and click to add into regedit.

 

 

Add Copy as Path Option.reg

-----------

 

 

Windows Registry Editor Version 5.00

 

;Created by Vishal Gupta for AskVG.com

 

[HKEY_CLASSES_ROOT\*\shell\Copy Full Path]

 

[HKEY_CLASSES_ROOT\*\shell\Copy Full Path\command]

@="cmd.exe /c echo %1|clip"

 

 

[HKEY_CLASSES_ROOT\*\shell\Copy Filename]

 

[HKEY_CLASSES_ROOT\*\shell\Copy Filename\command]

@="cmd /c for %%i in (\"%1\") do @echo %%~nxi | clip"

 

 

[HKEY_CLASSES_ROOT\*\shell\Copy Dir Path]

 

[HKEY_CLASSES_ROOT\*\shell\Copy Dir Path\command]

@="cmd /c for %%i in (\"%1\") do @echo %%~dpi | clip"

 

 

[HKEY_CLASSES_ROOT\Directory\shell\Copy Dir Path]

 

[HKEY_CLASSES_ROOT\Directory\shell\Copy Dir Path\command]

@="cmd.exe /c echo %1|clip"

 

=======

 

Remove Copy as Path Option.reg

----------

 

Windows Registry Editor Version 5.00

 

;Created by Vishal Gupta for AskVG.com

 

[-HKEY_CLASSES_ROOT\*\shell\Copy Full Path]

 

[-HKEY_CLASSES_ROOT\*\shell\Copy Filename]

 

[-HKEY_CLASSES_ROOT\*\shell\Copy Dir Path]

 

[-HKEY_CLASSES_ROOT\Directory\shell\Copy Dir Path]

 

 

 

 

 

=======

 

 

Enjoy~