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 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 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.
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)?
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.
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.
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 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 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 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 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.
We're being told that fewer HTTP requests per page load is a Good Thing. The extreme form of that for CSS would be to have a single, unique CSS file per page, with any shared site-wide styles duplicated in each file.
But there's a trade off there. If you have separate shared global CSS files, they can be cached once when the front page is loaded and then re-used on multiple pages, thereby reducing the necessary size of the page-specific CSS files.
So which is better in real-world practice? Shorter CSS files through multiple discrete CSS files that are cacheable, or fewer HTTP requests through fewer-but-larger CSS files?
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
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)
Found the following in an Oracle-based application that we're migrating (generalized):
SELECT
Table1.Category1,
Table1.Category2,
count(*) as Total,
count(Tab2.Stat) AS Stat
FROM Table1, Table2
WHERE (Table1.PrimaryKey = Table2.ForeignKey(+))
GROUP BY Table1.Category1, Table1.Category2
What does (+) do in a WHERE clause? I've never seen it used like that before.
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
Does anyone know where I can get documentation on "Lists Web Service" for SharePoint. I tried this link, but it seems that every child link goes to a random page.
http://msdn.microsoft.com/en-us/library/dd587198(office.11).aspx
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.
I am using the Jquery Validation plug-in, however i need to add a "custom rule", i have 2 date fields and i need to ensure that the end date is not less than the start date. My problem is how to pass the two fields in as elements.
As i understand u set up a custom function something like this :
function customValidationMethod(value, element, params){ }
But can't see how i could use it with two fields, if anyone has any ideas it would be greatly appreciated.
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.
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!
Not sure I fully understand what phpmyadmin does.
I created a database in phpmyadmin, and would now like to start accessing the data in it from php. However I have no idea where the database is?
Should I export in the phpmyadmin software? I tried that but it came up with a .sql file which can be opened in notepad and contains the SQL statements used to create the datbase and the one table inside. Basically that doesn't look like a database to me.
Hi!
I need to retrieve the name, email and picture from a google account.
I am already using the openid to make the user login with it's google acc.
Can I have the picture URL from the openid proccess?
with OAuth I cant'seem to find the right scope to retrieve this information... See this link:
http://code.google.com/apis/gdata/docs/directory.html
there is a list of scopes that you can fetch with REST api to google and I didnt't see the one related to the profile.
Btw, I am using PHP and the openid is already working, but didn't start with the oauth untill I know if I can(and need) retrieve the picture (because email and name already comes within the openid proccess)
thanks,
Joe
How would I programatically access a SharePoint document library from another machine? I want to recursively scan all the folders and generate a list of files with a certain custom property.