Daily Archives

Articles indexed Thursday April 29 2010

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

  • django manage.py syncdb not working?

    - by Diego
    Trying to learn Django, I closed the shell and am getting this problem now when I call python manage.py syncdb, any idea what happened?: I've already set up a db. I have manage.py set up in the folder django_bookmarks. What's up here? Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management my-computer:~/Django-1.1.1/django_bookmarks mycomp$ export PATH=/Users/mycomp/bin:$PATH my-computer:~/Django-1.1.1/django_bookmarks mycomp$ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management my-computer:~/Django-1.1.1/django_bookmarks mycomp$

    Read the article

  • Populating an NSBrowser (Cocoa OSX)

    - by Michael Minerva
    I want to make a widget that displays a column of selectable text data. It seems that the NSBrowser is the best cocoa object to do this but I cannot figure out how to populate the NSBrowser with any sort of data. I assume I can set the string value of an NsBrowserCell but no where in the documentation can I find where to add a new cell to a column. Am I using the wrong object?

    Read the article

  • Wandering CGAffineTransformMakeRotation

    - by Joe
    Okay this is about to make me insane -- any help would be appreciated. I have two images which are part of a timer application. One is the needle/hand and the other is a little hub which is styled to look like the needle base. I'm using a CGAffineTransformMakeRotation to rotate the needle and the base stays stationary. The problem: there is like a 1-2px 'wander' to the needle's rotation which makes it look like it's moving off center in relation to the base. I have worked the base and needle image over in PS extensively, and both are dead center pixel wise -- seriously. My method to rotate the hand: -(IBAction) rotateSteamArrow{ CGAffineTransform rotate = CGAffineTransformMakeRotation( degreesSteam / 180.0 * 3.14159265); degreesSteam = degreesSteam + 1.5; if (degreesSteam <= 180) { [steamNeedle setTransform:rotate]; } else { [self handleSteamTimer]; [self toggleButton:(id)timerButton]; [self switchSound]; } }

    Read the article

  • C#: Adding Functionality to 3rd Party Libraries With Extension Methods

    - by James Michael Hare
    Ever have one of those third party libraries that you love but it's missing that one feature or one piece of syntactical candy that would make it so much more useful?  This, I truly think, is one of the best uses of extension methods.  I began discussing extension methods in my last post (which you find here) where I expounded upon what I thought were some rules of thumb for using extension methods correctly.  As long as you keep in line with those (or similar) rules, they can often be useful for adding that little extra functionality or syntactical simplification for a library that you have little or no control over. Oh sure, you could take an open source project, download the source and add the methods you want, but then every time the library is updated you have to re-add your changes, which can be cumbersome and error prone.  And yes, you could possibly extend a class in a third party library and override features, but that's only if the class is not sealed, static, or constructed via factories. This is the perfect place to use an extension method!  And the best part is, you and your development team don't need to change anything!  Simply add the using for the namespace the extensions are in! So let's consider this example.  I love log4net!  Of all the logging libraries I've played with, it, to me, is one of the most flexible and configurable logging libraries and it performs great.  But this isn't about log4net, well, not directly.  So why would I want to add functionality?  Well, it's missing one thing I really want in the ILog interface: ability to specify logging level at runtime. For example, let's say I declare my ILog instance like so:     using log4net;     public class LoggingTest     {         private static readonly ILog _log = LogManager.GetLogger(typeof(LoggingTest));         ...     }     If you don't know log4net, the details aren't important, just to show that the field _log is the logger I have gotten from log4net. So now that I have that, I can log to it like so:     _log.Debug("This is the lowest level of logging and just for debugging output.");     _log.Info("This is an informational message.  Usual normal operation events.");     _log.Warn("This is a warning, something suspect but not necessarily wrong.");     _log.Error("This is an error, some sort of processing problem has happened.");     _log.Fatal("Fatals usually indicate the program is dying hideously."); And there's many flavors of each of these to log using string formatting, to log exceptions, etc.  But one thing there isn't: the ability to easily choose the logging level at runtime.  Notice, the logging levels above are chosen at compile time.  Of course, you could do some fun stuff with lambdas and wrap it, but that would obscure the simplicity of the interface.  And yes there is a Logger property you can dive down into where you can specify a Level, but the Level properties don't really match the ILog interface exactly and then you have to manually build a LogEvent and... well, it gets messy.  I want something simple and sexy so I can say:     _log.Log(someLevel, "This will be logged at whatever level I choose at runtime!");     Now, some purists out there might say you should always know what level you want to log at, and for the most part I agree with them.  For the most party the ILog interface satisfies 99% of my needs.  In fact, for most application logging yes you do always know the level you will be logging at, but when writing a utility class, you may not always know what level your user wants. I'll tell you, one of my favorite things is to write reusable components.  If I had my druthers I'd write framework libraries and shared components all day!  And being able to easily log at a runtime-chosen level is a big need for me.  After all, if I want my code to really be re-usable, I shouldn't force a user to deal with the logging level I choose. One of my favorite uses for this is in Interceptors -- I'll describe Interceptors in my next post and some of my favorites -- for now just know that an Interceptor wraps a class and allows you to add functionality to an existing method without changing it's signature.  At the risk of over-simplifying, it's a very generic implementation of the Decorator design pattern. So, say for example that you were writing an Interceptor that would time method calls and emit a log message if the method call execution time took beyond a certain threshold of time.  For instance, maybe if your database calls take more than 5,000 ms, you want to log a warning.  Or if a web method call takes over 1,000 ms, you want to log an informational message.  This would be an excellent use of logging at a generic level. So here was my personal wish-list of requirements for my task: Be able to determine if a runtime-specified logging level is enabled. Be able to log generically at a runtime-specified logging level. Have the same look-and-feel of the existing Debug, Info, Warn, Error, and Fatal calls.    Having the ability to also determine if logging for a level is on at runtime is also important so you don't spend time building a potentially expensive logging message if that level is off.  Consider an Interceptor that may log parameters on entrance to the method.  If you choose to log those parameter at DEBUG level and if DEBUG is not on, you don't want to spend the time serializing those parameters. Now, mine may not be the most elegant solution, but it performs really well since the enum I provide all uses contiguous values -- while it's never guaranteed, contiguous switch values usually get compiled into a jump table in IL which is VERY performant - O(1) - but even if it doesn't, it's still so fast you'd never need to worry about it. So first, I need a way to let users pass in logging levels.  Sure, log4net has a Level class, but it's a class with static members and plus it provides way too many options compared to ILog interface itself -- and wouldn't perform as well in my level-check -- so I define an enum like below.     namespace Shared.Logging.Extensions     {         // enum to specify available logging levels.         public enum LoggingLevel         {             Debug,             Informational,             Warning,             Error,             Fatal         }     } Now, once I have this, writing the extension methods I need is trivial.  Once again, I would typically /// comment fully, but I'm eliminating for blogging brevity:     namespace Shared.Logging.Extensions     {         // the extension methods to add functionality to the ILog interface         public static class LogExtensions         {             // Determines if logging is enabled at a given level.             public static bool IsLogEnabled(this ILog logger, LoggingLevel level)             {                 switch (level)                 {                     case LoggingLevel.Debug:                         return logger.IsDebugEnabled;                     case LoggingLevel.Informational:                         return logger.IsInfoEnabled;                     case LoggingLevel.Warning:                         return logger.IsWarnEnabled;                     case LoggingLevel.Error:                         return logger.IsErrorEnabled;                     case LoggingLevel.Fatal:                         return logger.IsFatalEnabled;                 }                                 return false;             }             // Logs a simple message - uses same signature except adds LoggingLevel             public static void Log(this ILog logger, LoggingLevel level, object message)             {                 switch (level)                 {                     case LoggingLevel.Debug:                         logger.Debug(message);                         break;                     case LoggingLevel.Informational:                         logger.Info(message);                         break;                     case LoggingLevel.Warning:                         logger.Warn(message);                         break;                     case LoggingLevel.Error:                         logger.Error(message);                         break;                     case LoggingLevel.Fatal:                         logger.Fatal(message);                         break;                 }             }             // Logs a message and exception to the log at specified level.             public static void Log(this ILog logger, LoggingLevel level, object message, Exception exception)             {                 switch (level)                 {                     case LoggingLevel.Debug:                         logger.Debug(message, exception);                         break;                     case LoggingLevel.Informational:                         logger.Info(message, exception);                         break;                     case LoggingLevel.Warning:                         logger.Warn(message, exception);                         break;                     case LoggingLevel.Error:                         logger.Error(message, exception);                         break;                     case LoggingLevel.Fatal:                         logger.Fatal(message, exception);                         break;                 }             }             // Logs a formatted message to the log at the specified level.              public static void LogFormat(this ILog logger, LoggingLevel level, string format,                                          params object[] args)             {                 switch (level)                 {                     case LoggingLevel.Debug:                         logger.DebugFormat(format, args);                         break;                     case LoggingLevel.Informational:                         logger.InfoFormat(format, args);                         break;                     case LoggingLevel.Warning:                         logger.WarnFormat(format, args);                         break;                     case LoggingLevel.Error:                         logger.ErrorFormat(format, args);                         break;                     case LoggingLevel.Fatal:                         logger.FatalFormat(format, args);                         break;                 }             }         }     } So there it is!  I didn't have to modify the log4net source code, so if a new version comes out, i can just add the new assembly with no changes.  I didn't have to subclass and worry about developers not calling my sub-class instead of the original.  I simply provide the extension methods and it's as if the long lost extension methods were always a part of the ILog interface! Consider a very contrived example using the original interface:     // using the original ILog interface     public class DatabaseUtility     {         private static readonly ILog _log = LogManager.Create(typeof(DatabaseUtility));                 // some theoretical method to time         IDataReader Execute(string statement)         {             var timer = new System.Diagnostics.Stopwatch();                         // do DB magic                                    // this is hard-coded to warn, if want to change at runtime tough luck!             if (timer.ElapsedMilliseconds > 5000 && _log.IsWarnEnabled)             {                 _log.WarnFormat("Statement {0} took too long to execute.", statement);             }             ...         }     }     Now consider this alternate call where the logging level could be perhaps a property of the class          // using the original ILog interface     public class DatabaseUtility     {         private static readonly ILog _log = LogManager.Create(typeof(DatabaseUtility));                 // allow logging level to be specified by user of class instead         public LoggingLevel ThresholdLogLevel { get; set; }                 // some theoretical method to time         IDataReader Execute(string statement)         {             var timer = new System.Diagnostics.Stopwatch();                         // do DB magic                                    // this is hard-coded to warn, if want to change at runtime tough luck!             if (timer.ElapsedMilliseconds > 5000 && _log.IsLogEnabled(ThresholdLogLevel))             {                 _log.LogFormat(ThresholdLogLevel, "Statement {0} took too long to execute.",                     statement);             }             ...         }     } Next time, I'll show one of my favorite uses for these extension methods in an Interceptor.

    Read the article

  • Jquery check if element exists then add class to different element

    - by Buddy
    I don't know much about jquery at all, so bear with my ignorance, but I'm pretty sure I can accomplish this with jquery. I need jquery to check if an element exists, and if so, add a class to a different element. For example, if class "minimal-price-link" exists, then add a class to "regular-price" or what I really am wanting to do is make the regular-price strikethrough. Here's the code: <div class="price-box"> <span class="regular-price" id="product-price-2"> <span class="price">$240.00</span> </span> <a href="http://stemulation.com/order/sfs30.html" class="minimal-price-link"> <span class="label">Your Price:</span> <span class="price" id="product-minimal-price-2">$110.00</span> </a> </div>

    Read the article

  • error C2059: syntax error : ']', i cant figure out why this coming up in c++

    - by user320950
    void display_totals(); int exam1[100][3];// array that can hold 100 numbers for 1st column int exam2[100][3];// array that can hold 100 numbers for 2nd column int exam3[100][3];// array that can hold 100 numbers for 3rd column int main() { int go,go2,go3; go=read_file_in_array; go2= calculate_total(exam1[],exam2[],exam3[]); go3=display_totals; cout << go,go2,go3; return 0; } void display_totals() { int grade_total; grade_total=calculate_total(exam1[],exam2[],exam3[]); } int calculate_total(int exam1[],int exam2[],int exam3[]) { int calc_tot,above90=0, above80=0, above70=0, above60=0,i,j; calc_tot=read_file_in_array(exam[100][3]); exam1[][]=exam[100][3]; exam2[][]=exam[100][3]; exam3[][]=exam[100][3]; for(i=0;i<100;i++); { if(exam1[i] <=90 && exam1[i] >=100) { above90++; cout << above90; } } return exam1[i],exam2[i],exam3[i]; } int read_file_in_array(int exam[100][3]) { ifstream infile; int num, i=0,j=0; infile.open("grades.txt");// file containing numbers in 3 columns if(infile.fail()) // checks to see if file opended { cout << "error" << endl; } while(!infile.eof()) // reads file to end of line { for(i=0;i<100;i++); // array numbers less than 100 { for(j=0;j<3;j++); // while reading get 1st array or element infile >> exam[i][j]; cout << exam[i][j] << endl; } } infile.close(); return exam[i][j]; }

    Read the article

  • CSS Centering Issue - Div Centering appx 15px too far to the right

    - by Sootah
    I have a theme that I'm modifying for my site. I currently have it live on my test domain while I tinker with it before launch. http://www.networkgenius.org The #content-wrap div is centering, but too far to the right for some reason. I've absolutely no idea why it's doing this, especially since everything else is centering properly. What is the problem? I did add a 15px padding to the content-wrap area as I've changed the body's background color to the grey that you see and obviously didn't want the text pressed right up against the edges of the wrapper. Thanks for your help! -Sootah

    Read the article

  • What's a unit test? [closed]

    - by Tyler
    Possible Duplicates: What is unit testing and how do you do it? What is unit testing? I recognize that to 95% of you, this is a very WTF question. So. What's a unit test? I understand that essentially you're attempting to isolate atomic functionality but how do you test for that? When is it necessary? When is it ridiculous? Can you give an example? (Preferably in C? I mostly hear about it from Java devs on this site so maybe this is specific to Object Oriented languages? I really don't know.) I know many programmers swear by unit testing religiously. What's it all about? EDIT: Also, what's the ratio of time you typically spend writing unit tests to time spent writing new code?

    Read the article

  • Convert large raster graphics image(bitmap, PNG, JPEG, etc) to non-vector postscript in C#

    - by Dennis Cheung
    How to convert an large image and embed it into postscript? I used to convert the bitmap into HEX codes and render with colorimage. It works for small icons but I hit a /limitcheck error in ghostscript when I try to embed little larger images. It seem there is a memory limit for bitmap in ghostscript. I am looking a solution which can run without 3rd party/pre-processing other then ghostscript itself.

    Read the article

  • Webservice Jira gives: Error: No such operation 'getIssuesFromJqlSearch' from Jira 4.01

    - by Robert
    When I use the Webservice of Jira, I need to use the method getIssuesFromJqlSearch to describe a certain (JQL) Query. But it returns me "No such operation 'getIssuesFromJqlSearch'". Is this method in Jira 4.01 not implemented yet? BTW: I need a method to get all Issues from one specific project, without creating filters first. This was my first way to find a workaround, because there is no function getIssuesFromProject. If there is no way to fix the problem with the JQL method, I try to take RSS XML View with the URL jql statement like SearchRequest.xml?jqlQuery=project+%3D+Testproject&tempMax=1000. But this is not my favorite.

    Read the article

  • What is the best way to use Unicode in C++ on iPhone?

    - by Olli Wang
    Hi, I want to create my C++ libraries with Unicode support so they can be reused on other platforms. I have found the ICU (International Components for Unicode) project but I also found a discuss about Apple rejecting for using ICU (see http://tinyurl.com/y86phfb). So how do you guys use Unicode in C++ on iPhone? Thanks.

    Read the article

  • ASP.NET Hosting Options

    - by Adam Haile
    I'm not trying to start a "which language is better" argument here, so please don't go there. I typically use PHP for most of my web development (mostly because hosting is cheap), but for various reasons I'm looking to use ASP.NET for a couple new projects. But one of the major reasons I've stayed away from ASP.NET up until now is the cost. I've seen some budget hosting options, but they always seem a little sketchy to me. From what I've generally found, that's just the way the hosting scene looks for ASP.NET unless you want to go dedicated. Does anyone have any good suggestions for a solid ASP.NET host with a good feature set and reliability for my money? Also, are there any options out there along the lines of Amazon's Elastic Compute Cloud? And yes, I know... Mono. I'm talking about Windows based "grid" hosting options?

    Read the article

  • Weird in my UIImagePickerController with camera

    - by Chun
    Hi everyone: I met a problem on using camera by scratch on iphone. Other people's code just run fine on my 3GS. But my code doesn't. When I implemented a UIViewController controller, and I add the following code in viewdidload: UIImagePickerController *picker = [UIImagePickerController alloc] init]; picker.source = UIImagePickerControllerSourceTypeCamera; picker.delegate = self; //Previously added all the delegate properly [self presentModalViewController:picker animated:YES]; Nothing comes out. I checked in the debugger, it shows that the picker is allocated, but here is the major difference between my and success one. picker._imagepickerflag.visible = 0; //others show 1; picker.UINavigationController._containerView: 0x0 ; // others have value. Can anyone help me on this, is there something wrong? Thank you.

    Read the article

  • Configuring Windows 2003 As A Router

    - by Sean M
    I am trying to configure a Windows 2003 server to act as a router, so that the two subnetworks that I'm dealing with can communicate with one another without NAT. I am mostly sure that I have configured Windows 2003 incorrectly, and I'm finding it very difficult to drill down through Google results to something helpful. I have a 192.168.1.0/24 network that is my "production" network (in the sense that I'm in trouble if I screw it up) and a 10.0.0.0/8 network that is my test network. The 192.168.1.0 network is ruled by a gateway whose routing table looks like this (my address redacted): The Windows 2003 server, "prime," is multihomed. Its network adapters are at 192.168.1.122, (as seen above), 10.0.0.1, and 10.0.0.2. I added the Routing and Remote Access role to it, and enabled LAN routing. I do not have it using RIP or other routing protocols. Its current routing table is shown below. To me, it looks like all of the right routes are there for traffic to pass between the 192.168.1.0 network and the 10.0.0.0 network. However, traffic does not pass. The 10.0.0.11 and .12 clients cannot be contacted from the 192.168.1.0 network. When I use traceroute to try to get to them, the trace gets to the Windows 2003 server's 192.168.1.122 address, then produces nothing but "* * *" timeouts. When I try to traceroute to 192.168.1.1 from a 10.0.0.0-network client, I get "destination host unreachable." However, I know that the routing is working at least a little, because from the 192.168.1.0 network, I can connect to the Windows server just fine by referring to it as 10.0.0.1. What static routes would allow me to contact 10.0.0.11 and .12 from the 192.168.1.0 network? Is it possible to tell the Windows server "since you are a DHCP/DNS server, you already know routes to get to machines that are getting IP addresses from you, please add those to your routing table" ? Will using RIP or OSPF on the Windows server actually be helpful in this situation?

    Read the article

  • Take contentd from url and place in container on page

    - by Jackson
    Hi There, I would like to use jQuery to find the last page name / directory from the url and display it on the page in a <h3> container. For example: /_blog/PunkLogic_News/tag/videos/ I would like to display 'videos' in a specific <h3 class="urltag"> on the page. /_blog/PunkLogic_News/tag/Noosa_Biosphere/ I would like to display 'Noosa Biosphere' without the underscore. I suppose all special characters would need to be removed as well. Thanks in advance for your help. Jackson

    Read the article

  • Remove accents from a JSON response.

    - by Pentium10
    I get back a JSON response from a social networks site. There are certain accented characters that I would like to be removed. An example is : L\u00e1szl\u00f3 M\u00e1rton, that reads "László Márton" and I would like to be transformed into Laszlo Marton. I would like to keep the JSON format intact, as I will send it towards. How can I do this?

    Read the article

  • How to hide nested form from jQuery under IE8

    - by pduel
    An html segment with a div containing a form: <div class="hide"> Form header <form action='' method='post'> .... form content here </form> form footer </div> <script type="text/javascript"><!--// $(document).ready(function() { $('.hide').hide(); } //--></script> The jquery should hide the form, but does not do so under IE8. (version 8.0.60001) The form content gets hidden, as does the content within the class='hide' div but outside the form, but the form border continues to show, and retains its size. Does anybody have a workaround for this? jQuery is version 1.4.2 I tried to create a small problem demo in jsfiddle, but that site was not functional in the IE browser.

    Read the article

  • Problem calling Java from PHP script

    - by Jack
    I am working on windows. I am running PHP (5.1.3) scripts on Tomcat using PHP/Java bridge. Here is my simple code //test.php <?php require_once("java\Java.inc"); $systemInfo = new Java("Test"); print $systemInfo->foo(); ?> Test.class is in the same folder as test.php. But the php file is not able to locate the test class and I get the following error - Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: CreateInstance failed: new Test. If I use a standard class like below. It works - <?php require_once("java\Java.inc"); $systemInfo = new Java("java.lang.System"); print "Total seconds since January 1, 1970: ".$systemInfo->currentTimeMillis(); ?> What should I do? 1)Should I copy my class to the standard location where all Java classes are kept. (What is this location?) 2) Do some changes in the php.ini file

    Read the article

  • My Core Animation block isn't working as I'd expect

    - by Alex Reynolds
    I have a UIView called activityView, which contains two subviews activityIndicator and cancelOperationsButton. These views are embedded in a XIB and wired up to my view controller. I have two methods that deal with activating (showing) and deactivating (hiding) these two subviews: - (void) enableActivityIndicator { [activityIndicator startAnimating]; [cancelOperationsButton setHidden:NO]; } - (void) disableActivityIndicator { [activityIndicator stopAnimating]; [cancelOperationsButton setHidden:YES]; } By themselves, these two methods work fine. To give this a bit of polish, I'd like to add an animation that fades these subviews in and out: - (void) enableActivityIndicator { [activityIndicator startAnimating]; [cancelOperationsButton setHidden:NO]; [UIView beginAnimations:@"fadeIn" context:nil]; [UIView setAnimationDelay:0.0f]; [UIView setAnimationDuration:1.0f]; [UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; activityView.alpha = 1.0f; [UIView commitAnimations]; } - (void) disableActivityIndicator { [UIView beginAnimations:@"fadeOut" context:nil]; [UIView setAnimationDelay:0.0f]; [UIView setAnimationDuration:1.0f]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; activityView.alpha = 0.0f; [UIView commitAnimations]; [activityIndicator stopAnimating]; [cancelOperationsButton setHidden:YES]; } But the animations are not working — the subviews just show up or disappear without the parent view's alpha property having an effect on transparency. How should I write these methods to get the fade-in, fade-out effect I am after?

    Read the article

  • Char * reallocation in C++

    - by JTom
    Hi, I need to store a certain amount of data in the "char *" in C++, because I want to avoid std::string to run out of memory, when exceeding max_size(). But the data comes in data blocks from the network so I need to use reallocation every time I get the data block. Is there any elegant solution for char * reallocation and concatenation in C++?

    Read the article

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