Rectangle 27 2

Why are you getting that result?

nil

It does happen because dataArray is defined as an array of optional Int (aka Int?). So the last property does return a value that is an Optional containing nil.

So the if clause is satisfied and the body of the if is executed.

let dataArray: [Int?] = [1, nil ,3]

if let lastOptional = dataArray.last, last = lastOptional {
    print("dataArray.last != nil, last = \(last)")
} else {
    print("dataArray.last == nil")
}
dataArray.last != nil, last = 3

Let's look at the if. It is made of 2 clauses and both must be satisfied for the if to be resolved as true.

let lastOptional = dataArray.last

does succeed if the last element does exist. It will be an Int? so an optional value containing nil or an Int. In both case this clause is satisfied.

Basically the first clause is satisfied when the array is NOT empty.

last = lastOptional

does succeed if the optional last (Int?) element is successfully unwrapped.

This clause is satisfied when the last element does exists and is not an Optional containing nil.

Inside the body of the if you can use last and you can be sure that it will be the unwrapped value. Infact the type of last is Int.

Your example is not an array of optionals (as in the question).

ios - Swift - How to check if var is nil? - Stack Overflow

ios swift swift2 ios9
Rectangle 27 17

You are getting a result which happens to be char representation of below values

104 -> h
101 -> e
108 -> l
108 -> l
111 -> o
32  -> (space)
119 -> w
111 -> o
114 -> r
108 -> l
100 -> d

java - How does this print "hello world"? - Stack Overflow

java string bit-shift
Rectangle 27 17

You are getting a result which happens to be char representation of below values

104 -> h
101 -> e
108 -> l
108 -> l
111 -> o
32  -> (space)
119 -> w
111 -> o
114 -> r
108 -> l
100 -> d

java - How does this print "hello world"? - Stack Overflow

java string bit-shift
Rectangle 27 55

Given a string, with a complete python path to a function, this is how I went about getting the result of said function:

import importlib
function_string = 'mypackage.mymodule.myfunc'
mod_name, func_name = function_string.rsplit('.',1)
mod = importlib.import_module(mod_name)
func = getattr(mod, func_name)
result = func()

This helped me. Its a lightweight version of __import__ function.

python - Calling a function of a module from a string with the functio...

python
Rectangle 27 55

Given a string, with a complete python path to a function, this is how I went about getting the result of said function:

import importlib
function_string = 'mypackage.mymodule.myfunc'
mod_name, func_name = function_string.rsplit('.',1)
mod = importlib.import_module(mod_name)
func = getattr(mod, func_name)
result = func()

This helped me. Its a lightweight version of __import__ function.

python - Calling a function of a module from a string with the functio...

python
Rectangle 27 54

Given a string, with a complete python path to a function, this is how I went about getting the result of said function:

import importlib
function_string = 'mypackage.mymodule.myfunc'
mod_name, func_name = function_string.rsplit('.',1)
mod = importlib.import_module(mod_name)
func = getattr(mod, func_name)
result = func()

This helped me. Its a lightweight version of __import__ function.

python - Calling a function of a module from a string with the functio...

python
Rectangle 27 54

Given a string, with a complete python path to a function, this is how I went about getting the result of said function:

import importlib
function_string = 'mypackage.mymodule.myfunc'
mod_name, func_name = function_string.rsplit('.',1)
mod = importlib.import_module(mod_name)
func = getattr(mod, func_name)
result = func()

This helped me. Its a lightweight version of __import__ function.

python - Calling a function of a module from a string with the functio...

python
Rectangle 27 25

Loki's answer points to the Hibernate 3 docs and provides good information, but I was still not getting the results I expected.

Much thrashing, waving of arms and general dead mouse runs finally landed me my cheese.

Because Hibernate 3 is using Simple Logging Facade for Java (SLF4J) (per the docs), if you are relying on Log4j 1.2 you will also need the slf4j-log4j12-1.5.10.jar if you are wanting to fully configure Hibernate logging with a log4j configuration file. Hope this helps the next guy.

Yup you need the slf4j-log4j12-1.5.10.jar to wire the facade into the underlying logging layer. The configuration file is still a log4j configuration if you are using log4j as the logging layer.

Configuring Hibernate logging using Log4j XML config file? - Stack Ove...

xml hibernate logging configuration log4j
Rectangle 27 2

Its because cells can be re-used right? thats why you are getting this result.

But finally, I would suggest that don't do any cell formatting kind of things directly here. Try to understand UICollectionViewLayoutAttributes and use it to do these kind of stuff there.

Hmm.Just declare one global NSIndexPath variable, then assign the selected indexpath to that variable, now based on that stored index you just apply your formattings in cellForItemAtIndexPath thats it..

selection - UICollectionView Tap Selects More Than One Cell - Stack Ov...

selection uicollectionview uitapgesturerecognizer uicollectionviewcell
Rectangle 27 10

There's nothing missing. Float was designed for the case where you want an image (for example) to sit beside several paragraphs of text, so the text flows around the image. That wouldn't happen if the text "stretched" the container. Your first paragraph would end, and then your next paragraph would begin under the image (possibly several hundred pixels below).

And that's why you're getting the result you are.

How does that have anything to do with the floated element properly stretching the height of the parent?

css - Floating elements within a div, floats outside of div. Why? - St...

css html css-float
Rectangle 27 10

There's nothing missing. Float was designed for the case where you want an image (for example) to sit beside several paragraphs of text, so the text flows around the image. That wouldn't happen if the text "stretched" the container. Your first paragraph would end, and then your next paragraph would begin under the image (possibly several hundred pixels below).

And that's why you're getting the result you are.

How does that have anything to do with the floated element properly stretching the height of the parent?

css - Floating elements within a div, floats outside of div. Why? - St...

css html css-float
Rectangle 27 10

There's nothing missing. Float was designed for the case where you want an image (for example) to sit beside several paragraphs of text, so the text flows around the image. That wouldn't happen if the text "stretched" the container. Your first paragraph would end, and then your next paragraph would begin under the image (possibly several hundred pixels below).

And that's why you're getting the result you are.

How does that have anything to do with the floated element properly stretching the height of the parent?

css - Floating elements within a div, floats outside of div. Why? - St...

css html css-float
Rectangle 27 2

The reason you are not getting any results is that there is no <a> elements that satisfy both conditions.

These are the links containing "3499047" in @href:

<a href="showthread.php?s=9bc55ab5990282a5353fb20d505d577e&amp;t=3499047" id="thread_title_3499047">Tesco misprices and discussion (Thread 12)</a>
<a href="showthread.php?s=9bc55ab5990282a5353fb20d505d577e&amp;t=3499047">1</a>
<a href="showthread.php?s=9bc55ab5990282a5353fb20d505d577e&amp;t=3499047&amp;page=2">2</a>
<a href="showthread.php?s=9bc55ab5990282a5353fb20d505d577e&amp;t=3499047&amp;page=3">3</a>
<a href="showthread.php?s=9bc55ab5990282a5353fb20d505d577e&amp;t=3499047&amp;page=110">Last Page</a>
<a href="member.php?s=9bc55ab5990282a5353fb20d505d577e&amp;find=lastposter&amp;t=3499047" rel="nofollow">ExiledCockney</a>
<a href="misc.php?do=whoposted&amp;t=3499047" onclick="who(3499047); return false;">2,184</a>
<a rel="shadowbox;width=732;height=527;player=iframe;" href="wow.php?t=3499047" target="_blank" style="display: block; width: 100%; height: 100%; cursor: pointer;">
        <div style="width: 100%; height: 100%;  background-image: url('http://images2.moneysavingexpert.com/images/forum_style_2/misc//wow_big_faint_grey.gif');">
            <div style="padding: 12px 0px 0px 0px;">
                <strong>3</strong>
            </div>
        </div>
    </a>

As you can see, none of them contain "'font-weight:bold'" in a style attribute.

In case the markup on the page has elements with your desired combination when you view it in a browser, they might have been added via javascript. DOM will not run any JavaScript, so you have to check the markup fetched with DOM.

Ahh, yes, I get a completely different HTML source. It will be because I am logged in - hence why I'm seeing bold font. Thanks! That really is a doh moment.

I now have it working (using id attribute) - thank you very much! Another quick question - is there any way to pull the value of t=xxxxxxxx ? e.g. above it's t=3499047

@cud use parse_url on the @href value. If there is multiple arguments in the query string, use parse_str.

PHP Dom XPath - Why isn't it working? - Stack Overflow

php dom xpath
Rectangle 27 5

If I'm removing the tags: "form" and "/form" I'm getting the same results

In other words , if you add :

<input type="submit" />

Form posts its inputs values (+ select , textarea etc...) to a server. Then you can read those values at the server side.

  • Giving a name to a form allows you to access its child inputs via their name : alert(myForm.myUserInputName)
  • You can cause the post to yield its result/response in other iframe/location using target property.
  • You can cause the page to post itself via GET and not via POST , which will cause all input values to be as QueryString.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

javascript - What is the benefit for using "form" tag? - Stack Overflo...

javascript html
Rectangle 27 3

you need to call rSet.next() in getRowCount() before getting the result (and i don't even think you are creating the row count query anywhere in this code).

also, you are not closing your database resources before discarding them, which will cause resource leaks. always close database resources in finally blocks as soon as you are finished with them.

I thought of this just now as well. As for the closes they are there but only via the Close() method. I do not want to close them down before I am finished with them. The program continually waits for new data to be added but once the user clicks on the Exit button in another one of my classes I call Close.

@Geowil - everytime you re-assign the statement and rSet member variables, you are losing a reference to a previous Statement/ResultSet (everytime you call addDonor() you create a new Statement and multiple new ResultSet instances). when you do that, you are leaking resources. you must close them before you discard them

java - JDBC ResultSet.getString Before/After Start/End of ResultSet Ex...

java mysql exception jdbc
Rectangle 27 325

Andrew I think the problem you are getting is a result of the RenderPartial method using the calling (view)'s model to the partial view when the model you pass is null.. you can get around this odd behavior by doing:

<% Html.RenderPartial("TaskList", Model.Tasks, new ViewDataDictionary()); %>

I get why they support null model and passing the pages Model but couldn't they have handled that by overloading. @Html.Render("donkeys") is different than @Html.Render("donkeys", couldbenull)

I found that with this solution my ValidationSummary in my partial view did not work because the ViewData of the primary model was lost in the partial view. I used the answer given here stackoverflow.com/a/12037580/649497 to solve this.

You should pass along the existing ViewData: new ViewDataDictionary(ViewData)

asp.net mvc - renderpartial with null model gets passed the wrong type...

asp.net-mvc renderpartial
Rectangle 27 325

Andrew I think the problem you are getting is a result of the RenderPartial method using the calling (view)'s model to the partial view when the model you pass is null.. you can get around this odd behavior by doing:

<% Html.RenderPartial("TaskList", Model.Tasks, new ViewDataDictionary()); %>

I get why they support null model and passing the pages Model but couldn't they have handled that by overloading. @Html.Render("donkeys") is different than @Html.Render("donkeys", couldbenull)

I found that with this solution my ValidationSummary in my partial view did not work because the ViewData of the primary model was lost in the partial view. I used the answer given here stackoverflow.com/a/12037580/649497 to solve this.

You should pass along the existing ViewData: new ViewDataDictionary(ViewData)

asp.net mvc - renderpartial with null model gets passed the wrong type...

asp.net-mvc renderpartial
Rectangle 27 4

Your C# declaration is wrong. A VB6 "Long" is 32-bits for historical reasons. That's an int on the C# side. With the stack frame wrong, you have no odds of getting the "result" argument passed correctly.

It ought to be a SafeArray of Variants, object[] in C#.

I've switched it to bool GetList(ref int rCount, ref int cCount, ref object[] result); and it still doesn't work. I get a .NET Exception right away.

Hans, the exception that is thrown is "Visual Basic has generated an exception..." It only happens with the result Variant() type. I created a new .NET method to test (below is my signature form the Interface): string Test(ref object[] value); Then, I created a test VB6 app like so: Private Sub Command1_Click() Set mx = CreateObject("Component.Class") Dim result() MsgBox mx.Test(result) End Sub Same issue as described above. As I originally described, it doesn't like the Variant type.

I've updated the stem above for your review.

It's going to take me a while to jumpstart that old machine. Bleh. I'd recommend a bonus.

c# - VB6 Variant Type to .NET Type - Stack Overflow

c# vb.net vb6 interop com-interop
Rectangle 27 10

A better approach here might be to use the Repository pattern to encapsulate your EF code. When testing your services you can use mocks or fakes. When testing your repositories you will want to hit the real DB to ensure that you are getting the results you expect.

If I just mock the Repository to return a given Customer, this doesn't test the Specification. I want to include the Specification in the unit test, and not wait until I'm using a real DB.

Lol.. And how LINQ2Entities queries can be tested with Repository pattern? There are no way to do this because these queries will generate sql queries and we need to test them in the database too.

I'm accepting this answer because it is the closest thing to what I actually did. I created interfaces in the shape of the Repository pattern, then implemented both an EF adapter and an in-memory test harness. It doesn't test the DB, but it does test my own Specifications.

Yes use Moq with InMemoryDbSet. This does not work for outer join but is good for inner join LINQ queries.

rhino mocks - Is there an in-memory provider for Entity Framework? - S...

entity-framework rhino-mocks
Rectangle 27 1

try{
            SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss Z");
            Date datetime = new Date();

            System.out.println("date "+sdf.format(datetime));

            sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

            System.out.println("GMT "+ sdf.format(datetime));

            sdf.setTimeZone(TimeZone.getTimeZone("GMT+13"));

            System.out.println("GMT+13 "+ sdf.format(datetime));

            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));

            System.out.println("utc "+sdf.format(datetime));

            Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("GMT"));

            DateFormat formatter = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z");    
            formatter.setTimeZone(TimeZone.getTimeZone("GMT+13"));  

            String newZealandTime = formatter.format(calendar.getTime());

            System.out.println("using calendar "+newZealandTime);

        }catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

and getting this result

date 06-10-2011 10:40:05 +0530
GMT 06-10-2011 05:10:05 +0000 // here getting 5:10:05
GMT+13 06-10-2011 06:10:05 +1300 // here getting 6:10:05
utc 06-10-2011 05:10:05 +0000
using calendar 06 Oct 2011 18:10:05 GMT+13:00

Hi pratik thanks for you input but you are missing the point. As mentioned in my IP I have it working for a current time stamp. The issue is with setting a time stamp and then generating accurate timezone specific output.

yeah it also work if you change the time. The time zone was set into the format object so whatever time you passed that will based on timezone which was specified into the format object

Hmmmm... I have tried adding: datetime.setTime(Timestamp.valueOf("2011-10-06 03:35:05").getTime()); And still it doesn't work. How do you figure it works when you set the time?

datetime - Convert Date/Time for given Timezone - java - Stack Overflo...

java datetime formatting timezone timestamp