Daily Archives

Articles indexed Wednesday December 12 2012

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

  • How do I analyze vague Google Analytics data re traffic from Facebook?

    - by user6982
    We have one Facebook fan page and two personal profiles that could be sending traffic and then there are the many facebook pages of friends etc. I am also running an ad campaign from my FB account for my husband's business which has a link from his personal FB profile and his fan page. On Google analytics for his business we get the following referring sites from Facebook: /ajax/emu/end.php which is listed under facebook.com / referral /l.php (which is a not-found page at FB /ajax/emu/end.php which is listed under apps.facebook.com Both of the working links send me to the home page of my profile, which is the account I am working from to create and review the FB ad campaign that we are running. Is this info telling me any useful information at all? Is there a best practice for tracking and analyzing Facebook traffic that is a lot more granular? thanks!

    Read the article

  • Calculate gears rotation for a realtime simulation

    - by nkint
    Hi I'm trying to do a game with real time simulations of gears. There is a big Gear with inside a smaller gear. I managed to draw gears with different diameters but equal size teeth, but if i try to move the smaller one inside the bigger one the movement is odd. see the animated gif. the biggest gear is in center C1 and the small in the center C2. I calculate C2 position in this way: C2.x = C1.x + C1_RADIUS-C2_RADIUS) * cos(t); C2.y = C1.y - C1_RADIUS-C2_RADIUS) * sin(t); for t that goes from 0 to TWO_PI in n steps. I apply as rotation the angle t, but maybe it is wrong and i have to calculate another rotation for get a perfect joint

    Read the article

  • Steering evaluate fitness

    - by Vodemki
    I've made a simple game with a steering model that manage a crowd of agents. I use an genetic algorithm to find the best parameters to use in my system but I need to determine a fitness for each simulation. I know it's something like that: number of collisions * time to reach goal * effort But I don't know how to calculate the effort, is there a special way to do that ? Here is what I've done so far: // Evaluate the distance from agents to goal Real totalDistance(0.0); for (unsigned i=0; i<_agents.size(); i++) { totalDistance += _agents[i]->position().distance(_agents[i]->_goal->position()); } Real totalWallsCollision(0.0); for (unsigned i=0; i<_agents.size(); i++) { for (unsigned j=0; j<walls.size(); j++) { if ( walls[j]->inside(_agents[i]->position()) ) { totalCollision += 1.0; } } } return totalDistance + totalWallsCollision; Thanks for your help.

    Read the article

  • Remove enemy when bullet hits enemy

    - by jordi12100
    For my education I have to make a basic game in HTML5 canvas. The game is a shooter game. When you can move left - right and space is shoot. When I shoot the bullets will move up. The enemy moves down. When the bullet hits the enemy the enemy has to dissapear and it will gain +1 score. But the enemy will dissapear after it comes up the screen. Demo: http://jordikroon.nl/test.html space = shoot + enemy shows up This is my code: for (i=0;i<enemyX.length;i++) { if(enemyX[i] > canvas.height) { enemyY.splice(i,1); enemyX.splice(i,1); } else { enemyY[i] += 5; moveEnemy(enemyX[i],enemyY[i]); } } for (i=0;i<bulletX.length;i++) { if(bulletY[i] < 0) { bulletY.splice(i,1); bulletX.splice(i,1); } else { bulletY[i] -= 5; moveBullet(bulletX[i],bulletY[i]); for (ib=0;ib<enemyX.length;ib++) { if(bulletX[i] + 50 < enemyX[ib] || enemyX[ib] + 50 < bulletX[i] || bulletY[i] + 50 < enemyY[ib] || enemyY[ib] + 50 < bulletY[i]) { ++score; enemyY.splice(i,1); enemyX.splice(i,1); } } } } Objects: function moveBullet(posX,posY) { //console.log(posY); ctx.arc(posX, (posY-150), 10, 0 , 2 * Math.PI, false); } function moveEnemy(posX,posY) { ctx.rect(posX, posY, 50, 50); ctx.fillStyle = '#ffffff'; ctx.fill(); }

    Read the article

  • Unity3D draw call optimization : static batching VS manually draw mesh with MaterialPropertyBlock

    - by Heisenbug
    I've read Unity3D draw call batching documentation. I understood it, and I want to use it (or something similar) in order to optimize my application. My situation is the following: I'm drawing hundreds of 3d buildings. Each building can be represented using a Mesh (or a SubMesh for each building, but I don't thing this will affect performances) Each building can be textured with several combinations of texture patterns(walls, windows,..). Textures are stored into an Atlas for optimizaztion (see Texture2d.PackTextures) Texture mapping and facade pattern generation is done in fragment shader. The shader can be the same (except for few values) for all buildings, so I'd like to use a sharedMaterial in order to optimize parameters passed to the GPU. The main problem is that, even if I use an Atlas, share the material, and declare the objects as static to use static batching, there are few parameters(very fews, it could be just even a float I guess) that should be different for every draw call. I don't know exactly how to manage this situation using Unity3D. I'm trying 2 different solutions, none of them completely implemented. Solution 1 Build a GameObject for each building building (I don't like very much the overhead of a GameObject, anyway..) Prepare each GameObject to be static batched with StaticBatchingUtility.Combine. Pack all texture into an atlas Assign the parent game object of combined batched objects the Material (basically the shader and the atlas) Change some properties in the material before drawing an Object The problem is the point 5. Let's say I have to assign a different id to an object before drawing it, how can I do this? If I use a different material for each object I can't benefit of static batching. If I use a sharedMaterial and I modify a material property, all GameObjects will reference the same modified variable Solution 2 Build a Mesh for every building (sounds better, no GameObject overhead) Pack all textures into an Atlas Draw each mesh manually using Graphics.DrawMesh Customize each DrawMesh call using a MaterialPropertyBlock This would solve the issue related to slightly modify material properties for each draw call, but the documentation isn't clear on the following point: Does several consecutive calls to Graphic.DrawMesh with a different MaterialPropertyBlock would cause a new material to be instanced? Or Unity can understand that I'm modifying just few parameters while using the same material and is able to optimize that (in such a way that the big atlas is passed just once to the GPU)?

    Read the article

  • forward motion car physics - gradual slow

    - by spartan2417
    Im having trouble creating realistic car movements in xna 4. Right now i have a car going forward and hitting a terminal velocity which is fine but when i release the up key i need to the car to slow down gradually and then come to a stop. Im pretty sure this is easy code but i cant seem to get it to work the code - update if (Keyboard.GetState().IsKeyDown(Keys.Up)) { double elapsedTime = gameTime.ElapsedGameTime.Milliseconds; CalcTotalForce(); Acceleration = Vector2.Divide(CalcTotalForce(), MASS); Velocity = Vector2.Add(Velocity, Vector2.Multiply(Acceleration, (float)(elapsedTime))); Position = Vector2.Add(Position, Vector2.Multiply(Velocity, (float)(elapsedTime))); } added functions public Vector2 CalcTraction() { //Traction force = vector direction * engine force return Vector2.Multiply(forwardDirection, ENGINE_FORCE); } public Vector2 CalcDrag() { //Drag force = constdrag * velocity * speed return Vector2.Multiply(Vector2.Multiply(Velocity, DRAG_CONST), Velocity.Y); } public Vector2 CalcRoll() { //roll force = const roll * velocity return Vector2.Multiply(Velocity, ROLL_CONST); } public Vector2 CalcTotalForce() { //total force = traction + (-drag) + (-rolling) return Vector2.Add(CalcTraction(), Vector2.Add(-CalcDrag(), -CalcRoll())); } anyone have any ideas?

    Read the article

  • Improving SpriteBatch performance for tiles

    - by Richard Rast
    I realize this is a variation on what has got to be a common question, but after reading several (good answers) I'm no closer to a solution here. So here's my situation: I'm making a 2D game which has (among some other things) a tiled world, and so, drawing this world implies drawing a jillion tiles each frame (depending on resolution: it's roughly a 64x32 tile with some transparency). Now I want the user to be able to maximize the game (or fullscreen mode, actually, as its a bit more efficient) and instead of scaling textures (bleagh) this will just allow lots and lots of tiles to be shown at once. Which is great! But it turns out this makes upward of 2000 tiles on the screen each time, and this is framerate-limiting (I've commented out enough other parts of the game to make sure this is the bottleneck). It gets worse if I use multiple source rectangles on the same texture (I use a tilesheet; I believe changing textures entirely makes things worse), or if you tint the tiles, or whatever. So, the general question is this: What are some general methods for improving the drawing of thousands of repetitive sprites? Answers pertaining to XNA's SpriteBatch would be helpful but I'm equally happy with general theory. Also, any tricks pertaining to this situation in particular (drawing a tiled world efficiently) are also welcome. I really do want to draw all of them, though, and I need the SpriteMode.BackToFront to be active, because

    Read the article

  • How do I cap rendering of tiles in a 2D game with SDL?

    - by farmdve
    I have some boilerplate code working, I basically have a tile based map composed of just 3 colors, and some walls and render with SDL. The tiles are in a bmp file, but each tile inside it corresponds to an internal number of the type of tile(color, or wall). I have pretty basic collision detection and it works, I can also detetc continuous presses, which allows me to move pretty much anywhere I want. I also have a moving camera, which follows the object. The problem is that, the tile based map is bigger than the resolution, thus not all of the map can be displayed on the screen, but it's still rendered. I would like to cap it, but since this is new to me, I pretty much have no idea. Although I cannot post all the code, as even though I am a newbie and the code pretty basic, it's already quite a few lines, I can post what I tried to do void set_camera() { //Center the camera over the dot camera.x = ( player.box.x + DOT_WIDTH / 2 ) - SCREEN_WIDTH / 2; camera.y = ( player.box.y + DOT_HEIGHT / 2 ) - SCREEN_HEIGHT / 2; //Keep the camera in bounds. if(camera.x < 0 ) { camera.x = 0; } if(camera.y < 0 ) { camera.y = 0; } if(camera.x > LEVEL_WIDTH - camera.w ) { camera.x = LEVEL_WIDTH - camera.w; } if(camera.y > LEVEL_HEIGHT - camera.h ) { camera.y = LEVEL_HEIGHT - camera.h; } } set_camera() is the function which calculates the camera position based on the player's positions. I won't pretend I know much about it. Rectangle box = {0,0,0,0}; for(int t = 0; t < TOTAL_TILES; t++) { if(box.x < (camera.x - TILE_WIDTH) || box.y > (camera.y - TILE_HEIGHT)) apply_surface(box.x - camera.x, box.y - camera.y, surface, screen, &clips[tiles[t]]); box.x += TILE_WIDTH; //If we've gone too far if(box.x >= LEVEL_WIDTH) { //Move back box.x = 0; //Move to the next row box.y += TILE_HEIGHT; } } This is basically my render code. The for loop loops over 192 tiles stored in an int array, each with their own unique value describing the tile type(wall or one of three possible colored tiles). box is an SDL_Rect containing the current position of the tile, which is calculated on render. TILE_HEIGHT and TILE_WIDTH are of value 80. So the cap is determined by if(box.x < (camera.x - TILE_WIDTH) || box.y > (camera.y - TILE_HEIGHT)) However, this is just me playing with the values and see what doesn't break it. I pretty much have no idea how to calculate it. My screen resolution is 1024/768, and the tile map is of size 1280/960.

    Read the article

  • Moving sprites on a graph in libGDX

    - by nosferat
    In my game I'd like to move sprites on a fixed path. Until this point I was trying to stick with the tools already provided by libGDX, like the Tiled map renderer classes so I'm looking for a solution nearly as convenient as that, e.g. I'd like to avoid creating the adjacency matrix by hand. Tiled has the functionality to add objects to the map but I'm not sure if I can use it for this purpose. Any idea?

    Read the article

  • Clutter for game GUI

    - by tjameson
    I'm pretty new to game development, having only written a simple 3d game for a class project, but I'd like to get started on a bigger project. I'm writing an MMORPG to run in both the browser (WebGL) and natively (OpenGL ES 2). In choosing a GUI toolkit, I'm trying to find a style that work work natively and would be simple to emulate in WebGL. I am considering using D or Go for writing my game, so interfacing with C++ libraries will be difficult, if not impossible. Of course, the language isn't the end goal here, so if using C++ will save considerable time, I'll bite the bullet and use that. In order to reduce the amount of code I'll have to write for the browser, I'm considering using something simple like Clutter for basic abstractions, which I think will be pretty easy to emulate (layered canvases maybe?). Does anyone have experience using Clutter for a 3d game? Note: I haven't used any game development libraries, and I only have limited experience with GUI libraries. I do have HTML+CSS experience, so maybe librocket is a viable solution?

    Read the article

  • Understanding math used to determine if vector is clockwise / counterclockwise from your vector

    - by MTLPhil
    I'm reading Programming Game AI by Example by Mat Buckland. In the Math & Physics primer chapter there's a listing of the declaration of a class used to represent 2D vectors. This class contains a method called Sign. It's implementation is as follows //------------------------ Sign ------------------------------------------ // // returns positive if v2 is clockwise of this vector, // minus if anticlockwise (Y axis pointing down, X axis to right) //------------------------------------------------------------------------ enum {clockwise = 1, anticlockwise = -1}; inline int Vector2D::Sign(const Vector2D& v2)const { if (y*v2.x > x*v2.y) { return anticlockwise; } else { return clockwise; } } Can someone explain the vector rules that make this hold true? What do the values of y*v2.x and x*v2.y that are being compared actually represent? I'd like to have a solid understanding of why this works rather than just accepting that it does without figuring it out. I feel like it's something really obvious that I'm just not catching on to. Thanks for your help.

    Read the article

  • Rule of thumb for enemy art design in 2D platformer

    - by Terrance
    I'm at the early stages of developing a 2D side scrolling open ended platformer (think Metroidvania) and am having a bit of difficulty at enemy design inspiration for something of a scifi, nature, fantasy setting that isn't overly familar or obvious. I haven't seen too many articles, blogs or books that talk about the subject at great length. Is there a fair rule of thumb when coming up with enemy art with respect to keeping your player engaged?

    Read the article

  • Call REST service while impersonating a user that is already authorized to the glasfish server

    - by user1894489
    There are two web-applications deployed on a glassfish server. Both web applications provide a REST web service. the access to both web-services is secured via glassfish security constraints (at the moment BASIC Auth and file-realm). Let's say a user is accessing the service of web application A. After he is authorized, service A wants to call service B via REST client. Is there a way for a service to impersonate a user that is already authorized to the glasfish server? Maybe something like forwarding the security context or editing the headers? Is there another Filter? @Context private SecurityContext securityContext; username = securityContext.getUserPrincipal().getName(); password = ??? client.addFilter(new com.sun.jersey.api.client.filter.HTTPBasicAuthFilter(username, password)); Thanks!

    Read the article

  • extjs4 display tooltip on button click instead of mouse hover

    - by user856753
    I am trying to add a on click listener to the below tooltip. I do not want the tooltip to display on mouse hover. Instead it need it show on button click. Do I have to add a handler function inside a listener? { xtype: 'button', cls:'my-btn', iconCls:'question', src:'../www/css/slate/btn/question.png', padding: '5 0 0 0', listeners: { render: function(cmp) { Ext.create('Ext.tip.ToolTip', { closable:true, hideDelay : 3000, padding: '0 0 0 0', maxWidth:400, width:800, target: cmp.el, html: "<b>read-only</b>:Users will have read only access to all pages", getTargetXY: function() { return [810, 340]; } }); } } },

    Read the article

  • Using SQL dB column as a lock for concurrent operations in Entity Framework

    - by Sid
    We have a long running user operation that is handled by a pool of worker processes. Data input and output is from Azure SQL. The master Azure SQL table structure columns are approximated to [UserId, col1, col2, ... , col N, beingProcessed, lastTimeProcessed ] beingProcessed is boolean and lastTimeProcessed is DateTime. The logic in every worker role is: public void WorkerRoleMain() { while(true) { try { dbContext db = new dbContext(); // Read foreach (UserProfile user in db.UserProfile .Where(u => DateTime.UtcNow.Subtract(u.lastTimeProcessed) > TimeSpan.FromHours(24) & u.beingProcessed == false)) { user.beingProcessed = true; // Modify db.SaveChanges(); // Write // Do some long drawn processing here ... ... ... user.lastTimeProcessed = DateTime.UtcNow; user.beingProcessed = false; db.SaveChanges(); } } catch(Exception ex) { LogException(ex); Sleep(TimeSpan.FromMinutes(5)); } } // while () } With multiple workers processing as above (each with their own Entity Framework layer), in essence beingProcessed is being used a lock for MutEx purposes Question: How can I deal with concurrency issues on the beingProcessed "lock" itself based on the above load? I think read-modify-write operation on the beingProcessed needs to be atomic but I'm open to other strategies. Open to other code refinements too.

    Read the article

  • matplotlib and python multithread file processing

    - by Napseis
    I have a large number of files to process. I have written a script that get, sort and plot the datas I want. So far, so good. I have tested it and it gives the desired result. Then I wanted to do this using multithreading. I have looked into the doc and examples on the internet, and using one thread in my program works fine. But when I use more, at some point I get random matplotlib error, and I suspect some conflict there, even though I use a function with names for the plots, and iI can't see where the problem could be. Here is the whole script should you need more comment, i'll add them. Thank you. #!/usr/bin/python import matplotlib matplotlib.use('GTKAgg') import numpy as np from scipy.interpolate import griddata import matplotlib.pyplot as plt import matplotlib.colors as mcl from matplotlib import rc #for latex import time as tm import sys import threading import Queue #queue in 3.2 and Queue in 2.7 ! import pdb #the debugger rc('text', usetex=True)#for latex map=0 #initialize the map index. It will be use to index the array like this: array[map,[x,y]] time=np.zeros(1) #an array to store the time middle_h=np.zeros((0,3)) #x phi c #for the middle of the box current_file=open("single_void_cyl_periodic_phi_c_middle_h_out",'r') for line in current_file: if line.startswith('# === time'): map+=1 np.append(time,[float(line.strip('# === time '))]) elif line.startswith('#'): pass else: v=np.fromstring(line,dtype=float,sep=' ') middle_h=np.vstack( (middle_h,v[[1,3,4]]) ) current_file.close() middle_h=middle_h.reshape((map,-1,3)) #3d array: map, x, phi,c ##### def load_and_plot(): #will load a map file, and plot it along with the corresponding profile loaded before while not exit_flag: print("fecthing work ...") #try: if not tasks_queue.empty(): map_index=tasks_queue.get() print("----> working on map: %s" %map_index) x,y,zp=np.loadtxt("single_void_cyl_growth_periodic_post_map_"+str(map_index),unpack=True, usecols=[1, 2,3]) for i,el in enumerate(zp): if el<0.: zp[i]=0. xv=np.unique(x) yv=np.unique(y) X,Y= np.meshgrid(xv,yv) Z = griddata((x, y), zp, (X, Y),method='nearest') figure=plt.figure(num=map_index,figsize=(14, 8)) ax1=plt.subplot2grid((2,2),(0,0)) ax1.plot(middle_h[map_index,:,0],middle_h[map_index,:,1],'*b') ax1.grid(True) ax1.axis([-15, 15, 0, 1]) ax1.set_title('Profiles') ax1.set_ylabel(r'$\phi$') ax1.set_xlabel('x') ax2=plt.subplot2grid((2,2),(1,0)) ax2.plot(middle_h[map_index,:,0],middle_h[map_index,:,2],'*r') ax2.grid(True) ax2.axis([-15, 15, 0, 1]) ax2.set_ylabel('c') ax2.set_xlabel('x') ax3=plt.subplot2grid((2,2),(0,1),rowspan=2,aspect='equal') sub_contour=ax3.contourf(X,Y,Z,np.linspace(0,1,11),vmin=0.) figure.colorbar(sub_contour,ax=ax3) figure.savefig('single_void_cyl_'+str(map_index)+'.png') plt.close(map_index) tasks_queue.task_done() else: print("nothing left to do, other threads finishing,sleeping 2 seconds...") tm.sleep(2) # except: # print("failed this time: %s" %map_index+". Sleeping 2 seconds") # tm.sleep(2) ##### exit_flag=0 nb_threads=2 tasks_queue=Queue.Queue() threads_list=[] jobs=list(range(map)) #each job is composed of a map print("inserting jobs in the queue...") for job in jobs: tasks_queue.put(job) print("done") #launch the threads for i in range(nb_threads): working_bee=threading.Thread(target=load_and_plot) working_bee.daemon=True print("starting thread "+str(i)+' ...') threads_list.append(working_bee) working_bee.start() #wait for all tasks to be treated tasks_queue.join() #flip the flag, so the threads know it's time to stop exit_flag=1 for t in threads_list: print("waiting for threads %s to stop..."%t) t.join() print("all threads stopped")

    Read the article

  • send email notifications to entrants of my contest form using php

    - by Zeljko Radic
    I am really stuck with the following issue and your assistance would be appreciated. Here is the deal. I have a contest form at http://www.beogradstore.com/mn/contest/main-contest/. Btw, I use WordPress contest domination plugin. So I want entrants of the contest to receive email notifications whenever they receive reward entries. After they enter the contest, they will receive referral link, which they can share online and whenever someone enters the contest with that referral link, the owner of the referral link will receive 10 new contest entries. What would be the easiest way to accomplish this?

    Read the article

  • gcc compilations (sometimes) result in cpu underload

    - by confusedCoder
    I have a larger C++ program which starts out by reading thousands of small text files into memory and storing data in stl containers. This takes about a minute. Periodically, a compilation will exhibit behavior where that initial part of the program will run at about 22-23% CPU load. Once that step is over, it goes back to ~100% CPU. It is more likely to happen with O2 flag turned on but not consistently. It happens even less often with the -p flag which makes it almost impossible to profile. I did capture it once but the gprof output wasn't helpful - everything runs with the same relative speed just at low cpu usage. I am quite certain that this has nothing to do with multiple cores. I do have a quad-core cpu, and most of the code is multi-threaded, but I tested this issue running a single thread. Also, when I run the problematic step in multiple threads, each thread only runs at ~20% CPU. I apologize ahead of time for the vagueness of the question but I have run out of ideas as to how to troubleshoot it further, so any hints might be helpful. UPDATE: Just to make sure it's clear, the problematic part of the code does sometimes (~30-40% of the compilations) run at 100% CPU, so it's hard to buy the (otherwise reasonable) argument that I/O is the bottleneck

    Read the article

  • php -Merging an Array

    - by Vidhu Shresth Bhatnagar
    I have two array which i want to merge in a specific way in php. So i need your help in helping me with it as i tried and failed. So say i have two arrays: $array1= array( "foo" => 3, "bar" => 2, "random1" => 4, ); $array2= array( "random2" => 3, "random3" => 4, "foo" => 6, ); Now when during merging i would like the common key's values to be added. So like foo exists in array1 and in array2 so when merging array1 with array 2 i should get "foo" => "9" I better illustration would be the final array which looks like this: $array1= array( "foo" => 9, "bar" => 2, "random1" => 4, "random2" => 3, "random3" => 4, ); So again i would like the values of the common keys to be added together and non common keys to be added to array or a new array I hope i was clear enough Thanks, Vidhu

    Read the article

  • Using custom HTML attributes for JavaScript purposes?

    - by user1103990
    One of my colleagues doesn't like to use HTML classes and ids for javascript/jQuery purpose. Therefore I've seen that he had created custom html attribute such as <div id="myid" class="cssClasses ..." [some-purpose-id]="mycustomId">...</div> I asked him if it was really a good idea and he replied that he considers that classes and Ids should be reserved for styling. Personally, I would have used classes. Some classes would have been used for styling, and some other classes would have been used for programming (jQuery selectors). The idea is to keep things appart also. And of course jQuery could set styling classes but if possible not use them for selection. Of course I also use id when appropriate but since an id is unique on a page, I like to do generic stuff using classes. I would like to know you opinions on the better approach (if there is one). Thank you.

    Read the article

  • jQuery and array of objects

    - by sepoto
    $(document).ready(function () { output = ""; $.ajax({ url: 'getevents.php', data: { ufirstname: 'ufirstname' }, type: 'post', success: function (output) { alert(output); var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,basicWeek,basicDay' }, editable: true, events: output }); } }); }); I have code like this and if I copy the text verbatim out of my alert box and replace events: output with events: [{ id: 1, title: 'Birthday', start: new Date(1355011200*1000), end: new Date(1355011200*1000), allDay: true, url: 'http://www.yahoo.com/'},{ id: 2, title: 'Birthday Hangover', start: new Date(1355097600*1000), end: new Date(1355097600*1000), allDay: false, url: 'http://www.yahoo.com'},{ id: 3, title: 'Sepotomus Maximus Christmas', start: new Date(1356393600*1000), end: new Date(1356393600*1000), allDay: false, url: 'http://www.yahoo.com/'},] Everything works just fine. What can I do to fix this problem? I though that using events: output would place the text in that location but it does not seem to be working. Thank you all kindly in advance for any comments or answers!

    Read the article

  • Ajax success function firing before java class responds

    - by user1899281
    I am creating a login function with ajax and am having an issue where the success function (SuccessLogin) fires before getting an ajax response. I am running the code as google web app from eclipse and I can see when debugging the java class file, that the javascript is throwing an alert for the success response from the class being false before the debugger catches the break point in the class file. I have only been writing code for a couple months now so I am sure its a stupid little error on my part. $(document).ready(function() { sessionChecker() // sign in $('#signInForm').click(function () { $().button('loading') var email = $('#user_username').val(); sessionStorage.email = $('#user_username').val(); var password= $('#user_password').val(); var SignInRequest = { type: "UserLoginRequest", email: email, password: password } var data= JSON.stringify(SignInRequest); //disabled all the text fields $('.text').attr('disabled','true'); //start the ajax $.ajax({ url: "/resources/user/login", type: "POST", data: data, cache: false, success: successLogin(data) }); }); //if submit button is clicked $('#Register').click(function () { $().button('loading') var email = $('#email').val(); if ($('#InputPassword').val()== $('#ConfirmPassword').val()) { var password= $('input[id=InputPassword]').val(); } else {alert("Passwords do not match"); return ;} var UserRegistrationRequest = { type: "UserRegistrationRequest", email: email, password: password } var data= JSON.stringify(UserRegistrationRequest); //disabled all the text fields $('.text').attr('disabled','true'); //start the ajax $.ajax({ url: "/resources/user/register", type: "POST", data: data, cache: false, success: function (data) { if (data.success==true) { //hide the form $('form').fadeOut('slow'); //show the success message $('.done').fadeIn('slow'); } else alert('data.errorReason'); } }); return false; }); }); function successLogin (data){ if (data.success) { sessionStorage.userID= data.userID var userID = data.userID sessionChecker(userID); } else alert(data.errorReason); } //session check function sessionChecker(uid) { if (sessionStorage.userID!= null){ var userID = sessionStorage.userID }; if (userID != null){ $('#user').append(userID) $('#fat-menu_1').fadeOut('slow') $('#fat-menu_2').append(sessionStorage.email).fadeIn('slow') }; }

    Read the article

  • Java Runtime.freeMemory() returning bizarre results when adding more objects

    - by Sotirios Delimanolis
    For whatever reason, I wanted to see how many objects I could create and populate a LinkedList with. I used Runtime.getRuntime().freeMemory() to get the approximation of free memory in my JVM. I wrote this: public static void main(String[] arg) { Scanner kb = new Scanner(System.in); List<Long> mem = new LinkedList<Long>(); while (true) { System.out.println("Max memory: " + Runtime.getRuntime().maxMemory() + ". Available memory: " + Runtime.getRuntime().freeMemory() + " bytes. Press enter to use more."); String s = kb.nextLine(); if (s.equals("m")) for (int i = 0; i < 1000000; i++) { mem.add(new Long((new Random()).nextLong())); } } } If I write in m, the app adds a million Long objects to the list. You would think the more objects (to which we have references, so can't be gc'ed), the less free memory. Running the code: Max memory: 1897725952. Available memory: 127257696 bytes. m Max memory: 1897725952. Available memory: 108426520 bytes. m Max memory: 1897725952. Available memory: 139873296 bytes. m Max memory: 1897725952. Available memory: 210632232 bytes. m Max memory: 1897725952. Available memory: 137268792 bytes. m Max memory: 1897725952. Available memory: 239504784 bytes. m Max memory: 1897725952. Available memory: 169507792 bytes. m Max memory: 1897725952. Available memory: 259686128 bytes. m Max memory: 1897725952. Available memory: 189293488 bytes. m Max memory: 1897725952. Available memory: 387686544 bytes. The available memory fluctuates. How does this happen? Is the GC cleaning up other things (what other things are there on the heap to really clean up?), is the freeMemory() method returning an approximation that's way off? Am I missing something or am I crazy?

    Read the article

  • Some optimization about the code (computing ranks of a vector)?

    - by user1748356
    The following code is a function (performance-critical) to compute tied ranks of a vector: mergeSort(x,inds,ci); //a sort function to sort vector x of length ci, also returns keys (inds) of x. int tj=0; double xi=x[0]; for (int j = 1; j < ci; ++j) { if (x[j] > xi) { double rankvalue = 0.5 * (j - 1 + tj); for (int k = tj; k < j; ++k) { ranks[inds[k]]=rankvalue; }; tj = j; xi = x[j]; }; }; double rankvalue = 0.5 * (ci - 1 + tj); for (int k = tj; k < ci; ++k) { ranks[inds[k]]=rankvalue; }; The problem is, the supposed performance bottleneck mergeSort(), which is O(NlogN) is several times faster than the other part of codes (which is O(N)), which suggests there is room for huge improvment with the other part of the codes, any advices?

    Read the article

  • What is the relationship between recursion functions and memory stack?

    - by Eslam
    is there's a direct relationship between recursive functions and the memory stack, for more explanation consider that code: public static int triangle(int n) { System.out.println(“Entering: n = ” + n); if (n == 1) { System.out.println(“Returning 1”); return 1; } else { int temp = n + triangle(n - 1); System.out.println(“Returning“ + temp); return temp; } }? in this example where will the values 2,3,4,5 be stored until the function returns ? note that they will be returned in LIFO(LastInFirstOut) is these a special case of recursion that deals with the memory stack or they always goes together?

    Read the article

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