Search Results

Search found 612 results on 25 pages for 'flip flop'.

Page 16/25 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • sampling integers uniformly efficiently in python using numpy/scipy

    - by user248237
    I have a problem where depending on the result of a random coin flip, I have to sample a random starting position from a string. If the sampling of this random position is uniform over the string, I thought of two approaches to do it: one using multinomial from numpy.random, the other using the simple randint function of Python standard lib. I tested this as follows: from numpy import * from numpy.random import multinomial from random import randint import time def use_multinomial(length, num_points): probs = ones(length)/float(length) for n in range(num_points): result = multinomial(1, probs) def use_rand(length, num_points): for n in range(num_points): rand(1, length) def main(): length = 1700 num_points = 50000 t1 = time.time() use_multinomial(length, num_points) t2 = time.time() print "Multinomial took: %s seconds" %(t2 - t1) t1 = time.time() use_rand(length, num_points) t2 = time.time() print "Rand took: %s seconds" %(t2 - t1) if __name__ == '__main__': main() The output is: Multinomial took: 6.58072400093 seconds Rand took: 2.35189199448 seconds it seems like randint is faster, but it still seems very slow to me. Is there a vectorized way to get this to be much faster, using numpy or scipy? thanks.

    Read the article

  • Nike + iPod app like customisation ?

    - by Madhup
    Hi, I am very much curious about Nike + iPod app look and feel. They have selected uitabbar buttons red in color The tableviewcell selection style as red in color. The disclosure indicator is also red in color. The solution in my mind for two of these is: I can use a red colored arrow image to use it as accessory view. I can flip between a red colored and white colored view with animation for having the selection style But I am clueless of how the tabbar thing is to be done. I am very curious to know the tricks behind this, I also accept that I may be wrong with my other two solutions. So please suggest the solution for any of the problems. I think all are worth knowing for the developers. Thanks, Madhup

    Read the article

  • How do I fire an asynchronous call in asp classic and ignore the response?

    - by Hexate
    Here's the gist: I have a call I want to make in asp, and I do not care about the response. I just want to fire the call and I do not want the page to wait for the response. According to the documentation, it should look something like this: dim xmlhttp : set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.Open "POST", url, true '' setting the 'asynchronous' option to 'true' xmlhttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8" xmlhttp.setRequestHeader "Content-Length", Len(XMLData) xmlhttp.send XMLData This works peachy when calling synchronously, but when I flip the ansynchronous option to 'true', nothing fires. What I can gather from the internet is that users do something like the following: While xmlhttp.readyState <> 4 xmlhttp.waitForResponse 1000 Wend Am I crazy in that this does not really seem like an asynchrous call anymore though if you are waiting for a response? putting the line xmlhttp.waitForResponse 1 right after the send will cause the request to fire, but again, I don't want to wait a second. Any thoughts?

    Read the article

  • I am trying to move a rectangle in Pygame using coordinates but won't work

    - by user1821449
    this is my code import pygame from pygame.locals import * import sys pygame.init() pygame.display.set_caption("*no current mission*") size = (1280, 750) screen = pygame.display.set_mode(size) clock = pygame.time.Clock() bg = pygame.image.load("bg1.png") guy = pygame.image.load("hero_stand.png") rect = guy.get_rect() x = 10 y = 10 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == KEYDOWN: _if event.key == K_RIGHT: x += 5 rect.move(x,y)_ rect.move(x,y) screen.blit(bg,(0,0)) screen.blit(guy, rect) pygame.display.flip() it is just a simple test to see if i can get a rectangle to move. Everything seems to work except the code I put in italic.

    Read the article

  • reverse loop for date display

    - by Michael
    Hi, I've been trying to figure this out, and can't seem to get it Here is the code.. $m= date("m"); $de= date("d"); $y= date("Y"); for($i=0; $i<=6; $i++){ echo "<br>"; echo date('m/d',mktime(0,0,0,$m,($de+$i),$y)); echo "<br>"; } That displays this 04/08 04/07 04/06 04/05 04/04 04/03 04/02 That is exactly what I want but I want it to flip around so echos it would like this 04/02 04/03 04/04 04/05 04/06 04/07 04/07 How would I do this? Thank you in advance!

    Read the article

  • code duplication in sql case statements

    - by NS
    Hi I'm trying to output something like the following but am finding that there is a lot of code duplication going on. | australian_has_itch | kiwi_has_itch | | yes | no | | no | n/a | | n/a | no | ... My query looks like this with two case statements that do the same thing but flip the country (my real query has 5 of these case statements): SELECT CASE WHEN NOT EXISTS ( SELECT person_id FROM people_with_skin WHERE people_with_skin.person_id = people.person_id AND people.country = "Australia" ) THEN 'N/A' WHEN EXISTS ( SELECT person_id FROM itch_none_to_report WHERE people.country = "Australia" AND person_id = people.person_id ) THEN 'None to report' WHEN EXISTS ( SELECT person_id FROM itchy_people WHERE people.country = "Australia" AND person_id = people.person_id ) THEN 'Yes' ELSE 'No' END australian_has_itch, CASE WHEN NOT EXISTS ( SELECT person_id FROM people_with_skin WHERE people_with_skin.person_id = people.person_id AND people.country = "NZ" ) THEN 'N/A' WHEN EXISTS ( SELECT person_id FROM itch_none_to_report WHERE people.country = "NZ" AND person_id = people.person_id ) THEN 'None to report' WHEN EXISTS ( SELECT person_id FROM itchy_people WHERE people.country = "NZ" AND person_id = people.person_id ) THEN 'Yes' ELSE 'No' END kiwi_has_itch, FROM people Is there a way for me to condense this somehow and not have so much code duplication? Thanks!

    Read the article

  • How to handle right to left languages in Flash (pre version 10)?

    - by Maan Ashgar
    Hello, We are currently working with Flex creating a web application. We are having trouble taking Arabic text from the user and displaying correctly (like in a chat feature). While presumably Flash 10 will solve this problem, we don't want to force our users to upgrade. Flash flips the order of the sentence's words. so if I wrote something like "Hello World" in the text field, it will appear as "World Hello" in the chat area. Is there a standard way to work with Right to Left languages in Flash? *We currently flip the order of the words with a function, but it things get messed up when using English or special characters in the chat like :) or :D *

    Read the article

  • changing img src with JQuery but leave pathing info intact?

    - by Kevin Won
    I'm using JQuery to switch out an image src thusly: $("#myImg").attr("src", "../../new.gif"); notice the relative pathing on the new src. Unfortunately, this isn't portable when I deploy my app. In my MVC app I'm using a ResolveUrl() method that will fix the pathing problem for me so it's portable, but now my JQuery image src swapper doesn't work right since it now switches the correctly resolved path to a broken relative one. <img id="myImg" src="<%=ResolveUrl("~/Images/transparent.gif")%>" /> What I want is for JQuery to just flip the actual filename and leave the path untouched. My first thought would be to // pseudocode javascript jquery on my thought on how to approach this prob var oldFullPath = $('#myImg").GetTheImgSrc; var newFileNameWithPathIntact = someRegexAddNewFileNameWithOldPath $("#myImg").attr("src", newFileNameWithPathIntact); but that seems rather gross and un-JQuery to me. Anyone got a better way?

    Read the article

  • iphone: repeating a transformation

    - by gonso
    Hi I'm trying to represent a view that rotates on the iphone screen. I have a button and when you press it, the view rotates 180 degrees. My problem is that this only works the first time. Here is the code: -(IBAction) flip:(id)sender{ CGAffineTransform transform; //the transform matrix to be used below //BEGIN ANIMATIONS [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:2.0]; //animate if (flag){ transform = CGAffineTransformMakeRotation( RADIANS(180) ); } else { transform = CGAffineTransformMakeRotation( RADIANS(-180) ); } flag = !flag; transform = CGAffineTransformTranslate(transform, 0, 0); self.mySuview.transform = transform; //COMMIT ANIMATIONS [UIView commitAnimations]; } The first time you click, the view spins alright, but when you click again NOTHING happens. No errors, no changes on the view. What am I missing? Thanks Gonso

    Read the article

  • Rewriting a simple Pygame 2D drawing function in C++

    - by Dominic Bou-Samra
    I have a 2D list of vectors (say 20x20 / 400 points) and I am drawing these points on a screen like so: for row in grid: for point in row: pygame.draw.circle(window, white, (particle.x, particle.y), 2, 0) pygame.display.flip() #redraw the screen This works perfectly, however it's much slower then I expected. I want to rewrite this in C++ and hopefully learn some stuff (I am doing a unit on C++ atm, so it'll help) on the way. What's the easiest way to approach this? I have looked at Direct X, and have so far followed a bunch of tutorials and have drawn some rudimentary triangles. However I can't find a simple (draw point).

    Read the article

  • CALayer Sublayers Flipping

    - by user128647
    Hello All, How to Flip CALayer Sublayer. i have tried : CGFloat timeOffset = 0; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; CATransform3D transform = CATransform3DMakeRotation(M_PI/2, 0, 1, 0); animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; animation.toValue = [NSValue valueWithCATransform3D:transform]; animation.duration = 0.2; animation.beginTime = CACurrentMediaTime() + timeOffset; animation.fillMode = kCAFillModeBoth; animation.removedOnCompletion = NO; [selectedLayer addAnimation:animation forKey:nil]; timeOffset += 0.1; in this code selected layer is not flipping properly, Give me some suggestions. Thank you

    Read the article

  • problem while switching between Portrait and landscape in android views

    - by vnshetty
    In my application im going to display a web page in web view , it works fine but if i flip between landscape to portrait or vice versa, then it exits and comes to main page. wht is the prblm? logcat: 03-10 13:35:47.123: INFO/WindowManager(69): Setting rotation to 1, animFlags=1 03-10 13:35:47.242: INFO/ActivityManager(69): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/1 nav=3/1 orien=2 layout=17 uiMode=17 seq=70} 03-10 13:35:47.363: INFO/UsageStats(69): Unexpected resume of com.mireader while already resumed in com.mireader 03-10 13:35:50.413: DEBUG/dalvikvm(69): GC_EXPLICIT freed 395 objects / 20424 bytes in 195ms

    Read the article

  • How to change the icon in the title bar in R?

    - by Jared
    I just installed R 2.11.0-x64 onto my Windows 7 Professional machine. With my previous installations of R (2.10.1 32 bit was the most recent) the little icon that appeared in the title bar and in the taskbar at the bottom of windows was the R "R." Now however, the icon almost looks like a small windows Task Manager. I know this isn't a code issue, but it affects me as I flip between windows. Is there a way to put the "R" icon back in there? Would it be an R setting or a Windows setting?

    Read the article

  • unrecognized selector sent to instance

    - by iamsmug
    My app works fine in the simulator but when I run it on my phone I get this error: 2010-04-05 21:32:45.119 Top Banana[119:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[MethodViewController setReferringObject:]: unrecognized selector sent to instance 0x16e930' It happens here: -(void)method { [UIView beginAnimations:@"View Flip" context:nil]; [UIView setAnimationDuration:0.50]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; MethodViewController *methodViewController = [[MethodViewController alloc] initWithNibName:@"MethodViewController" bundle:0]; NSManagedObject *selectedObject = self.referringObject; methodViewController.referringObject = selectedObject; [self.navigationController pushViewController:methodViewController animated:NO]; methodViewController.title = @"Method"; [UIView commitAnimations]; [MethodViewController release]; } It crashes on this line: methodViewController.referringObject = selectedObject; Not sure how to resolve this as it works in the simulator, I'm sure it is fairly basic to fix, any help will be appreciated.

    Read the article

  • System("pause"); - Why is it wrong?

    - by Faken
    Here's a question that I don't quite understand: The command, System("pause"); is taught to new programmers as a way to pause a program and wait for a keyboard input to continue. However, it seems to be frowned on by many veteran programmers as something that should not be done in varying degrees. Some people say it is fine to use. Some say it is only to be used when you are locked in your room and no one is watching. Some say that they will personally come to your house and kill you if you use it. I, myself am a new programmer with no formal programming training. I use it because I was taught to use it. What I don't understand is that if it is not something to be used, then why was I taught to use it? Or, on the flip side, is it really not that bad after all? What are your thoughts on this subject?

    Read the article

  • LWJGL Circle program create's an oval-like shape

    - by N1ghtk1n9
    I'm trying to draw a circle in LWJGL, but when I draw I try to draw it, it makes a shape that's more like an oval rather than a circle. Also, when I change my circleVertexCount 350+, the shape like flips out. I'm really not sure how the code works that creates the vertices(I have taken Geometry and I know the basic trig ratios). I haven't really found that good of tutorials on creating circles. Here's my code: public class Circles { // Setup variables private int WIDTH = 800; private int HEIGHT = 600; private String title = "Circle"; private float fXOffset; private int vbo = 0; private int vao = 0; int circleVertexCount = 300; float[] vertexData = new float[(circleVertexCount + 1) * 4]; public Circles() { setupOpenGL(); setupQuad(); while (!Display.isCloseRequested()) { loop(); adjustVertexData(); Display.update(); Display.sync(60); } Display.destroy(); } public void setupOpenGL() { try { Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT)); Display.setTitle(title); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(-1); } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } public void setupQuad() { float r = 0.1f; float x; float y; float offSetX = 0f; float offSetY = 0f; double theta = 2.0 * Math.PI; vertexData[0] = (float) Math.sin(theta / circleVertexCount) * r + offSetX; vertexData[1] = (float) Math.cos(theta / circleVertexCount) * r + offSetY; for (int i = 2; i < 400; i += 2) { double angle = theta * i / circleVertexCount; x = (float) Math.cos(angle) * r; vertexData[i] = x + offSetX; } for (int i = 3; i < 404; i += 2) { double angle = Math.PI * 2 * i / circleVertexCount; y = (float) Math.sin(angle) * r; vertexData[i] = y + offSetY; } FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(vertexData.length); vertexBuffer.put(vertexData); vertexBuffer.flip(); vao = glGenVertexArrays(); glBindVertexArray(vao); vbo = glGenBuffers(); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER,vertexBuffer, GL_STATIC_DRAW); glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); } public void loop() { glClear(GL_COLOR_BUFFER_BIT); glBindVertexArray(vao); glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexData.length / 2); glDisableVertexAttribArray(0); glBindVertexArray(0); } public static void main(String[] args) { new Circles(); } private void adjustVertexData() { float newData[] = new float[vertexData.length]; System.arraycopy(vertexData, 0, newData, 0, vertexData.length); if(Keyboard.isKeyDown(Keyboard.KEY_W)) { fXOffset += 0.05f; } else if(Keyboard.isKeyDown(Keyboard.KEY_S)) { fXOffset -= 0.05f; } for(int i = 0; i < vertexData.length; i += 2) { newData[i] += fXOffset; } FloatBuffer newDataBuffer = BufferUtils.createFloatBuffer(newData.length); newDataBuffer.put(newData); newDataBuffer.flip(); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferSubData(GL_ARRAY_BUFFER, 0, newDataBuffer); glBindBuffer(GL_ARRAY_BUFFER, 0); } } 300 Vertex Count(This is my main problem) 400 Vertex Count - I removed this image, it's bugged out, should be a tiny sliver cut out from the right, like a secant 500 Vertex Count Each 100, it removes more and more of the circle, and so on.

    Read the article

  • Question about domain models & their visibility...

    - by Another SO User
    I was involved in an interesting debate about the visibility of domain models & was wondering if people here have any good guidance. Per my understanding of MDA, we need not expose the domain model throughout the application layers & tiers The reason being that any change to the domain model has an impact in the overall application The wise thing to do would be to expose light-weight object (DTO's) which are a small sub-set of the domain model to abstract the actual model On the flip side, any change to the domain model would mean changing various DTO's throughout the application for the change to be visible, while if we do expose the domain model, then the change is in a single location Hope to see some comments & thoughts about this. Appreciate all the help!

    Read the article

  • Need a Javascript Expert, IE slow script

    - by Aaron Carlino
    I have a jQuery plugin running on my site that is executing very, very slowly in IE7/8 to the point that it throws a slow script warning to the user. It doesn't happen in any other browser, and I can't figure out what might be going on. If you go to this page: http://dev.xeetic.org/projects You'll see that there are 16 results on each page, and each one has a "flip" behavior attached, using the jQuery plugin "quickflip." Attaching this behavior is very slow in IE. If I reduce the result set to 8 or 4 per page, it's faster, but still very bogged down. I have contacted the author of the script with no success. I am willing to pay for a solution, if I'm allowed to offer such a thing on this site. Very desperate. Please help!

    Read the article

  • How to create an iPad directory view like animation?

    - by mahes25
    In the recent iOS 4.2 update, Apple introduced a nice animation for creating one level directories. I am trying to figure out how to implement a similar animation in my project. I would deeply appreciate it if anyone could give me any pointers to do this efficiently. From my investigation, I believe this animation or effect could be done very efficiently using Core Image which would allow me to write a custom filter. Unfortunately, Core Image is not available in iPhone. So how can do it? I read a blog post that explained a core animation scheme to create an iPad flip clock. The problem I have is similar but has important differences. Besides, I not excited about saving the subimage combinations, which I believe can cause a memory issue. Please enlighten me on the possible ways of doing this animation. I am relatively new to iOS programming, so I might have missed obvious ways of doing this animation or effect.

    Read the article

  • Animation on single UIWebView

    - by Shri
    I have searched quite a bit(sample one, Sample two) but cant seem to get the correct answer. I have a webview on my XYZ view controller class. When i press on a button, it takes an URL from an array and re-loads the same webview. Now I need to do the flip book animation on it. Same webview should be reloaded. That is the webview should rotate around its own axis 180/360 degree while the loading of next url is going on. Is this possible?

    Read the article

  • How to join 2 tables & display them correctly?

    - by steven
    http://img293.imageshack.us/img293/857/tablez.jpg Here is a picture of the 2 tables. The mybb_users table is the table that has the users that signed up for the forum. The mybb_userfields is the table that contain custom profile field data that they are able to customize & change in their profile. Now, all I want to do is display all users in rows with the custom profile field data that they provided in their profile(which is in the mybb_userfields table) How can I display these fields correctly together? For instance, p0gz is a male,lives in AZ,he owns a 360,does not know his bandwidth & Flip Side Phoenix is his team. How can it just be like "p0gz-male-az-360-dont know-flipside phoenix" in a row~???

    Read the article

  • How to implement a book preview (2 page spread) without using Flash?

    - by littlejim84
    I'm looking into a solution for work, where you have a two page spread of the book to preview. Either side of this, you can hover in the corner to create a pseudo-flip and then click the mouse button to actually turn the page. I know there is many Flash solutions out there, but in this case we cannot use it... So we are looking for a possible solution that can work across all major browsers (yes, including IE6)... I looked a few canvas solutions, but with Google's canvas extension for IE, these will terribly slow. So was thinking about an SVG/VML solution, like Raphael Javascript library. This could be good, but then trying to look into how to code this, without examples, could be a challenge with the time constraint. Is there a solution out there that fits (or almost fits) this problem?

    Read the article

  • "Othello" game needs some clarification

    - by pappu
    I am trying to see if my understanding of "othello" fame is correct or not. According to the rules, we flip the dark/light sides if we get some sequence like X000X = XXXXX. The question I have is if in the process of flipping 0-X or X- 0, do we also need to consider the rows/columns/diagonals of newly flipped elements? e.g. consider board state as shown in above image(New element X is placed @ 2,3) When we update board, we mark elements from 2,3 to 6,3 as Xs but in this process elements like horizontal 4,3 to 4,5 and diagonal 2,3 to 4,5 are also eligible for update? so do we update those elements as well? or just the elements which have starting as 2,3 (i.e update rows/column/diagonal whose starting point is the element we are dealing with, in our case 2,3?) Please help me understand it

    Read the article

  • How is this website fixing the encoding ??

    - by Tal Galili
    Hi all, I am trying to turn this text: ×וויר. העתיד של רשתות חברתיות והתקשורת ×©×œ× ×• Into this text: ?????. ????? ?? ????? ??????? ???????? ???? Somehow, this website: http://www.pixiesoft.com/flip/ Can do it, and I would like to know how I might be able to do it myself (with whatever programming language or software) Just saving the file as UTF8 won't do it. My motivation for this question is that I have a friend's exported XML file with the garbled text which I want to turn into corrected Hebrew text file. The XML export was originally garbled by MySQL import and exports, but I don't have the information needed to fix it or traceback the problem. Thanks.

    Read the article

  • Forcing Reload of View when returning from FlipSideView of Utility Application

    - by Chris McCall
    I've got a Utility Application for iPhone 3.1.3. I have my main view loading fine. I flip over to the flipside view of the utility app and change some settings. How can I call the code I've currently got in viewDidLoad in the main view to refresh it, as settings have changed? Do I create a public method and call it from the viewDidUnload method of the flipside view? Do I call viewDidLoad directly? What's the best way to do this?

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >