In .NET there are 8 bytes of overheard for each object. 4 bytes are a pointer to the object's type. What are the other 4 bytes, known as the object header, used for?
I'm creating a list of my defined objects like so
List<clock> cclocks = new List<clocks>();
for each object in the list i'm calling a method moveTime, like so
foreach(clock c in cclocks)
{
c.moveTime();
}
is the a way i can write some cleaver thing so i can call
cclocks.moveTime();
it would then go though the list doing that method
I guess I want to create a collection method?
I'm guessing there must be some thing I can do I just don't know what.
thanks for your help
I'm using tablesorter in on a table I added to a view in django's admin (although I'm not sure this is relevant).
I'm extending the html's header:
{% block extrahead %}
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script type="text/javascript" src="http://mysite.com/media/tablesorter/jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function()
{ $("#myTable").tablesorter(); }
);
</script>
{% endblock %}
When I click on a column header, it sorts the table using this column in descending order - that's ok.
When I click the same column header a second time - it does not reorder to ascending order. What's wrong with it?
the table's html looks like:
<table id="myTable" border="1">
<thead>
<tr>
<th>column_name_1</th>
<th>column_name_2</th>
<th>column_name_3</th>
</tr>
</thead>
<tbody>
{% for item in extra.items %}
<tr>
<td>{{ item.0|safe }} </td>
<td>{{ item.1|safe }} </td>
<td>{{ item.2|safe }} </td>
</tr>
{% endfor %}
</tbody>
</table>
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
Url is an NSURL and it works fine. However I'd like to get the HTML (data) after I've logged in.
So the website has a standard way of logging in with 2 textboxes and a submit action on the form.
So how can I log in then get the HTMl source so I can parse it. Do i have to use something other than NSData?
I can't seem to figure out how to get Objective-c to auto box my primitives.
I assumed that i would be able to do the following
NSString* foo = @"12.5";
NSNumber* bar;
bar = [foo floatValue];
However i find that i have used to the more verbose method of
NSString* foo = @"12.5";
NSNumber* bar;
bar = [NSNumber numberWithFloat:[foo floatValue]];
Am i doing it wrong or is this as good as it gets?
I'm afraid this question is pretty basic, but I think it's relevant to a lot of Objective-C programmers who are getting into blocks.
What I've heard is that since blocks capture local variables referenced within them as const copies, using self within a block can result in a retain cycle, should that block be copied. So, we are supposed to use __block to force the block to deal directly with self instead of having it copied.
__block typeof(self) bself = self;
[someObject messageWithBlock:^{ [bself doSomething]; }];
instead of just
[someObject messageWithBlock:^{ [self doSomething]; }];
What I'd like to know is the following: if this is true, is there a way that I can avoid the ugliness (aside from using GC)?
What's the best way of writing robust code so that a variable can be checked for null and blank.
e.g.
string a;
if((a != null) && (a.Length() > 0))
{
//do some thing with a
}
I'm using Spring.NET to connect to ActiveMQ and do some fairly simple pub sub routing. Everything works fine when my selector is a simple expression like Car='Honda' but if I try a compound expression like Car='Honda' AND Make='Pilot' I never get any matches on my subscription.
Here's the code to generate the subscription, does anyone see where I might be doing something wrong?
public bool AddSubscription(string topicName, Dictionary<string,string> selectorList, GDException exp)
{
try
{
ActiveMQTopic topic = new ActiveMQTopic(topicName);
string selectorString = "";
if (selectorList.Keys.Count == 0)
{
// Select all items for this topic
selectorString = "2>1";
}
else
{
foreach (string key in selectorList.Keys)
{
selectorString += key + " = '" + selectorList[key] + "'" + " AND ";
}
selectorString = selectorString.Remove(selectorString.Length - 5, 5);
}
IMessageConsumer consumer = this._subSession.CreateConsumer(topic, selectorString, false);
if (consumer != null)
{
_consumers.Add(consumer);
consumer.Listener += new MessageListener(HandleRecieveMessage);
return true;
}
else
{
exp.SetValues("Error adding subscription, null consumer returned");
return false;
}
}
catch (Exception ex)
{
exp.SetValues(ex);
return false;
}
}
And then the code to send the message, which seems simple enough to me
public void SendMessage(GDPubSubMessage messageToSend)
{
if (!this.isDisposed)
{
if (_producers.ContainsKey(messageToSend.Topic))
{
IBytesMessage bytesMessage = this._pubSession.CreateBytesMessage(messageToSend.Payload);
foreach (string key in messageToSend.MessageProperties.Keys)
{
bytesMessage.Properties.SetString(key, messageToSend.MessageProperties[key]);
}
_producers[messageToSend.Topic].Send(bytesMessage, false, (byte)255, TimeSpan.FromSeconds(1));
}
else
{
ActiveMQTopic topic = new ActiveMQTopic(messageToSend.Topic);
_producers.Add(messageToSend.Topic, this._pubSession.CreateProducer(topic));
IBytesMessage bytesMessage = this._pubSession.CreateBytesMessage(messageToSend.Payload);
foreach (string key in messageToSend.MessageProperties.Keys)
{
bytesMessage.Properties.SetString(key, messageToSend.MessageProperties[key]);
}
_producers[messageToSend.Topic].Send(bytesMessage);
}
}
else
{
throw new ObjectDisposedException(this.GetType().FullName);
}
}
07/102009: Update
Ok, found the problem
bytesMessage.Properties.SetString(key, messageToSend.MessageProperties[key]);
This justs sets a single property, so my messages are only being tagged with a single property, hence the combo subscription never gets hit. Anyone know how to add more properties? You'd think bytesMessage.Properties would have a Add method, but it doesn't.
What is a "Visual Studio SharePoint Package file" (.package)? I am trying to extract some data and this is the only file that looks large enough to contain what I'm after.
I have a site which has been running for some time now that uses a great deal of user input to build the site. Naturally there are dozens of forms on the site. When building the site, I often used hidden form fields to pass data back to the server so that I know which record to update.
an example might be:
<input type="hidden" name="id" value="132" />
<input type="text" name="total_price" value="15.02" />
When the form is submitted, these values get passed to the server and I update the records based on the data passed (i.e. the price of record 132 would get changed to 15.02).
I recently found out that you can change the attributes and values via something as simple as firebug. So...I open firebug and change the id value to "155" and the price value to "0.00" and then submit the form. Viola! I view product number 155 on the site and it now says that it's $0.00. This concerns me.
How can I know which record to update without either a query string (easily modified) or a hidden input element passing the id to the server?
And if there's no better way (I've seen literally thousands of websites that pass the data this way), then how would I make it so that if a user changes these values, the data on the server side is not executed (or something similar to solve the issue)?
I've thought about encrypting the id and then decrypting it on the other side, but that still doesn't protect me from someone changing it and just happening to get something that matches another id in the database.
I've also thought about cookies, but I've heard that those can be manipulated as well.
Any ideas? This seems like a HUGE security risk to me.
I have a logic problem: We have a database that has a donations table with name, address, last donation year, and last donation term (Spring and Fall). We want to pull all donors unless they donated in the last term (Spring or Fall). I have been trying to figure out the logic of pulling all years up to the current year while omitting the last term. So for example this year is 2012 and we are in the Spring term (I defined the spring term between 1/1 and 6/30) so I only want to display donors before and including spring 2011 (we will exclude the current term which is spring 12 and the last term which is fall 2011). The problem is I want to pull sprig 2011, fall 2010, spring 2010 etc, but only omit the current term and last term donated.
Is there an event which will get whether the user has moved his finger outside of the button?
Kind of like TouchUpOutside except without the "up" bit.
Like how the iphone keyboard, the letter gets smaller (back to normal) as you move your finger of the letter.
My configuration: Win7 + Python 2.6 + eclipse + PyDev
How do I enable Unicode print statements in:
PyDev console in eclipse
Idle Python GUI
Example print statement:
print(u"???? ????")
This comes out as:
ùìåí òåìí
I have a dict of lists in python:
content = {88962: [80, 130], 87484: [64], 53662: [58,80]}
I want to turn it into a list of the unique values
[58,64,80,130]
I wrote a manual solution, but it's a manual solution. I know there are more concise and more elegant way to do this with list comprehensions, map/reduce , itertools , etc. anyone have a clue ?
content = {88962: [80, 130], 87484: [64], 53662: [58,80]}
result = set({})
for k in content.keys() :
for i in content[k]:
result.add(i)
# and list/sort/print just to compare the output
r2 = list( result )
r2.sort()
print r2
I have an application that uses CoreData and I'm trying to figure out the best way to implement tagging and filtering by tag. For my purposes, if I was doing this in raw SQLite I would only need three tables, tags, item_tags and of course my items table. Then filtering would be as simple as joining between the three tables where only items are related to the given tags. Quite straightforward.
But, is there a way to do this in CoreData and utilizing NSFetchedResultsController? It doesn't seem that NSPredicate give you the ability to filter through joins. NSPredicate's aren't full SQL anyway so I'm probably barking up the wrong tree there. I'm trying to avoid reimplementing my app using SQLite without CoreData since I'm enjoying the performance CoreData gives me in other areas. Yes, I did consider (and built a test implementation) diving into the raw SQLite that CoreData generates, but that's not future proof and I want to avoid that, too.
Has anyone else tried to tackle tagging/filtering with CoreData in a UITableView with NSFetchedResultsController
I can get the active window's process, but I have no idea how to get the location of that process, as far as I can see the process object only has ProcessName property which just returns like chrome instead of C:\pathtochrome\chrome.exe
How can I get the latter because I'm trying to get the process's File Description attribute, but I need the full path to it.
I have a database in MS Access and within it I am holding dates for expirations for SSL's. I want to set a reminder for any SSL that is soon to expire. Anyone know the easiest way to go about this?
I'm using the post-receive-email script included with git. (Source is here.) It works just fine, but I want each email to be sent from the author of the commits pushed. How do I do it?
My post-receive file currently looks like this, and I want to customize the from-email-address.
#!/bin/sh
export [email protected]
$(dirname $0)/post-receive-email
I've been developing websites for over a decade now, but quickly found that many of my habits in developing for the web are useless when developing for email clients. This has caused me an enormous amount of frustration, so I thought I would ask a question that would hopefully surface the best practices and necessary considerations for others like myself who may find themselves designing for gmail, outlook, etc. from time to time.
Example: <style>...</style> vs inline CSS.
In short: what transfers over from the web-world to the email-world, and what doesn't.
How can I use touchesbegan in a table's cell without having to subclass a whole cell. Something like addTarget..... which is available for a UIButton?
(in vb.net this would be like AddHandler I think)
Hi, I'm looping a two-dimensional array like this:
if (!empty($aka)) {
foreach ($aka as $ak) {
if($ak["lang"]=="es") {
$sptitle=$ak["title"];
}
}
}
Pretty simple. If the array ($aka) is not empty I loop trough it and when it finds that the "lang" index is equal to "es" I just save the "title" value for that index in $sptitle.
The problem is that the array ($aka) contains a lot of information and sometimes there is no "lang" index... and I get this error: Notice: Undefined index: lang.
How can I fix this???
This is a extract of the array to help you understand. Notice that [1] doesn't have a [lang] index but [2] does have:
[1] => Array
(
[title] => The Lord of the Rings: The Motion Picture
[year] =>
[country] => USA
[comment] => promotional title
)
[2] => Array
(
[title] => Señor de los anillos: La comunidad del anillo, El
[year] =>
[country] => Argentina
[comment] => Chile, Mexico, Peru, Spain
[lang] => es
)
Thanks!
Last year I heard that Installer Projects were going away and we should be switching to Windows Installer XML. Whatever happened with that?
So you know where I'm coming from, support for TFS-based buil machines is very important to me. I know Installer Projects kinda-sorta work with TFS, but they have issues.
The alerts that I setup for source code changes isn't being triggered. I suspect that the email server settings are wrong, but where would I configure them?