Daily Archives

Articles indexed Sunday March 14 2010

Page 22/89 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Can I use an NSDecimalNumber anywhere that an NSNumber is expected?

    - by Nick Forge
    NSDecimalNumber is a subclass of NSNumber, and from what I can tell, it implements all of the NSNumber methods as expected for an NSNumber instance. Given that, is it ok to give NSDecimalNumbers to any code that is expecting an NSNumber? The only possible issue might be code that checks that an argument is an instance of NSNumber, but since NSNumber is a class-cluster, code like this would have to check that the instance is a subclass of NSNumber, and NSDecimalNumber instances should pass the same tests.

    Read the article

  • onPause/onResume activity issues

    - by Josh
    I have a small test application I am working on which has a timer that updates a textview to countdown from 100 to 0. That works fine, but now I am trying to pause the application if the user presses the back button on the phone and then restart the timer from where they left off when they reopen the app. Here is the code I am using: @Override public void onPause() { if(this._timer_time_remaining > 0) { this.timer.cancel(); } super.onPause(); Log.v("Pausing", String.format("Pausing with %d", this._timer_time_remaining)); } @Override public void onResume() { super.onResume(); Log.v("Resuming", String.format("Resuming with %d", this._timer_time_remaining)); if(this._timer_time_remaining > 0) { setContentView(R.layout.in_game); start_timer(this._timer_time_remaining); } } The start_timer() method creates a CountDownTimer which updates the textview in the onTick method and updates the this._timer_time_remaining int variable. CountDownTimer and _timer_time_remaining are both declared at the class level like this: private CountDownTimer timer; private int _timer_time_remaining; From the Log.v() prints I see that the _timer_time_remaining variable has the correct number of seconds stored when onPause is called, but it is set back to 0 when onResume starts. Why does the variable get reset? I thought that the application would continue to run in the background with the same values. Am I missing something? This is all declared in a class that extends Activity. Thanks in advance!

    Read the article

  • Jaxer and HTTP proxy requests...

    - by rakhavan
    Thanks to everyone in advance. I'm using Jaxer.sandbox and making requests just fine. I'd like these requests to go through my http proxy (like squid for example). Here is the code I that is currently working for me. window.onload = function() { //the url to scrape var url = "http://www.cnn.com/"; //our sandboxed browser var sandbox = new Jaxer.Sandbox(); //open optons var openOptions = new Jaxer.Sandbox.OpenOptions(); openOptions.allowJavaScript = false; openOptions.allowMetaRedirects = false; openOptions.allowSubFrames = false; openOptions.allowSubFrames = false; openOptions.onload = function() { //do something onload }; //make the call sandbox.open(url, null, openOptions); //write the response Jaxer.response.setContents(sandbox.toHTML()); }; How can I send this request through a proxy server? Thanks, Reza.

    Read the article

  • What is an efficient method for partitioning and aggregating intervals from timestamped rows in a da

    - by mattrepl
    From a data frame with timestamped rows (strptime results), what is the best method for aggregating statistics for intervals? Intervals could be an hour, a day, etc. I've found the aggregate function, but that doesn't help with assigning each row to an interval. I'm planning on adding a column to the data frame that denotes interval and using that with aggregate, but if there's a better solution it'd be great to hear it. Thanks for any pointers!

    Read the article

  • WPF: "Items collection must be empty before using ItemsSource."

    - by Zack Peterson
    I'm trying to get images to display in a WPF ListView styled like a WrapPanel as described in this old ATC Avalon Team article: How to Create a Custom View. When I try to populate the ListView with a LINQ-to-Entities queried collection of ADO.NET Entity Framework objects I get the following exception: Exception Items collection must be empty before using ItemsSource. My code… Visual Basic Private Sub Window1_Loaded(...) Handles MyBase.Loaded ListViewImages.ItemsSource = From g In db.Graphic _ Order By g.DateAdded Ascending _ Select g End Sub XAML <ListView Name="ListViewImages" SelectionMode="Single" ItemsSource="{Binding}"> <local:ImageView /> </ListView> I put a breakpoint on that line. ListViewImages.ItemsSource is Nothing just before the LINQ assignment.

    Read the article

  • Embed python interpreter in a python application

    - by MatToufoutu
    Hi, i'm looking for a way to ship the python interpreter with my application (also written in python), so that it doesn't need to have python installed on the machine. I searched google and found a bunch of results about how to embed the python interpreter in applications written in various languages, but nothing for applications writtent in python itself... I don't need to "hide" my code or make a binary like cx_freeze does, i just don't want my users to have to install python to use my app, that's all. Thanks.

    Read the article

  • how can we check file types before uploading them in asp.net?

    - by LostLord
    how can we check file types (formats such as jpg) without using file extensions before -uploading them- in asp.net with c# ? i am using vs 2008 + asp.net + c# + TELERIK Controls (RadUpload) ========================================================================================= imagine that some body change the text file extension to jpg and select it in a upload conrol such as radupload ... how can we recognize that this file is truely jpg or not?

    Read the article

  • Linux application that bundles multiple incoming audio and video streams into one container file?

    - by StackedCrooked
    I've been assigned to implement a video on-demand service for a local university. Different aspects of the lectures (video, audio, screen cast, white board) will be recorded. During a lecture all these data streams arrive at one Linux server. This server should transcode and bundle all these streams into one container (Matroska) file. My options seem to be: Write a GStreamer application do something with FFMPEG do something with VLC ...? Has anyone done something similar in the past? Can you recommend something? Edit For those interested, here are a few of my findings: Matroska is not a good format for streaming (it's possible, but it's not its primary intent) For Flash streaming you can use MPEG4 If you want to combine different videos into one video where each subvideo occupies a rectangular portion of the total screen, then this GStreamer script is useful (I found it on this blog post). Desktop capture works fine with VLC

    Read the article

  • Help with replacing Mac factory install of apache with MAMP PRO so FileMaker will work with my other

    - by tannerSF
    I am running Mac 10.4 and have been using MAMP PRO to host several websites I manage. Now that I have installed FileMaker Pro Server, it forces me to turn Web Sharing on in System Preference. So is it possible to either replace Apache with MAMP PRO's version? Or is it possible to get FileMaker Pro to use MAMP instead of Web Sharing? If so, how can I make it happen? Also, with FileMaker Instant Web Publishing, how , how can I make my domain link directly to where FileMaker publishes it? So what I want to be able to do is type http:///mydomain.com and it direct to mydomain.com:591/FMI/IWP/

    Read the article

  • Collectable<T> serialization, Root Namespaces on T in .xml files.

    - by Stacey
    I have a Repository Class with the following method... public T Single<T>(Predicate<T> expression) { using (var list = (Models.Collectable<T>)System.Xml.Serializer.Deserialize(typeof(Models.Collectable<T>), FileName)) { return list.Find(expression); } } Where Collectable is defined.. [Serializable] public class Collectable<T> : List<T>, IDisposable { public Collectable() { } public void Dispose() { } } And an Item that uses it is defined.. [Serializable] [System.Xml.Serialization.XmlRoot("Titles")] public partial class Titles : Collectable<Title> { } The problem is when I call the method, it expects "Collectable" to be the XmlRoot, but the XmlRoot is "Titles" (all of object Title). I have several classes that are collected in .xml files like this, but it seems pointless to rewrite the basic methods for loading each up when the generic accessors do it - but how can I enforce the proper root name for each file without hard coding methods for each one? The [System.Xml.Serialization.XmlRoot] seems to be ignored.

    Read the article

  • Removing a specific XML node in TIBCO BusinessWorks

    - by sangretu
    I have a "global variable" XML schema in TIBCO BusinessWorks. It's simpler than it looks - basically just a single repeatable node. Image: Tibco globals. (old URL redacted) Various processes in the system can update this list. Checking to see if they are listed is easy: $GetVariable/subscriber-list/subscriber = $_processContext/ns:ProcessContext/ProcessId Adding themselves to the list is pretty easy too, using a Set Variable activity (see bottom half of image) But how can a process remove itself from the list? I'm sure there's a type of mapping I can use to filter out the node I want and let the rest through?

    Read the article

  • Python + QT + Gstreamer

    - by Ptterb
    Hi everyone, I'm working with PyQt and trying to get video from a webcam to play within a QT widget. I've found tutorials for C and Qt, and for python and gtk, but NOTHING for this combo of pyQt and gstreamer. Anybody get this working? This plays the video fine, but in a separate window: self.gcam = gst.parse_launch('v4l2src device=/dev/video0 ! autovideosink') self.gcam.set_state(gst.STATE_PLAYING) what I need is to get the overlay working so it's displayed within a widget on my GUI. Thanks, Gurus of the internet! ok, so I've gotten a lot farther, but still in need of some help. I'm actually writing this for Maemo, but the following code works fine on my linux laptop: class Vid: def __init__(self, windowId): self.player = gst.Pipeline("player") self.source = gst.element_factory_make("v4l2src", "vsource") self.sink = gst.element_factory_make("autovideosink", "outsink") self.source.set_property("device", "/dev/video0") self.scaler = gst.element_factory_make("videoscale", "vscale") self.window_id = None self.windowId = windowId self.player.add(self.source, self.scaler, self.sink) gst.element_link_many(self.source,self.scaler, self.sink) bus = self.player.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() bus.connect("message", self.on_message) bus.connect("sync-message::element", self.on_sync_message) def on_message(self, bus, message): t = message.type if t == gst.MESSAGE_EOS: self.player.set_state(gst.STATE_NULL) elif t == gst.MESSAGE_ERROR: err, debug = message.parse_error() print "Error: %s" % err, debug self.player.set_state(gst.STATE_NULL) def on_sync_message(self, bus, message): if message.structure is None: return message_name = message.structure.get_name() if message_name == "prepare-xwindow-id": win_id = self.windowId assert win_id imagesink = message.src imagesink.set_property("force-aspect-ratio", True) imagesink.set_xwindow_id(win_id) def startPrev(self): self.player.set_state(gst.STATE_PLAYING) print "should be playing" vidStream = Vid(wId) vidStream.startPrev() where wId is the window id of the widget im trying to get to display the output in. When I run this on the N900, the screen goes black and blinks. Any ideas? I'm dying here!

    Read the article

  • Effect of suffixes in memory operations

    - by tur1ng
    In x86 GNU Assembler there are different suffixes for memory related operations. E.g.: movb, movs, movw, movl, movq, movt(?) Now my question is the following: Does the suffix has ANY effect on how the processor is getting the data out of main memory or will always be one or more 32-bit (x86) chunks loaded into the cache ? What are the effects beside the memory access?

    Read the article

  • OpenCV to JNI how to make it work?

    - by padfoot-4444
    I am tring to use opencv and java for face detection, and in that pursit i found this "JNI2OPENCV" file....but i am confused on how to make it work, can anyone help me? http://img519.imageshack.us/img519/4803/askaj.jpg and the following is the FaceDetection.java `class JNIOpenCV { static { System.loadLibrary("JNI2OpenCV"); } public native int[] detectFace(int minFaceWidth, int minFaceHeight, String cascade, String filename); } public class FaceDetection { private JNIOpenCV myJNIOpenCV; private FaceDetection myFaceDetection; public FaceDetection() { myJNIOpenCV = new JNIOpenCV(); String filename = "lena.jpg"; String cascade = "haarcascade_frontalface_alt.xml"; int[] detectedFaces = myJNIOpenCV.detectFace(40, 40, cascade, filename); int numFaces = detectedFaces.length / 4; System.out.println("numFaces = " + numFaces); for (int i = 0; i < numFaces; i++) { System.out.println("Face " + i + ": " + detectedFaces[4 * i + 0] + " " + detectedFaces[4 * i + 1] + " " + detectedFaces[4 * i + 2] + " " + detectedFaces[4 * i + 3]); } } public static void main(String args[]) { FaceDetection myFaceDetection = new FaceDetection(); } }` CAn anyone tell me how can i make this work on Netbeans?? I tried Google but help on this particular topic is very meger. I have added the whole folder as Llibrary in netbeans project and whe i try to run the file i get the followig wrroes. Exception in thread "main" java.lang.UnsatisfiedLinkError: FaceDetection.JNIOpenCV.detectFace(IILjava/lang/String;Ljava/lang/String;)[I at FaceDetection.JNIOpenCV.detectFace(Native Method) at FaceDetection.FaceDetection.<init>(FaceDetection.java:19) at FaceDetection.FaceDetection.main(FaceDetection.java:29) Java Result: 1 BUILD SUCCESSFUL (total time: 2 seconds) CAn anyone tell me the exact way to work with this? like what all i have to do?

    Read the article

  • jQuery setInterval loop not holding variable

    - by Ryan
    Here is my code: var showNo = 1; window.setInterval(function() { if(showNo === 1) { var nextNo = 2; } else if(showNo === 2) { var nextNo = 3; } else if(showNo === 3) { var nextNo = 4; } else if(showNo === 4) { var nextNo = 5; } else if(showNo === 5) { var nextNo = 1; } else { var showNo = 1; var nextNo = 2; } var showNo = nextNo; }, 500); My question is, why is the showNo variable not holding when the setInterval loop starts? This may be a simple question, but I am trying to teach myself query and this has me stuck.. Any answers would be great. Thanks.

    Read the article

  • Ruby Design Problem for SQL Bulk Inserter

    - by crunchyt
    This is a Ruby design problem. How can I make a reusable flat file parser that can perform different data scrubbing operations per call, return the emitted results from each scrubbing operation to the caller and perform bulk SQL insertions? Now, before anyone gets narky/concerned, I have written this code already in a very unDRY fashion. Which is why I am asking any Ruby rockstars our there for some assitance. Basically, everytime I want to perform this logic, I create two nested loops, with custom processing in between, buffer each processed line to an array, and output to the DB as a bulk insert when the buffer size limit is reached. Although I have written lots of helpers, the main pattern is being copy pasted everytime. Not very DRY! Here is a Ruby/Pseudo code example of what I am repeating. lines_from_file.each do |line| line.match(/some regex/).each do |sub_str| # Process substring into useful format # EG1: Simple gsub() call # EG2: Custom function call to do complex scrubbing # and matching, emitting results to array # EG3: Loop to match opening/closing/nested brackets # or other delimiters and emit results to array end # Add processed lines to a buffer as SQL insert statement @buffer << PREPARED INSERT STATEMENT # Flush buffer when "buffer size limit reached" or "end of file" if sql_buffer_full || last_line_reached @dbc.insert(SQL INSERTS FROM BUFFER) @buffer = nil end end I am familiar with Proc/Lambda functions. However, because I want to pass two separate procs to the one function, I am not sure how to proceed. I have some idea about how to solve this, but I would really like to see what the real Rubyists suggest? Over to you. Thanks in advance :D

    Read the article

  • Why is IE7 rendering these differently?

    - by htm
    I'm totally baffled as to why these 2 sites are rendering differently in IE7, even though the theme powering both is the same, they're both on WordPress 2.9.2... This one is okay: http://htm2wp.com/dev/svn This one has the sidebar appear at the bottom: svnsvadvisors.com/blog Meanwhile, they render the exact same in Chrome and Firefox. Anyone have any idea why this is happening? I think I may just be too close to the problem to see it.

    Read the article

  • Sharing memory among YACC, Lex, and C files

    - by sczizzo
    I have a YACC (Bison) grammar, a Lex (Flex) tokenizer, and a C program among which I need to share a struct (or really any variable). Currently, I declare the actual object in the grammar file and extern it wherever I need it (which is to say, my C source file), usually using a pointer to manipulate it. I have a shared header (and implementation) file between the C file and the grammar file with functions useful for manipulating my data structure. This works, but it feels a little uncomfortable. Is there a better way to share memory between the grammar and program?

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >