How to break out of multiple loops in Python?

How to break out of multiple loops in Python?

Given the following code (that doesn't work):while True: #snip: print out current state while True: ok = get_input("Is this ok? (y/n)") if ok == "y" or ok == "Y": break 2 #this doesn't work :( if ok == "n" or ok =

Creating a byte array from a stream

Creating a byte array from a stream

What is the prefered method for creating a byte array from an input stream? Here is my current solution with .NET 3.5. Stream s;byte[] b;using (BinaryReader br = new BinaryReader(s)){ b = br.ReadBytes((int)s.Length);}Is it still a better

How to use FormData for ajax file upload

How to use FormData for ajax file upload

This is my html which I'm generating dynamically using drag and drop functionality.

Using jQuery to center a DIV on the screen

Using jQuery to center a DIV on the screen

How do I go about setting a

in the center of the screen using jQuery? 1:I like adding functions to jQuery so this function would help:jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", Math.max(

Difference between append vs. extend list methods in Python

Difference between append vs. extend list methods in Python

What's the difference between the list methods append() and extend()? 1:append: Appends object at end.x = [1, 2, 3]x.append([4, 5])print (x)gives you: [1, 2, 3, [4, 5]]extend: Extends list by appending elements from the iterable.x = [1,

How do I shuffle an array in Swift?

How do I shuffle an array in Swift?

How do I randomize or shuffle the elements within an array in Swift? For example, if my array consists of 52 playing cards, I want to shuffle the array in order to shuffle the deck. 1:This answer details how to add a fast and uniform (Fi

What's wrong with Java Date & Time API? [closed]

What's wrong with Java Date & Time API? [closed]

Very often I come across negative feedback on Java Date and other date-time-related classes. Being a .NET developer, I cannot fully (without having used them) understand, what's actually wrong with them. Can anybody shed some light on this?

What should my Objective-C singleton look like? [closed]

What should my Objective-C singleton look like? [closed]

My singleton accessor method is usually some variant of:static MyClass *gInstance = NULL;+ (MyClass *)instance{ @synchronized(self) { if (gInstance == NULL) gInstance = [[self alloc] init]; } return(gInstance);

How do I test multiple variables against a value?

How do I test multiple variables against a value?

I'm trying to make a function that will compare multiple variables to an integer and output a string of three letters. I was wondering if there was a way to translate this into Python. So say:x = 0y = 1z = 3mylist = []if x or y or z == 0 :

Add another button next to the “back” button on the left of a UINavigationBar

Add another button next to the “back” button on the left of a UINavigationBar

I've tried this for hours but I still cannot solve it.When using UINavigationController and push a new view controller on top, I got a free "back" button on the left of the navigation bar. I want another button just next to it (to show a po

Auto TimeStamp new entry to DB (phpMyAdmin)

Auto TimeStamp new entry to DB (phpMyAdmin)

If I want each new entry into my db to be automatically timestamped, would I set the Field Type to "timestamp" and have the Default value set to "CURRENT_TIMESTAMP"?Is this the correct method? 1:That is correct. In SQL code that would be

JQuery UI dialog - *Dialog not a function* error

JQuery UI dialog - *Dialog not a function* error

I am developing a site using pinax. In one of my templates I am trying to open a simple jquery dialog box. However I keep getting the "Dialog not a function" javascript error. I am using jquery 1.2.6 and jquery-ui 1.6. My javascript and HTM

CSS using negative relative positioning issue

CSS using negative relative positioning issue

I have a header, mainbody and footer. Header and mainbody are properly styled. Now for footer I want to make it appear behind mainbody, so I used:z-index: -1;position: relative;top: -60px;This gives the desired result, but I get an extra sp

Jackson JsonNode to string with sorted keys

Jackson JsonNode to string with sorted keys

I'm using Jackson 2.2.3 and need to convert a JsonNode tree into a string with sorted field keys. It's completely unclear to me how to do this, especially since the opposite is so simple - JsonNode jn = ObjectMapper.readTree(String s).It ap

Pyramid: Custom 404 page returns as “200 OK”

Pyramid: Custom 404 page returns as “200 OK”

I have a custom 404 view defined in my Pyramid app:@view_config(context=HTTPNotFound, renderer='404.pt')def not_found(self, request): return {}It works fine, except that the HTTP status code sent with the content is 200 OK, which is not

Facebook crops open graph image in to a square

Facebook crops open graph image in to a square

I'm trying to create a custom open graph story to Facebook but I'm having some trouble getting the og:image to show properly. I'm using a 1200*630 sized image as recommended here and here but on my timeline it gets cropped in to a square fr

Why does PostgreSQL not return null values when the condition is  true

Why does PostgreSQL not return null values when the condition is true

I was confused behind the reasoning of the following:SELECT * FROM table WHERE avalue is nullReturns x number of rows where 'avalue' is nullSELECT * FROM table WHERE avalue trueDoes not return rows where 'avalue' is null. My reasoning (whi

How to copy a “Dictionary” in Swift?

How to copy a “Dictionary” in Swift?

How to copy a "Dictionary" in Swift?That is, get another object with same keys/values but different memory address.Furthermore, how to copy an object in Swift?Thanks, 1:A 'Dictionary' is actually a Struct in swift, which is a value type.

C# boolean int conversion issue

C# boolean int conversion issue

I am working on a trading API (activex from interactive brokers)which has a method called:void reqMktDataEx(int tickerId, IContract contract, string generalDetails, int snapshot)The issue is around the last parameter "int snapshot" which ob

suppress instance method override linker warning framework xcode

suppress instance method override linker warning framework xcode

I have a library that started throwing a couple linker warnings under XCode 4.4. The warnings are along the lines of "ld: warning: instance method 'methodName:' in category from overrides method from class in "The framework still work fine

What is meaning of a pointer to a constant function?

What is meaning of a pointer to a constant function?

Pointers can be declared as pointing to mutable (non-const) data or pointer to constant data.Pointers can be defined to point to a function.My coworkers and I were discussing the use of "const" with pointers and the question came up regardi

Spaces cause split in path with PowerShell

Spaces cause split in path with PowerShell

I'm having an issue with powershell when invoking an exe at a path containing spaces.PS C:\Windows Services> invoke-expression "C:\Windows Services\MyService.exe"The term 'C:\Windows' is not recognized as the name of a cmdlet, function, scr

OCaml explicit type signatures

OCaml explicit type signatures

In Haskell, it is considered good practice to explicitly declare the type signature of your functions, even though it can (usually) be inferred. It seems like this isn't even possible in OCaml, e.g. val add : int -> int -> int ;;gives me an

how to change jQuery autocomplete plugin default querystring key? (term to that i want)

how to change jQuery autocomplete plugin default querystring key? (term to that i want)

jQuery autocomplete plugin sent request like thismysite.com/suggestion?term=Sadeghis there any way to change term querystring key to another? i can't find option that provide this for me ;) 1:I assume you're using jQuery UI AutoCompleteY

What is the difference between destroy() and delete() methods in Laravel?

What is the difference between destroy() and delete() methods in Laravel?

I'm having a minor issue with Laravel 4. I'd like to use the delete() method on a record but for some reason it doesn't actually delete the record. destroy() does, though, so my code is good. Also, if I pass Teetime::where('date', '=', $for