Search Results

Search found 2327 results on 94 pages for 'reverse geocoding'.

Page 81/94 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • How should I implement lazy session creation in PHP?

    - by Adam Franco
    By default, PHP's session handling mechanisms set a session cookie header and store a session even if there is no data in the session. If no data is set in the session then I don't want a Set-Cookie header sent to the client in the response and I don't want an empty session record stored on the server. If data is added to $_SESSION, then the normal behavior should continue. My goal is to implement lazy session creation behavior of the sort that Drupal 7 and Pressflow where no session is stored (or session cookie header sent) unless data is added to the $_SESSION array during application execution. The point of this behavior is to allow reverse proxies such as Varnish to cache and serve anonymous traffic while letting authenticated requests pass through to Apache/PHP. Varnish (or another proxy-server) is configured to pass through any requests without cookies, assuming correctly that if a cookie exists then the request is for a particular client. I have ported the session handling code from Pressflow that uses session_set_save_handler() and overrides the implementation of session_write() to check for data in the $_SESSION array before saving and will write this up as library and add an answer here if this is the best/only route to take. My Question: While I can implement a fully custom session_set_save_handler() system, is there an easier way to get this lazy session creation behavior in a relatively generic way that would be transparent to most applications?

    Read the article

  • In Java, howd do I iterate through lines in a textfile from back to front

    - by rogue780
    Basically I need to take a text file such as : Fred Bernie Henry and be able to read them from the file in the order of Henry Bernie Fred The actual file I'm reading from is 30MB and it would be a less than perfect solution to read the whole file, split it into an array, reverse the array and then go from there. It takes way too long. My specific goal is to find the first occurrence of a string (in this case it's "InitGame") and then return the position beginning of the beginning of that line. I did something like this in python before. My method was to seek to the end of the file - 1024, then read lines until I get to the end, then seek another 1024 from my previous starting point and, by using tell(), I would stop when I got to the previous starting point. So I would read those blocks backwards from the end of the file until I found the text I was looking for. So far, I'm having a heck of a time doing this in Java. Any help would be greatly appreciated and if you live near Baltimore it may even end up with you getting some fresh baked cookies. Thanks!

    Read the article

  • (EXCEL)VBA Spin button which steps through in an sql databases date time

    - by Gulredy
    I have an sql Database table in MySQL which have lots of rows with varied date time values. For example: 2012-08-21 10:10:00 <-- with these date there are around 12 rows 2012-08-21 15:31:00 <-- with these date there are around 5 rows 2012-08-22 11:40:00 <-- with these date there are around 10 rows 2012-08-22 12:17:00 <-- with these date there are around 9 rows 2012-08-22 12:18:00 <-- with these date there are around 7 rows 2012-08-25 07:21:00 <-- with these date there are around 6 rows If the user clicks on the SpinButton1_SpinUp() or SpinButton1_SpinDown() button then it should do the following: The SpinButton1_SpinUp() button should filter out those data from an sql table which is the next after what we are currently on now. Example: We have currently selected: 2012-08-21 15:31:00. The user hits the SpinUp button then the program selects those date from the database, which is the next higher value like this one: 2012-08-22 11:40:00. So the user hits the SpinUp button the data which is selected in the database will change from those with date: 2012-08-21 15:31:00 to those with date: 2012-08-22 11:40:00 The SpinButton1_SpinDown() will do exactly the reverse of the SpinUp button. When the user hits the SpinDown button the data which is selected in the database will change from those with date: 2012-08-21 15:31:00 to those with date 2012-08-21 10:10:00 So I think the date which we are currently on, should be stored in a variable. But on button hit not every bigger or lower data should be selected in the database, only those which are the closest bigger or the closest lower date. How can I do this? I hope I described my problem understandable. My native language is not english, so misunderstandings can occur! Please ask if you don't understand something! Thank you for reading!

    Read the article

  • Cursor image to the center on mouseout

    - by Milla
    Hi all! I'm a real noobie with flash and I was wondering if somebody could help me with this one. I have this actionsript 3 code, where the cursor image "ball_mc" follows the mouse's position with a slight delay: stage.addEventListener(Event.ENTER_FRAME,followBall); function followBall(event:Event):void { var dx:int = ball_mc.x - mouseX; var dy:int = ball_mc.y - mouseY; ball_mc.x -= dx / 5; ball_mc.y -= dy /5; } 1) How can I get the cursor image automatically return to the center of the stage on mouseout? As of now, it stays at the position where the mouse leaves the stage. 2) How can I reverse the movement of the mouse? So that when I, for example, move mouse to the right, the cursor image would move to the left? And when moving the mouse up, the image would go down. The stage is 800 x 250 pixels, in case that makes any difference.

    Read the article

  • Extracting email addresses in an html block in ruby/rails

    - by corroded
    I am creating a parser that wards off against spamming and harvesting of emails from a block of text that comes from tinyMCE (so it may or may not have html tags in it) I've tried regexes and so far this has been successful: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i problem is, i need to ignore all email addresses with mailto hrefs. for example: <a href="mailto:[email protected]">[email protected]</a> should only return the second email add. To get a background of what im doing, im reversing the email addresses in a block so the above example would look like this: <a href="mailto:[email protected]">moc.liam@tset</a> problem with my current regex is that it also replaces the one in href. Is there a way for me to do this with a single regex? Or do i have to check for one then the other? Is there a way for me to do this just by using gsub or do I have to use some nokogiri/hpricot magicks and whatnot to parse the mailtos? Thanks in advance! Here were my references btw: so.com/questions/504860/extract-email-addresses-from-a-block-of-text so.com/questions/1376149/regexp-for-extracting-a-mailto-address im also testing using this: http://rubular.com/ edit here's my current helper code: def email_obfuscator(text) text.gsub(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i) { |m| m = "<span class='anti-spam'>#{m.reverse}</span>" } end which results in this: <a target="_self" href="mailto:<span class='anti-spam'>moc.liamg@tset</span>"><span class="anti-spam">moc.liamg@tset</span></a>

    Read the article

  • correcting fisheye distortion programmatically

    - by Will
    I have some points that describe positions in a picture taken with a fisheye lens. I've found this description of how to generate a fisheye effect, but not how to reverse it. How do you calculate the radial distance from the centre to go from fisheye to rectilinear? My function stub looks like this: Point correct_fisheye(const Point& p,const Size& img) { // to polar const Point centre = {img.width/2,img.height/2}; const Point rel = {p.x-centre.x,p.y-centre.y}; const double theta = atan2(rel.y,rel.x); double R = sqrt((rel.x*rel.x)+(rel.y*rel.y)); // fisheye undistortion in here please //... change R ... // back to rectangular const Point ret = Point(centre.x+R*cos(theta),centre.y+R*sin(theta)); fprintf(stderr,"(%d,%d) in (%d,%d) = %f,%f = (%d,%d)\n",p.x,p.y,img.width,img.height,theta,R,ret.x,ret.y); return ret; } Alternatively, I could somehow convert the image from fisheye to rectilinear before finding the points, but I'm completely befuddled by the OpenCV documentation. Is there a straightforward way to do it in OpenCV, and does it perform well enough to do it to a live video feed?

    Read the article

  • Help with animating an element in jQuery

    - by alex
    I have an unordered list with a few list elements. #tags { width: 300px; height: 300px; position: relative; border: 1px solid red; list-style: none none; } #tags li { position: absolute; background: gray; } I have also started writing a jQuery plugin to animate the list elements. So far, I place the list elements randomly in the parent container, and choose a random font size for the text. My next step (which I am a bit stuck on) is to animate the list elements... essentially, I want the list elements to do something like this Slide from left to right whilst getting slightly larger up to the middle and then dropping in size back to normal when it hits the right border. Then, it should do the same in reverse, however it should also set a negative 'z-index' and maybe fade in opacity a bit. The first bit I'm really stuck on, is how to determine if the element is near the middle, in a way that I can have a value that starts at 0.1 on the far left hand size and is 1 in the middle and then back to 0.1 on the far right hand size. Basically, I want them to appear as if they are going around in a faux 3D circle into the page. Then I could do something like this $(this).css({ fontSize: percentageTowardsMiddle * 14, }); Do you know how I could do this? Thanks

    Read the article

  • Squid handling of concurrent cache misses

    - by Oliver H-H
    We're using a Squid cache to off-load traffic from our web servers, ie. it's setup as a reverse-proxy responding to inbound requests before they hit our web servers. When we get blitzed with concurrent requests for the same request that's not in the cache, Squid proxies all the requests through to our web ("origin") servers. For us, this behavior isn't ideal: our origin servers gets bogged down trying to fulfill N identical requests concurrently. Instead, we'd like the first request to proxy through to the origin server, the rest of the requests to queue at the Squid layer, and then all be fulfilled by Squid when the origin server has responded to that first request. Does anyone know how to configure Squid to do this? We've read through the documentation multiple times and thoroughly web-searched the topic, but can't figure out how to do it. We use Akamai too and, interestingly, this is its default behavior. (However, Akamai has so many nodes that we still see lots of concurrent requests in certain traffic spike scenarios, even with Akamai's super-node feature enabled.) This behavior is clearly configurable for some other caches, eg. the Ehcache documentation offers the option "Concurrent Cache Misses: A cache miss will cause the filter chain, upstream of the caching filter to be processed. To avoid threads requesting the same key to do useless duplicate work, these threads block behind the first thread." Some folks call this behavior a "blocking cache," since the subsequent concurrent requests block behind the first request until it's fulfilled or timed-out. Thx for looking over my noob question! Oliver

    Read the article

  • Is there a library that can decompile a method into an Expression tree, with support for CLR 4.0?

    - by Daniel Earwicker
    Previous questions have asked if it is possible to turn compiled delegates into expression trees, for example: http://stackoverflow.com/questions/767733/converting-a-net-funct-to-a-net-expressionfunct The sane answers at the time were: It's possible, but very hard and there's no standard library solution. Use Reflector! But fortunately there are some greatly-insane/insanely-great people out there who like reverse engineering things, and they make difficult things easy for the rest of us. Clearly it is possible to decompile IL to C#, as Reflector does it, and so you could in principle instead target CLR 4.0 expression trees with support for all statement types. This is interesting because it wouldn't matter if the compiler's built-in special support for Expression<> lambdas is never extended to support building statement expression trees in the compiler. A library solution could fill the gap. We would then have a high-level starting point for writing aspect-like manipulations of code without having to mess with raw IL. As noted in the answers to the above linked question, there are some promising signs but I haven't succeeded in finding if there's been much progress since by searching. So has anyone finished this job, or got very far with it? Note: CLR 4.0 is now released. Time for another look-see.

    Read the article

  • Is there a disassembler + debugger for java (ala OllyDbg / SoftICE for assembler)?

    - by Ran Biron
    Is there a utility similar to OllyDbg / SoftICE for java? I.e. execute class (from jar / with class path) and, without source code, show the disassembly of the intermediate code with ability to step through / step over / search for references / edit specific intermediate code in memory / apply edit to file... If not, is it even possible to write something like this (assuming we're willing to live without hotspot for the debug duration)? Edit: I'm not talking about JAD or JD or Cavaj. These are fine decompilers, but I don't want a decompiler for several reasons, most notable is that their output is incorrect (at best, sometimes just plain wrong). I'm not looking for a magical "compiled bytes to java code" - I want to see the actual bytes that are about to be executed. Also, I'd like the ability to change those bytes (just like in an assembly debugger) and, hopefully, write the changed part back to the class file. Edit2: I know javap exists - but it does only one way (and without any sort of analysis). Example (code taken from the vmspec documentation): From java code, we use "javac" to compile this: void setIt(int value) { i = value; } int getIt() { return i; } to a java .class file. Using javap -c I can get this output: Method void setIt(int) 0 aload_0 1 iload_1 2 putfield #4 5 return Method int getIt() 0 aload_0 1 getfield #4 4 ireturn This is OK for the disassembly part (not really good without analysis - "field #4 is Example.i"), but I can't find the two other "tools": A debugger that goes over the instructions themselves (with stack, memory dumps, etc), allowing me to examine the actual code and environment. A way to reverse the process - edit the disassembled code and recreate the .class file (with the edited code).

    Read the article

  • How do attribute classes work?

    - by AaronLS
    My searches keep turning up only guides explaining how to use and apply attributes to a class. I want to learn how to create my own attribute classes and the mechanics of how they work. How are attribute classes instantiated? Are they instantiated when the class they are applied to is instantiated? Is one instantiated for each class instantiated that it is applied to? E.g. if I apply the SerializableAttribute class to a MyData class, and I instantiate 5 MyData instances, will there be 5 instances of the SerializbleAttribute class created behind the scenes? Or is there just one instance shared between all of them? How do attribute class instances access the class they are associated with? How does a SerializableAttribute class access the class it is applied to so that it can serialize it's data? Does it have some sort of SerializableAttribute.ThisIsTheInstanceIAmAppliedTo property? :) Or does it work in the reverse direction that whenever I serialize something, the Serialize function I pass the MyClass instance to will reflectively go through the Attributes and find the SerialiableAttribute instance?

    Read the article

  • DAL Layer : EF 4.0 or Normal Data access layer with Stored Procedure

    - by Harryboy
    Hello Experts, Application : I am working on one mid-large size application which will be used as a product, we need to decide on our DAL layer. Application UI is in Silverlight and DAL layer is going to be behind service layer. We are also moving ahead with domain model, so our DB tables and domain classes are not having same structure. So patterns like Data Mapper and Repository will definitely come into picture. I need to design DAL Layer considering below mentioned factors in priority manner Speed of Development with above average performance Maintenance Future support and stability of the technology Performance Limitation : 1) As we need to strictly go ahead with microsoft, we can not use NHibernate or any other ORM except EF 4.0 2) We can use any code generation tool (Should be Open source or very cheap) but it should only generate code in .Net, so there would not be any licensing issue on per copy basis. Questions I read so many articles about EF 4.0, on outset it looks like that it is still lacking in features from NHibernate but it is considerably better then EF 1.0 So, Do you people feel that we should go ahead with EF 4.0 or we should stick to ADO .Net and use any code geneartion tool like code smith or any other you feel best Also i need to answer questions like what time it will take to port application from EF 4.0 to ADO .Net if in future we stuck up with EF 4.0 for some features or we are having serious performance issue. In reverse case if we go ahead and choose ADO .Net then what time it will take to swith to EF 4.0 Lastly..as i was going through the article i found the code only approach (with POCO classes) seems to be best suited for our requirement as switching is really easy from one technology to other. Please share your thoughts on the same and please guide on the above questions

    Read the article

  • randomized quicksort: probability of two elements comparison?

    - by bantu
    I am reading "Probability and Computing" by M.Mitzenmacher, E.Upfal and I have problems understanding how the probability of comparison of two elements is calculated. Input: the list (y1,y2,...,YN) of numbers. We are looking for pivot element. Question: what is probability that two elements yi and yj (ji) will be compared? Answer (from book): yi and yj will be compared if either yi or yj will be selected as pivot in first draw from sequence (yi,yi+1,...,yj-1,yj). So the probablity is: 2/(y-i+1). The problem for me is initial claim: for example, picking up yi in the first draw from the whole list will cause the comparison with yj (and vice-versa) and the probability is 2/n. So, rather the "reverse" claim is true -- none of the (yi+1,...,yj-1) elements can be selected beforeyi or yj, but the "pool" size is not fixed (in first draw it is n for sure, but on the second it is smaller). Could someone please explain this, how the authors come up with such simplified conclusion? Thank you in advance

    Read the article

  • Ajax UpdatePanels scroll on partial page update.

    - by George
    I set the AutoPostback property of a textbox to True so I can process the TextChanged event on the server and, based on what they typed in the textbox, appropriately display a message in an update panel. The problem is, when the partial screen refresh is performed, no control on the screen has focus. 99% of the time, when the text in the textbox is changed, it is because the user has tabbed forward, and so, to limit the disruption in the lost of focus, I perform a "Focus" call on teh next control in the tab sequence. For the most part, this works OK, but of course, is disputive if the user is tabbing in the reverse order or has used the mouse to set the focus to another control. In these situations, the focus would be set to the next control even though the user was trying to set focus elsewhere. OK, that sucks. Now what I consider the bigger problem with calling the focus method on the server: In IE, it works OK, but in Mozilla Firefox and Chrome, setting the focus causes a repositioning of the scroll bar, even though none is necessary because the control is already in view. I realize that I could switch to doing AJAX web service calls, but these darn Updae Panels are so convenient if used in moderation. is there anyway to use updatepanels and not have these focus/scroll issues?

    Read the article

  • WPF DockPanel doesn't respect the "Filled" control's desired size

    - by Dan Puzey
    I have the following Xaml (simplified for brevity, but will repro the problem in Xamlpad or Kaxaml): <DockPanel Width="400"> <TextBlock DockPanel.Dock="Left" TextWrapping="Wrap"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum massa metus, ornare in fringilla nec, fringilla at orci. Nunc pharetra enim sit amet sapien aliquet eu euismod turpis vehicula. Aenean gravida tempus lectus ut ornare. Nullam massa augue, suscipit vel consectetur fringilla, pretium vitae neque. </TextBlock> <Button MinWidth="100" VerticalAlignment="Center" HorizontalAlignment="Left">Hello world</Button> </DockPanel> My problem is that I want the Button to take its minimum 100px of space, and for the text to wrap suitably to leave that space. However, what happens is that the text wraps as close to 400px as possible, and then the Button is clipped. If I Snoop the output I can see that the button is rendering at the desired 100px, but it's being clipped off the side of the DockPanel. If I reverse the Dock (so the button is docked "Right" and the TextBlock fills) then I get the layout I want, but unfortunately that's not an option due to the surrounding layout. Is there something I can do that will make the DockPanel a) not clip and b) layout in a way that respects the MinWidth? Or am I stuck finding an alternative layout mechanism? Thanks in advance!

    Read the article

  • Python OOP and lists

    - by Mikk
    Hi, I'm new to Python and it's OOP stuff and can't get it to work. Here's my code: class Tree: root = None; data = []; def __init__(self, equation): self.root = equation; def appendLeft(self, data): self.data.insert(0, data); def appendRight(self, data): self.data.append(data); def calculateLeft(self): result = []; for item in (self.getLeft()): if (type(item) == type(self)): data = item.calculateLeft(); else: data = item; result.append(item); return result; def getLeft(self): return self.data; def getRight(self): data = self.data; data.reverse(); return data; tree2 = Tree("*"); tree2.appendRight(44); tree2.appendLeft(20); tree = Tree("+"); tree.appendRight(4); tree.appendLeft(10); tree.appendLeft(tree2); print(tree.calculateLeft()); It looks like tree2 and tree are sharing list "data"? At the moment I'd like it to output something like [[20,44], 10, 4], but when I tree.appendLeft(tree2) I get RuntimeError: maximum recursion depth exceeded, and when i even won't appendLeft(tree2) it outputs [10, 20, 44, 4] (!!!). What am I missing here? I'm using Portable Python 3.0.1. Thank you

    Read the article

  • How can I get the mapi system stub dll to pass extended mapi calls to my dll?

    - by Bogatyr
    For various reasons (questioning the reasons is not helpful to me), I'd like to implement my own extended mapi dll for windows xp. I have a skeleton dll now, just a few entrypoints exist for testing, but the system mapi stub (c:\windows\system32\mapi32.dll, I've checked that it's identical to mapistub.dll) will not pass through calls to my dll, while it happily passes the same calls through to MS Outlook's msmapi32.dll, (MAPIInitialize, MAPILoginEx are two such calls). There's some secret handshake between the stub and the extended mapi dll wherein the stub checks that "yup, it's an extended mapi dll": maybe it's the presence of some additional entrypoints I haven't implemented yet, maybe it's the return value from some function, I don't know. I've tried tracing a sample app I wrote that calls MAPIInitialize with STraceNT and ProcessMonitor but that didn't show anything obvious. Tracing has shown that indeed the stub loads my dll, but then finds the secret sauce is missing apparently, and returns an error code instead of calling my dll's function. What more could be needed for calling MAPIInitialize than the presence of MAPIInitialize in my dll's exports table? GetProcAddress says it's there. What I'd like to know is how to minimally extend my skeleton extended mapi dll so that the stub mapi dll will pass through extended mapi calls to my dll. What's the secret sauce? I'd rather not spend a painful week in msvc reverse engineering the stub behavior.

    Read the article

  • jQuery loading issues within wordpress

    - by Chase
    I am having a couple problems trying to manually insert some jQuery features into a wordpress theme. I have a lightbox wordpress plugin that is jQuery based that is working fine. So if I manually load the jQuery script into wordpress the functions seem to work but instead of say a slide being hidden it is revealed when it should still be hidden. Or a pop up that should work is already being shown instead of hidden. I don't think I'm supposed to manually include the jQuery into my skin but using the wp_enqueue_script('jquery'); doesn't seem to be resolving my issues either. <script src="http://platform.twitter.com/anywhere.js?id=i5CnpkmwnlWpDdAZGVpxw&v=1" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $(".btn-slide").click(function(){ $("#twitpanel").slideToggle("slow"); $(this).toggleClass("active"); }); }); </script> <div id="tweetit"><a class="btn-slide">Tell em'</a> <div id="twitpanel"></div> <script type="text/javascript"> twttr.anywhere(function (T) { T("#twitpanel").tweetBox({ height: 100, width: 225, defaultContent: "Some Random Text" }); }); </script> </div></h2> Like I said it works but in the reverse fashion that it should be. I think I'm just loading in something wrong? TIA, Chase

    Read the article

  • Retrieve a list of the most popular GET param variations for a given URL?

    - by jamtoday
    I'm working on building intelligence around link propagation, and because I need to deal with many short URL services where a reverse-lookup from an exact URL address is required, I need to be able to resolve multiple approximate versions of the same URL. An example would be a URL like http://www.example.com?ref=affil&hl=en&ct=0 Of course, changing GET params in certain circumstances can refer to a completely different page, especially if the GET params in question refer to a profile or content ID. But a quick parse of the page would quickly determine how similar the pages were to each other. Using a bit of machine learning, it could quickly become clear which GET params don't effect the content of the pages returned for a given site. I'm assuming a service to send a URL and get a list of very similar URLs could only be offered by the likes of Google or Yahoo (or Twitter), but they don't seem to offer this feature, and I haven't found any other services that do. If you know of any services that do cluster together groups of almost identical URLs in the aforementioned way, please let me know. My bounty is a hug.

    Read the article

  • Vim + OmniCppComplete and completing members of class members

    - by Robert S. Barnes
    I've noticed that I can't seem to complete members of class members using OmniCppComplete. For example, given the following files: // foo.h #include <string> class foo { public: void set_str(const std::string &); std::string get_str_reverse( void ); private: std::string str; }; // foo.cpp #include "foo.h" using std::string; string foo::get_str_reverse ( void ) { string temp; temp.assign(str); reverse(temp.begin(), temp.end()); return temp; } /* ----- end of method foo::get_str ----- */ void foo::set_str ( const string &s ) { str.assign(s); } /* ----- end of method foo::set_str ----- */ I've set up tags for stdlibc++ and generated the tags for these two files using: ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q . When I type temp. in the cpp I get a list of string member functions as expected. But if I type str. omnicomplete spits out "Pattern Not Found". I've noticed that the temp. completion only works if I have the using std::string; declaration. How do I get completion to work on my class members?

    Read the article

  • Django apache-wsgi configuration problem

    - by omat
    Hi, I am trying to get my Django project running on the production server. I setup the environment using pip, so it is identical to the development environment where everything is running fine. The only difference is that I don't use virtualenv on production, because this project is the only one that is going to run on production. Also on production, there is an Nginx reverse proxy to serve static content, and passes dynamic requests to Apache2. The Apache wsgi file is as follows: import sys, os sys.path.append('/home/project/src') os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() When I access the server, I get an import error: ImproperlyConfigured: Error importing middleware middleware: "cannot import name UserProfile" Which refers to the middleware.py under src/ folder which is referred by the settings. But I can import both the middleware and the UserProfile class from within ./manage.py shell prompt. It seems like a problem with paths in wsgi file but I cannot see what. The directory structure is: /home/project /home/project/src (which contains the settings.py, middleware.py and app folders) /home/apache/apache.wsgi Any help is greatly appreciated. Thanks, oMat

    Read the article

  • Trouble adding video controls to video selected by XML comboBox

    - by user560128
    Hello, it's been a few years since I've touched flash, so perhaps I'm just overlooking something. If anyone could look at the code and offer any suggestions that would be awesome. What's working, I select a video from a combobox that is populated from an XML file, pick the video and it plays. I've been trying to add pause/play, stop, forward and reverse functionality, once I get that to work I also want to add a video scrubber(slider), and previous/next buttons to go to the previous/next video as listed in the xml file. At the moment I have a component button on the stage called playButton, which I'm trying to use for pause/play functionality. Below is my code, the player control is at the very bottom. Thanks. import fl.data.DataProvider; var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); var videosXML:XML = new XML(); var loader:URLLoader = new URLLoader(); var request:URLRequest= new URLRequest("xml/videos.xml"); var videos:Array = new Array({label:"Select a Video",data:""}); var client:Object = new Object(); theVideo.attachNetStream(ns); ns.client = client; loader.addEventListener(Event.COMPLETE,loaderOnComplete); loader.load (request); function loaderOnComplete(event:Event):void{ videosXML = new XML(event.target.data); for each (var video:XML in videosXML.video){ videos.push({label:video.name.toString(),data:video.url.toString()}); } moviesCB.dataProvider = new DataProvider(videos); } moviesCB.addEventListener(Event.CHANGE, changeHandler); function changeHandler(event:Event):void { if(ComboBox(event.target).selectedItem.data != ""){ ns.play(ComboBox(event.target).selectedItem.data); } }; client.onMetaData = metadataHandler; function metadataHandler(md:Object):void{ } //player controls playButton.onRelease = function() { ns.pause(); }

    Read the article

  • Django Testing: Faking User Creation

    - by Ygam
    I want to better write this test: def test_profile_created(self): self.client.post(reverse('registration_register'), data={ 'username':'ygam', 'email':'[email protected]', 'password1':'ygam', 'password2':'ygam' }) """ Test if a profile is created on save """ user = User.objects.get(username='ygam') self.assertTrue(UserProfile.objects.filter(user=user).exists()) and I just came upon this code on django-registration tests that does not actually "create" the user: def test_registration_signal(self): def receiver(sender, **kwargs): self.failUnless('user' in kwargs) self.assertEqual(kwargs['user'].username, 'bob') self.failUnless('request' in kwargs) self.failUnless(isinstance(kwargs['request'], WSGIRequest)) received_signals.append(kwargs.get('signal')) received_signals = [] signals.user_registered.connect(receiver, sender=self.backend.__class__) self.backend.register(_mock_request(), username='bob', email='[email protected]', password1='secret') self.assertEqual(len(received_signals), 1) self.assertEqual(received_signals, [signals.user_registered]) However he used a custom function for this "_mock_request": class _MockRequestClient(Client): def request(self, **request): environ = { 'HTTP_COOKIE': self.cookies, 'PATH_INFO': '/', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': '', 'SERVER_NAME': 'testserver', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1', 'wsgi.version': (1,0), 'wsgi.url_scheme': 'http', 'wsgi.errors': self.errors, 'wsgi.multiprocess':True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.input': None, } environ.update(self.defaults) environ.update(request) request = WSGIRequest(environ) # We have to manually add a session since we'll be bypassing # the middleware chain. session_middleware = SessionMiddleware() session_middleware.process_request(request) return request def _mock_request(): return _MockRequestClient().request() However, it may be too long of a function for my needs. I want to be able to somehow "fake" the account creation. I have not much experience on mocks and stubs so any help would do. Thanks!

    Read the article

  • order of onclick events

    - by NicoF
    I want to add a jquery click event to href's that already have an onclick event. In the example below the hard coded onclick event will get triggered first. How can I reverse that? <a class="whatever clickyGoal1" href="#" onclick="alert('trial game');">play trial</a> <br /> <a class="whatever clickyGoal2" href="#" onclick="alert('real game');">real trial</a> <p class="goal1"> </p> <p class="goal2"> </p> <script type="text/javascript"> $("a.clickyGoal1").click(function() { $("p.goal1").append("trial button click goal is fired");//example }); $("a.clickyGoal2").click(function() { $("p.goal2").append("real button click goal is fired"); //example }); </script>

    Read the article

  • To have efficient many-to-many relation in Java

    - by Masi
    How can you make the efficient many-to-many -relation from fileID to Words and from word to fileIDs without database -tools like Postgres in Java? I have the following classes. The relation from fileID to words is cheap, but not the reverse, since I need three for -loops for it. My solution is not apparently efficient. Other options may be to create an extra class that have word as an ID with the ArrayList of fileIDs. Reply to JacobM's answer The relevant part of MyFile's constructors is: /** * Synopsis of data in wordToWordConutInFile.txt: * fileID|wordID|wordCount * * Synopsis of the data in the file wordToWordID.txt: * word|wordID **/ /** * Getting words by getting first wordIDs from wordToWordCountInFile.txt and then words in wordToWordID.txt. */ InputStream in2 = new FileInputStream("/home/dev/wordToWordCountInFile.txt"); BufferedReader fi2 = new BufferedReader(new InputStreamReader(in2)); ArrayList<Integer> wordIDs = new ArrayList<Integer>(); String line = null; while ((line = fi2.readLine()) != null) { if ((new Integer(line.split("|")[0]) == currentFileID)) { wordIDs.add(new Integer(line.split("|")[6])); } } in2.close(); // Getting now the words by wordIDs. InputStream in3 = new FileInputStream("/home/dev/wordToWordID.txt"); BufferedReader fi3 = new BufferedReader(new InputStreamReader(in3)); line = null; while ((line = fi3.readLine()) != null) { for (Integer wordID : wordIDs) { if (wordID == (new Integer(line.split("|")[1]))) { this.words.add(new Word(new String(line.split("|")[0]), fileID)); break; } } } in3.close(); this.words.addAll(words); The constructor of Word is at the paste.

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >