Daily Archives

Articles indexed Sunday October 27 2013

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

  • Ubuntu 12.04.1 LTS and Nvidia dirver (304.51) 64bit: problem 640x480

    - by nibianaswen
    I have a problem with this configuration: Asus K55V, Ubuntu 12.04 LTS and Nvidia driver 304.51. I have remove the nouveau driver with: apt-get --purge remove xserver-xorg-video-nouveau I installed the official nvidia driver (from www.nvidia.com) but when I reboot the PC the resolution of screen is only 640x480 and the monitor is resized. Mo solution at this problem if i change the xorg.conf. Now i have uninstall the nvidia driver and reinstall with sudo apt-get purge nvidia-current sudo apt-add-repository ppa:ubuntu-x-swat/x-updates sudo apt-get update sudo apt-get install nvidia-current When I reboot the screen resolution and size is OK, but if I start nvidia-setting I received the message: You do not appear to be using the NVIDIA X driver. and with command: sudo lshw -c display | grep driver I received configuration: driver=i915 latency=0 This sound like the system is using the Intel card. When I launch command lspci | grep VGA the output is: 00:02.0 VGA compatible controller: Intel Corporation Ivy Bridge Graphics Controller (rev 09) 01:00.0 VGA compatible controller: NVIDIA Corporation Device 1058 (rev ff) And there is no /etc/X11/xorg.conf. I have read a lot of guides on internet but without success.. How i can use nvidia card with the driver that i have installed?

    Read the article

  • Problem with gnome-shell-extensions-user-theme

    - by sodiumnitrate
    I'm trying to install themes with gnome tweak, and I need to install gnome-shell-extensions-user-theme because otherwise I cannot see the shell extensions tab. However, I cannot install shell extensions. I have tried to install by adding the PPA with the following: sudo add-apt-repository ppa:webupd8team/gnome3 Then, sudo apt-get update Finally, when I try to install: sudo apt-get install gnome-shell-extensions-user-theme It gives an error: The following packages have unmet dependencies: gnome-shell-extensions-user-theme : Depends: gnome-shell-extensions-common but it is not going to be installed E: Unable to correct problems, you have held broken packages. I am convinced that there is a problem with the package. So I went on and tried to install the extensions from the website: https://extensions.gnome.org/ But even though I use Firefox (15.0), I cannot see the "switch" that is being mentioned to install the extension. Maybe the version of Firefox is too new. Is there any workaround that you know of? (By the way, I use Ubuntu 12.04, freshly downloaded and installed.)

    Read the article

  • Why does flush dns often fail to work?

    - by Sharen Eayrs
    C:\Windows\system32>ipconfig /flushdns Windows IP Configuration Successfully flushed the DNS Resolver Cache. C:\Windows\system32>ping beautyadmired.com Pinging beautyadmired.com [xxx.45.62.2] with 32 bytes of data: Reply from xxx.45.62.2: bytes=32 time=253ms TTL=49 Reply from xxx.45.62.2: bytes=32 time=249ms TTL=49 Reply from xxx.45.62.2: bytes=32 time=242ms TTL=49 Reply from xxx.45.62.2: bytes=32 time=258ms TTL=49 Ping statistics for xxx.45.62.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 242ms, Maximum = 258ms, Average = 250ms My site should point to xx.73.42.27 I change the name server. It's been 3 hours. It still points to xxx.45.62.2 Actually what happen after we change name server anyway? Wait for what? I already flush dns. Why it still points to the wrong IP? Also most other people that do not have the DNS cache also still go to the wrong IP

    Read the article

  • Slick2D Rendering Lots of Polygons

    - by Hazzard
    I'm writing an little isometric game using Slick. The world terrain is made up of lots of quadrilaterals. In a small world that is 128 by 128 squares, over 16,000 quadrilaterals need to be rendered. This puts my pretty powerful computer down to 30 fps. I've though about caching "chunks" of the world so only single chunks would ever need updating at a time, but I don't know how to do this, and I am sure there are other ways to optimize it besides that. Maybe I'm doing the whole thing wrong, surely fancy 3D games that run fine on my machine are more intensive than this. My question is how can I improve the FPS and am I doing something wrong? Or does it actually take that much power to render those polygons? -- Here is the source code for the render method in my game state. It iterates through a 2d array or heights and draws polygons based on the height. public void render(GameContainer container, StateBasedGame game, Graphics gfx) throws SlickException { gfx.translate(offsetX * d + container.getWidth() / 2, offsetY * d + container.getHeight() / 2); gfx.scale(d, d); for (int y = 0; y < placeholder.length; y++) {// x & y are isometric // diag for (int x = 0; x < placeholder[0].length; x++) { Polygon poly; int hor = TestState.TILE_WIDTH * (x - y);// hor and ver are orthagonal int W = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y + 1][x];//points to go off of int S = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y + 1][x + 1]; int E = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y][x + 1]; int N = TestState.TILE_HEIGHT * (x + y) - 1 * heights[y][x]; if (placeholder[y][x] == null) { poly = new Polygon();//Create actual surface polygon poly.addPoint(-TestState.TILE_WIDTH + hor, W); poly.addPoint(hor, S + TestState.TILE_HEIGHT); poly.addPoint(TestState.TILE_WIDTH + hor, E); poly.addPoint(hor, N - TestState.TILE_HEIGHT); float z = ((float) heights[y][x + 1] - heights[y + 1][x]) / 32 + 0.5f; placeholder[y][x] = new Tile(poly, new Color(z, z, z)); //ShapeRenderer.fill(placeholder[y][x]); } if (true) {//ONLY draw tile if it's on screen gfx.setColor(placeholder[y][x].getColor()); ShapeRenderer.fill(placeholder[y][x]); //gfx.fill(placeholder[y][x]); //placeholder[y][x]. //DRAW EDGES if (y + 1 == placeholder.length) {//draw South foundation edges gfx.setColor(Color.gray); Polygon found = new Polygon(); found.addPoint(-TestState.TILE_WIDTH + hor, W); found.addPoint(hor, S + TestState.TILE_HEIGHT); found.addPoint(hor, TestState.TILE_HEIGHT * (x + y + 1)); found.addPoint(-TestState.TILE_WIDTH + hor, TestState.TILE_HEIGHT * (x + y)); gfx.fill(found); } if (x + 1 == placeholder[0].length) {//north gfx.setColor(Color.darkGray); Polygon found = new Polygon(); found.addPoint(TestState.TILE_WIDTH + hor, E); found.addPoint(hor, S + TestState.TILE_HEIGHT); found.addPoint(hor, TestState.TILE_HEIGHT * (x + y + 1)); found.addPoint(TestState.TILE_WIDTH + hor, TestState.TILE_HEIGHT * (x + y)); gfx.fill(found); }//*/ } } } }

    Read the article

  • How to create a fountain in UDK

    - by user36425
    I'm trying to make a fountain in my level in UDK, I made the base of the fountain by using a Cylinder build and now I'm trying to put water in it. I went to use the fluidSurfaceActor but I notice that this is square but my fountain is a cylinder. Is there a way that I can change the shape of the fluidSurfaceActor to fit the builder brush shape or is there another way to do this? Or is it hopeless and I have to make my fountain into a cube? Here is a link/picture to the screenprint of what I'm talking about:

    Read the article

  • How do I choose the scaling factor of a 3D game world?

    - by concept3d
    I am making a 3D tank game prototype with some physics simulation, am using C++. One of the decisions I need to make is the scale of the game world in relation to reality. For example, I could consider 1 in-game unit of measurement to correspond to 1 meter in reality. This feels intuitive, but I feel like I might be missing something. I can think of the following as potential problems: 3D modelling program compatibility. (?) Numerical accuracy. (Does this matter?) Especially at large scales, how games like Battlefield have huge maps: How don't they lose numerical accuracy if they use 1:1 mapping with real world scale, since floating point representation tend to lose more precision with larger numbers (e.g. with ray casting, physics simulation)? Gameplay. I don't want the movement of units to feel slow or fast while using almost real world values like -9.8 m/s^2 for gravity. (This might be subjective.) Is it ok to scale up/down imported assets or it's best fit with a world with its original scale? Rendering performance. Are large meshes with the same vertex count slower to render? I'm wondering if I should split this into multiple questions...

    Read the article

  • How to define type-specific scripts when using a 'type object' programming pattern?

    - by Erik
    I am in the process of creating a game engine written in C++, using the C/C++ SQLite interface to achieve a 'type object' pattern. The process is largely similar to what is outlined here (Thank you Bob Nystrom for the great resource!). I have a generally defined Entity class that when a new object is created, data is taken from a SQLite database and then is pushed back into a pointer vector, which is then iterated through, calling update() for each object. All the ints, floats, strings are loaded in fine, but the script() member of Entity is proving an issue. It's not much fun having a bunch of stationary objects laying around my gameworld. The only solutions I've come up with so far are: Create a monolithic EntityScript class with member functions encompassing all game AI and then calling the corresponding script when iterating through the Entity vector. (Not ideal) Create bindings between C++ and a scripting language. This would seem to get the job done, but it feels like implementing this (given the potential memory overhead) and learning a new language is overkill for a small team (2-3 people) that know the entirety of the existing game engine. Can you suggest any possible alternatives? My ideal situation would be that to add content to the game, one would simply add a script file to the appropriate directory and append the SQLite database with all the object data. All that is required is to have a variety of integers and floats passed between both the engine and the script file.

    Read the article

  • Collide with rotation of the object

    - by Lahiru
    I'm developing a mirror for lazer beam(Ball sprite). There I'm trying to redirect the laze beam according to the ration degree of the mirror(Rectangle). How can I collide the ball to the correct angle if the colliding object is with some angle(45 deg) rather than colliding back. here is an screen shot of my work here is my code using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace collision { /// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D ballTexture; Rectangle ballBounds; Vector2 ballPosition; Vector2 ballVelocity; float ballSpeed = 30f; Texture2D blockTexture; Rectangle blockBounds; Vector2 blockPosition; private Vector2 origin; KeyboardState keyboardState; //Font SpriteFont Font1; Vector2 FontPos; private String displayText; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } /// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here ballPosition = new Vector2(this.GraphicsDevice.Viewport.Width / 2, this.GraphicsDevice.Viewport.Height * 0.25f); blockPosition = new Vector2(this.GraphicsDevice.Viewport.Width / 2, this.GraphicsDevice.Viewport.Height /2); ballVelocity = new Vector2(0, 1); base.Initialize(); } /// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ballTexture = Content.Load<Texture2D>("ball"); blockTexture = Content.Load<Texture2D>("mirror"); //create rectangles based off the size of the textures ballBounds = new Rectangle((int)(ballPosition.X - ballTexture.Width / 2), (int)(ballPosition.Y - ballTexture.Height / 2), ballTexture.Width, ballTexture.Height); blockBounds = new Rectangle((int)(blockPosition.X - blockTexture.Width / 2), (int)(blockPosition.Y - blockTexture.Height / 2), blockTexture.Width, blockTexture.Height); origin.X = blockTexture.Width / 2; origin.Y = blockTexture.Height / 2; // TODO: use this.Content to load your game content here Font1 = Content.Load<SpriteFont>("SpriteFont1"); FontPos = new Vector2(graphics.GraphicsDevice.Viewport.Width - 100, 20); } /// <summary> /// UnloadContent will be called once per game and is the place to unload /// all content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here } /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> /// private float RotationAngle; float circle = MathHelper.Pi * 2; float angle; protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // TODO: Add your update logic here //check for collision between the ball and the block, or if the ball is outside the bounds of the screen if (ballBounds.Intersects(blockBounds) || !GraphicsDevice.Viewport.Bounds.Contains(ballBounds)) { //we have a simple collision! //if it has hit, swap the direction of the ball, and update it's position ballVelocity = -ballVelocity; ballPosition += ballVelocity * ballSpeed; } else { //move the ball a bit ballPosition += ballVelocity * ballSpeed; } //update bounding boxes ballBounds.X = (int)ballPosition.X; ballBounds.Y = (int)ballPosition.Y; blockBounds.X = (int)blockPosition.X; blockBounds.Y = (int)blockPosition.Y; keyboardState = Keyboard.GetState(); float val = 1.568017f/90; if (keyboardState.IsKeyDown(Keys.Space)) RotationAngle = RotationAngle + (float)Math.PI; if (keyboardState.IsKeyDown(Keys.Left)) RotationAngle = RotationAngle - val; angle = (float)Math.PI / 4.0f; // 90 degrees RotationAngle = angle; // RotationAngle = RotationAngle % circle; displayText = RotationAngle.ToString(); base.Update(gameTime); } /// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here spriteBatch.Begin(); // Find the center of the string Vector2 FontOrigin = Font1.MeasureString(displayText) / 2; spriteBatch.DrawString(Font1, displayText, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f); spriteBatch.Draw(ballTexture, ballPosition, Color.White); spriteBatch.Draw(blockTexture, blockPosition,null, Color.White, RotationAngle,origin, 1.0f, SpriteEffects.None, 0f); spriteBatch.End(); base.Draw(gameTime); } } }

    Read the article

  • XNA: Auto-populate content within the content project based on current folder/file structure and content management for large games

    - by Joe
    1) Is it possible to implement a system where I can simply drop a new image into my content project's folder and VS will automatically see that and bring it into the project for compiling? 2) Similarly, if I wanted a specific texture I could state something like var texture = Game.Assets.Image["backgrounds/sky_02"]; (where Game is the standard XNA Game class and Assets is some kind of content manager statically defined within Game). I know this is fairly simple to implement manually and have done such things in the past (static Dictionary defined within Game) except this only works for relatively small games where you can have all assets loaded at the start without much issue. How would you go about making this work for games where content is loaded and unloaded based on level / area? I'm not asking for the solution, just how you would go about this and what things you would have to be aware of. Thanks.

    Read the article

  • Writing Game Engine from scratch with OpenGL [on hold]

    - by Wazery
    I want to start writing my game engine from scratch for learning purpose, what is the prerequisites and how to do that, what programming languages and things you recommend me? Also if you have good articles and books on that it will be great. Thanks in advance! My Programming languages and tools are: C/C++ is it good to use only C? Python OpenGL Git GDB What I want to learn from it: Core Game Engine Rendering / Graphics Game Play/Rules Input (keyboard/mouse/controllers, etc) In Rendering/Graphics: 3D Shading Lighting Texturing

    Read the article

  • Rich Text Editor in Table view

    - by pubudu
    Im try to implement rich text editor in table view cell. before this i test rich text editor using web view.it work fine I want to put this web view inside my costume cell. i did it, but it not working (bold , italic ... styles) how can i pass stringByEvaluatingJavaScriptFromString:@"document.execCommand(\"Bold\") this command to webview in cell i did like this in viewContoller - (IBAction)clickbold:(id)sender { static NSString *CellIdentifier = @"Cell1"; Cell *cell = [_tableview dequeueReusableCellWithIdentifier:CellIdentifier]; cell = [_tableview cellForRowAtIndexPath:0]; [cell.webView stringByEvaluatingJavaScriptFromString:@"document.execCommand(\"Bold\")"]; [_tableview beginUpdates]; [_tableview endUpdates]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell1"; Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; { NSBundle *bundle = [NSBundle mainBundle]; NSURL *indexFileURL = [bundle URLForResource:@"index" withExtension:@"html"]; [cell.tableview loadRequest:[NSURLRequest requestWithURL:indexFileURL]]; cell.webView.delegate = self; [cell.webView stringByEvaluatingJavaScriptFromString:@"document.execCommand(\"Italic\")"]; return cell; } return cell; } my html file like this <html> <head> <script> function myFunction() { window.location.href = "myclick://buttonClicked"; } function onKEYPRESS() { window.location.href = "onkeypress://buttonClicked"; } </script> </head> <body> <body> <div id="content" contenteditable="true" style="font-family:Arial" onfocus="myFunction()" onkeypress="onKEYPRESS()">TEXT TEXT </div> </body> </html>

    Read the article

  • Laravel - Paginate and get()

    - by Bajongskie
    With the code below, what I wanted was paginate the query I created. But, when I try to add paginate after get, it throws an error. I wanted to remain get since I want to limit to columns that was set on $fields. What would should be the better idea to paginate this thing? or what's a good substitute for get and limit the columns? What I tried: ->get($this->fields)->paginate($this->limit) Part of my controller: class PhonesController extends BaseController { protected $limit = 5; protected $fields = array('Phones.*','manufacturers.name as manufacturer'); /** * Display a listing of the resource. * * @return Response */ public function index() { if (Request::query("str")) { $phones = Phone::where("model", 'LIKE', '%'. Request::query('str') . '%') ->join('manufacturers', 'manufacturers_id', '=', 'manufacturers.id') ->get($this->fields); } else { $phones = Phone::join('manufacturers', 'manufacturers_id', '=', 'manufacturers.id') ->get($this->fields); } return View::make('phones.index')->with('phones', $phones); } }

    Read the article

  • How to change font color inside nav element?

    - by user2924752
    I have a element and I want to change the color of the links within it, but all other links on my page are styled using the following CSS: a:link { color:#22b14c; text-decoration:none; } and here is the nav: <nav id="Nav"> <a href="index.html">Home</a> | <a href="Gallery.html">Library</a> | <a href="Contact.html">Contact</a> | <a href="About.html">About</a> </nav> and the nav css: #Nav { margin-top: 20px; background-color: #000000; color: #f2f2f2; font-size: 40px; font-family: "Calibri"; text-align: center; } I tried a span inside the nav element but that didn't work. How can I change the color for these links only inside the element?

    Read the article

  • Debug a local maven dependency with eclipse

    - by mcamier
    i have two maven projects, the first one is a library and the other one use it to works properly, the both have to elvolve regardless each other, this is why i use two different project. But breakpoints on my library code doesn't work when i launch my app (the second application). This is how i include my library in the second project's POM (my IDE is eclipse and projects are in the same workspaces) <dependency> <groupId>com.mcamier</groupId> <artifactId>lazyEngine</artifactId> <version>0.0.1-SNAPSHOT</version> <scope>system</scope> <systemPath>${basedir}/../lazyEngine/target/lazyEngine-0.0.1-SNAPSHOT-jar-with-dependencies.jar</systemPath> </dependency>

    Read the article

  • Create a Task list, with tasks without executing

    - by Ernesto Araya Eguren
    I have an async method private async Task DoSomething(CancellationToken token) a list of Tasks private List<Task> workers = new List<Task>(); and I have to create N threads that runs that method public void CreateThreads(int n) { tokenSource = new CancellationTokenSource(); token = tokenSource.Token; for (int i = 0; i < n; i++) { workers.Add(DoSomething(token)); } } but the problem is that those have to run at a given time public async Task StartAllWorkers() { if (0 < workers.Count) { try { while (0 < workers.Count) { Task finishedWorker = await Task.WhenAny(workers.ToArray()); workers.Remove(finishedWorker); finishedWorker.Dispose(); } if (workers.Count == 0) { tokenSource = null; } } catch (OperationCanceledException) { throw; } } } but actually they run when i call the CreateThreads Method (before the StartAllWorkers). I searched for keywords and problems like mine but couldn't find anything about stopping the task from running. I've tried a lot of different aproaches but anything that could solve my problem entirely. For example, moving the code from DoSomething into a workers.Add(new Task(async () => { }, token)); would run the StartAllWorkers(), but the threads will never actually start. There is another method for calling the tokenSource.Cancel().

    Read the article

  • Chipmunk warning still present with --release

    - by Kaliber64
    I'm using Python27 on Windows 7 64-bit. I downloaded the source for Chipmunk 6.2.x and compiled Pymunk with --release and -c ming32. Almost zero problems. Lots of path not found cause I'm bad. All prints seem to have disappeared but I get spammed with EPA iteration warnings. I've seen a couple discussions but no solutions. Possible chipmunk betas to fix the float errors causing the double truths causing the warning. I picked the latest stable version I think. My program is seriously bogged down with all the prints. class NullDevice(): def write(self, s): pass sys.stdout=NullDevice() Does not disable the C prints .< Any help?

    Read the article

  • Howto use predicates in LINQ to Entities for Entity Framework objects

    - by user274947
    I'm using LINQ to Entities for Entity Framework objects in my Data Access Layer. My goal is to filter as much as I can from the database, without applying filtering logic on in-memory results. For that purpose Business Logic Layer passes a predicate to Data Access Layer. I mean Func<MyEntity, bool> So, if I use this predicate directly, like public IQueryable<MyEntity> GetAllMatchedEntities(Func<MyEntity, Boolean> isMatched) { return qry = _Context.MyEntities.Where(x => isMatched(x)); } I'm getting the exception [System.NotSupportedException] --- {"The LINQ expression node type 'Invoke' is not supported in LINQ to Entities."} Solution in that question suggests to use AsExpandable() method from LINQKit library. But again, using public IQueryable<MyEntity> GetAllMatchedEntities(Func<MyEntity, Boolean> isMatched) { return qry = _Context.MyEntities.AsExpandable().Where(x => isMatched(x)); } I'm getting the exception Unable to cast object of type 'System.Linq.Expressions.FieldExpression' to type 'System.Linq.Expressions.LambdaExpression' Is there way to use predicate in LINQ to Entities query for Entity Framework objects, so that it is correctly transformed it into a SQL statement. Thank you.

    Read the article

  • Is fetching data from database a get-method thing?

    - by theva
    I have a small class that I call Viewer. This class is supposed to view the proper layout of each page or something like that... I have a method called getFirstPage, when called the user of this method will get a setting value for which page is currently set as the first page. I have some code here, I think it works but I am not really shure that I have done it the right way: class Viewer { private $db; private $user; private $firstPage; function __construct($db, $user) { $this->db = $db; if(isset($user)) { $this->user = $user; } else { $this->user = 'default'; } } function getFistPage() { $std = $db->prepare("SELECT firstPage FROM settings WHERE user = ':user'"); $std->execute(array(':user' => $user)); $result = $std->fetch(); $this->firstPage = $result['firstPage']; return $this->firstPage; } } My get method is fetching the setting from databse (so far so good?). The problem is that then I have to use this get method to set the private variable firstPage. It seems like I should have a set method to do this, but I cannot really have a set method that just fetch some setting from database, right? Because the user of this object should be able to assume that there already is a setting defined in the object... How should I do that?

    Read the article

  • html5 uploader + jquery drag & drop: how to store file data with FormData?

    - by lauthiamkok
    I am making a html5 drag and drop uploader with jquery, below is my code so far, the problem is that I get an empty array without any data. Is this line incorrect to store the file data - fd.append('file', $thisfile);? $('#div').on( 'dragover', function(e) { e.preventDefault(); e.stopPropagation(); } ); $('#div').on( 'dragenter', function(e) { e.preventDefault(); e.stopPropagation(); } ); $('#div').on( 'drop', function(e){ if(e.originalEvent.dataTransfer){ if(e.originalEvent.dataTransfer.files.length) { e.preventDefault(); e.stopPropagation(); // The file list. var fileList = e.originalEvent.dataTransfer.files; //console.log(fileList); // Loop the ajax post. for (var i = 0; i < fileList.length; i++) { var $thisfile = fileList[i]; console.log($thisfile); // HTML5 form data object. var fd = new FormData(); //console.log(fd); fd.append('file', $thisfile); /* var file = {name: fileList[i].name, type: fileList[i].type, size:fileList[i].size}; $.each(file, function(key, value) { fd.append('file['+key+']', value); }) */ $.ajax({ url: "upload.php", type: "POST", data: fd, processData: false, contentType: false, success: function(response) { // .. do something }, error: function(jqXHR, textStatus, errorMessage) { console.log(errorMessage); // Optional } }); } /*UPLOAD FILES HERE*/ upload(e.originalEvent.dataTransfer.files); } } } ); function upload(files){ console.log('Upload '+files.length+' File(s).'); }; then if I use another method is that to make the file data into an array inside the jquery code, var file = {name: fileList[i].name, type: fileList[i].type, size:fileList[i].size}; $.each(file, function(key, value) { fd.append('file['+key+']', value); }); but where is the tmp_name data inside e.originalEvent.dataTransfer.files[i]? php, print_r($_POST); $uploaddir = './uploads/'; $file = $uploaddir . basename($_POST['file']['name']); if (move_uploaded_file($_POST['file']['tmp_name'], $file)) { echo "success"; } else { echo "error"; } as you can see that tmp_name is needed to upload the file via php... html, <div id="div">Drop here</div>

    Read the article

  • matlab constant anonymous function returns only one value instead of an array

    - by Filo
    I've been searching the net for a couple of mornings and found nothing, hope you can help. I have an anonymous function like this f = @(x,y) [sin(2*pi*x).*cos(2*pi*y), cos(2*pi*x).*sin(2*pi*y)]; that needs to be evaluated on an array of points, something like x = 0:0.1:1; y = 0:0.1:1; w = f(x',y'); Now, in the above example everything works fine, the result w is a 11x2 matrix with in each row the correct value f(x(i), y(i)). The problem comes when I change my function to have constant values: f = @(x,y) [0, 1]; Now, even with array inputs like before, I only get out a 1x2 array like w = [0,1]; while of course I want to have the same structure as before, i.e. a 11x2 matrix. I have no idea why Matlab is doing this...

    Read the article

  • How to display image from server (newest-oldest) to a new php page?

    - by Jben Kaye
    i have a form that create images and save it on a folder in the server. What i need to do is to display ALL created images to another page, the newest on the top and so that the oldest is at the bottom. i have a form called formdisplay.php but it's just displaying a broken image and not newest to oldest. hope you can help me with this. really need to get this working. thanks in advance for your help. i have read the posts but none of those worked for me. Pull dedicated images from folder - show image + filename (strip part of filename + file-extension) How can I display latest uploaded image first? (PHP+CSS) getting images from the server and display them Displaying images from folder in php display image from server embedding php in html formcreatesave.php imagecopymerge($im, $img2, 10, 350, 0, 0, imagesx($img2), imagesy($img2), 100); $date_created = date("YmdHis");//get date created $img_name = "-img_entry.jpg"; //the file name of the generated image $img_newname = $date_created . $img_name; //datecreated+name $img_dir =dirname($_SERVER['SCRIPT_FILENAME']) ."/". $img_newname; //the location to save imagejpeg($im, $img_dir , 80); //function to save the image with the name and quality imagedestroy($im); formdisplay.php $dir = '/home3/birdieon/public_html/Amadeus/uploader/uploader'; $base_url = 'http://birdieonawire.com/Amadeus/uploader/uploader/20131027024705-img_entry.jpg'; $newest_mtime = 0; $show_file = 'BROKEN'; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (($file != '.') && ($file != '..')) { $mtime = filemtime("$dir/$file"); if ($mtime > $newest_mtime) { $newest_mtime = $mtime; $show_file = "$base_url/$file"; } } } } print '<img src="' .$show_file. '" alt="Image Title Here">'; please feel free to edit my code. thanks :)

    Read the article

  • Restructuring html with javascript

    - by tolborg
    I have a regular unordered list of links, which I would like to change using js <ul> <li><a href="#">Theme 1</a></li> <li><a href="#">Theme 2</a></li> <li><a href="#">Theme 3</a></li> <li><a href="#">Theme 4</a></li> <li><a href="#">Theme 5</a></li> <li><a href="#">Theme 6</a></li> <li><a href="#">Theme 7</a></li> <li><a href="#">Theme 8</a></li> <li><a href="#">Theme 9</a></li> <li><a href="#">Theme 10</a></li> <li><a href="#">Theme 11</a></li> <li><a href="#">Theme 12</a></li> </ul> I would like the following output: <div class="themes__row"> <div class="themes__item><a href="#">Theme 1</a></div> <div class="themes__item><a href="#">Theme 2</a></div> <div class="themes__item><a href="#">Theme 3</a></div> <div class="themes__item><a href="#">Theme 4</a></div> </div> <div class="themes__row"> <div class="themes__item><a href="#">Theme 5</a></div> <div class="themes__item><a href="#">Theme 6</a></div> <div class="themes__item><a href="#">Theme 7</a></div> <div class="themes__item><a href="#">Theme 8</a></div> </div> <div class="themes__row"> <div class="themes__item><a href="#">Theme 9</a></div> <div class="themes__item><a href="#">Theme 10</a></div> <div class="themes__item><a href="#">Theme 11</a></div> <div class="themes__item><a href="#">Theme 12</a></div> </div> I have tried a few different solutions back and forth, but it ends up being really messy, so I dont really have any code to show. How is this done in a clever way? The site is using jQuery 1.4.4 if that matters.

    Read the article

  • why resubmit after refresh php page

    - by user2719452
    why resubmit after refresh php page? try it, go to: http://qass.im/message-envelope/ and upload any image now try click F5, after refresh page "resubmit" Why? I don't want resubmit after refresh page What is the solution? See this is my form code: <form id="uploadedfile" name="uploadedfile" enctype="multipart/form-data" action="upload.php" method="POST"> <input name="uploadedfile" type="file" /> <input type="submit" value="upload" /> </form> See this is php code upload.php file: <?php $allowedExts = array("gif", "jpeg", "jpg", "png", "zip", "pdf", "docx", "rar", "txt", "doc"); $temp = explode(".", $_FILES["uploadedfile"]["name"]); $extension = end($temp); $newname = $extension.'_'.substr(str_shuffle(str_repeat("0123456789abcdefghijklmnopqrstuvwxyz", 7)), 4, 7); $imglink = 'attachment/attachment_file_'; $uploaded = $imglink .$newname.'.'.$extension; if ((($_FILES["uploadedfile"]["type"] == "image/jpeg") || ($_FILES["uploadedfile"]["type"] == "image/jpeg") || ($_FILES["uploadedfile"]["type"] == "image/jpg") || ($_FILES["uploadedfile"]["type"] == "image/pjpeg") || ($_FILES["uploadedfile"]["type"] == "image/x-png") || ($_FILES["uploadedfile"]["type"] == "image/gif") || ($_FILES["uploadedfile"]["type"] == "image/png") || ($_FILES["uploadedfile"]["type"] == "application/msword") || ($_FILES["uploadedfile"]["type"] == "text/plain") || ($_FILES["uploadedfile"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") || ($_FILES["uploadedfile"]["type"] == "application/pdf") || ($_FILES["uploadedfile"]["type"] == "application/x-rar-compressed") || ($_FILES["uploadedfile"]["type"] == "application/x-zip-compressed") || ($_FILES["uploadedfile"]["type"] == "application/zip") || ($_FILES["uploadedfile"]["type"] == "multipart/x-zip") || ($_FILES["uploadedfile"]["type"] == "application/x-compressed") || ($_FILES["uploadedfile"]["type"] == "application/octet-stream")) && ($_FILES["uploadedfile"]["size"] < 5242880) // Max size is 5MB && in_array($extension, $allowedExts)) { move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $uploaded ); echo '<a target="_blank" href="'.$uploaded.'">click</a>'; // If has been uploaded file echo '<h3>'.$uploaded.'</h3>'; } if($_FILES["uploadedfile"]["error"] > 0){ echo '<h3>Please choose file to upload it!</h3>'; // If you don't choose file } elseif(!in_array($extension, $allowedExts)){ echo '<h3>This extension is not allowed!</h3>'; // If you choose file not allowed } elseif($_FILES["uploadedfile"]["size"] > 5242880){ echo "Big size!"; // If you choose big file } ?> if you have solution, please edit my php code and paste your solution code! Thanks.

    Read the article

  • How can I use from ismember

    - by ahmad hosseini
    Assuming A=[32512199.30 5401000.29 347.33 32512199.69 5401000.45 347.39 32512199.67 5401001.32 353.58 32512199.96 5401001.50 346.99 32512196.71 5401001.69 346.62 ] and B=[32512199.30 5401000.29 347.33 32512199.69 5401000.45 347.39 32512199.67 5401001.32 347.00 32512198.85 5401000.91 347.25 32512196.71 5401001.69 346.87 ] I want using ismember extract the rows that have same X and Y and different Z. X is first column, Y is the second and Z is third. in A and B I want extract from A 32512199.67 5401001.32 353.58 and 32512196.71 5401001.69 346.62 OR from B 32512199.67 5401001.32 347.00 and 32512196.71 5401001.69 346.87 How can I do it?

    Read the article

  • Pass dynamic data to mvc controller with AJAX

    - by Yustme
    How can I pass dynamic data with an AJAX call to an MVC Controller? Controller: public JsonResult ApplyFilters(dynamic filters){ return null; } The AJAX call: $(':checkbox').click(function (event) { var serviceIds = $('input[type="checkbox"]:checked').map(function () { return $(this).val(); }).toArray(); //alert(serviceIds); $.ajax({ type: 'GET', url: '/home/ApplyFilters', data: JSON.stringify({ name: serviceIds }), contentType: 'application/json', success: function (data) { alert("succeeded"); }, error: function (err, data) { alert("Error " + err.responseText); } }); //return false; }); Ideally would be that the filters would contain the serviceIds as a property For example like this: filters.ServiceIds. I got another filter for a date range and that one would be added like so: filters.DateRange. And server side get the filter as a dynamic object in the ApplyFilters()

    Read the article

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