Friday, May 4, 2012
Wednesday, May 2, 2012
Use TOP and DISTINCT together in t-sql
Surprisingly it is difficult to use TOP and DISTINCT together in SQL.
This will not work:
select top 2 distinct t.ID as tID, t.Name as tName from Table1 order by tID
It can be replaced by something like this to work:
select top 2 * from
(select distinct t.ID as tID, t.Name as tName from Table1 t) y
order by tID
Also see some other web links, such as Here
Friday, April 27, 2012
Friday, April 20, 2012
ACM classic - Reflections on Trusting Trust
Reflections on Trusting Trust, by Ken Thompson.
See how Ken Thompson implanted a back door into unix by hacking the compiler.
See how Ken Thompson implanted a back door into unix by hacking the compiler.
Wednesday, April 18, 2012
Debugging experience
Debugging is a hard thing. Here records some of my experiences.
- A same program instance is running on many machines for years without problem. But today one single machine reports an error. A stored procedure that takes multiple parameters, is now getting those parameters in reverse order.
Reason: A query that returns the list of parameters is now returning the entries in reverse. MSSQL returns data set in undeterministic order if "order by" is not used. It has worked consistently for years on all the machines, now for unknown reason is functioning differently on one single machine.
Solution: Add "order by" clause to the query.
- The Database server in production was accidentally uninstalled ... This happened because the admin logged into the wrong server. As the solution, the desktop background is changed to reflect the server name.
- A same program instance is running on many machines for years without problem. But today one single machine reports an error. A stored procedure that takes multiple parameters, is now getting those parameters in reverse order.
Reason: A query that returns the list of parameters is now returning the entries in reverse. MSSQL returns data set in undeterministic order if "order by" is not used. It has worked consistently for years on all the machines, now for unknown reason is functioning differently on one single machine.
Solution: Add "order by" clause to the query.
- The Database server in production was accidentally uninstalled ... This happened because the admin logged into the wrong server. As the solution, the desktop background is changed to reflect the server name.
"Same Domain Policy" limitation of jQuery
The same domain policy prevents javascripts hosted on one domain from accessing data from a remote domain. This is for security purpose. So when use jQuery, you can not directly access a web service from a remote server.
The solution is to create a serverside script (for example, in php, as shown below) on your domain, which will serve as a proxy, get the data from the remote domain, and then output it. For example:
<?php
readfile('http://remote_server.com/service?param=' . urlencode($_GET['param']);
?>
[1] Getting data from remote URL using jquery
[2] Cross-domain requests with jQuery
The solution is to create a serverside script (for example, in php, as shown below) on your domain, which will serve as a proxy, get the data from the remote domain, and then output it. For example:
<?php
readfile('http://remote_server.com/service?param=' . urlencode($_GET['param']);
?>
[1] Getting data from remote URL using jquery
[2] Cross-domain requests with jQuery
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2026
(36)
-
▼
June
(19)
- C10K to C10M: from thread-per-connection model to ...
- Benchmark server performance
- Application server for php, python, java, node.js,...
- Application server for C++, Go and Rust
- Nginx as reverse proxy and load balancer
- Infrastructure running: nginx, apache, php, python...
- Flow chart of nginx+apache+uvcorn infrastructure
- Flow chart of apache+uvcorn infrastructure
- Uvicorn and Gunicorn
- What's deadsnakes PPA
- What's the optional lsb-core package
- Codex known logging bug
- Daemonsize a service
- Train text to image model, to generate images of c...
- Train a model based on OpenAI API
- Open port 8080 for WebSocket
- Add websocket support on Bluehost Ubuntu VPS for D...
- Install Claude Code on ubuntu VPS of Bluehost
- Install PostgreSQL on Mac
-
▼
June
(19)