Monday, 7 February 2011

How to Hide/Show rows dynamically in Excel

hide-show-excel-1

hide-show-excel-2

Friday, 4 February 2011

Simple Java HttpServer / HttpHandler

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
public class TestServer {
    private static final int PORT = 8000;
    private static final String HOST = "127.0.0.1";
    public static void main(String[] args){
        System.out.println("Starting HttpServer on port "+PORT);
        try{
            InetSocketAddress address = new InetSocketAddress(HOST, 8000);
            HttpServer httpServer = HttpServer.create(address, 0);
            System.out.println("Running..");
            HttpHandler handler = new HttpHandler() {
                public void handle(HttpExchange exchange) throws IOException {
                    String response = "Hello World!";
                    byte[] bytes = response.getBytes();
                    exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK,bytes.length);
                    exchange.getResponseBody().write(bytes);
                    exchange.close();
                }
            };
            httpServer.createContext("/", handler);
            httpServer.start();
            System.out.println("Press any key to stop.");
            System.in.read();
            httpServer.stop(0);
        }catch (Exception ex){
            System.out.println("Error: "+ ex.getMessage());
        }
        System.out.println("Stopped.");
    }
}

Tuesday, 1 February 2011

SQL Server How to find if any stored procedure is referencing database object

select StoredProcedureName = p.name
from sys.sql_modules sm
inner join
sys.procedures p
on sm.[object_id] = p.[object_id]
where [definition] like '%Database_Object_Name%'