Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

filename

export data fro grid view to excel in asp.net
Saturday, 28 January 2012 01:44
// export data fro grid view to excel in asp.net


Private Sub ExportDataToExcel(ByVal myDataTable As DataTable)
Dim fileName As String = ""
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
fileName = "MyFile"
Response.AddHeader("Content-Disposition", "filename=" & fileName & DateTime.Now.Ticks & ".xls")
Response.Charset = ""
Dim sw As New StringWriter
Dim htw As New HtmlTextWriter(sw)
Dim myGrid As New GridView
myGrid.AllowPaging = False
myGrid.DataSource = myDataTable
myGrid.DataBind()
myGrid.RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
myGrid.Dispose()
End Sub

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/gwnHQ5Yr_a8/14503

 
Conditional and Null-Coalescing Operators (?: and ??)
Wednesday, 14 December 2011 01:03
In code you want to assign one variable to another, but only if the variable is not null. If it is null, you want to populate the target variable with another value. The code normally may look like this using the C# Conditional Operator:

string fileName = tempFileName != null ? tempFileName : "Untitled";


If tempFileName is not null, fileName = tempFileName, else fileName = “Untitled“.
This can now be abbreviated as follows using the Null-Coalescing Operator:

string fileName = tempFileName ?? "Untitled";


The logic is the same. If tempFileName is not null, fileName = tempFileName, else fileName = “Untitled“.
The Null-Coalescing Operator comes up a lot with nullable types, particular when converting from a nullable type to its value type:

int? count = null;
int amount = count ?? default(int);


Since count is null, amount will now be the default value of an integer type ( zero ).

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/GH4PJob4sNg/14169

 
Logging class( Using singleton )
Wednesday, 16 November 2011 19:17
// A logging class, using a singleton.
// Will create a backup file
// Coded in C++
// Doesn't use a pointer for the singleton
// Coded by Ian T. Jacobsen 2011

// Header

#ifndef LOGGING_H
#define LOGGING_H

#include
#include

#define LOG CLogging::Inst("log.log").Log

class CLogging
{
public:
static CLogging& Inst(char* filename);
void Log(std::string message);
~CLogging();
protected:
CLogging(char* filename);
private:
char* m_filename;
std::fstream m_fOut;
};

#endif // LOGGING_H


// Source file

#include "include/logging.h"
#include

CLogging& CLogging::Inst(char* filename)
{
static CLogging m_pInstance(filename);
return m_pInstance;
}

CLogging::CLogging(char* filename)
: m_filename(filename)
{
std::fstream temp(filename, std::ios_base::in);

std::fstream backup(std::string(std::string(m_filename).append(".backup")).c_str(), std::ios_base::out | std::ios_base::trunc);

temp.seekg(0,std::ios::end);
int length = temp.tellg();
temp.seekg(0,std::ios::beg);

char* buffer = new char[length];

temp.read(buffer,length);

backup.write(buffer, length-4);

delete[] buffer;
temp.close();
backup.close();

m_fOut.open(filename, std::ios_base::out | std::ios_base::trunc);

char date[9];
_strdate(date);

m_fOut<< "Log file started on (mm/dd/year) " << date << "\n\n";
}

CLogging::~CLogging() {
m_fOut<< "\nLogging ended.";

m_fOut.close();
}

void CLogging::Log(std::string message)
{
m_fOut<< message << "\n";
}

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/WIn3M36BAd4/13883

 
HTML entities - decoding - Perl one-liner
Tuesday, 15 March 2011 05:39
// Perl one-liner to expand HTML entities like &


perl -i.bak -pe "BEGIN { use HTML::Entities;} HTML::Entities::decode($_); " filename

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/wnYvn4jkqIs/13027

 
Tail Log Output with Node.js
Sunday, 15 August 2010 17:42
// http://nodejs.org/api.html#_child_processes
var sys = require('sys')
var spawn = require('child_process').spawn;
var filename = process.ARGV[2];

if (!filename)
return sys.puts("Usage: node ");

var tail = spawn("tail", ["-f", filename]);
sys.puts("start tailing");

tail.stdout.on("data", function (data) {
sys.puts(data);
});

// node tail.js development.log

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/IwfrycFqnBY/12067

 


Taxonomy by Zaragoza Online