Search Results

Search found 701 results on 29 pages for 'jay bell'.

Page 7/29 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • How does MySQL's ORDER BY RAND() work?

    - by Eugene
    Hi, I've been doing some research and testing on how to do fast random selection in MySQL. In the process I've faced some unexpected results and now I am not fully sure I know how ORDER BY RAND() really works. I always thought that when you do ORDER BY RAND() on the table, MySQL adds a new column to the table which is filled with random values, then it sorts data by that column and then e.g. you take the above value which got there randomly. I've done lots of googling and testing and finally found that the query Jay offers in his blog is indeed the fastest solution: SELECT * FROM Table T JOIN (SELECT CEIL(MAX(ID)*RAND()) AS ID FROM Table) AS x ON T.ID >= x.ID LIMIT 1; While common ORDER BY RAND() takes 30-40 seconds on my test table, his query does the work in 0.1 seconds. He explains how this functions in the blog so I'll just skip this and finally move to the odd thing. My table is a common table with a PRIMARY KEY id and other non-indexed stuff like username, age, etc. Here's the thing I am struggling to explain SELECT * FROM table ORDER BY RAND() LIMIT 1; /*30-40 seconds*/ SELECT id FROM table ORDER BY RAND() LIMIT 1; /*0.25 seconds*/ SELECT id, username FROM table ORDER BY RAND() LIMIT 1; /*90 seconds*/ I was sort of expecting to see approximately the same time for all three queries since I am always sorting on a single column. But for some reason this didn't happen. Please let me know if you any ideas about this. I have a project where I need to do fast ORDER BY RAND() and personally I would prefer to use SELECT id FROM table ORDER BY RAND() LIMIT 1; SELECT * FROM table WHERE id=ID_FROM_PREVIOUS_QUERY LIMIT 1; which, yes, is slower than Jay's method, however it is smaller and easier to understand. My queries are rather big ones with several JOINs and with WHERE clause and while Jay's method still works, the query grows really big and complex because I need to use all the JOINs and WHERE in the JOINed (called x in his query) sub request. Thanks for your time!

    Read the article

  • How to read direct3d texture pixels

    - by Mr Bell
    So I have a x8r8g8b8 formatted IDirect3DSurface9 that contains the contents of the back buffer. When I call LockRect on it I get access to a struct containing pBits, a pointer to the pixels I assume, and and integer Pitch (which I am very unclear about its purpose). How to read the individual pixels? Visual Studio 2008 C++

    Read the article

  • Hide horizontal scrollbar in IE 7 and below

    - by Bradley Bell
    Hi all. Basically, I'm having trouble removing the horizontal scrollbar in Internet Explorer 7 and Below. I've tried the code below and It seems to work fine in every browser except IE. overflow-x: hidden; The even bigger problem is that, even though the scrollbar isn't even removed, it seems to completely screw the layout.. It somehow hides the majority of the page content in boxes 2 and 3? It also.. adds a second vertical scrollbar which moves relatively/absolute positioned items down?! I did contemplate just leaving the scrollbar in IE via a specified stylesheet, but even that seems to be messing with the page? The website is on a test directory here.. I'll post the stylesheet in a comment below. Any suggestions? Thanks in advance, hope you can help! Bradley

    Read the article

  • Add share button in magiczoomplus

    - by duyen hoang
    I am creating a WordPress site using Artisteer and various plugins to show off some photo galleries. I have also purchased a e-commerce WordPress theme that I have included as a subdirectory. In this theme they have a share button that I like the functionality of. I want to replicate the button in the front section of the site within the gallery pages. See the attached links to see what I am talking about. http://rrestricted.com/eshop/20mens/jay-chillin http://rrestricted.com/gallery/jay-3 The first link has the share button (loveheart icon) and the second the gallery that I want to add the button to. If you click on the images in the gallery you will see a large lightbox come up. I want to add the Share button just above the navigation buttons. This is my require from a customer. I was searched magiczoomplus.js, but I can't add it.

    Read the article

  • jqueryForm and empty uploads

    - by Aiden Bell
    Hi All, Been scratching my head for too long on this: Using jquery.form, (http://malsup.com/jquery/form) with PHP ... my $_FILES['someimage'] gets set but the error number is always UPLOAD_ERR_NO_FILE, size is also 0. The JavaScript: $('form input[type=file]').change(function(){ $(this).clone().appendTo('#imgform'); $('#imgform').ajaxForm(); $('#imgform').ajaxSubmit( { type:'POST' } ); }); Which appends to: <form id="imgform" method="POST" action="/api/images.php" enctype="multipart/form-data"></form> From another form which has bog-standard file inputs. PHP logs are clean, but var_dumping $_FILES always shows that the index is set to the name of the form element ... but no data. Thanks guys! (Sorry, I know jQuery-like questions are too frequent round these parts).

    Read the article

  • How to attach a sample grabber to the playcap sdk sample

    - by Mr Bell
    I want to get access to a webcam's frame image data so I can composite it with some other data. The playcap sample in the windows sdk directshow folder can show you a window streaming the webcam, but doesn't demonstrate access to the bytes. Someone mentioned that I could use a samplegrabber filter attached to a null rendered to gain access to the frame data. Unfortunately I haven't the first clue how to do this. How can I modify the playcap sample to attach a sample grabber and access the frame bytes? visual studio 2008 c++

    Read the article

  • building mono from svn - android target

    - by Jeremy Bell
    There were patches made to mono on trunk svn to support android. My understanding is that essentially instead of Koush's system which builds mono using the android NDK build system directly, these patches add support for the android NDK using the regular mono configure.sh process. I'd like to play around with this patch, but not being an expert in the mono build system, I have no idea how to tell it to target the android NDK, or even where to look. I've been able to build mono from SVN using the default target (linux) on Ubuntu, but no documentation on how to target android was given with the patches. Since anyone not submitting or reviewing a patch is generally ignored on the mono mailing list, I figured I'd post the question here.

    Read the article

  • MYSQL update query php

    - by bell
    I am trying to use an update query to change values held in a database, the new values I am trying to store are held in php variables. I'm not sure what it is I'm doing wrong. mysql_query("UPDATE user SET status='full' WHERE user_id = '$user_id'")or die(mysql_error()); thanks in advance

    Read the article

  • printf and formatting rules

    - by Stringer Bell
    I'd like to know if all formatting rules of printf functions currently work (or are implemented) in F# ? For instance, if I want to align arguments on 9 characters (padding with spaces or 0), I would use: printfn "%9A %9A" arg1 arg2 //don't seem to work Thanks!

    Read the article

  • PHP and XSLTProcessor Misbehavior

    - by Aiden Bell
    Hi all, Simple question: Why is a PHP function called from an XSL Stylesheet just returning the last argument passed: foo.xsl: <xsl:template match="/"> <xsl:value-of select="php:function('date','c')" /> </xsl:template> PHP: ... $xsl = new XSLTProcessor(); $xsl->registerPHPFunctions(); $xsl->importStylesheet($fooStylesheet); echo $xsl->transformToXML($myXML); I Get the output c and if I call <xsl:value-of select="php:function('date')" /> I just get date as my output. Seems strange to me. Version info: PHP 5.3.2 libxslt Version 1.1.26 libxslt compiled against libxml Version 2.7.6 EXSLT enabled libexslt Version 1.1.26

    Read the article

  • Can I split system.serviceModel into a separate .config file?

    - by Mr Bell
    I want to separate my system.serviceModel section of the web.config into a separate file to facilitate some environment settings. My efforts have been fruitless. When I attempt it using this method. The wcf code throws an exception: "The type initializer for 'System.ServiceModel.ClientBase 1 threw an exception. Can anyone tell me what I am doing wrong? Web.config: <configuration> <system.serviceModel configSource="MyWCF.config" /> .... MyWCF.config: <system.serviceModel> <extensions> ... </extensions> <bindings> ... </bindings> <behaviors> ... </behaviors> <client> ... </client> </system.serviceModel>

    Read the article

  • Strangely structured xml code finding last value of a certain type using java

    - by Damien.Bell
    Thus the structure is something like this: OasisReportMessagePayloadRTOReport_ItemReport_Data Under report data it's broken into categories: >>Zone >>Type >>Value >>Interval What I need to do is: Get the value if the type is equal to 'myType' and the interval value is the LARGEST. So an example of the xml might be (under report_data): OasisReport MessagePayload RTO REPORT_ITEM REPORT_DATA <zone>myZone1</zone> -- This should be the same in all reports since I only get them for 1 zone <type>myType</type> --This can change from line to line <value>12345</value>--This changes every interval <Interval>122</Interval> -- This is essentially how many 5 minute intervals have taken place since the beginning of a day, finding the "max" lets me know it's the newest data. Thereby I want to find stuff of "MyType" for the "max" interval and pull the Value (into a string, or a double, if not I can convert from string. Can someone help me with this task? Thanks! Note: I've used Xpath to handle things like this in the past, but it seems outlandish for this... as it's SO complex (since not all the reports live in the same report_item, and not all the types are the same in each report)

    Read the article

  • jQuery crashing Internet Explorer

    - by Bradley Bell
    Hello. Okay basically, I'm designing and developing a fairly complicated website which revolves around the use of jQuery.. My knowlege of jQuery is really poor and this is the first time I've properly used it. I posted a question here before about the script and apparently its awful, but I didn't show you exactly what I was actually writing it for, which I can now.. Because I've uploaded it onto a test directory. It now works fine in every browser other than IE. The CSS styling is getting there and it should be close to finish soon! However, Internet Explorer is showing bad problems.. In IE 7,8 it looks fine but when you go to hover over a link, it immediately crashes. IE 6, the display doesn't seem to be working properly at all. But IE 6 is a lesser problem. If you could take just 5 or 10 minutes to potentially rewrite a simple script which would potentially take me 10 hours, I would be so so grateful! Heres the site - http://openyourheart.org.uk/test/index.html I can send all the files zipped if required. Thankyou in advance. Bradley

    Read the article

  • Need help regarding Async and fsi

    - by Stringer Bell
    I'd like to write some code that runs a sequence of F# scripts (.fsx). The thing is that I could have literally hundreds of scripts and if I do that: let shellExecute program args = let startInfo = new ProcessStartInfo() do startInfo.FileName <- program do startInfo.Arguments <- args do startInfo.UseShellExecute <- true do startInfo.WindowStyle <- ProcessWindowStyle.Hidden //do printfn "%s" startInfo.Arguments let proc = Process.Start(startInfo) () scripts |> Seq.iter (shellExecute "fsi") it could stress too much my 2GB system. Anyway, I'd like to run scripts by batch of n, which seems also a good exercise for learning Async (I guess it's the way to go). I have written some code and unfortunately it doesn't work: open System.Diagnostics let p = shellExecute "fsi" @"C:\Users\Stringer\foo.fsx" async { let! exit = Async.AwaitEvent p.Exited do printfn "process has exited" } |> Async.StartImmediate foo.fsx is just a hello world script. I'd like also to figure out if it's doable to retrieve a return code for each executing script and if not, find another way. Thanks!

    Read the article

  • How do I get the IVsTextView of a specific OutputWindowPane?

    - by Jeremy Bell
    I have a visual studio integration package that tracks output from the debug window. I can get the IVsTextView of the output window, like so: IVsTextView view = GetService(typeof(SVsOutputWindow)) as IVsTextView; // grab text from the view and process it However, if a different panel other than the "Debug" panel is currently active, then this IVsTextView will have text from that panel, and not the "Debug" panel. Is it possible to get an IVsTextView for a specific output window panel, without calling OutputWindowPanel.Activate() prior to getting the IVsTextView of the output window?

    Read the article

  • idiomatic property changed notification in scala?

    - by Jeremy Bell
    I'm trying to find a cleaner alternative (that is idiomatic to Scala) to the kind of thing you see with data-binding in WPF/silverlight data-binding - that is, implementing INotifyPropertyChanged. First, some background: In .Net WPF or silverlight applications, you have the concept of two-way data-binding (that is, binding the value of some element of the UI to a .net property of the DataContext in such a way that changes to the UI element affect the property, and vise versa. One way to enable this is to implement the INotifyPropertyChanged interface in your DataContext. Unfortunately, this introduces a lot of boilerplate code for any property you add to the "ModelView" type. Here is how it might look in Scala: trait IDrawable extends INotifyPropertyChanged { protected var drawOrder : Int = 0 def DrawOrder : Int = drawOrder def DrawOrder_=(value : Int) { if(drawOrder != value) { drawOrder = value OnPropertyChanged("DrawOrder") } } protected var visible : Boolean = true def Visible : Boolean = visible def Visible_=(value: Boolean) = { if(visible != value) { visible = value OnPropertyChanged("Visible") } } def Mutate() : Unit = { if(Visible) { DrawOrder += 1 // Should trigger the PropertyChanged "Event" of INotifyPropertyChanged trait } } } For the sake of space, let's assume the INotifyPropertyChanged type is a trait that manages a list of callbacks of type (AnyRef, String) = Unit, and that OnPropertyChanged is a method that invokes all those callbacks, passing "this" as the AnyRef, and the passed-in String). This would just be an event in C#. You can immediately see the problem: that's a ton of boilerplate code for just two properties. I've always wanted to write something like this instead: trait IDrawable { val Visible = new ObservableProperty[Boolean]('Visible, true) val DrawOrder = new ObservableProperty[Int]('DrawOrder, 0) def Mutate() : Unit = { if(Visible) { DrawOrder += 1 // Should trigger the PropertyChanged "Event" of ObservableProperty class } } } I know that I can easily write it like this, if ObservableProperty[T] has Value/Value_= methods (this is the method I'm using now): trait IDrawable { // on a side note, is there some way to get a Symbol representing the Visible field // on the following line, instead of hard-coding it in the ObservableProperty // constructor? val Visible = new ObservableProperty[Boolean]('Visible, true) val DrawOrder = new ObservableProperty[Int]('DrawOrder, 0) def Mutate() : Unit = { if(Visible.Value) { DrawOrder.Value += 1 } } } // given this implementation of ObservableProperty[T] in my library // note: IEvent, Event, and EventArgs are classes in my library for // handling lists of callbacks - they work similarly to events in C# class PropertyChangedEventArgs(val PropertyName: Symbol) extends EventArgs("") class ObservableProperty[T](val PropertyName: Symbol, private var value: T) { protected val propertyChanged = new Event[PropertyChangedEventArgs] def PropertyChanged: IEvent[PropertyChangedEventArgs] = propertyChanged def Value = value; def Value_=(value: T) { if(this.value != value) { this.value = value propertyChanged(this, new PropertyChangedEventArgs(PropertyName)) } } } But is there any way to implement the first version using implicits or some other feature/idiom of Scala to make ObservableProperty instances function as if they were regular "properties" in scala, without needing to call the Value methods? The only other thing I can think of is something like this, which is more verbose than either of the above two versions, but is still less verbose than the original: trait IDrawable { private val visible = new ObservableProperty[Boolean]('Visible, false) def Visible = visible.Value def Visible_=(value: Boolean): Unit = { visible.Value = value } private val drawOrder = new ObservableProperty[Int]('DrawOrder, 0) def DrawOrder = drawOrder.Value def DrawOrder_=(value: Int): Unit = { drawOrder.Value = value } def Mutate() : Unit = { if(Visible) { DrawOrder += 1 } } }

    Read the article

  • Intercepting Xstream conversion while parsing XML

    - by Shane Bell
    Suppose I have a simple Java class like this: public class User { String firstName; String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } Now, suppose I want to parse the following XML: <user> <firstName>Homer</firstName> <lastName>Simpson</lastName> </user> I can do this with no problems in XStream like so: User homer = (User) xstream.fromXML(xml); Ok, all good so far, but here's my problem. Suppose I have the following XML that I want to parse: <user> <fullName>Homer Simpson</fullName> </user> How can I convert this XML into the same User object using XStream? I'd like a way to implement some kind of callback so that when XStream parses the fullName field, I can split the string in two and manually set the first name and last name fields on the user object. Is this possible? Note that I'm not asking how to split the string in two (that's the easy part), I want to know how to intercept the XML parsing so XStream doesn't try to reflectively set the fullName field on the User object (which obviously doesn't exist). I looked at the converters that XStream provides but couldn't figure out how to use it for this purpose. Any help would be appreciated.

    Read the article

  • Get image data for Direct3d rendering stream

    - by Mr Bell
    I would like to get at the raw image data, as in a pointed to a byte array or something like that, of the image output from a direct3d app without actually rendering it to the monitor. I need to do this so that I can render direct3d as a directshow source filter Visual studio 2008 c++

    Read the article

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