Here is the breakdown of Operating Systems for visitors in the past 30 days:
{'a': 2,
'b': 4,
'c': 3,
'd': 1}
.. and you want to convert it into a list, sorted by value (not key), like this:
[('d', 1),
('a', 2),
('c', 3),
('b', 4)]
There is a Python Recipe for it with various implementations discussed in the comments.sorted(foo.items(), key=lambda(k,v):(v,k))
SELECT count(*) FROM :: fn_trace_getinfo(default) WHERE property = 5 and value = 1Here is how you can find more detail about the running traces:
SELECT * FROM :: fn_trace_getinfo(default)You can terminate a trace with the 'sp_trace_setstatus' stored procedure using the traceid:
EXEC sp_trace_setstatus 1, @status = 0 EXEC sp_trace_setstatus 1, @status = 2setting the status to 0 stops the trace setting the status to 2 closes the trace and deletes its definition from the server
"Pylot is an open-source performance and scalability testing tool. It uses HTTP load tests so that you can plan, benchmark, analyze and tweak performance. Pylot requires that you have Python installed on the server - but you don’t need to know the language, you use XML to create your testing scenarios."

import ystockquote
ticker = 'GOOG'
start = '20080101'
end = '20080523'
data = ystockquote.get_historical_prices(ticker, start, end)
closing_prices = [x[4] for x in data][1:]
closing_prices.reverse()
fh = open('data.txt', 'w')
for closing_price in closing_prices:
fh.write(closing_price + '\n')
fh.close()
Now that you have the data.txt file setup, you can call the Sparkplot script via the command line to generate the sparkline image:
python sparkplot.py --label_first --label_last*Note: The Sparkplot module needs Matplotlib installed. The sparkline output is an image (png) like this:
import java.io.*;
public static String cmdExec(String cmdLine) {
String line;
String output = "";
try {
Process p = Runtime.getRuntime().exec(cmdLine);
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output += (line + '\n');
}
input.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
return output;
}
Sample Usage:
public static void main(String[] args) {
CmdExec cmd = new CmdExec();
System.out.println(cmd.run("ls -a"));
}