Search Results

Search found 5192 results on 208 pages for 'random forests'.

Page 129/208 | < Previous Page | 125 126 127 128 129 130 131 132 133 134 135 136  | Next Page >

  • how to rearrange randomly and show all the 5 elements

    - by user295189
    how can I rearrange it randomly and NOT use shuffle function and still be able to randomly arrange all the elements $input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $rand_keys = array_rand($input, 5); echo $input[$rand_keys[0]] . "\n"; echo $input[$rand_keys[1]] . "\n"; echo $input[$rand_keys[2]] . "\n"; echo $input[$rand_keys[3]] . "\n"; echo $input[$rand_keys[4]] . "\n"; so it shows random names everytime the function is ran. thanks

    Read the article

  • Grails multi column indexes

    - by Kimble
    Can someone explain how to define multi column indexes in Grails? The documentation is at best sparse. This for example does not seem to work at all: http://grails.org/GORM+Index+definitions I've had some luck with this, but the results seems random at best. Definitions that works in one domain class does not when applied to another (with different names of course). http://www.grails.org/doc/1.1/guide/single.html#5.5.2.6%20Database%20Indices Some working examples and explanations would be highly appreciated!

    Read the article

  • JTextArea thread safe?

    - by Dhaivat Pandya
    Hello everyone, I have some code that does some initialization (including making a JTextArea object), starts three seperate threads, and then these threads try to update the JTextArea (i.e. append() to it), but its not working at all. Nothing shows up on the JTextArea (however, during the initialzation, I print some test lines onto it, and that works fine). What's going on? How can I fix this? Also, each of those threads sleeps a random amount of time every time it has to update the JTextArea. Sorry I haven't provided any code, its all spread out over several files.

    Read the article

  • Hooking into DirectX application

    - by x3ro
    Hey there :) I'm currently trying to display some information (as an overlay) to the user inside a DirectX-based game, much like the frame count which Fraps displayed, but I have no clue where to start. I don't expect a full solution to my problem, just a few hints where I can start and where to get more information about the topic ;) Thanks in advance. PS: The project I'm working on is written in C# (.NET 3.5) PPS: To clarify: I mean hooking into any random DX-based game. Start my app, start any game, display some kind of overlay.

    Read the article

  • Fastest way to zero out a 2d array in C?

    - by Eddy
    I want to repeatedly zero a large 2d array in C. This is what I do at the moment: for(j = 0; j < n; j++) { for(i = 0; i < n; i++) { array[i][j] = 0; } } I've tried using memset: memset(array, 0, sizeof(array)) But this only works for 1D arrays. When I printf the contents of the 2D array, the first row is zeroes, but then I got a load of random large numbers and it crashes.

    Read the article

  • TcpListener Socket still active after program exits.

    - by lnical
    I'm trying to stop a TCP Listener as my program is exiting. I do not care about any data that is currently active on the socket or any of the active client sockets. The socket clean up code is essentially: try { myServer.Server.Shutdown(SocketShutdown.Both) } catch (Exception ex) { LogException(ex) } myServer.Server.Close(0) myServer.Stop() myServer is a TCPListener On some occasions, Shutdown will thrown an exception System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied at System.Net.Sockets.Socket.Shutdown(SocketShutdown how) When this happens, the socket is never released. Even after the application exits netstat shows the socket is still in the listening state. I have not been able to create definitive reproduction scenerio, it happens at seemingly random times. Client Sockets are cleaned up independently. Do you have any suggestions to help me make this socket die?

    Read the article

  • What is the advantage of using static methods in Python?

    - by Curious2learn
    I ran into unbound method error in python with the code class Sample(object): '''This class defines various methods related to the sample''' def drawSample(samplesize,List): sample=random.sample(List,samplesize) return sample Choices=range(100) print Sample.drawSample(5,Choices) After reading many helpful posts here, I figured how I could add @staticmethod above to get the code working. I am python newbie. Can someone please explain why one would want to define static methods? Or, why are not all methods defined as static methods. Thanks in advance.

    Read the article

  • Cocoa window position anomaly

    - by Marius
    Hello everyone, I have a weird problem with positioning a window on screen. I want to center the window on the screen, but i don't know how to do that. Here's what i've got. The window is created from nib by the main controller: IdentFormController *ftf = [[IdentFormController alloc] initWithWindowNibName:@"IdentForm"]; [[ftf window] makeKeyAndOrderFront:self]; Now the IdentFormController has awakeFromNib() method in which it tries to position the window. For the sake of simplicity i've just tried to do setFrameOrigin(NSMakePoint(0, 0)). What happens is as follows: The first time i create this window, everything works as expected. But if i create it again after releasing the previous, it starts appearing at random positions. Why does it do that?

    Read the article

  • Accidentally created a virus?

    - by Workshop Alex
    I've seen it happen reasonabley often: I write an application in Delphi and when I compile it, the virus-scanner tells me that I've created a virus and thus immediately deletes the executable again. It's annoying but reasonable easy to fix by doing a full rebuild, deleting the *.dcu files first and sometimes by simply waiting. It happens with Delphi 6, 7, 2005 and 2007, as far as I know. And Symantec, Kaspersky, McAfee and NOD32 have all been guilty of reporting these false positives. I know it's because Delphi adds timestamps to its DCU files and these timestamps end up in the final executable and apparently appear to be part of some random virus signature. I don't want to disable the virus-scanner, not even for a single folder or file. And I'm not really for a solution, but am wondering about the following: Do these false positives also occur with other compilers? Does it also happen with .NET executables? Do others also notice similar problems with Delphi?

    Read the article

  • Google Application Engine slow in case of Python...

    - by Aftershock
    hi, I am reading a "table" in Python in GAE that has 1000 rows and the program stops because the time limit is reached. (So it takes at least 20 seconds.)( Is that possible that GAE is that slow? Is there a way to fix that? Is this because I use free service and I do not pay for it? Thank you. The code itself is this: for u in userall: # userall has 1000 users for stockname in stocknamesall: # 4 stocks astock= stocksowned() astock.quantity = random.randint(1,100) astock.nameid = u.key() astock.stockid = stockname.key() liststocks.append(astock);

    Read the article

  • VS2005 project has dependency that is not built

    - by Eyal
    I have VS2005 solution that contains many projects and dependencies (some C++, some C#) - in the past it compiled successfully. when I rebuild all the solution it fails on a project claiming dll is missing (dll that was needed to built before according to dependency). the thing is that from time to time it fails on random project (not all the time the same project). I'm not sure it is meaningful but I see in output console Deleting intermediate and output files for project doesn't VS2005 go according to "Project Build Order" and ReBuild every project starting with its dependencies?

    Read the article

  • c99 goto past initialization

    - by R Samuel Klatchko
    While debugging a crash, I came across this issue in some code: int func() { char *p1 = malloc(...); if (p1 == NULL) goto err_exit; char *p2 = malloc(...); if (p2 == NULL) goto err_exit; ... err_exit: free(p2); free(p1); return -1; } The problem occurs when the first malloc fails. Because we jump across the initialization of p2, it contains random data and the call to free(p2) can crash. I would expect/hope that this would be treated the same way as in C++ where the compiler does not allow a goto to jump across an initialization. My question: is jumping across an initialization allowed by the standard or is this a bug in gcc's implementation of c99?

    Read the article

  • Compression Array of Bytes

    - by Pedro Magalhaes
    Hi, My problem is: I want to store a array of bytes in compressed file, and then I want to read it with a good performance. So I create a array of bytes then pass to a ZLIB algorithm then store it in the file. For my surprise the algorithm doesn't work well., probably because the array is a random sample. Using this approach, it will will be ber easy to read. Just copy the stream to memory, decompress them and copy it to a array of bytes. But i need to compress the file. Do I have to use a algorithm, like RLE, for compresse the byte array? I think that I can store the byte array like a string and then compress it. But i think I am going to have a poor performance on reading data. Sorry for my poor english. Thanks

    Read the article

  • Why might different computers calculate different arithmetic results in VB.NET?

    - by Eyal
    I have some software written in VB.NET that performs a lot of calculations, mostly extracting jpegs to bitmaps and computing calculations on the pixels like convolutions and matrix multiplication. Different computers are giving me different results despite having identical inputs. What might be the reason? Edit: I can't provide the algorithm because it's proprietary but I can provide all the relevant operations: ULong \ ULong (Turuncating division) Bitmap.Load("filename.bmp') (Load a bitmap into memory) Bitmap.GetPixel(Integer, Integer) (Get a pixel's brightness) Double + Double Double * Double Math.Sqrt(Double) Math.PI Math.Cos(Double) ULong - ULong ULong * ULong ULong << ULong List.OrderBy(Of Double)(Func) Hmm... Is it possible that OrderBy is using a non-stable QuickSort and that QuickSort is using a random pivot? Edit: Just tested, nope. The sort is stable.

    Read the article

  • Glib convert epoch time to string.

    - by PP
    I am using glibs functions to convert epoch time to string as follows. But each time it is giving me some random time. //Convert Time in string. GDate *date = g_date_new_julian(timestampsecs); gchar date_string[50]; g_date_strftime(date_string, 50, (const gchar*)"%a, %I:%M %p", (const GDate*)date); printf("Date String [%s]\n", date_string ); Why this might be happening? am i missing anything? Thanks, PP.

    Read the article

  • JavaScript on Android randomly stops working

    - by AndersWid
    Hi! I have an application that uses a WebView and a html-page with javascript functions. Randomly the JavaScript functions doesn't seem to be called. It works up to a random point (I have looked at this bug all day) can only be produced on hardware (HTC Legend) not on emulator. Basicly I'm using callback to javaScript whenever the user presses a button, these callbacks tell the html to redraw using javaScript functions. mHandler.post(new Runnable() { public void run() { mWebView.loadUrl("javascript:getDataLine()"); } }); The first line in this javaScript code is an alert that says that it has started, so that I can see that it's working. Settings alerts or console.log's everywhere won't help as it seems the problem is in the webview or in Android itself. I need a way to see what's going on in the background. Maybe see if a previous call failed and stalled the thread or something.

    Read the article

  • g_tree_insert overwrites all data

    - by pechenie
    I wonder how I should use the GTree (from GLib) to store data? Every new value I insert into GTree with g_tree_insert routine is overwrite the previous one! GTree *tree; //init tree = g_tree_new( g_str_equal ); //"g_str_equal" is a GLib default compare func //... for( i = 0; i < 100; ++i ) g_tree_insert( tree, random_key(), random_value() ); //insert some random vals // printf( "%d", g_tree_nnodes( tree ) ); //should be 100? NO! Prints "1"!!! What am I doing wrong? Thank you.

    Read the article

  • How to make tag group with including predefined attributes, to wrap other things quickly?

    - by jitendra
    for example. if i want to quickly wrap anything by this in once. in dreamweaver or in any other free software where i can do this. I want to select this <p>anything can be here - content, other html tag etc.</p> and in one shot want to wrap inside 2 divs with predefined classes <div class="one"> <div class="two"> <p>anything can be here - content, other html tag etc.</p> </div> </div> I have work with large amount of code and need to wrap random things in Divs with defined attributes.

    Read the article

  • C functions invoked as threads - Linux userland program

    - by Einar
    I'm writing a linux daemon in C which gets values from an ADC by SPI interface (ioctl). The SPI (spidev - userland) seems to be a bit unstable and freezes the daemon at random times. I need to have some better control of the calls to the functions getting the values, and I was thinking of making it as a thread which I could wait for to finish and get the return value and if it times out assume that it froze and kill it without this new thread taking down the daemon itself. Also I could do other things like resetting the ADC before restarting. Is this possible? Pseudo example of what I want to achieve: (function int get_adc_value(int adc_channel, float *value) ) pid = thread( get_adc_value(1,&value); //makes thread wait_until_finish(pid, timeout); //waits until function finishes/timesout if(timeout) kill pid, start over //if thread do not return in given time, kill it (it is frozen) else if return value sane, continue //if successful, handle return variable value and continue Thanks for any input on the matter, examples highly appreciated!

    Read the article

  • string parsing help

    - by sprugman
    I've got a string like this: #################### Section One #################### Data A Data B #################### Section Two #################### Data C Data D etc. I want to parse it into something like: $arr( 'Section One' => array('Data A', 'Data B'), 'Section Two' => array('Data C', 'Data D') ) At first I tried this: $sections = preg_split("/(\r?\n)(\r?\n)#/", $file_content); The problem is, the file isn't perfectly clean: sometimes there are different numbers of blank lines between the sections, or blank spaces between data rows. The section head pattern itself seems to be relatively consistent: #################### Section Title #################### The number of #'s is probably consistent, but I don't want to count on it. The white space on the title line is pretty random. Once I have it split into sections, I think it'll be pretty straightforward, but any help writing a killer reg ex to get it there would be appreciated. (Or if there's a better approach than reg ex...)

    Read the article

  • Replace images in a DIV using javascript.

    - by Muhammad Sajid
    Hi, I want to show different images in a DIV, the turn of an image depend on a random number. The image name is like 1.gif, 2.gif, .. 6.gif to do that I coded var img = document.createElement("IMG"); img.src = "images/1.gif"; document.getElementById('imgDiv').appendChild(img); but it does not replace the old image how ever it add an another image right in the bottom of first image. syntax for DIV is: <div id="imgDiv" style="width:85px; height:100px; margin:0px 10px 10px 375px;"></div> may u halp me ?

    Read the article

  • Can somone help fix up my simple regex query, please?

    - by Pure.Krome
    Hi folks, yep - another noob regex query, which I can't seem to get. I'm trying to get all matches for the string foo.mydomain.com/ or foo.mydomain.com:1234/ or foo.mydomain.com:<random port>/ but any other paths do not match, ie. foo.mydomain.com/bar or foo.mydomain.com/bar/pewpew I tried to use: foo.mydomain.com(.*)/$ ( starts with anything, then foo.mydomain.com, then any thing after that .. until a slash. then end. (this search query is anchored to the end of the line). but that doesn't work. It doesn't match when i pass in foo.mydomain.com:1234 but it correct says foo.mydomain.com/bar/pewpew is not a match (as expected). any ideas?

    Read the article

  • Why does this give a segmentation fault?

    - by nightcracker
    I'm stunned, why does this code give me a segmentation fault? #include <stdio.h> #define LIMIT 1500000 typedef struct { int p; int a; int b; } triplet; int main(int argc, char **argv) { int i; triplet triplets[LIMIT]; for (i = 0; i < 5; i++) { triplets[i].p = 9; // remove this line and everything works fine } printf("%d\n", triplets[15].p); return 0; } EDIT: After changing LIMIT to 150 I no longer get a segmentation fault, it prints random numbers instead.

    Read the article

  • Python and hebrew encoding/decoding error

    - by user340495
    Hey, I have sqlite database which I would like to insert values in Hebrew to I am keep getting the following error : UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 0: ordinal not in range(128) my code is as following : runsql(u'INSERT into personal values(%(ID)d,%(name)s)' % {'ID':1,'name':fabricate_hebrew_name()}) def fabricate_hebrew_name(): hebrew_names = [u'????',u'???',u'???',u'???',u'????',u'???',u'????',u'???',u'????',u'?????',u'????',u'???',u'????'] return random.sample(names,1)[0].encode('utf-8') note: runsql executing the query on the sqlite database fabricate_hebrew_name() should return a string which could be used in my SQL query. any help is much appreciated.

    Read the article

  • Is there a way to avoid IE7 quirks mode while rendering XML + CSS?

    - by Steven Huwig
    I've got some DocBook documentation styled with a CSS xml-stylesheet declaration. It looks great in Firefox, but IE7 doesn't seem to understand the CSS child selectors (e.g. section > title { ... }). I think this is because IE is running in quirks mode to render this XML, and older versions of IE didn't support that CSS syntax at all. The pages I found on the web all seem to focus on HTML and XHTML doctypes and how IE will behave given various permutations of these values. I couldn't find any information about straight XML + CSS. Worse yet, it seems that random XML documents always end up in quirks mode, no matter what format or stylesheet directives they have. Is XML rendering in IE doomed to be IE5.5 compatible? Will I really have to rewrite my CSS?

    Read the article

< Previous Page | 125 126 127 128 129 130 131 132 133 134 135 136  | Next Page >