Labels

_fuxi (75) _IV (146) _misc (5) {610610 (30) algo (1) automatedTrading (8) banking/economy (3) book (14) c++misc (125) c++real (15) c++STL/java_container (7) cppTemplate (1) db (13) DB_tuning (4) deepUnder (1) dotnet (69) eTip (17) excelVBA (12) finance+sys (34) financeMisc (24) financeRisk (2) financeTechMisc (4) financeVol (21) finmath (17) fixedIncome (25) forex (16) IDE (24) invest (1) java (43) latency (4) LinearAlgebra (3) math (30) matlab (24) memoryMgmt (11) metaPrograming (2) MOM (15) msfm (1) murex (4) nofx (11) nosql (3) OO_Design (1) original_content (4) scriptUnixAutosys (19) SOA (7) socket/stream (15) sticky (1) subquery+join (2) swing (32) sybase (6) tech_orphan (12) tech+fin_career (30) telco (11) thread (21) timeSaver (13) tune (10) US_imm (2) US_misc (2) windoz (20) z_algo+dataStructure (4) z_arch (2) z_c#GUI (30) z_career (10) z_career]US^Asia (2) z_careerBig20 (1) z_careerFinanceTech (11) z_FIX (6) z_forex (31) z_hib (2) z_ikm (7) z_inMemDB (3) z_j2ee (10) z_oq (14) z_php (1) z_py (26) z_quant (4) z_skillist (3) z_spr (5)
Showing posts with label timeSaver. Show all posts
Showing posts with label timeSaver. Show all posts

Sunday, June 14, 2015

disable python stdout buffering

http://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print

python -u # didn't work for me...

sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) # worked

Sunday, April 13, 2014

DOS | Temporarily change working directory for a single command

pushd myjava & java -Djava.rmi.server.codebase=http://10.203.111.166:20380/murex.download.guiclient.download -classpath %CP% com.ocbc.quest.murexgateway.MurexServer 19673  & popd

 

This DOS command line does 3 things

1)      temporarily chdir into “myjava” folder and

2)      run a (long) java command line, and then

3)      restore the previous directory.

 

Actually, the java process blocks the script forever. If you use ctrl-C to terminate the blocking java process, you still get back into the previous directory J

 

See

https://www.google.com/url?q=http://superuser.com/questions/316431/temporarily-change-directory-for-single-batch-file-command&sa=U&ei=QE9GU6a0AYaErAev64CoBQ&ved=0CB4QFjAA&sig2=rynk5GiLWNBUreRFdwTTLw&usg=AFQjCNGuhZaXsvB2BIxXBvylAo79NcFRTA

 

Friday, December 14, 2012

cygwin to access a remote shared folder

http://superuser.com/questions/102233/how-to-go-to-remote-directory-in-cygwin explains

Windows' builtin pushd will auto-mount the share to a temporary drive, which is accessible from Cygwin.

C:> pushd \\myserver\photos\original

Z:\original>

c# log each msg with line number + thread id

This method conveniently logs to console, IDE output window and log4net

It also logs the file name, method name and line number of top 2 levels on the call stack

        public static void Info(Object o, bool isStackTraceNeeded = false)
        {
            /*According to MSDN:
             * An operating-system ThreadId has no fixed relationship to a managed thread, because an unmanaged host
             * can control the relationship between managed and unmanaged threads. Specifically, a sophisticated host
             * can use the CLR Hosting API to schedule many managed threads against the same operating system thread,
             * or to move a managed thread between different operating system threads.
             */
            var winThrId = AppDomain.GetCurrentThreadId();
            var thId = "/T" + Thread.CurrentThread.ManagedThreadId + "/" + winThrId + "/ ";

            #region locator
            StackTrace stackTrace = new StackTrace(fNeedFileInfo:true);
            var frames = stackTrace.GetFrames();

            StringBuilder locator = new StringBuilder(StackFrameToStr(frames[1]));
            if (frames.Length > 2)
                locator.Append(StackFrameToStr(frames[2]));
         
            var locator2 = "{" + locator.ToString().Trim() + "}";
            var msg = thId + locator2 + (o ?? "_nul_");
            #endregion

            if (isStackTraceNeeded) msg += "\n" + stackTrace;

            log4n.Debug(msg);
            //System.Diagnostics.Trace.Write("Trace is possible as well.");
            System.Diagnostics.Debug.WriteLine(msg);
            Console.WriteLine(msg);
            return;
        }

        public static string StackFrameToStr(StackFrame f)
        {
            return Path.GetFileNameWithoutExtension(f.GetFileName()) + "." + f.GetMethod().Name + "." +f.GetFileLineNumber() + " ";
        }
    }

c# get base name from a full path


Path.GetFileNameWithoutExtension(string)

Usage example:
       public static string StackFrameToStr(StackFrame f)      {
            return Path.GetFileNameWithoutExtension(f.GetFileName()) + "."
+f.GetMethod().Name + "."
+f.GetFileLineNumber() + " ";
        }

Tuesday, November 27, 2012

dump a hashset C#

string.Join(" ",theSet)

Monday, August 22, 2011

simple snoop table to monitor DB access

CREATE TABLE snoop( 
 charp1 VARCHAR(16384) DEFAULT  ''  NULL,
 charv1 VARCHAR(16384) DEFAULT  ''  NULL,
 charp2 VARCHAR(16384) DEFAULT  ''  NULL,
 charv2 VARCHAR(16384) DEFAULT  ''  NULL,
 nump1 VARCHAR(99)     DEFAULT  ''  NULL,
 numv1 FLOAT           DEFAULT  0   NULL,
 datep1 VARCHAR(99)    DEFAULT  ''  NULL,
 datev1 DATETIME NULL,
 ts DATETIME DEFAULT  getDate()  NOT NULL,

/* one way to use this table is to save multiple params when calling a proc
insert snoop(charp1,charv1,nump1,numv1,datep1,datev1,sproc)
      values('param1',?, 'param2',?,  'param3',?, 'myProc')
*/
 sproc VARCHAR(99) DEFAULT  ''  NULL,
 ident INT IDENTITY NOT NULL,
 remark VARCHAR(99) DEFAULT  ''  NULL
)

Friday, April 29, 2011

easiest mswe-style ftp interface

ftp://btan@mts-as1-u.apps.ml.com

svn folder comparison

Tortisesvn has s nice recursive check-for-modifications. It shows my
local changes, in an offline fashion.

No such feature in subclipse.

exceed copy-paste between win32 and X-windows

Using exceed, it can be a challenge to set up copy-paste between win32
and X windows. I know 2 options.

Note I always enable auto-copy-x-selection and
auto-paste-to-x-selection.

-- option: X-selection-page -> X Selection Associated With Edit
Operations set to Primary --
Lesson? "Primary" is the default. In this mode, don't use the xwin
context-menu.

* Simple-Select (without middle-button or context menu) to copy from
unix, paste to win32? Yes
* Simple-Select (without middle-button or context menu) to copy from
unix, middle-button to paste to unix? yes
* Select from win32, middle-button to paste in unix? Yes
* Select from win32, context-menu->edit->paste in unix? no

-- option: X-selection-page -> X Selection Associated With Edit
Operations set to Clipboard --
This is suggested on some webpage. It also enables copy-paste between
unix and windows.

Saturday, May 29, 2010

capture text selection in a JTextComponent

@Override
public void caretUpdate(CaretEvent e) {
int dot = e.getDot();
int mark = e.getMark();
if (dot == mark) return; // no text selection

if (!(e.getSource() instanceof JTextComponent)) return;
String selection = ((JTextComponent) e.getSource()).getSelectedText();

Sunday, March 9, 2008

Thursday, July 12, 2007

for loop dos^shell

--dos: FOR %A IN (1 2 3 4 5 6 7 8 9 10) DO echo ...

--shell:
i=4; while [ $i != 0 ]; do
i=`expr $i - 1`
done

The let command is a replacement for the old method of performing shell arithmetic using the expr command.

# Note: != syntax is easier to remember and less error-prone than -le. Now, If you must count from 1 upward,

i=1; while [ $i -le 4 ]; do
i=`expr $i + 1`
done