Just curious,
Is there any difference between calling len([1,2,3]) or [1,2,3].__len__() ? If there is no apparent difference, what is done differently behind the scenes?
Thanks
If I have a table like this:
pkey age
---- ---
1 8
2 5
3 12
4 12
5 22
I can "group by" to get a count of each age.
select age,count(*) n from tbl group by age;
age n
--- -
5 1
8 1
12 2
22 1
What query can I use to group by age ranges?
age n
----- -
1-10 2
11-20 2
20+ 1
I have a grid view column in which I give the datefomat as dd MMM yyyy HH:mm and in code behind databound I change the time, the same time in database is not shown in the gridview, because of that the date is not displayed in 16 Nov 2011 15:12 format, it is displayed in 16/11/2011 15:12 format, how can i display it in 16 Nov 2011 15:12 format
asp…
I'm trying to write a "staff only" decorator for Django, but I can't seem to get it to work:
def staff_only(error='Only staff may view this page.'):
def _dec(view_func):
def _view(request, *args, **kwargs):
u = request.user
if u.is_authenticated() and u.is_staff:
return view_func(request, *args,…
So our web server apps need to connect to the database, and some other apps have startup scripts that execute at boot time.
What's the best way to store the name/password for these applications, in terms of
security, e.g. perhaps we don't want sysadmins to know the database password
maintainability, e.g. making the configuration easy to change…
I just installed trac for this project I'm working on, since it's turned out to be a bit bigger than I anticipated. I've added a bunch of tickets with my clients requests which come in the form of emails, phone calls, and meetings. I've also added some stuff I know needs to be done/fixed but they haven't specifically requested. Should I grant…
Dear ladies and sirs.
I am wondering if it is possible to control the Visual Studio exception handling options from the code itself. For instance, I would like to turn off stopping on FCE for a certain piece of code, that generates many FCE, however, I would like it to be active for all the other code.
Is it possible to do it from code?…
I'm taking my first crack at AJAX with jQuery. I'm getting my data onto my page, but I'm having some trouble with the JSON that is returned for Date data types. Basically, I'm getting a string back that looks like this:
/Date(1224043200000)/
From a total newbie at JSON - How do I format this to a short date format? Should this be…
I am working on the design and implementation of an iPhone application ( a newbie, but I am getting the hang of it) where a person can download specific contact information about teachers based on their majors.
The information is currently on different edu websites. And I have exported the information into SQLite databases. Is it…
I have a contenteditable element that I want to focus, but only insofar as to place the cursor at the front of the element, rather selecting everything.
elem.trigger('focus'); with jquery selects the entire element in chrome. How can I get it to behave the way I want, or is focus perhaps not what I'm looking for.
Thanks
Given an SCN (system change number), and assuming an SCN for which the data is still in the undo logs, what information about the SCN can I derive?
of course, SCN_TO_TIMESTAMP() gives an approximate time the data was committed.
Is there any other information I can derive? What transaction, what tables, what data were affected?…
I am working on creating a custom form designer in the Delphi IDE. I'm trying to use the RegisterCustomModule, TBaseCustomModule, and ICustomModule functions, classes, and interfaces.
My first question on this pointed me to the Delphi Developer's Handbook and the idea that I could even create a custom form designer. However,…
I am writing an App Engine app that is supposed to receive emails in this form:
addcontact.someID@my-app.appspotmail.com (someID is an alphanumeric ID that I generate).
I have this in my web.xml thinking it would catch emails that start
with 'addcontact.':
<servlet>
…
This question is to help me (us) ask better questions of this community to encourage better working together.
What questions here bring out the best in you? I don't mean which are the best / most appropriate questions but which bring the best out of you? That is, it brings out…
I am working on program that calculate the GPAs for university students in C#.
I have made a gridview that contains columns for each subject. Its mark as letter and
number. After the user "student" insert his/her subject I want to let the user click a
button that will get…
I have an ActionResult returning from a strongly typed view where I manually validate some conditions, pass in an error message, but would like to preserve the users responses.
Since my View is strongly typed, I am calling it like this:
return…
What is the difference between a Class Abstraction and an Object Interfaces in PHP? I ask because, I don't really see the point to both of them, they both do the same thing! So, what are the advantages of disadvantages using both against one or…
I am quite new to TDD and am going with NUnit and Moq. I have got a method where I expect an exception, so I wanted to play a little with the frameworks features.
My test code looks as follows:
[Test]
…
I've set up my DataContext like this:
<Window.DataContext>
<c:DownloadManager />
</Window.DataContext>
Where DownloadManager is Enumerable<DownloadItem>. Then I set my DataGrid…
How do I sort a multi dimensional list like this based on a time string? The sublists can be of different sizes (i.e. 4 and 5, here)
I want to sort by comparing the first time string in each sublist…
I have a form that can be dynamically duplicated (with JS) so that the user can enter as much data as he wants. This works great for text inputs, because I just leave the name attribute the same…
How do I initialize a 2d array in perl?
I am trying the following code:
0 use strict;
10 my @frame_events = (((1) x 10), ((1) x 10));
20 print "$frame_events[1][1]\n";
but it gives the…
Background:
I'm trying to come up with a regex for a rewrite rule that will take anything that does not start with a particular prefix, and add that prefix to it. But urls that already…
Suppose you're building an HTML form and you want to have 2 or more drop-down menus, where after picking an option from the first, the 2nd menu is populated, and so forth. For example,…