Daily Archives

Articles indexed Tuesday May 4 2010

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

  • How to use C to write a C compiler?

    - by israkir
    I am taking a compiler course this semester and we talked about this interesting thing in the class. Teacher used an example of p-code along with pascal to explain it. After google-ing a bit, I saw this phenomena is called self-hosting and naturally related to the first compilers. Ok, there is an interpreter which interprets the compiler source code written in its own language. But, there is still something missing in the explanations I found. I mean, there are some parts still looks mysterious (what about the interpreter? it is also a program, still need to be translated into machine code etc...) What I am asking you guys is that can you explain it as simple as possible or provide any online resource which you think that it explains this phenomena precisely..

    Read the article

  • Fixed mouse pointer with jQuery draggable

    - by MikeWyatt
    I'm building a little game in HTML5. The canvas element is a viewport into the game world. The user can move the viewport's position in the world by clicking and dragging with the mouse on a small icon. The problem is that the scrolling stops when the mouse pointer hits the edge of the screen. In all likelihood, that will limit scrolling in one of the directions severely, since the icon will be in one of the corners of the page. The only technical solution I can think of would be to somehow fix the mouse pointer's position on the icon and detect the relative movement each frame. Basically I would just reset the pointer position back to the center of the icon after each drag event. Unfortunately, I'm fairly positive that this is not possible. Playing with the user's pointer is a big no-no from a usability and security standpoint. So, is there any other way to do what I want? I'm primarily looking for technical ideas here, but suggestions for a more appropriate interface would also be welcome.

    Read the article

  • What's the reason both Image and Bitmap classes don't implement a custom equality/hashcode logic?

    - by devoured elysium
    From MSDN documentation, it seems as both GetHashCode() and Equals() haven't been overriden in Bitmap. Neither have them been overriden in Image. So both classes are using the Object's version of them just compares references. I wasn't too convinced so I decided to fire up Reflector to check it out. It seems MSDN is correct in that matter. So, is there any special reason why MS guys wouldn't implement "comparison logic", at least for the Bitmap class? I find it is kinda acceptable for Image, as it is an abstract class, but not so much for the Bitmap class. I can see in a lot of situations calculating the hash code can be an expensive operation, but it'd be alright if it used some kind of lazy evaluation (storing the computed hash code integer in a variable a variable, so it wouldn't have to calculate it later again). When wanting to compare 2 bitmaps, will I have to resort to having to run all over the picture comparing each one of its pixels? Thanks

    Read the article

  • What is the fastest way to validate that a field has no more than n words?

    - by James A. Rosen
    I have a Ruby-on-Rails model: class Candidate < ActiveRecord::Base validates_presence_of :application_essay validate :validate_length_of_application_essay protected def validate_length_of_application_essay return if application_essay.blank? # don't add a second error message if they didn't fill it out errors.add(:application_essay, :too_long), unless ... end end Without dropping into C, what is the fastest way to check that the application_essay contains no more than 500 words? You can assume that most essays will be at least 200 words, are unlikely to be more than 5000 words, and are in English (or the pseudo-English sometimes called "business-ese"). You can also classify anything you want as a "word" as long as your classification would be immediately obvious to a typical user. (NB: this is not the place to debate what a "typical user" is :) )

    Read the article

  • Broadcasting an intent to a specific component.

    - by Nic Strong
    I have an activity that is starting a background operation in another service. This activity receives various notifications from this service. As part of the intent I use to initiate the background operation I pass extra data with the context of my activity so the background service can broadcast intents back to me (the download service is a good example of this usage). So in the activity I use the following to attach the context: intent.putExtra(Intents.EXTRA_NOTIFICATION_PACKAGE, IntentTestActivity.this.getPackageName()); intent.putExtra(Intents.EXTRA_NOTIFICATION_CLASS, IntentTestActivity.class.getCanonicalName()); intent.putExtra(Intents.EXTRA_NOTIFICATION_EXTRAS, myContext); I register for the notifications in the activity: IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intents.ACTION_NOTIFICATION); intentFilter.addCategory(Intents.CATEGORY_COMPLETION); intentFilter.addCategory(Intents.CATEGORY_PROGRESSS); Intent intent = registerReceiver(receiver, intentFilter); In the background service I send notifications with the following code: void broadcastNotification(String action, String category, String packageName, String className, String extras, int operationResult) { Intent intent = new Intent(action); intent.addCategory(category); intent.setClassName(packageName, className); if (extras != null) { intent.putExtra(Intents.EXTRA_NOTIFICATION_EXTRAS, extras); } intent.putExtra(Intents.EXTRA_OPERATION_RESULT, operationResult); context.sendBroadcast(intent); } My problem is that the above broadcast will never be received. If however I comment out the line intent.setClassName(packageName, className); Then the broadcast is received. Is it a problem with my filter? Do I have to specify intents intended for a specific component? Or cannot I not use such fine grain control over the delivery of broadcasts. Thanks, Nic

    Read the article

  • Splitting a filename into words and numbers in Python

    - by danspants
    The following code splits a string into a list of words but does not include numbers: txt="there_once was,a-monkey.called phillip?09.txt" sep=re.compile(r"[\s\.,-_\?]+") sep.split(txt) ['there', 'once', 'was', 'a', 'monkey', 'called', 'phillip', 'txt'] This code gives me words and numbers but still includes "_" as a valid character: re.findall(r"\w+|\d+",txt) ['there_once', 'was', 'a', 'monkey', 'called', 'phillip', '09', 'txt'] What do I need to alter in either piece of code to end up with the desired result of: ['there', 'once', 'was', 'a', 'monkey', 'called', 'phillip', '09', 'txt']

    Read the article

  • jQuery: Cannot change style of element after selected

    - by JamesBrownIsDead
    Here is my code. Where you see "alert([...]);", an alert pops up. Why doesn't the CSS style change? The 'click' event fires, too! resolveSideMenuAddress: function () { var firstLink = $("#masterHeaderMenu .masterHeaderMenuButton a:first"); function select(link) { alert('i alert'); link.css({ 'color': '#9a4d9e', 'cursor': 'default' }); alert('color and cursor not changed'); link.click(function () { alert('click'); return false; }); } if (window.location.pathname === firstLink.attr('href')) { alert('i alert'); select(firstLink); } } I've tried addClass() and can't change the color of the link that way either.

    Read the article

  • Unit testing in Web2py

    - by Wraith
    I'm following the instructions from this post but cannot get my methods recognized globally. The error message: ERROR: test_suggest_performer (__builtin__.TestSearch) ---------------------------------------------------------------------- Traceback (most recent call last): File "applications/myapp/tests/test_search.py", line 24, in test_suggest_performer suggs = suggest_flavors("straw") NameError: global name 'suggest_flavors' is not defined My test file: import unittest from gluon.globals import Request db = test_db execfile("applications/myapp/controllers/search.py", globals()) class TestSearch(unittest.TestCase): def setUp(self): request = Request() def test_suggest_flavors(self): suggs = suggest_flavors("straw") self.assertEqual(len(suggs), 1) self.assertEqual(suggs[0][1], 'Strawberry') My controller: def suggest_flavors(term): return [] Has anyone successfully completed unit testing like this in web2py?

    Read the article

  • Strange IIS hits originating from Trend Micro

    - by TesterTurnedDeveloper
    I'm trying to trace thru an error on a extranet site I maintain. I've had a look thru the logs, and I'm seeing hits originate from these IP addresses: 216.104.15.130 216.104.15.138 216.104.15.142 216.104.15.13 150.70.84.49 150.70.84.44 Network-tools.com gives 'TREND MICRO INCORPORATED' as the owner of all these IPs. The hits fail as they aren't sending any cookies (therefore aren't considered logged in). The hits are to pages containing URLs that only the logged in user would see, i.e. ImageEdit.aspx?ImageId=467424. I.e. the server isn't guessing these URLs, someone would have to log into the site to know these URLs exist. Theory: the Trend Antivirus client grabs URLs and sends them to the server for 'extra processing'? Googling around gives me this: http://www.forumpostersunion.com/showthread.php?p=51272 - where people are reporting comment spam from these addresses. The articles says their servers have been hacked (a few months ago, presumably fixed now?). A hacked server wouldn't explain how the URLs have been plucked off the user's PCs. Has anyone seen this before? Anything nefarious going on here?

    Read the article

  • Webserver: Performance impact when storing session files on /dev/shm

    - by GetFree
    I have a website runing on a typical setup: Linux, Apache, PHP, MySQL. However, what's not typical about it, is that it's getting tons of traffic (400,000+ visits a day) and so, efficiency is becoming more and more important to me. I'm constantly looking for things I could optimize and, right now, my attention is focused on PHP's session files. There's a hell lot of session files constantly being read and created on the /tmp directory. So my question is: Is it a good idea to store the session files in /dev/shm (tmpfs) in order to speed things up a little bit??

    Read the article

  • How do I change the font formatting of cells in Google Spreadsheets?

    - by NoCatharsis
    I am trying to add checkboxes to a spreadsheet in Google Spreadsheets. I found an interesting solution to this problem here in Google's help. The second post on that thread states you can just format the cell to Wingdings 2 and certain characters will correspond to a checkbox. Now the problem is I have no idea how to change the font of a cell, as the Format menu only has 6 font options. How can I add or use other fonts? Bonus question: Is this even the best way to do what I'm trying to do, considering Google Spreadsheets does not support checkboxes or dropdowns?

    Read the article

  • Oracle EBS R12.1.1 system09.dbf file corruption Bug

    - by longchun.zhu
    ??????,??????????????????,???? ?????????????.. ???????????,??????,???????????? After Installing or Upgrading Perform the following steps after installing or upgrading to Release 12.1.1 and before allowing users to access the system. Manually fix database dbf file If you installed 12.1.1 with a startCD of 12.1.1.9 or earlier (see Oracle Applications Release Notes, Release 12.1.1 My Oracle Support Document 798258.1), you must run the following sql commands to fix a particular corrupted dbf file: $ sqlplus/nolog sql connect / as sysdba sql alter database datafile '[full path of system09.dbf]' resize 1000M; sql alter database datafile '[full path of system09.dbf]' resize 1500M;

    Read the article

  • ???Oracle EBS R12.1.1 Upgrade ?R12.1.2 ??

    - by longchun.zhu
    ??????EBS R12.1.1 ???,????,???????????,???????,?????????, ??????????,????,???? 2 ???,?????,???SR ,?????BUG??? ??: - Oracle Linux 5.2 (x86_64bit) - Oracle EBS R12.1.1 (x86_64bit) upgrade R12.1.2 - DB:11.1.0.7 ??????: ??: - ?Oracle AS 10g ??? - ?Oracle AS 10G for Forms and reports ??? - ???DBA UP2 ???8502056 - ?7303033 US ?? ### ??????,?????. - ?8937577 US ?? - ?7303033 CHS ?? - ?8937577 CHS ?? - ????APPS DBA ???????,autocfg ??appsutil.zip ?? ?????,?????HRMS ???,?????????? ?????1: 2?FORM ????? 2. ????66??????

    Read the article

  • Will C++/CLI give me control over low-level devices like audio?

    - by schmoopy
    I was wondering - how much limitation is there to C++/CLI compared to classic C++ (chuckle) - I was wanting to write an application that I cannot do with c# -- I was wanting to be able to connect to the PC's audio device and detect audio (for example) - Is this something I can do with C++/CLI? I have tried using NAudio with c#, but i have been able to do this. What other advantages would C++/CLI or C++ give me over c#?

    Read the article

  • How to HIDE the iPad keyboard from a MODAL view controller?

    - by Cal
    I'm trying to hide the iPad keyboard from a modal view controller but it doesn't work. I have tried resignFirstResponder but that doesn't have any affect if we are in a modal view controller. I tried resignFirstResponder in a non-modal UINavigationController with the very same UIViewController and the keyboard hides correctly. Does anyone know how solve this problem? Thanks. [Update] it looks like there's something wrong with my code because the resignFirstResponder does work (I made a simple test case instead of using my code). But I still don't know what the problem is.

    Read the article

  • How would I find all sets of N single-digit, non-repeating numbers that add up to a given sum in PHP

    - by TerranRich
    Let's say I want to find all sets of 5 single-digit, non-repeating numbers that add up to 30... I'd end up with [9,8,7,5,1], [9,8,7,4,2], [9,8,6,4,3], [9,8,6,5,2], [9,7,6,5,3], and [8,7,6,5,4]. Each of those sets contains 5 non-repeating digits that add up to 30, the given sum. Any help would be greatly appreciated. Even just a starting point for me to use would be awesome. I came up with one method, which seems like a long way of going about it: get all unique 5-digit numbers (12345, 12346, 12347, etc.), add up the digits, and see if it equals the given sum (e.g. 30). If it does, add it to the list of possible matching sets. I'm doing this for a personal project, which will help me in solving Kakuro puzzles without actually solving the whole thing at once. Yeah, it may be cheating, but it's... it's not THAT bad... :P

    Read the article

  • Unit Testing-- fundamental goal?

    - by David
    Me and my co-workers had a bit of a disagreement last night about unit testing in our PHP/MySQL application. Half of us argued that when unit testing a function within a class, you should mock everything outside of that class and its parents. The other half of us argued that you SHOULDN'T mock anything that is a direct dependancy of the class either. The specific example was our logging mechanism, which happened through a static Logging class, and we had a number of Logging::log() calls in various locations throughout our application. The first half of us said the Logging mechanism should be faked (mocked) because it would be tested in the Logging unit tests. The second half of us argued that we should include the original Logging class in our unit test so that if we make a change to our logging interface, we'll be able to see if it creates problems in other parts of the application due to failing to update the call interface. So I guess the fundamental question is-- do unit tests serve to test the functionality of a single unit in a closed environment, or show the consequences of changes to a single unit in a larger environment? If it's one of these, how do you accomplish the other?

    Read the article

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