{"QuestionId": 8779574, "AnswerCount": 1, "Tags": "", "CreationDate": "2012-01-08T17:25:13.273", "AcceptedAnswerId": "8779703", "Title": "UITableView only with Images", "Body": "

I'm developing an iOS App and I want to make a table view, but only with images like the 6G Nano images app. Does anyone know how to implement that?

\n", "Lable": "No"} {"QuestionId": 8877080, "AnswerCount": 2, "Tags": "", "CreationDate": "2012-01-16T07:58:22.020", "AcceptedAnswerId": "8877209", "Title": "Retrieving selected values from ListBox with multiselect", "Body": "

I have one WPF ListBox loaded using LINQ:

\n\n
lbxCalculosSec.ItemsSource = from p in database.CALCULOS\n                             orderby p.NOMBRECALCULO\n                             select new { ID = p.IDCALCULO, NOMBRE = p.NOMBRECALCULO + \" - \" + p.DESCRIPCIONCALCULO };\n\nlbxCalculosSec.DisplayMemberPath = \"NOMBRE\";\nlbxCalculosSec.SelectedValuePath = \"ID\";\n
\n\n

The listbox has multiselect = true. The problem is when I try to retrieve all the SelectedValue's (ID's) from SelectedItems List.

\n\n

When I inspect one SelectedItem at runtime, the object type is \"<>f__AnonymousType0`2\"

\n\n

I tried using this:

\n\n
ItemPropertyInfo ID  = null;\n\nlbxCalculosSec.SelectedItem.GetType().GetProperty(\"ID\").GetValue(ID as ItemPropertyInfo, null)\n
\n\n

But it didn't work.

\n\n

I need a solution to access ListBox Selected Values (ID fields).

\n\n

Thank you very much in advance.

\n\n

Kind Regards.

\n", "Lable": "No"} {"QuestionId": 8929554, "AnswerCount": 1, "Tags": "", "CreationDate": "2012-01-19T16:24:09.210", "AcceptedAnswerId": null, "Title": "Custom run-time type system/ library for C++", "Body": "

In an application I'm making at the moment, I have an EventDispatcher class that works with a base Event class. The dispatcher is not templated, it works with the run-time types of each event; this is to allow scripts to inherit from the base Event class and make their own types of events.

\n\n

It'd like this event dispatcher to handle inheritance of events as well. For example, I have FooEvent that inherits from a FooBaseEvent; whenever a FooEvent occurs, callbacks interested in FooBaseEvent are also notified, but not the other way around.

\n\n

Is there any library that would make this easier? Remember that inheritance checking should be extended to events defined in scripts as well.

\n\n

(The scripting language is Python, but that shouldn't matter so much.)

\n\n
\n\n

Edit: My EventDispatcher has the following interface (Python):

\n\n
class EventDispatcher:\n    def subscribe(self, event_type, callback) -> EventDispatcher.Subscription\n    def post(self, event)\n\n    class Subscription:\n        def cancel(self)\n        def alive(self) -> bool\n
\n", "Lable": "No"} {"QuestionId": 8974040, "AnswerCount": 2, "Tags": "", "CreationDate": "2012-01-23T15:27:08.793", "AcceptedAnswerId": "8974103", "Title": "Why is this foreach failing?", "Body": "

The script I am using 'gets' a html page and parses is showing only the .jpg images within, but I need to make some modifications and when i do it simply fails...

\n\n

This works:

\n\n
include('simple_html_dom.php');\n\nfunction getUrlAddress() {\n    $url = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';\n    return $url .'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];\n}\n\n$html = file_get_html($url);\n\nforeach($html->find('img[src$=jpg]') as $e)\n    echo '<img src='.$e->src .'><br>';\n
\n\n

However, there are some problems... I only want to show images over a certain size, plus some site do not display full URL in the img tag and so need to try to get around that too... so I have done the following:

\n\n
include('simple_html_dom.php');\n\nfunction getUrlAddress() {\n    $url = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';\n    return $url .'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];\n}\n\n$html = file_get_html($url);\n\nforeach($html->find('img[src$=jpg]') as $e)\n   $image = $e->src;\n\n// check to see if src has domain\nif (preg_match(\"/http/\", $e->src)) { \n    $image = $image; \n} else {\n    $parts = explode(\"/\",$url);\n    $image = $parts['0'].\"//\".$parts[1].$parts[2].$e->src;\n}\n\n$size = getimagesize($image);\n\necho \"<br /><br />size is {$size[0]}\";\necho '<img src='.$image.'><br>';\n
\n\n

This works, but only returns the first image.

\n\n

On the example link below there are 5 images, which the first code shows but does not display them as the src is without the leading domain

\n\n

Example link as mentioned above

\n\n

Is there a better way to do this? And why does the loop fail?

\n", "Lable": "No"} {"QuestionId": 9036482, "AnswerCount": 3, "Tags": "", "CreationDate": "2012-01-27T16:15:33.333", "AcceptedAnswerId": "9036801", "Title": "Is it good practice to cache parts of a 2D drawing?", "Body": "

I'm making a 2D game in Java and one of the main issues causing low FPS (on my slow laptop) is having to re-draw complex structures to a Graphics instance, such as dials with markings.

\n\n

The dial and its markings will never change unless the window is resized, so I thought it would be a good idea to draw to a BufferedImage and just re-draw the image rather than re-drawing the details. The position of the needle obviously changes, so this can just be drawn on top.

\n\n

I've never heard about this being done to improve the FPS of 2D games so I'm wondering if it's actually good practice to store a cache of images or if there's a better way to solve this sort of problem? Are there any issues associated with this that I haven't considered?

\n", "Lable": "No"} {"QuestionId": 9040355, "AnswerCount": 5, "Tags": "
", "CreationDate": "2012-01-27T21:32:37.430", "AcceptedAnswerId": null, "Title": "Alternative to NSDistributedNotificationCenter for comms between iPhone apps", "Body": "

I've been looking for a way to compare timestamps between applications on the same phone in real time, and NSDistributedNotificationCenter sounded like an ideal solution since i may not know the names of the apps listening for it, but it sounds like its not available in iOS.

\n\n

Is there an equivalent way of notifying multiple apps of a time-sensitive event without knowing their name?

\n\n

Coding for iOS 5+ and assuming the apps in question will register for the notification.

\n", "Lable": "No"} {"QuestionId": 9060146, "AnswerCount": 1, "Tags": "", "CreationDate": "2012-01-30T06:26:17.983", "AcceptedAnswerId": "9405083", "Title": "How to make method like UIActionSheet initWithTitle", "Body": "

How can i make method with parameter is unlimited array like this :

\n\n
UIActionSheet *actionSheet = [[[UIActionSheet alloc]\n                initWithTitle:@\"Test Title\"\n                delegate:self\n                cancelButtonTitle:@\"Cancel\"\n                destructiveButtonTitle:@\"Destructive\"\n                otherButtonTitles: @\"abc\", @\"xyz\",\n                nil] autorelease];\n
\n\n

In above code, parameter otherButtonTitles can have unlimit number of NSString like \"abc\", \"xyz\",..\nCan do this with other type of parameter?
\nThanks in advance!.

\n", "Lable": "No"} {"QuestionId": 9074893, "AnswerCount": 3, "Tags": "", "CreationDate": "2012-01-31T05:31:54.590", "AcceptedAnswerId": null, "Title": "undefined local variable or method `config' for main:Object - rails", "Body": "

When I run the rails application, I get the following error:

\n\n
\n

undefined local variable or method \"config\" for main:Object

\n
\n\n

How can I resolve it?

\n", "Lable": "No"} {"QuestionId": 9141619, "AnswerCount": 1, "Tags": "", "CreationDate": "2012-02-04T14:37:41.407", "AcceptedAnswerId": "18978552", "Title": "After Upgrading JQuery Mobile to 1.0.1, Code Isn't Working", "Body": "

This works just fine, with JQM 1.0a1:

\n\n
<!DOCTYPE HTML>\n<html lang=\"en-US\">\n<head>\n<meta charset=\"UTF-8\">\n<title>Main Page</title>\n<link rel=\"stylesheet\" href=\"http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css\" />\n<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js\"></script>\n<script src=\"http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js\"></script>\n</head>\n<body>\n<div data-role=\"page\">\n<div data-role=\"header\"><h1>Main Page</h1></div>\n<div data-role=\"content\"><p><a href=\"#map\">Map</a></p></div>\n</div>\n<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>\n<script type=\"text/javascript\">\n\n    $('#map').live(\"pagecreate\", function() {\n        initialize(1.359,103.818);\n    });\n\n\n    function initialize(lat,lng) {\n        var latlng = new google.maps.LatLng(lat, lng);\n        var myOptions = {\n            zoom: 8,\n            center: latlng,\n            mapTypeId: google.maps.MapTypeId.ROADMAP\n        };\n        var map = new google.maps.Map(document.getElementById(\"map_canvas\"),myOptions);\n    }\n\n\n</script>\n\n<div id=\"map\" data-role=\"page\" data-theme=\"b\" class=\"page-map\" style=\"width:100%; height:100%;\">\n<div data-role=\"header\"><h1>Map Page</h1></div>\n<div data-role=\"content\" style=\"width:100%; height:100%; padding:0;\"> \n    <div id=\"map_canvas\" style=\"width:100%; height:100%;\"></div>\n</div>\n</div>\n</body>\n</html>\n
\n\n

But the same using JQM 1.0.1 (http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js) doesn't show the map at all. I tried using $('#map').on and \"pageinit\" to no avail.

\n\n

What am I missing?

\n\n

UPDATE: same behavior with JQuery 1.6.3

\n\n

UPDATE2: by giving an absolute size (eg height: 200px; width: 200px;) to the #map-canvas div, it works fine.

\n", "Lable": "No"} {"QuestionId": 9144856, "AnswerCount": 3, "Tags": "", "CreationDate": "2012-02-04T21:48:10.057", "AcceptedAnswerId": null, "Title": "Stop Words into a string", "Body": "

I want to create a function in PHP that will return true when it finds that in the string there are some bad words.

\n\n

Here is an example:

\n\n
function stopWords($string, $stopwords) {\nif(the words in the stopwords variable are found in the string) {\nreturn true;\n}else{\nreturn false;\n}\n
\n\n

Please assume that $stopwords variable is an array of values, like:

\n\n
$stopwords = array('fuc', 'dic', 'pus');\n
\n\n

How can I do that?

\n\n

Thanks

\n", "Lable": "No"} {"QuestionId": 9178734, "AnswerCount": 2, "Tags": "", "CreationDate": "2012-02-07T15:15:05.753", "AcceptedAnswerId": "9189245", "Title": "LESS syntax for .mixin > *", "Body": "

I am using LESS and im trying for a type of mixin.

\n\n

I have this mixin:

\n\n
.mixin, .mixin > * {\n    font:arial;\n}\n
\n\n

and i want to use it as a mix in so.

\n\n
.my-class {\n    color:#000;\n    .mixin;\n}\n
\n\n

becomes

\n\n
.my-class {\n    color:#000;\n}\n\n.my-class, .my-class > * {\n    font:arial;\n}\n
\n\n

But it doesnt work, probobly because i cannot use mixins like that. Or can I? How do i write them then? Cannot find this information in the documentation of LESS.

\n", "Lable": "No"} {"QuestionId": 9240763, "AnswerCount": 1, "Tags": "", "CreationDate": "2012-02-11T13:57:45.603", "AcceptedAnswerId": "9240801", "Title": "Working with for loop and jquery load event for multiple images return only the last loaded one props", "Body": "

I'm working with a jQuery plug-in useful to zoom the resized background images with the mouse interaction.

\n\n

To make it work, I thought to use an array of objects with the width and height of a background-image of every element I bring to it.

\n\n

To do this I've created an empty img element, set the src attribute to the background image, and once it's loaded getting width and height.

\n\n

I've thought to handle it starting in a for loop which prepares every image, when the jQuery event load is called I create the new array element with every info about the loaded image.

\n\n

It seems the load event sets the first loaded image, and apply the same properties to every element loaded after it, how can I avoid this problem?

\n\n
// this is a portion of the plugin\n\nvar setImageSize = function (i) {\n    return function (e) {\n        // I use the extend method only to get different zoom animation if they are added by the user\n        instances[i] = {id:i, element:this_obj.get(i), settings:$.extend(true, defaults, options)};\n        instances[i].settings.bg.url = getBackgroundUrl(i);\n        instances[i].settings.bg.width = parseInt($(this).width());\n        instances[i].settings.bg.height = parseInt($(this).height());\n        updateDefaultValues(instances[i]);\n        $(instances[i].element).hover(setRollOver(i), setRollOut(i));\n        $(window).resize(getUpdateDefaultValues(i));\n        $('#debug').html($('#debug').html() + 'image loaded: ' + i + ' url:' + instances[i].settings.bg.url +'<br/>width: '+ instances[i].settings.bg.width +' height: '+ instances[i].settings.bg.height +'<br>- - - - - <br>');\n        $(this).remove();\n    }\n}\n\nvar prepareImageSize = function (i) {\n    var img = $('<img id=\"jquery-background-zoom-'+i+'\"/>');\n    img.hide();\n    img.bind('load', setImageSize(i));\n    $('body').append(img);\n    img.attr('src', getBackgroundUrl(i));\n}\n\nvar init = function () {\n    for (var i = 0; i < this_obj.length; i ++) {\n        prepareImageSize (i);\n    }\n}\n\ninit();\n
\n\n

I've reported a full working example here at http://jsfiddle.net/tonino/CFPTa/

\n\n

In the plug-in I've added a script to see how the images are set, then if you try to interact with the images you'll notice the props of every images are overwritten by the last loaded image, I'm not sure how?

\n\n

It seems like the load event overwrite previous load event or something, how can I fix it?

\n", "Lable": "No"} {"QuestionId": 9309288, "AnswerCount": 2, "Tags": "", "CreationDate": "2012-02-16T10:09:06.443", "AcceptedAnswerId": "9313325", "Title": "OpenCL- waste of host computing power", "Body": "

I am new to OpenCL, please tell me that the host cpu can be used only for allocating memory to the device, or we can use it can as an openCL device. (Because after the allocation is done, the host cpu will be idle).

\n", "Lable": "No"} {"QuestionId": 9366780, "AnswerCount": 1, "Tags": "", "CreationDate": "2012-02-20T18:55:53.723", "AcceptedAnswerId": null, "Title": "Awesomium with .NET VS2010 (ObjectForScripting)", "Body": "

I'm having some issues finding examples of how to use the Awesomium web browser control in vb.net with objectforscripting. I know that objectforscripting isn't the same for the webcontrol used with awesomium since its HTML5 and not the traditional IE control that comes with vs 2010.

\n\n

The issue I'm having is finding any info/examples on how to communicate with the awesomium web browser control with my javascript. It's quite easy with the IE built in control with objectforscripting. I've found samples of how to do it in C# but I don't see any info of how I could do it just in VB. I've searched several things in google and I just can't seem to find anything on how to do it.

\n\n

So for example, I would have a button in a php page that the webcontrol browsers to and if I click the button it closes the application down. So I need to communicate using window.external with the webcontrol in VB.

\n", "Lable": "No"}