Daily Archives

Articles indexed Tuesday April 27 2010

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

  • Undefined Variable? But I defined it...

    - by Rob
    Well before anyone claims that theres a duplicate question... (I've noticed that people who can't answer the question tend to run and look for a duplicate, and then report it.) Here is the duplicate you are looking for: http://stackoverflow.com/questions/2481382/php-claims-my-defined-variable-is-undefined However, this isn't quite a duplicate. It gives me a solution, but I'm not really looking for this particular solution. Here is my problem: Notice: Undefined variable: custom Now here is my code: $headers = apache_request_headers(); // Request the visitor's headers. $customheader = "Header: 7ddb6ffab28bb675215a7d6e31cfc759"; //This is what the header should be. foreach ($headers as $header => $value) { $custom .= "$header: $value"; } Clearly, $custom is defined. According to the other question, it's a global and should be marked as one. But how is it a global? And how can I make it a (non-global)? The script works fine, it still displays what its supposed to and acts correctly, but when I turn on error messages, it simply outputs that notice as well. I suppose its not currently necessary to fix it, but I'd like to anyway, as well as know why its doing this.

    Read the article

  • What is a lightweight cross platform WAV playing library?

    - by Lokkju
    I'm looking for a lightweight way to make my program (written in C) be able to play audio files on either windows or linux. I am currently using windows native calls, which is essentially just a single call that is passed a filename. I would like something similar that works on linux. The audio files are Microsoft PCM, Single channel, 22Khz Any Suggestions?

    Read the article

  • Elisp performance on Windows and Linux

    - by JasonFruit
    I have the following dead simple elisp functions; the first removes the fill breaks from the current paragraph, and the second loops through the current document applying the first to each paragraph in turn, in effect removing all single line-breaks from the document. It runs fast on my low-spec Puppy Linux box using emacs 22.3 (10 seconds for 600 pages of Thomas Aquinas), but when I go to a powerful Windows XP machine with emacs 21.3, it takes almost an hour to do the same document. What can I do to make it run as well on the Windows machine with emacs 21.3? (defun remove-line-breaks () "Remove line endings in a paragraph." (interactive) (let ((fill-column 90002000)) (fill-paragraph nil))) : (defun remove-all-line-breaks () "Remove all single line-breaks in a document" (interactive) (while (not (= (point) (buffer-end 1))) (remove-line-breaks) (next-line 1))) Forgive my poor elisp; I'm having great fun learning Lisp and starting to use the power of emacs, but I'm new to it yet.

    Read the article

  • after shuffle a list get array with jquery

    - by robertdd
    i want after i shuffle a list of images to get all the alt="" value in one array! but i get always the save value!why? $('ul').shuffle(); //this will shuffle the list var a = {}; $("ul img").each(function() { a[this.alt] = $(this).attr("alt"); }); $.operation(a, shuffle);

    Read the article

  • C# Extension Methods - To Extend or Not To Extend...

    - by James Michael Hare
    I've been thinking a lot about extension methods lately, and I must admit I both love them and hate them. They are a lot like sugar, they taste so nice and sweet, but they'll rot your teeth if you eat them too much.   I can't deny that they aren't useful and very handy. One of the major components of the Shared Component library where I work is a set of useful extension methods. But, I also can't deny that they tend to be overused and abused to willy-nilly extend every living type.   So what constitutes a good extension method? Obviously, you can write an extension method for nearly anything whether it is a good idea or not. Many times, in fact, an idea seems like a good extension method but in retrospect really doesn't fit.   So what's the litmus test? To me, an extension method should be like in the movies when a person runs into their twin, separated at birth. You just know you're related. Obviously, that's hard to quantify, so let's try to put a few rules-of-thumb around them.   A good extension method should:     Apply to any possible instance of the type it extends.     Simplify logic and improve readability/maintainability.     Apply to the most specific type or interface applicable.     Be isolated in a namespace so that it does not pollute IntelliSense.     So let's look at a few examples in relation to these rules.   The first rule, to me, is the most important of all. Once again, it bears repeating, a good extension method should apply to all possible instances of the type it extends. It should feel like the long lost relative that should have been included in the original class but somehow was missing from the family tree.    Take this nifty little int extension, I saw this once in a blog and at first I really thought it was pretty cool, but then I started noticing a code smell I couldn't quite put my finger on. So let's look:       public static class IntExtensinos     {         public static int Seconds(int num)         {             return num * 1000;         }           public static int Minutes(int num)         {             return num * 60000;         }     }     This is so you could do things like:       ...     Thread.Sleep(5.Seconds());     ...     proxy.Timeout = 1.Minutes();     ...     Awww, you say, that's cute! Well, that's the problem, it's kitschy and it doesn't always apply (and incidentally you could achieve the same thing with TimeStamp.FromSeconds(5)). It's syntactical candy that looks cool, but tends to rot and pollute the code. It would allow things like:       total += numberOfTodaysOrders.Seconds();     which makes no sense and should never be allowed. The problem is you're applying an extension method to a logical domain, not a type domain. That is, the extension method Seconds() doesn't really apply to ALL ints, it applies to ints that are representative of time that you want to convert to milliseconds.    Do you see what I mean? The two problems, in a nutshell, are that a) Seconds() called off a non-time value makes no sense and b) calling Seconds() off something to pass to something that does not take milliseconds will be off by a factor of 1000 or worse.   Thus, in my mind, you should only ever have an extension method that applies to the whole domain of that type.   For example, this is one of my personal favorites:       public static bool IsBetween<T>(this T value, T low, T high)         where T : IComparable<T>     {         return value.CompareTo(low) >= 0 && value.CompareTo(high) <= 0;     }   This allows you to check if any IComparable<T> is within an upper and lower bound. Think of how many times you type something like:       if (response.Employee.Address.YearsAt >= 2         && response.Employee.Address.YearsAt <= 10)     {     ...     }     Now, you can instead type:       if(response.Employee.Address.YearsAt.IsBetween(2, 10))     {     ...     }     Note that this applies to all IComparable<T> -- that's ints, chars, strings, DateTime, etc -- and does not depend on any logical domain. In addition, it satisfies the second point and actually makes the code more readable and maintainable.   Let's look at the third point. In it we said that an extension method should fit the most specific interface or type possible. Now, I'm not saying if you have something that applies to enumerables, you create an extension for List, Array, Dictionary, etc (though you may have reasons for doing so), but that you should beware of making things TOO general.   For example, let's say we had an extension method like this:       public static T ConvertTo<T>(this object value)     {         return (T)Convert.ChangeType(value, typeof(T));     }         This lets you do more fluent conversions like:       double d = "5.0".ConvertTo<double>();     However, if you dig into Reflector (LOVE that tool) you will see that if the type you are calling on does not implement IConvertible, what you convert to MUST be the exact type or it will throw an InvalidCastException. Now this may or may not be what you want in this situation, and I leave that up to you. Things like this would fail:       object value = new Employee();     ...     // class cast exception because typeof(IEmployee) != typeof(Employee)     IEmployee emp = value.ConvertTo<IEmployee>();       Yes, that's a downfall of working with Convertible in general, but if you wanted your fluent interface to be more type-safe so that ConvertTo were only callable on IConvertibles (and let casting be a manual task), you could easily make it:         public static T ConvertTo<T>(this IConvertible value)     {         return (T)Convert.ChangeType(value, typeof(T));     }         This is what I mean by choosing the best type to extend. Consider that if we used the previous (object) version, every time we typed a dot ('.') on an instance we'd pull up ConvertTo() whether it was applicable or not. By filtering our extension method down to only valid types (those that implement IConvertible) we greatly reduce our IntelliSense pollution and apply a good level of compile-time correctness.   Now my fourth rule is just my general rule-of-thumb. Obviously, you can make extension methods as in-your-face as you want. I included all mine in my work libraries in its own sub-namespace, something akin to:       namespace Shared.Core.Extensions { ... }     This is in a library called Shared.Core, so just referencing the Core library doesn't pollute your IntelliSense, you have to actually do a using on Shared.Core.Extensions to bring the methods in. This is very similar to the way Microsoft puts its extension methods in System.Linq. This way, if you want 'em, you use the appropriate namespace. If you don't want 'em, they won't pollute your namespace.   To really make this work, however, that namespace should only include extension methods and subordinate types those extensions themselves may use. If you plant other useful classes in those namespaces, once a user includes it, they get all the extensions too.   Also, just as a personal preference, extension methods that aren't simply syntactical shortcuts, I like to put in a static utility class and then have extension methods for syntactical candy. For instance, I think it imaginable that any object could be converted to XML:       namespace Shared.Core     {         // A collection of XML Utility classes         public static class XmlUtility         {             ...             // Serialize an object into an xml string             public static string ToXml(object input)             {                 var xs = new XmlSerializer(input.GetType());                   // use new UTF8Encoding here, not Encoding.UTF8. The later includes                 // the BOM which screws up subsequent reads, the former does not.                 using (var memoryStream = new MemoryStream())                 using (var xmlTextWriter = new XmlTextWriter(memoryStream, new UTF8Encoding()))                 {                     xs.Serialize(xmlTextWriter, input);                     return Encoding.UTF8.GetString(memoryStream.ToArray());                 }             }             ...         }     }   I also wanted to be able to call this from an object like:       value.ToXml();     But here's the problem, if i made this an extension method from the start with that one little keyword "this", it would pop into IntelliSense for all objects which could be very polluting. Instead, I put the logic into a utility class so that users have the choice of whether or not they want to use it as just a class and not pollute IntelliSense, then in my extensions namespace, I add the syntactical candy:       namespace Shared.Core.Extensions     {         public static class XmlExtensions         {             public static string ToXml(this object value)             {                 return XmlUtility.ToXml(value);             }         }     }   So now it's the best of both worlds. On one hand, they can use the utility class if they don't want to pollute IntelliSense, and on the other hand they can include the Extensions namespace and use as an extension if they want. The neat thing is it also adheres to the Single Responsibility Principle. The XmlUtility is responsible for converting objects to XML, and the XmlExtensions is responsible for extending object's interface for ToXml().

    Read the article

  • 3G/Edge/GPRS IP addresses and geocoding

    - by LookitsPuck
    Hey all! So, we're looking to develop a mobile website. On this mobile website, we'd like to automatically populate a user's location (with proper fallback) based on their IP address. I'm aware of geocoding a location based on IP address (mapping to latitude, longitude and then getting the location with that information). However, I'm curious how accurate this information is? Are mobile devices assigned IP's when they utilize 3G, EDGE, and GPRS connections? I think so. If that is so, does it map to a relatively accurate location? It doesn't have to be spot on, but relatively accurate would be nice. Thanks! -Steve

    Read the article

  • Freezing a dead(ish) laptop battery...

    - by Wesley
    I have a Compaq CQ50-215CA laptop with a battery that does not properly hold charge. Vista's battery meter does not read the remaining charge left; the laptop will randomly shut down at ~60% and sometimes the meter goes back up to 100% before shutting down without warning. So, does freezing a dead-ish laptop battery somehow repair it and allow it to hold charge again?

    Read the article

  • Shell extension installation not recognized by Windows 7 64-bit shell

    - by Avalanchis
    I have a Copy Hook Handler shell extension that I'm trying to install on Windows 7 64-bit. The shell extension DLL is compiled in two separate versions for 32-bit and 64-bit Windows. The DLL implements DLLRegisterServer which adds the necessary registry entries. After adding the registry entries, it calls the following line of code to nofity the Windows shell: SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); Everything works great on Windows7 32-bit. The shell recognizes the extension immediately. On 64-bit, the shell extension is only recognized after the shell is restarted. Is there anything I can do to cause the extension to be recognized without restarting the 64-bit shell?

    Read the article

  • RadWindow AlwaysOnTop

    - by klausbyskov
    Does anyone have any experience with the RadWindow wpf control from Telerik? My problem is that when I open a RadWindow and minimize my application then when I maximize the application the RadWindow is not visible. I can use alt+tab to get the RadWindow in front again, but I would really like to avoid having to do this. I'm doing the following to display the RadWindow: this.theWindow.ShowDialog(); Where theWindow is an instance of a class that inherits from RadWindow. Any ideas?

    Read the article

  • Virtual PC (XPMode) - How to access Webserver on guest from host

    - by sannoble
    I have Windows XP running inside Windows 7 via Virtual PC (XPMode) and installed Zend Server CE on the virtual XP guest. The webserver is running and can be accessed on the guest, but I cannot access the webserver from the Win7 host. I configured a static IP address and subnet of 255.255.255.0 on the guest and can ping this IP from the guest but not from the host. The other way it works fine, i.e. I can ping the host from the guest. I can also access the internet from the virtual XP guest. I tried different Network Options in the VirtualPC settings, but nothing helps. Googling the topic I couldn't find anything helpful yet. Any idea, what I could try to access the webserver on the virtual XP guest from the Win7 host?

    Read the article

  • "Disabled use of AcceptEx() WinSock2 API" error on Windows 7 using Tomcat

    - by Richard
    When starting Tomcat 6 on Windows 7 Enterprise with JRE 6 using C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\tomcat6.exe the application does not open and my event viewer has the message: "Disabled use of AcceptEx() WinSock2 API." The same installer of Tomcat worked on Windows Vista before I upgraded my operating system. Can anyone please suggest a way to fix this? The only site I can find mentioning this is http://www.apachelounge.com/viewtopic.php?p=4418 which suggests using this config setting "Win32DisableAcceptEx" - but it's for Apache, not Tomcat, and I have no idea where in what config file it might need to go in Tomcat.

    Read the article

  • how to read a string from a \n delimited file

    - by Matias
    I'm trying to read a return delimited file. full of phrases. I'm trying to put each phrase into a string. The problem is that when I try to read the file with fscanf(file,"%50s\n",string); the string only contains one word. when it bumps with a space it stops reading the string

    Read the article

  • How can you pass GET values to another url in php? GET value forwarding

    - by gobackpacking
    Ok, so I'm using Jquery's AJAX function and it's having trouble passing a URL with a http address. So I'm hoping to "get" the GET values and send them to another URL — so: a local php file begin passed GET values, which in turn forwards the GET values to another url. Maybe curl is the answer? I don't know. It's got to be a very short answer I know. pseudo code: //retrieve the GET values $var retrieve [GET] //passing it to another url send get values to url ($var, url_address)

    Read the article

  • Visual Studio 2008 and Windows 7 render text differently

    - by niq
    I have attached a screen shot : http://i.imgur.com/tU05T.png I have checked my DPI settings. they are 100%. I cant seem to find out why the test would be a differnt font size in the runtime application vs the designer.. Can anyone assist. I have tried googling, have have not come up with any meaningful links..

    Read the article

  • WCF on Windows 7 not working

    - by Nyla Pareska
    I am using an example from iDesign about one way calls. I can get it to work on a Vista machine (VS2008) but not on a windows 7 machine (VS2010). I get this error: HTTP could not register URL http://+:8001/MyService/. Your process does not have access rights to this namespace ServiceHost host = new ServiceHost(typeof(MyService)); host.Open(); I get the error on the host.Open(); line. I noticed that windows asks first for some firewall and to give permission which I did but still it is not working. What can I do?

    Read the article

  • PDO::PARAM for type decimal?

    - by dmontain
    I have 2 database fields `decval` decimal(5,2) `intval` int(3) I have 2 pdo queries that update them. The one that updates the int works ok $update_intval->bindParam(':intval', $intval, PDO::PARAM_INT); but I can't update the decimal field. I've tried the 3 ways below, but nothing works $update_decval->bindParam(':decval', $decval, PDO::PARAM_STR); $update_decval->bindParam(':decval', $decval, PDO::PARAM_INT); $update_decval->bindParam(':decval', $decval); It seems the problem is with the database type decimal? Is there a PDO::PARAM for a field of type decimal? If not, what do I use as a workaround?

    Read the article

  • Programatically enable / disable multitouch finger input?

    - by winSharp93
    I have a multitoch-enabled tablet PC running Windows 7. However, when using the stylus pen and getting too far away from the display, I often accidently hit it with my fingers which causes unwanted mouse-clicks. The solution is navigating to "Control Panel - Pen- and Finger Input - Finger Input" and deactivate the checkbox "Use the finger as an input device" (all titles translated so they might be different on an English windows). Now I am wondering whether I can do this programatically, too, so I would be able to write a little tray app for this. I tried using Process Monitor to find out registry keys, however, I did not find one which really shows the same effect as the checkbox. Does anyone know how to access this property (without using UI-Automation)? Cheers winSharp93

    Read the article

  • new Date() timezone in grails

    - by xain
    Hi, I'm inserting a date in grails using "new Date()" and when I read the record, it's three hours ahead the O.S.'s system time. Is there a configuration to fix this ? Thanks in advance.

    Read the article

  • Sharepoint edit task from outlook on windows7

    - by Alex
    I have sharepoint approval workflow on Moss2007. Windows XP users are able to approve the task from their outlook. But in windows 7, outlook would not open the task edit form at all and no error message either. is there anything need to be turned off/on in windows 7 outlook in order to approve an item from their inbox?

    Read the article

  • Handling Java stdout and stderr in Perl

    - by syker
    I am trying to run a Java program from my Perl script. I would like to avoid using System.exit(1) and System.exit(-1) commands in Java. I am however printing to STDOUT and STDERR from Java. In my Perl script, I am reading from Java's stdout and using that line by line output. How do I print stderr and fail if I ever see stderr? This is what I have so far: my $java_command = ...; open(DATA, ">$java_command"); while (<DATA>) { chomp($_); .... .... }

    Read the article

  • How can I declare a pointer structure using {}?

    - by Y_Y
    This probably is one of the easiest question ever in C programming language... I have the following code: typedef struct node { int data; struct node * after; struct node * before; }node; struct node head = {10,&head,&head}; Is there a way I can make head to be *head [make it a pointer] and still have the availability to use '{ }' [{10,&head,&head}] to declare an instance of head and still leave it out in the global scope? For example: //not legal!!! struct node *head = {10,&head,&head};

    Read the article

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