Daily Archives

Articles indexed Wednesday June 2 2010

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

  • Empty or "flush" a file descriptor without read()?

    - by Teddy
    (Note: This is not a question of how to flush a write(). This is the other end of it, so to speak.) Is it possible to empty a file descriptor that has data to be read in it without having to read() it? You might not be interested in the data, and reading it all would therefore waste space and cycles you might have better uses for. If it is not possible in POSIX, do any operating systems have any non-portable ways to do this? UPDATE: Please note that I'm talking about file descriptors, not streams.

    Read the article

  • facebook javascript sdk fb_xd_fragment??

    - by James Lin
    Hi guys, I am using the facebook javascript sdk to embed a like button in my page. What is fb_xd_fragment??? I see it appends to the end of my url like http://www.mysite.com/controller/?fb_xd_fragment, and this is causing some nasty recursive reload of the page. Cheers James

    Read the article

  • UML class diagram vs ER database diagram

    - by salva84
    Hi, I'm a little confused, I'm developing a program, the program consist in two parts, the server and the clients, there are groups, places, messages... stored in the server, and the clients has to connect with it. I've design the use cases diagram, the activity diagrams, and I have design the class diagram too. The thing is that I want to implement the server in a mysql tables for storing the users, groups, places... users in groups... so I've designed a E-R diagram consisting in 6 tables, but the problem is that I think that my class diagram and my ER diagram looks too similar, I mean, I think I'm not doing things right because I have a class for each table practically, and when I have to extract all the users on my system, do I have to convert all the rows into objects at first and write in the database for each object modified? The easy choice for me would be to base my whole application only in the database, and making a class to extract and insert data in it, but I have to follow the UML specification and I'm a little confused what to do with the class diagram, because the books I have read say that I have to create a class for each "entity" of my program. Sorry for my bad English. Thank you.

    Read the article

  • zoom a JPanel and all of its components

    - by user253530
    I have a big JPanel which holds many TileMapping objects (TileMapping extends JPanel). I want to zoom the big JPanel and all of its components to be scaled aswell. A TileMapping has an image which of course has to be zoomed as well. here is my TileMapping class public class TileMapping extends JPanel { private double zoom = 1.0; private Mapping mapping; private int height; private int width; private int xCoord; private int yCoord; TileMapping(Mapping m, int w, int h, int x, int y) { super(); mapping = m; height = h; width = w; this.xCoord = x; this.yCoord = y; this.setPreferredSize(new Dimension(w, h)); } public int getXcoord() { return xCoord; } public int getYcoord() { return yCoord; } public Mapping getMapping() { return mapping; } public void setMapping(Mapping m) { mapping = m; } public void originalSize() { zoom = 1; } public void zoomIn() { zoom += 0.2; } public void zoomOut() { zoom -= 0.2; } @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; if (mapping.getImage() != null) { BufferedImage bg = mapping.getImage(); g2d.scale(zoom, zoom); g2d.drawImage(bg, 0, 0, width, height, this); } else { g2d.scale(zoom, zoom); this.setBackground(Color.white); } } } I need to know how i should continue this on the main JPanel which is populated using this code: This is part of a MapWindow class. if you carefully read the code you will understand what i'm talking about. Basically this is a Tile MapEditor and I am simulating a Tile as a JPanel which holds the mapping object (mapping is a binding between an ASCII character and an image) you place. private void populateMapPanel(Map map) { GridBagConstraints c = new GridBagConstraints(); mapPanel.setLayout(new GridBagLayout()); for (int i = 0; i < map.getMapGrid().getRows(); i++) { for (int j = 0; j < map.getMapGrid().getColumns(); j++) { tile = new TileMapping(map.getMapItem(i, j), cellSize, cellSize, i, j); tile.setBorder(new LineBorder(Color.black)); tile.addMouseListener(this); tile.addMouseMotionListener(this); c.gridx = i; c.gridy = j; mapPanel.add(tile, c); } } mapPanel.validate(); mapPanel.repaint(); } I need to know how to do the following: 1. When the user presses Zoom In the mapPanel should zoom in and also all the images in the smaller panels. 2. when the user click and drag over the TileMappings an image should be painted on them and this image should get scaled of course if the mapPanel is zoomed. Pseudo code, ideas, hints, java code ...anything would be helpful. Thank you

    Read the article

  • Max ping response time?

    - by DougN
    I'm wondering what a maximum (practical) ping response time might be. As far as I know, there isn't a max defined anywhere (TTL, but that's hops, not time). As I think about it, I'm not sure I've ever seen a ping response time of more than a second or so. But as far as I know, there is nothing to stop a remote host from waiting (or being really busy) and not sending the response back for a few seconds. As a simple data point, I just pinged a number of servers around the world and the worst time I could find was 350ms.

    Read the article

  • Different actions on multiple Keydown event

    - by Billy Mitchell
    Okay, so my question (im hoping) is fairly simple. I want to know what to do so that I can create different events for the same keycode. For instance Id like to fade out a div and fade a new one in on the first keypress, then fade that one out and fade a new one in on keypress. Thanks! $(document).keydown(function() { if (event.keyCode == '40') { $('.div-1').fadeOut("slow") $('.div-2').fadeIn("slow") // I'd like this event to occur on the Second keydown $('.div-2').fadeOut("slow") $('.div-3').fadeIn("slow") } });

    Read the article

  • delete all files and folders in multiple directory but leave the directoy

    - by NightsEVil
    well i like this nice of code right here it seems to work awsome but i cant seem to add any more directories to it DirectoryInfo dir = new DirectoryInfo(@"C:\temp"); foreach(FileInfo files in dir.GetFiles()) { files.Delete(); } foreach (DirectoryInfo dirs in dir.GetDirectories()) { dirs.Delete(true); } i would also like to add in special folders aswell like History and cookies and such how would i go about doing that (i would like to include atleast 4-5 different folders)

    Read the article

  • Setting Key Usage attributes with Makecert

    - by nlawalker
    Is it possible to set Key Usage attributes using makecert, or any other tool I can use to generate my own test certificates? The reason I'm interested is that certificates used for BizTalk Server AS2 transport require a key usage of Digital Signature for signing and Data Encipherment or Key Encipherment for encryption/decryption, and I want to play around with this feature. I see how to set enhanced key usage attributes with makecert, but not key usage.

    Read the article

  • Predicate in Java

    - by srikanth
    I am going through the code which uses Predicate in Java. I have never used predicate. Can someone guide me to any tutorial or conceptual explanation of predicate and their implementation in java ? Google didnt help much...

    Read the article

  • "Streaming" MJPG using python.

    - by tyler
    I have a webcam that I want to do some image processing on using Python. It's coming through as a Motion-JPEG. I want to try to process the stuff "live," but really what I want to do is this: Open the URL, start data streaming to some buffer... Read x bytes (where x is image size) to an image Process that image Display in result panel Return to number 2 The problem is that, while I do have the resolution, I have no idea how many bytes to read. I've tried googling the M-JPEG specification but can't find anything on if the images are separated by some header or what. Anybody have any ideas?

    Read the article

  • How to draw multiple rectangles using c#

    - by Nivas
    I have drawn and saved the Rectangle on the image i loaded in the picture box. How i like to draw multiple rectangles for that i tried array in the rectangle but it gives error ("Object reference not set to an instance of an object." (Null reference Exception was unhandled). private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (mybitmap == null) { mybitmap = new Bitmap(sz.Width, sz.Height); } rect[count] = new Rectangle(e.X, e.Y, 0, 0); this.Invalidate(); } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (stayToolStripMenuItem.Checked == true) { switch (e.Button) { case MouseButtons.Left: { rect[count] = new Rectangle(rect[count].Left, rect[count].Top, e.X - rect[count].Left, e.Y - rect[count].Top); pictureBox1.Invalidate(); count++: break; } } } } private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (stayToolStripMenuItem.Checked == true) { button1.Visible = true; button2.Visible = true; if (mybitmap == null) { return; } using (g = Graphics.FromImage(mybitmap)) { using (Pen pen = new Pen(Color.Red, 2)) { //g.Clear(Color.Transparent); e.Graphics.DrawRectangle(pen, rect); label1.Top = rect[count].Top; label1[count].Left = rect[count].Left; label1.Width = rect[count].Width; label1.Height = rect[count].Height; if (label1.TextAlign == ContentAlignment.TopLeft) { e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect); g.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect); g.DrawRectangle(pen, rect[count]); } } } } } How can i do this.....

    Read the article

  • .NET RegEx for letters and spaces

    - by user70192
    I am trying to create a regular expression in C# that allows only alphanumeric characters and spaces. Currently, I am trying the following: string pattern = @"^\w+$"; Regex regex = new Regex(pattern); if (regex.IsMatch(value) == false) { // Display error } What am I doing wrong?

    Read the article

  • UIDEVICE orientation

    - by hardik
    hello all i have my splash screen which i want to show in landscape mode and all other screen in potrait mode. My root view controller is acting as a splash screen i am writing this code in viewdidload method [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight]; But this code is not working and shows me that UIdevice may not respond to setorentation please guide me that how could i change the orentation for only first splash screen and also other screen should be in potrait mode

    Read the article

  • Optimize MySQL query (ngrams, COUNT(), GROUP BY, ORDER BY)

    - by Gerardo
    I have a database with thousands of companies and their locations. I have implemented n-grams to optimize search. I am making one query to retrieve all the companies that match with the search query and another one to get a list with their locations and the number of companies in each location. The query I am trying to optimize is the latter. Maybe the problem is this: Every company ('anunciante') has a field ('estado') to make logical deletes. So, if 'estado' equals 1, the company should be retrieved. When I run the EXPLAIN command, it shows that it goes through almost 40k rows, when the actual result (the reality matching companies) are 80. How can I optimize this? This is my query (XXX represent the n-grams for the search query): SELECT provincias.provincia AS provincia, provincias.id, COUNT(*) AS cantidad FROM anunciantes JOIN anunciante_invertido AS a_i0 ON anunciantes.id = a_i0.id_anunciante JOIN indice_invertido AS indice0 ON a_i0.id_invertido = indice0.id LEFT OUTER JOIN domicilios ON anunciantes.id = domicilios.id_anunciante LEFT OUTER JOIN localidades ON domicilios.id_localidad = localidades.id LEFT OUTER JOIN provincias ON provincias.id = localidades.id_provincia WHERE anunciantes.estado = 1 AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') AND indice0.id IN (SELECT invertido_ngrama.id_palabra FROM invertido_ngrama JOIN ngrama ON ngrama.id = invertido_ngrama.id_ngrama WHERE ngrama.ngrama = 'XXX') GROUP BY provincias.id ORDER BY cantidad DESC And this is the query explained (hope it can be read in this format): id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY anunciantes ref PRIMARY,estado estado 1 const 36669 Using index; Using temporary; Using filesort 1 PRIMARY domicilios ref id_anunciante id_anunciante 4 db84771_viaempresas.anunciantes.id 1 1 PRIMARY localidades eq_ref PRIMARY PRIMARY 4 db84771_viaempresas.domicilios.id_localidad 1 1 PRIMARY provincias eq_ref PRIMARY PRIMARY 4 db84771_viaempresas.localidades.id_provincia 1 1 PRIMARY a_i0 ref PRIMARY,id_anunciante,id_invertido PRIMARY 4 db84771_viaempresas.anunciantes.id 1 Using where; Using index 1 PRIMARY indice0 eq_ref PRIMARY PRIMARY 4 db84771_viaempresas.a_i0.id_invertido 1 Using index 6 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 6 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 5 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 5 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 4 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 4 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 3 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 3 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index 2 DEPENDENT SUBQUERY ngrama const PRIMARY,ngrama ngrama 5 const 1 Using index 2 DEPENDENT SUBQUERY invertido_ngrama eq_ref PRIMARY,id_palabra,id_ngrama PRIMARY 8 func,const 1 Using index

    Read the article

  • Advantages/disadvantages of Python and Ruby

    - by Seburdis
    I know this is going to seem a little like all the other python vs ruby question out there, but I'm not looking specifically to pick one over the other all the time. My question is, essentially, why would you use one language over the other when you are starting a new project? What features does ruby have that python doesn't that would make you decide on it for a given project? What about python over ruby? I was just recently thinking about the differentiation between the two languages because of Jamis Buck's "There is no magic, only awesome" series of articles (4 parts, available here) when I realized I really don't know enough about the two languages to know when to choose one over the other. I'm hoping to get objective answers from people who have experience with both languages, rather than just "python is better, ruby sucks" kind of responses. If you know of a feature in one language that doesn't exist in the other and is great in a certain situation, feel free to chime in and say why you think it's awesome. If you have another language comparable to these that you'd like to suggest pros/cons for, like groovy for example, that would be appreciated too. Some thing I know each language has going for it: Ruby: Awesome metaprogramming Great community Wide selection of Gems Rails Great code readability, usually MacRuby is great for native development on Mac without objc Amazing testing tools (cucumber, rspec, shoulda, autotest, etc.) Python: Whitespace indentation List comprehensions Better functional programming support? Lots of support on linux Easy_install isn't far from gems Great variety of libraries available

    Read the article

  • GWT-RPC vs HTTP Call - which is better??

    - by Nirmal Patel
    I am evaluating if there is a performance variation between calls made using GWT-RPC and HTTP Call. My appln services are hosted as Java servlets and I am currently using HTTPProxy connections to fetch data from them. I am looking to convert them to GWT-RPC calls if that brings in performance improvement. I would like to know about pros/cons of each... Also any suggestions on tools to measure performance of Async calls...

    Read the article

  • any source code for this kind of ajax game?

    - by Dels
    I tried to find source code for this kind of ajax game: http://www.pitstreet.com/cgi-bin/pitstreet/pitgame.pl?lang=en&game=6&level=5 Some info: The objective is to swap image with another with 3 same images or more in row (vertical or horizontal) Maybe someone willing help me?

    Read the article

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