Pages

Monday 21 May 2012

get proper ms-dos timestamp


set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
set myFilesuffix=%date:~-4,4%%date:~-7,2%%date:~-10,2%_%hr%%time:~3,2%%time:~6,2%
echo %myFilesuffix%
pause
 

Tuesday 20 March 2012

Writing Pure UTF-8 file in vba using ADODB.Stream

for appending to an existing file just send in myappend true...
Call WriteUTF8WithBOM(sometext, afile, true)
Public Function WriteUTF8WithBOM(mytext As Variant, myfullfilename As String, myappend As Boolean)
    Dim fsT As Object
    Set fsT = CreateObject("ADODB.Stream")
    fsT.Type = 2 'Specify stream type - we want To save text/string data.
    fsT.Charset = "utf-8" 'Specify charset For the source text data.
    fsT.Open 'Open the stream And write binary data To the object
        
        If myappend Then
            myx = ""
            fsT.LoadFromFile (myfullfilename)
            myx = fsT.ReadText(-1)
            'mytext = myx & mytext
        End If
    
    fsT.WriteText mytext
    
    fsT.SaveToFile myfullfilename, adSaveCreateOverWrite
    'fsT.SaveToFile sFileName, 2 'Save binary data To disk
End Function

Don't forget to add ActiveX Data Objects

Monday 28 November 2011

setTimeOut() javascript function

function timer()
 {   
  // Calculate new YValue for the DataPoint
  var newYValue = Math.abs(Math.random() * 100 - 10 * dataPointIndex);

  // Update a YValue property of a DataPoint
  updateYValue(newYValue, dataPointIndex);

  // Update dataPointIndex
  dataPointIndex = (dataPointIndex > 4) ? 0 : dataPointIndex + 1;

  // Set timeout for timer() function
  setTimeout(timer, 5000);
 }

jquery ui changing themes

Some undocumented Google CDN Feature

link to stylesheet in the head section:
<link href="./jquery/css/start/jquery-ui.css" type="text/css" rel="stylesheet" />

javascript function to change theme:
function ThemeChange(mytheme){
  $("link[rel=stylesheet]").attr({href : "./jquery/css/" + mytheme + "/jquery-ui-1.7.2.custom.css"});
  $("#mytab").tabs('select', 0);
}

html code that is calling the javascript function:
<div id="divloadfiles" style="display: block; font-size: 10px; text-align: left;">
<select id="mytheme" onchange="javascript:ThemeChange(this.value);">
  <option value="redmond">redmond</option>
  <option value="sunny">sunny</option>
  <option value="smoothness">smoothness</option>
  <option value="vader">vader</option>
  <option value="blitzer">blitzer</option>
  <option value="le-frog">le-frog</option>
  <option value="overcast" selected="selected">overcast</option> 
  <option value="pepper-grinder">pepper-grinder</option>
  <option value="start">start</option>
</select>
</div>