Skip to main content

Posts

Showing posts from May, 2009

Compute Running (Execution) Time or Time Difference in C#

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalculateTimeDifference { class Program { static void Main( string [] args) { string result; // start time of this program DateTime dStart = DateTime.Now; result = string .Format(" Start: Year:{0}, Month:{1}, Day:{2}, Hour:{3}, Minute:{4}, Second:{5}, Millisecond:{6}, In Ticks:{7} ", dStart.Year, dStart.Month, dStart.Day, dStart.Hour, dStart.Minute, dStart.Second,dStart.Millisecond, dStart.Ticks); Console.WriteLine(result); Console.ReadLine(); // wait until you press enter // end time of this program DateTime dEnd = DateTime.Now; result = string .Format(" End : Year:{0}, Month:{1}, Day:{2}, Hour:{3}, Minute:{4}, Second:{5}, Millisecond:{6}, In Ticks:{7} ", dStart.Year, dStart.Month, dEnd.Day, dEnd.Hour, dEnd.Minute, dEnd.Second, dEn

Avoid timeout limit of execution time in php

When uploading data into MySQL through phpmyadmin exceed the timeout limit, you can edit the setting to avoid it. In .\phpmyadminXXX\libraries\config.default.php /** * maximum execution time in seconds (0 for no limit) * * @global integer $cfg['ExecTimeLimit'] */ //$cfg['ExecTimeLimit'] = 300; $cfg['ExecTimeLimit'] = 0; Setting $cfg['ExecTimeLimit'] equal to zero means no limit of execution time.

Read text file using C#’s StreamReader

1: using System; 2: using System.Collections.Generic; 3: using System.Linq; 4: using System.Text; 5: using System.IO; 6: 7: namespace ConsoleApplication1 8: { 9: class Program 10: { 11: static void Main( string [] args) 12: { 13: // text file to read 14: string fileName = " YourFileName.extension "; 15: StreamReader sr = new StreamReader(fileName, Encoding.Default); 16: string tempS = " "; 17: while (sr.EndOfStream != true ) 18: { 19: // read a line a time 20: tempS = sr.ReadLine(); 21: // print each line on console 22: Console.Out.WriteLine(tempS); 23: } 24: } 25: } 26: }

Using global variable in Python

1: # two global variable 2: myMin = 360.0 3: myMax = 0.0 4: 5: def MyStatistics( fileName ) : 6: myFile = open (fileName) 7: strList = myFile.readlines() 8: 9: # Specify that these two are global variable 10: global myMin 11: global myMax 12: 13: for str in strList : 14: myFloat = float(str) 15: if ( myFloat > myMax ): 16: myMax = myFloat 17: 18: if ( myFloat < myMin ): 19: myMin = myFloat 20: 21: # a file with number seperate '\n' 22: MyStatistics(FileWithFloat) 23: 24: print 'myMin = %s' % (myMin) 25: print 'myMax = %s' % (myMax)

Google Docs: Download GM Script (Google Docs Backup Tool) by Peter Shafer

Tools to backup all your documents on Google Docs, including doc, ppt, xls, and pdf,  to your hard drive in an easy way. Install DownThemAll , a firefox add-on. Install Greasemonkey , a firefox add-on. Install Goole Docs: Download (Greasemonkey Script) , a greasemonkey script run on firefox. Login to your Googld Docs page. Select all the documents you want to backup. There will be a new item on the right side of the toolbar of Google Docs. (See picture) Choose the option and back up all your documents.You will be redirect to a page that list all the files. (See picture) Start “DownloadAll” to download the files. (See picture) Choose the output folder on local hard drive and set your filter (ex. All files), then press “Start” to backup all your files. (See picture)   Original Project and Tutorials : Google Docs: Download GM Script by Peter Shafer