Search Results

Search found 1501 results on 61 pages for 'adam fraser'.

Page 9/61 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Is there a way to make PHP progressively output as the script executes?

    - by Iain Fraser
    So I'm writing a disposable script for my own personal single use and I want to be able see how the process is going. Basically I'm processing a couple of thousand media releases and sending them to our new CMS. So I don't hammer the CMS, I'm making the script sleep for a couple of seconds after every 5 requests. I would like - as the script is executing - to be able to see my echos telling me the script is going to sleep or that the last transaction with the webservice was successful. Is this possible in PHP? Thanks for your help! Iain

    Read the article

  • Optimizing multiple dispatch notification algorithm in C#?

    - by Robert Fraser
    Sorry about the title, I couldn't think of a better way to describe the problem. Basically, I'm trying to implement a collision system in a game. I want to be able to register a "collision handler" that handles any collision of two objects (given in either order) that can be cast to particular types. So if Player : Ship : Entity and Laser : Particle : Entity, and handlers for (Ship, Particle) and (Laser, Entity) are registered than for a collision of (Laser, Player), both handlers should be notified, with the arguments in the correct order, and a collision of (Laser, Laser) should notify only the second handler. A code snippet says a thousand words, so here's what I'm doing right now (naieve method): public IObservable<Collision<T1, T2>> onCollisionsOf<T1, T2>() where T1 : Entity where T2 : Entity { Type t1 = typeof(T1); Type t2 = typeof(T2); Subject<Collision<T1, T2>> obs = new Subject<Collision<T1, T2>>(); _onCollisionInternal += delegate(Entity obj1, Entity obj2) { if (t1.IsAssignableFrom(obj1.GetType()) && t2.IsAssignableFrom(obj2.GetType())) obs.OnNext(new Collision<T1, T2>((T1) obj1, (T2) obj2)); else if (t1.IsAssignableFrom(obj2.GetType()) && t2.IsAssignableFrom(obj1.GetType())) obs.OnNext(new Collision<T1, T2>((T1) obj2, (T2) obj1)); }; return obs; } However, this method is quite slow (measurable; I lost ~2 FPS after implementing this), so I'm looking for a way to shave a couple cycles/allocation off this. I thought about (as in, spent an hour implementing then slammed my head against a wall for being such an idiot) a method that put the types in an order based on their hash code, then put them into a dictionary, with each entry being a linked list of handlers for pairs of that type with a boolean indication whether the handler wanted the order of arguments reversed. Unfortunately, this doesn't work for derived types, since if a derived type is passed in, it won't notify a subscriber for the base type. Can anyone think of a way better than checking every type pair (twice) to see if it matches? Thanks, Robert

    Read the article

  • Do I need to use http redirect code 302 or 307?

    - by Iain Fraser
    I am working on a CMS that uses a search facility to output a list of content items. You can use this facility as a search engine, but in this instance I am using it to output the current month's Media Releases from an archive of all Media Releases. The default parameters for these "Data Lists" as they are called, don't allow you to specify "current month" or "current year" for publication date - only "last x days" or "from dateA to dateB". The search facility will accept querystring parameters though, so I intend to code around it like this: Page loads How many days into the current month are we? Do we have a query string that asks for a list including this many days? If no, redirect the client back to this page with the appropriate query-string included. If yes, allow the CMS to process the query Now here's the rub. Suppose the spider from your favourite search engine comes along and tries to index your main Media Releases page. If you were to use a 301 redirect to the default query page, the spider would assume the main page was defunct and choose to add the query page to its index instead of the main page. Now I see that 302 and 307 indicate that a page has been moved temporarily; if I do this, are spiders likely to pop the main page into their index like I want them to? Thanks very much in advance for your help and advice. Kind regards Iain

    Read the article

  • PostgreSQL: Auto-partition a table

    - by Adam Matan
    Hi, I have a huge database which holds pairs of numbers (A,B), each ranging from 0 to 10,000 and stored as floats. e.g., (1, 9984.4), (2143.44, 124.243), (0.55, 0), ... Since the PostgreSQL table which stores these pairs grew quite large, I have decided to partition it into inheriting sub-tables. I intend to create 100 such tables, each storing a range of 1000x1000. The problem is that these numbers tend to come in large chunks of nearby numbers. It means that in the future, some tables will be nearly empty and some will hold a very large portion of the database. Unfortunately, the distribution of future pairs is yet unknown. I am looking for a way to automatically repartition my table. That means that if a certain subtable holds more than a specific number of pairs, it will be automatically partitioned into four sub-sub tables, and so on. My questions are: Is recursive partitioning and inheritance possible in PostgreSQL 8.3? Will indexes and query plans understand it? What's the best way to split a subtable once it grew too large? I should point out that this isn't a live database, so a downtime of few hours every week is totally acceptable. Thanks in advance, Adam

    Read the article

  • Codility-like sites for code golfs

    - by Adam Matan
    Hi, I've run into codility.com new cool service after listening to one of the recent stackoverflow.com podcasts. In short, it presents the user with a programming riddle to solve, within a given time frame. The user writes code in an online editor, and has the ability to run the program and view the standard output. After final submission, the user sees its final score and which tests failed him. Quoting Joel Spolsky: You are given a programming problem, you can do it in Java, C++, C#, C, Pascal, Python and PHP, which is pretty cool, and you have 30 minutes. And it gives you an editor in a webpage. And you've got to just start typing your code. And it's going to time you, basically you have to do it in a certain amount of time. And it actually runs your code and determines the performance characteristics of your code. It is intended for job interview screenings, but the idea seems very cool for code-golfs and for practicing new languages. Do you know if there's any proper open replacement? Adam

    Read the article

  • Wrappers/law of demeter seems to be an anti-pattern...

    - by Robert Fraser
    I've been reading up on this "Law of Demeter" thing, and it (and pure "wrapper" classes in general) seem to generally be anti patterns. Consider an implementation class: class Foo { void doSomething() { /* whatever */ } } Now consider two different implementations of another class: class Bar1 { private static Foo _foo = new Foo(); public static Foo getFoo() { return _foo; } } class Bar2 { private static Foo _foo = new Foo(); public static void doSomething() { _foo.doSomething(); } } And the ways to call said methods: callingMethod() { Bar1.getFoo().doSomething(); // Version 1 Bar2.doSomething(); // Version 2 } At first blush, version 1 seems a bit simpler, and follows the "rule of Demeter", hide Foo's implementation, etc, etc. But this ties any changes in Foo to Bar. For example, if a parameter is added to doSomething, then we have: class Foo { void doSomething(int x) { /* whatever */ } } class Bar1 { private static Foo _foo = new Foo(); public static Foo getFoo() { return _foo; } } class Bar2 { private static Foo _foo = new Foo(); public static void doSomething(int x) { _foo.doSomething(x); } } callingMethod() { Bar1.getFoo().doSomething(5); // Version 1 Bar2.doSomething(5); // Version 2 } In both versions, Foo and callingMethod need to be changed, but in Version 2, Bar also needs to be changed. Can someone explain the advantage of having a wrapper/facade (with the exception of adapters or wrapping an external API or exposing an internal one).

    Read the article

  • Use of @keyword in C# -- bad idea?

    - by Robert Fraser
    In my naming convention, I use _name for private member variables. I noticed that if I auto-generate a constructor with ReSharper, if the member is a keyword, it will generate an escaped keyword. For example: class IntrinsicFunctionCall { private Parameter[] _params; public IntrinsicFunctionCall(Parameter[] @params) { _params = @params; } } Is this generally considered bad practice or is it OK? It happens quite frequently with @params and @interface.

    Read the article

  • $.jQTouch.goTo is not a function Options

    - by Max Fraser
    I am trying to use the goTo function to rotate between images, here is my basic JS: <script type="text/javascript" charset="utf-8"> $.jQTouch(); $(function () { $('.touch').live('swipe', function (event, info) { alert('called' + info.direction); var id = $(this).parent().next().attr("id"); alert(id); $.jQTouch.goTo(id, 'slide'); }); }); </script> This works great up until I get to the $.jQTouch.goTo(id, 'slide'); line and then I get the following error: $.jQTouch.goTo is not a function How do I access this goTo function?

    Read the article

  • How to make strtotime parse dates in Australian (i.e. UK) format: dd/mm/yyyy?

    - by Iain Fraser
    I can't beleive I've never come across this one before. Basically, I'm parsing the text in human-created text documents and one of the fields I need to parse is a date and time. Because I'm in Australia, dates are formatted like dd/mm/yyyy but strtotime only wants to parse it as a US formatted date. Also, exploding by / isn't going to work because, as I mentioned, these documents are hand-typed and some of them take the form of d M yy. I've tried multiple combinations of setlocale but no matter what I try, the language is always set to US English. I'm fairly sure setlocale is the key here, but I don't seem to be able to strike upon the right code. Tried these: au au-en en_AU australia aus Anything else I can try? Thanks so much :) Iain Example: $mydatetime = strtotime("9/02/10 2.00PM"); echo date('j F Y H:i', $mydatetime); Produces 2 September 2010 14:00 I want it to produce: 9 February 2010 14:00

    Read the article

  • Embed resource in .NET Assembly without assembly prefix?

    - by Robert Fraser
    Hi all, When you embed a reosurce into a .NET assembly using Visual Studio, it is prefixed with the assembly name. However, assemblies can have embedded resources that are not assembly-name-prefixed. The only way I can see to do this is to disassemble the assembly using ildasm, then re-assemble it, adding the new resource -- which works, but... do I really need to finish that sentence? (Desktop .NET Framework 3.5, VS 2008 SP1, C#, Win7 Enterprise x64) Thanks, All the best, Robert

    Read the article

  • Show cue banner for wpf ComboBox with grouping

    - by Adam Duston
    I have a ComboBox in my WPF form: <ComboBox Margin="75,0,15,102" Name="videoFormatCombo" Height="23" VerticalAlignment="Bottom" DataContext="{StaticResource GroupedVideoFormats}" ItemsSource="{Binding}" ItemTemplate="{StaticResource VideoFormatTemplate}"> <ComboBox.GroupStyle> <GroupStyle HeaderTemplate="{StaticResource GroupHeader}"/> </ComboBox.GroupStyle> </ComboBox> As you might be able to guess, GroupedVideoFormats is a CollectionViewSource with grouping. I need to get a cue banner to display for this ComboBox. I've attempted the solution that is (very verbosely) outlined in this blog post, but it will not work for a ComboBox with grouped data. The two solutions outlined in superfluousprefixhttp://stackoverflow.com/questions/2548757/how-can-the-blank-space-in-a-c-combobox-be-filled-as-a-hint-for-the-user are for Windows Forms ComboBoxes only, and won't work with WPF. If it would help to see all the original source, this particular form is on github: superfluousprefixhttp://github.com/8planes/mirovideoconverter/blob/master/MSWindows/Windows/FileSelect.xaml . It's an open-source project, so the entire project is on github: superfluousprefixhttp://github.com/8planes/mirovideoconverter/tree/master/MSWindows . Thank you for any advice! Adam P.S. stackoverflow wouldn't let me make more than one anchor tag in my post, hence the long urls with the superfluous prefix. Sorry!

    Read the article

  • How can I plot NaN values as a special color with imshow in matplotlib?

    - by Adam Fraser
    example: import numpy as np import matplotlib.pyplot as plt f = plt.figure() ax = f.add_subplot(111) a = np.arange(25).reshape((5,5)).astype(float) a[3,:] = np.nan ax.imshow(a, interpolation='nearest') f.canvas.draw() The resultant image is unexpectedly all blue (the lowest color in the jet colormap). However, if I do the plotting like this: ax.imshow(a, interpolation='nearest', vmin=0, vmax=24) --then I get something better, but the NaN values are drawn the same color as vmin... Is there a graceful way that I can set NaNs to be drawn with a special color (eg: gray or transparent)?

    Read the article

  • How do I use a custom authentication mechanism for a Java web application with Spring Security?

    - by Adam
    Hi, I'm working on a project to convert an existing Java web application to use Spring Web MVC. As a part of this I will migrate the existing log-on/log-off mechanism to use Spring Security. The idea at this stage is to replicate the existing functionality and replace only the web layer, leaving the service classes and objects in place. The required functionality is simple. Access is controlled to URLs and to access certain pages the user must log on. Authentication is performed with a simple username and password along with an extra static piece of information that comes from the login page. There is no notion of a role: once a user has logged on they have access to all of the pages. Behind the scenes, the service layer has a class with a simple authentication method: doAuthenticate(String username, String password, String info) throws ServiceException An exception is thrown if the login fails. I'd like to leave this existing service object that does the authentication intact but to "plug it into" the Spring Security mechanism. Can somebody suggest the best approach to take for this please? Naturally, I'd like to take the path of least resistance and leave the work where possible to Spring... Thanks in advance, Adam.

    Read the article

  • Is there a tag in XHTML that you can put anywhere in the body - even inside TABLE elements?

    - by Iain Fraser
    I would like to be able to place an empty tag anywhere in my document as a marker that can be addressed by jQuery. However, it is important that the XHTML still validates. To give you a bit of background as to what I'm doing: I've compared the current and previous versions of a particular document and I'm placing markers in the html where the differences are. I'm then intending to use jQuery to highlight the parent block-level elements when highlightchanges=true is in the URL's query string. At the moment I'm using <span> tags but it occurred to me that this sort of thing wouldn't validate: <table> <tr> <td>Old row</td> </tr> <span class="diff"></span><tr> <td>Just added</td> </tr> </table> So is there a tag I can use anywhere? Meta tag maybe? Thanks for your help! Iain

    Read the article

  • How to interpret trackpad pinch gestures to zoom IKImageBrowserView

    - by Fraser Speirs
    I have an IKImageBrowserView that I want to be able to pinch-zoom using a multi-touch trackpad on a recent Mac laptop. The Cocoa Event Handling Guide, in the section Handling Gesture Events says: The magnification accessor method returns a floating-point (CGFloat) value representing a factor of magnification ..and goes on to show code that adjusts the size of the view by multiplying height and width by magnification + 1.0. This doesn't seem to be the right approach for zooming IKImageBrowserView, whose zoomValue property is clamped between 0.0 and 1.0. So, does anyone know how to interpret the event in -[NSResponder magnifyWithEvent:] to zoom IKImageBrowserView?

    Read the article

  • wx Menu disappears from frame when shown as a popup

    - by Adam Fraser
    I'm trying to create a wx.Menu that will be shared between a popup (called on right-click), and a sub menu accessible from the frame menubar. The following code demonstrates the problem. If you open the "MENUsubmenu" from the menubar the item "asdf" is visible. If you right click on the frame content area, "asdf" will be visible from there as well... however, returning to the menubar, you will find that "MENUsubmenu" is vacant. Why is this happening and how can I fix it? import wx app = wx.PySimpleApp() m = wx.Menu() m.Append(-1, 'asdf') def show_popup(evt): ''' R-click callback ''' f.PopupMenu(m, (evt.X, evt.Y)) f = wx.Frame(None) f.SetMenuBar(wx.MenuBar()) frame_menu = wx.Menu() f.MenuBar.Append(frame_menu, 'MENU') frame_menu.AppendMenu(-1,'submenu', m) f.Show() f.Bind(wx.EVT_RIGHT_DOWN, show_popup) app.MainLoop() Interestingly, appending the menu to MenuBar works, but is not the behavior I want: import wx app = wx.PySimpleApp() m = wx.Menu() m.Append(-1, 'asdf') def show_popup(evt): f.PopupMenu(m, (evt.X, evt.Y)) f = wx.Frame(None) f.SetMenuBar(wx.MenuBar()) f.MenuBar.Append(m, 'MENU') f.Show() f.Bind(wx.EVT_RIGHT_DOWN, show_popup) app.MainLoop()

    Read the article

  • Python many-to-one mapping (creating equivalence classes)

    - by Adam Matan
    Hi, I have a project of converting one database to another. One of the original database columns defines the row's category. This coulmn should be mapepd to a new category in the new databse. For example, let's assume the original categories are:parrot, spam, cheese_shop, Cleese, Gilliam, Palin Now that's a little verbose for me, And I want to have these rows categorized as sketch, actor - That is, define all the sketches and all the actors as two equivalence classes. >>> monty={'parrot':'sketch', 'spam':'sketch', 'cheese_shop':'sketch', 'Cleese':'actor', 'Gilliam':'actor', 'Palin':'actor'} >>> monty {'Gilliam': 'actor', 'Cleese': 'actor', 'parrot': 'sketch', 'spam': 'sketch', 'Palin': 'actor', 'cheese_shop': 'sketch'} That's quite awkward- I would prefer having something like: monty={ ('parrot','spam','cheese_shop'): 'sketch', ('Cleese', 'Gilliam', 'Palin') : 'actors'} But this, of course, sets the entire tuple as a key: >>> monty['parrot'] Traceback (most recent call last): File "<pyshell#29>", line 1, in <module> monty['parrot'] KeyError: 'parrot' Any ideas how to create an elegant many-to-one dictionary in Python? Thanks, Adam

    Read the article

  • xcode syntax color coding explained?

    - by Max Fraser
    Can anyone give me a quick rundown of the color syntax meanings in xcode? I am running into some problems and understanding the color coding I am sure will help me out. Currently I have some variables that are light blue and I think they need to be black but I am not sure of the difference? masterViewController=[[UINavigationController alloc] initWithDestination: destination]; I believe my masterViewController here should be colored black and not the light blue it is currently colored - I am assuming I defined or initialized something wrong somewhere. First day in xCode so I am pretty damn confused!

    Read the article

  • How to load JPG file into NSBitmapImageRep?

    - by Adam
    Objective-C / Cocoa: I need to load the image from a JPG file into a two dimensional array so that I can access each pixel. I am trying (unsuccessfully) to load the image into a NSBitmapImageRep. I have tried several variations on the following two lines of code: NSString *filePath = [NSString stringWithFormat: @"%@%@",@"/Users/adam/Documents/phoneimages/", [outLabel stringValue]]; //this coming from a window control NSImageRep *controlBitmap = [[NSImageRep alloc] imageRepWithContentsOfFile:filePath]; With the code shown, I get a runtime error: -[NSImageRep imageRepWithContentsOfFile:]: unrecognized selector sent to instance 0x100147070. I have tried replacing the second line of code with: NSImage *controlImage = [[NSImage alloc] initWithContentsOfFile:filePath]; NSBitmapImageRep *controlBitmap = [[NSBitmapImageRep alloc] initWithData:controlImage]; But this yields a compiler error 'incompatible type' saying that initWithData wants a NSData variable not an NSImage. I have also tried various other ways to get this done, but all are unsuccessful either due to compiler or runtime error. Can someone help me with this? I will eventually need to load some PNG files in the same way (so it would be nice to have a consistent technique for both). And if you know of an easier / simpler way to accomplish what I am trying to do (i.e., get the images into a two-dimensional array), rather than using NSBitmapImageRep, then please let me know! And by the way, I know the path is valid (confirmed with fileExistsAtPath) -- and the filename in outLabel is a file with .jpg extension. Thanks for any help!

    Read the article

  • How do you go about finding out whether an idea you've had has already been patented?

    - by Iain Fraser
    I have an idea for image copy-protection that I'm in the process of coding up and plan on selling to one of my clients who sells images online. If successful I think there would be a lot of people in a similar situation to my client who would be interested in the code also. I think this is a fairly unique idea that could be packaged into a saleable product - but if I did do this, I wouldn't want some big corporation decending on me with their lawyers after all my hard work. So before I put too much work into this I'd really like to know how I'd go about finding if this idea has been patented already and whether I'd get in trouble if I sold my product and if it would be worthwhile patenting the idea myself. Although I find the idea of software patenting abhorrent, it would be more to protect myself from the usual suspects than to stop fellow-developers from using the idea (if it is in fact a worthwhile one). I live in Australia, so an idea of who to go and see and a ball park figure of how much money I'd be looking at having to pay would be fantastic (in orders of a magnitude: 100s, 1000s, 10s of thousands of dollars, etc). Cheers Iain

    Read the article

  • SEO redirects for removed pages

    - by adam
    Hi, Apologies if SO is not the right place for this, but there are 700+ other SEO questions on here. I'm a senior developer for a travel site with 12k+ pages. We completely redeveloped the site and relaunched in January, and with the volatile nature of travel, there are many pages which are no longer on the site. Examples: /destinations/africa/senegal.aspx /destinations/africa/features.aspx Of course, we have a 404 page in place (and it's a hard 404 page rather than a 30x redirect to a 404). Our SEO advisor has asked us to 30x redirect all our 404 pages (as found in Webmaster Tools), his argument being that 404's are damaging to our pagerank. He'd want us to redirect our Senegal and features pages above to the Africa page (which doesn't contain the content previously found on Senegal.aspx or features.aspx). An equivalent for SO would be taking a url for a removed question and redirecting it to /questions rather than showing a 404 'Question/Page not found'. My argument is that, as these pages are no longer on the site, 404 is the correct status to return. I'd also argue that redirecting these to less relevant pages could damage our SEO (due to duplicate content perhaps)? It's also very time consuming redirecting all 404's when our site takes some content from our in-house system, which adds/removes content at will. Thanks for any advice, Adam

    Read the article

  • Drawing Directed Acyclic Graphs: Minimizing edge crossing?

    - by Robert Fraser
    Laying out the verticies in a DAG in a tree form (i.e. verticies with no in-edges on top, verticies dependent only on those on the next level, etc.) is rather simple without graph drawing algorithms such as Efficient Sugimiya. However, is there a simple algorithm to do this that minimizes edge crossing? (For some graphs, it may be impossible to completely eliminate edge crossing.) A picture says a thousand words, so is there an algorithm that would suggest: instead of: EDIT: As the picture suggests, a vertex's inputs are always on top and outputs are always below, which is another barrier to just pasting in an existing layout algorithm.

    Read the article

  • jquery load returns empty, possible MVC 2 problem?

    - by Max Fraser
    I have a site that need to get some data from a different sit that is using asp.net MVC/ The data to get loaded is from these pages: http://charity.hondaclassic.com/home/totaldonations http://charity.hondaclassic.com/Home/CharityList This should be a no brainer but for some reason I get an empty response, here is my JS: <script> jQuery.noConflict(); jQuery(document).ready(function($){ $('.totalDonations').load('http://charity.hondaclassic.com/home/totaldonations'); $('#charityList').load('http://charity.hondaclassic.com/home/CharityList'); }); </script> in firebug I see the request is made and come back with a response of 200 OK but the response is empty, if you browse to these pages they work fine! What the heck? Here are the controller actions from the MVC site: public ActionResult TotalDonations() { var total = "$" + repo.All<Customer>().Sum(x => x.AmountPaid).ToString(); return Content(total); } public ActionResult CharityList() { var charities = repo.All<Company>(); return View(charities); } Someone please out what stupid little thing I am missing - this should have taken me 5 minutes and it's been hours!

    Read the article

  • How can I draw a log-normalized imshow plot with a colorbar representing the raw data in matplotlib

    - by Adam Fraser
    I'm using matplotlib to plot log-normalized images but I would like the original raw image data to be represented in the colorbar rather than the [0-1] interval. I get the feeling there's a more matplotlib'y way of doing this by using some sort of normalization object and not transforming the data beforehand... in any case, there could be negative values in the raw image. import matplotlib.pyplot as plt import numpy as np def log_transform(im): '''returns log(image) scaled to the interval [0,1]''' try: (min, max) = (im[im > 0].min(), im.max()) if (max > min) and (max > 0): return (np.log(im.clip(min, max)) - np.log(min)) / (np.log(max) - np.log(min)) except: pass return im a = np.ones((100,100)) for i in range(100): a[i] = i f = plt.figure() ax = f.add_subplot(111) res = ax.imshow(log_transform(a)) # the colorbar drawn shows [0-1], but I want to see [0-99] cb = f.colorbar(res) I've tried using cb.set_array, but that didn't appear to do anything, and cb.set_clim, but that rescales the colors completely. Thanks in advance for any help :)

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >