Daily Archives

Articles indexed Saturday January 8 2011

Page 8/30 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How can a new programmer impress the software engineer (boss)? [closed]

    - by Pablo
    Note 1/8/2011: As of this Monday, I'm the new software engineer. Turns out I did not impress the S.E., but ended impressing the CEO. See Joel, not everyone has to leave their Honda idling in front of the airport. =) Ashton, this one is for you buddy. Hi, I'm working at my first programming job. My boss is a very smart software engineer, and I feel like I have very little to offer compared to him. Problem is, he is always busy, and needs someone to help him out. I feel like I'm not good enough, but I still want to succeed. I want to be a great programmer. What can I do to impress him? Thank you.

    Read the article

  • Collision Resolution

    - by CiscoIPPhone
    I know quite well how to check for collisions, but I don't know how to handle the collision in a good way. Simplified, if two objects collide I use some calculations to change the velocity direction. If I don't move the two objects they will still overlap and if the velocity is not big enough they will still collide after next update. This can cause objects to get stuck in each other. But what if I try to move the two objects so they do not overlap. This sounds like a good idea but I have realised that if there is more than two objects this becomes very complicated. What if I move the two objects and one of them collides with other objects so I have to move them too and they may collide with walls etc. I have a top down 2D game in mind but I don't think that has much to do with it. How are collisions usually handled? This question is asked on behalf of Wooh

    Read the article

  • 2D Side Scrolling game and "walk over ground" collision detection

    - by Fire-Dragon-DoL
    The question is not hard, I'm writing a game engine for 2D side scrolling games, however I'm thinking to my 2D side scrolling game and I always come up with the problem of "how should I do collision with the ground". I think I couldn't handle the collision with ground (ground for me is "where the player walk", so something heavily used) in a per-pixel way, and I can't even do it with simple shape comparison (because the ground can be tilted), so what's the correct way? I'know what tiles are and i've read about it, but how much should be big each tile to not appear like a stairs?Are there any other approach? I watched this game and is very nice how he walks on ground: http://www.youtube.com/watch?v=DmSAQwbbig8&feature=player_embedded If there are "platforms" in mid air, how should I handle them?I can walk over them but I can't pass "inside". Imagine a platform in mid air, it allows you to walk over it but limit you because you can't jump in the area she fits Sorry for my english, it's not my native language and this topic has a lot of keywords I don't know so I have to use workarounds Thanks for any answer Additional informations and suggestions: I'm doing a game course in this period and I asked them how to do this, they suggested me this approach (a QuadTree): -All map is divided into "big nodes" -Each bigger node has sub nodes, to find where the player is -You can find player's node with a ray on player position -When you find the node where the player is, you can do collision check through all pixels (which can be 100-200px nothing more) Here is an example, however i didn't show very well the bigger nodes because i'm not very good with photoshop :P How is this approach?

    Read the article

  • problem in loading class from 'me.prettyprint.hector.api.Serializer'

    - by dhananjay patil
    I have created executable jar but having some problem with Class not found Exception. When I type command: java -jar JarFileName.jar arguments.. I get error message, Exception in thread "main" java.lang.NoClassDefFoundError: me/prettyprint/hector/api/Serializer at com.ensarm.niidle.web.scraper.NiidleScrapeManager.main(NiidleScrapeManager.java:21) Caused by: java.lang.ClassNotFoundException: me.prettyprint.hector.api.Serializer at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 1 more please tell me solution for this,class is not getting loaded from the external jar

    Read the article

  • SGML Parser in Python

    - by afg102
    I am completely new to Python. I have the following code: class ExtractTitle(sgmllib.SGMLParser): def __init__(self, verbose=0): sgmllib.SGMLParser.__init__(self, verbose) self.title = self.data = None def handle_data(self, data): if self.data is not None: self.data.append(data) def start_title(self, attrs): self.data = [] def end_title(self): self.title = string.join(self.data, "") raise FoundTitle # abort parsing! which extracts the title element from SGML, however it only works for a single title. I know I have to overload the unknown_starttag and unknown_endtag in order to get all titles but I keep getting it wrong. Help me please!!!

    Read the article

  • CSS/Menu: How to position element right below/beside elements

    - by jiewmeng
    Suppose I have markup as setup http://jsfiddle.net/ADxne/ Currently drop downs look like To solve the 1st problem, I could add a margin-top to child ul's to compensate for padding in list items http://jsfiddle.net/ADxne/1/ .horMenu > li > ul { margin-top: 10px; } but for the 2nd problem without a fixed width list or list items, is there a way to position the sub menu to the right of the list item? Or is the only way to set a fixed width? http://jsfiddle.net/ADxne/2/

    Read the article

  • Why I cant be able to change the UITableViewCell detailTextLabel's frame (just the label's position)?

    - by Simon
    Hi.. I am having a table view with default UITableViewCell of style UITableViewCellStyleValue2. I just want to move detailTextLabel few pixels to the right. I know it makes no sense to adjust its width and height :). I am trying to set detailTextLabel's frame with my x and y value. But its not affecting the its frame. I prefer to use default UITableViewCell, in this case, over a customized cell because the default UITableViewCell automatically manages the text alignment and centering of the labels.. How to change UITableViewCell detailTextLabel's frame? Am I allowed to change its frame? Thanks everyone..

    Read the article

  • Display only latest three results from PHP and MySQL

    - by nogggin1
    <?php $result = @mysql_query('SELECT Article FROM news WHERE ID = (SELECT MAX(ID) FROM News)'); if (!$result) { die('<p>Error performing query: ' . mysql_error() . '</p>'); } while ( $row = mysql_fetch_array($result) ) { echo('<p>' . $row['Article'] . '</p>'); } ?> basically i need to tweak this so that it shows the latest 3 results instead of just the latest one, also i need the order to be: newest 2nd newest 3rd newest any help would be greatly appreciated!

    Read the article

  • Dictionary w/ null key?

    - by Ralph
    Firstly, why doesn't Dictionary<TKey, TValue> support a single null key? Secondly, is there an existing dictionary-like collection that does? I want to store an "empty" or "missing" or "default" System.Type, thought null would work well for this. More specifically, I've written this class: class Switch { private Dictionary<Type, Action<object>> _dict; public Switch(params KeyValuePair<Type, Action<object>>[] cases) { _dict = new Dictionary<Type, Action<object>>(cases.Length); foreach (var entry in cases) _dict.Add(entry.Key, entry.Value); } public void Execute(object obj) { var type = obj.GetType(); if (_dict.ContainsKey(type)) _dict[type](obj); } public static void Execute(object obj, params KeyValuePair<Type, Action<object>>[] cases) { var type = obj.GetType(); foreach (var entry in cases) { if (entry.Key == null || type.IsAssignableFrom(entry.Key)) { entry.Value(obj); break; } } } public static KeyValuePair<Type, Action<object>> Case<T>(Action action) { return new KeyValuePair<Type, Action<object>>(typeof(T), x => action()); } public static KeyValuePair<Type, Action<object>> Case<T>(Action<T> action) { return new KeyValuePair<Type, Action<object>>(typeof(T), x => action((T)x)); } public static KeyValuePair<Type, Action<object>> Default(Action action) { return new KeyValuePair<Type, Action<object>>(null, x => action()); } } For switching on types. There are two ways to use it: Statically. Just call Switch.Execute(yourObject, Switch.Case<YourType>(x => x.Action())) Precompiled. Create a switch, and then use it later with switchInstance.Execute(yourObject) Works great except when you try to add a default case to the "precompiled" version (null argument exception).

    Read the article

  • Prevent coersion to a single type in unlist() or c(); passing arguments to wrapper functions

    - by Leo Alekseyev
    Is there a simple way to flatten a list while retaining the original types of list constituents?.. Is there a way to programmatically construct a heterogeneous list?.. For instance, I want to create a simple wrapper for functions like png(filename,width,height) that would take device name, file name, and a list of options. The naive approach would be something like my.wrapper <- function(dev,name,opts) { do.call(dev,c(filename=name,opts)) } or similar code with unlist(list(...)). This doesn't work because opts gets coerced to character, and the resulting call is e.g. png(filename,width="500",height="500"). If there's no straightforward way to create heterogeneous lists like that, is there a standard idiomatic way to splice arguments into functions without naming them explicitly (e.g. do.call(dev,list(filename=name,width=opts["width"]))? -- Edit -- Gavin Simpson answered both questions below in his discussion about constructing wrapper functions. Let me give a summary of the answer to the title question: It is possible to construct a heterogeneous list with c() provided the arguments to c() are lists. To wit: > foo <- c("a","b"); bar <- 1:3 > c(foo,bar) [1] "a" "b" "1" "2" "3" > c(list(foo),list(bar)) [[1]] [1] "a" "b" [[2]] [1] 1 2 3 > c(as.list(foo),as.list(bar)) ## this creates a flattened heterogeneous list [[1]] [1] "a" [[2]] [1] "b" [[3]] [1] 1 [[4]] [1] 2 [[5]] [1] 3

    Read the article

  • Why will this for loop not return one field from list rather than the list?

    - by Dick Eshelman
    import csv """sample row = 10/6/2010,73.42,74.43,72.9,74.15,2993500""" filename_in = 'c:/python27/scripts/fiverows.csv' reader = csv.reader(open(filename_in, "rb"), dialect="excel", delimiter="\t", quoting =csv.QUOTE_MINIMAL) for row in reader: for item in row: print 'row = ',row print 'item = ', item When you run this script and print the row you get the sample row returned in [] as a list. When you print the item you get the sample row as an unquoted string. Why do I not get each field ie, (10/6/2010), (73.42), etc. returned as an item? How do I return a single item?

    Read the article

  • C# XML node with colon

    - by Sticky
    Hi, my code attempts to grab data from the RSS feed of a website. It grabs the nodes fine, but when attempting to grab the data from a node with a colon, it crashes and gives the error "Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function." The code is shown below: WebRequest request = WebRequest.Create("http://buypoe.com/external.php?type=RSS2&lastpost=true"); WebResponse response = request.GetResponse(); StringBuilder sb = new StringBuilder(""); System.IO.StreamReader rssStream = new System.IO.StreamReader(response.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8")); XmlDocument rssDoc = new XmlDocument(); rssDoc.Load(rssStream); XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item"); for (int i = 0; i < 5; i++) { XmlNode rssDetail; rssDetail = rssItems.Item(i).SelectSingleNode("dc:creator"); if (rssDetail != null) { user = rssDetail.InnerText; } else { user = ""; } } I understand that I need to define the namespace, but am unsure how to do this. Help would be appreciated.

    Read the article

  • How to define template directives (from an API perspective)?

    - by Ralph
    Preface I'm writing a template language (don't bother trying to talk me out of it), and in it, there are two kinds of user-extensible nodes. TemplateTags and TemplateDirectives. A TemplateTag closely relates to an HTML tag -- it might look something like div(class="green") { "content" } And it'll be rendered as <div class="green">content</div> i.e., it takes a bunch of attributes, plus some content, and spits out some HTML. TemplateDirectives are a little more complicated. They can be things like for loops, ifs, includes, and other such things. They look a lot like a TemplateTag, but they need to be processed differently. For example, @for($i in $items) { div(class="green") { $i } } Would loop over $items and output the content with the variable $i substituted in each time. So.... I'm trying to decide on a way to define these directives now. Template Tags The TemplateTags are pretty easy to write. They look something like this: [TemplateTag] static string div(string content = null, object attrs = null) { return HtmlTag("div", content, attrs); } Where content gets the stuff between the curly braces (pre-rendered if there are variables in it and such), and attrs is either a Dictionary<string,object> of attributes, or an anonymous type used like a dictionary. It just returns the HTML which gets plunked into its place. Simple! You can write tags in basically 1 line. Template Directives The way I've defined them now looks like this: [TemplateDirective] static string @for(string @params, string content) { var tokens = Regex.Split(@params, @"\sin\s").Select(s => s.Trim()).ToArray(); string itemName = tokens[0].Substring(1); string enumName = tokens[1].Substring(1); var enumerable = data[enumName] as IEnumerable; var sb = new StringBuilder(); var template = new Template(content); foreach (var item in enumerable) { var templateVars = new Dictionary<string, object>(data) { { itemName, item } }; sb.Append(template.Render(templateVars)); } return sb.ToString(); } (Working example). Basically, the stuff between the ( and ) is not split into arguments automatically (like the template tags do), and the content isn't pre-rendered either. The reason it isn't pre-rendered is because you might want to add or remove some template variables or something first. In this case, we add the $i variable to the template variables, var templateVars = new Dictionary<string, object>(data) { { itemName, item } }; And then render the content manually, sb.Append(template.Render(templateVars)); Question I'm wondering if this is the best approach to defining custom Template Directives. I want to make it as easy as possible. What if the user doesn't know how to render templates, or doesn't know that he's supposed to? Maybe I should pass in a Template instance pre-filled with the content instead? Or maybe only let him tamper w/ the template variables, and then automatically render the content at the end? OTOH, for things like "if" if the condition fails, then the template wouldn't need to be rendered at all. So there's a lot of flexibility I need to allow in here. Thoughts?

    Read the article

  • nginx error: (99: Cannot assign requested address)

    - by k-g-f
    I am running Ubuntu Hardy 8.04 and nginx 0.7.65, and when I try starting my nginx server: $ sudo /etc/init.d/nginx start I get the following error: Starting nginx: [emerg]: bind() to IP failed (99: Cannot assign requested address) where "IP" is a placeholder for my IP address. Does anybody know why that error might be happening? This is running on EC2. My nginx.conf file looks like this: user www-data www-data; worker_processes 4; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; access_log /usr/local/nginx/logs/access.log; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 3; gzip on; gzip_comp_level 2; gzip_proxied any; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; include /usr/local/nginx/sites-enabled/*; } and my /usr/local/nginx/sites-enabled/example.com looks like: server { listen IP:80; server_name example.com; rewrite ^/(.*) https://example.com/$1 permanent; } server { listen IP:443 default ssl; ssl on; ssl_certificate /etc/ssl/certs/myssl.crt; ssl_certificate_key /etc/ssl/private/myssl.key; ssl_protocols SSLv3 TLSv1; ssl_ciphers ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP; server_name example.com; access_log /home/example/example.com/log/access.log; error_log /home/example/example.com/log/error.log; }

    Read the article

  • KXML library Problem

    - by Hesham
    i'm working j2me with netbeans platform and i had a problem while i was trying to read a XML file and i added the library kxml.zip to my project's libraries and i used some of it's functions, there r no errors or red lines in the code, but the problem is that i cant run the project cos it come up with errors while compiling and all these errors are on the kxml functions, so any on can help me through this cos i really dont know what to do to make it run properly

    Read the article

  • Export from a standalone database to an embedded database.

    - by jdana
    I have a two-part application, where there is a central database that is edited, and then at certain times, the data is released and distributed as its own application. I would like to use a standalone database for the central database (MySQL, Postgres, Oracle, SQL Server, etc.) and then have a reliable export to an embedded database (probably SQLite) for distribution. What tools/processes are available for such an export, or is it a practice to be avoided? EDIT: A couple of additional pieces of information. The distributed application should be able to run without having to connect to another server (ex: your spellchecker still works even you don't have internet), and I don't want to install a full DB server for read-only access to the data.

    Read the article

  • Youtube Javascript API play(); not working.. what am I doing wrong?

    - by odpogn
    Hello, I'm playing around with YouTubes Javascript API. I've set up a test page on my local enviornment, but the play function is not working. The video loads, and I can press play on the yt video screen, but my link "play" isn't working. Can someone tell me what I'm doing wrong?? I've been following this: http://code.google.com/apis/youtube/js_api_reference.html <html> <head> <script type="text/javascript" src="public/javascripts/swfobject.js"></script> </head> <body> <div id="ytapiplayer"> You will need Flash 8 or better to view this content. </div> <script type="text/javascript"> var params = { allowScriptAccess: "always" }; var atts = { id: "myytplayer" }; swfobject.embedSWF("http://www.youtube.com/v/OQSNhk5ICTI&enablejsapi=1&playerapiid=ytplayer", "ytapiplayer", "425", "365", "8", null, null, params, atts); function onYouTubePlayerReady(playerId) { ytplayer = document.getElementById("myytplayer"); } function play() { if (ytplayer) { ytplayer.playVideo(); } } </script> <a href="javascript:void(0);" onclick="play();">Play</a> </body> </html>

    Read the article

  • System.Net.WebClient Class in .Net CompactFramework 3.5 ?

    - by Leen15
    Hi at all! I need to comunicate with a Server that give me async answers (streamer connection). I find this: http://msdn.microsoft.com/en-en/library/ms144211%28v=VS.80%29.aspx that generate this event: http://msdn.microsoft.com/en-en/library/system.net.webclient.openreadcompleted%28v=VS.80%29.aspx I think this is what i need, but i don't have the WebClient class in my System.Net of CompactFramework 3.5. How can i do? Thanks. EDIT: I've done a more clear question: httpRequest, httpResponse, send GET through Stream and Receive the Result in C#

    Read the article

  • In forms application, is there any Alternative to MsgBox?

    - by GuruC
    I like how MsgBox stops all further processing until it's clicked but I don't like how it pops that little msgbox in the middle of the screen, which I then have bring to the front if there is a window covering it. Is there a way to do something like a msgbox but keep it on my Form (which is always in view) so I can go ahead and click a button on the form instead of having to bring the little msgbox window on top of windows that may be covering it. I use the msgbox to inform me that a certain situation has happened, which I manually fix and when I'm done I click the MsgBox to continue processing. It'd be nice to have this button right on the form.

    Read the article

  • Fortran 90 How to call a function in a subroutine in a module?

    - by Feynman
    I have a module that "contains" a subroutine that "contains" a function. I say "use themodule" in my main program and I can "call thesubroutine", but how to I get the function that is "contained" in the subroutine? The code looks like this: module useful integer, parameter :: N=2 double precision, parameter :: xmin=1, xmax=10, pi=3.1415926535898 double complex :: green(N,N), solution(N), k=(2.0,0.0) contains subroutine y(n1) contains function x(n1) real :: n1, x x=n1*(xmax-xmin)/N end function x end subroutine y end module useful

    Read the article

  • Prepared statement help, Number of variables doesn't match number of parameters in prepared statement

    - by Sam Gabriel
    I'm getting this error : Number of variables doesn't match number of parameters in prepared statement every time I run this code: $dbh = new mysqli("localhost", "***", "***", "pics"); $stmt = $dbh->prepare("INSERT INTO comments (username, picture, comment) VALUES (?, ?, ?)"); $stmt->bind_Param('s', $username); $stmt->bind_Param('d', $picture); $stmt->bind_Param('s', $comment); $username=$_SESSION['username']; $picture=$_GET['id']; $comment=$_POST['comment']; $stmt->execute(); What's the problem?

    Read the article

  • why is a minus sign prepended to my biginteger?

    - by kyrogue
    package ewa; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.logging.Level; import java.util.logging.Logger; import java.math.BigInteger; /** * * @author Lotus */ public class md5Hash { public static void main(String[] args) throws NoSuchAlgorithmException { String test = "abc"; MessageDigest md = MessageDigest.getInstance("MD5"); try { md.update(test.getBytes("UTF-8")); byte[] result = md.digest(); BigInteger bi = new BigInteger(result); String hex = bi.toString(16); System.out.println("Pringting result"); System.out.println(hex); } catch (UnsupportedEncodingException ex) { Logger.getLogger(md5Hash.class.getName()).log(Level.SEVERE, null, ex); } } } i am testing conversion of byte to hex and when done, the end result has a minus sign on the beginning of the string, why does this happen? i have read the docs and it says it will add a minus sign, however i do not understand it. And will the minus sign affect the hash result? because i am going to implement it to hash password stored on my database

    Read the article

  • Indentation (and wrap-indentation) of debug strings output by printf()/fprintf() in C program

    - by mbaitoff
    I'm using a debug output using printf() in my functions, but the output goes to the console starting at the 1st columns. I'd like to distinguish the nesting level of functions by indenting their output strings each time I dive into the function (it's implemented easily having a static int indentlevel; variable, which is incremented at the beginning of a function, used as a space-filler-count and decremented at the end). But the flaw is that once the output line becomes too long to be wrapped at the console edge, lines' wrapped parts start at column 1 of the console. Should I take care about this, since once the output is redirected to a file, lines are, say, one-line-length, and widths of the lines depend only on the text file viewer settings?

    Read the article

  • mvc contrib pager question - AsPagination

    - by csetzkorn
    Hi, I might be wrong but is the AsPagination method not very inefficient as it sucks all the data from a repository first to initialise TotalItems etc.? So paging is not used to make the data access more efficient. I have not found any examples which use a repository and 'true' paging (i.e. uses TOP etc. in the atcual SQL). How do I use the Pager if I have a repository method with this signature: IList GetData(int? page, out int TotalItems) Any feedback would be very much appreciated. Thanks. Christian

    Read the article

  • How can I correctly calculate the direction for a moving object?

    - by Jakub Hampl
    I'm solving the following problem: I have an object and I know its position now and its position 300ms ago. I assume the object is moving. I have a point to which I want the object to get. What I need is to get the angle from my current object to the destination point in such a format that I know whether to turn left or right. The idea is to assume the current angle from the last known position and the current position. I'm trying to solve this in MATLAB. I've tried using several variations with atan2 but either I get the wrong angle in some situations (like when my object is going in circles) or I get the wrong angle in all situations. Examples of code that screws up: a = new - old; b = dest - new; alpha = atan2(a(2) - b(2), a(1) - b(1); where new is the current position (eg. x = 40; y = 60; new = [x y];), old is the 300ms old position and dest is the destination point. Edit Here's a picture to demonstrate the problem with a few examples: In the above image there are a few points plotted and annotated. The black line indicates our estimated current facing of the object. If the destination point is dest1 I would expect an angle of about 88°. If the destination point is dest2 I would expect an angle of about 110°. If the destination point is dest3 I would expect an angle of about -80°.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >