Daily Archives

Articles indexed Tuesday June 19 2012

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

  • IIS 6 nested virtual directory redirection

    - by threedaysatsea
    We're running IIS 6 on a WinServer2k3 box and we're having some trouble with the following problem: E-mails were sent out to users asking them to go to the following URL: alias.contoso.com/directory2/view.aspx?queryparam1=no&queryparam2=blue However, the URLS are actually supposed to be: server.contoso.com/directory2/view.aspx?queryparam1=no&queryparam2=blue It's too late to recall all of the e-mails, and we'd like to redirect traffic to make this as seamless as possible for our users. The real problem here is that the server (server.contoso.com) is hosting the alias (alias.contoso.com) as a redirect thusly, and the existing redirect we need to keep functional: Default Web Site (server.contoso.com) --Directory1 --Directory2 --Directory3 Redirection to Directory3 (alias.contoso.com) --Essentially alias.contoso.com will take the user to server.contoso.com/Directory3 Is there any way to host a separate redirect inside of the existing redirect? We need to keep alias.contoso.com taking the user to server.contoso.com/Directory3 but also make alias.contoso.com/directory2/view.aspx?queryparam1=no&queryparam2=blue point to server.contoso.com/directory2/view.aspx?queryparam1=no&queryparam2=blue Any tips? Is this even possible?

    Read the article

  • Photo management utilities

    - by Frantumn
    I'm about to develop a web site for a new client. It's not going to be very intense, but one requirement is that, if possible, the client wants to be able to manage the photo gallery themselves. Since they are not technically savvied at all, I was wondering what utilities exist that provide a GUI for users to log in to manage photos. Can anyone make a recontamination? I haven't purchased the web hosting yet, so if your answer requires a specific type of host server don't worry, I am open to options.

    Read the article

  • How to draw a global day night curve

    - by Lumis
    I see many applications which have world-clock map, and I would like to make my own to enhance some of my mobile apps. I wonder if anybody has any knowledge where to start, how to draw a curved shadow representing the dawn and the sunset on the globe. See the example: http://aa.usno.navy.mil/imagery/earth/map?year=2012&month=6&day=19&hour=14&minute=47 I think that this curve goes up and down and creates an artic day/night etc Perhaps there is some acceptable approximation formula without a need to load data for each our and each global parallel and meridian...

    Read the article

  • Cocos2d: Changing b2Body x val every frame causes jitter

    - by Joey Green
    So, I have a jumping mechanism similar to what you would see in doodle jump where character jumps and you use the accelerometer to make character change direction left or right. I have a player object with position and a box2d b2Body with position. I'm changing the player X position via the accelerometer and the Y position according to box2d. pseudocode for this is like so -----accelerometer acceleration------ player.position = new X -----world update--------- physicsWorld-step() //this will get me the new Y according to the physics similation //so we keep the bodys Y value but change x to new X according to accelerometer data playerPhysicsBody.position = new pos(player.position.x, keepYval) player.position = playerPhysicsBody.position Now this is simplifying my code, but I'm doing the position conversion back and forth via mult or divide by PTM_. Well, I'm getting a weird jitter effect after I get big jump in acceleration data. So, my questions are: 1) Is this the right approach to have the accelerometer control the x pos and box2d control the y pos and just sync everthing up every frame? 2) Is there some issue with updating a b2body x position every frame? 3) Any idea what might be creating this jitter effect? I've collecting some data while running the game. Pre-body is before I set the x value on the b2Body in my update method after I world-step(). Post of course is afterwards. As you can see there is definitively a pattern. 012-06-19 08:14:13.118 Game[1073:707] pre-body pos 5.518720~24.362963 2012-06-19 08:14:13.120 Game[1073:707] post-body pos 5.060156~24.362963 2012-06-19 08:14:13.131 Game[1073:707] player velocity x: -31.833529 2012-06-19 08:14:13.133 Game[1073:707] delta 0.016669 2012-06-19 08:14:13.135 Game[1073:707] pre-body pos 5.060156~24.689455 2012-06-19 08:14:13.137 Game[1073:707] post-body pos 5.502138~24.689455 2012-06-19 08:14:13.148 Game[1073:707] player velocity x: -31.833529 2012-06-19 08:14:13.150 Game[1073:707] delta 0.016667 2012-06-19 08:14:13.151 Game[1073:707] pre-body pos 5.502138~25.006948 2012-06-19 08:14:13.153 Game[1073:707] post-body pos 5.043575~25.006948 2012-06-19 08:14:13.165 Game[1073:707] player velocity x: -31.833529 2012-06-19 08:14:13.167 Game[1073:707] delta 0.016644 2012-06-19 08:14:13.169 Game[1073:707] pre-body pos 5.043575~25.315441 2012-06-19 08:14:13.170 Game[1073:707] post-body pos 5.485580~25.315441 2012-06-19 08:14:13.180 Game[1073:707] player velocity x: -31.833529 2012-06-19 08:14:13.182 Game[1073:707] delta 0.016895 2012-06-19 08:14:13.185 Game[1073:707] pre-body pos 5.485580~25.614935 2012-06-19 08:14:13.188 Game[1073:707] post-body pos 5.026768~25.614935 2012-06-19 08:14:13.198 Game[1073:707] player velocity x: -31.833529 2012-06-19 08:14:13.199 Game[1073:707] delta 0.016454 2012-06-19 08:14:13.207 Game[1073:707] pre-body pos 5.026768~25.905428 2012-06-19 08:14:13.211 Game[1073:707] post-body pos 5.469213~25.905428 2012-06-19 08:14:13.217 Game[1073:707] acceleration x -0.137421 2012-06-19 08:14:13.223 Game[1073:707] player velocity x: -65.022644 2012-06-19 08:14:13.229 Game[1073:707] delta 0.016603

    Read the article

  • Basic AI FSM - Handling state transition

    - by Galvanize
    I'm starting to study on how to implement game AI, and it seems to me that a very simple FSM for my Pong demo would be a nice way to start. My vision on implementing this would be to have a basic state interface and a class for each state, then the NPC would have an instance of the current state. The class should have an update method and directions on wich state to go next, depending on the event received. The question is: How do I handle this event? Should I have a regular addEventListener and a costum event system? Or should I check on update for the things that could change the current state? I'm feeling a bit lost, I feel I have a good grasp on the FSM concept but a good implementation seems tricky, thanks in advance.

    Read the article

  • Complex shading using one single (small) texture

    - by teodron
    Recently I stumbled upon a demo reel in UDK about how one can attain beautiful results using just one (rather tiny) texture that's being sent to the shader pipeline. The famous link is this one. Basically, the author states that they've used just one texture and give a snapshot of the technique here. I see that every RGBA channel contains different grayscale information.. and that info could be used to inside a shader to obtain a colour blended output. The problem is that the reel displays a fairly complex scene. To top that, the author even makes use of a normal map. How did they manage to fit a normal map in an already cluttered texture? It makes sense to have a half-space normal map by using only RG from an RGB texture, but what about the rest of the information? Since it was proven to be possible, could someone please explain how it was done (the big picture, not the dirty details!)!? Here's the texture being used. Click to see in full size.

    Read the article

  • How should I store a Game Database on Android?

    - by Liam
    I'm looking at creating a game for Android and while I have most of the ins and outs worked out, the one thing I'm struggling with is how to store data for the game. Ultimately, the game will be based off of a lot of pre-defined data and statistics so the obvious choice to me would be something like SQLite, but as I'm pretty new to the realm of Android and Game Development, I'm not 100% certain if this is the right route to follow. The data will be general pre-defined data as well as player data (along the lines of careers stats - what place finished, etc). I was wondering if there was a better/best practice solution that wasn't SQLite and that would provide said functionality and if so, could you point me in the right direction?

    Read the article

  • Engine Start and Stop Show Abnormal Behaviour

    - by Siddharth
    In my game, when I pause the game using mEngine.stop() it works perfectly but when I press resume button that has code mEngine.start() it provide some movement to the physics body. So the created body does not stand at its desire position after the resuming the game. That fault I have found in other game developed by other developer also. So please provide some guidance for it. I also tried with mScene.onUpdate(0) and mScene.onUpdate(1) but I does not able to found anything new from it.

    Read the article

  • Smooth vector based jump

    - by Esa
    I started working on Wolfire's mathematics tutorials. I got the jumping working well using a step by step system, where you press a button and the cube moves to the next point on the jumping curve. Then I tried making the jumping happen during a set time period e.g the jump starts and lands within 1.5 seconds. I tried the same system I used for the step by step implementation, but it happens instantly. After some googling I found that Time.deltatime should be used, but I could not figure how. Below is my current jumping code, which makes the jump happen instantly. while (transform.position.y > 0) { modifiedJumperVelocity -= jumperDrag; transform.position += new Vector3(modifiedJumperVelocity.x, modifiedJumperVelocity.y, 0); } Where modifiedJumperVelocity is starting vector minus the jumper drag. JumperDrag is the value that is substracted from the modifiedJumperVelocity during each step of the jump. Below is an image of the jumping curve:

    Read the article

  • Action button: only true once per press

    - by Sidar
    I'm using SFML2.0 and am trying to make a wrapper class for my controller/joystick. I read all the input data from my controller and send it off to my controllable object. I want to have two types of buttons per button press, one that is continues(true false state ) and one that is an action and is set to false after the next frame update. Here is an example of how I set my button A to true or false with the SFML api. Whereas data is my struct of buttons, and A holds my true/false state every update. data.A = sf::Joystick::isButtonPressed(i,st::input::A); But I've also added "data.actionA" which represents the one time action state. Basically what I want is for actionA to be set false after the update its been set to true. I'm trying to keep track of the previous state. But I seem to fall into this loop where it toggles between true and false every update. Anyone an idea? Edit: Since I can't answer my own question yet here is my solution: data.actionA = data.A = sf::Joystick::isButtonPressed(i,st::input::A); if(prev.A) data.actionA = false; First I always set the actionA to the value of the button state. Then I check if the previous state of A is true. If so we negate the value.

    Read the article

  • Not getting desired results with SSAO implementation

    - by user1294203
    After having implemented deferred rendering, I tried my luck with a SSAO implementation using this Tutorial. Unfortunately, I'm not getting anything that looks like SSAO, you can see my result below. You can see there is some weird pattern forming and there is no occlusion shading where there needs to be (i.e. in between the objects and on the ground). The shaders I implemented follow: #VS #version 330 core uniform mat4 invProjMatrix; layout(location = 0) in vec3 in_Position; layout(location = 2) in vec2 in_TexCoord; noperspective out vec2 pass_TexCoord; smooth out vec3 viewRay; void main(void){ pass_TexCoord = in_TexCoord; viewRay = (invProjMatrix * vec4(in_Position, 1.0)).xyz; gl_Position = vec4(in_Position, 1.0); } #FS #version 330 core uniform sampler2D DepthMap; uniform sampler2D NormalMap; uniform sampler2D noise; uniform vec2 projAB; uniform ivec3 noiseScale_kernelSize; uniform vec3 kernel[16]; uniform float RADIUS; uniform mat4 projectionMatrix; noperspective in vec2 pass_TexCoord; smooth in vec3 viewRay; layout(location = 0) out float out_AO; vec3 CalcPosition(void){ float depth = texture(DepthMap, pass_TexCoord).r; float linearDepth = projAB.y / (depth - projAB.x); vec3 ray = normalize(viewRay); ray = ray / ray.z; return linearDepth * ray; } mat3 CalcRMatrix(vec3 normal, vec2 texcoord){ ivec2 noiseScale = noiseScale_kernelSize.xy; vec3 rvec = texture(noise, texcoord * noiseScale).xyz; vec3 tangent = normalize(rvec - normal * dot(rvec, normal)); vec3 bitangent = cross(normal, tangent); return mat3(tangent, bitangent, normal); } void main(void){ vec2 TexCoord = pass_TexCoord; vec3 Position = CalcPosition(); vec3 Normal = normalize(texture(NormalMap, TexCoord).xyz); mat3 RotationMatrix = CalcRMatrix(Normal, TexCoord); int kernelSize = noiseScale_kernelSize.z; float occlusion = 0.0; for(int i = 0; i < kernelSize; i++){ // Get sample position vec3 sample = RotationMatrix * kernel[i]; sample = sample * RADIUS + Position; // Project and bias sample position to get its texture coordinates vec4 offset = projectionMatrix * vec4(sample, 1.0); offset.xy /= offset.w; offset.xy = offset.xy * 0.5 + 0.5; // Get sample depth float sample_depth = texture(DepthMap, offset.xy).r; float linearDepth = projAB.y / (sample_depth - projAB.x); if(abs(Position.z - linearDepth ) < RADIUS){ occlusion += (linearDepth <= sample.z) ? 1.0 : 0.0; } } out_AO = 1.0 - (occlusion / kernelSize); } I draw a full screen quad and pass Depth and Normal textures. Normals are in RGBA16F with the alpha channel reserved for the AO factor in the blur pass. I store depth in a non linear Depth buffer (32F) and recover the linear depth using: float linearDepth = projAB.y / (depth - projAB.x); where projAB.y is calculated as: and projAB.x as: These are derived from the glm::perspective(gluperspective) matrix. z_n and z_f are the near and far clip distance. As described in the link I posted on the top, the method creates samples in a hemisphere with higher distribution close to the center. It then uses random vectors from a texture to rotate the hemisphere randomly around the Z direction and finally orients it along the normal at the given pixel. Since the result is noisy, a blur pass follows the SSAO pass. Anyway, my position reconstruction doesn't seem to be wrong since I also tried doing the same but with the position passed from a texture instead of being reconstructed. I also tried playing with the Radius, noise texture size and number of samples and with different kinds of texture formats, with no luck. For some reason when changing the Radius, nothing changes. Does anyone have any suggestions? What could be going wrong?

    Read the article

  • SDL & Windows 8 Metro WinRT

    - by Adrian
    I am just beginning to dip my tow into game programming and have been reading up on SDL, SFML, OpenGL, XNA, MonoGame and of course DirectX. (Needless to say there are a lot of choices out there) As much as I like SFMLs syntax I have chosen to read up and start with SDL as it is pretty ubiquitous and available on every platform (Windows, Linux, Mac) and also available on portable devices (Android, iOS) with the current exception of WinPhone 7 After that pre-amble here is my question. I notice that the docs say that for the windows platform the SDL API calls through to DirectX for higher perf. ( http://www.libsdl.org/intro.en/whatplatforms.html ) Microsoft have said that for Metro Game Apps you can only use DirectX (which means no XNA, no OpenGL, no SFML, etc, etc) My question is: If SDL just wraps DirectX calls will I (we) be able to use SDL to bring games to the new Metro WinRT environment and Windows 8 marketplace? This would be great if possible. Additionally as WinPhone 8 is supposedly built on Win8 then this could mean SDL would be available on the win phone in the future too. Thanks for your time in responding to this question and I look forward to hearing your response. EDIT: Based on DeadMG's answer I have installed Visual Studio 11 (beta) in Windows 8 Consumer Preview (CP) and went file-New to check project types. The project types: "Blank Application", "Direct2D Application" and "Direct3D Application" look of interest. I have selected "Direct2D App" but SDL generates its own window when you call: SDL_INIT Is it possible to link/setup the SDL window to point to the Direct2D surface in the this project?

    Read the article

  • Doing an SNES Mode 7 (affine transform) effect in pygame

    - by 2D_Guy
    Is there such a thing as a short answer on how to do a Mode 7 / mario kart type effect in pygame? I have googled extensively, all the docs I can come up with are dozens of pages in other languages (asm, c) with lots of strange-looking equations and such. Ideally, I would like to find something explained more in English than in mathematical terms. I can use PIL or pygame to manipulate the image/texture, or whatever else is necessary. I would really like to achieve a mode 7 effect in pygame, but I seem close to my wit's end. Help would be greatly appreciated. Any and all resources or explanations you can provide would be fantastic, even if they're not as simple as I'd like them to be. If I can figure it out, I'll write a definitive how to do mode 7 for newbies page. edit: mode 7 doc: http://www.coranac.com/tonc/text/mode7.htm

    Read the article

  • Abstracting entity caching in XNA

    - by Grofit
    I am in a situation where I am writing a framework in XNA and there will be quite a lot of static (ish) content which wont render that often. Now I am trying to take the same sort of approach I would use when doing non game development, where I don't even think about caching until I have finished my application and realise there is a performance problem and then implement a layer of caching over whatever needs it, but wrap it up so nothing is aware its happening. However in XNA the way we would usually cache would be drawing our objects to a texture and invalidating after a change occurs. So if you assume an interface like so: public interface IGameComponent { void Update(TimeSpan elapsedTime); void Render(GraphicsDevice graphicsDevice); } public class ContainerComponent : IGameComponent { public IList<IGameComponent> ChildComponents { get; private set; } // Assume constructor public void Update(TimeSpan elapsedTime) { // Update anything that needs it } public void Render(GraphicsDevice graphicsDevice) { foreach(var component in ChildComponents) { // draw every component } } } Then I was under the assumption that we just draw everything directly to the screen, then when performance becomes an issue we just add a new implementation of the above like so: public class CacheableContainerComponent : IGameComponent { private Texture2D cachedOutput; private bool hasChanged; public IList<IGameComponent> ChildComponents { get; private set; } // Assume constructor public void Update(TimeSpan elapsedTime) { // Update anything that needs it // set hasChanged to true if required } public void Render(GraphicsDevice graphicsDevice) { if(hasChanged) { CacheComponents(graphicsDevice); } // Draw cached output } private void CacheComponents(GraphicsDevice graphicsDevice) { // Clean up existing cache if needed var cachedOutput = new RenderTarget2D(...); graphicsDevice.SetRenderTarget(renderTarget); foreach(var component in ChildComponents) { // draw every component } graphicsDevice.SetRenderTarget(null); } } Now in this example you could inherit, but your Update may become a bit tricky then without changing your base class to alert you if you had changed, but it is up to each scenario to choose if its inheritance/implementation or composition. Also the above implementation will re-cache within the rendering cycle, which may cause performance stutters but its just an example of the scenario... Ignoring those facts as you can see that in this example you could use a cache-able component or a non cache-able one, the rest of the framework needs not know. The problem here is that if lets say this component is drawn mid way through the game rendering, other items will already be within the default drawing buffer, so me doing this would discard them, unless I set it to be persisted, which I hear is a big no no on the Xbox. So is there a way to have my cake and eat it here? One simple solution to this is make an ICacheable interface which exposes a cache method, but then to make any use of this interface you would need the rest of the framework to be cache aware, and check if it can cache, and to then do so. Which then means you are polluting and changing your main implementations to account for and deal with this cache... I am also employing Dependency Injection for alot of high level components so these new cache-able objects would be spat out from that, meaning no where in the actual game would they know they are caching... if that makes sense. Just incase anyone asked how I expected to keep it cache aware when I would need to new up a cachable entity.

    Read the article

  • Call the cast operator of template base class within the derived class

    - by yoni
    I have a template class, called Cell, here the definition: template <class T> class OneCell { ..... } I have a cast operator from Cell to T, here virtual operator const T() const { ..... } Now i have derived class, called DCell, here template <class T> class DCell : public Cell<T> { ..... } I need to override the Cell's cast operator (insert a little if), but after I need to call the Cell's cast operator. In other methods it's should be something like virtual operator const T() const { if (...) { return Cell<T>::operator const T; } else throw ... } but i got a compiler error error: argument of type 'const int (Cell::)()const' does not match 'const int' What can I do? Thank you, and sorry about my poor English.

    Read the article

  • Node.js/ v8: How to make my own snapshot to accelerate startup

    - by Anand
    I have a node.js (v0.6.12) application that starts by evaluating a Javascript file, startup.js. It takes a long time to evaluate startup.js, and I'd like to 'bake it in' to a custom build of Node if possible. The v8 source directory distributed with Node, node/deps/v8/src, contains a SconScript that can almost be used to do this. On line 302, we have LIBRARY_FILES = ''' runtime.js v8natives.js array.js string.js uri.js math.js messages.js apinatives.js date.js regexp.js json.js liveedit-debugger.js mirror-debugger.js debug-debugger.js '''.split() Those javascript files are present in the same directory. Something in the build process apparently evaluates them, takes a snapshot of state, and saves it as a byte string in node/out/Release/obj/release/snapshot.cc (on Mac OS). Some customization of the startup snapshot is possible by altering the SconScript. For example, I can change the definition of the builtin Date.toString by altering date.js. I can even add new global variables by adding startup.js to the list of library files, with contents global.test = 1. However, I can't put just any javascript code in startup.js. If it contains Date.toString = 1;, an error results even though the code is valid at the node repl: Build failed: -> task failed (err #2): {task: libv8.a SConstruct -> libv8.a} make: *** [program] Error 1 And it obviously can't make use of code that depends on libraries Node adds to v8. global.underscore = require('underscore'); causes the same error. I'd ideally like a tool, customSnapshot, where customSnapshot startup.js evaluates startup.js with node and then dumps a snapshot to a file, snapshot.cc, which I can put into the node source directory. I can then build node and tell it not to rebuild the snapshot.

    Read the article

  • Android string formatiing from xml

    - by mann
    I am parsing xml from server. One of its node contains data like <distance>16.3432434324354324km</distance> I am putting it into hashmap like for (int i = 0; i < nl.getLength(); i++) { map.put(KEY_DISTANCE, parser.getValue(e, KEY_DISTANCE)); // adding HashList to ArrayList menuItems.add(map); } Everything is nice. But i want it two decimal places for example i want its value should be 16.34km rather then 16.343234324342342km I tried with DecimalFormat twoDForm=new DecimalFormat("##.00"); try{ Double StartVTwo=Double.valueOf(KEY_DISTANCE); Double resultDouble1 = Double.valueOf(twoDForm.format(StartVTwo)); Log.e("check", String.valueOf(resultDouble1)); }catch (NumberFormatException e){ Log.e("error"," This is error "); } But it shows exception and prints this message. Any help would be appreciated!!

    Read the article

  • Tal condition always evaluates to false

    - by Ander2
    I'm using plone and trying to display a form result in a page template. I'm trying to filter some database results using tal:condition with a python expression but it always evaluates to false. The code looks like this: <tr tal:repeat="result view/results"> <td> <span tal:condition="python:view.teams[0]==result.team_id" tal:replace="result/position">Position</span></td> <td> <span tal:condition="python:view.teams[1]==result.team_id" tal:replace="result/position">Position</span></td> </tr> I want the table cells to be filled with the team position when the team id is matched in the result, but the cells always are empty. If I remove the tal:condition from the span and replace the tal:replace="result/position" with tal:replace=python:view.teams[0]==result.team_id it prints True or False so I can check that the result is correct. Can anyone help me about this issue? Why does tal:condition allways evaluate false?

    Read the article

  • Have error message show when form is created through AJAX

    - by Railslearner
    I have a page called /add that you can add a Dog on and the form is in its own partial. I'm using Simple Form and Twitter Bootstrap. I added the files for the main Bootstrap but use a gem for simple_form to work with it just so you know. DogsController # new.js.erb (deleted new.html.erb) def new @dog = Dog.new respond_to do |format| format.js end end # create.js.erb def create @dog = current_user.dogs.new(params[:dog]) respond_to do |format| if @dog.save format.html { redirect_to add_url, notice: 'Dog was successfully added.' } format.json { render json: @dog, status: :created, location: @dog} format.js else format.html { render 'pages/add' } format.json { render json: @dog.errors, status: :unprocessable_entity } end end end dogs/_form.html.erb <%= simple_form_for(@dog, :remote => true) do |f| %> <%= render :partial => "shared/error_message", :locals => { :f => f } %> <%= f.input :name %> <%= f.button :submit, 'Done' %> <% end %> This line: <%= render :partial => "shared/error_message", :locals => { :f => f } %> Is for bootstrap so it renders the errors html correctly. PagesController def add respond_to do |format| format.html end end pages/add.html.erb <div id="generate-form"> </div> dogs/new.js.erb $("#generate-form").html("<%= escape_javascript(render(:partial => 'dogs/form', locals: { dog: @dog })) %>"); Now how would I get this to render the error partial as if it was still on my dogs/new.html.erb since its being created through AJAX? I don't need client side validations do I?

    Read the article

  • Highlight anchor element

    - by dotNetNewbie
    I have the following three items displayed side by side: <div class="page-header"> <h1 style="line-height:0">Title</h1> <ul style="float: right; list-style-type: none;"> <li><a href="http://test1.com">T1</a></li> <li><a href="http://test2.com">T2</a></li> <li><a href="#">T3</a></li> </ul> </div> I want to highlight the item once the user clicked on it (eg. T1). Something similar to how stackoverflow has the blocks like Questions, Tags, Users etc.

    Read the article

  • Python: How can I read in the characters from a line in a file and convert them to floats and strs, depending on if they are numbers or letters?

    - by user1467577
    I have a file that looks like: 1 1 C C 1.9873 2.347 3.88776 1 2 C Si 4.887 9.009 1.21 I would like to read in the contents of the file, line-by-line. When I only had numbers on the lines I used: for line in readlines(file): data = map(float, line.split) But this only works when all the elements of line.split are numbers. How can I make it store the letters as strings and the numbers as floats?

    Read the article

  • Android Java ArrayList inserting element not working

    - by DavidNg
    I have a simple Android program with one button and one textview. When the button is clicked, a number is inserted in in an ArrayList. However, it does not work. If changing to add, it works fine. package test_ad.com; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class Test_adActivity extends Activity { ArrayList<Integer> al = new ArrayList<Integer>(); Button myB; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myB = (Button) findViewById(R.id.button1); myTV = (TextView) findViewById(R.id.textView1); myB.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { al.set(i,10*i);//insert an Integer at index i, but not working i++; if (i == 5) myTV.setText(al.toString()); } }); } }

    Read the article

  • how do call a polymorphic function from an agnostic function?

    - by sds
    I have a method foo void foo (String x) { ... } void foo (Integer x) { ... } and I want to call it from a method which does not care about the argument: void bar (Iterable i) { ... for (Object x : i) foo(x); // this is the only time i is used ... } the code above complains that that foo(Object) is not defined and when I add void foo (Object x) { throw new Exception; } then bar(Iterable<String>) calls that instead of foo(String) and throws the exception. How do I avoid having two textually identical definitions of bar(Iterable<String>) and bar(Iterable<Integer>)? I thought I would be able to get away with something like <T> void bar (Iterable<T> i) { ... for (T x : i) foo(x); // this is the only time i is used ... } but then I get cannot find foo(T) error.

    Read the article

  • How do I add a URL parameter to redirected login page using JSF 2.0

    - by Big Al
    I have a question about session timeouts and JSF 2. I have my exception handler working exactly the way everyone prefers but I need to pass a value to the login page. For example, I have a typical login URL - www.acme.com/?companyId=company14 which in turn presents company14 with their own custom login page (using their logo). After they enter the application and do a bit of work, they read an email or 2. The session times out and a session timeout page is shown instructing the user to click Ok to proceed to the login page. How do I add ?companyId=company14 to the URL? I can hardcode it in the exception handler by using this: requestMap.put("companyId", "company14"); and then referring to it on the viewExpired.xhtml page: <h:panelGrid id="expiredGrid" columns="1"> <f:facet name="header"> <h:outputText id="outExpireMsg" value="Your session has expired"/> </f:facet> <h:outputText id="outReqMessage" value="Reloading the page will require login."/> <h:outputText value=""/> <h:button id="okButton" type="submit" value="Ok" outcome="login?companyId=#{companyId}"/> </h:panelGrid> The issue is I can't seem to save the companyId anywhere without it getting wiped out by the session timeout. I'd like to set the companyId in the exceptionhandler using this value. Any ideas?

    Read the article

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